R32658 - in /trunk/sitemgr: ./ inc/ setup/ sitemgr-site/inc/ sitemgr-site/templates/default/style/ templates/default/

Author: ralfbecker
New Revision: 32658

URL: http://www.egroupware.org/viewvc/egroupware?rev=32658&view=rev
Log:
GUI to edit Joomla 1.5 template preferences and store them template specific in sitemgr config

Added:
trunk/sitemgr/templates/default/templateprefs.xet
Modified:
trunk/sitemgr/inc/class.Common_UI.inc.php
trunk/sitemgr/inc/class.Theme_BO.inc.php
trunk/sitemgr/setup/etemplates.inc.php
trunk/sitemgr/sitemgr-site/inc/class.joomla_ui.inc.php
trunk/sitemgr/sitemgr-site/templates/default/style/default.css
trunk/sitemgr/templates/default/sitemgr_preferences.tpl
trunk/sitemgr/templates/default/theme_info.tpl
trunk/sitemgr/theme_info.php

Modified: trunk/sitemgr/inc/class.Common_UI.inc.php
URL: http://www.egroupware.org/viewvc/egroupware/trunk/sitemgr/inc/class.Common_UI.inc.php?rev=32658&r1=32657&r2=32658&view=diff

— trunk/sitemgr/inc/class.Common_UI.inc.php (original)
+++ trunk/sitemgr/inc/class.Common_UI.inc.php Sat Oct 23 22:47:36 2010
@@ -1,499 +1,675 @@

