* @package MCMS\System\Plugin * @since 1.0.0.0 * @see \MCMS\Interfaces\iPlugInAdmin */ abstract class PlugInAdminBase extends AdminBase implements iPlugInAdmin, \MCMS\Module\iAdminModule { /** * Redirects the request to the matching run$Request method * * @param Response $response * the respone object which has to be filled with the content * @throws \MCMS\Exception\PageNotFoundException if no matching method could be found */ // public function handleAction(Response &$response) { // $system = System::getInstance(); // $part = $system->getTarget('part'); // $action = $system->getTarget('action'); // $method = 'run' . ucfirst($action); // if(method_exists($this, $method)) // $this->$method($response); // else // throw new \MCMS\Exception\PageNotFoundException($part . ':' . $action); // } /** * Builds a string which represents a link to this plugin admin * * @return string the resulting link */ // protected function getMyRef() { // $system = System::getInstance(); // $cat = substr($system->getTarget('cat'), 0, 2); // $plugin = $system->getTarget('plugin'); // $part = $system->getTarget('part'); // return "{$cat}.{$plugin}:{$part}"; // } protected function _checkAdminAccess(iUser $user, $site, $area, $key = null) { $usrSvc = System::getInstance()->getUserSvc(); if ($user->isMasterAdmin()) return true; if (empty($site) && empty($area)) { if ($user->backendaccess) return true; } if (!$usrSvc->userHasAdminPriv($user, $site, $area, $key, false)) throw new AccessDeniedException('Access denied'); throw new AccessDeniedException('Access denied'); } /** * Creates a help link. * * @param string $topic * the topic which should be linked, path in mcms namespace notation * @param string $text * text of the link * @param mixed $icon * false=none, true=default, string=image file * @param string $locale * the locale setting to use * @return string the complete help link as html */ public static function genHelpLink($topic, $text = '', $icon = true, $locale = NULL) { $baseurl = _BASEURL_ . '/data/manual/plugin/'; $basedir = _BASEPATH_ . __DS__ . 'data' . __DS__ . 'manual' . __DS__ . 'plugin' . __DS__; $topicurl = $baseurl . str_replace('.', '/', $topic); $topicdir = $basedir . str_replace('.', __DS__, $topic); if(is_null($locale)) $locale = System::getInstance()->getActiveLocale(); if(file_exists($topicdir . '-' . $locale . '.html')) $topicurl = $topicurl . '-' . $locale . '.html'; else $topicurl = $topicurl . '-en.html'; // default fallback if($icon === true) $icon = './layout/default/admin/images/actions/help.png'; $st = '' . ($icon ? ' ' : '') . $text . ''; return $st; } }