function rowTranslation($oPage, $bExportDisabled, $bNoticePhp, $bNoticeAcl) { $sTime = Anwi18n::dateTime($oPage->getTime()); $nPageId = $oPage->getId(); $sContentClass = $oPage->getPageGroup()->getContentClass()->getLabel(); if ($oPage->isTranslated()) { $sUntranslated = $this->g_("translation_complete"); $sColor = 'green'; } else { $nTranslatedPercent = $oPage->getTranslatedPercent(); $sUntranslated = $this->g_("translation_progress", array("percent" => $nTranslatedPercent)); if ($nTranslatedPercent < 25) { $sColor = 'red'; } else { $sColor = 'orange'; } } $sDisabled = $bExportDisabled ? ' disabled="disabled"' : ""; $sNoticePhp = $bNoticePhp ? $this->drawNoticeIcon($this->t_("notice_php")) : ""; $sNoticeAcl = $bNoticeAcl ? $this->drawNoticeIcon($this->t_("notice_acl")) : ""; $sImgFlag = Anwi18n::imgFlag($oPage->getLang()); $HTML = <<<EOF \t\t<li> \t\t\t<div class="colpagename"> \t\t\t\t<input type="checkbox" name="exportpages[]" class="chkexport" value="{$this->xQuote($nPageId)}" id="exportpages{$nPageId}"{$sDisabled}/> \t\t\t\t<label for="exportpages{$nPageId}">{$sImgFlag} {$this->xText($oPage->getName())}</label> {$sNoticePhp} {$sNoticeAcl} \t\t\t</div> \t\t\t<div class="colprogress"><span style="color:{$sColor}">{$sUntranslated}</span></div> \t\t\t<div class="colcontentclass">{$sContentClass}</div> \t\t\t<div class="coltime">{$sTime}</div> \t\t</li> EOF; return $HTML; }
function untranslatedPageLine($oPage) { static $n = 0; $n = $n % 2 + 1; $sCss = 'line' . $n; $sTime = Anwi18n::dateTime($oPage->getTime()); $sLnkPage = $oPage->link(); if ($oPage->isTranslated()) { $sUntranslated = $this->g_("translation_complete"); $sColor = 'green'; } else { $nTranslatedPercent = $oPage->getTranslatedPercent(); $sUntranslated = $this->g_("translation_progress", array("percent" => $nTranslatedPercent)); if ($nTranslatedPercent < 25) { $sColor = 'red'; } else { $sColor = 'orange'; } } $sContentClass = $oPage->getPageGroup()->getContentClass()->getLabel(); $HTML = <<<EOF \t\t<tr class="{$sCss}"> \t\t\t<td class="pagename">{$sLnkPage}</td> \t\t\t<td class="pageprogress"><span style="color:{$sColor}">{$sUntranslated}</span></td> \t\t\t<td class="pagecontentclass">{$sContentClass}</td> \t\t\t<td class="pagetime">{$sTime}</td> \t\t</tr> EOF; return $HTML; }
function rowTranslation($sChkName, $sInputPageName, $sInputPageLang, $sOriginalPageName, $sPageName, $sPageLang, $nPageTime, $bImportDisabled, $asNotices) { $sDisabled = $bImportDisabled ? ' disabled="disabled"' : ""; $sNotices = ""; foreach ($asNotices as $sNotice) { $sNotices .= $this->drawNoticeIcon($sNotice) . ' '; } $sPageTime = Anwi18n::dateTime($nPageTime); $sImgFlag = Anwi18n::imgFlag($sPageLang); $sSrcFlag = Anwi18n::srcFlag($sPageLang); $HTML = <<<EOF \t\t<li> \t\t\t<input type="checkbox" name="{$this->xQuote($sChkName)}[]" class="chkimport" id="{$this->xQuote($sOriginalPageName)}" value="{$this->xQuote($sOriginalPageName)}"{$sDisabled}/> \t\t\t<label for="{$this->xQuote($sOriginalPageName)}">{$sImgFlag}{$this->xText($sPageName)} ({$sPageTime}) {$sNotices}</label> EOF; if (!$bImportDisabled) { $sSelectLang = $this->selectLang(null, $sPageLang); $HTML .= <<<EOF \t\t<input type="text" class="intext inpagename" style="background-image:url('{$sSrcFlag}')" name="{$this->xQuote($sInputPageName)}" value="{$this->xQuote($sPageName)}"/> \t\t<select class="languages" name="{$this->xQuote($sInputPageLang)}">{$sSelectLang}</select> EOF; } $HTML .= <<<EOF \t\t</li> EOF; return $HTML; }
function simulateCreate($oPageRev) { $nRevTime = Anwi18n::dateTime($oPageRev->getTime()); $sRevName = $oPageRev->getName(); $sRevLang = $oPageRev->getLang(); $sRevUser = $oPageRev->getChange() ? $oPageRev->getChange()->getUser()->getDisplayName() : ""; $HTML = <<<EOF <span style="color:green;">{$this->t_('revert_sim_create', array('revtime' => $nRevTime, 'revname' => '<b>' . $sRevName . '</b>', 'revlang' => $sRevLang, 'revuser' => $this->xText($sRevUser)))}</span> <br/> EOF; return $HTML; }
private function importSelectionForm($sUploadedFile, $sImportPrefix) { //load XML from file $aaData = $this->getDataFromXmlFile(self::tmpFilename($sUploadedFile)); $sExportTime = Anwi18n::dateTime($aaData['TIME']); $sExportFrom = $aaData['FROM']; $sExportVersionName = $aaData['VERSION_NAME']; $nExportVersionId = $aaData['VERSION_ID']; //select pages to import $this->out .= $this->tpl()->beginSelection($this->linkMe(), $sUploadedFile, self::IN_FILENAME, self::IN_CONTINUE_ON_ERRORS, $sExportTime, $sExportFrom, $sExportVersionName); foreach ($aaData['PAGEGROUPS'] as $aaDataGroup) { $this->out .= $this->tpl()->rowGroupOpen($sExportTime, $sExportFrom); foreach ($aaDataGroup['PAGES'] as $aaDataPage) { $asNotices = array(); $bImportDisabled = false; $sOriginalPageName = $aaDataPage['NAME']; $sPageName = $sImportPrefix . $sOriginalPageName; //prefix $sPageLang = $aaDataPage['LANG']; $nPageTime = $aaDataPage['TIME']; $sPageContent = $aaDataPage['CONTENT']; try { //check pagename and content $asNotices = $this->checkPermissions($sPageName, $sPageLang, $sPageContent); foreach ($asNotices as $sNotice) { //don't disable import checkbox for pages already existing, as user may change the destination name if ($sNotice != $this->t_("notice_exists")) { $bImportDisabled = true; } } } catch (AnwInvalidContentException $e) { $asNotices[] = $this->t_("notice_content"); $bImportDisabled = true; } catch (AnwException $e) { $asNotices[] = $this->t_("notice_unknown"); $bImportDisabled = true; } //check lang if (!Anwi18n::langExists($sPageLang)) { $asNotices[] = $this->t_("notice_lang"); $bImportDisabled = true; } $sInputPageName = $this->getInputPageName($sOriginalPageName); $sInputPageLang = $this->getInputPageLang($sOriginalPageName); $this->out .= $this->tpl()->rowTranslation(self::IN_PAGENAMES, $sInputPageName, $sInputPageLang, $sOriginalPageName, $sPageName, $sPageLang, $nPageTime, $bImportDisabled, $asNotices); } $this->out .= $this->tpl()->rowGroupClose(); } $this->out .= $this->tpl()->endSelection(); }
function showFeed($aoPages) { $sFeedTitle = $this->t_("title") . " - " . self::globalCfgWebsiteName(); $oFeed = new AnwFeed(AnwEnv::_GET("feed"), $sFeedTitle, AnwUtils::aLinkAbsolute("untranslated")); foreach ($aoPages as $oPage) { //add to feed $sUserDisplayName = ""; $sItemTitle = '[' . $oPage->getLang() . '] ' . $oPage->getName() . ' (' . $oPage->getTranslatedPercent() . '%) - ' . Anwi18n::dateTime($oPage->getTime()); $sPageLink = AnwUtils::linkAbsolute($oPage); $oFeedItem = new AnwFeedItem($sItemTitle, $sPageLink); $oFeedItem->setDate($oPage->getTime()); $oFeedItem->setAuthor($sUserDisplayName); $oFeed->addItem($oFeedItem); } $oFeed->output(); }
private function getOptions($aoPageRevisions, $oPageSelected, $oPageReference) { $HTML = ""; foreach ($aoPageRevisions as $oPageRevision) { $nRevChangeId = $oPageRevision->getChangeId(); $sSelected = ''; if ($nRevChangeId == $oPageSelected->getChangeId()) { $sSelected = ' selected'; } $sTimeRev = Anwi18n::dateTime($oPageRevision->getTime()); $sChangeInfo = ""; if ($oPageRevision->getChange()) { $sChangeInfo = '- ' . AnwChange::changeTypei18n($oPageRevision->getChange()->getType()); } if (!$oPageReference->isArchive() && $nRevChangeId == $oPageReference->getChangeId()) { $sChangeInfo .= " " . $this->t_("rev_current"); } $HTML .= <<<EOF <option value="{$this->xQuote($nRevChangeId)}"{$sSelected}>{$sTimeRev} {$sChangeInfo}</option> EOF; } return $HTML; }
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(); } }
private function exportData($aaExportPageGroups) { $oDoc = new DOMDocument("1.0", "UTF-8"); //put information as comment $sComment = ""; $sComment .= $this->t_("xmlcomment_info") . "\n"; $sComment .= ANWIKI_WEBSITE . "\n\n"; $sComment .= $this->t_("xmlcomment_time", array("time" => Anwi18n::dateTime(time()))) . "\n"; $sComment .= $this->t_("xmlcomment_version", array("version" => ANWIKI_VERSION_NAME)) . "\n"; $sComment .= $this->t_("xmlcomment_user", array("user" => AnwCurrentSession::getUser()->getLogin())) . "\n"; $sComment .= $this->t_("xmlcomment_from", array("url" => self::globalCfgUrlRoot())) . "\n\n"; $sComment .= $this->t_("xmlcomment_contents") . "\n"; //list exported contents as comment foreach ($aaExportPageGroups as $amPageGroup) { foreach ($amPageGroup['PAGES'] as $oPage) { $sPageTime = Anwi18n::dateTime($oPage->getTime()); $sComment .= ' * ' . $oPage->getName() . " (" . $oPage->getLang() . ") (" . $sPageTime . ")\n"; } } $sCommentSeparator = "\n**************************************************\n"; $sComment = " " . $sCommentSeparator . $sComment . $sCommentSeparator . " "; $oCommentNode = $oDoc->createComment($sComment); $oDoc->appendChild($oCommentNode); //end comment //<anwexport time="" origin=""> $oRootNode = $oDoc->createElement(self::XMLTAG_ROOT); $oRootNode->setAttribute("time", time()); $oRootNode->setAttribute("from", AnwXml::xmlFileAttributeEncode(self::globalCfgUrlRoot())); $oRootNode->setAttribute("version_id", ANWIKI_VERSION_ID); $oRootNode->setAttribute("version_name", AnwXml::xmlFileAttributeEncode(ANWIKI_VERSION_NAME)); $oDoc->appendChild($oRootNode); foreach ($aaExportPageGroups as $amPageGroup) { $oPageGroup = $amPageGroup['GROUP']; $sContentClassName = $oPageGroup->getContentClass()->getName(); //<anwpagegroup> $oPageGroupNode = $oDoc->createElement(self::XMLTAG_PAGEGROUP); $oPageGroupNode->setAttribute("contentclass", AnwXml::xmlFileAttributeEncode($sContentClassName)); foreach ($amPageGroup['PAGES'] as $oPage) { //add comment $sPageTime = Anwi18n::dateTime($oPage->getTime()); $sComment = $oPage->getName() . " (" . $oPage->getLang() . ") (" . $sPageTime . ") (" . $oPageGroup->getContentClass()->getLabel() . "/" . $sContentClassName . ")"; //$sComment = " \n*\n* ".$sComment."\n*\n "; $sCommentSeparator = "\n**************************************************\n"; $sComment = " \n\n" . $sCommentSeparator . $sComment . $sCommentSeparator . " "; $oCommentNode = $oDoc->createComment($sComment); $oPageGroupNode->appendChild($oCommentNode); //end comment //using a CDATA node to preserve source breaklines :-) //$sPageContent = $oPage->getContent()->toXml(); //$oPageContentNode = $oDoc->createCDATASection($sPageContent); $oContentNodeDoc = $oPage->getContent()->toXml()->documentElement; //here we got a <doc> node $oPageContentNodeDoc = $oDoc->importNode($oContentNodeDoc, true); //<anwpage name="" lang="" time=""> $oPageNode = $oDoc->createElement(self::XMLTAG_PAGE); $oPageNode->setAttribute("name", AnwXml::xmlFileAttributeEncode($oPage->getName())); $oPageNode->setAttribute("lang", AnwXml::xmlFileAttributeEncode($oPage->getLang())); $oPageNode->setAttribute("time", $oPage->getTime()); //we need to do this to squeeze the unwanted <doc> node in //WARNING - special loop ! childs are getting modified... while ($oChildNode = $oPageContentNodeDoc->childNodes->item(0)) { $oPageNode->appendChild($oChildNode); } $oPageGroupNode->appendChild($oPageNode); } $oRootNode->appendChild($oPageGroupNode); } $sReturn = AnwUtils::xmlDumpNode($oRootNode); // even if final XML structure may be broken due to undeclared namespaces used in content, // we let raw content as it is for better compatibility in later versions. // $sReturn = AnwXml::prepareXmlValueToXml($sReturn); return $sReturn; }
private function selectTimezone($nSelectedTimezone) { $HTML = ""; $anTimezones = AnwUsers::getTimezones(); foreach ($anTimezones as $nTimezone) { $sSelected = $nSelectedTimezone == $nTimezone ? ' selected="selected"' : ''; $sTimezoneName = Anwi18n::timezoneName($nTimezone); $sTimezoneTime = Anwi18n::dateTime(time(), false, $nTimezone); $HTML .= <<<EOF \t\t\t\t<option value="{$nTimezone}"{$sSelected}>({$sTimezoneName}) {$sTimezoneTime}</option> EOF; } return $HTML; }
function showHtml($aoChanges, $amAllChangeTypes, $amDisplayChangeTypes, $asAllLangs, $asDisplayLangs, $asAllClasses, $asDisplayClasses, $nStartPrev, $nStartNext, $sTitle, $bGrouped, $oPage, $oPageGroup) { $this->out .= $this->tpl()->lastchangesHeader($sTitle); $sUrl = AnwEnv::_SERVER('REQUEST_URI'); $sUrl = preg_replace("/&s=([0-9]*)/", "", $sUrl); //rss link $sRssLink = $sUrl; $sRssLink .= '&feed=rss2'; //without start $this->head($this->tpl()->headRss($sRssLink)); $this->out .= $this->tpl()->filterBefore($this->linkMe()); $nPageId = $oPage ? $oPage->getId() : null; $nPageGroupId = $oPageGroup ? $oPageGroup->getId() : null; $bShowHistoryColumn = $oPage ? false : true; //disable filters if a page is selected if (!$nPageId) { //filter lang $this->out .= $this->tpl()->filterLangs($asAllLangs, $asDisplayLangs); } if (!$nPageId && !$nPageGroupId) { //filter contentclass $this->out .= $this->tpl()->filterClass($asAllClasses, $asDisplayClasses); } //filter changes types $this->out .= $this->tpl()->filterChangeTypes($amAllChangeTypes, $amDisplayChangeTypes); //display mode $sHistoryPageGroupLink = false; if ($oPage && AnwCurrentSession::isActionGlobalAllowed($this->getName())) { $sHistoryPageGroupLink = AnwEnv::_SERVER('REQUEST_URI'); $sHistoryPageGroupLink = preg_replace("\$&page=([0-9]*)\$", "", $sHistoryPageGroupLink); $sHistoryPageGroupLink = preg_replace("\$&pagegroup=([0-9]*)\$", "", $sHistoryPageGroupLink); $sHistoryPageGroupLink .= '&pagegroup=' . $oPage->getPageGroup()->getId(); } $this->out .= $this->tpl()->filterAfter($bGrouped, $nPageId, $nPageGroupId, $sRssLink, $sHistoryPageGroupLink); //nav $sLatestLink = ""; $sPrevLink = ""; if ($nStartPrev >= 0) { $sPrevLink = $sUrl . '&s=' . $nStartPrev; if ($nStartPrev > 0) { $sLatestLink = $sUrl . '&s=0'; } } $sNextLink = $sUrl . '&s=' . $nStartNext; $this->out .= $this->tpl()->nav($sLatestLink, $sPrevLink, $sNextLink, $bShowHistoryColumn); foreach ($aoChanges as $i => $oChange) { $sType = AnwChange::changeTypei18n($oChange->getType()); //links $sLnkPage = '<span class="pageid">#' . $oChange->getPageId() . '</span>'; $sLnkDiff = '-'; if ($oChange->activePageExists()) { $sLnkPage = $oChange->getActivePage()->link(); //active link, if it exists } //diffs link if ($oChange->isGlobalAndViewActionAllowed('diff')) { if ($oChange->isDiffAvailable()) { $sImgDiff = AnwUtils::xQuote(AnwUtils::pathImg("diff.gif")); $sAltDiff = AnwUtils::xQuote(self::g_("change_diff_link")); $sLnkDiff = AnwUtils::xQuote(AnwUtils::alink("diff", array("page" => $oChange->getPageId(), "revto" => $oChange->getChangeId()))); $sLnkDiff = <<<EOF <a href="{$sLnkDiff}" title="{$sAltDiff}"><img src="{$sImgDiff}" alt="{$sAltDiff}"/></a> EOF; } } //history link $sLnkHistory = false; if ($bShowHistoryColumn) { $sLnkHistory = " - "; if ($oChange->isActionAllowed('history')) { $sImgHistory = AnwUtils::xQuote(AnwUtils::pathImg("history.gif")); $sAltHistory = AnwUtils::xQuote($this->t_("change_history_link")); $sLnkHistory = AnwUtils::xQuote(AnwUtils::alink("lastchanges", array("page" => $oChange->getPageId()))); $sLnkHistory = <<<EOF <a href="{$sLnkHistory}" title="{$sAltHistory}"><img src="{$sImgHistory}" alt="{$sAltHistory}"/></a> EOF; } } //revert link $sLnkRevert = " - "; if ($oChange->isGlobalAndViewActionAllowed('revert')) { if ($oChange->isRevertAvailable()) { $sImgRevert = AnwUtils::xQuote(AnwUtils::pathImg("revert.gif")); $sAltRevert = AnwUtils::xQuote(self::t_("change_revert_link")); $sLnkRevert = AnwUtils::xQuote(AnwUtils::alink("revert", array("page" => $oChange->getPageId(), "revto" => $oChange->getChangeId()))); //we pass pageid instead of pagegroupid for better performances... $sLnkRevert = <<<EOF <a href="{$sLnkRevert}" title="{$sAltRevert}"><img src="{$sImgRevert}" alt="{$sAltRevert}"/></a> EOF; } } //output $this->out .= $this->tpl()->lastchangesLine(Anwi18n::dateTime($oChange->getTime()), $sType, $oChange->getComment(), $oChange->getInfo(), $oChange->getUser()->getDisplayName(), $sLnkPage, $sLnkDiff, $sLnkHistory, $sLnkRevert, $oChange->getPageName(), $oChange->getPageLang()); } $this->out .= $this->tpl()->lastchangesFooter(); }
protected function showCurrentPage() { //prepare content for display try { $oOutputHtml = $this->getoPage()->toHtml(); } catch (AnwException $e) { $oOutputHtml = new AnwOutputHtml($this->getoPage()); $oOutputHtml->setBody(self::g_("err_rendercontent"), false); AnwDebug::reportError($e); } $this->head($oOutputHtml->runHead()); $this->title = $oOutputHtml->runTitle(); $sBody = $oOutputHtml->runBody(); //if the translation is not complete, display a notice if (!$this->getoPage()->isTranslated() && $this->getoPage()->isActionAllowed('translate')) { $sNotice = $this->t_("local_notice_incomplete", array("lnkopen" => '<a href="' . AnwUtils::link($this->getoPage(), "translate") . '">', "lnkclose" => '</a>')); $this->out .= $this->tpl()->drawNotice($sNotice); } //page translations $aoTranslations = array(); $aoPages = $this->getoPage()->getPageGroup()->getPages(); foreach ($aoPages as $oPage) { if ($oPage->isActionAllowed('view')) { $bCurrent = $oPage->getName() == $this->getoPage()->getName(); $bTranslatedPercentEnough = $oPage->getTranslatedPercent() >= self::globalCfgViewUntranslatedMinpercent() ? true : false; $aoTranslations[] = array('current' => $bCurrent, 'page' => $oPage, 'online' => $bTranslatedPercentEnough); } } //display page content $this->out .= $this->tpl()->viewPage(self::g_("local_html_dir", array(), AnwAction::getActionLang()), AnwUtils::cssViewContent($this->getoPage()), $this->title, $sBody, str_replace(',', ' ', Anwi18n::dateTime($this->getoPage()->getTime(), AnwAction::getActionLang())), $aoTranslations); }
protected function doLockReply($nLockType) { $sStatus = 'ERROR'; $sMessage = ''; $nRemainingTime = 0; try { switch ($nLockType) { case AnwLock::TYPE_PAGEONLY: $sTranslation = "lockinfo_pageonly"; break; case AnwLock::TYPE_PAGEGROUP: $sTranslation = "lockinfo_pagegroup"; break; default: throw new AnwUnexpectedException("unknown lockactionid"); break; } $oLock = $this->lockPageForEdition($nLockType); $nExpirationTime = $oLock->getLockTimeLast() + self::globalCfgLocksExpiry(); $nRemainingTime = $nExpirationTime - time(); $sMessage = self::g_($sTranslation, array("pagename" => '<i>' . $oLock->getLockPage()->getName() . '</i>', "locktime" => Anwi18n::dateTime($oLock->getLockTime()), "remainingtime" => '<span id="lockinfo_remainingtime"></span>')); if ($nRemainingTime <= 0) { throw new AnwLockException(); } $sStatus = 'OK'; } catch (AnwException $e) { $sStatus = 'ERROR'; } $this->out = '<status>' . $sStatus . '</status>'; $this->out .= '<message><![CDATA[' . $sMessage . ']]></message>'; $this->out .= '<remainingtime>' . $nRemainingTime . '</remainingtime>'; $this->printOutputAjax(); }
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; } }
function getInfo($bFormat = true) { if ($this->getType() == self::TYPE_PAGE_REVERT) { $sDateTime = Anwi18n::dateTime($this->sInfo); return AnwComponent::g_("changes_revert_info", array('datetime' => $sDateTime)); } else { if ($this->getType() == self::TYPE_PAGE_EDITION_DEPLOY) { $sPageName = $this->sInfo; return AnwComponent::g_("changes_edition_deploy_info", array('pagename' => AnwUtils::xText($sPageName))); } } return AnwUtils::xText($this->sInfo); }