<?php - /**************************************************************************\ - * eGroupWare SiteMgr - Web Content Management * - * http://www.egroupware.org * - * -------------------------------------------- * - * 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. * - \**************************************************************************/ - - /* $Id$ */ - - class Common_UI - { - var $t, $acl, $do_sites_exist, $menu; - /** - * Instance of theme class - * - * @var Theme_BO - */ - var $theme; - var $public_functions = array - ( - 'DisplayPrefs' => True, - 'DisplayMenu' => True, - 'DisplayIFrame' => True - ); - - function Common_UI() - { - $GLOBALS['Common_BO'] =& CreateObject('sitemgr.Common_BO'); - $this->do_sites_exist = $GLOBALS['Common_BO']->sites->set_currentsite(False,'Administration'); - $this->t = new Template($GLOBALS['egw']->common->get_tpl_dir('sitemgr')); - $this->acl = &$GLOBALS['Common_BO']->acl; - $this->theme = &$GLOBALS['Common_BO']->theme; - $this->pages_bo = &$GLOBALS['Common_BO']->pages; - $this->cat_bo = &$GLOBALS['Common_BO']->cats; - } - - - function DisplayMenu() - { - $this->DisplayHeader(); - $this->t->set_file('MainMenu','mainmenu.tpl'); - $this->t->set_block('MainMenu','switch','switchhandle'); - $this->t->set_block('MainMenu','menuentry','entry'); - $this->t->set_var('lang_sitemenu',lang('Website') . ' ' . $GLOBALS['Common_BO']->sites->current_site['site_name']); - foreach($GLOBALS['Common_BO']->get_sitemenu() as $display => $value) - { - if ($display == '_NewLine_') +/** + * EGroupware SiteMgr CMS + * + * @link http://www.egroupware.org + * @package sitemgr + * @author Ralf Becker + * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License + * @version $Id$ + */ + +/** + * User interface for site configuration + */ +class Common_UI +{ + var $t, $acl, $do_sites_exist, $menu; + /** + * Instance of theme class + * + * @var Theme_BO + */ + var $theme; + var $public_functions = array( + 'DisplayPrefs' => True, + 'DisplayMenu' => True, + 'DisplayIFrame' => True, + 'templatePrefs' => true, + ); + + /** + * Constructor + */ + function __construct() + { + $GLOBALS['Common_BO'] = CreateObject('sitemgr.Common_BO'); + $this->do_sites_exist = $GLOBALS['Common_BO']->sites->set_currentsite(False,'Administration'); + $this->t = new Template($GLOBALS['egw']->common->get_tpl_dir('sitemgr')); + $this->acl = $GLOBALS['Common_BO']->acl; + $this->theme = $GLOBALS['Common_BO']->theme; + $this->pages_bo = $GLOBALS['Common_BO']->pages; + $this->cat_bo = $GLOBALS['Common_BO']->cats; + } + + /** + * Edit Joomla 1.5+ template preferences + * + * @param array $content=null + * @param string $msg='' + */ + public function templatePrefs(array $content=null,$msg='') + { + if (!is_array($content)) + { + if (!($content = $this->theme->getThemeInfos($_GET['template']))) + { + $msg = lang('Theme "%1" not found!'); + $readonlys['button[save]'] = $readonlys['button[apply]'] = true; + } + else + { + if ($content['params']) + { + self::store_params_as_cf($content['params'],$content['directory']); + $content += self::get_params($content['value'],$content['params'],$content['directory']); + } + else + { + $msg = lang('Template has no parameters!'); + $readonlys['button[save]'] = $readonlys['button[apply]'] = true; + } + } + } + elseif ($content['button']) + { + list($button) = each($content['button']); + unset($content['button']); + + switch($button) + { + case 'save': + case 'apply': + self::set_params($content['value'],$content); + $msg = lang('Parameters saved.'); + break; + } + if ($button == 'save') + { + echo "\n\n\n\n\n\n\n"; + common::egw_exit(); + } + } + $content['msg'] = $msg; + + $GLOBALS['egw_info']['flags']['app_header'] = lang('Edit template preferences for %1',$content['name']); + unset($GLOBALS['Common_BO']); // otherwise etemplate thinks it runs inside sitemgr! + $tpl = new etemplate('sitemgr.templateprefs'); + $tpl->exec('sitemgr.Common_UI.templatePrefs',$content,$sel_options,$readonlys,$content,2); + } + + /** + * Store parameter in sitemgr configuration + * + * @param string $template template-name + * @param array $content param names prefixed with '#' like custom fields + */ + static function set_params($template,array $content) + { + require_once(EGW_SERVER_ROOT.'/sitemgr/sitemgr-site/inc/class.joomla_ui.inc.php'); + $jparam = new JParameter(''); + $arr = array(); + foreach($content as $name => $value) + { + if ($name[0] == '#') + { + $jparam->set(substr($name,1),$value); + } + } + config::save_value('params_'.$template,$jparam->getINI(),'sitemgr'); + } + + /** + * Read parameters from ini file and sitemgr configuration + * + * @param string $template template-name + * @param array $params + * @param string $template_dir directory of template for ini-file + * @return array params with names prefixed with '#' like custom fields + */ + static function get_params($template,array $params,$template_dir) + { + + if (file_exists($ini_file=$template_dir.SEP.'params.ini')) + { + $ini_string = file_get_contents($ini_file); + } + $config = config::read('sitemgr'); + if (isset($config['params_'.$template])) + { + $ini_string .= $config['params_'.$template]; + } + require_once(EGW_SERVER_ROOT.'/sitemgr/sitemgr-site/inc/class.joomla_ui.inc.php'); + $jparam = new JParameter($ini_string); + $arr = array(); + foreach($jparam->toArray() as $name => $value) + { + $arr['#'.$name] = $value; + } + foreach($params as $param) + { + if ($param['name'] && !isset($arr['#'.$param['name']])) + { + $arr['#'.$param['name']] = $param['default']; + } + } + return $arr; + } + + /** + * Store Joomla template parameters as EGroupware custom fields + * + * @param array $params + */ + static function store_params_as_cf(array $params,$template_dir) + { + $cfs = array(); + foreach($params as $param) + { + switch($param['type']) + { + case 'spacer': + $cfs[] = array( + 'type' => 'label', + 'label' => str_replace('_',' ',$param['default']), + 'order' => ++$order, + ); + break; + case 'folderlist': + $param['option'] = array( + '' => '- '.lang('Default').' -', + '-1' => '- '.lang('None selected').' -', + ); + $dir = $template_dir.SEP.implode('/',array_slice(explode('/',$param['directory']),2)); + foreach(scandir($dir) as $file) + { + if ($file[0] != '.' && $file != 'index.html') + { + $param['option'][$file] = $file; + } + } + // fall through + case 'list': + case 'radio': + $cfs[$param['name']] = array( + 'type' => /*$param['type'] == 'radio' ? 'radio' :*/ 'select', + 'label' => $param['label'], + 'order' => ++$order, + 'values' => $param['option'], + ); + break; + case 'text': + $cfs[$param['name']] = array( + 'type' => 'text', + 'label' => $param['label'], + 'order' => ++$order, + 'len' => $param['size'], + ); + break; + default: + throw new egw_exception_assertion_failed("Not yet implemented Joomla template parameter type '$param[type]'!"); + } + } + config::save_value('custom_fields', $cfs, 'sitemgr'); + } + + function DisplayMenu() + { + $this->DisplayHeader(); + $this->t->set_file('MainMenu','mainmenu.tpl'); + $this->t->set_block('MainMenu','switch','switchhandle'); + $this->t->set_block('MainMenu','menuentry','entry'); + $this->t->set_var('lang_sitemenu',lang('Website') . ' ' . $GLOBALS['Common_BO']->sites->current_site['site_name']); + foreach($GLOBALS['Common_BO']->get_sitemenu() as $display => $value) + { + if ($display == '_NewLine_') + { + continue; + } + $this->t->set_var(array('value'=>$value,'display'=>lang($display))); + $this->t->parse('sitemenu','menuentry', true); + } + if (($othermenu = $GLOBALS['Common_BO']->get_othermenu())) + { + $this->t->set_var('lang_othermenu',lang('Other websites')); + foreach($othermenu as $display => $value) + { + if ($display === '_NewLine_') { continue; } - $this->t->set_var(array('value'=>$value,'display'=>lang($display))); - $this->t->parse('sitemenu','menuentry', true); - } - if (($othermenu = $GLOBALS['Common_BO']->get_othermenu())) - { - $this->t->set_var('lang_othermenu',lang('Other websites')); - foreach($othermenu as $display => $value) - { - if ($display === '_NewLine_') + if (is_array($value)) + { + $this->t->set_var(array( + 'display' => $value['no_lang'] ? $value['text'] : lang($value['text']), + 'value' => $value['link'] + )); + } + else + { + $this->t->set_var(array( + 'display' => lang($display), + 'value' => $value + )); + } + $this->t->parse('othermenu','menuentry', true); + } + $this->t->parse('switchhandle','switch'); + } + else + { + $this->t->set_var('switchhandle','testtesttest'); + } + $this->t->pfp('out','MainMenu'); + $this->DisplayFooter(); + } + + function DisplayIFrame() + { + if (($site = $GLOBALS['Common_BO']->sites->read(CURRENT_SITE_ID)) && $site['site_url']) + { + $site['site_url'] .= '?mode=Edit&sessionid='.@$GLOBALS['egw_info']['user']['sessionid'] . + '&kp3=' . @$GLOBALS['egw_info']['user']['kp3'] . + '&domain=' . @$GLOBALS['egw_info']['user']['domain']; + + common::egw_header(); + parse_navbar(); + // jdots already uses an iframe, so no need to create an other one + if ($GLOBALS['egw']->framework->template == 'jdots') + { + echo "\n"; + } + else + { + echo "\n".'
'; + echo "\n\t".''; + echo "\n
\n"; + } + } + else + { + $this->DisplayMenu(); + } + } + + function DisplayPrefs() + { + $this->DisplayHeader(); + if ($this->acl->is_admin()) + { + if ($_POST['btnlangchange']) + { + echo '

'; + while (list($oldlang,$newlang) = each($_POST['change'])) + { + if ($newlang == "delete") { - continue; - } - if (is_array($value)) - { - $this->t->set_var(array( - 'display' => $value['no_lang'] ? $value['text'] : lang($value['text']), - 'value' => $value['link'] - )); + echo '' . lang('Deleting all data for %1',$GLOBALS['Common_BO']->getlangname($oldlang)) . '
'; + $this->pages_bo->removealllang($oldlang); + $this->cat_bo->removealllang($oldlang); } else { - $this->t->set_var(array( - 'display' => lang($display), - 'value' => $value - )); + echo '' . lang('Migrating data for %1 to %2', + $GLOBALS['Common_BO']->getlangname($oldlang), + $GLOBALS['Common_BO']->getlangname($newlang)) . + '
'; + $this->pages_bo->migratealllang($oldlang,$newlang); + $this->cat_bo->migratealllang($oldlang,$newlang); } - $this->t->parse('othermenu','menuentry', true); - } - $this->t->parse('switchhandle','switch'); - } - else - { - $this->t->set_var('switchhandle','testtesttest'); - } - $this->t->pfp('out','MainMenu'); - $this->DisplayFooter(); - } - - function DisplayIFrame() - { - if (($site = $GLOBALS['Common_BO']->sites->read(CURRENT_SITE_ID)) && $site['site_url']) - { - $site['site_url'] .= '?mode=Edit&sessionid='.@$GLOBALS['egw_info']['user']['sessionid'] . - '&kp3=' . @$GLOBALS['egw_info']['user']['kp3'] . - '&domain=' . @$GLOBALS['egw_info']['user']['domain']; - - common::egw_header(); - parse_navbar(); - // jdots already uses an iframe, so no need to create an other one - if ($GLOBALS['egw']->framework->template == 'jdots') - { - echo "\n"; - } - else - { - echo "\n".'

'; - echo "\n\t".''; - echo "\n
\n"; - } - } - else - { - $this->DisplayMenu(); - } - } - - function DisplayPrefs() - { - $this->DisplayHeader(); - if ($this->acl->is_admin()) - { - if ($_POST['btnlangchange']) - { - echo '

'; - while (list($oldlang,$newlang) = each($_POST['change'])) + } + echo '

'; + } + + if ($_POST['btnSave']) + { + $oldsitelanguages = $GLOBALS['Common_BO']->sites->current_site['site_languages']; + + if ($oldsitelanguages && ($oldsitelanguages != $_POST['pref']['site_languages'])) + { + $oldsitelanguages = explode(',',$oldsitelanguages); + $newsitelanguages = preg_split('/ ?, ?/',trim($_POST['pref']['site_languages'])); + $replacedlang = array_diff($oldsitelanguages,$newsitelanguages); + $addedlang = array_diff($newsitelanguages,$oldsitelanguages); + if ($replacedlang) { - if ($newlang == "delete") + echo lang('You removed one ore more languages from your site languages.') . '
' . + lang('What do you want to do with existing translations of categories and pages for this language?') . '
'; + if ($addedlang) { - echo '' . lang('Deleting all data for %1',$GLOBALS['Common_BO']->getlangname($oldlang)) . '
'; - $this->pages_bo->removealllang($oldlang); - $this->cat_bo->removealllang($oldlang); + echo lang('You can either migrate them to a new language or delete them') . '
'; } else { - echo '' . lang('Migrating data for %1 to %2', - $GLOBALS['Common_BO']->getlangname($oldlang), - $GLOBALS['Common_BO']->getlangname($newlang)) . - '
'; - $this->pages_bo->migratealllang($oldlang,$newlang); - $this->cat_bo->migratealllang($oldlang,$newlang); + echo lang('Do you want to delete them?'). '
'; } - } - echo ''; - } - - if ($_POST['btnSave']) - { - $oldsitelanguages = $GLOBALS['Common_BO']->sites->current_site['site_languages']; - - if ($oldsitelanguages && ($oldsitelanguages != $_POST['pref']['site_languages'])) - { - $oldsitelanguages = explode(',',$oldsitelanguages); - $newsitelanguages = preg_split('/ ?, ?/',trim($_POST['pref']['site_languages'])); - $replacedlang = array_diff($oldsitelanguages,$newsitelanguages); - $addedlang = array_diff($newsitelanguages,$oldsitelanguages); - if ($replacedlang) + echo ''; + foreach ($replacedlang as $oldlang) { - echo lang('You removed one ore more languages from your site languages.') . '
' . - lang('What do you want to do with existing translations of categories and pages for this language?') . '
'; + $oldlangname = $GLOBALS['Common_BO']->getlangname($oldlang); + echo ""; if ($addedlang) { - echo lang('You can either migrate them to a new language or delete them') . '
'; + foreach ($addedlang as $newlang) + { + echo '"; + } } - else - { - echo lang('Do you want to delete them?'). '
'; - } - echo '
" . $oldlangname . " Migrate to ' . + $GLOBALS['Common_BO']->getlangname($newlang) . "
'; - foreach ($replacedlang as $oldlang) - { - $oldlangname = $GLOBALS['Common_BO']->getlangname($oldlang); - echo ""; - if ($addedlang) - { - foreach ($addedlang as $newlang) - { - echo '"; - } - } - echo ''; - } - echo '
" . $oldlangname . " Migrate to ' . - $GLOBALS['Common_BO']->getlangname($newlang) . " delete
'; + echo ' delete '; } + echo ' '; } - - $oldsitelanguages = $oldsitelanguages ? explode(',',$oldsitelanguages) : array("en"); - - $prefs = $_POST['pref']; - if ($prefs['default_theme'] == 'custom') + } + + $oldsitelanguages = $oldsitelanguages ? explode(',',$oldsitelanguages) : array("en"); + + $prefs = $_POST['pref']; + if ($prefs['default_theme'] == 'custom') + { + $themedir = $GLOBALS['egw_info']['server']['files_dir'].'/'.$prefs['themedir']; + if (empty($prefs['themedir']) || !file_exists($themedir) || !is_dir($themedir)) { - $themedir = $GLOBALS['egw_info']['server']['files_dir'].'/'.$prefs['themedir']; - if (empty($prefs['themedir']) || !file_exists($themedir) || !is_dir($themedir)) - { - $error = lang('Custom template directory does NOT exist or is NOT accessible by webserver!'); - } - $prefs['themesel'] = '/'.$prefs['themedir']; + $error = lang('Custom template directory does NOT exist or is NOT accessible by webserver!'); } - else + $prefs['themesel'] = '/'.$prefs['themedir']; + } + else + { + $prefs['themesel'] = $prefs['default_theme']; + } + unset($prefs['default_theme']); + unset($prefs['themedir']); + if (!$error) $GLOBALS['Common_BO']->sites->saveprefs($prefs); + + echo '

' . ($error ? ''.$error.'' : lang('Changes Saved.')) . '

'; + } + + foreach ($GLOBALS['Common_BO']->sites->current_site['sitelanguages'] as $lang) + { + $langname = $GLOBALS['Common_BO']->getlangname($lang); + $preferences['site_name_' . $lang] = array( + 'title'=>lang('Site name'). ' ' . $langname, + 'note'=>lang('This is used chiefly for meta data and the title bar. If you change the site languages below you have to save before being able to set this preference for a new language.'), + 'default'=>lang('New sitemgr site') + ); + $preferences['site_desc_' . $lang] = array( + 'title'=>lang('Site description'). ' ' . $langname, + 'note'=>lang('This is used chiefly for meta data. If you change the site languages below you have to save before being able to set this preference for a new language.'), + 'input'=>'textarea' + ); + } + + $preferences['home_page_id'] = array( + 'title'=>lang('Default home page ID number'), + 'note'=>lang('This should be a page that is readable by everyone. If you leave this blank, the site index will be shown by default.'), + 'input'=>'option', + 'options'=>$this->pages_bo->getPageOptionList() + ); + $theme = $GLOBALS['Common_BO']->sites->current_site['default_theme']; + if ($theme[0] == '/') $GLOBALS['Common_BO']->sites->current_site['default_theme'] = 'custom'; + $theme_info = $GLOBALS['egw']->link('/sitemgr/theme_info.php'); + $theme_info .= (strpos($theme_info,'?') !== false ? '&' : '?').'theme='; + $edit_link = egw::link('/index.php',array( + 'menuaction' => 'sitemgr.Common_UI.templatePrefs', + 'template' => '', + )); + $preferences['default_theme'] = array( + 'title'=>lang('Template select'), + 'note'=>lang('Choose your site\'s theme or template. Note that if you changed the above checkbox you need to save before choosing a theme or template.').'

'. + lang('Want more templates?
Just download one from the template gallery at %1www.eGroupWare.org%2 or use a %3Mambo Open Source%4 Version 4.5 compatible template eg. from %5. Unpack the downloaded template in your templates directory (%6).', + '','', + '','', + 'www.mamboserver.com', + $GLOBALS['Common_BO']->sites->current_site['site_dir'] . SEP . 'templates'). + '

'.lang('Template Preferences').' '.html::input('template_prefs',lang('Edit'),'button', + 'onclick="egw_openWindowCentered2(\''.$edit_link.'\'+this.form.elements[\'pref[default_theme]\'].value,\'_blank\',640,480); return false;"').'

', + 'input'=>'option', + 'options'=>$this->theme->getAvailableThemes()+array( + 'custom' => array( + 'value' => 'custom', + 'display' => lang('Custom template directory'), + ), + ), + 'extra'=> 'onchange="'. + " document.getElementById('themedir').style.display=this.value=='custom'?'block':'none';". + " document.getElementById('TemplateInfoIframe').style.display=this.value!='custom'?'block':'none';". + " if(this.value!='custom')frames.TemplateInfo.location='$theme_info'+this.value;".'"', + 'below' => ''. + '
'. + '

'.lang("Template directory is relative to EGroupware's files directory. You have to map that direcotory with an alias, so it is accessible like any stock template!")."

\n". + htmlspecialchars($GLOBALS['egw_info']['server']['files_dir']).'/'. + ''. + ($error ? '
'.$error.'' : ''). + '
', + 'default'=>'idots' + ); + $preferences['upload_dir'] = array( + 'title' => lang('Startdirectory in VFS for image uploads'), + 'note' => lang("This directory is in EGroupware's virtual filesystem, NOT in the filesystem of the webserver!").'
'. + lang('The given directory should be readable by the anonymous user for a regular public website!'), + ); + $preferences['htaccess_rewrite'] = array( + 'title' => lang('Generate search engine friendly URLs'), + 'note' => lang('Generates "%1" instead of "%2" URLs.','/name','/index.php?page_name=name').'
'. + ''.lang('You have to enable URL rewriting on the webserver!').'
'. + lang('Eg. be renaming %1 to %2 in the %3 directory for an Apache.','htacces','.htaccess','sitemgr-site'), + 'input' => 'checkbox', + ); + $preferences['site_languages'] = array( + 'title'=>lang('Languages the site user can choose from'), + 'note'=>lang('This should be a comma-separated list of language-codes.'), + 'default'=>'en' + ); + + $this->t->set_file('sitemgr_prefs','sitemgr_preferences.tpl'); + $this->t->set_var('formaction',$GLOBALS['egw']->link( + '/index.php','menuaction=sitemgr.Common_UI.DisplayPrefs')); + $this->t->set_var(array( + 'options' => lang('SiteMgr Options'), + 'lang_save' => lang('Save'), + )); + + $this->t->set_block('sitemgr_prefs','PrefBlock','PBlock'); + foreach($preferences as $name => $details) + { + $inputbox = ''; + switch($details['input']) + { + case 'htmlarea': + $inputbox = $this->inputhtmlarea($name); + break; + case 'textarea': + $inputbox = $this->inputtextarea($name); + break; + case 'checkbox': + $inputbox = $this->inputCheck($name); + break; + case 'option': + $inputbox = $this->inputOption($name, + $details['options'],$details['default'],@$details['extra']); + break; + case 'inputbox': + default: + $inputbox = $this->inputText($name, + $details['input_size'],$details['default']); + } + if ($inputbox) + { + if (isset($details['below'])) { - $prefs['themesel'] = $prefs['default_theme']; + $inputbox .= "
".$details['below']; } - unset($prefs['default_theme']); - unset($prefs['themedir']); - if (!$error) $GLOBALS['Common_BO']->sites->saveprefs($prefs); - - echo '

' . ($error ? ''.$error.'' : lang('Changes Saved.')) . '

'; - } - - foreach ($GLOBALS['Common_BO']->sites->current_site['sitelanguages'] as $lang) - { - $langname = $GLOBALS['Common_BO']->getlangname($lang); - $preferences['site_name_' . $lang] = array( - 'title'=>lang('Site name'). ' ' . $langname, - 'note'=>lang('This is used chiefly for meta data and the title bar. If you change the site languages below you have to save before being able to set this preference for a new language.'), - 'default'=>lang('New sitemgr site') - ); - $preferences['site_desc_' . $lang] = array( - 'title'=>lang('Site description'). ' ' . $langname, - 'note'=>lang('This is used chiefly for meta data. If you change the site languages below you have to save before being able to set this preference for a new language.'), - 'input'=>'textarea' - ); - } - - $preferences['home_page_id'] = array( - 'title'=>lang('Default home page ID number'), - 'note'=>lang('This should be a page that is readable by everyone. If you leave this blank, the site index will be shown by default.'), - 'input'=>'option', - 'options'=>$this->pages_bo->getPageOptionList() - ); - $theme = $GLOBALS['Common_BO']->sites->current_site['default_theme']; - if ($theme[0] == '/') $GLOBALS['Common_BO']->sites->current_site['default_theme'] = 'custom'; - $theme_info = $GLOBALS['egw']->link('/sitemgr/theme_info.php'); - $theme_info .= (strpos($theme_info,'?') !== false ? '&' : '?').'theme='; - $preferences['default_theme'] = array( - 'title'=>lang('Template select'), - 'note'=>lang('Choose your site\'s theme or template. Note that if you changed the above checkbox you need to save before choosing a theme or template.').'

'. - lang('Want more templates?
Just download one from the template gallery at %1www.eGroupWare.org%2 or use a %3Mambo Open Source%4 Version 4.5 compatible template eg. from %5. Unpack the downloaded template in your templates directory (%6).', - '','', - '','', - 'www.mamboserver.com', - $GLOBALS['Common_BO']->sites->current_site['site_dir'] . SEP . 'templates'), - 'input'=>'option', - 'options'=>$this->theme->getAvailableThemes()+array( - 'custom' => array( - 'value' => 'custom', - 'display' => lang('Custom template directory'), - ), - ), - 'extra'=> 'onchange="'. - " document.getElementById('themedir').style.display=this.value=='custom'?'block':'none';". - " document.getElementById('TemplateInfoIframe').style.display=this.value!='custom'?'block':'none';". - " if(this.value!='custom')frames.TemplateInfo.location='$theme_info'+this.value;".'"', - 'below' => ''. - '
'. - '

'.lang("Template directory is relative to EGroupware's files directory. You have to map that direcotory with an alias, so it is accessible like any stock template!")."

\n". - htmlspecialchars($GLOBALS['egw_info']['server']['files_dir']).'/'. - ''. - ($error ? '
'.$error.'' : ''). - '
', - 'default'=>'idots' - ); - $preferences['upload_dir'] = array( - 'title' => lang('Startdirectory in VFS for image uploads'), - 'note' => lang("This directory is in EGroupware's virtual filesystem, NOT in the filesystem of the webserver!").'
'. - lang('The given directory should be readable by the anonymous user for a regular public website!'), - ); - $preferences['htaccess_rewrite'] = array( - 'title' => lang('Generate search engine friendly URLs'), - 'note' => lang('Generates "%1" instead of "%2" URLs.','/name','/index.php?page_name=name').'
'. - ''.lang('You have to enable URL rewriting on the webserver!').'
'. - lang('Eg. be renaming %1 to %2 in the %3 directory for an Apache.','htacces','.htaccess','sitemgr-site'), - 'input' => 'checkbox', - ); - $preferences['site_languages'] = array( - 'title'=>lang('Languages the site user can choose from'), - 'note'=>lang('This should be a comma-separated list of language-codes.'), - 'default'=>'en' - ); - - $this->t->set_file('sitemgr_prefs','sitemgr_preferences.tpl'); - $this->t->set_var('formaction',$GLOBALS['egw']->link( - '/index.php','menuaction=sitemgr.Common_UI.DisplayPrefs')); - $this->t->set_var(Array('setup_instructions' => lang('SiteMgr Setup Instructions'), - 'options' => lang('SiteMgr Options'), - 'lang_save' => lang('Save'), - 'lang_subdir' => lang('There are two subdirectories off of your sitemgr directory that you should move before you do anything else. You don\'t have to move either of these directories, although you will probably want to.'), - 'lang_first_directory' => lang('The first directory to think about is sitemgr-link. If you move this to the parent directory of sitemgr (your egroupware root directory) then you can use setup to install the app and everyone with access to the app will get an icon on their navbar that links them directly to the public web site. If you don\'t want this icon, there\'s no reason to ever bother with the directory.'), - 'lang_second_directory' => lang('The second directory is the sitemgr-site directory. This can be moved anywhere. It can also be named anything. Wherever it winds up, when you point a web browser to it, you will get the generated website. Assuming, of course, that you\'ve accurately completed the setup fields below and also edited the config.inc.php file.'), - 'lang_edit_config_inc}' => lang('The config.inc.php file needs to be edited to point to the eGroupWare directory. Copy the config.inc.php.template file to config.inc.php and then edit it.') - )); - - $this->t->set_block('sitemgr_prefs','PrefBlock','PBlock'); - foreach($preferences as $name => $details) - { - $inputbox = ''; - switch($details['input']) - { - case 'htmlarea': - $inputbox = $this->inputhtmlarea($name); - break; - case 'textarea': - $inputbox = $this->inputtextarea($name); - break; - case 'checkbox': - $inputbox = $this->inputCheck($name); - break; - case 'option': - $inputbox = $this->inputOption($name, - $details['options'],$details['default'],@$details['extra']); - break; - case 'inputbox': - default: - $inputbox = $this->inputText($name, - $details['input_size'],$details['default']); - } - if ($inputbox) - { - if (isset($details['below'])) - { - $inputbox .= "
".$details['below']; - } - $this->PrefBlock($details['title'],$inputbox,$details['note']); - } - } - $this->t->pfp('out','sitemgr_prefs'); + $this->PrefBlock($details['title'],$inputbox,$details['note']); + } + } + $this->t->pfp('out','sitemgr_prefs'); + } + else + { + echo lang("You must be an administrator to setup the Site Manager.") . "

"; + } + $this->DisplayFooter(); + } + + function inputText($name='',$size=40,$default='') + { + if (!is_int($size)) + { + $size=40; + } + $val = $GLOBALS['Common_BO']->sites->current_site[$name]; + if (!$val) + { + $val = $default; + } + + return ''; + } + + function inputtextarea($name,$cols=80,$rows=5,$default='') + { + $val = $GLOBALS['Common_BO']->sites->current_site[$name]; + if (!$val) + { + $val = $default; + } + + return ''. $GLOBALS['egw']->strip_html($val).''; + } + + function inputhtmlarea($name,$cols=80,$rows=5,$default='') + { + return html::htmlarea("pref[$name]",$default,'',$GLOBALS['Common_BO']->sites->current_site['site_url']); + } + + function inputCheck($name = '') + { + $val = $GLOBALS['Common_BO']->sites->current_site[$name]; + if ($val) + { + $checked_yes = ' CHECKED'; + $checked_no = ''; + } + else + { + $checked_yes = ''; + $checked_no = ' CHECKED'; + } + return 'Yes'."\n". + 'No'."\n"; + + } + + function inputOption($name = '', $options='', $default = '',$extra='') + { + if (!is_array($options) || count($options)==0) + { + return lang('No options available.'); + } + $val = $GLOBALS['Common_BO']->sites->current_site[$name]; + if(!$val) + { + $val = $default; + } + $returnValue = ''."\n"; + + foreach($options as $option) + { + $selected=''; + if ($val == $option['value']) + { + $selected = 'selected="1" '; + } + $returnValue.=''.$option['display'].''."\n"; + } + $returnValue .= ''; + return $returnValue; + } + + function PrefBlock($title,$input,$note) + { + //$this->t->set_var('PBlock',''); + $this->t->set_var('pref-title',$title); + $this->t->set_var('pref-input',$input); + $this->t->set_var('pref-note',$note); + $this->t->parse('PBlock','PrefBlock',true); + } + + function DisplayHeader($extra_title='') + { + $GLOBALS['egw_info']['flags']['app_header'] = $GLOBALS['egw_info']['apps']['sitemgr']['title']. + ($extra_title ? ' - '.$extra_title : ''); + common::egw_header(); + + if ($this->do_sites_exist && $GLOBALS['egw_info']['server']['template_set'] != 'idots') + { + $this->t->set_file('sitemgr_header','sitemgr_header.tpl'); + $this->t->set_block('sitemgr_header','switch','switchhandle'); + $this->t->set_var('menulist',$this->menuselectlist()); + if ($GLOBALS['Common_BO']->get_othermenu()) + { + $this->t->set_var('sitelist',$this->siteselectlist()); + $this->t->parse('switchhandle','switch'); } else { - echo lang("You must be an administrator to setup the Site Manager.") . "

"; - } - $this->DisplayFooter(); - } - - function inputText($name='',$size=40,$default='') - { - if (!is_int($size)) - { - $size=40; - } - $val = $GLOBALS['Common_BO']->sites->current_site[$name]; - if (!$val) - { - $val = $default; - } - - return ''; - } - - function inputtextarea($name,$cols=80,$rows=5,$default='') - { - $val = $GLOBALS['Common_BO']->sites->current_site[$name]; - if (!$val) - { - $val = $default; - } - - return ''. $GLOBALS['egw']->strip_html($val).''; - } - - function inputhtmlarea($name,$cols=80,$rows=5,$default='') - { - return html::htmlarea("pref[$name]",$default,'',$GLOBALS['Common_BO']->sites->current_site['site_url']); - } - - function inputCheck($name = '') - { - $val = $GLOBALS['Common_BO']->sites->current_site[$name]; - if ($val) - { - $checked_yes = ' CHECKED'; - $checked_no = ''; + $this->t->set_var('switchhandle',''); + } + $GLOBALS['egw_info']['flags']['app_header'] .= $this->t->parse('out','sitemgr_header'); + } + parse_navbar(); + } + + function DisplayFooter() + { + // is empty atm + // $this->t->set_file('sitemgr_footer','sitemgr_footer.tpl'); + // $this->t->pfp('out','sitemgr_footer'); + } + + function siteselectlist() + { + $selectlist= '' . lang('Other websites') . ''; + while(list($display,$value) = @each($GLOBALS['Common_BO']->othermenu)) + { + if ($display == '_NewLine_') + { + continue; } else { - $checked_yes = ''; - $checked_no = ' CHECKED'; - } - return 'Yes'."\n". - 'No'."\n"; - - } - - function inputOption($name = '', $options='', $default = '',$extra='') - { - if (!is_array($options) || count($options)==0) - { - return lang('No options available.'); - } - $val = $GLOBALS['Common_BO']->sites->current_site[$name]; - if(!$val) - { - $val = $default; - } - $returnValue = ''."\n"; - - foreach($options as $option) - { - $selected=''; - if ($val == $option['value']) - { - $selected = 'selected="1" '; - } - $returnValue.=''.$option['display'].''."\n"; - } - $returnValue .= ''; - return $returnValue; - } - - function PrefBlock($title,$input,$note) - { - //$this->t->set_var('PBlock',''); - $this->t->set_var('pref-title',$title); - $this->t->set_var('pref-input',$input); - $this->t->set_var('pref-note',$note); - $this->t->parse('PBlock','PrefBlock',true); - } - - function DisplayHeader($extra_title='') - { - $GLOBALS['egw_info']['flags']['app_header'] = $GLOBALS['egw_info']['apps']['sitemgr']['title']. - ($extra_title ? ' - '.$extra_title : ''); - common::egw_header(); - - if ($this->do_sites_exist && $GLOBALS['egw_info']['server']['template_set'] != 'idots') - { - $this->t->set_file('sitemgr_header','sitemgr_header.tpl'); - $this->t->set_block('sitemgr_header','switch','switchhandle'); - $this->t->set_var('menulist',$this->menuselectlist()); - if ($GLOBALS['Common_BO']->get_othermenu()) - { - $this->t->set_var('sitelist',$this->siteselectlist()); - $this->t->parse('switchhandle','switch'); - } - else - { - $this->t->set_var('switchhandle',''); - } - $GLOBALS['egw_info']['flags']['app_header'] .= $this->t->parse('out','sitemgr_header'); - } - parse_navbar(); - } - - function DisplayFooter() - { - // is empty atm - // $this->t->set_file('sitemgr_footer','sitemgr_footer.tpl'); - // $this->t->pfp('out','sitemgr_footer'); - } - - function siteselectlist() - { - $selectlist= '' . lang('Other websites') . ''; - while(list($display,$value) = @each($GLOBALS['Common_BO']->othermenu)) - { - if ($display == '_NewLine_') - { - continue; - } - else - { - $selectlist .= '' . lang($display) . '' . "\n"; - } - } - return $selectlist; - } - - function menuselectlist() - { - reset($GLOBALS['Common_BO']->sitemenu); - $selectlist= '' . lang('Website') . ' ' . $GLOBALS['Common_BO']->sites->current_site['site_name'] . ''; - while(list($display,$value) = @each($GLOBALS['Common_BO']->sitemenu)) - { - if ($display == '_NewLine_') - { - continue; - } $selectlist .= '' . lang($display) . '' . "\n"; } - return $selectlist; - } - } -?>
  •   }
    
  •   return $selectlist;
    
  • }
  • function menuselectlist()
  • {
  •   reset($GLOBALS['Common_BO']->sitemenu);
    
  •   $selectlist= '<option>' . lang('Website') . ' ' . $GLOBALS['Common_BO']->sites->current_site['site_name'] . '</option>';
    
  •   while(list($display,$value) = @each($GLOBALS['Common_BO']->sitemenu))
    
  •   {
    
  •   	if ($display == '_NewLine_')
    
  •   	{
    
  •   		continue;
    
  •   	}
    
  •   	$selectlist .= '<option onClick="location.href=this.value" value="' . $value . '">' . lang($display) . '</option>' . "\n";
    
  •   }
    
  •   return $selectlist;
    
  • }
    +}

