/** * Handles an error. * * @param integer $errno Number of the error. * @param string $errstr Error message. * @param string $errfile Filename where the error occurred. * @param integer $errline Line of the error. * @param string $errcontext Context of the error. * * @return boolean */ public function handler($errno, $errstr, $errfile = '', $errline = 0, $errcontext = null) { $this->setupHandler($errno, $errstr, $errfile, $errline, $errcontext); // Notify all loggers $this->eventManager->notify($this->event->setArgs(array('trace' => $this->trace, 'type' => $this->type, 'errno' => $this->errno, 'errstr' => $this->errstr, 'errfile' => $this->errfile, 'errline' => $this->errline, 'errcontext' => $this->errcontext))); if ($this->isPHPError() && System::isDevelopmentMode() && $this->showPHPErrorHandler()) { // allow PHP to return error $this->resetHandler(); return false; } if (!$this->isDisplayErrorTemplate()) { // prevent PHP from handling the event after we return $this->resetHandler(); return true; } // obey reporing level if (abs($this->getType()) > $this->serviceManager['log.display_level']) { return false; } // unless in development mode, exit. if (!$this->serviceManager['log.display_template']) { return false; } // if we get this far, display template echo ModUtil::func('Errors', 'user', 'system', array('type' => $this->errno, 'message' => $this->errstr, 'file' => $this->errfile, 'line' => $this->errline)); Zikula_View_Theme::getInstance()->themefooter(); System::shutDown(); }
/** * Sets a theme variable. * * @param string $name Variable name. * @param mixed $value Value to set. * * @return void */ public static function setVar($name, $value) { // if no variable name is present does nothing if (!$name) { return; } Zikula_View_Theme::getInstance()->assign($name, $value); }
/** * Clear all compiled and cache directories. * * This function simply calls the theme and renderer modules to refresh the entire site. * * @return boolean true. */ public function clearallcompiledcaches() { Zikula_View_Theme::getInstance()->clear_all_cache(); Zikula_View_Theme::getInstance()->clear_compiled(); Zikula_View_Theme::getInstance()->clear_cssjscombinecache(); Zikula_View::getInstance()->clear_all_cache(); Zikula_View::getInstance()->clear_compiled(); return true; }
/** * Event: 'frontcontroller.predispatch'. * * @param Zikula_Event $event * * @return void */ public function sessionExpired(Zikula_Event $event) { if (SessionUtil::hasExpired()) { // Session has expired, display warning header('HTTP/1.0 403 Access Denied'); echo ModUtil::apiFunc('Users', 'user', 'expiredsession'); Zikula_View_Theme::getInstance()->themefooter(); System::shutdown(); } }
/** * Clear cache for given item. Can be called from other modules to clear an item cache. * * @param $args['ot'] the treated object type * @param $args['item'] the actual object */ public function clearItemCache(array $args = array()) { if (!isset($args['ot']) || !isset($args['item'])) { return; } $objectType = $args['ot']; $item = $args['item']; $controllerHelper = new Reviews_Util_Controller($this->serviceManager); $utilArgs = array('api' => 'cache', 'action' => 'clearItemCache'); if (!in_array($objectType, $controllerHelper->getObjectTypes('controllerAction', $utilArgs))) { return; } if ($item && !is_array($item) && !is_object($item)) { $item = ModUtil::apiFunc($this->name, 'selection', 'getEntity', array('ot' => $objectType, 'id' => $item, 'useJoins' => false, 'slimMode' => true)); } if (!$item) { return; } // create full identifier (considering composite keys) $idFields = ModUtil::apiFunc($this->name, 'selection', 'getIdFields', array('ot' => $objectType)); $instanceId = ''; foreach ($idFields as $idField) { if (!empty($instanceId)) { $instanceId .= '_'; } $instanceId .= $item[$idField]; } // Clear View_cache $cacheIds = array(); $cacheIds[] = 'main'; $cacheIds[] = 'view'; $cacheIds[] = $instanceId; $view = Zikula_View::getInstance('Reviews'); foreach ($cacheIds as $cacheId) { $view->clear_cache(null, $cacheId); } // Clear Theme_cache $cacheIds = array(); $cacheIds[] = 'homepage'; // for homepage (can be assigned in the Settings module) $cacheIds[] = 'Reviews/user/main'; // main function $cacheIds[] = 'Reviews/user/view/' . $objectType; // view function (list views) $cacheIds[] = 'Reviews/user/display/' . $objectType . '|' . $instanceId; // display function (detail views) $theme = Zikula_View_Theme::getInstance(); $theme->clear_cacheid_allthemes($cacheIds); }
public function renderTheme(FilterResponseEvent $event) { if ($event->getRequestType() !== HttpKernel::MASTER_REQUEST) { return; } $response = $event->getResponse(); if ($response instanceof RedirectResponse || $response instanceof PlainResponse || $response instanceof AbstractBaseResponse) { // dont theme redirects, plain responses or Ajax responses return; } $content = $response->getContent(); $code = $response->getStatusCode(); $themedContent = \Zikula_View_Theme::getInstance()->themefooter($content); $themeResponse = new Response($themedContent, $code); $event->setResponse($themeResponse); }
function cronShutdown() { Zikula_View_Theme::getInstance()->clear_all_cache(); Zikula_View_Theme::getInstance()->clear_compiled(); Zikula_View_Theme::getInstance()->clear_cssjscombinecache(); Zikula_View::getInstance()->clear_all_cache(); Zikula_View::getInstance()->clear_compiled(); System::shutdown(); }
/** * Update block settings * * @param array $blockInfo blockinfo array * * @return array $blockinfo */ public function update($blockInfo) { $vars = BlockUtil::varsFromContent($blockInfo['content']); // write back the new contents $blockInfo['content'] = BlockUtil::varsToContent($vars); // clear the block cache $this->view->clear_cache(null, $blockInfo['bkey'] . '/bid' . $blockInfo['bid']); // and clear the theme cache Zikula_View_Theme::getInstance()->clear_cache(); return $blockInfo; }
/** * Disable or enable add the module wrapper. * * @param boolean $wrap False to disable wrapper, true to enable it. * * @return $this */ public function setWrapper($wrap) { if ($this->modinfo['name'] == $this->toplevelmodule) { Zikula_View_Theme::getInstance()->themeinfo['system'] = !$wrap; } return $this; }
$file = $func; } $includetype = true; if ($type == 'admin') { // standard module interface $includetype = false; } if ($file == 'posting') { $mode = FormUtil::getPassedValue('mode', '', 'GETPOST'); if ($mode == 'topicreview' || $mode == 'smilies' || $mode == 'rules' || $mode == 'postimages') { $includetype = false; } } if ($file == 'quick_reply') { $qmode = FormUtil::getPassedValue('mode', '', 'GETPOST'); if ($qmode == 'smilies' || $qmode == 'postimages') { $includetype = false; } } if ($includetype) { // direct file include if (empty($file) || $file == 'main') { $file = 'index'; } $zview = Zikula_View_Theme::getInstance(); $phpbb_root_path = __DIR__ . '/vendor/phpBB2/'; include $phpbb_root_path . 'includezik.php'; include $phpbb_root_path . $file . '.php'; $zview->themefooter(); System::shutdown(); }
/** * Clear cache for given item. Can be called from other modules to clear an item cache. * * @param $args['ot'] the treated object type * @param $args['item'] the actual object */ public function clearItemCache(array $args = array()) { if (!isset($args['ot']) || !isset($args['item'])) { return; } $objectType = $args['ot']; $item = $args['item']; $controllerHelper = new MUVideo_Util_Controller($this->serviceManager); $utilArgs = array('api' => 'cache', 'action' => 'clearItemCache'); if (!in_array($objectType, $controllerHelper->getObjectTypes('controllerAction', $utilArgs))) { return; } if ($item && !is_array($item) && !is_object($item)) { $item = ModUtil::apiFunc($this->name, 'selection', 'getEntity', array('ot' => $objectType, 'id' => $item, 'useJoins' => false, 'slimMode' => true)); } if (!$item) { return; } $instanceId = $item->createCompositeIdentifier(); // Clear View_cache $cacheIds = array(); $cacheIds[] = 'user_main'; switch ($objectType) { case 'collection': $cacheIds[] = 'collection_main'; $cacheIds[] = $objectType . '_view'; $cacheIds[] = $objectType . '_display|' . $instanceId; break; case 'movie': $cacheIds[] = 'movie_main'; $cacheIds[] = $objectType . '_view'; $cacheIds[] = $objectType . '_display|' . $instanceId; break; } $view = Zikula_View::getInstance('MUVideo'); foreach ($cacheIds as $cacheId) { $view->clear_cache(null, $cacheId); } // Clear Theme_cache $cacheIds = array(); $cacheIds[] = 'homepage'; // for homepage (can be assigned in the Settings module) $cacheIds[] = 'MUVideo/user/main'; // main function switch ($objectType) { case 'collection': $cacheIdPrefix = 'MUVideo/' . $objectType . '/'; $cacheIds[] = $cacheIdPrefix . 'main'; // main function $cacheIds[] = $cacheIdPrefix . 'view/'; // view function (list views) $cacheIds[] = $cacheIdPrefix . 'display/' . $instanceId; // display function (detail views) break; case 'movie': $cacheIdPrefix = 'MUVideo/' . $objectType . '/'; $cacheIds[] = $cacheIdPrefix . 'main'; // main function $cacheIds[] = $cacheIdPrefix . 'view/'; // view function (list views) $cacheIds[] = $cacheIdPrefix . 'display/' . $instanceId; // display function (detail views) break; } $theme = Zikula_View_Theme::getInstance(); $theme->clear_cacheid_allthemes($cacheIds); }
/** * Initialise Zikula. * * Carries out a number of initialisation tasks to get Zikula up and * running. * * @param integer $stage Stage to load. * * @return boolean True initialisation successful false otherwise. */ public function init($stage = self::STAGE_ALL) { $coreInitEvent = new Zikula_Event('core.init', $this); // store the load stages in a global so other API's can check whats loaded $this->stage = $this->stage | $stage; if ($stage & self::STAGE_PRE && $this->stage & ~self::STAGE_PRE) { ModUtil::flushCache(); System::flushCache(); $this->eventManager->notify(new Zikula_Event('core.preinit', $this)); } // Initialise and load configuration if ($stage & self::STAGE_CONFIG) { if (System::isLegacyMode()) { require_once 'lib/legacy/Compat.php'; } // error reporting if (!System::isInstalling()) { // this is here because it depends on the config.php loading. $event = new Zikula_Event('setup.errorreporting', null, array('stage' => $stage)); $this->eventManager->notify($event); } // initialise custom event listeners from config.php settings $coreInitEvent->setArg('stage', self::STAGE_CONFIG); $this->eventManager->notify($coreInitEvent); } // Check that Zikula is installed before continuing if (System::getVar('installed') == 0 && !System::isInstalling()) { System::redirect(System::getBaseUrl() . 'install.php?notinstalled'); System::shutDown(); } if ($stage & self::STAGE_DB) { try { $dbEvent = new Zikula_Event('core.init', $this, array('stage' => self::STAGE_DB)); $this->eventManager->notify($dbEvent); } catch (PDOException $e) { if (!System::isInstalling()) { header('HTTP/1.1 503 Service Unavailable'); require_once System::getSystemErrorTemplate('dbconnectionerror.tpl'); System::shutDown(); } else { return false; } } } if ($stage & self::STAGE_TABLES) { // Initialise dbtables ModUtil::dbInfoLoad('Extensions', 'Extensions'); ModUtil::initCoreVars(); ModUtil::dbInfoLoad('Settings', 'Settings'); ModUtil::dbInfoLoad('Theme', 'Theme'); ModUtil::dbInfoLoad('Users', 'Users'); ModUtil::dbInfoLoad('Groups', 'Groups'); ModUtil::dbInfoLoad('Permissions', 'Permissions'); ModUtil::dbInfoLoad('Categories', 'Categories'); if (!System::isInstalling()) { ModUtil::registerAutoloaders(); } $coreInitEvent->setArg('stage', self::STAGE_TABLES); $this->eventManager->notify($coreInitEvent); } if ($stage & self::STAGE_SESSIONS) { SessionUtil::requireSession(); $coreInitEvent->setArg('stage', self::STAGE_SESSIONS); $this->eventManager->notify($coreInitEvent); } // Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak) // start block if ($stage & self::STAGE_LANGS) { $lang = ZLanguage::getInstance(); } if ($stage & self::STAGE_DECODEURLS) { System::queryStringDecode(); $coreInitEvent->setArg('stage', self::STAGE_DECODEURLS); $this->eventManager->notify($coreInitEvent); } if ($stage & self::STAGE_LANGS) { $lang->setup(); $coreInitEvent->setArg('stage', self::STAGE_LANGS); $this->eventManager->notify($coreInitEvent); } // end block if ($stage & self::STAGE_MODS) { // Set compression on if desired if (System::getVar('UseCompression') == 1) { //ob_start("ob_gzhandler"); } ModUtil::load('SecurityCenter'); $coreInitEvent->setArg('stage', self::STAGE_MODS); $this->eventManager->notify($coreInitEvent); } if ($stage & self::STAGE_THEME) { // register default page vars PageUtil::registerVar('title'); PageUtil::setVar('title', System::getVar('defaultpagetitle')); PageUtil::registerVar('keywords', true); PageUtil::registerVar('stylesheet', true); PageUtil::registerVar('javascript', true); PageUtil::registerVar('jsgettext', true); PageUtil::registerVar('body', true); PageUtil::registerVar('header', true); PageUtil::registerVar('footer', true); $theme = Zikula_View_Theme::getInstance(); // set some defaults // Metadata for SEO $this->serviceManager['zikula_view.metatags']['description'] = System::getVar('defaultmetadescription'); $this->serviceManager['zikula_view.metatags']['keywords'] = System::getVar('metakeywords'); $coreInitEvent->setArg('stage', self::STAGE_THEME); $this->eventManager->notify($coreInitEvent); } // check the users status, if not 1 then log him out if (UserUtil::isLoggedIn()) { $userstatus = UserUtil::getVar('activated'); if ($userstatus != Users_Constant::ACTIVATED_ACTIVE) { UserUtil::logout(); // TODO - When getting logged out this way, the existing session is destroyed and // then a new one is created on the reentry into index.php. The message // set by the registerStatus call below gets lost. LogUtil::registerStatus(__('You have been logged out.')); System::redirect(ModUtil::url('Users', 'user', 'login')); } } if ($stage & self::STAGE_POST && $this->stage & ~self::STAGE_POST) { $this->eventManager->notify(new Zikula_Event('core.postinit', $this, array('stages' => $stage))); } }
public function update($blockinfo) { // Get current content $vars = BlockUtil::varsFromContent($blockinfo['content']); // alter the corresponding variable $vars['format'] = FormUtil::getPassedValue('format', 1, 'POST'); // write back the new contents $blockinfo['content'] = BlockUtil::varsToContent($vars); // clear the block cache $this->view->clear_cache('theme_block_themeswitcher.tpl'); // and clear the theme cache Zikula_View_Theme::getInstance()->clear_cache(); return $blockinfo; }
/** * Display a block based on the current theme. * * @param array $blockinfo Block info. * * @return string The rendered output. */ public static function themeBlock($blockinfo) { static $themeinfo, $themedir, $upb, $downb; if (!isset($blockinfo['bid'])) { $blockinfo['bid'] = ''; } if (!isset($blockinfo['title'])) { $blockinfo['title'] = ''; } if (UserUtil::isLoggedIn() && ModUtil::getVar('Blocks', 'collapseable') == 1 && isset($blockinfo['collapsable']) && ($blockinfo['collapsable'] == '1')) { if (!isset($themeinfo)) { $themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme())); $themedir = DataUtil::formatForOS($themeinfo['directory']); } // check for collapsable menus being enabled, and setup the collapsable menu image. if (!isset($upb)) { if (file_exists('themes/' . $themedir . '/images/upb.png')) { $upb = '<img src="themes/' . $themedir . '/images/upb.png" alt="-" />'; } elseif (file_exists('themes/' . $themedir . '/images/14_layer_raiselayer.png')) { $upb = '<img src="themes/' . $themedir . '/images/14_layer_raiselayer.png" alt="-" />'; } else { $upb = '<img src="images/icons/extrasmall/14_layer_raiselayer.png" alt="-" />'; } } if (!isset($downb)) { if (file_exists('themes/' . $themedir . '/images/downb.png')) { $downb = '<img src="themes/' . $themedir . '/images/downb.png" alt="+" />'; } elseif (file_exists('themes/' . $themedir . '/images/14_layer_lowerlayer.png')) { $downb = '<img src="themes/' . $themedir . '/images/14_layer_lowerlayer.png" alt="+" />'; } else { $downb = '<img src="images/icons/extrasmall/14_layer_lowerlayer.png" alt="+" />'; } } if (self::checkUserBlock($blockinfo) == '1') { if (!empty($blockinfo['title'])) { $blockinfo['minbox'] = '<a href="' . DataUtil::formatForDisplay(ModUtil::url('Blocks', 'user', 'changestatus', array('bid' => $blockinfo['bid']))) . '">' . $upb . '</a>'; } } else { $blockinfo['content'] = ''; if (!empty($blockinfo['title'])) { $blockinfo['minbox'] = '<a href="' . DataUtil::formatForDisplay(ModUtil::url('Blocks', 'user', 'changestatus', array('bid' => $blockinfo['bid']))) . '">' . $downb . '</a>'; } } // end collapseable menu config } else { $blockinfo['minbox'] = ''; } return Zikula_View_Theme::getInstance()->themesidebox($blockinfo); }
/** * Clears the cache for a specific cache_id's in all active themes. * * @param string $cache_ids Array of given cache ID's for which to clear theme cache. * @param string $themes Array of theme objects for which to clear theme cache, defaults to all active themes. * * @return boolean True on success. */ public function clear_cacheid_allthemes($cache_ids, $themes = null) { if ($cache_ids) { if (!is_array($cache_ids)) { $cache_ids = array($cache_ids); } if (!$themes) { $themes = ThemeUtil::getAllThemes(); } $theme = Zikula_View_Theme::getInstance(); foreach ($themes as $themearr) { foreach ($cache_ids as $cache_id) { $theme->clear_cache(null, $cache_id, null, null, $themearr['directory']); } } } return true; }
/** * Display a block based on the current theme. * * @param array $blockinfo Block info. * * @return string The rendered output. */ public static function themeBlock($blockinfo) { static $themeinfo, $themedir, $upb, $downb; if (!isset($blockinfo['bid'])) { $blockinfo['bid'] = ''; } if (!isset($blockinfo['title'])) { $blockinfo['title'] = ''; } if (UserUtil::isLoggedIn() && ModUtil::getVar('ZikulaBlocksModule', 'collapseable') == 1 && isset($blockinfo['collapsable']) && $blockinfo['collapsable'] == '1') { if (!isset($themeinfo)) { $themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme())); $themedir = DataUtil::formatForOS($themeinfo['directory']); } // check for collapsable menus being enabled, and setup the collapsable menu image. if (!isset($upb)) { if (file_exists('themes/' . $themedir . '/images/upb.png')) { $upb = '<img src="themes/' . $themedir . '/images/upb.png" alt="-" />'; } elseif (file_exists('themes/' . $themedir . '/images/14_layer_raiselayer.png')) { $upb = '<img src="themes/' . $themedir . '/images/14_layer_raiselayer.png" alt="-" />'; } else { $upb = '<img src="images/icons/extrasmall/14_layer_raiselayer.png" alt="-" />'; } } if (!isset($downb)) { if (file_exists('themes/' . $themedir . '/images/downb.png')) { $downb = '<img src="themes/' . $themedir . '/images/downb.png" alt="+" />'; } elseif (file_exists('themes/' . $themedir . '/images/14_layer_lowerlayer.png')) { $downb = '<img src="themes/' . $themedir . '/images/14_layer_lowerlayer.png" alt="+" />'; } else { $downb = '<img src="images/icons/extrasmall/14_layer_lowerlayer.png" alt="+" />'; } } $checkUserBlock = self::checkUserBlock($blockinfo); if ($checkUserBlock) { if (!empty($blockinfo['title'])) { $blockinfo['minbox'] = '<a href="' . DataUtil::formatForDisplay(ModUtil::url('ZikulaBlocksModule', 'user', 'changestatus', array('bid' => $blockinfo['bid']))) . '">' . $upb . '</a>'; } } else { $blockinfo['content'] = ''; if (!empty($blockinfo['title'])) { $blockinfo['minbox'] = '<a href="' . DataUtil::formatForDisplay(ModUtil::url('ZikulaBlocksModule', 'user', 'changestatus', array('bid' => $blockinfo['bid']))) . '">' . $downb . '</a>'; } } // end collapseable menu config } else { $blockinfo['minbox'] = ''; } // try twig theme first (note: theme is already set by this point) $container = ServiceUtil::getManager(); $twigBasedThemeBlock = $container->get('zikula_core.common.theme_engine')->wrapBcBlockInTheme($blockinfo); if ($twigBasedThemeBlock) { return $twigBasedThemeBlock; } // theme is not twig based revert to smarty return Zikula_View_Theme::getInstance()->themesidebox($blockinfo); }
/** * update block settings * * @param array $blockinfo a blockinfo structure * @return $blockinfo the modified blockinfo structure */ public function update($blockinfo) { $vars['displaymodules'] = FormUtil::getPassedValue('displaymodules'); $vars['style'] = FormUtil::getPassedValue('style'); $vars['stylesheet'] = FormUtil::getPassedValue('stylesheet'); // Defaults if (empty($vars['displaymodules'])) { $vars['displaymodules'] = 0; } if (empty($vars['style'])) { $vars['style'] = 1; } if (empty($vars['template'])) { $vars['template'] = 'menu'; } // User links $content = array(); $c = 1; $linkname = FormUtil::getPassedValue('linkname'); $linkurl = FormUtil::getPassedValue('linkurl'); $linkdesc = FormUtil::getPassedValue('linkdesc'); $linkdelete = FormUtil::getPassedValue('linkdelete'); $linkinsert = FormUtil::getPassedValue('linkinsert'); if (isset($linkname)) { foreach ($linkname as $v) { if (empty($linkdelete[$c])) { $content[] = "$linkurl[$c]|$linkname[$c]|$linkdesc[$c]"; } if (!empty($linkinsert[$c])) { $content[] = '||'; } $c++; } } $new_linkname = FormUtil::getPassedValue('new_linkname'); $new_linkurl = FormUtil::getPassedValue('new_linkurl'); $new_linkdesc = FormUtil::getPassedValue('new_linkdesc'); $new_linkinsert = (bool)FormUtil::getPassedValue('new_linkinsert'); if ($new_linkname) { $content[] = $new_linkurl . '|' . $new_linkname . '|' . $new_linkdesc; if ($new_linkinsert) { $content[] = '||'; } } $vars['content'] = implode('LINESPLIT', $content); $blockinfo['content'] = BlockUtil::varsToContent($vars); // clear the block cache $this->view->clear_cache('blocks_block_menu.tpl'); // and clear the theme cache Zikula_View_Theme::getInstance()->clear_cache(); return($blockinfo); }
} } switch (true) { case $return === true: // prevent rendering of the theme. System::shutDown(); break; case $httpCode == 403: if (!UserUtil::isLoggedIn()) { $url = ModUtil::url('Users', 'user', 'login', array('returnpage' => urlencode(System::getCurrentUri()))); LogUtil::registerError(LogUtil::getErrorMsgPermission(), $httpCode, $url); System::shutDown(); } // there is no break here deliberately. // there is no break here deliberately. case $return === false: if (!LogUtil::hasErrors()) { LogUtil::registerError(__f('Could not load the \'%1$s\' module at \'%2$s\'.', array($module, $func)), $httpCode, null); } echo ModUtil::func('Errors', 'user', 'main', array('message' => $message, 'exception' => $e)); break; case $httpCode == 200: echo $return; break; default: LogUtil::registerError(__f('The \'%1$s\' module returned an error in \'%2$s\'.', array($module, $func)), $httpCode, null); echo ModUtil::func('Errors', 'user', 'main', array('message' => $message, 'exception' => $e)); break; } Zikula_View_Theme::getInstance()->themefooter(); System::shutdown();
/** * Initialise Zikula. * * Carries out a number of initialisation tasks to get Zikula up and * running. * * @param integer $stage Stage to load. * * @return boolean True initialisation successful false otherwise. */ public function onInit(GetResponseEvent $event) { if ($event->getRequestType() === HttpKernelInterface::SUB_REQUEST) { return; } $this->dispatcher = $event->getDispatcher(); $this->stage = $stage = self::STAGE_ALL; $coreInitEvent = new GenericEvent($this); $coreInitEvent['request'] = $event->getRequest(); // store the load stages in a global so other API's can check whats loaded $this->dispatcher->dispatch(CoreEvents::PREINIT, new GenericEvent($this)); // // Initialise and load configuration // if ($stage & self::STAGE_CONFIG) { // // error reporting // if (!\System::isInstalling()) { // // this is here because it depends on the config.php loading. // $event = new GenericEvent(null, array('stage' => $stage)); // $this->dispatcher->dispatch(CoreEvents::ERRORREPORTING, $event); // } // // // initialise custom event listeners from config.php settings // $coreInitEvent->setArg('stage', self::STAGE_CONFIG); // $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent); // } // // Check that Zikula is installed before continuing // if (\System::getVar('installed') == 0 && !\System::isInstalling()) { // $response = new RedirectResponse(\System::getBaseUrl().'install.php?notinstalled'); // $response->send(); // \System::shutdown(); // } if ($stage & self::STAGE_DB) { try { $dbEvent = new GenericEvent(); $this->dispatcher->dispatch('doctrine.init_connection', $dbEvent); $dbEvent = new GenericEvent($this, array('stage' => self::STAGE_DB)); $this->dispatcher->dispatch(CoreEvents::INIT, $dbEvent); } catch (\PDOException $e) { if (!\System::isInstalling()) { header('HTTP/1.1 503 Service Unavailable'); require_once \System::getSystemErrorTemplate('dbconnectionerror.tpl'); \System::shutDown(); } else { return false; } } } if ($stage & self::STAGE_TABLES) { // Initialise dbtables \ModUtil::initCoreVars(); \ModUtil::dbInfoLoad('SettingsModule', 'SettingsModule'); \ModUtil::dbInfoLoad('ThemeModule', 'ThemeModule'); \ModUtil::dbInfoLoad('UsersModule', 'UsersModule'); \ModUtil::dbInfoLoad('GroupsModule', 'GroupsModule'); \ModUtil::dbInfoLoad('PermissionsModule', 'PermissionsModule'); \ModUtil::dbInfoLoad('CategoriesModule', 'CategoriesModule'); if (!\System::isInstalling()) { \ModUtil::registerAutoloaders(); } $coreInitEvent->setArg('stage', self::STAGE_TABLES); $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent); } if ($stage & self::STAGE_SESSIONS) { \SessionUtil::requireSession(); $coreInitEvent->setArg('stage', self::STAGE_SESSIONS); $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent); } // Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak) // start block if ($stage & self::STAGE_LANGS) { $lang = \ZLanguage::getInstance(); } if ($stage & self::STAGE_DECODEURLS) { \System::queryStringDecode(); $coreInitEvent->setArg('stage', self::STAGE_DECODEURLS); $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent); } if ($stage & self::STAGE_LANGS) { $lang->setup(); $coreInitEvent->setArg('stage', self::STAGE_LANGS); $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent); } // end block if ($stage & self::STAGE_MODS) { // Set compression on if desired if (\System::getVar('UseCompression') == 1) { //ob_start("ob_gzhandler"); } \ModUtil::load('SecurityCenter'); $coreInitEvent->setArg('stage', self::STAGE_MODS); $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent); } if ($stage & self::STAGE_THEME) { // register default page vars \PageUtil::registerVar('title'); \PageUtil::setVar('title', \System::getVar('defaultpagetitle')); \PageUtil::registerVar('keywords', true); \PageUtil::registerVar('stylesheet', true); \PageUtil::registerVar('javascript', true); \PageUtil::registerVar('jsgettext', true); \PageUtil::registerVar('body', true); \PageUtil::registerVar('header', true); \PageUtil::registerVar('footer', true); $theme = \Zikula_View_Theme::getInstance(); // set some defaults // Metadata for SEO $this->container['zikula_view.metatags']['description'] = \System::getVar('defaultmetadescription'); $this->container['zikula_view.metatags']['keywords'] = \System::getVar('metakeywords'); $coreInitEvent->setArg('stage', self::STAGE_THEME); $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent); } // check the users status, if not 1 then log him out if (\UserUtil::isLoggedIn()) { $userstatus = \UserUtil::getVar('activated'); if ($userstatus != UsersConstant::ACTIVATED_ACTIVE) { \UserUtil::logout(); // TODO - When getting logged out this way, the existing session is destroyed and // then a new one is created on the reentry into index.php. The message // set by the registerStatus call below gets lost. \LogUtil::registerStatus(__('You have been logged out.')); $response = new RedirectResponse(\ModUtil::url('Users', 'user', 'login')); $response->send(); exit; } } if ($stage & self::STAGE_POST && $this->stage & ~self::STAGE_POST) { $this->dispatcher->dispatch(CoreEvents::POSTINIT, new GenericEvent($this, array('stages' => $stage))); } $this->dispatcher->dispatch('frontcontroller.predispatch', new GenericEvent()); }
/** * update block settings * * @param array $blockinfo a blockinfo structure * @return $blockinfo the modified blockinfo structure */ public function update($blockinfo) { // Get current content $vars = BlockUtil::varsFromContent($blockinfo['content']); // Read inputs $vars['format'] = $this->request->get('format'); // Read inputs $vars['fulltranslation'] = $this->request->get('fulltranslation'); // Scan for languages and save cached version $vars['languages'] = $this->getAvailableLanguages(); // write back the new contents $blockinfo['content'] = BlockUtil::varsToContent($vars); // clear the block cache $this->view->clear_cache('Block/thelang.tpl'); // and clear the theme cache \Zikula_View_Theme::getInstance()->clear_cache(); return $blockinfo; }
/** * Clear cache for given item. Can be called from other modules to clear an item cache. * * @param $item - the item: array with data or id of the item */ function clearItemCache($item) { if ($item && !is_array($item)) { $object = new AddressBook_DBObject_Address(); $item = $object->get($item); } if ($item && isset($item['id']) && $item['id'] > 0) { // Clear View_cache $cache_ids = array(); $cache_ids[] = 'display/id_' . $item['id']; $cache_ids[] = 'view/cat_0'; $cache_ids[] = 'view/cat_' . $item['cat_id']; $view = Zikula_View::getInstance('AddressBook'); foreach ($cache_ids as $cache_id) { $view->clear_cache(null, $cache_id); } // Clear Theme_cache $cache_ids = array(); $cache_ids[] = 'AddressBook/user/display/id_' . $item['id']; // for given Id, according to new cache_id structure in Zikula 1.3.2.dev (1.3.3) //$cache_ids[] = 'homepage'; // for homepage (it can be adjustment in module settings) $cache_ids[] = 'AddressBook/user/view'; // view function (contacts list) $cache_ids[] = 'AddressBook/user/main'; // main function $theme = Zikula_View_Theme::getInstance(); //if (Zikula_Core::VERSION_NUM > '1.3.2') { if (method_exists($theme, 'clear_cacheid_allthemes')) { $theme->clear_cacheid_allthemes($cache_ids); } else { // clear cache for current theme only foreach ($cache_ids as $cache_id) { $theme->clear_cache(null, $cache_id); } } } }
/** * Clear the Zikula cache. * * This function clear the zikula cache. * * @return void */ function upgrade_clear_caches() { Zikula_View_Theme::getInstance()->clear_all_cache(); Zikula_View_Theme::getInstance()->clear_compiled(); Zikula_View_Theme::getInstance()->clear_cssjscombinecache(); Zikula_View::getInstance()->clear_all_cache(); Zikula_View::getInstance()->clear_compiled(); }
/** * update block configuration */ public function update($blockinfo) { // Get current content $vars = BlockUtil::varsFromContent($blockinfo['content']); // check if import old menu $menutree_menus = FormUtil::getPassedValue('menutree_menus', 'null'); if ($menutree_menus != 'null') { $vars['menutree_content'] = $this->_import_menu($menutree_menus); } else { $vars['menutree_content'] = FormUtil::getPassedValue('menutree_content', '', 'POST'); $vars['menutree_content'] = DataUtil::urlsafeJsonDecode($vars['menutree_content']); } if (!$this->validate_menu($vars['menutree_content'])) { return LogUtil::registerError($this->__('Error! Could not save your changes.')); } // sort tree array according to lineno key uasort($vars['menutree_content'], array('Blocks_Block_Menutree','sort_menu')); // get other form data $menutree_data = FormUtil::getPassedValue('menutree'); $vars['menutree_tpl'] = isset($menutree_data['tpl']) ? $menutree_data['tpl'] : ''; if (empty($vars['menutree_tpl']) || !$this->view->template_exists($vars['menutree_tpl'])) { $vars['menutree_tpl'] = 'menutree/blocks_block_menutree_default.tpl'; } $vars['menutree_stylesheet'] = isset($menutree_data['stylesheet']) ? $menutree_data['stylesheet'] : ''; if (empty($vars['menutree_stylesheet']) || $vars['menutree_stylesheet'] == 'null' || !file_exists($vars['menutree_stylesheet'])) { $vars['menutree_stylesheet'] = ''; } $vars['menutree_titles'] = isset($menutree_data['titles']) ? $menutree_data['titles'] : array(); $vars['menutree_linkclass'] = isset($menutree_data['linkclass']) ? (bool)$menutree_data['linkclass'] : false; // if class list is provided - rebuild array and fill empty entries if ($vars['menutree_linkclass'] && isset($menutree_data['linkclasses'])) { foreach ((array)$menutree_data['linkclasses'] as $k => $class) { if (empty($class['name'])) { unset($menutree_data['linkclasses'][$k]); } elseif (empty($class['title'])) { $menutree_data['linkclasses'][$k]['title'] = $class['name']; } } $vars['menutree_linkclasses'] = $menutree_data['linkclasses']; if (count($vars['menutree_linkclasses']) < 1) { $vars['menutree_linkclass'] = false; } } $vars['menutree_maxdepth'] = isset($menutree_data['maxdepth']) ? (int)$menutree_data['maxdepth'] : 0; $vars['menutree_editlinks'] = isset($menutree_data['editlinks']) ? (bool)$menutree_data['editlinks'] : false; $vars['menutree_stripbaseurl'] = isset($menutree_data['stripbaseurl']) ? (bool)$menutree_data['stripbaseurl'] : false; $vars['menutree_titlesperms'] = isset($menutree_data['titlesperms']) && array_key_exists($menutree_data['titlesperms'],$this->_permlevels()) ? $menutree_data['titlesperms'] : 'ACCESS_EDIT'; $vars['menutree_displayperms'] = isset($menutree_data['displayperms']) && array_key_exists($menutree_data['displayperms'],$this->_permlevels()) ? $menutree_data['displayperms'] : 'ACCESS_EDIT'; $vars['menutree_settingsperms'] = isset($menutree_data['settingsperms']) && array_key_exists($menutree_data['settingsperms'],$this->_permlevels()) ? $menutree_data['settingsperms'] : 'ACCESS_EDIT'; if (empty($vars['menutree_content'])) { unset($vars['menutree_content']); } else { // check langs and save current langs list and current default lang $tmp = current($vars['menutree_content']); $vars['oldlanguages'] = array_keys($tmp); $vars['olddefaultanguage'] = $vars['oldlanguages'][0]; // strip base url - if needed if ($vars['menutree_stripbaseurl'] === true) { $baseurl = System::getBaseUrl(); foreach ($vars['menutree_content'] as $itemid => $item) { foreach ($item as $lang => $_item) { // strip base url only when it occurs at the beginning of url and only once if (strpos($_item['href'], $baseurl) === 0) { $vars['menutree_content'][$itemid][$lang]['href'] = substr_replace($_item['href'], '', 0, strlen($baseurl)); } } } } } // write back the new contents $blockinfo['content'] = BlockUtil::varsToContent($vars); // clear the block cache $this->view->clear_cache(null, $blockinfo['bkey'].'/bid'.$blockinfo['bid']); // and clear the theme cache Zikula_View_Theme::getInstance()->clear_cache(); return $blockinfo; }
/** * update block settings * * @param array $blockinfo a blockinfo structure * @return $blockinfo the modified blockinfo structure */ public function update($blockinfo) { // list of vars that don't need to be saved $search_reserved_vars = array('authid', 'csrftoken', 'bid', 'title', 'positions', 'language', 'submit', 'refresh', 'filter', 'type', 'functions', 'customargs'); // Get current content $vars = BlockUtil::varsFromContent($blockinfo['content']); foreach ($_POST as $key => $value) { if (in_array($key, $search_reserved_vars)) { continue; } $vars[$key] = $value; } // write back the new contents $blockinfo['content'] = BlockUtil::varsToContent($vars); // clear the block cache $this->view->clear_cache('search_block_search.tpl'); // and clear the theme cache Zikula_View_Theme::getInstance()->clear_cache(); return($blockinfo); }
/** * Clear theme engine configurations * * Using this function, the admin can clear all theme engine configuration * copies created inside the temporary directory. */ public function clear_config() { $csrftoken = FormUtil::getPassedValue('csrftoken'); $this->checkCsrfToken($csrftoken); // Security check if (!SecurityUtil::checkPermission('Theme::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } $theme = Zikula_View_Theme::getInstance(); $res = $theme->clear_theme_config(); if ($res) { LogUtil::registerStatus($this->__('Done! Deleted theme engine configurations.')); } else { LogUtil::registerError($this->__('Error! Failed to clear theme engine configurations.')); } $this->redirect(ModUtil::url('Theme', 'admin', 'modifyconfig')); }
/** * update block settings * * @param array $blockinfo a blockinfo structure * @return $blockinfo the modified blockinfo structure */ public function update($blockinfo) { $vars['displaymodules'] = FormUtil::getPassedValue('displaymodules'); $vars['stylesheet'] = FormUtil::getPassedValue('stylesheet'); $vars['template'] = FormUtil::getPassedValue('template'); $vars['blocktitles'] = FormUtil::getPassedValue('blocktitles'); // Defaults if (empty($vars['displaymodules'])) { $vars['displaymodules'] = 0; } if (empty($vars['template'])) { $vars['template'] = 'blocks_block_extmenu.tpl'; } if (empty($vars['stylesheet'])) { $vars['stylesheet'] = 'extmenu.css'; } // User links $content = array(); $vars['links'] = FormUtil::getPassedValue('links'); $vars['blockversion'] = 1; // Save links hierarchy $linksorder = FormUtil::getPassedValue('linksorder'); $linksorder = json_decode($linksorder, true); if (is_array($linksorder) && !empty($linksorder)) { foreach ((array) $vars['links'] as $lang => $langlinks) { foreach ($langlinks as $linkid => $link) { $vars['links'][$lang][$linkid]['parentid'] = $linksorder[$linkid]['parentid']; $vars['links'][$lang][$linkid]['haschildren'] = $linksorder[$linkid]['haschildren']; } } } $blockinfo['content'] = BlockUtil::varsToContent($vars); // clear the block cache $this->view->clear_cache(null, $blockinfo['bkey'] . '/bid' . $blockinfo['bid']); // and clear the theme cache Zikula_View_Theme::getInstance()->clear_cache(); return $blockinfo; }
/** * Upgrade a module * @param int 'id' module id * @return bool true */ public function upgradeAction() { $csrftoken = $this->request->get('csrftoken'); $this->checkCsrfToken($csrftoken); $session = $this->request->getSession(); $interactive_upgrade = $session->get('interactive_upgrade'); $interactive_upgrade = empty($interactive_upgrade) ? false : true; if ($interactive_upgrade == false) { $id = (int) $this->request->query->get('id', null); $startnum = (int) $this->request->query->get('startnum', null); $letter = $this->request->query->get('letter', null); $state = $this->request->query->get('state', null); $session->set('modules_id', $id); $session->set('modules_startnum', $startnum); $session->set('modules_letter', $letter); $session->set('modules_state', $state); $activate = false; } else { $id = $session->get('modules_id'); $startnum = $session->get('modules_startnum'); $letter = $session->get('modules_letter'); $state = $session->get('modules_state'); $activate = (bool) $this->request->request->get('activate', null); } if (empty($id) || !is_numeric($id)) { return LogUtil::registerError($this->__('Error! No module ID provided.'), 404, ModUtil::url('Extensions', 'admin', 'view')); } // Upgrade module $res = ModUtil::apiFunc('ExtensionsModule', 'admin', 'upgrade', array('id' => $id, 'interactive_upgrade' => $interactive_upgrade)); if (is_bool($res) && $res == true) { // Success $session->remove('modules_id'); $session->remove('modules_startnum'); $session->remove('modules_letter'); $session->remove('modules_state'); $session->set('interactive_upgrade', false); LogUtil::registerStatus($this->__('New version')); if ($activate == true) { if (ModUtil::apiFunc('ExtensionsModule', 'admin', 'setstate', array('id' => $id, 'state' => ModUtil::STATE_ACTIVE))) { // Success LogUtil::registerStatus($this->__('Activated')); } } // Clear the Zikula_View cached/compiled files and Themes cached/compiled/cssjs combination files $theme = \Zikula_View_Theme::getInstance('Theme'); $theme->clear_compiled(); $theme->clear_all_cache(); $theme->clear_cssjscombinecache(); $this->view->clear_compiled(); $this->view->clear_all_cache(); return $this->redirect(ModUtil::url('Extensions', 'admin', 'view', array('startnum' => $startnum, 'letter' => $letter, 'state' => $state))); } elseif (is_bool($res)) { return $this->redirect(ModUtil::url('Extensions', 'admin', 'view', array('startnum' => $startnum, 'letter' => $letter, 'state' => $state))); } else { return $res; } }
/** * Clear cache for given item. Can be called from other modules to clear an item cache. * * @param $item - the item: array with data or id of the item */ public function clearItemCache($item) { if ($item && !is_array($item)) { $item = ModUtil::apiFunc('Pages', 'user', 'get', array('sid' => $item)); } if ($item) { // Clear View_cache $cache_ids = array(); $cache_ids[] = $item['sid']; $cache_ids[] = 'view'; $cache_ids[] = 'main'; $view = Zikula_View::getInstance('Pages'); foreach ($cache_ids as $cache_id) { $view->clear_cache(null, $cache_id); } // Clear Theme_cache $cache_ids = array(); $cache_ids[] = 'Pages/user/display/pageid_'.$item['pageid']; // for given page Id, according to new cache_id structure in Zikula 1.3.2.dev (1.3.3) $cache_ids[] = 'homepage'; // for homepage (it can be adjustment in module settings) $cache_ids[] = 'Pages/user/view'; // view function (pages list) $cache_ids[] = 'Pages/user/main'; // main function $theme = Zikula_View_Theme::getInstance(); //if (Zikula_Core::VERSION_NUM > '1.3.2') { if (method_exists($theme, 'clear_cacheid_allthemes')) { $theme->clear_cacheid_allthemes($cache_ids); } else { // clear cache for current theme only foreach ($cache_ids as $cache_id) { $theme->clear_cache(null, $cache_id); } } } }
function message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', $err_file = '', $sql = '') { // Begin PNphpBB2 Module // global $db, $template, $board_config, $theme, $lang, $phpEx, $phpbb_root_path, $nav_links, $gen_simple_header, $images; global $db, $template, $board_config, $phpbb_theme, $lang, $phpEx, $phpbb_root_path, $nav_links, $images; // End PNphpBB2 Module global $userdata, $user_ip, $session_length; global $starttime; if (defined('HAS_DIED')) { die("message_die() was called multiple times. This isn't supposed to happen. Was message_die() used in page_tail.php?"); } define('HAS_DIED', 1); $sql_store = $sql; // // Get SQL error if we are debugging. Do this as soon as possible to prevent // subsequent queries from overwriting the status of sql_error() // if (DEBUG && ($msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR)) { $sql_error = $db->sql_error(); $debug_text = ''; if ($sql_error['message'] != '') { $debug_text .= '<br /><br />SQL Error : ' . $sql_error['code'] . ' ' . $sql_error['message']; } if ($sql_store != '') { $debug_text .= "<br /><br />{$sql_store}"; } if ($err_line != '' && $err_file != '') { $debug_text .= '<br /><br />Line : ' . $err_line . '<br />File : ' . basename($err_file); } } if (empty($userdata) && ($msg_code == GENERAL_MESSAGE || $msg_code == GENERAL_ERROR)) { $userdata = session_pagestart($user_ip, PAGE_INDEX); init_userprefs($userdata); } // // If the header hasn't been output then do it // if (!defined('HEADER_INC') && $msg_code != CRITICAL_ERROR) { if (empty($lang)) { if (!empty($board_config['default_lang'])) { include $phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx; } else { include $phpbb_root_path . 'language/lang_english/lang_main.' . $phpEx; } } // Begin PNphpBB2 Module if (empty($template) || empty($phpbb_theme)) { $phpbb_theme = setup_style($board_config['default_style']); } // End PNphpBB2 Module // // Load the Page Header // if (!defined('IN_ADMIN')) { include $phpbb_root_path . 'includes/page_header.' . $phpEx; } else { include $phpbb_root_path . 'admin/page_header_admin.' . $phpEx; } } switch ($msg_code) { case GENERAL_MESSAGE: if ($msg_title == '') { $msg_title = $lang['Information']; } break; case CRITICAL_MESSAGE: if ($msg_title == '') { $msg_title = $lang['Critical_Information']; } break; case GENERAL_ERROR: if ($msg_text == '') { $msg_text = $lang['An_error_occured']; } if ($msg_title == '') { $msg_title = $lang['General_Error']; } break; case CRITICAL_ERROR: // // Critical errors mean we cannot rely on _ANY_ DB information being // available so we're going to dump out a simple echo'd statement // include $phpbb_root_path . 'language/lang_english/lang_main.' . $phpEx; if ($msg_text == '') { $msg_text = $lang['A_critical_error']; } if ($msg_title == '') { // Begin PNphpBB2 Module // $msg_title = 'phpBB : <b>' . $lang['Critical_Error'] . '</b>'; $msg_title = 'ZphpBB2 : <b>' . $lang['Critical_Error'] . '</b>'; // End PNphpBB2 Module } break; } // // Add on DEBUG info if we've enabled debug mode and this is an error. This // prevents debug info being output for general messages should DEBUG be // set TRUE by accident (preventing confusion for the end user!) // if (DEBUG && ($msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR)) { if ($debug_text != '') { $msg_text = $msg_text . '<br /><br /><b><u>DEBUG MODE</u></b>' . $debug_text; } } if ($msg_code != CRITICAL_ERROR) { if (!empty($lang[$msg_text])) { $msg_text = $lang[$msg_text]; } if (!defined('IN_ADMIN')) { $template->set_filenames(array('message_body' => 'message_body.tpl')); } else { $template->set_filenames(array('message_body' => 'admin/admin_message_body.tpl')); } $template->assign_vars(array('MESSAGE_TITLE' => $msg_title, 'MESSAGE_TEXT' => $msg_text)); ob_start(); // ZphpBB2 $template->pparse('message_body'); $content = ob_get_contents(); // ZphpBB2 ob_end_clean(); // ZphpBB2 if (!defined('IN_ADMIN')) { include $phpbb_root_path . 'includes/page_tail.' . $phpEx; } else { echo $content; // ZphpBB2 include $phpbb_root_path . 'admin/page_footer_admin.' . $phpEx; } } else { echo "<html>\n<body>\n" . $msg_title . "\n<br /><br />\n" . $msg_text . "</body>\n</html>"; } // ZphpBB2 => if (defined('IN_ADMIN')) { exit; } else { if (Zikula_Core::VERSION_NUM >= '1.4.0') { LogUtil::registerStatus($content); System::redirect(ModUtil::url('ZphpBB2', 'user', 'message')); } else { echo $content; Zikula_View_Theme::getInstance()->themefooter(); System::shutdown(); } } //exit; // <= ZphpBB2 }