cvs: doc-editor /js main.js /js/locale fr.js /php ExtJsController.php ToolsError.php class.php
| From: | Yannick Torres | Date: | Mon, 27 Apr 2009 05:09:58 +0000 |
| Subject: | cvs: doc-editor /js main.js /js/locale fr.js /php ExtJsController.php ToolsError.php class.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-3889@lists.php.net to get a copy of this message | ||
yannick Mon Apr 27 05:09:58 2009 UTC
Modified files:
/doc-editor/js/locale fr.js
/doc-editor/js main.js
/doc-editor/php class.php ExtJsController.php ToolsError.php
Log:
- modules "NotInEn" should work now
- modify the way we commit files (update, delete and new are now supported)
http://cvs.php.net/viewvc.cgi/doc-editor/js/locale/fr.js?r1=1.12&r2=1.13&diff_format=u Index: doc-editor/js/locale/fr.js diff -u doc-editor/js/locale/fr.js:1.12 doc-editor/js/locale/fr.js:1.13 --- doc-editor/js/locale/fr.js:1.12 Sat Apr 25 16:50:01 2009 +++ doc-editor/js/locale/fr.js Mon Apr 27 05:09:57 2009 @@ -130,7 +130,7 @@ i18n["Your filter must contain at least 3 characters"] = "Votre filtre doit comporter au moins 3 caractères"; i18n["Not in EN tree"] = "Non présent en EN"; i18n["Remove this file"] = "Supprimer ce fichier"; - +i18n["This action will mark this file as need deleted.<br/><br/>You need commit this change to take it effect.<br/><br/>Please, confirm this action."] = "Voulez-vous marquer ce fichier comme devant être effacé ?<br/><br/>L'effacement sera effectif qu'une fois le commit émis.<br/><br/>Vous devez confirmer cette action."; // Main Menu i18n["Main Menu"] = "Menu principal"; http://cvs.php.net/viewvc.cgi/doc-editor/js/main.js?r1=1.52&r2=1.53&diff_format=u Index: doc-editor/js/main.js diff -u doc-editor/js/main.js:1.52 doc-editor/js/main.js:1.53 --- doc-editor/js/main.js:1.52 Sat Apr 25 08:38:45 2009 +++ doc-editor/js/main.js Mon Apr 27 05:09:57 2009 @@ -43,7 +43,7 @@ userLang: '', appName: 'PhpDocumentation Online Editor', appVer: '0.2', - uiRevision: '$Revision: 1.52 $', + uiRevision: '$Revision: 1.53 $', userConf: { 'conf_needupdate_diff': 'using-exec', @@ -433,6 +433,9 @@ }, { name: 'name', mapping: 'name' + }, { + name: 'needcommit', + mapping: 'needcommit' }]), sortInfo: { field: 'path', @@ -1060,6 +1063,107 @@ GoToNode(this.treeAllFilesRoot, this); }, //openFile + + clearLocalChange: function(FileType, FilePath, FileName, rowIndex, scope) { + + if (scope.userLogin === 'cvsread') { + scope.winForbidden(); + return; + } + + function goClearChange(btn){ + if (btn === 'yes') { + + Ext.getBody().mask('<img src="themes/img/loading.gif" style="vertical-align: middle;" /> '+_('Please, wait...')); + + // Before clear local change, we close the file if there is open + if (Ext.getCmp('main-panel').findById('FNU-' + Ext.util.md5('FNU-' + FilePath + FileName))) { + Ext.getCmp('main-panel').remove('FNU-' + Ext.util.md5('FNU-' + FilePath + FileName)); + } + + // + Ext.Ajax.request({ + scope: scope, + url: './php/controller.php', + params: { + task: 'clearLocalChange', + FileType: FileType, + FilePath: FilePath, + FileName: FileName + }, + success: function(a){ + var o = Ext.util.JSON.decode(a.responseText); + if (o.success) { + + var node; + + if (this.userLang === 'en') { + // We reload all store + this.storeFilesNeedUpdate.reload(); + this.storeFilesError.reload(); + this.storeFilesNeedReviewed.reload(); + } + + // We delete from this store + this.storePendingCommit.remove(this.storePendingCommit.getAt(rowIndex)); + + // We fire event add to update the file count + this.storePendingCommit.fireEvent('add', this.storePendingCommit); + + // We try to search in others stores if this file is marked as needCommit + + // trow storeNotInEn + this.storeNotInEn.each(function(record){ + if ((this.userLang+record.data.path) === FilePath && record.data.name === FileName) { + record.set('needcommit', false); + } + }, this); + + // trow storeFilesNeedReviewed + this.storeFilesNeedReviewed.each(function(record){ + if ((this.userLang+record.data.path) === FilePath && record.data.name === FileName) { + record.set('needcommit', false); + } + }, this); + + // trow storeFilesNeedUpdate + this.storeFilesNeedUpdate.each(function(record){ + if ((this.userLang+record.data.path) === FilePath && record.data.name === FileName) { + record.set('needcommit', false); + } + }, this); + + // trow FileError + this.storeFilesError.each(function(record){ + if ((this.userLang+record.data.path) === FilePath && record.data.name === FileName) { + record.set('needcommit', false); + } + }, this); + + // find open node in All Files modules + node = this.treeAllFiles.getNodeById('//'+FilePath+FileName); + if( node ) { + node.getUI().removeClass('modified'); + } + Ext.getBody().unmask(); + } + else { + Ext.getBody().unmask(); + this.winForbidden(); + } + + }, + failure: function(){ + + } + }); + } + } + + Ext.MessageBox.confirm(_('Confirm'), _('This action will clear your local modification and take back this file from his original stats.<br/>You need confirm.'), goClearChange, scope); + + }, //clearLocalChange + rejectPatch: function(FileID, FilePath, FileName, FileUniqID, rowIndex, scope){ if (scope.userLogin === 'cvsread') { @@ -1141,7 +1245,7 @@ if (o.success) { // Add this files into storePendingCommit - this.addToPendingCommit(FilePath, FileName, 'update'); + this.addToPendingCommit(o.id, FilePath, FileName, 'update'); // Remove this patch from the PendingPatchStore this.storePendingPatch.remove(this.storePendingPatch.getAt(rowIndex)); @@ -1227,7 +1331,7 @@ } // Add this files into storePendingCommit - this.addToPendingCommit("en" + FilePath, FileName, 'update'); + this.addToPendingCommit(o.id, "en" + FilePath, FileName, 'update'); // Remove wait msg msg.hide(); @@ -1417,7 +1521,7 @@ } // Add this files into storePendingCommit - this.addToPendingCommit(this.userLang + FilePath, FileName, 'update'); + this.addToPendingCommit(o.id, this.userLang + FilePath, FileName, 'update'); // Remove wait msg msg.hide(); @@ -1526,7 +1630,7 @@ } // Add this files into storePendingCommit - this.addToPendingCommit(this.userLang + FilePath, FileName, 'update'); + this.addToPendingCommit(o.id, this.userLang + FilePath, FileName, 'update'); } else { this.winForbidden(); @@ -1626,7 +1730,7 @@ this.storePendingPatch.insert(0, r); }, //addToPendingPatch - addToPendingCommit: function(FilePath, FileName, type){ + addToPendingCommit: function(FileID, FilePath, FileName, type){ var alReady, dt, r1; @@ -1645,7 +1749,7 @@ dt = new Date(); r1 = new this.storePendingCommit.recordType({ - id: Ext.id('', ''), + id: FileID, path: FilePath, name: FileName, by: this.userLogin, @@ -1653,6 +1757,7 @@ type: type }); this.storePendingCommit.insert(0, r1); + this.storePendingCommit.groupBy('path', true); } }, //addToPendingCommit @@ -1836,7 +1941,7 @@ }, //removeTabEvent WinCommit: function(singleFile, rowIndex, choice){ - var win, btn, FileID, FilePath, FileName, node, TreeSorter; + var win, btn, FileDBID, FileID, FilePath, FileName, node, TreeSorter; btn = Ext.get('acc-need-update'); @@ -2050,9 +2155,7 @@ NeedToBeClose = []; for (i = 0; i < files.length; i = i + 1) { - - //var checkNode, paneID_FE, paneID_FNU, paneID_FNR, tmp = [], paneID, libelNeedToBeClose = ''; - + checkNode = Ext.getCmp('tree-panel').getNodeById(files[i]).attributes; paneID_FE = 'FE-' + Ext.util.md5('FE-' + checkNode.FilePath + checkNode.FileName); @@ -2132,6 +2235,7 @@ // Just the current file + FileDBID = this.storePendingCommit.getAt(rowIndex).data.id; FilePath = this.storePendingCommit.getAt(rowIndex).data.path; FileName = this.storePendingCommit.getAt(rowIndex).data.name; FileID = Ext.util.md5(FilePath + FileName); @@ -2139,6 +2243,7 @@ node = new Ext.tree.TreeNode({ id: 'need-commit-' + FileID, text: FilePath + FileName, + FileDBID: FileDBID, FilePath: FilePath, FileName: FileName, leaf: true, @@ -2158,6 +2263,7 @@ } else { + FileDBID = record.data.id; FilePath = record.data.path; FileName = record.data.name; FileID = Ext.util.md5(FilePath + FileName); @@ -2165,9 +2271,9 @@ node = new Ext.tree.TreeNode({ id: 'need-commit-' + FileID, text: FilePath + FileName, + FileDBID: FileDBID, FilePath: FilePath, FileName: FileName, - //fileLang : this.userLang, leaf: true, checked: true, uiProvider: Ext.ux.tree.CheckTreeNodeUI @@ -2189,17 +2295,13 @@ Ext.getBody().mask('<img src="themes/img/loading.gif" style="vertical-align: middle;" /> '+_('Please, wait until commit...')); - var nodes = [], node, tmp, LogMessage, i; + var nodes = [], node, LogMessage, i; // Go for Cvs commit for (i = 0; i < files.length; i = i + 1) { node = Ext.getCmp('tree-panel').getNodeById(files[i]); - tmp = []; - - tmp[0] = node.attributes.FilePath; - tmp[1] = node.attributes.FileName; - nodes.push(tmp); + nodes.push(node.attributes.FileDBID); } // Get log message @@ -2233,7 +2335,7 @@ modal: true, autoScroll: true, bodyStyle: 'background-color: white; padding: 5px;', - html: o.mess.join("<br>"), + html: o.mess.join("<br/>"), buttons: [{ text: _('Close'), handler: function(){ @@ -5196,7 +5298,12 @@ view: new Ext.grid.GroupingView({ forceFit: true, groupTextTpl: '{[values.rs[0].data["path"]]} ({[values.rs.length]} {[values.rs.length > 1 ? "'+_('Files')+'" : "'+_('File')+'"]})', - emptyText: '<div style="text-align: center;">'+_('No Files')+'</div>' + emptyText: '<div style="text-align: center;">'+_('No Files')+'</div>', + getRowClass: function(record, numIndex, rowParams, store){ + if (record.data.needcommit) { + return 'file-need-commit'; + } + } }), autoExpandColumn: 'name', bodyBorder: false, @@ -5205,19 +5312,56 @@ rowcontextmenu: function(grid, rowIndex, e){ grid.getSelectionModel().selectRow(rowIndex); - - var menu = new Ext.menu.Menu({ - items: [{ - text: _('Remove this file'), - iconCls: 'iconDelete', - scope: this, - handler: function(){ - - } - }] - }); - menu.showAt(e.getXY()); + if( !this.storeNotInEn.getAt(rowIndex).data.needcommit ) { + + var menu = new Ext.menu.Menu({ + items: [{ + text: _('Remove this file'), + iconCls: 'iconDelete', + scope: this, + handler: function(){ + gridNotInEn.fireEvent('rowdblclick', grid, rowIndex, e); + } + }] + }); + menu.showAt(e.getXY()); + + } + + }, + rowdblclick: function(grid, rowIndex, e){ + + var FilePath, FileName, FileID; + + FilePath = this.storeNotInEn.getAt(rowIndex).data.path; + FileName = this.storeNotInEn.getAt(rowIndex).data.name; + + function goMarkAsDelete(btn){ + if (btn === 'yes') { + Ext.getBody().mask('<img src="themes/img/loading.gif" style="vertical-align: middle;" /> '+_('Please, wait...')); + + Ext.Ajax.request({ + scope: this, + url: './php/controller.php', + params: { + task: 'markAsNeedDelete', + FilePath: FilePath, + FileName: FileName + }, + success: function(action){ + var o = Ext.util.JSON.decode(action.responseText); + if (o.success) { + Ext.getBody().unmask(); + this.addToPendingCommit( o.id, this.userLang + FilePath, FileName, 'delete' ); + this.storeNotInEn.getAt(rowIndex).set('needcommit', true); + } + } + }); + } + } + + Ext.MessageBox.confirm(_('Confirm'), _('This action will mark this file as need deleted.<br/><br/>You need commit this change to take it effect.<br/><br/>Please, confirm this action.'), goMarkAsDelete, this); } } }); @@ -5270,214 +5414,155 @@ scope: this, 'rowcontextmenu': function(grid, rowIndex, e){ - var FilePath, FileName, menu; + var FileType, FilePath, FileName, menu, subMenuCommit; + FileType = this.storePendingCommit.getAt(rowIndex).data.type; FilePath = this.storePendingCommit.getAt(rowIndex).data.path; FileName = this.storePendingCommit.getAt(rowIndex).data.name; grid.getSelectionModel().selectRow(rowIndex); - menu = new Ext.menu.Menu({ - items: [{ - text: '<b>'+_('Edit in a new Tab')+'</b>', - iconCls: 'PendingCommit', - scope: this, - handler: function(){ - gridPendingCommit.fireEvent('rowdblclick', grid, rowIndex, e); - } - }, '-', { - text: _('View Diff'), - iconCls: 'iconViewDiff', - scope: this, - handler: function(){ - - // Add tab for the diff - Ext.getCmp('main-panel').add({ - xtype: 'panel', - id: 'diff_panel_' + rowIndex, - title: _('Diff'), - tabTip: _('Diff'), - closable: true, - autoScroll: true, - iconCls: 'iconTabLink', - html: '<div id="diff_content_' + rowIndex + '" class="diff-content"></div>' - }); - Ext.getCmp('main-panel').setActiveTab('diff_panel_' + rowIndex); - - Ext.get('diff_panel_' + rowIndex).mask('<img src="themes/img/loading.gif" style="vertical-align: middle;" /> '+_('Please, wait...')); - - // Load diff data - Ext.Ajax.request({ - url: './php/controller.php', - params: { - task: 'getDiff', - FilePath: FilePath, - FileName: FileName - }, - success: function(action){ - var o = Ext.util.JSON.decode(action.responseText); - if (o.success) { - // We display in diff div - Ext.get('diff_content_' + rowIndex).dom.innerHTML = o.content; - Ext.get('diff_panel_' + rowIndex).unmask(); - - } - - }, - failure: function(){ - - } - }); - - - } - }, { - text: _('Download the diff as a patch'), - iconCls: 'iconCommitFileCvs', - scope: this, - handler: function(){ - window.location.href = './php/controller.php?task=downloadPatch&FilePath=' + FilePath + '&FileName=' + FileName; - } - }, '-', { - text: _('Clear this change'), - iconCls: 'iconPageDelete', - disabled: (this.userLogin === 'cvsread') ? true : false, - scope: this, - handler: function(){ - - if (this.userLogin === 'cvsread') { - this.winForbidden(); - return; + subMenuCommit = { + text: _('Commit...'), + iconCls: 'iconCommitFileCvs', + scope: this, + handler: function(){ + return false; + }, + disabled: (this.userLogin === 'cvsread') ? true : false, + menu: new Ext.menu.Menu({ + items: [{ + text: _('...this file'), + iconCls: 'iconCommitFileCvs', + scope: this, + handler: function(){ + this.WinCommit(true, rowIndex); } - - function goClearChange(btn){ - if (btn === 'yes') { - - Ext.getBody().mask('<img src="themes/img/loading.gif" style="vertical-align: middle;" /> '+_('Please, wait...')); - - // Before clear local change, we close the file if there is open - if (Ext.getCmp('main-panel').findById('FNU-' + Ext.util.md5('FNU-' + FilePath + FileName))) { - Ext.getCmp('main-panel').remove('FNU-' + Ext.util.md5('FNU-' + FilePath + FileName)); - } - - // - Ext.Ajax.request({ - scope: this, - url: './php/controller.php', - params: { - task: 'clearLocalChange', - FilePath: FilePath, - FileName: FileName - }, - success: function(action){ - var o = Ext.util.JSON.decode(action.responseText); - if (o.success) { - - var node; - - if (this.userLang === 'en') { - // We reload all store - this.storeFilesNeedUpdate.reload(); - this.storeFilesError.reload(); - this.storeFilesNeedReviewed.reload(); - } - - // We delete from this store - this.storePendingCommit.remove(this.storePendingCommit.getAt(rowIndex)); - - // We fire event add to update the file count - this.storePendingCommit.fireEvent('add', this.storePendingCommit); - - // We try to search in others stores if this file is marked as needCommit - - // trow storeFilesNeedReviewed - this.storeFilesNeedReviewed.each(function(record){ - if ((this.userLang+record.data.path) === FilePath && record.data.name === FileName) { - record.set('needcommit', false); - } - }, this); + }, { + text: _('...all files modified by me'), + iconCls: 'iconCommitFileCvs', + scope: this, + handler: function(){ + this.WinCommit(false, '', 'by me'); + } + }, { + text: _('...all files modified'), + iconCls: 'iconCommitFileCvs', + scope: this, + handler: function(){ + this.WinCommit(false); + } + }] + }) + }; - // trow storeFilesNeedUpdate - this.storeFilesNeedUpdate.each(function(record){ - if ((this.userLang+record.data.path) === FilePath && record.data.name === FileName) { - record.set('needcommit', false); - } - }, this); + if( FileType === 'delete' ) { - // trow FileError - this.storeFilesError.each(function(record){ - if ((this.userLang+record.data.path) === FilePath && record.data.name === FileName) { - record.set('needcommit', false); - } - }, this); + menu = new Ext.menu.Menu({ + items: [{ + text: '<b>' + _('Cancel') + '<b>', + iconCls: 'iconPageDelete', + disabled: (this.userLogin === 'cvsread') ? true : false, + scope: this, + handler: function(){ + gridPendingCommit.fireEvent('rowdblclick', grid, rowIndex, e); + } + }, '-', subMenuCommit] + }); + } - // find open node in All Files modules - node = this.treeAllFiles.getNodeById('//'+FilePath+FileName); - if( node ) { - node.getUI().removeClass('modified'); - } - Ext.getBody().unmask(); - } - else { - Ext.getBody().unmask(); - this.winForbidden(); - } + if( FileType === 'update' ) { + menu = new Ext.menu.Menu({ + items: [{ + text: '<b>'+_('Edit in a new Tab')+'</b>', + iconCls: 'PendingCommit', + scope: this, + handler: function(){ + gridPendingCommit.fireEvent('rowdblclick', grid, rowIndex, e); + } + }, '-', { + text: _('View Diff'), + iconCls: 'iconViewDiff', + scope: this, + handler: function(){ + + // Add tab for the diff + Ext.getCmp('main-panel').add({ + xtype: 'panel', + id: 'diff_panel_' + rowIndex, + title: _('Diff'), + tabTip: _('Diff'), + closable: true, + autoScroll: true, + iconCls: 'iconTabLink', + html: '<div id="diff_content_' + rowIndex + '" class="diff-content"></div>' + }); + Ext.getCmp('main-panel').setActiveTab('diff_panel_' + rowIndex); + + Ext.get('diff_panel_' + rowIndex).mask('<img src="themes/img/loading.gif" style="vertical-align: middle;" /> '+_('Please, wait...')); + + // Load diff data + Ext.Ajax.request({ + url: './php/controller.php', + params: { + task: 'getDiff', + FilePath: FilePath, + FileName: FileName + }, + success: function(action){ + var o = Ext.util.JSON.decode(action.responseText); + if (o.success) { + // We display in diff div + Ext.get('diff_content_' + rowIndex).dom.innerHTML = o.content; + Ext.get('diff_panel_' + rowIndex).unmask(); - }, - failure: function(){ - } - }); - } + + }, + failure: function(){ + + } + }); + } - - Ext.MessageBox.confirm(_('Confirm'), _('This action will clear your local modification and take back this file from his original stats.<br/>You need confirm.'), goClearChange, this); - } - }, '-', { - text: _('Commit...'), - iconCls: 'iconCommitFileCvs', - scope: this, - handler: function(){ - return false; - }, - disabled: (this.userLogin === 'cvsread') ? true : false, - menu: new Ext.menu.Menu({ - items: [{ - text: _('...this file'), - iconCls: 'iconCommitFileCvs', - scope: this, - handler: function(){ - this.WinCommit(true, rowIndex); - } - }, { - text: _('...all files modified by me'), - iconCls: 'iconCommitFileCvs', - scope: this, - handler: function(){ - this.WinCommit(false, '', 'by me'); - } - }, { - text: _('...all files modified'), - iconCls: 'iconCommitFileCvs', - scope: this, - handler: function(){ - this.WinCommit(false); - } - }] - }) - }] - }); + }, { + text: _('Download the diff as a patch'), + iconCls: 'iconCommitFileCvs', + scope: this, + handler: function(){ + window.location.href = './php/controller.php?task=downloadPatch&FilePath=' + FilePath + '&FileName=' + FileName; + } + }, '-', { + text: _('Clear this change'), + iconCls: 'iconPageDelete', + disabled: (this.userLogin === 'cvsread') ? true : false, + scope: this, + handler: function(){ + this.clearLocalChange(FileType, FilePath, FileName, rowIndex, this); + } + }, '-', subMenuCommit] + }); + + } + menu.showAt(e.getXY()); }, 'rowdblclick': function(grid, rowIndex, e){ - var FilePath, FileName; + var FileType, FilePath, FileName; + FileType = this.storePendingCommit.getAt(rowIndex).data.type; FilePath = this.storePendingCommit.getAt(rowIndex).data.path; FileName = this.storePendingCommit.getAt(rowIndex).data.name; - - this.openFile(FilePath, FileName); - + + if( FileType === 'update' ) { + this.openFile(FilePath, FileName); + } + + if( FileType === 'delete' ) { + this.clearLocalChange(FileType, FilePath, FileName, rowIndex, this); + } + } //rowdblclick } //listeners }); @@ -7048,7 +7133,7 @@ node.getUI().addClass('modified'); // Add this files into storePendingCommit - this.addToPendingCommit(FilePath, FileName, 'update'); + this.addToPendingCommit(o.id, FilePath, FileName, 'update'); // Remove wait msg msg.hide(); http://cvs.php.net/viewvc.cgi/doc-editor/php/class.php?r1=1.44&r2=1.45&diff_format=u Index: doc-editor/php/class.php diff -u doc-editor/php/class.php:1.44 doc-editor/php/class.php:1.45 --- doc-editor/php/class.php:1.44 Sat Apr 25 16:48:09 2009 +++ doc-editor/php/class.php Mon Apr 27 05:09:57 2009 @@ -814,6 +814,33 @@ } /** + * Get modified files by ID. + * @param $id Can be a single ID or an array of id + * @return An associated array containing all informations about modified files. + */ + function getModifiedFilesById($id) { + + if( is_array($id) ) { + $ids = implode($id, ','); + } else { + $ids = $id; + } + + $s = sprintf('SELECT * FROM `pendingCommit` WHERE + (`lang`="%s" OR `lang`="en") AND `id` IN (%s)', $this->cvsLang, $ids); + + $r = $this->db->query($s) or die('Error: '.$this->db->error.'|'.$s); + + $nodes = array(); + + while ($a = $r->fetch_assoc()) { + $nodes[] = $a; + } + + return $nodes; + } + + /** * Get all files witch need to be updated. * * @return An associated array containing all informations about files witch need to be updated. @@ -922,12 +949,15 @@ } /** - * Get all witch are not in EN tree. + * Get all files witch are not in EN tree. * * @return An associated array containing all informations about files witch are not in EN tree */ function getFilesNotInEn() { + // Get Files Need Commit + $ModifiedFiles = $this->getModifiedFiles(); + $s = sprintf('SELECT `id`, `path`, `name` FROM `files` WHERE `lang`="%s" AND `status`=\'NotInEN\'', $this->cvsLang); $r = $this->db->query($s) or die('Error: '.$this->db->error.'|'.$s); @@ -935,8 +965,15 @@ $node = array(); - while ($row = $r->fetch_assoc()) { - $node[] = $row; + while ($a = $r->fetch_object()) { + + $node[] = array( + "id" => $a->id, + "path" => $a->path, + "name" => $a->name, + "needcommit" => ( isset($ModifiedFiles[$this->cvsLang.$a->path.$a->name]) ) ? true : false + ); + } return array('nb' => $nb, 'node' => $node); @@ -1536,7 +1573,7 @@ $this->db->query($s) or die('Error: '.$this->db->error.'|'.$s); $fileID = $a->id; } - + return $fileID; } /** @@ -1808,11 +1845,12 @@ /** * Delete local change of a file. * + * @param $type The type of the file. Can be 'update', 'delete' or new' * @param $path The path of the file. * @param $file The name of the file. * @return An array witch contain informations about this file. */ - function clearLocalChange($path, $file) { + function clearLocalChange($type, $path, $file) { // Extract the lang $t = explode('/',$path); @@ -1831,6 +1869,11 @@ $s = sprintf('DELETE FROM `pendingCommit` WHERE `id`="%s"', $a->id); $this->db->query($s) or die('Error: '.$this->db->error.'|'.$s); + // If type == delete or new, we stop here and return + if( $type == 'delete' || $type == 'new' ) { + return; + } + // We need delete file on filesystem $doc = DOC_EDITOR_CVS_PATH.$lang.$path.$file.".new"; @@ -1843,7 +1886,13 @@ $info = $this->getInfoFromContent($lang_content); - $anode[0] = array( 0 => $lang.$path, 1 => $file, 2 => $en_content, 3 => $lang_content, 4 => $info['maintainer']); + $anode[0] = array( 'lang' => $lang, + 'path' => $path, + 'name' => $file, + 'en_content' => $en_content, + 'lang_content' => $lang_content, + 'maintainer' => $info['maintainer'] + ); $errorTools = new ToolsError($this->db); $error = $errorTools->updateFilesError($anode, 'nocommit'); @@ -1880,27 +1929,69 @@ */ function cvsCommit($anode, $log) { - $files = ''; + $filesUpdate = array(); + $filesDelete = array(); + $filesNew = array(); - for ($i = 0; $i < count($anode); $i++ ) { + $cmdUpdate = ''; + $cmdDelete = ''; + $cmdNew = ''; - // We need move .new file into the real file - @unlink( DOC_EDITOR_CVS_PATH.$anode[$i][0].$anode[$i][1]); - @copy( DOC_EDITOR_CVS_PATH.$anode[$i][0].$anode[$i][1].'.new', DOC_EDITOR_CVS_PATH.$anode[$i][0].$anode[$i][1]); - @unlink( DOC_EDITOR_CVS_PATH.$anode[$i][0].$anode[$i][1].'.new'); + $nodes = $this->getModifiedFilesById($anode); - $files .= $anode[$i][0].$anode[$i][1].' '; + // Loop over $nodes to find files to be delete, update, or new + reset($nodes); + for( $i=0; $i < count($nodes); $i++) { + $fullPath = $nodes[$i]['lang'].$nodes[$i]['path'].$nodes[$i]['name']; + + if( $nodes[$i]['type'] == 'delete' ) { + $filesDelete[] = $fullPath; + } + + if( $nodes[$i]['type'] == 'update' ) { + + $filesUpdate[] = $fullPath; + + // Pre-commit : We need move .new file into the real file + @unlink( DOC_EDITOR_CVS_PATH.$fullPath); + @copy( DOC_EDITOR_CVS_PATH.$fullPath.'.new', DOC_EDITOR_CVS_PATH.$fullPath); + @unlink( DOC_EDITOR_CVS_PATH.$fullPath.'.new'); + + } + + if( $nodes[$i]['type'] == 'new' ) { + $filesNew[] = $fullPath; + } + } + + // Linearization + $filesDelete = implode($filesDelete, ' '); + $filesUpdate = implode($filesUpdate, ' '); + $filesNew = implode($filesNew, ' '); + + // Buil the command line + if( trim($filesDelete) != '' ) { + $cmdDelete = 'cvs -d :pserver:'.$this->cvsLogin.':'.$this->cvsPasswd.'@cvs.php.net:/repository -f remove -f '.$filesDelete.' && '; + } + if( trim($filesNew) != '' ) { + $cmdNew = 'cvs -d :pserver:'.$this->cvsLogin.':'.$this->cvsPasswd.'@cvs.php.net:/repository -f add '.$filesNew.' && '; } + // Escape single quote $log = str_replace("'", "\\'", $log); + $cmd = $cmdDelete. + $cmdNew. + 'cvs -d :pserver:'.$this->cvsLogin.':'.$this->cvsPasswd.'@cvs.php.net:/repository -f commit -l -m \''.$log.'\' '.$filesUpdate.' '.$filesDelete.' '.$filesNew; + // First, login into Cvs - $cmd = 'export CVS_PASSFILE='.realpath(DOC_EDITOR_DATA_PATH).'/.cvspass && cd '.DOC_EDITOR_CVS_PATH.' && cvs -d :pserver:'.$this->cvsLogin.':'.$this->cvsPasswd.'@cvs.php.net:/repository login && cvs -d :pserver:'.$this->cvsLogin.':'.$this->cvsPasswd.'@cvs.php.net:/repository -f commit -l -m \''.$log.'\' '.$files; + $fullCmd = 'export CVS_PASSFILE='.realpath(DOC_EDITOR_DATA_PATH).'/.cvspass && cd '.DOC_EDITOR_CVS_PATH.' && cvs -d :pserver:'.$this->cvsLogin.':'.$this->cvsPasswd.'@cvs.php.net:/repository login && '.$cmd; + $output = array(); - exec($cmd, $output); + exec($fullCmd, $output); - //$this->debug('commit cmd : '.$cmd); + //$this->debug('commit cmd : '.$fullCmd); return $this->highlightCommitLog($output); } @@ -1921,24 +2012,21 @@ /** * Update information about a file after his commit (update informations added with revcheck tools). * - * @param $anode An array of files. + * @param $nodes An array of files. */ - function updateRev($anode) { + function updateRev($nodes) { - for ($i = 0; $i < count($anode); $i++ ) { + for ($i = 0; $i < count($nodes); $i++ ) { - $t = explode("/", $anode[$i][0]); + $FileLang = $nodes[$i]['lang']; - $FileLang = $t[0]; - array_shift($t); - - $FilePath = implode("/", $t); - $FileName = $anode[$i][1]; + $FilePath = $nodes[$i]['path']; + $FileName = $nodes[$i]['name']; //En file ? if ($FileLang == 'en' ) { - $path = DOC_EDITOR_CVS_PATH.'en/'.$FilePath.$FileName; + $path = DOC_EDITOR_CVS_PATH.'en'.$FilePath.$FileName; $content = file_get_contents($path); $info = $this->getInfoFromContent($content); $size = intval(filesize($path) / 1024); @@ -1953,7 +2041,7 @@ WHERE `lang` = "%s" AND - `path` = \'/%s\' AND + `path` = "%s" AND `name` = "%s" ',$info['rev'], $size, $date, $FileLang, $FilePath, $FileName); $this->db->query($s) or die($this->db->error.'|'.$s); @@ -1965,7 +2053,7 @@ WHERE `lang` != "%s" AND - `path` = \'/%s\' AND + `path` = "%s" AND `name` = "%s" ', $info['rev'], $FileLang, $FilePath, $FileName); $this->db->query($s) or die($this->db->error.'|'.$s); @@ -1973,14 +2061,14 @@ } else { - $path = DOC_EDITOR_CVS_PATH.$FileLang.'/'.$FilePath.$FileName; + $path = DOC_EDITOR_CVS_PATH.$FileLang.$FilePath.$FileName; $content = file_get_contents($path); $info = $this->getInfoFromContent($content); $size = intval(filesize($path) / 1024); $date = filemtime($path); - $pathEN = DOC_EDITOR_CVS_PATH.'en/'.$FilePath.$FileName; + $pathEN = DOC_EDITOR_CVS_PATH.'en'.$FilePath.$FileName; $sizeEN = intval(filesize($pathEN) / 1024); $dateEN = filemtime($pathEN); @@ -1999,9 +2087,9 @@ `mdate_diff` = "%s" WHERE - `lang`="%s" AND - `path`=\'/%s\' AND - `name`="%s" + `lang` = "%s" AND + `path` = "%s" AND + `name` = "%s" ',$info['en-rev'], $info['reviewed'], $size, $date, $info['maintainer'], $info['status'], $size_diff, $date_diff, $FileLang, $FilePath, $FileName); $this->db->query($s) or die($this->db->error.'|'.$s); } @@ -2014,24 +2102,20 @@ /** * Remove the mark "needCommit" into DB for a set of files. * - * @param $anode An array of files. + * @param $nodes An array of files. */ - function removeNeedCommit($anode) { - - for ($i = 0; $i < count($anode); $i++ ) { + function removeNeedCommit($nodes) { - $t = explode("/", $anode[$i][0]); + for ($i = 0; $i < count($nodes); $i++ ) { - $FileLang = $t[0]; - array_shift($t); - - $FilePath = implode("/", $t); - $FileName = $anode[$i][1]; + $FileLang = $nodes[$i]['lang']; + $FilePath = $nodes[$i]['path']; + $FileName = $nodes[$i]['name']; $s = sprintf('DELETE FROM `pendingCommit` WHERE `lang` = "%s" AND - `path` = \'/%s\' AND + `path` = "%s" AND `name` = "%s" ', $FileLang, $FilePath, $FileName); @@ -2381,6 +2465,26 @@ return; - } // + } + + /** + * Mark a file as need delete. + * + * @param $FilePath + * @param $FileName + * @return + */ + function markAsNeedDelete($FilePath, $FileName) + { + + $date = date("Y-m-d H:i:s"); + + $s = sprintf('INSERT INTO `pendingCommit` (`lang`, `path`, `name`, `revision`, `en_revision`, `reviewed`, `maintainer`, `modified_by`, `date`, `type`) VALUES ("%s","%s", "%s", "-", "-", "-", "-", "%s", "%s", "delete")', $this->cvsLang, $FilePath, $FileName, $this->cvsLogin, $date); + $this->db->query($s) or die('Error: '.$this->db->error.'|'.$s); + + return Array('id'=>$this->db->insert_id, 'by'=>$this->cvsLogin, 'date'=>$date); + + } + } // End of class http://cvs.php.net/viewvc.cgi/doc-editor/php/ExtJsController.php?r1=1.25&r2=1.26&diff_format=u Index: doc-editor/php/ExtJsController.php diff -u doc-editor/php/ExtJsController.php:1.25 doc-editor/php/ExtJsController.php:1.26 --- doc-editor/php/ExtJsController.php:1.25 Sat Apr 25 16:17:40 2009 +++ doc-editor/php/ExtJsController.php Mon Apr 27 05:09:57 2009 @@ -354,13 +354,17 @@ // Update DB with this new Error (if any) $info = $this->phpDoc->getInfoFromContent($FileContent); - $anode[0] = array( 0 => $FileLang.$FilePath, 1 => $FileName, 2 => $en_content, 3 => $FileContent, 4 => $info['maintainer']); + $anode[0] = array( 'lang' => $FileLang, + 'path' => $FilePath, + 'name' => $FileName, + 'en_content' => $en_content, + 'lang_content' => $FileContent, + 'maintainer' => $info['maintainer'] + ); $errorTools = new ToolsError($this->phpDoc->db); $r = $errorTools->updateFilesError($anode, 'nocommit'); - //$r = $this->phpDoc->updateFilesError($anode, 'nocommit'); - return $this->getResponse(array('success' => true, 'error' => $r['state'], 'error_first' => $r['first'])); } @@ -414,9 +418,11 @@ if ($type == 'file') { $this->phpDoc->saveFile($filePath.$fileName, $fileContent, $fileLang, 'file'); - $this->phpDoc->registerAsPendingCommit($fileLang, $filePath, $fileName, $info['rev'], $info['en-rev'], $info['reviewed'], $info['maintainer'], 'update'); + $r = $this->phpDoc->registerAsPendingCommit($fileLang, $filePath, $fileName, $info['rev'], $info['en-rev'], $info['reviewed'], $info['maintainer'], 'update'); + return $this->getResponse(array( 'success' => true, + 'id' => $r, 'en_revision' => $info['rev'], 'new_revision' => $info['en-rev'], 'maintainer' => $info['maintainer'], @@ -504,10 +510,11 @@ return $this->getFailure(); } + $FileType = $this->getRequestVariable('FileType'); $FilePath = $this->getRequestVariable('FilePath'); $FileName = $this->getRequestVariable('FileName'); - $info = $this->phpDoc->clearLocalChange($FilePath, $FileName); + $info = $this->phpDoc->clearLocalChange($FileType, $FilePath, $FileName); $return = array('success' => true); $return['revision'] = $info['rev']; @@ -584,35 +591,31 @@ $anode = json_decode(stripslashes($nodes)); + $nodes = $this->phpDoc->getModifiedFilesById($anode); + // Update revision & reviewed for all this files - $this->phpDoc->updateRev($anode); + $this->phpDoc->updateRev($nodes); // Update FilesError for all this files - for ($i = 0; $i < count($anode); $i++) { + for ($i = 0; $i < count($nodes); $i++) { - $t = explode("/", $anode[$i][0]); - - $FileLang = $t[0]; - array_shift($t); - - $FilePath = '/'.implode("/", $t); - $FileName = $anode[$i][1]; + $FileLang = $nodes[$i]['lang']; + $FilePath = $nodes[$i]['path']; + $FileName = $nodes[$i]['name']; $en_content = file_get_contents(DOC_EDITOR_CVS_PATH.'en'.$FilePath.$FileName); $lang_content = file_get_contents(DOC_EDITOR_CVS_PATH.$FileLang.$FilePath.$FileName); - $info = $this->phpDoc->getInfoFromContent($lang_content); + $nodes[$i]['en_content'] = $en_content; + $nodes[$i]['lang_content'] = $lang_content; - $anode[$i][2] = $en_content; - $anode[$i][3] = $lang_content; - $anode[$i][4] = $info['maintainer']; } $errorTools = new ToolsError($this->phpDoc->db); - $errorTools->updateFilesError($anode); + $errorTools->updateFilesError($nodes); // Remove all this files in needcommit - $this->phpDoc->removeNeedCommit($anode); + $this->phpDoc->removeNeedCommit($nodes); // Manage this logMessage $this->phpDoc->manageLogMessage($logMessage); @@ -875,4 +878,17 @@ return $this->getResponse(array('success' => true, 'lastupdate' => $r['lastupdate'])); } + public function markAsNeedDelete() { + + $this->phpDoc->isLogged(); + + $FilePath = $this->getRequestVariable('FilePath'); + $FileName = $this->getRequestVariable('FileName'); + + $r = $this->phpDoc->markAsNeedDelete($FilePath, $FileName); + + return $this->getResponse(array('success' => true, 'id' => $r['id'], 'by' => $r['by'], 'date' => $r['date'])); + + } + } \ No newline at end of file http://cvs.php.net/viewvc.cgi/doc-editor/php/ToolsError.php?r1=1.10&r2=1.11&diff_format=u Index: doc-editor/php/ToolsError.php diff -u doc-editor/php/ToolsError.php:1.10 doc-editor/php/ToolsError.php:1.11 --- doc-editor/php/ToolsError.php:1.10 Tue Apr 21 20:24:59 2009 +++ doc-editor/php/ToolsError.php Mon Apr 27 05:09:57 2009 @@ -97,28 +97,24 @@ /** * Update error's informations about a file after his commit. - * @param array $anode An array of files. + * @param array $nodes An array of files. * @param string $action Can be 'commit' or not if we call this method after a commit action or not * @return An array of information */ - function updateFilesError($anode, $action='commit') { + function updateFilesError($nodes, $action='commit') { - for ($i = 0; $i < count($anode); $i++) { + for ($i = 0; $i < count($nodes); $i++) { - $t = explode("/", $anode[$i][0]); - - $FileLang = $t[0]; - array_shift($t); - - $FilePath = '/'.implode("/", $t); - $FileName = $anode[$i][1]; + $FileLang = $nodes[$i]['lang']; + $FilePath = $nodes[$i]['path']; + $FileName = $nodes[$i]['name']; // Remove all row in errorfiles tables $s = 'DELETE FROM errorfiles WHERE lang=\''.$FileLang.'\' AND path=\''.$FilePath.'\' AND name=\''.$FileName.'\''; $this->db->query($s) or die($this->db->error.'|'.$s); - $this->setParams($anode[$i][2], $anode[$i][3], $FileLang, $FilePath, $FileName, $anode[$i][4]); + $this->setParams($nodes[$i]['en_content'], $nodes[$i]['lang_content'], $FileLang, $FilePath, $FileName, $nodes[$i]['maintainer']); $this->clearError(); $this->run();
http://cvs.php.net/viewvc.cgi/doc-editor/js/locale/fr.js?r1=1.12&r2=1.13&diff_format=u Index: doc-editor/js/locale/fr.js diff -u doc-editor/js/locale/fr.js:1.12 doc-editor/js/locale/fr.js:1.13 --- doc-editor/js/locale/fr.js:1.12 Sat Apr 25 16:50:01 2009 +++ doc-editor/js/locale/fr.js Mon Apr 27 05:09:57 2009 @@ -130,7 +130,7 @@ i18n["Your filter must contain at least 3 characters"] = "Votre filtre doit comporter au moins 3 caractères"; i18n["Not in EN tree"] = "Non présent en EN"; i18n["Remove this file"] = "Supprimer ce fichier"; - +i18n["This action will mark this file as need deleted.<br/><br/>You need commit this change to take it effect.<br/><br/>Please, confirm this action."] = "Voulez-vous marquer ce fichier comme devant être effacé ?<br/><br/>L'effacement sera effectif qu'une fois le commit émis.<br/><br/>Vous devez confirmer cette action."; // Main Menu i18n["Main Menu"] = "Menu principal"; http://cvs.php.net/viewvc.cgi/doc-editor/js/main.js?r1=1.52&r2=1.53&diff_format=u Index: doc-editor/js/main.js diff -u doc-editor/js/main.js:1.52 doc-editor/js/main.js:1.53 --- doc-editor/js/main.js:1.52 Sat Apr 25 08:38:45 2009 +++ doc-editor/js/main.js Mon Apr 27 05:09:57 2009 @@ -43,7 +43,7 @@ userLang: '', appName: 'PhpDocumentation Online Editor', appVer: '0.2', - uiRevision: '$Revision: 1.52 $', + uiRevision: '$Revision: 1.53 $', userConf: { 'conf_needupdate_diff': 'using-exec', @@ -433,6 +433,9 @@ }, { name: 'name', mapping: 'name' + }, { + name: 'needcommit', + mapping: 'needcommit' }]), sortInfo: { field: 'path', @@ -1060,6 +1063,107 @@ GoToNode(this.treeAllFilesRoot, this); }, //openFile + + clearLocalChange: function(FileType, FilePath, FileName, rowIndex, scope) { + + if (scope.userLogin === 'cvsread') { + scope.winForbidden(); + return; + } + + function goClearChange(btn){ + if (btn === 'yes') { + + Ext.getBody().mask('<img src="themes/img/loading.gif" style="vertical-align: middle;" /> '+_('Please, wait...')); + + // Before clear local change, we close the file if there is open + if (Ext.getCmp('main-panel').findById('FNU-' + Ext.util.md5('FNU-' + FilePath + FileName))) { + Ext.getCmp('main-panel').remove('FNU-' + Ext.util.md5('FNU-' + FilePath + FileName)); + } + + // + Ext.Ajax.request({ + scope: scope, + url: './php/controller.php', + params: { + task: 'clearLocalChange', + FileType: FileType, + FilePath: FilePath, + FileName: FileName + }, + success: function(a){ + var o = Ext.util.JSON.decode(a.responseText); + if (o.success) { + + var node; + + if (this.userLang === 'en') { + // We reload all store + this.storeFilesNeedUpdate.reload(); + this.storeFilesError.reload(); + this.storeFilesNeedReviewed.reload(); + } + + // We delete from this store + this.storePendingCommit.remove(this.storePendingCommit.getAt(rowIndex)); + + // We fire event add to update the file count + this.storePendingCommit.fireEvent('add', this.storePendingCommit); + + // We try to search in others stores if this file is marked as needCommit + + // trow storeNotInEn + this.storeNotInEn.each(function(record){ + if ((this.userLang+record.data.path) === FilePath && record.data.name === FileName) { + record.set('needcommit', false); + } + }, this); + + // trow storeFilesNeedReviewed + this.storeFilesNeedReviewed.each(function(record){ + if ((this.userLang+record.data.path) === FilePath && record.data.name === FileName) { + record.set('needcommit', false); + } + }, this); + + // trow storeFilesNeedUpdate + this.storeFilesNeedUpdate.each(function(record){ + if ((this.userLang+record.data.path) === FilePath && record.data.name === FileName) { + record.set('needcommit', false); + } + }, this); + + // trow FileError + this.storeFilesError.each(function(record){ + if ((this.userLang+record.data.path) === FilePath && record.data.name === FileName) { + record.set('needcommit', false); + } + }, this); + + // find open node in All Files modules + node = this.treeAllFiles.getNodeById('//'+FilePath+FileName); + if( node ) { + node.getUI().removeClass('modified'); + } + Ext.getBody().unmask(); + } + else { + Ext.getBody().unmask(); + this.winForbidden(); + } + + }, + failure: function(){ + + } + }); + } + } + + Ext.MessageBox.confirm(_('Confirm'), _('This action will clear your local modification and take back this file from his original stats.<br/>You need confirm.'), goClearChange, scope); + + }, //clearLocalChange + rejectPatch: function(FileID, FilePath, FileName, FileUniqID, rowIndex, scope){ if (scope.userLogin === 'cvsread') { @@ -1141,7 +1245,7 @@ if (o.success) { // Add this files into storePendingCommit - this.addToPendingCommit(FilePath, FileName, 'update'); + this.addToPendingCommit(o.id, FilePath, FileName, 'update'); // Remove this patch from the PendingPatchStore this.storePendingPatch.remove(this.storePendingPatch.getAt(rowIndex)); @@ -1227,7 +1331,7 @@ } // Add this files into storePendingCommit - this.addToPendingCommit("en" + FilePath, FileName, 'update'); + this.addToPendingCommit(o.id, "en" + FilePath, FileName, 'update'); // Remove wait msg msg.hide(); @@ -1417,7 +1521,7 @@ } // Add this files into storePendingCommit - this.addToPendingCommit(this.userLang + FilePath, FileName, 'update'); + this.addToPendingCommit(o.id, this.userLang + FilePath, FileName, 'update'); // Remove wait msg msg.hide(); @@ -1526,7 +1630,7 @@ } // Add this files into storePendingCommit - this.addToPendingCommit(this.userLang + FilePath, FileName, 'update'); + this.addToPendingCommit(o.id, this.userLang + FilePath, FileName, 'update'); } else { this.winForbidden(); @@ -1626,7 +1730,7 @@ this.storePendingPatch.insert(0, r); }, //addToPendingPatch - addToPendingCommit: function(FilePath, FileName, type){ + addToPendingCommit: function(FileID, FilePath, FileName, type){ var alReady, dt, r1; @@ -1645,7 +1749,7 @@ dt = new Date(); r1 = new this.storePendingCommit.recordType({ - id: Ext.id('', ''), + id: FileID, path: FilePath, name: FileName, by: this.userLogin, @@ -1653,6 +1757,7 @@ type: type }); this.storePendingCommit.insert(0, r1); + this.storePendingCommit.groupBy('path', true); } }, //addToPendingCommit @@ -1836,7 +1941,7 @@ }, //removeTabEvent WinCommit: function(singleFile, rowIndex, choice){ - var win, btn, FileID, FilePath, FileName, node, TreeSorter; + var win, btn, FileDBID, FileID, FilePath, FileName, node, TreeSorter; btn = Ext.get('acc-need-update'); @@ -2050,9 +2155,7 @@ NeedToBeClose = []; for (i = 0; i < files.length; i = i + 1) { - - //var checkNode, paneID_FE, paneID_FNU, paneID_FNR, tmp = [], paneID, libelNeedToBeClose = ''; - + checkNode = Ext.getCmp('tree-panel').getNodeById(files[i]).attributes; paneID_FE = 'FE-' + Ext.util.md5('FE-' + checkNode.FilePath + checkNode.FileName); @@ -2132,6 +2235,7 @@ // Just the current file + FileDBID = this.storePendingCommit.getAt(rowIndex).data.id; FilePath = this.storePendingCommit.getAt(rowIndex).data.path; FileName = this.storePendingCommit.getAt(rowIndex).data.name; FileID = Ext.util.md5(FilePath + FileName); @@ -2139,6 +2243,7 @@ node = new Ext.tree.TreeNode({ id: 'need-commit-' + FileID, text: FilePath + FileName, + FileDBID: FileDBID, FilePath: FilePath, FileName: FileName, leaf: true, @@ -2158,6 +2263,7 @@ } else { + FileDBID = record.data.id; FilePath = record.data.path; FileName = record.data.name; FileID = Ext.util.md5(FilePath + FileName); @@ -2165,9 +2271,9 @@ node = new Ext.tree.TreeNode({ id: 'need-commit-' + FileID, text: FilePath + FileName, + FileDBID: FileDBID, FilePath: FilePath, FileName: FileName, - //fileLang : this.userLang, leaf: true, checked: true, uiProvider: Ext.ux.tree.CheckTreeNodeUI @@ -2189,17 +2295,13 @@ Ext.getBody().mask('<img src="themes/img/loading.gif" style="vertical-align: middle;" /> '+_('Please, wait until commit...')); - var nodes = [], node, tmp, LogMessage, i; + var nodes = [], node, LogMessage, i; // Go for Cvs commit for (i = 0; i < files.length; i = i + 1) { node = Ext.getCmp('tree-panel').getNodeById(files[i]); - tmp = []; - - tmp[0] = node.attributes.FilePath; - tmp[1] = node.attributes.FileName; - nodes.push(tmp); + nodes.push(node.attributes.FileDBID); } // Get log message @@ -2233,7 +2335,7 @@ modal: true, autoScroll: true, bodyStyle: 'background-color: white; padding: 5px;', - html: o.mess.join("<br>"), + html: o.mess.join("<br/>"), buttons: [{ text: _('Close'), handler: function(){ @@ -5196,7 +5298,12 @@ view: new Ext.grid.GroupingView({ forceFit: true, groupTextTpl: '{[values.rs[0].data["path"]]} ({[values.rs.length]} {[values.rs.length > 1 ? "'+_('Files')+'" : "'+_('File')+'"]})', - emptyText: '<div style="text-align: center;">'+_('No Files')+'</div>' + emptyText: '<div style="text-align: center;">'+_('No Files')+'</div>', + getRowClass: function(record, numIndex, rowParams, store){ + if (record.data.needcommit) { + return 'file-need-commit'; + } + } }), autoExpandColumn: 'name', bodyBorder: false, @@ -5205,19 +5312,56 @@ rowcontextmenu: function(grid, rowIndex, e){ grid.getSelectionModel().selectRow(rowIndex); - - var menu = new Ext.menu.Menu({ - items: [{ - text: _('Remove this file'), - iconCls: 'iconDelete', - scope: this, - handler: function(){ - - } - }] - }); - menu.showAt(e.getXY()); + if( !this.storeNotInEn.getAt(rowIndex).data.needcommit ) { + + var menu = new Ext.menu.Menu({ + items: [{ + text: _('Remove this file'), + iconCls: 'iconDelete', + scope: this, + handler: function(){ + gridNotInEn.fireEvent('rowdblclick', grid, rowIndex, e); + } + }] + }); + menu.showAt(e.getXY()); + + } + + }, + rowdblclick: function(grid, rowIndex, e){ + + var FilePath, FileName, FileID; + + FilePath = this.storeNotInEn.getAt(rowIndex).data.path; + FileName = this.storeNotInEn.getAt(rowIndex).data.name; + + function goMarkAsDelete(btn){ + if (btn === 'yes') { + Ext.getBody().mask('<img src="themes/img/loading.gif" style="vertical-align: middle;" /> '+_('Please, wait...')); + + Ext.Ajax.request({ + scope: this, + url: './php/controller.php', + params: { + task: 'markAsNeedDelete', + FilePath: FilePath, + FileName: FileName + }, + success: function(action){ + var o = Ext.util.JSON.decode(action.responseText); + if (o.success) { + Ext.getBody().unmask(); + this.addToPendingCommit( o.id, this.userLang + FilePath, FileName, 'delete' ); + this.storeNotInEn.getAt(rowIndex).set('needcommit', true); + } + } + }); + } + } + + Ext.MessageBox.confirm(_('Confirm'), _('This action will mark this file as need deleted.<br/><br/>You need commit this change to take it effect.<br/><br/>Please, confirm this action.'), goMarkAsDelete, this); } } }); @@ -5270,214 +5414,155 @@ scope: this, 'rowcontextmenu': function(grid, rowIndex, e){ - var FilePath, FileName, menu; + var FileType, FilePath, FileName, menu, subMenuCommit; + FileType = this.storePendingCommit.getAt(rowIndex).data.type; FilePath = this.storePendingCommit.getAt(rowIndex).data.path; FileName = this.storePendingCommit.getAt(rowIndex).data.name; grid.getSelectionModel().selectRow(rowIndex); - menu = new Ext.menu.Menu({ - items: [{ - text: '<b>'+_('Edit in a new Tab')+'</b>', - iconCls: 'PendingCommit', - scope: this, - handler: function(){ - gridPendingCommit.fireEvent('rowdblclick', grid, rowIndex, e); - } - }, '-', { - text: _('View Diff'), - iconCls: 'iconViewDiff', - scope: this, - handler: function(){ - - // Add tab for the diff - Ext.getCmp('main-panel').add({ - xtype: 'panel', - id: 'diff_panel_' + rowIndex, - title: _('Diff'), - tabTip: _('Diff'), - closable: true, - autoScroll: true, - iconCls: 'iconTabLink', - html: '<div id="diff_content_' + rowIndex + '" class="diff-content"></div>' - }); - Ext.getCmp('main-panel').setActiveTab('diff_panel_' + rowIndex); - - Ext.get('diff_panel_' + rowIndex).mask('<img src="themes/img/loading.gif" style="vertical-align: middle;" /> '+_('Please, wait...')); - - // Load diff data - Ext.Ajax.request({ - url: './php/controller.php', - params: { - task: 'getDiff', - FilePath: FilePath, - FileName: FileName - }, - success: function(action){ - var o = Ext.util.JSON.decode(action.responseText); - if (o.success) { - // We display in diff div - Ext.get('diff_content_' + rowIndex).dom.innerHTML = o.content; - Ext.get('diff_panel_' + rowIndex).unmask(); - - } - - }, - failure: function(){ - - } - }); - - - } - }, { - text: _('Download the diff as a patch'), - iconCls: 'iconCommitFileCvs', - scope: this, - handler: function(){ - window.location.href = './php/controller.php?task=downloadPatch&FilePath=' + FilePath + '&FileName=' + FileName; - } - }, '-', { - text: _('Clear this change'), - iconCls: 'iconPageDelete', - disabled: (this.userLogin === 'cvsread') ? true : false, - scope: this, - handler: function(){ - - if (this.userLogin === 'cvsread') { - this.winForbidden(); - return; + subMenuCommit = { + text: _('Commit...'), + iconCls: 'iconCommitFileCvs', + scope: this, + handler: function(){ + return false; + }, + disabled: (this.userLogin === 'cvsread') ? true : false, + menu: new Ext.menu.Menu({ + items: [{ + text: _('...this file'), + iconCls: 'iconCommitFileCvs', + scope: this, + handler: function(){ + this.WinCommit(true, rowIndex); } - - function goClearChange(btn){ - if (btn === 'yes') { - - Ext.getBody().mask('<img src="themes/img/loading.gif" style="vertical-align: middle;" /> '+_('Please, wait...')); - - // Before clear local change, we close the file if there is open - if (Ext.getCmp('main-panel').findById('FNU-' + Ext.util.md5('FNU-' + FilePath + FileName))) { - Ext.getCmp('main-panel').remove('FNU-' + Ext.util.md5('FNU-' + FilePath + FileName)); - } - - // - Ext.Ajax.request({ - scope: this, - url: './php/controller.php', - params: { - task: 'clearLocalChange', - FilePath: FilePath, - FileName: FileName - }, - success: function(action){ - var o = Ext.util.JSON.decode(action.responseText); - if (o.success) { - - var node; - - if (this.userLang === 'en') { - // We reload all store - this.storeFilesNeedUpdate.reload(); - this.storeFilesError.reload(); - this.storeFilesNeedReviewed.reload(); - } - - // We delete from this store - this.storePendingCommit.remove(this.storePendingCommit.getAt(rowIndex)); - - // We fire event add to update the file count - this.storePendingCommit.fireEvent('add', this.storePendingCommit); - - // We try to search in others stores if this file is marked as needCommit - - // trow storeFilesNeedReviewed - this.storeFilesNeedReviewed.each(function(record){ - if ((this.userLang+record.data.path) === FilePath && record.data.name === FileName) { - record.set('needcommit', false); - } - }, this); + }, { + text: _('...all files modified by me'), + iconCls: 'iconCommitFileCvs', + scope: this, + handler: function(){ + this.WinCommit(false, '', 'by me'); + } + }, { + text: _('...all files modified'), + iconCls: 'iconCommitFileCvs', + scope: this, + handler: function(){ + this.WinCommit(false); + } + }] + }) + }; - // trow storeFilesNeedUpdate - this.storeFilesNeedUpdate.each(function(record){ - if ((this.userLang+record.data.path) === FilePath && record.data.name === FileName) { - record.set('needcommit', false); - } - }, this); + if( FileType === 'delete' ) { - // trow FileError - this.storeFilesError.each(function(record){ - if ((this.userLang+record.data.path) === FilePath && record.data.name === FileName) { - record.set('needcommit', false); - } - }, this); + menu = new Ext.menu.Menu({ + items: [{ + text: '<b>' + _('Cancel') + '<b>', + iconCls: 'iconPageDelete', + disabled: (this.userLogin === 'cvsread') ? true : false, + scope: this, + handler: function(){ + gridPendingCommit.fireEvent('rowdblclick', grid, rowIndex, e); + } + }, '-', subMenuCommit] + }); + } - // find open node in All Files modules - node = this.treeAllFiles.getNodeById('//'+FilePath+FileName); - if( node ) { - node.getUI().removeClass('modified'); - } - Ext.getBody().unmask(); - } - else { - Ext.getBody().unmask(); - this.winForbidden(); - } + if( FileType === 'update' ) { + menu = new Ext.menu.Menu({ + items: [{ + text: '<b>'+_('Edit in a new Tab')+'</b>', + iconCls: 'PendingCommit', + scope: this, + handler: function(){ + gridPendingCommit.fireEvent('rowdblclick', grid, rowIndex, e); + } + }, '-', { + text: _('View Diff'), + iconCls: 'iconViewDiff', + scope: this, + handler: function(){ + + // Add tab for the diff + Ext.getCmp('main-panel').add({ + xtype: 'panel', + id: 'diff_panel_' + rowIndex, + title: _('Diff'), + tabTip: _('Diff'), + closable: true, + autoScroll: true, + iconCls: 'iconTabLink', + html: '<div id="diff_content_' + rowIndex + '" class="diff-content"></div>' + }); + Ext.getCmp('main-panel').setActiveTab('diff_panel_' + rowIndex); + + Ext.get('diff_panel_' + rowIndex).mask('<img src="themes/img/loading.gif" style="vertical-align: middle;" /> '+_('Please, wait...')); + + // Load diff data + Ext.Ajax.request({ + url: './php/controller.php', + params: { + task: 'getDiff', + FilePath: FilePath, + FileName: FileName + }, + success: function(action){ + var o = Ext.util.JSON.decode(action.responseText); + if (o.success) { + // We display in diff div + Ext.get('diff_content_' + rowIndex).dom.innerHTML = o.content; + Ext.get('diff_panel_' + rowIndex).unmask(); - }, - failure: function(){ - } - }); - } + + }, + failure: function(){ + + } + }); + } - - Ext.MessageBox.confirm(_('Confirm'), _('This action will clear your local modification and take back this file from his original stats.<br/>You need confirm.'), goClearChange, this); - } - }, '-', { - text: _('Commit...'), - iconCls: 'iconCommitFileCvs', - scope: this, - handler: function(){ - return false; - }, - disabled: (this.userLogin === 'cvsread') ? true : false, - menu: new Ext.menu.Menu({ - items: [{ - text: _('...this file'), - iconCls: 'iconCommitFileCvs', - scope: this, - handler: function(){ - this.WinCommit(true, rowIndex); - } - }, { - text: _('...all files modified by me'), - iconCls: 'iconCommitFileCvs', - scope: this, - handler: function(){ - this.WinCommit(false, '', 'by me'); - } - }, { - text: _('...all files modified'), - iconCls: 'iconCommitFileCvs', - scope: this, - handler: function(){ - this.WinCommit(false); - } - }] - }) - }] - }); + }, { + text: _('Download the diff as a patch'), + iconCls: 'iconCommitFileCvs', + scope: this, + handler: function(){ + window.location.href = './php/controller.php?task=downloadPatch&FilePath=' + FilePath + '&FileName=' + FileName; + } + }, '-', { + text: _('Clear this change'), + iconCls: 'iconPageDelete', + disabled: (this.userLogin === 'cvsread') ? true : false, + scope: this, + handler: function(){ + this.clearLocalChange(FileType, FilePath, FileName, rowIndex, this); + } + }, '-', subMenuCommit] + }); + + } + menu.showAt(e.getXY()); }, 'rowdblclick': function(grid, rowIndex, e){ - var FilePath, FileName; + var FileType, FilePath, FileName; + FileType = this.storePendingCommit.getAt(rowIndex).data.type; FilePath = this.storePendingCommit.getAt(rowIndex).data.path; FileName = this.storePendingCommit.getAt(rowIndex).data.name; - - this.openFile(FilePath, FileName); - + + if( FileType === 'update' ) { + this.openFile(FilePath, FileName); + } + + if( FileType === 'delete' ) { + this.clearLocalChange(FileType, FilePath, FileName, rowIndex, this); + } + } //rowdblclick } //listeners }); @@ -7048,7 +7133,7 @@ node.getUI().addClass('modified'); // Add this files into storePendingCommit - this.addToPendingCommit(FilePath, FileName, 'update'); + this.addToPendingCommit(o.id, FilePath, FileName, 'update'); // Remove wait msg msg.hide(); http://cvs.php.net/viewvc.cgi/doc-editor/php/class.php?r1=1.44&r2=1.45&diff_format=u Index: doc-editor/php/class.php diff -u doc-editor/php/class.php:1.44 doc-editor/php/class.php:1.45 --- doc-editor/php/class.php:1.44 Sat Apr 25 16:48:09 2009 +++ doc-editor/php/class.php Mon Apr 27 05:09:57 2009 @@ -814,6 +814,33 @@ } /** + * Get modified files by ID. + * @param $id Can be a single ID or an array of id + * @return An associated array containing all informations about modified files. + */ + function getModifiedFilesById($id) { + + if( is_array($id) ) { + $ids = implode($id, ','); + } else { + $ids = $id; + } + + $s = sprintf('SELECT * FROM `pendingCommit` WHERE + (`lang`="%s" OR `lang`="en") AND `id` IN (%s)', $this->cvsLang, $ids); + + $r = $this->db->query($s) or die('Error: '.$this->db->error.'|'.$s); + + $nodes = array(); + + while ($a = $r->fetch_assoc()) { + $nodes[] = $a; + } + + return $nodes; + } + + /** * Get all files witch need to be updated. * * @return An associated array containing all informations about files witch need to be updated. @@ -922,12 +949,15 @@ } /** - * Get all witch are not in EN tree. + * Get all files witch are not in EN tree. * * @return An associated array containing all informations about files witch are not in EN tree */ function getFilesNotInEn() { + // Get Files Need Commit + $ModifiedFiles = $this->getModifiedFiles(); + $s = sprintf('SELECT `id`, `path`, `name` FROM `files` WHERE `lang`="%s" AND `status`=\'NotInEN\'', $this->cvsLang); $r = $this->db->query($s) or die('Error: '.$this->db->error.'|'.$s); @@ -935,8 +965,15 @@ $node = array(); - while ($row = $r->fetch_assoc()) { - $node[] = $row; + while ($a = $r->fetch_object()) { + + $node[] = array( + "id" => $a->id, + "path" => $a->path, + "name" => $a->name, + "needcommit" => ( isset($ModifiedFiles[$this->cvsLang.$a->path.$a->name]) ) ? true : false + ); + } return array('nb' => $nb, 'node' => $node); @@ -1536,7 +1573,7 @@ $this->db->query($s) or die('Error: '.$this->db->error.'|'.$s); $fileID = $a->id; } - + return $fileID; } /** @@ -1808,11 +1845,12 @@ /** * Delete local change of a file. * + * @param $type The type of the file. Can be 'update', 'delete' or new' * @param $path The path of the file. * @param $file The name of the file. * @return An array witch contain informations about this file. */ - function clearLocalChange($path, $file) { + function clearLocalChange($type, $path, $file) { // Extract the lang $t = explode('/',$path); @@ -1831,6 +1869,11 @@ $s = sprintf('DELETE FROM `pendingCommit` WHERE `id`="%s"', $a->id); $this->db->query($s) or die('Error: '.$this->db->error.'|'.$s); + // If type == delete or new, we stop here and return + if( $type == 'delete' || $type == 'new' ) { + return; + } + // We need delete file on filesystem $doc = DOC_EDITOR_CVS_PATH.$lang.$path.$file.".new"; @@ -1843,7 +1886,13 @@ $info = $this->getInfoFromContent($lang_content); - $anode[0] = array( 0 => $lang.$path, 1 => $file, 2 => $en_content, 3 => $lang_content, 4 => $info['maintainer']); + $anode[0] = array( 'lang' => $lang, + 'path' => $path, + 'name' => $file, + 'en_content' => $en_content, + 'lang_content' => $lang_content, + 'maintainer' => $info['maintainer'] + ); $errorTools = new ToolsError($this->db); $error = $errorTools->updateFilesError($anode, 'nocommit'); @@ -1880,27 +1929,69 @@ */ function cvsCommit($anode, $log) { - $files = ''; + $filesUpdate = array(); + $filesDelete = array(); + $filesNew = array(); - for ($i = 0; $i < count($anode); $i++ ) { + $cmdUpdate = ''; + $cmdDelete = ''; + $cmdNew = ''; - // We need move .new file into the real file - @unlink( DOC_EDITOR_CVS_PATH.$anode[$i][0].$anode[$i][1]); - @copy( DOC_EDITOR_CVS_PATH.$anode[$i][0].$anode[$i][1].'.new', DOC_EDITOR_CVS_PATH.$anode[$i][0].$anode[$i][1]); - @unlink( DOC_EDITOR_CVS_PATH.$anode[$i][0].$anode[$i][1].'.new'); + $nodes = $this->getModifiedFilesById($anode); - $files .= $anode[$i][0].$anode[$i][1].' '; + // Loop over $nodes to find files to be delete, update, or new + reset($nodes); + for( $i=0; $i < count($nodes); $i++) { + $fullPath = $nodes[$i]['lang'].$nodes[$i]['path'].$nodes[$i]['name']; + + if( $nodes[$i]['type'] == 'delete' ) { + $filesDelete[] = $fullPath; + } + + if( $nodes[$i]['type'] == 'update' ) { + + $filesUpdate[] = $fullPath; + + // Pre-commit : We need move .new file into the real file + @unlink( DOC_EDITOR_CVS_PATH.$fullPath); + @copy( DOC_EDITOR_CVS_PATH.$fullPath.'.new', DOC_EDITOR_CVS_PATH.$fullPath); + @unlink( DOC_EDITOR_CVS_PATH.$fullPath.'.new'); + + } + + if( $nodes[$i]['type'] == 'new' ) { + $filesNew[] = $fullPath; + } + } + + // Linearization + $filesDelete = implode($filesDelete, ' '); + $filesUpdate = implode($filesUpdate, ' '); + $filesNew = implode($filesNew, ' '); + + // Buil the command line + if( trim($filesDelete) != '' ) { + $cmdDelete = 'cvs -d :pserver:'.$this->cvsLogin.':'.$this->cvsPasswd.'@cvs.php.net:/repository -f remove -f '.$filesDelete.' && '; + } + if( trim($filesNew) != '' ) { + $cmdNew = 'cvs -d :pserver:'.$this->cvsLogin.':'.$this->cvsPasswd.'@cvs.php.net:/repository -f add '.$filesNew.' && '; } + // Escape single quote $log = str_replace("'", "\\'", $log); + $cmd = $cmdDelete. + $cmdNew. + 'cvs -d :pserver:'.$this->cvsLogin.':'.$this->cvsPasswd.'@cvs.php.net:/repository -f commit -l -m \''.$log.'\' '.$filesUpdate.' '.$filesDelete.' '.$filesNew; + // First, login into Cvs - $cmd = 'export CVS_PASSFILE='.realpath(DOC_EDITOR_DATA_PATH).'/.cvspass && cd '.DOC_EDITOR_CVS_PATH.' && cvs -d :pserver:'.$this->cvsLogin.':'.$this->cvsPasswd.'@cvs.php.net:/repository login && cvs -d :pserver:'.$this->cvsLogin.':'.$this->cvsPasswd.'@cvs.php.net:/repository -f commit -l -m \''.$log.'\' '.$files; + $fullCmd = 'export CVS_PASSFILE='.realpath(DOC_EDITOR_DATA_PATH).'/.cvspass && cd '.DOC_EDITOR_CVS_PATH.' && cvs -d :pserver:'.$this->cvsLogin.':'.$this->cvsPasswd.'@cvs.php.net:/repository login && '.$cmd; + $output = array(); - exec($cmd, $output); + exec($fullCmd, $output); - //$this->debug('commit cmd : '.$cmd); + //$this->debug('commit cmd : '.$fullCmd); return $this->highlightCommitLog($output); } @@ -1921,24 +2012,21 @@ /** * Update information about a file after his commit (update informations added with revcheck tools). * - * @param $anode An array of files. + * @param $nodes An array of files. */ - function updateRev($anode) { + function updateRev($nodes) { - for ($i = 0; $i < count($anode); $i++ ) { + for ($i = 0; $i < count($nodes); $i++ ) { - $t = explode("/", $anode[$i][0]); + $FileLang = $nodes[$i]['lang']; - $FileLang = $t[0]; - array_shift($t); - - $FilePath = implode("/", $t); - $FileName = $anode[$i][1]; + $FilePath = $nodes[$i]['path']; + $FileName = $nodes[$i]['name']; //En file ? if ($FileLang == 'en' ) { - $path = DOC_EDITOR_CVS_PATH.'en/'.$FilePath.$FileName; + $path = DOC_EDITOR_CVS_PATH.'en'.$FilePath.$FileName; $content = file_get_contents($path); $info = $this->getInfoFromContent($content); $size = intval(filesize($path) / 1024); @@ -1953,7 +2041,7 @@ WHERE `lang` = "%s" AND - `path` = \'/%s\' AND + `path` = "%s" AND `name` = "%s" ',$info['rev'], $size, $date, $FileLang, $FilePath, $FileName); $this->db->query($s) or die($this->db->error.'|'.$s); @@ -1965,7 +2053,7 @@ WHERE `lang` != "%s" AND - `path` = \'/%s\' AND + `path` = "%s" AND `name` = "%s" ', $info['rev'], $FileLang, $FilePath, $FileName); $this->db->query($s) or die($this->db->error.'|'.$s); @@ -1973,14 +2061,14 @@ } else { - $path = DOC_EDITOR_CVS_PATH.$FileLang.'/'.$FilePath.$FileName; + $path = DOC_EDITOR_CVS_PATH.$FileLang.$FilePath.$FileName; $content = file_get_contents($path); $info = $this->getInfoFromContent($content); $size = intval(filesize($path) / 1024); $date = filemtime($path); - $pathEN = DOC_EDITOR_CVS_PATH.'en/'.$FilePath.$FileName; + $pathEN = DOC_EDITOR_CVS_PATH.'en'.$FilePath.$FileName; $sizeEN = intval(filesize($pathEN) / 1024); $dateEN = filemtime($pathEN); @@ -1999,9 +2087,9 @@ `mdate_diff` = "%s" WHERE - `lang`="%s" AND - `path`=\'/%s\' AND - `name`="%s" + `lang` = "%s" AND + `path` = "%s" AND + `name` = "%s" ',$info['en-rev'], $info['reviewed'], $size, $date, $info['maintainer'], $info['status'], $size_diff, $date_diff, $FileLang, $FilePath, $FileName); $this->db->query($s) or die($this->db->error.'|'.$s); } @@ -2014,24 +2102,20 @@ /** * Remove the mark "needCommit" into DB for a set of files. * - * @param $anode An array of files. + * @param $nodes An array of files. */ - function removeNeedCommit($anode) { - - for ($i = 0; $i < count($anode); $i++ ) { + function removeNeedCommit($nodes) { - $t = explode("/", $anode[$i][0]); + for ($i = 0; $i < count($nodes); $i++ ) { - $FileLang = $t[0]; - array_shift($t); - - $FilePath = implode("/", $t); - $FileName = $anode[$i][1]; + $FileLang = $nodes[$i]['lang']; + $FilePath = $nodes[$i]['path']; + $FileName = $nodes[$i]['name']; $s = sprintf('DELETE FROM `pendingCommit` WHERE `lang` = "%s" AND - `path` = \'/%s\' AND + `path` = "%s" AND `name` = "%s" ', $FileLang, $FilePath, $FileName); @@ -2381,6 +2465,26 @@ return; - } // + } + + /** + * Mark a file as need delete. + * + * @param $FilePath + * @param $FileName + * @return + */ + function markAsNeedDelete($FilePath, $FileName) + { + + $date = date("Y-m-d H:i:s"); + + $s = sprintf('INSERT INTO `pendingCommit` (`lang`, `path`, `name`, `revision`, `en_revision`, `reviewed`, `maintainer`, `modified_by`, `date`, `type`) VALUES ("%s","%s", "%s", "-", "-", "-", "-", "%s", "%s", "delete")', $this->cvsLang, $FilePath, $FileName, $this->cvsLogin, $date); + $this->db->query($s) or die('Error: '.$this->db->error.'|'.$s); + + return Array('id'=>$this->db->insert_id, 'by'=>$this->cvsLogin, 'date'=>$date); + + } + } // End of class http://cvs.php.net/viewvc.cgi/doc-editor/php/ExtJsController.php?r1=1.25&r2=1.26&diff_format=u Index: doc-editor/php/ExtJsController.php diff -u doc-editor/php/ExtJsController.php:1.25 doc-editor/php/ExtJsController.php:1.26 --- doc-editor/php/ExtJsController.php:1.25 Sat Apr 25 16:17:40 2009 +++ doc-editor/php/ExtJsController.php Mon Apr 27 05:09:57 2009 @@ -354,13 +354,17 @@ // Update DB with this new Error (if any) $info = $this->phpDoc->getInfoFromContent($FileContent); - $anode[0] = array( 0 => $FileLang.$FilePath, 1 => $FileName, 2 => $en_content, 3 => $FileContent, 4 => $info['maintainer']); + $anode[0] = array( 'lang' => $FileLang, + 'path' => $FilePath, + 'name' => $FileName, + 'en_content' => $en_content, + 'lang_content' => $FileContent, + 'maintainer' => $info['maintainer'] + ); $errorTools = new ToolsError($this->phpDoc->db); $r = $errorTools->updateFilesError($anode, 'nocommit'); - //$r = $this->phpDoc->updateFilesError($anode, 'nocommit'); - return $this->getResponse(array('success' => true, 'error' => $r['state'], 'error_first' => $r['first'])); } @@ -414,9 +418,11 @@ if ($type == 'file') { $this->phpDoc->saveFile($filePath.$fileName, $fileContent, $fileLang, 'file'); - $this->phpDoc->registerAsPendingCommit($fileLang, $filePath, $fileName, $info['rev'], $info['en-rev'], $info['reviewed'], $info['maintainer'], 'update'); + $r = $this->phpDoc->registerAsPendingCommit($fileLang, $filePath, $fileName, $info['rev'], $info['en-rev'], $info['reviewed'], $info['maintainer'], 'update'); + return $this->getResponse(array( 'success' => true, + 'id' => $r, 'en_revision' => $info['rev'], 'new_revision' => $info['en-rev'], 'maintainer' => $info['maintainer'], @@ -504,10 +510,11 @@ return $this->getFailure(); } + $FileType = $this->getRequestVariable('FileType'); $FilePath = $this->getRequestVariable('FilePath'); $FileName = $this->getRequestVariable('FileName'); - $info = $this->phpDoc->clearLocalChange($FilePath, $FileName); + $info = $this->phpDoc->clearLocalChange($FileType, $FilePath, $FileName); $return = array('success' => true); $return['revision'] = $info['rev']; @@ -584,35 +591,31 @@ $anode = json_decode(stripslashes($nodes)); + $nodes = $this->phpDoc->getModifiedFilesById($anode); + // Update revision & reviewed for all this files - $this->phpDoc->updateRev($anode); + $this->phpDoc->updateRev($nodes); // Update FilesError for all this files - for ($i = 0; $i < count($anode); $i++) { + for ($i = 0; $i < count($nodes); $i++) { - $t = explode("/", $anode[$i][0]); - - $FileLang = $t[0]; - array_shift($t); - - $FilePath = '/'.implode("/", $t); - $FileName = $anode[$i][1]; + $FileLang = $nodes[$i]['lang']; + $FilePath = $nodes[$i]['path']; + $FileName = $nodes[$i]['name']; $en_content = file_get_contents(DOC_EDITOR_CVS_PATH.'en'.$FilePath.$FileName); $lang_content = file_get_contents(DOC_EDITOR_CVS_PATH.$FileLang.$FilePath.$FileName); - $info = $this->phpDoc->getInfoFromContent($lang_content); + $nodes[$i]['en_content'] = $en_content; + $nodes[$i]['lang_content'] = $lang_content; - $anode[$i][2] = $en_content; - $anode[$i][3] = $lang_content; - $anode[$i][4] = $info['maintainer']; } $errorTools = new ToolsError($this->phpDoc->db); - $errorTools->updateFilesError($anode); + $errorTools->updateFilesError($nodes); // Remove all this files in needcommit - $this->phpDoc->removeNeedCommit($anode); + $this->phpDoc->removeNeedCommit($nodes); // Manage this logMessage $this->phpDoc->manageLogMessage($logMessage); @@ -875,4 +878,17 @@ return $this->getResponse(array('success' => true, 'lastupdate' => $r['lastupdate'])); } + public function markAsNeedDelete() { + + $this->phpDoc->isLogged(); + + $FilePath = $this->getRequestVariable('FilePath'); + $FileName = $this->getRequestVariable('FileName'); + + $r = $this->phpDoc->markAsNeedDelete($FilePath, $FileName); + + return $this->getResponse(array('success' => true, 'id' => $r['id'], 'by' => $r['by'], 'date' => $r['date'])); + + } + } \ No newline at end of file http://cvs.php.net/viewvc.cgi/doc-editor/php/ToolsError.php?r1=1.10&r2=1.11&diff_format=u Index: doc-editor/php/ToolsError.php diff -u doc-editor/php/ToolsError.php:1.10 doc-editor/php/ToolsError.php:1.11 --- doc-editor/php/ToolsError.php:1.10 Tue Apr 21 20:24:59 2009 +++ doc-editor/php/ToolsError.php Mon Apr 27 05:09:57 2009 @@ -97,28 +97,24 @@ /** * Update error's informations about a file after his commit. - * @param array $anode An array of files. + * @param array $nodes An array of files. * @param string $action Can be 'commit' or not if we call this method after a commit action or not * @return An array of information */ - function updateFilesError($anode, $action='commit') { + function updateFilesError($nodes, $action='commit') { - for ($i = 0; $i < count($anode); $i++) { + for ($i = 0; $i < count($nodes); $i++) { - $t = explode("/", $anode[$i][0]); - - $FileLang = $t[0]; - array_shift($t); - - $FilePath = '/'.implode("/", $t); - $FileName = $anode[$i][1]; + $FileLang = $nodes[$i]['lang']; + $FilePath = $nodes[$i]['path']; + $FileName = $nodes[$i]['name']; // Remove all row in errorfiles tables $s = 'DELETE FROM errorfiles WHERE lang=\''.$FileLang.'\' AND path=\''.$FilePath.'\' AND name=\''.$FileName.'\''; $this->db->query($s) or die($this->db->error.'|'.$s); - $this->setParams($anode[$i][2], $anode[$i][3], $FileLang, $FilePath, $FileName, $anode[$i][4]); + $this->setParams($nodes[$i]['en_content'], $nodes[$i]['lang_content'], $FileLang, $FilePath, $FileName, $nodes[$i]['maintainer']); $this->clearError(); $this->run();