Modified: trunk/sitemgr/inc/class.Theme_BO.inc.php
URL: http://www.egroupware.org/viewvc/egroupware/trunk/sitemgr/inc/class.Theme_BO.inc.php?rev=32658&r1=32657&r2=32658&view=diff

— trunk/sitemgr/inc/class.Theme_BO.inc.php (original)
+++ trunk/sitemgr/inc/class.Theme_BO.inc.php Sat Oct 23 22:47:36 2010
@@ -1,102 +1,143 @@

<?php - /**************************************************************************\ - * eGroupWare SiteMgr - Web Content Management * - * http://www.egroupware.org * - * Written and (c) by RalfBecker@outdoor-training.de * - * -------------------------------------------- * - * 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. * - \**************************************************************************/ +/** + * EGroupware SiteMgr CMS - Site templates aka themes + * + * @link http://www.egroupware.org + * @package sitemgr + * @author Ralf Becker + * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License + * @copyright Ralf Becker + * @version $Id$ + */ - /* $Id$ */ +/** + * Site templates aka themes + */ +class Theme_BO +{ + /** + * List installed templates + * + * @return array name => template-infos from getTemplateInfos + */ + function getAvailableThemes() + { + $templates_dir = $GLOBALS['Common_BO']->sites->current_site['site_dir'] . SEP . 'templates' . SEP; + $result_array=array(); - class Theme_BO + if ($handle = @opendir($templates_dir)) + { + while ($file = readdir($handle)) + { + if (is_dir($templates_dir . $file) && $file != '..' && $file != '.' && $file != 'CVS' && $file != '.svn') + { + if ($info = $this->getThemeInfos