/** * Declare the handler function to process the actual page PATH * @param $hookName string The name of the invoked hook * @param $args array Hook parameters * @return boolean Hook handling status */ function callbackHandleContent($hookName, $args) { $request = $this->getRequest(); $templateMgr = TemplateManager::getManager($request); $page =& $args[0]; $op =& $args[1]; $staticPagesDao = DAORegistry::getDAO('StaticPagesDAO'); if ($page == 'pages' && $op == 'preview') { // This is a preview request; mock up a static page to display. // The handler class ensures that only managers and administrators // can do this. $staticPage = $staticPagesDao->newDataObject(); $staticPage->setContent((array) $request->getUserVar('content'), null); $staticPage->setTitle((array) $request->getUserVar('title'), null); } else { // Construct a path to look for $path = $page; if ($op !== 'index') { $path .= "/{$op}"; } if ($ops = $request->getRequestedArgs()) { $path .= '/' . implode('/', $ops); } // Look for a static page with the given path $context = $request->getContext(); $staticPage = $staticPagesDao->getByPath($context ? $context->getId() : CONTEXT_ID_NONE, $path); } // Check if this is a request for a static page or preview. if ($staticPage) { // Trick the handler into dealing with it normally $page = 'pages'; $op = 'view'; // It is -- attach the static pages handler. define('HANDLER_CLASS', 'StaticPagesHandler'); $this->import('StaticPagesHandler'); // Allow the static pages page handler to get the plugin object StaticPagesHandler::setPlugin($this); StaticPagesHandler::setPage($staticPage); return true; } return false; }
/** * Set a static page to view. * @param $staticPage StaticPage */ static function setPage($staticPage) { self::$staticPage = $staticPage; }