function runAndOutput() { try { AnwDebug::startbench("action runAndOutput", true); //captcha request? if (AnwEnv::_GET(self::GET_CAPTCHA)) { $this->doCaptcha(); exit; } //make sure this action is enabled in configuration if (!in_array($this->getName(), AnwComponent::getEnabledComponents(AnwComponent::TYPE_ACTION))) { throw new AnwAclException("Trying to execute an action which is not enabled"); } //is it an admin action? if ($this instanceof AnwAdminAction) { if (!AnwCurrentSession::getUser()->isAdminAllowed()) { throw new AnwAclException("Admin is not allowed"); } } //does action require https if available? if (self::isHttpsAction($this->getName())) { //do we need to redirect to https? if (self::globalCfgHttpsEnabled() && !AnwEnv::isHttps()) { //redirect to https self::debug("Redirecting to https..."); AnwUtils::httpPostToSession(); $asParams = $_GET; $sLink = AnwUtils::alink($this->getName(), $asParams); AnwUtils::redirect($sLink); //should automatically use https } } if (AnwCurrentSession::needsReauth()) { //reauth processing if (AnwEnv::_POST("reauth")) { self::debug("Processing reauth request..."); try { //check password and reset reauth $this->doReauth(AnwEnv::_POST("reauth")); self::debug("Reauth request success!"); } catch (AnwException $e) { //reauth failed, show reauth form again self::debug("Reauth success failed."); $this->doReauthForm(); //post data is already in session exit; } } //must the user reauth for this action? - do this after reauth processing if ($this instanceof AnwHarmlessAction) { //ok, user is authorized to run action without reauthenticating } else { //user needs to reauthenticate $this->checkReauth(); } } //restore POST if any in session AnwUtils::restoreHttpPostFromSession(); $this->initializeAction(); //run the action $this->init(); $this->run(); AnwDebug::stopbench("action runAndOutput"); $this->output(); } catch (AnwLockException $e) { $aoLocks = $e->getLocks(); $asLockInfos = array(); foreach ($aoLocks as $oLock) { $nLockType = $oLock->getLockType(); switch ($nLockType) { case AnwLock::TYPE_PAGEONLY: $sTranslation = "err_ex_lock_details_pageonly"; break; case AnwLock::TYPE_PAGEGROUP: $sTranslation = "err_ex_lock_details_pagegroup"; break; default: throw new AnwUnexpectedException("lock type unknown"); break; } $asLockInfos[] = self::g_($sTranslation, array("user" => '<b>' . AnwUtils::xText($oLock->getLockUser()->getDisplayName()) . '</b>', "pagename" => '<i>' . AnwUtils::xText($oLock->getLockPage()->getName()) . '</i>', "timestart" => Anwi18n::dateTime($oLock->getLockTime()), "timeseen" => Anwi18n::dateTime($oLock->getLockTimeLast()), "timeexpire" => Anwi18n::dateTime($oLock->getLockTimeLast() + self::globalCfgLocksExpiry()))); } $this->headJs($this->tpl()->errorLock_js()); $this->out = $this->tpl()->errorLock($asLockInfos); $this->output(); } catch (AnwException $e) { $nErrorNumber = false; if ($e instanceof AnwAclPhpEditionException) { $sTitle = self::g_("err_ex_acl_t"); $sExplain = self::g_("err_ex_acl_php_p"); $sImageSrc = AnwUtils::pathImg("warning.gif"); } else { if ($e instanceof AnwAclJsEditionException) { $sTitle = self::g_("err_ex_acl_t"); $sExplain = self::g_("err_ex_acl_js_p"); $sImageSrc = AnwUtils::pathImg("warning.gif"); } else { if ($e instanceof AnwAclMinTranslatedPercentException) { $sTitle = self::g_("err_ex_acl_t"); $sExplain = self::g_("err_ex_acl_mintranslatedpercent_p", array('percent' => $e->getTranslatedPercent())); $sImageSrc = AnwUtils::pathImg("warning.gif"); } else { if ($e instanceof AnwAclException) { $sTitle = self::g_("err_ex_acl_t"); if (AnwCurrentSession::isLoggedIn()) { $sExplain = self::g_("err_ex_acl_loggedin_p"); } else { $sExplain = self::g_("err_ex_acl_loggedout_p"); } $sImageSrc = AnwUtils::pathImg("warning.gif"); } else { if ($e instanceof AnwBadCallException) { $sTitle = self::g_("err_ex_badcall_t"); $sExplain = self::g_("err_ex_badcall_p"); $sImageSrc = AnwUtils::pathImg("warning.gif"); } else { if ($e instanceof AnwDbConnectException) { $sTitle = self::g_("err_ex_dbconnect_t"); $sExplain = self::g_("err_ex_dbconnect_p"); $sImageSrc = AnwUtils::pathImg("error.gif"); $nErrorNumber = AnwDebug::reportError($e); } else { $sTitle = self::g_("err_ex_unexpected_t"); $sExplain = self::g_("err_ex_unexpected_p"); $sImageSrc = AnwUtils::pathImg("error.gif"); $nErrorNumber = AnwDebug::reportError($e); } } } } } } $this->out = $this->tpl()->errorException($sTitle, $sExplain, $sImageSrc, $nErrorNumber); //self::output(); //not use $this to avoid potential errors if it's an ActionPage $this->output(); } }
protected function xText($sString) { return AnwUtils::xText($sString); }
function link($action = 'view') { $sSrcFlag = Anwi18n::srcFlag($this->getLang()); if ($action) { $sLink = AnwUtils::link($this, $action); $HTML = "<a href=\"" . AnwUtils::xQuote($sLink) . "\" style=\"background:url('{$sSrcFlag}') no-repeat left;padding-left:18px;\">" . AnwUtils::xText($this->getName()) . "</a>"; } else { $HTML = "<span style=\"background:url('{$sSrcFlag}') no-repeat left;padding-left:18px;\">" . AnwUtils::xText($this->getName()) . "</span>"; } return $HTML; }
function getComment() { return AnwUtils::xText(parent::getComment()) . ' <span class="change_similars">(' . AnwComponent::g_("change_similars", array('count' => count($this->aoSimilarChanges))) . ')</span>'; }
function renderCollapsedInput($sInputName, $sInputValue) { $sInputValue = AnwUtils::xText($sInputValue); $HTML = <<<EOF \t{$sInputValue} {$this->sLabel} EOF; return $HTML; }