[Phpcms-plugins-cvs] admin4phpCMS/modules/phpcms-content module_phpcms-content_en.lng,NONE,1.1 class
Brought to you by:
mjahn
From: Martin J. <mj...@us...> - 2005-05-26 15:56:32
|
Update of /cvsroot/phpcms-plugins/admin4phpCMS/modules/phpcms-content In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19290/modules/phpcms-content Modified Files: class.module_phpcms_content.php Added Files: module_phpcms-content_en.lng Removed Files: module_phpcms_de.lng module_phpcms_en.lng Log Message: beginning of phpcms-content and filemanager --- module_phpcms_en.lng DELETED --- Index: class.module_phpcms_content.php =================================================================== RCS file: /cvsroot/phpcms-plugins/admin4phpCMS/modules/phpcms-content/class.module_phpcms_content.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- class.module_phpcms_content.php 15 May 2005 12:24:03 -0000 1.2 +++ class.module_phpcms_content.php 26 May 2005 15:55:52 -0000 1.3 @@ -28,6 +28,9 @@ /* * $Log$ +* Revision 1.3 2005/05/26 15:55:52 mjahn +* beginning of phpcms-content and filemanager +* * Revision 1.2 2005/05/15 12:24:03 mjahn * Commit as backup during development * @@ -57,7 +60,7 @@ $actiondata1 = array ('module' => 'phpcms-content'); $this->_callEvent('CONFIG_GET', $actiondata1); $this->_CONF = $actiondata1['config']; - + $this->docroot = dirname (realpath ($_SERVER ['DOCUMENT_ROOT']).'/.'); return true; } // function init () @@ -74,17 +77,18 @@ if (isset ($actiondata['request']['action'])) { $this->action = $actiondata['request']['action']; } - if ($this->display) { $this->_registerAction('doGetData', 'getData'); - $this->_registerAction('doGetLanguage', 'getLanguageData'); switch ($this->action) { - case 'config' : - $this->_registerAction('doProcess', 'processConfig'); - $this->_configaction = ''; - if (isset ($actiondata['request']['configform-submit'])) { - $this->_configaction = 'save'; - $this->_formdata = $actiondata['post']; + case 'content' : + $this->_registerAction('doProcess', 'processContent'); + $this->_contentaction = ''; + if (isset ($actiondata['request']['contentaction'])) { + $this->_contentaction = strip_tags ($actiondata['request']['contentaction']); + } + $this->_contentfile = ''; + if (isset ($actiondata['request']['contentfile'])) { + $this->_contentfile = strip_tags ($actiondata['request']['contentfile']); } break; default:; @@ -140,20 +144,10 @@ function getphpCMSMenu (&$actiondata) { if (!isset ($this->menu_loaded) || !$this->menu_loaded) { - // load menu from menufile - $actiondata1 = array ('id'=>'TEMPLATE_DIR'); - $this->_callEvent ('PHPCMS_GET_DEFAULT_VALUE', $actiondata1); - $this->templatedir = $actiondata1 ['value']; } } - - function getphpCMSMenuData () { - - return array (); - } - /** * Get content of the module * @@ -168,13 +162,11 @@ return true; } $data = array ('action'=>$this->action); - switch ($this->action) { case 'content':$data = array_merge ($data, $this->getphpCMSContentData ());break; case 'config':$data = array_merge ($data, $this->getphpCMSConfigData ());break; } - $data = array ('action'=>$this->action); if (isset ($this->_error) && count ($this->_error) > 0) { $data ['error'] = $this->_error; } @@ -188,37 +180,101 @@ function processConfig (&$actiondata) { } - function getphpCMSContentData () { - // get templatefiles - - // get menufiles - - // get menudata of current menufile - - // get contentfile of selected menuentry - + function processContent (&$actiondata) { + // get contentfile + if (trim ($this->_contentfile) && file_exists ($this->docroot.$this->_contentfile)) { + $this->_getContentData (); + } + + // get projectdata + $projectfile = ''; + if (isset ($this->contents ['PROJECT'])) { + $projectfile = trim ($this->contents ['PROJECT']); + } + $projectdata = $this->_getProjectData ($projectfile); + // get menudata of current menufile / projectfile + $menufile = $this->docroot.$projectdata ['MENU']; + include_once (dirname (__FILE__).'/includes/class.phpcmsMenu.php'); + $this->menu = new phpcmsMenu (); + $this->menu->load ($menufile); // end } - function getLanguageData (&$actiondata) { - - $langAvailable = array ('de', 'en'); - - $data = $actiondata [$actiondata ['tag']]; - - foreach ($langAvailable as $lang) { - if (!file_exists (dirname (__FILE__).'/module_phpcms-content_'.$lang.'.lng')) { + function getphpCMSContentData () { + return array ('menu'=>$this->menu->menu, 'contents'=>$this->contents); + } + + function getphpCMSConfigData () { + return array ('menu'=>$this->menu->menu, 'contents'=>$this->contents); + } + + function _getContentData () { + $contents = file ($this->docroot.$this->_contentfile); + $this->contents = array (); + $temp = ''; + $fieldname = ''; + for ($i = 0; $i < count ($contents); $i++) { + $start = strpos ($contents [$i], '{'); + $ende = strpos ($contents [$i], '}', $start + 1); + // is there a new field-definition? + if ($start == 1 && $ende > $start) { + // oh, we got a new field definition in the contentfile + if (!isset ($this->contents [$fieldname])) { + // save the content in front of the new field-definition in the old field + $temp .= substr ($contents [$i], 0, $start - 1); + $this->contents [$fieldname] = $temp; + } + // get the new fieldname + $fieldname = substr ($contents [$i], $start + 1, $ende - $start); + // save content between the fieldname and the end of the line in the new field + $temp = substr ($contents [$i], $ende + 1, strlen ($contents [$i]) - $ende); + continue;; + } + $temp .= $contents [$i]; + } + if (!isset ($this->contents [$fieldname])) { + $this->contents [$fieldname] = $temp; + } + } + + function _getProjectData ($projectfile = '') { + if (trim ($projectfile) == '') { + // get projectdir + $actiondata1 = array ('id'=>'GLOBAL_PROJECT_FILE'); + $this->_callEvent ('PHPCMS_GET_DEFAULTS_VALUE', $actiondata1); + $projectfile = $actiondata1 ['value']; + } + if (!file_exists ($this->docroot.$projectfile)) { + return false; + } + $data = file ($this->docroot.$projectfile); + $ret = array (); + $vars = array (); + for ($i = 0; $i < count ($data); $i++) { + $line = trim ($data [$i]); + if ($line {0} == ';') { + // the line is commented out continue; } - if (isset ($data [$lang])) { - $data [$lang] = array_merge ($data [$lang], parse_ini_file (dirname (__FILE__).'/module_phpcms-content_'.$lang.'.lng')); - } else { - $data [$lang] = parse_ini_file (dirname (__FILE__).'/module_phpcms-content_'.$lang.'.lng', true); + // search for the symbol ':=' + $trenner = strpos ($line, ':='); + if ($trenner < 2) { + continue; + } + + $fieldname = substr ($line, 0, $trenner - 1); + $value = substr ($line, $trenner + 2, strlen ($line)); + + // replace variables ($home) + if ($fieldname == 'HOME') { + $vars ['$home'] = $value; } + + $value = str_replace (array_keys ($vars), array_values ($vars), $value); + $value = str_replace ('//', '/', $value); + $ret [$fieldname] = trim ($value); } - $actiondata [$actiondata ['tag']] = $data; - - return true; + return $ret; } } --- NEW FILE: module_phpcms-content_en.lng --- [editor] title_editor = "Editor" title_menu = "Menu" title_menu_options = "Options" button_new = "New" button_open ="Open" button_save = "Save" button_delete = "Delete" button_saveexit = "Save and quit" --- module_phpcms_de.lng DELETED --- |