00001 <?php
00002
00015
00016
00017
00018 import('classes.plugins.ThemePlugin');
00019
00020 class CustomThemePlugin extends ThemePlugin {
00028 function register($category, $path) {
00029 if (parent::register($category, $path)) {
00030 $this->addLocaleData();
00031 return true;
00032 }
00033 return false;
00034 }
00040 function getName() {
00041 return 'CustomThemePlugin';
00042 }
00043
00044 function getDisplayName() {
00045 return Locale::translate('plugins.theme.custom.name');
00046 }
00047
00048 function getDescription() {
00049 return Locale::translate('plugins.theme.custom.description');
00050 }
00051
00052 function getStylesheetFilename() {
00053 return 'custom.css';
00054 }
00055
00056 function getManagementVerbs() {
00057 return array(array('settings', Locale::translate('plugins.theme.custom.settings')));
00058 }
00059
00065 function setBreadcrumbs($isSubclass = false) {
00066 $templateMgr = &TemplateManager::getManager();
00067 $pageCrumbs = array(
00068 array(
00069 Request::url(null, 'user'),
00070 'navigation.user'
00071 ),
00072 array(
00073 Request::url(null, 'manager'),
00074 'user.role.manager'
00075 )
00076 );
00077 if ($isSubclass) $pageCrumbs[] = array(
00078 Request::url(null, 'manager', 'plugins'),
00079 'manager.plugins'
00080 );
00081
00082 $templateMgr->assign('pageHierarchy', $pageCrumbs);
00083 }
00084
00088 function smartyPluginUrl($params, &$smarty) {
00089 $path = array($this->getCategory(), $this->getName());
00090 if (is_array($params['path'])) {
00091 $params['path'] = array_merge($path, $params['path']);
00092 } elseif (!empty($params['path'])) {
00093 $params['path'] = array_merge($path, array($params['path']));
00094 } else {
00095 $params['path'] = $path;
00096 }
00097
00098 if (!empty($params['id'])) {
00099 $params['path'] = array_merge($params['path'], array($params['id']));
00100 unset($params['id']);
00101 }
00102 return $smarty->smartyUrl($params, $smarty);
00103 }
00104
00105 function manage($verb) {
00106 if ($verb != 'settings') return false;
00107
00108 $journal =& Request::getJournal();
00109 $templateMgr =& TemplateManager::getManager();
00110
00111 $templateMgr->register_function('plugin_url', array(&$this, 'smartyPluginUrl'));
00112 $templateMgr->setCacheability(CACHEABILITY_MUST_REVALIDATE);
00113
00114 $this->import('CustomThemeSettingsForm');
00115 $form = &new CustomThemeSettingsForm($this, $journal->getJournalId());
00116 if (Request::getUserVar('save')) {
00117 $form->readInputData();
00118 if ($form->validate()) {
00119 $form->execute();
00120 Request::redirect(null, 'manager', 'plugin', array('themes', 'CustomThemePlugin', 'settings'));
00121 } else {
00122 $this->setBreadCrumbs(true);
00123 $form->display();
00124 }
00125 } else {
00126 $this->setBreadCrumbs(true);
00127 $form->initData();
00128 $form->display();
00129 }
00130
00131 return true;
00132 }
00133 }
00134
00135 ?>