[Phpcms-plugins-cvs] admin4phpCMS/modules/phpcms class.module_phpcms.php,NONE,1.1 class.phpcms_menu.
Brought to you by:
mjahn
From: Martin J. <mj...@us...> - 2004-07-24 08:58:36
|
Update of /cvsroot/phpcms-plugins/admin4phpCMS/modules/phpcms In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24990/modules/phpcms Added Files: class.module_phpcms.php class.phpcms_menu.php config.tpl.xml Log Message: changed some things --- NEW FILE: config.tpl.xml --- <?xml version="1.0" encoding="iso-8859-1"?> <structure> <tab id="standard" label="Allgemein"> <element id="PAGE_EXTENSION" label="Erweiterung der Seiten" type="input_text" /> <element id="PAGE_DEFAULTNAME" label="Standarderweiterung der Seiten" type="input_text" /> <element id="TEMPEXT" label="Erweiterung der Templatedateien" type="input_text" /> <element id="GLOBAL_PROJECT_FILE" label="Standard Projectdatei" type="input_text" /> <element id="GLOBAL_PROJECT_HOME" label="Standard Homeverzeichnis" type="input_text" /> <element id="PLUGIN_DIR" label="Standard-Pluginverzeichnis" type="input_text" /> <element id="START_FIELD" label="Start-Feld" type="input_text" /> <element id="STOP_FIELD" label="Stop-Feld" type="input_text" /> </tab> <tab id="pax" label="PAX & MAil2Crypt"> <element id="PAX" label="PAX-Erweiterung" type="checkbox" /> <element id="PAXTAGS" label="PAX-Tags" type="checkbox" /> <element id="MAIL2CRYPT" label="Mail2Crypt-Erweiterung" type="checkbox" /> <element id="MAIL2CRYPT_JS" label="Mail2Crypt JS-Pfad" type="input_text" /> <element id="MAIL2CRYPT_IMG" label="Mail2Crypt Img-Pfad" type="input_text" /> </tab> <tab id="cache" label="Cache"> <element id="CACHE_STATE" label="Server-Cache" type="checkbox" /> <element id="CACHE_DIR" label="Cacheverzeichnis" type="input_text" /> <element id="CACHE_CLIENT" label="Client-Cache" type="checkbox" /> <element id="PROXY_CACHE_TIME" label="Proxy-Cache-Zeit" type="input_text" /> </tab> <tab id="server" label="Servereinstellungen"> <element id="GZIP" label="GZIP-Komprimierung" type="checkbox" /> <element id="STEALTH" label="Stealth-Modus" type="checkbox" /> <element id="STEALTH_SECURE" label="Secure-Stealth-Mode" type="checkbox" /> <element id="NOLINKCHANGE" label="Non-Stealt-Mode-Endungen" type="input_text" /> <element id="DEBUG" label="Debug-Modus" type="checkbox" /> <element id="ERROR_PAGE" label="allg. Fehlerseite" type="input_text" /> <element id="ERROR_PAGE_404" label="Fehlerseite für Fehler 404" type="input_text" /> <element id="TAGS_ERROR" label="Fehler bei leerem Tag" type="checkbox" /> <element id="P3P_HEADER" label="P3P-Header" type="checkbox" /> <element id="P3P_POLICY" label="P3P-Policy" type="input_text" /> <element id="P3P_HREF" label="P3P-Link" type="input_text" /> </tab> <tab id="statistik" label="Statistik"> <element id="STATS" label="Statistik" type="checkbox" /> <element id="STATS_DIR" label="Verzeichnis für die Statistik" type="input_text" /> <element id="STATS_CURRENT" label="Verzeichnis für die aktuellen Statistikdaten" type="input_text" /> <element id="STATS_FILE" label="Dateiname für die Statistik" type="input_text" /> <element id="STATS_BACKUP" label="Verzeichnis für Backup der Statistik" type="input_text" /> <element id="STATS_IP_COUNT" label="Anzahl IPs loggen" type="input_text" /> <element id="STATS_IP_IGNORE" label="IPs ausschließen" type="input_text" /> <element id="STATS_URL_COUNT" label="Anzahl URLs zählen" type="input_text" /> <element id="REFERRER" label="Referrer-Logging" type="checkbox" /> <element id="REFERRER_FILE" label="Datei für Referrer-Daten" type="input_text" /> <element id="STATS_REFERER_COUNT" label="Anzahl Referrer" type="input_text" /> <element id="STATS_REFERER_IGNORE" label="IPs ausschließen" type="input_text" /> <element id="REF_RELOAD_LOCK" label="Zeitdauer der Reloadsperre" type="input_text" /> </tab> <tab id="other" label="Sonstiges"> <element id="LANGUAGE" label="Sprache" type="input_text" /> <element id="PASS" label="Passwort" type="input_password" /> <element id="ENABLE_ONLINE_EDITOR" label="Online-Editor" type="checkbox" /> </tab> --> </structure> --- NEW FILE: class.phpcms_menu.php --- <?php /** * Manipulation of the phpcms-menufile * * <b>License</b> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @author Martin Jahn <mj...@us...> * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @copyright Copyright (c) 2004, Martin Jahn * @version $Id$ * @package admin4phpCMS * @subpackage module_phpcms **/ /* * $Log$ */ /** * Class for manipulating the phpcms-menufile * * @package admin4phpCMS * @subpackage module_phpcms * @author Martin Jahn <mj...@us...> * @copyright (c) Copyright by Martin Jahn * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id$ **/ class phpcms_menu { function phpcms_menu () { return $this->__construct (); } function __construct () { $this->docroot = realpath($_SERVER['DOCUMENT_ROOT']); } function insert ($class, $menuEntry, $after = true, $recursive = false) { if (!isset($this->quicklink[$class])) { return false; } $parentclass = substr($class, 0, strrpos ($class, '.')); if ($parentclass == $this->root) { $menu =& $this->menu; } else { $menu =& $this->quicklink[$parentclass]['_sub_']; } for ($i = 0; $i < count ($menu); $i++) { if ($menu[$i]['CLASS'] != $class) { continue; } break; } if (isset($this->quicklink[$menuEntry['CLASS']])) { for ($j = 0; isset($this->quicklink[$menuEntry['CLASS'].$j]); $j++); $menuEntry['CLASS'] = $menuEntry['CLASS'].$j; } if ($after) { $i = ($i == count($menu)) ? count($menu) : $i + 2; array_splice($menu, $i, 0, array($menuEntry)); } else { $i = ($i == 0) ? 0 : $i; array_splice($menu, $i, 0, array($menuEntry)); } $this->quicklink[$menuEntry['CLASS']] = $menu[$i]; } function delete ($class) { if (isset($this->quicklink[$class])) { return false; } $parentclass = substr($class, 0, strrpos ($class, '.')); $menu =& $this->quicklink[$parentclass]; for ($i = 0; $i < count ($menu); $i++) { if ($menu[$i]['CLASS'] != $class) { continue; } break; } $this->quicklink['parentclass'] = array_splice($menu, $i, 1); } function load ($menufile) { if (!file_exists($menufile) || !is_file($menufile)) { return false; } $this->menufile = $menufile; $this->__parse(); } function save ($tofile, $as = 'phpcms') { if (!file_exists(dirname($tofile)) || !is_writeable($tofile)) { return false; } $this->savefile = $tofile; switch ($as) { case 'phpcms': $o = $this->__saveAsPhpCMS(); break; case 'xml': $o = $this->__saveAsXML(); break; default; } $fh = fopen ($tofile, 'wb'); fwrite ($fh, $o); fclose ($fh); } function getEntryByClass ($class) { $parentclass = substr ($class, 0, strrpos ($class, '.')); if (!isset ($this->menuclasses)) { return false; } for ($i = 0; $i < count($this->menuclasses); $i++) { if ($this->menuclasses[$i] == $parentclass) { } } } function __parse () { // check if the menufile exists if (!file_exists($this->menufile) || !is_file($this->menufile)) { return false; } // get content from menufile $data = file ($this->menufile); // initialize some variables $this->menu = array(); $new = false; $menufields = array(); $menucounter = -1; $entrycounter = 0; // walk through the lines of the menufile for ($i = 0; $i < count($data); $i++) { // remove trailing and leading whitespace $line = trim($data[$i]); // check for empty line if (trim($line) == '') { continue; } // check for comment-line if ($line[0] == ';') { countinue; } // check for menu-definition if (substr($line, 0, 5) == 'MENU:') { if (substr($line, -1) == ';') { $line = trim(substr($line, 0, strrpos($line, ';'))); } $menulevel = trim (substr($line, 5)); // increase the counter for the menublocks $menucounter++; // initialize the new element in the menuarray $this->menu[$menucounter] = array(); $entrycounter = 0; // save actual menuposition in pointer $actual =& $this->menu[$menucounter]; continue; } // check for field-definition line if (substr($line, 0, 6) == 'CLASS;') { if (substr($line, -1) == ';') { $line = trim(substr($line, 0, strrpos($line, ';'))); } // get field definitions $menufielddata = explode(';',$line); // initialize some variables $k = 0; $menufields = array(); // walk throught the array of field definitions for ($j = 0; $j < count($menufielddata); $j++) { $l = trim($menufielddata[$j]); // save name of field definition $menufields[$k++] = $l; } continue; } // now we have a menu entry, explode into field elements $entry = explode(';', $line); for ($j = 0; $j < count($menufields); $j++) { // put data of menu-entry into menu-structure $actual[$entrycounter][$menufields[$j]] = trim($entry[$j]); } $actual[$entrycounter]['_level_'] = $menulevel; // increase menucounter $entrycounter++; $this->menuclasses[$menucounter] = substr($actual[0]['CLASS'], 0, strrpos($actual[0]['CLASS'], '.')); } // sort the array with the menu-classes $temp = $this->menuclasses; sort ($temp); $this->root = $temp[0]; echo '<!--'; print_r($this->menu); echo '-->'; // complete building of menu-structure $this->menu = $this->__recurseMenu($this->root); } /** * recursive construction of the menu-tree **/ function __recurseMenu ($menuclass) { if (!in_array ($menuclass, $this->menuclasses)) { return false; } $rootmenu = $this->__getKeyByValue ($this->menuclasses, $menuclass); $menu = array(); $actual = 0; for ($i = 0; $i < count ($this->menu[$rootmenu]); $i++) { $submenuclass = $this->menu[$rootmenu][$i]['CLASS']; $this->quicklink[$submenuclass] =& $menu[$actual]; $menu[$actual] = $this->menu[$rootmenu][$i]; if ($sub = $this->__recurseMenu ($submenuclass)) { $menu[$actual]['_sub_'] = $sub; } $actual++; } return $menu; } function __getKeyByValue($array, $value) { for ($i = 0; $i < count($array); $i++) { if (isset ($array [$i]) && $array[$i] == $value) { return $i; } } } function __saveAsPhpCMS () { $i = 0; $o = ''; $menu = array($this->menu); while (isset($menu[$i])) { $o .= 'MENU:'.$menu[$i][0]['_level_']."\n"; $menuline = $menu[$i][0]; unset ($menuline['_level_']); if (isset($menuline['_sub_'])) { unset ($menuline['_sub_']); } $o .= join(';', array_keys($menuline))."\n"; for ($j = 0; $j < count ($menu[$i]); $j++) { $menuEntry = $menu[$i][$j]; if (isset($menuEntry['_sub_'])) { unset($menuEntry['_sub_']); $menu[] = $menu[$i][$j]['_sub_']; } if (isset($menuEntry['_level_'])) { unset($menuEntry['_level_']); } $o .= join (";\t", $menuEntry)."\n"; } $o .= "\n"; $i++; } return $o; } } ?> --- NEW FILE: class.module_phpcms.php --- <?php /** * Managment of the phpCMS-related administration part * * <b>License</b> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @author Martin Jahn <mj...@us...> * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @copyright Copyright (c) 2004, Martin Jahn * @version $Id: class.module_user.php,v 1.5 2004/06/18 15:17:01 mjahn Exp $ * @package admin4phpCMS * @subpackage module_phpcms **/ /* * $Log$ */ /** * Class for managing the phpCMS-parser and the phpcms-related website-setting * * <p> * This class provides functionality for manipulating menufiles, projectfiles * of a phpCMS-based website and the phpCMS-configurationfile (default.php) * </p> * <p> * 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> * </ul> * * @package admin4phpCMS * @subpackage module_phpcms * @todo Get the class work completly **/ class module_phpcms extends module { /** * @var object $DEFAULTS contains the information of the default.php-file * @access private **/ var $_DEFAULTS; /** * Initialization of the module * * The module registers its own events and connects his methods to some actions **/ function init () { // connect to actions $this->_registerAction ('doParseParam', 'parseParam'); $this->_registerAction ('doParseMenuMain', 'getMenuMain'); $this->_registerAction ('doParseMenuSub', 'getMenuSub'); return true; } /** * Parse the URI-params * * @param array $actiondata $actiondata contains the URI-param-arrays **/ function parseParam (&$actiondata) { $this->display = (isset ($actiondata['request']['moduleid']) && $actiondata['request']['moduleid'] == 'phpcms'); $this->action = ''; if (isset ($actiondata['request']['action'])) { $this->action = $actiondata['request']['action']; } $this->configaction = ''; if (isset ($actiondata['request']['configform-submit'])) { $this->configaction = $actiondata['request']['configform-submit']; $this->_formdata =& $actiondata ['request']; } switch ($this->action) { case 'cache': $this->_registerAction ('doProcess', 'processCache'); break; default: $this->_registerAction ('doProcess', 'Process'); } $this->_callEvent ('USER_GET_STATUS', $actiondata); $this->_USER = $actiondata; $actiondata = array ('module'=>'phpcms', 'format'=>'array'); $this->_callEvent ('CONFIG_GET', $actiondata); $this->_CONF = $actiondata ['config']; return true; } // function parseParam () /** * Process-methode of the module * * @param array $actiondata **/ function process (&$actiondata) { switch ($this->action) { case 'config': if ($this->configaction == 'save') { $this->checkConfigForm (); } $this->_registerAction ('doParseContent', 'getConfigContent'); $config = new XML_Tree (dirname (__FILE__).'/config.tpl.xml'); $this->_DATA = & $config->getTreeFromFile (); $_data = @file ($this->docroot.$this->_CONF ['configfile']); foreach ($_data as $line) { if (!stristr ($line, '$this->')) { continue; } if (preg_match ('°\$this->([^=]*)=(.*?)$°im', $line, $erg)) { $id = trim ($erg [1]); $value = trim ($erg [2]); if ($value{0} == '\'') { $value = substr ($value, 1); } if (substr ($value, -1) == ';') { $value = substr ($value, 0, strlen ($value) - 1); } if (substr ($value, -1) == '\'') { $value = substr ($value, 0, strlen ($value) - 1); } $this->_DEFAULTS [$id] = $value; } } break; case 'menu':; $this->_registerAction ('doParseContent', 'getMenuContent'); break; case 'tags':; $this->_registerAction ('doParseContent', 'getTagsContent'); break; case 'cache':; //$this->_registerAction ('doParseContent', 'getCacheContent'); break; default: $this->_registerAction ('doParseContent', 'getContent'); } return true; } // function process () /** * Get content for mainmenu * * @param array $actiondata $actiondata['_root'] must provide the id of the parental element **/ function getMenuMain (&$actiondata) { if (!$this->_USER['isLoggedIn']) { return true; } $root = $actiondata['_root']; $actiondata = array ('_type'=>'menu_main_entry', '_root'=>$root, 'name'=>'phpCMS', 'module'=>'phpcms', '_id'=>'phpcmsmenu', '_root'=>'mainmenu'); if ($this->display) { $actiondata ['extra'] = 'class="active"'; } $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); return true; } // function getMenuMain () /** * Get submenu of module * * @param array $actiondata $actiondata['_root'] must provide the id of the parental element **/ function getMenuSub (&$actiondata) { if (!$this->_USER['isLoggedIn']) { return true; } if (!$this->display) { return true; } $root = $actiondata['_root']; $actiondata = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Cache', 'module'=>'phpcms', '_id'=>'phpcmscache', 'action'=>'cache'); if ($this->action == 'cache') { $actiondata['extra'] = 'id="current"'; } $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); $actiondata = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Konfiguration', 'module'=>'phpcms', '_id'=>'phpcmsconfig', 'action'=>'config'); if ($this->action == 'config') { $actiondata['extra'] = 'id="current"'; } $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); $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"'; } $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); $actiondata = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Tags editieren', 'module'=>'phpcms', '_id'=>'phpcmstags', 'action'=>'tags'); if ($this->action == 'tags') { $actiondata['extra'] = 'id="current"'; } $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); return true; } // function getMenuSub () /** * Get content of the module * * @param array $actiondata $actiondata['_root'] must provide the id of the parental element **/ function getContent (&$actiondata) { if (!$this->_USER['isLoggedIn']) { return true; } if (!$this->display) { return true; } ob_start (); print_r($this->_CONF); $content = ob_get_contents (); ob_end_clean (); $actiondata = array ('_root'=>$actiondata ['_root'], '_id'=>'usercontent', '_type'=>'paragraph', 'content'=>'<pre>'.$content.'</pre>'); $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); 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. '; $actiondata = array ('_root'=>$actiondata ['_root'], '_id'=>'user1content', '_type'=>'paragraph', 'content'=>$content); $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); } return true; } // function getContent () function processCache (&$actiondata) { $cachedir = $this->docroot.'/cms/phpcms2412/cache/'; if (!file_exists ($cachedir)) { return false; } if (!is_dir ($cachedir)) { return false; } $this->_registerAction ('doParseContent', 'getCacheContent'); $this->_CACHE = array(); $dh = dir ($cachedir); while ($file = $dh->read ()) { if ($file{0} == '.') { continue; } $fh = fopen ($cachedir.$file, 'rb'); $temp = fgets ($fh, 1024); $temp .= fgets ($fh, 1024); fclose ($fh); preg_match('/<!--\sPHPCMS\sFILENAME\s(.*?)\s-->\s*/', $temp, $result); if(isset($result[1])){ $url = $result[1]; } else { $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; } } /** * Get content of the module * * @param array $actiondata $actiondata['_root'] must provide the id of the parental element **/ function getCacheContent (&$actiondata) { if (!$this->_USER['isLoggedIn']) { return true; } if (!$this->display) { return true; } ob_start (); print_r($this->_CACHE); $content = ob_get_contents (); ob_end_clean (); $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'); $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); 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) { if (!isset ($id) || !isset ($tree [$id])) { 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; } } 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); } 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; } // 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); $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++; } /** * Get content of the module * * @param array $actiondata $actiondata['_root'] must provide the id of the parental element **/ function getConfigContent (&$actiondata) { if (!$this->_USER['isLoggedIn']) { return true; } if (!$this->display) { return true; } $actiondata = array ('_root'=>$actiondata ['_root'], '_id'=>'config_container', '_type'=>'block', 'extra'=>'class="config"'); $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); $actiondata = array ('_root'=>'config_container', '_id'=>'configform', '_type'=>'form'); $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); $actiondata = array ('_root'=>'configform', '_id'=>'tablist', '_type'=>'ulist', 'extra'=>'class="tabbed"'); $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); $actiondata = array ('_root'=>$actiondata ['_root'], '_id'=>'tabbox', '_type'=>'block', 'extra'=>'class="tabbox"'); $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); $num_tab = count ($this->_DATA->children); for ($i = 0; $i < $num_tab; $i++) { $tab =& $this->_DATA->children[$i]; // set tab-list-entry $actiondata = array ('_root'=>'tablist', '_id'=>'tablistitem-'.$tab->attributes ['id'], '_type'=>'list_entry'); $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); // set tab-list-entry $actiondata = array ('_root'=>'tablist', '_id'=>'tablistscript-'.$tab->attributes ['id'], '_type'=>'script', 'content'=>'registerTab (\'tabbox-'.$tab->attributes ['id'].'\');'); $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); // set the tab-link $actiondata = array ('_root'=>'tablistitem-'.$tab->attributes ['id'], '_id'=>'tablink-'.$tab->attributes ['id'], '_type'=>'link', 'href'=>'#tabbox-'.$tab->attributes ['id'], 'content'=>$tab->attributes ['label'], 'extra'=>'onclick="displayTab (\'tabbox-'.$tab->attributes ['id'].'\')" onkeypress="displayTab (\'tabbox-'.$tab->attributes ['id'].'\')"'); $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); // set the tab-box $actiondata = array ('_root'=>'tabbox', '_id'=>'tabbox-'.$tab->attributes ['id'], '_type'=>'block', 'extra'=>'id="tabbox-'.$tab->attributes ['id'].'" class="tabbox"'); $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); // walk through the array of config-items $num = count ($tab->children); for ($j = 0; $j < $num; $j++) { if (!isset ($this->_DEFAULTS [$tab->children [$j]->attributes ['id']])) { continue; } // set config-field $actiondata = array ('_root'=>'tabbox-'.$tab->attributes ['id'], '_id'=>'config-'.$tab->children [$j]->attributes ['id'], '_type'=>'form_'.$tab->children [$j]->attributes ['type'], 'label'=>$tab->children [$j]->attributes ['label'], 'value'=>$this->_DEFAULTS [$tab->children [$j]->attributes ['id']], 'name'=>'config-'.$tab->children [$j]->attributes ['id']); $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); } } // set the tab-box $actiondata = array ('_root'=>'configform', '_id'=>'configform-submit', '_type'=>'form_button', 'type'=>'submit', 'name'=>'configform-submit', 'value'=>'save', 'text'=>'Speichern'); $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); return true; } // function getConfigContent () /** * Get content of the module * * @param array $actiondata $actiondata['_root'] must provide the id of the parental element **/ function getMenuContent (&$actiondata) { if (!$this->_USER['isLoggedIn']) { return true; } if (!$this->display) { return true; } include_once (dirname (__FILE__).'/class.phpcms_menu.php'); $this->_MENU =& new phpcms_menu (); $this->_MENU->load (); 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. '; $actiondata = array ('_root'=>$actiondata ['_root'], '_id'=>'user1content', '_type'=>'paragraph', 'content'=>$content); $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); return true; } // function getMenuContent () /** * Get content of the module * * @param array $actiondata $actiondata['_root'] must provide the id of the parental element **/ function getTagsContent (&$actiondata) { if (!$this->_USER['isLoggedIn']) { return true; } if (!$this->display) { return true; } ob_start (); print_r($this->_CONF); $content = ob_get_contents (); ob_end_clean (); $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. '; $actiondata = array ('_root'=>$actiondata ['_root'], '_id'=>'user1content', '_type'=>'paragraph', 'content'=>$content); $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); return true; } // function getTagsContent () function checkConfigForm () { foreach ($this->_formdata as $id=>$value) { if (substr ($id, 0, 7) != 'config-') { continue; } //echo '<p>'.$id.' = '.$value.'</p>'; } } // function checkConfigForm () } ?> |