[Phpcms-plugins-cvs] admin4phpCMS/modules/phpcms layout.xml,NONE,1.1 class.module_phpcms.php,1.1,1.2
Brought to you by:
mjahn
From: Martin J. <mj...@us...> - 2004-08-05 16:38:55
|
Update of /cvsroot/phpcms-plugins/admin4phpCMS/modules/phpcms In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4032/modules/phpcms Modified Files: class.module_phpcms.php Added Files: layout.xml Log Message: tweaked phpcms::cache-module output --- NEW FILE: layout.xml --- <?xml version="1.0" encoding="iso-8859-15" standalone="yes"?> <!DOCTYPE layout SYSTEM "layout.dtd"> <layout name="standard"> <layout:insert name="cachelist"> <![CDATA[ <div class="symbolleiste"> <img src="modules/phpcms/img/cache/del-all.gif" width="20" height="20" alt="" title="Alle Dateien im Cache löschen" /> <img src="modules/phpcms/img/cache/del-sel.gif" width="20" height="20" alt="" title="Ausgewählte Dateien im Cache löschen" /> </div> <ul id="cacheview"> <layout:replace name="content" default="" /> </ul> <div class="symbolleiste"> <img src="modules/phpcms/img/cache/del-all.gif" width="20" height="20" alt="" title="Alle Dateien im Cache löschen" /> <img src="modules/phpcms/img/cache/del-sel.gif" width="20" height="20" alt="" title="Ausgewählte Dateien im Cache löschen" /> </div> ]]> </layout:insert> <layout:insert name="cachedir"> <![CDATA[ <li class="subdir"> <input type="checkbox" name="deletedir[<layout:replace name="cachedir" />]" value="1" /> <layout:replace name="dirname" /> <ul> <layout:replace name="content" default="" /> </ul> </li> ]]> </layout:insert> <layout:insert name="cachefile"> <![CDATA[ <li> <input type="checkbox" name="delete[<layout:replace name="cachefile" />]" value="1" /> <span title="<layout:replace name="cachefile" />"><layout:replace name="filename" /></span> <span class="<layout:replace name="cachetype" />">CACHE</span> <span><layout:replace name="cachetime" /></span> </li> ]]> </layout:insert> </layout> Index: class.module_phpcms.php =================================================================== RCS file: /cvsroot/phpcms-plugins/admin4phpCMS/modules/phpcms/class.module_phpcms.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- class.module_phpcms.php 24 Jul 2004 08:58:25 -0000 1.1 +++ class.module_phpcms.php 5 Aug 2004 16:38:42 -0000 1.2 @@ -28,8 +28,8 @@ /* * $Log$ -* Revision 1.1 2004/07/24 08:58:25 mjahn -* changed some things +* Revision 1.2 2004/08/05 16:38:42 mjahn +* tweaked phpcms::cache-module output * */ /** @@ -43,8 +43,9 @@ * This module <b>provides</b> some events for use in the other modules: * </p> * <ul> -* <li><b>PHPCMS_GET_MENU</b></li> -* <li><b>PHPCMS_SET_MENU</b></li> +* <li><b>PHPCMS_GET_MENU</b> gets a menu-entry of the phpCMS-menufile</li> +* <li><b>PHPCMS_SET_MENU</b> sets a menu-entry in the phpCMS-menufile</li> +* <li><b>PHPCMS_GET_DEFAULT_VALUE</b> returns a configuration-value of the phpCMS-config</li> * </ul> * * @package admin4phpCMS @@ -133,7 +134,7 @@ continue; } - if (preg_match ('°\$this->([^=]*)=(.*?)$°im', $line, $erg)) { + if (preg_match ('%\$this->([^=]*)=(.*?)$%im', $line, $erg)) { $id = trim ($erg [1]); $value = trim ($erg [2]); if ($value{0} == '\'') { @@ -156,9 +157,6 @@ case 'tags':; $this->_registerAction ('doParseContent', 'getTagsContent'); break; - case 'cache':; - //$this->_registerAction ('doParseContent', 'getCacheContent'); - break; default: $this->_registerAction ('doParseContent', 'getContent'); } @@ -199,7 +197,7 @@ if (!$this->display) { return true; - } + } $root = $actiondata['_root']; @@ -215,7 +213,7 @@ } $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); - $actiondata = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Menüverwaltung', 'module'=>'phpcms', '_id'=>'phpcmsmenu', 'action'=>'menu'); + $actiondata = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Menüverwaltung', 'module'=>'phpcms', '_id'=>'phpcmsmenu', 'action'=>'menu'); if ($this->action == 'menu') { $actiondata['extra'] = 'id="current"'; } @@ -254,9 +252,9 @@ if ($this->action == 'menu' || $this->action == 'template' || $this->action == 'tags') { - $content = 'Durch Auswahl eines Templates ist es möglich, die Menüdatei, das Seitentemplate und die Tagdatei zu bearbeiten. '. - 'Eventuell kann die Software auch alle Projectdateien auslesen, obwohl phpCMS ja keine feste Endung für eine Projectdatei vorgibt. '. - 'Damit wäre es möglich alle Menüdateien, Seitentemplatedateien und Tagdateien getrennt zur Auswahl anzubieten. '; + $content = 'Durch Auswahl eines Templates ist es m�glich, die Men�datei, das Seitentemplate und die Tagdatei zu bearbeiten. '. + 'Eventuell kann die Software auch alle Projectdateien auslesen, obwohl phpCMS ja keine feste Endung f�r eine Projectdatei vorgibt. '. + 'Damit w�re es m�glich alle Men�dateien, Seitentemplatedateien und Tagdateien getrennt zur Auswahl anzubieten. '; $actiondata = array ('_root'=>$actiondata ['_root'], '_id'=>'user1content', '_type'=>'paragraph', 'content'=>$content); @@ -265,7 +263,27 @@ return true; } // function getContent () + + /** + * + **/ + function sortCacheList ($a, $b) { + $dira = strpos ($a, '/') !== false; + $dirb = strpos ($b, '/') !== false; + if ($dira && !$dirb) { + return -1; + } + if (!$dira && $dirb) { + return 1; + } + return strcmp ($a, $b); + + } + // function sortCacheList + /** + * + **/ function processCache (&$actiondata) { $cachedir = $this->docroot.'/cms/phpcms2412/cache/'; @@ -282,10 +300,12 @@ $dh = dir ($cachedir); while ($file = $dh->read ()) { + if ($file{0} == '.') { continue; } + // get the URL of the contentfile $fh = fopen ($cachedir.$file, 'rb'); $temp = fgets ($fh, 1024); $temp .= fgets ($fh, 1024); @@ -297,29 +317,12 @@ $url = basename($file); } - $data = explode ('/', $url); - $basename = array_pop ($data); - $path = $data; - $ext = substr ($file, strrpos ($file, '.') + 1); - switch ($ext) { - case 'gz': $kind = 1; break; - case 'dyn': $kind = 2; break; - default: $kind = 0; - } - - $data = array ('cachename'=>$file, 'filename'=>$url, 'basename'=>$basename, 'filesize'=>filesize ($cachedir.$file), 'filemtime'=>filemtime ($cachedir.$file), 'type'=>$kind); - - $root =& $this->_CACHE; - - $num = count ($path); - for ($i = 0; $i < $num; $i++) { - if (!isset ($root [$path [$i]])) { - $root [urldecode ($path [$i])] = array (); - } - $root =& $root [urldecode ($path [$i])]; - } - - $root [urldecode ($basename)] = $data; + // insert entry + $this->_CACHE [$url] = $file; + } + + if (!uksort ($this->_CACHE, array (&$this, 'sortCacheList'))) { + return false; } } @@ -331,146 +334,76 @@ **/ function getCacheContent (&$actiondata) { + // check if user-status if (!$this->_USER['isLoggedIn']) { return true; } + // check for display of content if (!$this->display) { return true; } - - ob_start (); - print_r($this->_CACHE); - $content = ob_get_contents (); - ob_end_clean (); + // get root-element for layout-module + $root = $actiondata ['_root']; - $actiondata = array ('_root'=>$actiondata ['_root'], '_id'=>'cache', '_type'=>'empty', 'content'=>'<pre>'.$content.'</pre>'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - $actiondata = array ('_root'=>$actiondata ['_root'], '_id'=>'cachedir-', '_type'=>'ulist'); + // initial list for the cache-view + $actiondata = array ('_root'=>$root, '_type'=>'cachelist', '_id'=>'cachedir-'); $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); + // ids of elements that were even created in the layout-module + // necessary for tree structure of the cache-view + $_ids = array ('cachedir-'=>'1'); + + // reset the array with the cache-filenames reset ($this->_CACHE); -/* $data = array (); - $data ['link'] = $this->_CACHE; - $data ['root'] = 'cachedir-'; - $_struct[] = $data; - - while (count ($_struct) > 0) { - $root = $_struct[0]['root']; - $tree =& $_struct[0]['link']; - foreach ($tree as $id=>$entry) { + // walk through the array with the cache-filenames + foreach ($this->_CACHE as $url=>$cachefile) { + // get path elements + $data = explode ('/', $url); + + // set the root-id + $rootid = 'cachedir-'; - if (!isset ($id) || !isset ($tree [$id])) { + // walk through the path-elements, that are subdirectories + $num = count ($data) - 1; + for ($i = 0; $i < $num; $i++) { + + // empty path-element (i.e. between a double slash in the path) + if ($data [$i] == '') { continue; } - - // set list element with empty container - $actiondata = array ('_root'=>$root, '_id'=>$root.$id, '_type'=>'list_entry'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - // directory entry - echo $id.' = '.$tree [$id] ['type']."\n"; - if (!isset ($tree [$id] ['type']) || is_array ($tree [$id] ['type'])) { - //print_r ($tree [$id]); - - // set element for the directory name - $actiondata = array ('_root'=>$root.$id, '_id'=>$root.$id.'-name', '_type'=>'empty', 'content'=>$id); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - //echo '<p>'.$root.'</p>'; - - // set sublist for file-list of the directory - $actiondata = array ('_root'=>$root.$id, '_id'=>$root.$id.'-', '_type'=>'ulist'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - $data = array (); - $data['link'] =& $tree [$id]; - $data['root'] = $root.$id.'-'; - $_struct[] = $data; - continue; - } - - // file entry - if (isset ($tree [$id] ['type'])) { - // set element for the file name - //echo $id; - $actiondata = array ('_root'=>$root.$id, '_id'=>$root.$id.'-name', '_type'=>'empty', 'content'=>$tree [$id] ['basename']); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - continue; - + if (isset ($_ids [$rootid.$data [$i].'-'])) { + $rootid = $rootid.$data [$i].'-'; + continue; } - } - array_shift ($_struct); - - }*/ - -/* - global $xyz; - $xyz = 5; - $this->walkThroughTree ($this->_CACHE, 'cachedir-'); -*/ - $actiondata = array ('_root'=>$actiondata ['_root'], '_id'=>'cacheview', '_type'=>'paragraph', 'content'=>'Hallo'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); + + // set output for subdirectory + $actiondata = array ('_root'=>$rootid, '_type'=>'cachedir', '_id'=>$rootid.$data [$i].'-', 'cachedir'=>$rootid, 'dirname'=>$data [$i], 'extra'=>'class="subdir"'); + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - } - - function walkThroughTree ($tree, $root) { - global $xyz; - if (!is_array ($tree)) { - return true; - } - - if ($xyz <= 0) { - return; - } - - foreach ($tree as $id=>$entry) { - if (!isset ($id) || !isset ($tree [$id])) { - continue; + $_ids [$rootid] = '1'; + $rootid = $rootid.$data [$i].'-'; + } - - // set list element with empty container - $actiondata = array ('_root'=>$root, '_id'=>$root.$id, '_type'=>'list_entry'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - // directory entry - echo $id.' = '.$tree [$id] ['type']."\n"; - if (!isset ($tree [$id] ['type']) || is_array ($tree [$id] ['type'])) { - //print_r ($tree [$id]); - - // set element for the directory name - $actiondata = array ('_root'=>$root.$id, '_id'=>$root.$id.'-name', '_type'=>'empty', 'content'=>$id); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - //echo '<p>'.$root.'</p>'; + $ext = substr ($cachefile, strrpos ($cachefile, '.') + 1); + switch ($ext) { + case 'htm':$cs = 'statisch'; break; + case 'gz': $cs = 'gzip'; break; + case 'dyn': $cs = 'dynamisch'; break; + } - // set sublist for file-list of the directory - $actiondata = array ('_root'=>$root.$id, '_id'=>$root.$id.'-', '_type'=>'ulist'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); + // now we can display the file-entry + $selfid = $rootid.$data [$num]; - $xyz--; - $this->walkThroughTree ($tree [$id], $root.$id.'-'); - continue; - } - - // file entry - if (isset ($tree [$id] ['type'])) { - // set element for the file name - //echo $id; - $actiondata = array ('_root'=>$root.$id, '_id'=>$root.$id.'-name', '_type'=>'empty', 'content'=>$tree [$id] ['basename']); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - continue; - - } - } - $xyz++; + $actiondata = array ('_root'=>$rootid, '_type'=>'cachefile', '_id'=>$selfid, 'cachefile'=>$cachefile, 'filename'=>$data [$num], 'cachetype'=>$cs, 'cachetime'=>'24.07.2004 11:58:59'); + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); + } // foreach } - + /** * Get content of the module * @@ -560,9 +493,9 @@ print_r($this->_CONF); $projectdir = - $content = 'Durch Auswahl einer Projectdatei ist es möglich, die Menüdatei, das Seitentemplate und die Tagdatei zu bearbeiten. '. - 'Eventuell kann die Software auch alle Projectdateien auslesen, obwohl phpCMS ja keine feste Endung für eine Projectdatei vorgibt. '. - 'Damit wäre es möglich alle Menüdateien, Seitentemplatedateien und Tagdateien getrennt zur Auswahl anzubieten. '; + $content = 'Durch Auswahl einer Projectdatei ist es m�glich, die Men�datei, das Seitentemplate und die Tagdatei zu bearbeiten. '. + 'Eventuell kann die Software auch alle Projectdateien auslesen, obwohl phpCMS ja keine feste Endung f�r eine Projectdatei vorgibt. '. + 'Damit w�re es m�glich alle Men�dateien, Seitentemplatedateien und Tagdateien getrennt zur Auswahl anzubieten. '; $actiondata = array ('_root'=>$actiondata ['_root'], '_id'=>'user1content', '_type'=>'paragraph', 'content'=>$content); $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); @@ -592,9 +525,9 @@ $actiondata = array ('_root'=>$actiondata ['_root'], '_id'=>'usercontent', '_type'=>'paragraph', 'content'=>'<pre>'.$content.'</pre>'); $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - $content = 'Durch Auswahl eines Templates ist es möglich, die Menüdatei, das Seitentemplate und die Tagdatei zu bearbeiten. '. - 'Eventuell kann die Software auch alle Projectdateien auslesen, obwohl phpCMS ja keine feste Endung für eine Projectdatei vorgibt. '. - 'Damit wäre es möglich alle Menüdateien, Seitentemplatedateien und Tagdateien getrennt zur Auswahl anzubieten. '; + $content = 'Durch Auswahl eines Templates ist es m�glich, die Men�datei, das Seitentemplate und die Tagdatei zu bearbeiten. '. + 'Eventuell kann die Software auch alle Projectdateien auslesen, obwohl phpCMS ja keine feste Endung f�r eine Projectdatei vorgibt. '. + 'Damit w�re es m�glich alle Men�dateien, Seitentemplatedateien und Tagdateien getrennt zur Auswahl anzubieten. '; $actiondata = array ('_root'=>$actiondata ['_root'], '_id'=>'user1content', '_type'=>'paragraph', 'content'=>$content); $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); @@ -611,5 +544,21 @@ } } // function checkConfigForm () + + function _getDefaultValue () { + + } + + function _loadDefault () { + } + + function _parseDefault () { + } + + function _saveDefault () { + } + + function _setDefaultValue () { + } } ?> \ No newline at end of file |