*/ /** * @package SquareThumb * @subpackage UserInterface */ class SquareThumbSiteAdminController 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 (empty($form['color'])) { $error[] = 'form[error][color][missing]'; } else if (!preg_match('/^[0-9a-f]{6}$/i', $form['color'])) { $error[] = 'form[error][color][invalid]'; } else { foreach (array('mode', 'color') as $key) { $ret = GalleryCoreApi::setPluginParameter('module', 'squarethumb', $key, $form[$key]); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } } $status['saved'] = 1; } } /* else $form['action']['reset'] */ $method = empty($error) ? 'redirect' : 'delegate'; $results = array($method => array('view' => 'core.SiteAdmin', 'subView' => 'squarethumb.SquareThumbSiteAdmin'), 'status' => $status, 'error' => $error); return array(null, $results); } } /** * @package SquareThumb * @subpackage UserInterface */ class SquareThumbSiteAdminView extends GalleryView { /** * @see GalleryView::loadTemplate */ function loadTemplate(&$template, &$form) { $ret = GalleryCoreApi::assertUserIsSiteAdministrator(); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } if ($form['formName'] != 'SquareThumbSiteAdmin') { $form['formName'] = 'SquareThumbSiteAdmin'; foreach (array('mode', 'color') as $key) { list ($ret, $form[$key]) = GalleryCoreApi::getPluginParameter('module', 'squarethumb', $key); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } } } $template->setVariable('controller', 'squarethumb.SquareThumbSiteAdmin'); return array(null, array('body' => 'modules/squarethumb/templates/SquareThumbSiteAdmin.tpl')); } } ?>