*/ /** * This controller will handle the rendering of an album or item. * * @package GalleryCore * @subpackage UserInterface */ class NavigationView extends GalleryView { /** * @see GalleryView::loadTemplate */ function loadTemplate(&$template, &$form) { global $gallery; /* Get system links */ list ($ret, $moduleSystemLinks) = $this->_getModuleSystemLinks(); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); } /* Get system content */ list ($ret, $systemContent) = $this->_loadSystemContent($template); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); } /* Get the links for navigating back to where we came from */ $urlGenerator =& $gallery->getUrlGenerator(); list ($ret, $navigationLinks) = $urlGenerator->getNavigationLinks(); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null, null); } $user = $gallery->getActiveUser(); $Navigation = array(); $Navigation['user'] = $user->getMemberData(); $Navigation['l10Domain'] = 'modules_core'; $Navigation['sidebar'] = 'modules/core/templates/NavigationSidebar.tpl'; $Navigation['systemContent'] = $systemContent; $Navigation['moduleSystemLinks'] = $moduleSystemLinks; $Navigation['navigationLinks'] = $navigationLinks; $template->setVariable('Navigation', $Navigation); return array(GalleryStatus::success(), null); } /** * Call loadSystemContent on every active module * * @param object GalleryTemplate a template instance * @return array object GalleryStatus a status code * array('moduleId' => 'template file path', * ...) * @access private */ function _loadSystemContent(&$template) { global $gallery; /* Load the module list */ list ($ret, $moduleStatus) = GalleryCoreApi::fetchPluginStatus('module'); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); } $systemContent = array(); foreach ($moduleStatus as $moduleId => $status) { if (empty($status['active'])) { continue; } list ($ret, $module) = GalleryCoreApi::loadPlugin('module', $moduleId); if ($ret->isError()) { if ($ret->getErrorCode() & ERROR_PLUGIN_VERSION_MISMATCH) { continue; } return array($ret->wrap(__FILE__, __LINE__), null); } /* Load all module-related content for these items */ list ($ret, $systemContent[$moduleId]) = $module->loadSystemContent($template); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); } if (empty($systemContent[$moduleId])) { unset($systemContent[$moduleId]); } } return array(GalleryStatus::success(), $systemContent); } /** * Call getModuleSystemLinks on every active module * * @param object GalleryTemplate a template instance * @return array object GalleryStatus a status code * array(array('moduleId' => array('text' => ..., * 'params' => ..., * 'url' => ...)), * @access private */ function _getModuleSystemLinks() { global $gallery; /* Load the module list */ list ($ret, $moduleStatus) = GalleryCoreApi::fetchPluginStatus('module'); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); } $urlGenerator =& $gallery->getUrlGenerator(); $links = array(); foreach ($moduleStatus as $moduleId => $status) { if (empty($status['active'])) { continue; } list ($ret, $module) = GalleryCoreApi::loadPlugin('module', $moduleId); if ($ret->isError()) { if ($ret->getErrorCode() & ERROR_PLUGIN_VERSION_MISMATCH) { continue; } return array($ret->wrap(__FILE__, __LINE__), null); } /* Get all module-related links for these items */ list ($ret, $links[$moduleId]) = $module->getSystemLinks(); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); } if (empty($links[$moduleId])) { unset($links[$moduleId]); } } return array(GalleryStatus::success(), $links); } } ?>