cvs: doc-editor /js main.js /js/locale fr.js /php ExtJsController.php class.php
| From: | Yannick Torres | Date: | Sat, 18 Apr 2009 22:16:53 +0000 |
| Subject: | cvs: doc-editor /js main.js /js/locale fr.js /php ExtJsController.php class.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-3789@lists.php.net to get a copy of this message | ||
yannick Sat Apr 18 22:16:53 2009 UTC
Modified files:
/doc-editor/js/locale fr.js
/doc-editor/js main.js
/doc-editor/php class.php ExtJsController.php
Log:
- New functionnality : we can now search any file via a search file into the "All files"
modules
http://cvs.php.net/viewvc.cgi/doc-editor/js/locale/fr.js?r1=1.8&r2=1.9&diff_format=u Index: doc-editor/js/locale/fr.js diff -u doc-editor/js/locale/fr.js:1.8 doc-editor/js/locale/fr.js:1.9 --- doc-editor/js/locale/fr.js:1.8 Sat Apr 18 08:02:36 2009 +++ doc-editor/js/locale/fr.js Sat Apr 18 22:16:53 2009 @@ -123,7 +123,8 @@ i18n["Posted by"] = "Proposé par"; i18n["This action will <b>reject</b> this patch, send an email to his author and close this tab."] = "Cette action va <b>rejeter</b> ce patch, envoyer un email à son auteur et fermer cet onglet."; i18n["This action will accept this patch, send an email to his author, save the file and close this tab."] = "Cette action va accepter ce patch, envoyer un email à son auteur et fermer cet onglet."; - +i18n["Search result"] = "Résultat de la recherche"; +i18n["Search: "] = "Recherche : "; // Main Menu i18n["Main Menu"] = "Menu principal"; http://cvs.php.net/viewvc.cgi/doc-editor/js/main.js?r1=1.42&r2=1.43&diff_format=u Index: doc-editor/js/main.js diff -u doc-editor/js/main.js:1.42 doc-editor/js/main.js:1.43 --- doc-editor/js/main.js:1.42 Sat Apr 18 13:27:47 2009 +++ doc-editor/js/main.js Sat Apr 18 22:16:53 2009 @@ -6371,16 +6371,52 @@ containerScroll: true, bodyBorder: false, tbar:[ - 'Search: ', ' ', + _('Search: '), ' ', new Ext.form.TwinTriggerField({ + id: 'AF-search', validationEvent:false, validateOnBlur:false, trigger1Class:'x-form-clear-trigger', trigger2Class:'x-form-search-trigger', hideTrigger1:true, width:180, - hasSearch : false, - paramName : 'query', + scope: this, + enableKeyEvents: true, + listeners: { + keypress: function(field, e){ + if (e.getKey() == e.ENTER) { + this.onTrigger2Click(); + } + } + }, + onTrigger1Click: function() { + + this.setValue(''); + this.triggers[0].hide(); + this.scope.treeAllFiles.root.setText(_('Repository')); + this.scope.treeAllFiles.loader = new Ext.tree.TreeLoader({ + baseParams:{task: 'getAllFiles'}, + dataUrl: './php/controller.php' + }); + this.scope.treeAllFiles.root.reload(); + + }, + onTrigger2Click: function() { + + var v = this.getValue(); + + if( v == '' || v.length < 3) { return; } + + this.triggers[0].show(); + this.scope.treeAllFiles.root.setText(_('Search result')); + + this.scope.treeAllFiles.loader = new Ext.tree.TreeLoader({ + baseParams:{search:v, task: 'getAllFiles'}, + dataUrl: './php/controller.php' + }); + this.scope.treeAllFiles.root.reload(); + + } }) ], listeners: { @@ -6467,10 +6503,9 @@ // Only for files if (node.attributes.type === 'file') { - FileName = node.attributes.text; FilePath = node.attributes.id; - FileID = Ext.util.md5('AF-' + FilePath + FileName); - + FileID = Ext.util.md5('AF-' + FilePath); + // Render only if this tab don't exist yet if (!Ext.getCmp('main-panel').findById('AF-' + FileID)) { @@ -6478,11 +6513,14 @@ t = FilePath.split('/'); t.shift(); t.shift(); + + FileName = t[t.length - 1]; + t.pop(); - + FileLang = t[0]; FilePath = t.join('/') + '/'; - + if (FileLang !== 'en') { menuMarkUp = this.menuMarkupLANG('AF-FILE-' + FileID, this); } @@ -7009,7 +7047,14 @@ layout: 'fit', iconCls: 'AllFiles', items: [this.treeAllFiles], - collapsed: true + collapsed: true, + listeners: { + expand: function(panel) { + //TODO: try to find a better way to handle this. If we don't do this, twinTrigger's field is not render because this panel is hidden at the load time + Ext.getCmp('AF-search').wrap.setWidth(200); + } + } + }, { title: _('Pending for commit')+' - <em id="acc-pendingCommit-nb">0</em>', id: 'acc-need-pendingCommit', http://cvs.php.net/viewvc.cgi/doc-editor/php/class.php?r1=1.35&r2=1.36&diff_format=u Index: doc-editor/php/class.php diff -u doc-editor/php/class.php:1.35 doc-editor/php/class.php:1.36 --- doc-editor/php/class.php:1.35 Sat Apr 18 13:27:47 2009 +++ doc-editor/php/class.php Sat Apr 18 22:16:53 2009 @@ -1991,52 +1991,68 @@ } - function getAllFiles($node) { + function getAllFiles($node, $search='') { // Get Files Need Commit $ModifiedFiles = $this->getModifiedFiles(); - // Security - $node = str_replace('..', '', $node); + if( $search == '' ) { - $d = dir(DOC_EDITOR_CVS_PATH.$node); + // Security + $node = str_replace('..', '', $node); - $nodes = array(); - while($f = $d->read()){ + $d = dir(DOC_EDITOR_CVS_PATH.$node); + + $nodes = array(); + while($f = $d->read()){ + + // We display only 'en' and 'LANG' tree + if ($node == '/' && $f != 'en' && $f != $this->cvsLang ) { + continue; + } - // We display only 'en' and 'LANG' tree - if ($node == '/' && $f != 'en' && $f != $this->cvsLang ) { - continue; - } + if ($f == '.' || + $f == '..' || + substr($f, 0, 1) == '.' || // skip hidden files + substr($f, -4) == '.new' || // skip pendingCommit files + substr($f, -6) == '.patch' || // skip pendingPatch files + $f == 'CVS' - if ($f == '.' || - $f == '..' || - substr($f, 0, 1) == '.' || // skip hidden files - substr($f, -4) == '.new' || // skip pendingCommit files - substr($f, -6) == '.patch' || // skip pendingPatch files - $f == 'CVS' - - ) continue; - - if (is_dir(DOC_EDITOR_CVS_PATH . $node . '/' . $f)) { - $nodes[] = array('text' => $f, 'id' => $node . '/' . $f, 'cls' => 'folder', 'type' => 'folder'); - } else { + ) continue; - if (isset($ModifiedFiles[substr($node, 2, (strlen($node)-1)).'/'.$f])) { - $cls = 'file modified'; + if (is_dir(DOC_EDITOR_CVS_PATH . $node . '/' . $f)) { + $nodes[] = array('text' => $f, 'id' => $node . '/' . $f, 'cls' => 'folder', 'type' => 'folder'); } else { - $cls = 'file'; + + if (isset($ModifiedFiles[substr($node, 2, (strlen($node)-1)).'/'.$f])) { + $cls = 'file modified'; + } else { + $cls = 'file'; + } + + // Get extension + $t = explode('.',$f); + $ext = $t[count($t)-1]; + $nodes[] = array('text'=>$f, 'id'=>$node.'/'.$f, 'leaf'=>true, 'cls'=>$cls, 'extension'=>$ext, 'type'=>'file'); + } + } + $d->close(); - // Get extension - $t = explode('.',$f); + } else { + + $s = 'SELECT lang, path, name FROM files WHERE (lang=\''.$this->cvsLang.'\' OR lang=\'en\') AND name LIKE \'%'.$search.'%\' ORDER BY lang, path, name'; + $r = $this->db->query($s) or die($this->db->error.'|'.$s); + while ($a = $r->fetch_object()) { + + $t = explode('.',$a->name); $ext = $t[count($t)-1]; - $nodes[] = array('text'=>$f, 'id'=>$node.'/'.$f, 'leaf'=>true, 'cls'=>$cls, 'extension'=>$ext, 'type'=>'file'); + $nodes[] = array('text'=>$a->lang.$a->path.$a->name, 'id'=>'//'.$a->lang.$a->path.$a->name, 'leaf'=>true, 'cls'=>'file', 'extension'=>$ext, 'type'=>'file'); } + } - $d->close(); return $nodes; } http://cvs.php.net/viewvc.cgi/doc-editor/php/ExtJsController.php?r1=1.17&r2=1.18&diff_format=u Index: doc-editor/php/ExtJsController.php diff -u doc-editor/php/ExtJsController.php:1.17 doc-editor/php/ExtJsController.php:1.18 --- doc-editor/php/ExtJsController.php:1.17 Sat Apr 18 13:27:47 2009 +++ doc-editor/php/ExtJsController.php Sat Apr 18 22:16:53 2009 @@ -660,8 +660,9 @@ $this->phpDoc->isLogged(); $node = $this->getRequestVariable('node'); + $search = $this->getRequestVariable('search'); - $files = $this->phpDoc->getAllFiles($node); + $files = $this->phpDoc->getAllFiles($node, $search); return $this->getResponse($files); }
http://cvs.php.net/viewvc.cgi/doc-editor/js/locale/fr.js?r1=1.8&r2=1.9&diff_format=u Index: doc-editor/js/locale/fr.js diff -u doc-editor/js/locale/fr.js:1.8 doc-editor/js/locale/fr.js:1.9 --- doc-editor/js/locale/fr.js:1.8 Sat Apr 18 08:02:36 2009 +++ doc-editor/js/locale/fr.js Sat Apr 18 22:16:53 2009 @@ -123,7 +123,8 @@ i18n["Posted by"] = "Proposé par"; i18n["This action will <b>reject</b> this patch, send an email to his author and close this tab."] = "Cette action va <b>rejeter</b> ce patch, envoyer un email à son auteur et fermer cet onglet."; i18n["This action will accept this patch, send an email to his author, save the file and close this tab."] = "Cette action va accepter ce patch, envoyer un email à son auteur et fermer cet onglet."; - +i18n["Search result"] = "Résultat de la recherche"; +i18n["Search: "] = "Recherche : "; // Main Menu i18n["Main Menu"] = "Menu principal"; http://cvs.php.net/viewvc.cgi/doc-editor/js/main.js?r1=1.42&r2=1.43&diff_format=u Index: doc-editor/js/main.js diff -u doc-editor/js/main.js:1.42 doc-editor/js/main.js:1.43 --- doc-editor/js/main.js:1.42 Sat Apr 18 13:27:47 2009 +++ doc-editor/js/main.js Sat Apr 18 22:16:53 2009 @@ -6371,16 +6371,52 @@ containerScroll: true, bodyBorder: false, tbar:[ - 'Search: ', ' ', + _('Search: '), ' ', new Ext.form.TwinTriggerField({ + id: 'AF-search', validationEvent:false, validateOnBlur:false, trigger1Class:'x-form-clear-trigger', trigger2Class:'x-form-search-trigger', hideTrigger1:true, width:180, - hasSearch : false, - paramName : 'query', + scope: this, + enableKeyEvents: true, + listeners: { + keypress: function(field, e){ + if (e.getKey() == e.ENTER) { + this.onTrigger2Click(); + } + } + }, + onTrigger1Click: function() { + + this.setValue(''); + this.triggers[0].hide(); + this.scope.treeAllFiles.root.setText(_('Repository')); + this.scope.treeAllFiles.loader = new Ext.tree.TreeLoader({ + baseParams:{task: 'getAllFiles'}, + dataUrl: './php/controller.php' + }); + this.scope.treeAllFiles.root.reload(); + + }, + onTrigger2Click: function() { + + var v = this.getValue(); + + if( v == '' || v.length < 3) { return; } + + this.triggers[0].show(); + this.scope.treeAllFiles.root.setText(_('Search result')); + + this.scope.treeAllFiles.loader = new Ext.tree.TreeLoader({ + baseParams:{search:v, task: 'getAllFiles'}, + dataUrl: './php/controller.php' + }); + this.scope.treeAllFiles.root.reload(); + + } }) ], listeners: { @@ -6467,10 +6503,9 @@ // Only for files if (node.attributes.type === 'file') { - FileName = node.attributes.text; FilePath = node.attributes.id; - FileID = Ext.util.md5('AF-' + FilePath + FileName); - + FileID = Ext.util.md5('AF-' + FilePath); + // Render only if this tab don't exist yet if (!Ext.getCmp('main-panel').findById('AF-' + FileID)) { @@ -6478,11 +6513,14 @@ t = FilePath.split('/'); t.shift(); t.shift(); + + FileName = t[t.length - 1]; + t.pop(); - + FileLang = t[0]; FilePath = t.join('/') + '/'; - + if (FileLang !== 'en') { menuMarkUp = this.menuMarkupLANG('AF-FILE-' + FileID, this); } @@ -7009,7 +7047,14 @@ layout: 'fit', iconCls: 'AllFiles', items: [this.treeAllFiles], - collapsed: true + collapsed: true, + listeners: { + expand: function(panel) { + //TODO: try to find a better way to handle this. If we don't do this, twinTrigger's field is not render because this panel is hidden at the load time + Ext.getCmp('AF-search').wrap.setWidth(200); + } + } + }, { title: _('Pending for commit')+' - <em id="acc-pendingCommit-nb">0</em>', id: 'acc-need-pendingCommit', http://cvs.php.net/viewvc.cgi/doc-editor/php/class.php?r1=1.35&r2=1.36&diff_format=u Index: doc-editor/php/class.php diff -u doc-editor/php/class.php:1.35 doc-editor/php/class.php:1.36 --- doc-editor/php/class.php:1.35 Sat Apr 18 13:27:47 2009 +++ doc-editor/php/class.php Sat Apr 18 22:16:53 2009 @@ -1991,52 +1991,68 @@ } - function getAllFiles($node) { + function getAllFiles($node, $search='') { // Get Files Need Commit $ModifiedFiles = $this->getModifiedFiles(); - // Security - $node = str_replace('..', '', $node); + if( $search == '' ) { - $d = dir(DOC_EDITOR_CVS_PATH.$node); + // Security + $node = str_replace('..', '', $node); - $nodes = array(); - while($f = $d->read()){ + $d = dir(DOC_EDITOR_CVS_PATH.$node); + + $nodes = array(); + while($f = $d->read()){ + + // We display only 'en' and 'LANG' tree + if ($node == '/' && $f != 'en' && $f != $this->cvsLang ) { + continue; + } - // We display only 'en' and 'LANG' tree - if ($node == '/' && $f != 'en' && $f != $this->cvsLang ) { - continue; - } + if ($f == '.' || + $f == '..' || + substr($f, 0, 1) == '.' || // skip hidden files + substr($f, -4) == '.new' || // skip pendingCommit files + substr($f, -6) == '.patch' || // skip pendingPatch files + $f == 'CVS' - if ($f == '.' || - $f == '..' || - substr($f, 0, 1) == '.' || // skip hidden files - substr($f, -4) == '.new' || // skip pendingCommit files - substr($f, -6) == '.patch' || // skip pendingPatch files - $f == 'CVS' - - ) continue; - - if (is_dir(DOC_EDITOR_CVS_PATH . $node . '/' . $f)) { - $nodes[] = array('text' => $f, 'id' => $node . '/' . $f, 'cls' => 'folder', 'type' => 'folder'); - } else { + ) continue; - if (isset($ModifiedFiles[substr($node, 2, (strlen($node)-1)).'/'.$f])) { - $cls = 'file modified'; + if (is_dir(DOC_EDITOR_CVS_PATH . $node . '/' . $f)) { + $nodes[] = array('text' => $f, 'id' => $node . '/' . $f, 'cls' => 'folder', 'type' => 'folder'); } else { - $cls = 'file'; + + if (isset($ModifiedFiles[substr($node, 2, (strlen($node)-1)).'/'.$f])) { + $cls = 'file modified'; + } else { + $cls = 'file'; + } + + // Get extension + $t = explode('.',$f); + $ext = $t[count($t)-1]; + $nodes[] = array('text'=>$f, 'id'=>$node.'/'.$f, 'leaf'=>true, 'cls'=>$cls, 'extension'=>$ext, 'type'=>'file'); + } + } + $d->close(); - // Get extension - $t = explode('.',$f); + } else { + + $s = 'SELECT lang, path, name FROM files WHERE (lang=\''.$this->cvsLang.'\' OR lang=\'en\') AND name LIKE \'%'.$search.'%\' ORDER BY lang, path, name'; + $r = $this->db->query($s) or die($this->db->error.'|'.$s); + while ($a = $r->fetch_object()) { + + $t = explode('.',$a->name); $ext = $t[count($t)-1]; - $nodes[] = array('text'=>$f, 'id'=>$node.'/'.$f, 'leaf'=>true, 'cls'=>$cls, 'extension'=>$ext, 'type'=>'file'); + $nodes[] = array('text'=>$a->lang.$a->path.$a->name, 'id'=>'//'.$a->lang.$a->path.$a->name, 'leaf'=>true, 'cls'=>'file', 'extension'=>$ext, 'type'=>'file'); } + } - $d->close(); return $nodes; } http://cvs.php.net/viewvc.cgi/doc-editor/php/ExtJsController.php?r1=1.17&r2=1.18&diff_format=u Index: doc-editor/php/ExtJsController.php diff -u doc-editor/php/ExtJsController.php:1.17 doc-editor/php/ExtJsController.php:1.18 --- doc-editor/php/ExtJsController.php:1.17 Sat Apr 18 13:27:47 2009 +++ doc-editor/php/ExtJsController.php Sat Apr 18 22:16:53 2009 @@ -660,8 +660,9 @@ $this->phpDoc->isLogged(); $node = $this->getRequestVariable('node'); + $search = $this->getRequestVariable('search'); - $files = $this->phpDoc->getAllFiles($node); + $files = $this->phpDoc->getAllFiles($node, $search); return $this->getResponse($files); }