[Phpcms-plugins-cvs] admin4phpCMS/modules/layout class.module_layout.php,1.6,1.7 layout.xml,1.2,1.3
Brought to you by:
mjahn
From: Martin J. <mj...@us...> - 2004-06-05 12:44:32
|
Update of /cvsroot/phpcms-plugins/admin4phpCMS/modules/layout In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16471/modules/layout Modified Files: class.module_layout.php layout.xml Log Message: separated layout-files Index: layout.xml =================================================================== RCS file: /cvsroot/phpcms-plugins/admin4phpCMS/modules/layout/layout.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- layout.xml 4 Jun 2004 11:11:58 -0000 1.2 +++ layout.xml 5 Jun 2004 12:44:23 -0000 1.3 @@ -2,26 +2,11 @@ <!DOCTYPE layout SYSTEM "layout.dtd"> <layout> - <document> + <empty> <![CDATA[ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> - <head> - <title>Verwaltungsoberfläche</title> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> - <meta name="description" content="Administrationsoberfläche von phpCMS" /> - <meta name="robots" content="noindex,nofollow" /> - <meta name="author" content="Martin Jahn" /> - <meta name="language" content="de" /> - <meta http-equiv="imagetoolbar" content="no" /> - <link rel="stylesheet" href="./modules/layout/layout.css" type="text/css" /> - </head> - <body> <content /> - </body> -</html> ]]> - </document> + </empty> <block> <![CDATA[ Index: class.module_layout.php =================================================================== RCS file: /cvsroot/phpcms-plugins/admin4phpCMS/modules/layout/class.module_layout.php,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- class.module_layout.php 4 Jun 2004 11:32:08 -0000 1.6 +++ class.module_layout.php 5 Jun 2004 12:44:23 -0000 1.7 @@ -30,6 +30,9 @@ /* * $Log$ +* Revision 1.7 2004/06/05 12:44:23 mjahn +* separated layout-files +* * Revision 1.6 2004/06/04 11:32:08 mjahn * several changes * @@ -149,71 +152,89 @@ **/ function displayLayout (&$actiondata) { - $this->_readLayoutFile(); - - // set the left content block - $actiondata = array ('_type'=>'block', '_id'=>'menu', 'id'=>'menu', 'name'=>'menu'); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); - - // set the phpcms-logo - $actiondata = array ('_type'=>'image', '_root'=>'menu', '_id'=>'logo', 'id'=>'', 'class'=>'', 'src'=>'phpcms.png', 'width'=>'181', 'height'=>'60', 'alt'=>'', 'title'=>'phpCMS-Logo v2'); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); - - // set the menu-root - $actiondata = array ('_type'=>'ulist', '_root'=>'menu', '_id'=>'mainmenu', 'id'=>'', 'class'=>''); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); - - // get the main-menu-tree - $actiondata = array ('_root'=>'mainmenu'); - $this->_callEvent ('DISPLAY_PARSE_MENU_MAIN', $actiondata); - - // set container for statusbar - $actiondata = array ('_type'=>'block', '_root'=>'menu', '_id'=>'statusbar', 'id'=>'', 'class'=>''); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + // parse the layoutfile for the elements + $this->_readLayoutFiles(); - // get the statusbar-entries - $actiondata = array ('_root'=>'statusbar'); - $this->_callEvent ('DISPLAY_PARSE_STATUSBAR', $actiondata); - - // set the copyright-message - $actiondata = array ('_type'=>'paragraph', '_root'=>'menu', '_id'=>'copyright', 'id'=>'', 'class'=>'', 'content'=>'© 2004, Alle Rechte bei phpcms-plugin-Team'); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + // read layoutfile for the framework + $output = join ('', file (dirname (__FILE__).'/layout.tpl')); - // set right content block - $actiondata = array ('_type'=>'block', '_id'=>'content', 'id'=>'content', 'class'=>''); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); - - // set the submenu block - $actiondata = array ('_type'=>'ulist', '_id'=>'submenu', 'id'=>'submenu', 'class'=>'', '_root'=>'content'); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); - - // get the error-messages - $actiondata = array ('_root'=>'submenu'); - $this->_callEvent ('DISPLAY_PARSE_MENU_SUB', $actiondata); - - // set the error-message block - $actiondata = array ('_type'=>'block', '_id'=>'error', 'id'=>'', 'class'=>'error', '_root'=>'content'); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); - - // get the error-messages - $actiondata = array ('_root'=>'error'); - $this->_callEvent ('DISPLAY_PARSE_ERROR', $actiondata); + // get all tags from the framework-layoutfile + $matches = preg_match_all ('°<phpcms-admin:([^(?/>)]*)\s/>°im', $output, $tags); + $tagnames = $tags[1]; + $search = $tags[0]; + $replace = array(); + unset ($tags); - // set the content block - $actiondata = array ('_type'=>'block', '_id'=>'inhalt', 'id'=>'', 'class'=>'content', '_root'=>'content'); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); - - // get the content - $actiondata = array ('_root'=>'inhalt'); - $this->_callEvent ('DISPLAY_PARSE_CONTENT', $actiondata); + for ($i = 0; $i < $matches; $i++) { + $replace[$i] = ''; + switch ($tagnames[$i]) { + case 'mainmenu': + // set the menu-root + $actiondata = array ('_type'=>'ulist', '_id'=>'mainmenu', 'id'=>'mainmenu'); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + // get the main-menu-tree + $actiondata = array ('_root'=>'mainmenu'); + $this->_callEvent ('DISPLAY_PARSE_MENU_MAIN', $actiondata); + if (isset ($this->_ids['mainmenu']['_sub'])) { + $replace[$i] = $this->displayElement ($this->_ids['mainmenu']); + } + break; + + case 'statusbar': + // set container for statusbar + $actiondata = array ('_type'=>'empty', '_id'=>'statusbar'); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + // get the statusbar-entries + $actiondata = array ('_root'=>'statusbar'); + $this->_callEvent ('DISPLAY_PARSE_STATUSBAR', $actiondata); + if (isset ($this->_ids['statusbar']['_sub'])) { + $replace[$i] = $this->displayElement ($this->_ids['statusbar']); + } + break; + + case 'submenu': + // set the submenu block + $actiondata = array ('_type'=>'ulist', '_id'=>'submenu', 'id'=>'submenu'); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + // get the error-messages + $actiondata = array ('_root'=>'submenu'); + $this->_callEvent ('DISPLAY_PARSE_MENU_SUB', $actiondata); + if (isset ($this->_ids['submenu']['_sub'])) { + $replace[$i] = $this->displayElement ($this->_ids['submenu']); + } + break; + + case 'error': + // set the error-message block + $actiondata = array ('_type'=>'empty', '_id'=>'error'); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + // get the error-messages + $actiondata = array ('_root'=>'error'); + $this->_callEvent ('DISPLAY_PARSE_ERROR', $actiondata); + if (isset ($this->_ids['error']['_sub'])) { + $replace[$i] = $this->displayElement ($this->_ids['error']); + } + break; + + case 'content': + // set the content block + $actiondata = array ('_type'=>'empty', '_id'=>'content'); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + + // get the content + $actiondata = array ('_root'=>'content'); + $this->_callEvent ('DISPLAY_PARSE_CONTENT', $actiondata); + if (isset ($this->_ids['content']['_sub'])) { + $replace[$i] = $this->displayElement ($this->_ids['content']); + } + break; + + default:; + } + } - /* - echo '<pre>'; - print_r($this->_elements); - echo '</pre>'; - */ - // generate output - echo $this->displayGroup ($this->_elements); + echo str_replace ($search, $replace, $output); + //print_r($this->_elements); } @@ -235,18 +256,6 @@ } // check if sub-elements exist - - if (isset ($elements[$i]['_sub']) && is_array ($elements[$i]['_sub'])) { - - // get the content of the sub-elements - $content = $this->displayGroup ($elements[$i]['_sub']); - - // merge the sub-element-content with the params of the element - if (!isset ($elements[$i]['content'])) { - $elements[$i]['content'] = $content; - } - } - $o .= $this->displayElement ($elements[$i]); } return $o; @@ -270,6 +279,17 @@ $element['content'] = ''; } + if (isset ($element['_sub']) && is_array ($element['_sub'])) { + + // get the content of the sub-elements + $content = $this->displayGroup ($element['_sub']); + + // merge the sub-element-content with the params of the element + if (!isset ($element['content']) || $element['content'] == '') { + $element['content'] = $content; + } + } + // create the search- and replace-arrays $replace = $search = array(); foreach (array_keys ($element) as $id) { @@ -280,6 +300,7 @@ $replace[] = $element[$id]; } + //print_r ($replace); return str_replace ($search, $replace, $this->_layout[$element['_type']]."\n"); } @@ -291,17 +312,17 @@ * * @access private **/ - function _readLayoutFile () { + function _readLayoutFiles () { $layoutfile = dirname(__FILE__).'/layout.xml'; if (!isset($layoutfile)) { - $actiondata = array ('errortext'=>'Layoutdatei konnte nicht geladen werden!'); + $actiondata = array ('errortext'=>'Layoutdatei layout.xml konnte nicht geladen werden!'); $this->_callEvent ('ERROR_NOTICE', $actiondata); return false; } if (!file_exists ($layoutfile)) { - $actiondata = array ('errortext'=>'Layoutdatei konnte nicht geladen werden!'); + $actiondata = array ('errortext'=>'Layoutdatei layout.xml konnte nicht geladen werden!'); $this->_callEvent ('ERROR_NOTICE', $actiondata); return false; } |