*/ /** * @package Icons * @subpackage UserInterface */ class IconsSiteAdminController extends GalleryController { /** * @see GalleryController::handleRequest */ function handleRequest($form) { $ret = GalleryCoreApi::assertUserIsSiteAdministrator(); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $status = $error = array(); if (isset($form['action']['save'])) { if (!isset($form['iconpack'])) { $error[] = 'form[error][iconpack][missing]'; } else { $ret = GalleryCoreApi::setPluginParameter( 'module', 'icons', 'iconpack', $form['iconpack']); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $status['saved'] = 1; } } /* Figure out where to redirect upon success */ $method = empty($error) ? 'redirect' : 'delegate'; $results[$method]['view'] = 'core.SiteAdmin'; $results[$method]['subView'] = 'icons.IconsSiteAdmin'; $results['status'] = $status; $results['error'] = $error; return array(null, $results); } } /** * @package Icons * @subpackage UserInterface */ class IconsSiteAdminView extends GalleryView { /** * @see GalleryView::loadTemplate */ function loadTemplate(&$template, &$form) { $ret = GalleryCoreApi::assertUserIsSiteAdministrator(); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } if ($form['formName'] != 'IconsSiteAdmin') { $form['formName'] = 'IconsSiteAdmin'; list ($ret, $form['iconpack']) = GalleryCoreApi::getPluginParameter('module', 'icons', 'iconpack'); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } } list ($ret, $icons) = GalleryCoreApi::newFactoryInstance('IconsInterface_1_0'); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } if (isset($icons)) { list ($ret, $list) = $icons->getIconPacks(); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $template->setVariable('IconsSiteAdmin', array('iconpacks' => $list)); } $template->setVariable('controller', 'icons.IconsSiteAdmin'); return array(null, array('body' => 'modules/icons/templates/IconsSiteAdmin.tpl')); } } ?>