protected function pagenotfound() { if (AnwCurrentSession::isActionAllowed($this->getoPage()->getName(), 'create', -1)) { AnwPlugins::hook('action_view_pagenotfound_create', $this->getoPage()); AnwUtils::redirect(AnwUtils::link($this->getoPage(), "create")); } else { AnwPlugins::hook('action_view_pagenotfound_404', $this->getoPage()); $this->error404(); } }
public static function loadContentClass($sContentClassName) { if (self::isContentClassLoaded($sContentClassName)) { throw new AnwUnexpectedException("ContentClass " . $sContentClassName . " is already defined"); } $oContentClass = AnwContentClassPage::loadComponent($sContentClassName); self::$osContentClasses[$sContentClassName] = $oContentClass; $oContentClass->init(); //AFTER adding to $osContentClasses !! AnwPlugins::hook("contentclass_init", $oContentClass); AnwPlugins::hook("contentclass_init_byname_" . $oContentClass->getName(), $oContentClass); }
private static function loadCurrentSession() { AnwDebug::startbench("Current session load"); try { self::$oSession = AnwSessions::getCurrentSession(); //keepalive $nElapsedTimeSinceKeepalive = time() - self::getLastKeepAlive(); $nKeepAliveInterval = AnwComponent::globalCfgKeepaliveDelay(); AnwDebug::log('(AnwSessions) Time elapsed since last keepalive: ' . $nElapsedTimeSinceKeepalive . '/' . $nKeepAliveInterval . 's'); if ($nElapsedTimeSinceKeepalive > $nKeepAliveInterval) { AnwDebug::log('(AnwSessions) Running keepalive...'); $nTime = time(); self::resetLastKeepAlive(); //keepalive session AnwSessions::keepAlive(); //run hooks $oSessionUser = self::$oSession->getUser(); AnwPlugins::hook("session_keepalive_any", $oSessionUser); if (self::$oSession->isLoggedIn()) { AnwPlugins::hook("session_keepalive_loggedin", $oSessionUser); } else { AnwPlugins::hook("session_keepalive_loggedout", $oSessionUser); } } } catch (AnwUserNotFoundException $e) { //current user doesn't exist anymore self::$oSession = new AnwSession(); self::logout(); } AnwDebug::stopbench("Current session load"); }
public function t_contentfieldpage($id, $asParams = array(), $sLangIfLocal = false, $sValueIfNotFound = false) { $sPrefix = $this->getComponentName() . '-contentfields'; if (!$this->bTranslationsContentFieldSettingsLoaded) { //load translations $this->bTranslationsContentFieldSettingsLoaded = true; try { Anwi18n::loadTranslationsFromPath($sPrefix, $this->getMyComponentDir() . ANWDIR_LANG, $this->isAddon(), $sPrefix); } catch (AnwException $e) { } } $sTranslation = AnwPlugins::vhook('component_t_contentfieldpage_override', null, $this, $id, $asParams, $sLangIfLocal, $sValueIfNotFound); if (!$sTranslation) { $sTranslation = Anwi18n::t_($id, $asParams, $sPrefix, $sLangIfLocal, $sValueIfNotFound); } return $sTranslation; }
function runBody() { $bRunDynamicParsing = $this->bRunDynamicParsingBody && $this->bHasDynamicParsingBody; $bRunDynamicPhp = $this->bRunDynamicPhpBody && $this->bHasDynamicPhpBody; $sHtml = $this->run($this->sBody, $bRunDynamicParsing, $bRunDynamicPhp); $sHtml = AnwPlugins::vhook('outputhtml_run_body', $sHtml); return $sHtml; }
private static function getPluginsMapping() { if (self::$aaPluginsMapping === null) { $bCachePluginsEnabled = AnwComponent::globalCfgCachePluginsEnabled(); try { //load plugins mapping if (!$bCachePluginsEnabled) { throw new AnwCacheNotFoundException(); } self::$aaPluginsMapping = AnwCache_pluginsMapping::getCachedPluginsMapping(); self::debug("Loading plugin mapping from cache"); } catch (AnwException $e) { //generate new mapping self::debug("Generating plugin mapping"); self::$aaPluginsMapping = self::generatePluginsMapping(); if ($bCachePluginsEnabled) { AnwCache_pluginsMapping::putCachedPluginsMapping(self::$aaPluginsMapping); } } } //print_r(self::$aaPluginsMapping); return self::$aaPluginsMapping; }
function getRender($bForceFromPost = false) { if (!$this->sRender) { $bFromPost = $bForceFromPost || $this->isPosted(); $this->sRender = $this->oContent->renderEditHtmlForm($bFromPost, $this->sFormUrl); $this->sRender .= '<input type="hidden" name="' . self::POSTED_INPUT_NAME . '" value="1"/>'; $this->sRender = AnwPlugins::vhook('contenteditionform_render_html', $this->sRender, $this->oContent, $bFromPost); } return $this->sRender; }
static function pubcallOperator($sArg, $sValue, $sLang, $asOperatorArgs = array()) { switch ($sArg) { case "firstwords": $sReturn = AnwXml::xmlGetUntranslatedTxt($sValue, false); $nFirstWordsLength = self::FIRSTWORDS_LENGTH; if (isset($asOperatorArgs[0]) && intval($asOperatorArgs[0]) > 0) { $nFirstWordsLength = intval($asOperatorArgs[0]); } if (strlen($sReturn) > self::FIRSTWORDS_LENGTH) { $sReturn = AnwUtils::firstWords($sValue, $nFirstWordsLength) . '...'; } return $sReturn; break; case "date": $sReturn = Anwi18n::date($sValue, $sLang); return $sReturn; break; case "datetime": $sReturn = Anwi18n::dateTime($sValue, $sLang); return $sReturn; break; case "year": $sReturn = AnwUtils::date("Y", $sValue); return $sReturn; break; case "monthyear": $sReturn = AnwUtils::date("M Y", $sValue); return $sReturn; break; case "count": $sReturn = count($sValue); return $sReturn; break; case "len": $sReturn = strlen(trim($sValue)); return $sReturn; break; case "skipuntr": $sReturn = AnwUtils::renderUntr($sValue); return $sReturn; break; // numeric maths // numeric maths case "add": case "sub": case "mul": case "div": case "pow": if (isset($asOperatorArgs[0])) { $nNumber = intval($asOperatorArgs[0]); } switch ($sArg) { case "add": $sReturn = intval($sValue) + $nNumber; break; case "sub": $sReturn = intval($sValue) - $nNumber; break; case "mul": $sReturn = intval($sValue) * $nNumber; break; case "div": $sReturn = intval($sValue) / $nNumber; break; case "pow": $sReturn = intval($sValue) ^ $nNumber; break; } return $sReturn; break; default: $sReturn = AnwPlugins::vhook('contentclass_pubcalloperator_default', $sValue, $sArg); return $sReturn; break; } }
/** * When a pageByName is not found, some plugins may offer a second chance to find the desired page. * In example, the plugin shortpagename allows to use shortcut pattern "[pagename]" to retrieve "[lang]/[pagename]" */ function getSecondChance() { if ($this->exists()) { throw new AnwUnexpectedException("Cannot call secondChance on an existing page!"); } $oPageTest = AnwPlugins::vhook('page_notfound_secondchance', null, $this->getName()); if ($oPageTest) { return $oPageTest; } return false; }
static function isNonUniqueDisplayNameAllowed() { if (!AnwComponent::globalCfgUsersUniqueDisplayname() && self::getDriver()->supportsNonUniqueDisplayName()) { try { AnwPlugins::hook("users_nonunique_displayname_allowed"); return true; } catch (AnwPluginInterruptionException $e) { } } return false; }
protected function cleanValueFromPost($sValue) { $sValue = parent::cleanValueFromPost($sValue); $sValue = self::closeMinimizedEndTags($sValue); $sValue = AnwPlugins::vHook("datatype_xhtml_cleanvaluefrompost", $sValue); return $sValue; }
private function pubcallContext($sArg) { switch ($sArg) { case "time": // timestamp for exact time return AnwUtils::time(); break; case "today": // timestamp for midnight today return AnwUtils::timeToday(); break; default: $sReturn = AnwPlugins::vhook('parser_pubcallcontext_default', $sArg); return $sReturn; break; } }