cleaned up about to use framework->list_templates to support app like templates

This commit is contained in:
Ralf Becker 2010-06-02 22:43:41 +00:00
parent e8c4786879
commit 7d19819ba1
2 changed files with 30 additions and 43 deletions

View File

@ -108,31 +108,31 @@ class about
'appMaintainer' => $info['maintainer'], 'appMaintainer' => $info['maintainer'],
'appVersion' => $info['version'], 'appVersion' => $info['version'],
'appLicense' => $this->_linkLicense($info['license']), 'appLicense' => $this->_linkLicense($info['license']),
'appDetails' => '<a href="'.$GLOBALS['egw_info']['server']['webserver_url'].'/about.php?app='.$app.'&nonavbar=true" onclick="egw_openWindowCentered2(this.href,this.target,750,410,'."'yes'".'); return false;"><img src="'.$GLOBALS['egw']->common->image('phpgwapi','view.png').'" /></a>' 'appDetails' => '<a href="'.$GLOBALS['egw_info']['server']['webserver_url'].'/about.php?app='.$app.'&nonavbar=true" onclick="egw_openWindowCentered2(this.href,this.target,750,410,'."'yes'".'); return false;"><img src="'.common::image('phpgwapi','view.png').'" /></a>'
); );
} }
// get informations about the templates // get informations about the templates
$templates = array(); $templates = array();
$templates[] = ''; // first empty row for eTemplate $templates[] = ''; // first empty row for eTemplate
foreach($GLOBALS['egw']->common->list_templates() as $template => $templateinfo) { foreach($GLOBALS['egw']->framework->list_templates(true) as $template => $info) {
$info = $this->_getParsedTemplateInfo($template); $info = $this->_getParsedTemplateInfo($info);
$templates[] = array( $templates[] = array(
'templateImage' => '<img src="'.$info['image'].'" />', 'templateImage' => '<img src="'.$info['image'].'" />',
'templateName' => $templateinfo['name'], 'templateName' => $info['title'],
'templateAuthor' => $info['author'], 'templateAuthor' => $info['author'],
'templateMaintainer'=> $info['maintainer'], 'templateMaintainer'=> $info['maintainer'],
'templateVersion' => $info['version'], 'templateVersion' => $info['version'],
'templateLicense' => $this->_linkLicense($info['license']), 'templateLicense' => $this->_linkLicense($info['license']),
'templateDetails' => '<a href="'.$GLOBALS['egw_info']['server']['webserver_url'].'/about.php?template='.$template.'&nonavbar=true" onclick="egw_openWindowCentered2(this.href,this.target,750,410,'."'yes'".'); return false;"><img src="'.$GLOBALS['egw']->common->image('phpgwapi','view.png').'" /></a>' 'templateDetails' => '<a href="'.$GLOBALS['egw_info']['server']['webserver_url'].'/about.php?template='.$template.'&nonavbar=true" onclick="egw_openWindowCentered2(this.href,this.target,750,410,'."'yes'".'); return false;"><img src="'.common::image('phpgwapi','view.png').'" /></a>'
); );
} }
// get informations about installed languages // get informations about installed languages
$translations = array(); $translations = array();
$translations[] = ''; // first empty row for eTemplate $translations[] = ''; // first empty row for eTemplate
$langs = $GLOBALS['egw']->translation->get_installed_langs(); $langs = translation::get_installed_langs();
foreach($GLOBALS['egw']->translation->get_installed_langs() as $translation => $translationinfo) { foreach(translation::get_installed_langs() as $translation => $translationinfo) {
$translations[] = array( $translations[] = array(
'langName' => $translationinfo.' ('.$translation.')' 'langName' => $translationinfo.' ('.$translation.')'
); );
@ -147,7 +147,7 @@ class about
'translations' => $translations 'translations' => $translations
); );
$tmpl =& CreateObject('etemplate.etemplate', 'phpgwapi.about.index'); $tmpl = new etemplate('phpgwapi.about.index');
$tmpl->exec('phpgwapi.about.index', $content); $tmpl->exec('phpgwapi.about.index', $content);
} }
@ -171,7 +171,8 @@ class about
$info = $this->_getParsedAppInfo($name); $info = $this->_getParsedAppInfo($name);
break; break;
case 'template': case 'template':
$info = $this->_getParsedTemplateInfo($name); $templates = $GLOBALS['egw']->framework->list_templates(true);
$info = $this->_getParsedTemplateInfo($templates[$name]);
break; break;
} }
@ -207,7 +208,7 @@ class about
/** /**
* parse template informations from setup.inc.php file * parse template informations from setup.inc.php file
* *
* @param string $template template template name * @param array $info template template info
* @return array html formated informations about author(s), * @return array html formated informations about author(s),
* maintainer(s), version, license of the * maintainer(s), version, license of the
* given application * given application
@ -215,33 +216,14 @@ class about
* @access private * @access private
* @since 1.4 * @since 1.4
*/ */
function _getParsedTemplateInfo($template) function _getParsedTemplateInfo($info)
{ {
// define the return array // define the return array
$ret = array( $info['image'] = file_exists(EGW_SERVER_ROOT.'/'.$info['icon']) ? '/'.$info['icon'] : common::image('thisdoesnotexist',array('navbar','nonav'));
'image' => (file_exists($GLOBALS['egw_info']['template'][$template]['icon'])) ? $GLOBALS['egw_info']['template'][$template]['icon'] : $GLOBALS['egw']->common->image('thisdoesnotexist',array('navbar','nonav')), $info['author'] = $this->_getHtmlPersonalInfo($info, 'author');
'author' => '', $info['maintainer'] = $this->_getHtmlPersonalInfo($info, 'maintainer');
'maintainer' => '',
'version' => '',
'license' => '',
'description' => '',
'note' => ''
);
if (!file_exists(EGW_INCLUDE_ROOT . "/phpgwapi/templates/$template/setup/setup.inc.php")) { return $info;
return $ret;
}
include(EGW_INCLUDE_ROOT . "/phpgwapi/templates/$template/setup/setup.inc.php");
$ret['author'] = $this->_getHtmlPersonalInfo($GLOBALS['egw_info']['template'][$template], 'author');
$ret['maintainer'] = $this->_getHtmlPersonalInfo($GLOBALS['egw_info']['template'][$template], 'maintainer');
$ret['version'] = $GLOBALS['egw_info']['template'][$template]['version'];
$ret['license'] = $GLOBALS['egw_info']['template'][$template]['license'];
$ret['description'] = $GLOBALS['egw_info']['template'][$template]['description'];
$ret['note'] = $GLOBALS['egw_info']['template'][$template]['note'];
return $ret;
} }
@ -274,7 +256,7 @@ class about
// define the return array // define the return array
$ret = array( $ret = array(
'image' => $GLOBALS['egw']->common->image(isset($app_info['icon_app'])?$app_info['icon_app']:$app, 'image' => common::image(isset($app_info['icon_app'])?$app_info['icon_app']:$app,
isset($app_info['icon'])?$app_info['icon']:array('navbar','nonav')), isset($app_info['icon'])?$app_info['icon']:array('navbar','nonav')),
'author' => '', 'author' => '',
'maintainer' => '', 'maintainer' => '',

View File

@ -198,7 +198,7 @@ abstract class egw_framework
protected function _get_footer() protected function _get_footer()
{ {
$var = Array( $var = Array(
'img_root' => $GLOBALS['egw_info']['server']['webserver_url'] . '/phpgwapi/templates/'.$this->template.'/images', 'img_root' => $GLOBALS['egw_info']['server']['webserver_url'] . $this->template_dir.'/images',
'version' => $GLOBALS['egw_info']['server']['versions']['phpgwapi'] 'version' => $GLOBALS['egw_info']['server']['versions']['phpgwapi']
); );
if($GLOBALS['egw_info']['user']['preferences']['common']['show_generation_time']) if($GLOBALS['egw_info']['user']['preferences']['common']['show_generation_time'])
@ -213,7 +213,7 @@ abstract class egw_framework
} }
$var['page_generation_time'] .= '</span></div>'; $var['page_generation_time'] .= '</span></div>';
} }
$var['powered_by'] = lang('Powered by').' <a href="'.$GLOBALS['egw_info']['server']['webserver_url'].'/about.php">eGroupWare</a> '.lang('version').' '.$GLOBALS['egw_info']['server']['versions']['phpgwapi']; $var['powered_by'] = lang('Powered by').' <a href="'.egw::link('/about.php','','about').'">EGroupware</a> '.lang('version').' '.$GLOBALS['egw_info']['server']['versions']['phpgwapi'];
return $var; return $var;
} }
@ -579,7 +579,7 @@ abstract class egw_framework
} }
if ($GLOBALS['egw_info']['flags']['currentapp'] == 'preferences' || $GLOBALS['egw_info']['flags']['currentapp'] == 'about') if ($GLOBALS['egw_info']['flags']['currentapp'] == 'preferences' || $GLOBALS['egw_info']['flags']['currentapp'] == 'about')
{ {
$app = $app_title = 'eGroupWare'; $app = $app_title = 'EGroupware';
} }
else else
{ {
@ -810,9 +810,10 @@ abstract class egw_framework
/** /**
* List available templates * List available templates
* *
* @param boolean $full_data=false true: value is array with values for keys 'name', 'title', ...
* @returns array alphabetically sorted list of templates * @returns array alphabetically sorted list of templates
*/ */
static function list_templates() static function list_templates($full_data=false)
{ {
$list = array(); $list = array();
// templates packaged in the api // templates packaged in the api
@ -824,11 +825,15 @@ abstract class egw_framework
if (file_exists ($f = EGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry . '/setup/setup.inc.php')) if (file_exists ($f = EGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry . '/setup/setup.inc.php'))
{ {
include($f); include($f);
$list[$entry] = $GLOBALS['egw_info']['template'][$entry]['title']; $list[$entry] = $full_data ? $GLOBALS['egw_info']['template'][$entry] :
$GLOBALS['egw_info']['template'][$entry]['title'];
} }
else else
{ {
$list[$entry] = $entry; $list[$entry] = $full_data ? array(
'name' => $entry,
'title' => $entry,
) : $entry;
} }
} }
} }
@ -843,7 +848,8 @@ abstract class egw_framework
include($f); include($f);
if (isset($GLOBALS['egw_info']['template'][$entry])) if (isset($GLOBALS['egw_info']['template'][$entry]))
{ {
$list[$entry] = $GLOBALS['egw_info']['template'][$entry]['title']; $list[$entry] = $full_data ? $GLOBALS['egw_info']['template'][$entry] :
$GLOBALS['egw_info']['template'][$entry]['title'];
} }
} }
} }
@ -852,7 +858,6 @@ abstract class egw_framework
return $list; return $list;
} }
} }
/** /**