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 lastchangesLine($sTime, $sType, $sComment, $sInfo, $sUserLogin, $sLnkPage, $sLnkDiff, $sLnkHistory = false, $sLnkRevert, $sPageName, $sPageLang) { static $n = 0; $n = $n % 2 + 1; $sCss = 'line' . $n; $sImgFlag = Anwi18n::imgFlag($sPageLang); $sInfo = $sInfo == "" ? "" : "<div class=\"changeinfo\">" . $sInfo . "</div>"; // info and comment are already escaped $HTML = <<<EOF \t\t<tr class="{$this->xQuote($sCss)}"> \t\t\t<td class="changetime">{$sTime}</td> \t\t\t<td class="changepageoriginal">{$sImgFlag}{$this->xText($sPageName)}</td> \t\t\t<td class="changetype">{$sType}{$sInfo}</td> \t\t\t<td class="changecomment">{$sComment}</td> \t\t\t<td class="changelogin">{$this->xText($sUserLogin)}</td> \t\t\t<td class="changepage">{$sLnkPage}</td> \t\t\t<td class="changediff">{$sLnkDiff}</td> EOF; if ($sLnkHistory) { $HTML .= <<<EOF \t\t\t<td class="changehistory">{$sLnkHistory}</td> EOF; } $HTML .= <<<EOF \t\t\t<td class="changerevert">{$sLnkRevert}</td> \t\t</tr> EOF; return $HTML; }
function init() { parent::init(); $oContentField = new AnwContentFieldSettings_select(self::FIELD_LANG_DEFAULT); $asEnumValues = array(); $asLangs = AnwComponent::globalCfgLangs(); foreach ($asLangs as $sLang) { $sLangName = $sLang . " - " . Anwi18n::langName($sLang); $asEnumValues[$sLang] = $sLangName; } $oContentField->setEnumValues($asEnumValues); $this->addContentField($oContentField); $oContentField = new AnwContentFieldSettings_string(self::FIELD_LANGS); $oContentField->addAllowedPattern("!^.{" . Anwi18n::MINLEN_LANG . "," . Anwi18n::MAXLEN_LANG . "}\$!"); $oContentMultiplicity = new AnwContentMultiplicity_multiple(); $oContentField->setMultiplicity($oContentMultiplicity); $this->addContentField($oContentField); $oContentField = new AnwContentFieldSettings_select(self::FIELD_TIMEZONE_DEFAULT); $anEnumValues = array(); $anTimezones = AnwUsers::getTimezones(); foreach ($anTimezones as $nTimezone) { $sTimezoneName = Anwi18n::timezoneName($nTimezone); $anEnumValues[$nTimezone] = $sTimezoneName; } $oContentField->setEnumValues($anEnumValues); $this->addContentField($oContentField); }
function toHtml($oContent, $oPage) { $oOutputHtml = new AnwOutputHtml($oPage); $oOutputHtml->setTitle($oContent->getContentFieldValue(self::FIELD_TITLE)); $sNewsCategoryTitle = $oContent->getContentFieldValue(self::FIELD_TITLE); $sNewsCategoryIntro = $oContent->getContentFieldValue(self::FIELD_DESCRIPTION); //try{$aoNewsList = $this->getNewsList($oPage);}catch(Exception $e){print_r($e);} //render news list $aoNewsList = self::getNewsList($oPage); $sHtmlNewsList = ""; if (count($aoNewsList) > 0) { $sHtmlNewsList .= $this->tpl()->newsListStart(); foreach ($aoNewsList as $oNewsPage) { $oNewsContent = $oNewsPage->getContent(); $sNewsTitle = $oNewsContent->getContentFieldValue(AnwContentClassPageDefault_news::FIELD_TITLE); $sNewsIntro = $oNewsContent->getContentFieldValue(AnwContentClassPageDefault_news::FIELD_INTRO); $sNewsDate = Anwi18n::date(AnwUtils::dateToTime($oNewsContent->getContentFieldValue(AnwContentClassPageDefault_news::FIELD_DATE)), $oPage->getLang()); $sNewsUrl = AnwUtils::link($oNewsPage); $sHtmlNewsList .= $this->tpl()->newsListItem($sNewsTitle, $sNewsIntro, $sNewsDate, $sNewsUrl, $oNewsPage->getLang()); } $sHtmlNewsList .= $this->tpl()->newsListEnd(); } unset($aoNewsList); //render the newscategory $sHtmlBody = $this->tpl()->showNewscategory($sNewsCategoryTitle, $sNewsCategoryIntro, $sHtmlNewsList, $oPage->getLang()); $oOutputHtml->setBody($sHtmlBody); return $oOutputHtml; }
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 availableTranslationsRow($oPage) { $sName = $oPage->getName(); $sUrl = AnwUtils::link($oPage); $sStyle = "background:url('" . Anwi18n::srcFlag($oPage->getLang()) . "') no-repeat left;"; $HTML = "<a href=\"" . $this->xQuote($sUrl) . "\" style=\"{$sStyle}\">" . $this->xText($sName) . "</a>"; return $HTML; }
function newTranslationCreated($sTranslationLang, $sTranslationLink) { $sImgFlag = Anwi18n::imgFlag($sTranslationLang); $HTML = <<<EOF \t<li>{$sTranslationLink}</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; }
function rowProcessDuplication_failed($sPageName, $sPageLang, $asNotices) { $sNotices = ""; foreach ($asNotices as $sNotice) { $sNotices .= $this->drawNoticeIcon($sNotice) . ' '; } $sImgFlag = Anwi18n::imgFlag($sPageLang); $HTML = <<<EOF \t\t<li>{$sImgFlag}{$this->xText($sPageName)} : <span style="color:red">{$this->t_('process_fail')}</span> {$sNotices}</li> EOF; return $HTML; }
function newTranslationRow($sLang, $sDefaultPageNameValue, $sInputName, $sCheckBoxName) { $sImgFlag = Anwi18n::imgFlag($sLang); $sSrcFlag = Anwi18n::srcFlag($sLang); $HTML = <<<EOF \t\t<input type="checkbox" name="{$this->xQuote($sCheckBoxName)}" value="1" id="{$this->xQuote($sCheckBoxName)}" class="newtranslation_lang" style="float:left"/> \t\t<label for="{$this->xQuote($sCheckBoxName)}" style="width:100px; float:left;"> \t\t\t{$sImgFlag} {$sLang} : \t\t</label> \t\t<input type="text" name="{$this->xQuote($sInputName)}" value="{$this->xQuote($sDefaultPageNameValue)}" class="intext inpagename" style="background-image:url('{$sSrcFlag}')"/><br/> EOF; return $HTML; }
function editForm($formaction, $sContentHtmlDir, $sPagename, $sContentFieldsHtml, $sLang, $sContentClassName, $htmldrafts, $nDraftTime = false, $summary, $bShowCaptcha, $error) { $sFlag = Anwi18n::imgFlag($sLang); $HTML = <<<EOF \t<h1>{$this->t_('title', array('pagename' => '<i>' . $this->xText($sPagename) . '</i>'))} {$sFlag} <span style="font-size:0.7em">{$this->xText($sContentClassName)}</span></h1> \t{$this->errorList($error)} \t<form action="{$this->xQuote($formaction)}" method="post" id="edit_form" class="editcontent"> {$sContentFieldsHtml} \t\t<div style="height:30px"></div> \t\t<input type="hidden" name="posted" value="1" /> EOF; // <input type="hidden" name="draft" value="{$this->xQuote($nDraftTime)}" /> if ($bShowCaptcha) { $HTML .= <<<EOF {$this->showCaptcha()}<br/> EOF; } $sAbortLabel = self::g_("in_abort"); $HTML .= <<<EOF \t\t{$this->g_('in_comment')} <input type="text" name="comment" class="intext incomment" id="comment" size="50" value="{$this->xQuote($summary)}" /> \t\t<input type="submit" name="publish" class="insubmit" value="{$this->xQuote($this->t_("publish"))}" /> \t\t<input type="submit" name="preview" class="inbutton" value="{$this->xQuote($this->t_("preview"))}" /> \t\t<input type="submit" name="abort" value="{$this->xQuote($sAbortLabel)}" class="inabort"/> \t\t<br/> EOF; /* {$this->t_('drafts')} <input type="submit" name="savenewdraft" class="insubmit" value="{$this->t_('savenewdraft')}" /> if ($nDraftTime) { $HTML .= <<<EOF <input type="submit" name="updatedraft" class="insubmit" value="{$this->t_('updatedraft')}" /> <input type="submit" name="discarddraft" class="inabort" value="{$this->t_('discarddraft')}" onclick="return confirm('{$this->t_('discarddraft_alert')}');" /> EOF; }*/ $HTML .= <<<EOF \t</form> \t \t{$htmldrafts} EOF; return $HTML; }
protected function initializeAdditional() { $sInitLog = ""; //----------------------------- // create default home page //----------------------------- $oContentClass = AnwContentClasses::getContentClass('page'); $sPageName = AnwComponent::globalCfgHomePage(); $sPageLang = AnwComponent::globalCfgLangDefault(); $sChangeComment = "Installation assistant"; $oContent = new AnwContentPage($oContentClass); $sHomeTitle = $this->t_("local_homepage_title", array(), $sPageLang); $sHomeHead = $this->tpl()->homePageHead($sPageLang); $sHomeBody = $this->tpl()->homePageBody($sPageLang, ANWIKI_WEBSITE); $oContent->setContentFieldValues(AnwIContentClassPageDefault_page::FIELD_TITLE, array($sHomeTitle)); $oContent->setContentFieldValues(AnwIContentClassPageDefault_page::FIELD_HEAD, array($sHomeHead)); $oContent->setContentFieldValues(AnwIContentClassPageDefault_page::FIELD_BODY, array($sHomeBody)); $oPage = AnwPage::createNewPage($oContentClass, $sPageName, $sPageLang, $sChangeComment, $oContent); $sInitLog .= $this->t_("initlog_pagecreated", array('pagename' => $sPageName)) . '<br/>'; //----------------------------- // create default menu //----------------------------- $oContentClass = AnwContentClasses::getContentClass('menu'); $sPageName = 'en/_include/menu'; //TODO $sPageLang = Anwi18n::langExists('en') ? 'en' : AnwComponent::globalCfgLangDefault(); //TODO $sChangeComment = "Installation assistant"; $oContent = new AnwContentPage($oContentClass); //menu title $sMenuTitle = $this->t_("local_menu_title", array(), $sPageLang); $oContent->setContentFieldValues(AnwIContentClassPageDefault_menu::FIELD_TITLE, array($sMenuTitle)); //items $oContentFieldItems = $oContentClass->getContentField(AnwIContentClassPageDefault_menu::FIELD_ITEMS); $oSubContentItem = new AnwContentPage($oContentFieldItems); //main link $oContentFieldMainLink = $oContentFieldItems->getContentField(AnwIContentFieldPage_menu_menuItem::FIELD_MAINLINK); $oSubContentMainLink = new AnwContentPage($oContentFieldMainLink); $sMainLinkTitle = $this->t_("local_menu_mainlink_title", array(), $sPageLang); $oSubContentMainLink->setContentFieldValues(AnwIPage_link::FIELD_TITLE, array($sMainLinkTitle)); $oSubContentMainLink->setContentFieldValues(AnwIPage_link::FIELD_URL, array(AnwComponent::globalCfgHomePage())); $oSubContentMainLink->setContentFieldValues(AnwIPage_link::FIELD_TARGET, array(AnwIPage_link::TARGET_SELF)); $oSubContentItem->setSubContents(AnwIContentFieldPage_menu_menuItem::FIELD_MAINLINK, array($oSubContentMainLink)); $oContent->setSubContents(AnwIContentClassPageDefault_menu::FIELD_ITEMS, array($oSubContentItem)); $oPage = AnwPage::createNewPage($oContentClass, $sPageName, $sPageLang, $sChangeComment, $oContent); $sInitLog .= $this->t_("initlog_pagecreated", array('pagename' => $sPageName)) . '<br/>'; return $sInitLog; }
function renameForm($sNewPageName, $sLang, $sComment, $sPagename, $formaction, $aoPageGroupsLinked, $sError) { $sSrcFlagTr = Anwi18n::srcFlag($sLang); $sSubmitLabel = self::g_("in_submit"); $sAbortLabel = self::g_("in_abort"); $HTML = <<<EOF \t<h1>{$this->t_('title', array('pagename' => '<i>' . $this->xText($sPagename) . '</i>'))}</h1> \t{$this->errorList($sError)} \t<form action="{$this->xQuote($formaction)}" method="post" id="rename_form"> \t\t{$this->g_('in_pagename')} <input type="text" name="newname" class="intext inpagename" id="newname" style="background-image:url('{$sSrcFlagTr}')" value="{$this->xQuote($sNewPageName)}"/><br/> \t\t{$this->g_('in_comment')} <input type="text" name="comment" class="intext incomment" id="comment" value="{$this->xQuote($sComment)}"/><br/> \t\t \t\t \t\t<input type="submit" name="rename" class="insubmit" value="{$this->xQuote($sSubmitLabel)}" /> \t\t<input type="submit" name="abort" class="inabort" value="{$this->xQuote($sAbortLabel)}" /> EOF; if (count($aoPageGroupsLinked) > 0) { $HTML .= <<<EOF \t\t<br/><input type="checkbox" name="updatelinks" value="1" checked="checked" id="updatelinks"/><label for="updatelinks">{$this->t_('rename_updatelinks')}</label><br/> EOF; } $HTML .= <<<EOF \t</form> EOF; if (count($aoPageGroupsLinked) > 0) { $HTML .= <<<EOF \t\t<p>{$this->t_('rename_links')}</p> \t\t<ul> EOF; foreach ($aoPageGroupsLinked as $oPageGroupLinked) { $aoPagesLinked = $oPageGroupLinked->getPages(); foreach ($aoPagesLinked as $oPageLinked) { $HTML .= <<<EOF \t\t\t<li>{$oPageLinked->link()}</li> EOF; } } $HTML .= <<<EOF \t\t</ul> EOF; } return $HTML; }
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(); }
function translationRowCurrent($sLang, $sPageName) { $sImgFlag = Anwi18n::imgFlag($sLang); $sSrcFlag = Anwi18n::srcFlag($sLang); $HTML = <<<EOF \t\t<div class="div_translation"> \t\t\t<input type="checkbox" name="lang_current" id="lang_current" value="null" style="float:left" checked="checked" disabled="disabled"/> \t\t\t<label for="lang_current" style="width:100px; float:left;"> \t\t\t\t{$sImgFlag} {$sLang} : \t\t\t</label> \t\t\t<input type="text" name="pagename_current" value="{$this->xQuote($sPageName)}" class="intext inpagename" style="background-image:url('{$sSrcFlag}')" disabled="disabled"/><br/> \t\t</div> EOF; return $HTML; }
function changeLangForm($sLang, $sComment, $selectlang, $sPagename, $formaction, $sError) { $sFlag = Anwi18n::imgFlag($sLang); $sSubmitLabel = self::g_("in_submit"); $sAbortLabel = self::g_("in_abort"); $HTML = <<<EOF \t<h1>{$this->t_('title', array("pagename" => "<i>" . $this->xText($sPagename) . "</i>"))} {$sFlag}</h1> \t{$this->errorList($sError)} \t<form action="{$this->xQuote($formaction)}" method="post" id="changelang_form"> \t\t{$this->g_('in_pagelang')} {$selectlang}<br/> \t\t{$this->g_('in_comment')} <input type="text" name="comment" id="comment" class="intext incomment" value="{$this->xQuote($sComment)}"/><br/> \t\t<input type="submit" name="changelang" class="insubmit" value="{$this->xQuote($sSubmitLabel)}" /> \t\t<input type="submit" name="abort" class="inabort" value="{$this->xQuote($sAbortLabel)}"/> \t</form> EOF; return $HTML; }
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 init() { parent::init(); //lang policy $oContentField = new AnwContentFieldSettings_radio(self::FIELD_POLICY); $asEnumValues = array(self::POLICY_ALL_LANGS => $this->getComponent()->t_contentfieldsettings("policy_all_langs"), self::POLICY_SELECTED_LANGS => $this->getComponent()->t_contentfieldsettings("policy_selected_langs")); $oContentField->setEnumValues($asEnumValues); $oContentField->setDefaultValue(self::POLICY_ALL_LANGS); $this->addContentField($oContentField); //langs selection $oContentField = new AnwContentFieldSettings_checkboxGroup(self::FIELD_LANGS); $asLangs = AnwComponent::globalCfgLangs(); $asEnumValues = array(); foreach ($asLangs as $sLang) { $sLangName = $sLang . " - " . Anwi18n::langName($sLang); $asEnumValues[$sLang] = $sLangName; } $oContentField->setEnumValues($asEnumValues); $oMultiplicity = new AnwContentMultiplicity_multiple(); $oMultiplicity->setSortable(false); $oContentField->setMultiplicity($oMultiplicity); $this->addContentField($oContentField); }
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(); } }
static function rebuildSession($oUser, $bResume, $sLang, $nTimezone, $sId, $nTimeStart, $nTimeSeen, $nTimeAuth = 0) { $oSession = new AnwSession(); $oSession->oUser = $oUser; $oSession->bResume = $bResume; if (!Anwi18n::isValidLang($sLang)) { $sLang = AnwComponent::globalCfgLangDefault(); } $oSession->sLang = $sLang; if ($oUser->exists()) { $oSession->bLoggedIn = true; } else { $oSession->bLoggedIn = false; } $oSession->sId = $sId; if (!AnwUsers::isValidTimezone($nTimezone)) { $nTimezone = AnwComponent::globalCfgTimezoneDefault(); } $oSession->nTimezone = $nTimezone; $oSession->nTimeStart = $nTimeStart; $oSession->nTimeSeen = $nTimeSeen; $oSession->nTimeAuth = $nTimeAuth; return $oSession; }
function loadContentFieldsSettings() { //load translations try { Anwi18n::loadTranslationsFromPath($this->getComponentName() . '-settings', $this->getMyComponentDir() . ANWDIR_LANG, $this->isAddon(), $this->getComponentName() . '-settings'); } catch (AnwException $e) { } }
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 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(); }
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(); }
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(); }
function saveEdition() { try { //make sure file is writable $sConfigFileOverride = $this->getEditableComponent()->getConfigurableFileOverride(); if (!file_exists($sConfigFileOverride)) { try { AnwUtils::file_put_contents($sConfigFileOverride, ""); } catch (AnwException $e) { } } if (!is_writable($sConfigFileOverride)) { $sError = Anwi18n::g_err_need_write_file($sConfigFileOverride); throw new AnwStructuredContentEditionFormException($sError); } //update content from post $this->getRender(true); //check errors if ($this->hasErrors()) { throw new AnwInvalidContentException(); } //save $this->getContent()->writeSettingsOverride(); } catch (AnwInvalidContentException $e) { $sError = AnwComponent::g_("err_contentinvalid"); throw new AnwStructuredContentEditionFormException($sError); } catch (AnwUnexpectedException $e) { $sError = AnwComponent::g_("err_ex_unexpected_p"); $nErrorNumber = AnwDebug::reportError($e); if ($nErrorNumber) { $sError .= '<br/>' . $this->g_("err_ex_report", array("errornumber" => $nErrorNumber)); } throw new AnwStructuredContentEditionFormException($sError); } }
function translateform($sContentHtmlDir, $sCss, $sReferenceHtmlDir, $formaction, $content, $nRev, $langfrom, $langto, $selectPageRef) { $sImgFlagFrom = Anwi18n::imgFlag($langfrom); $sImgFlagTo = Anwi18n::imgFlag($langto); $sAbortLabel = self::g_("in_abort"); $sTranslateSaveLabel = $this->t_("translate_button_save"); $sTranslatePreviousLabel = $this->t_("translate_button_previous"); $sTranslateNextLabel = $this->t_("translate_button_next"); $sTranslateRevertLabel = $this->t_("translate_button_revert"); $sTranslateCloseLabel = $this->t_("translate_button_closepanel"); $sTranslateUndoAllLabel = $this->t_("translate_button_undoneall"); $sTranslateDoneAllLabel = $this->t_("translate_button_doneall"); $sTranslateRefreshLabel = $this->t_("translate_button_refresh"); $HTML = <<<EOF \t<div class="explain"> \t\t{$this->t_('translate_explain')} \t\t<ol> \t\t\t<li>{$this->t_('translate_explain_1', array('selectref' => $selectPageRef))}</li> \t\t\t<li>{$this->t_('translate_explain_2')}</li> \t\t\t<li>{$this->t_('translate_explain_3')}</li> \t\t\t<li>{$this->t_('translate_explain_4')}</li> \t\t</ol> \t\t<input type="button" onclick="oTranslator.save();return false;" class="insubmit" value="{$this->xQuote($sTranslateSaveLabel)}"/> \t\t<input type="button" onclick="window.location=window.location+'&abort=1'" class="inabort" value="{$this->xQuote($sAbortLabel)}"/> \t\t \t</div> \t \t<form action="{$this->xQuote($formaction)}" method="post" id="translateform"> \t\t<input type="hidden" name="save" value="1"/> \t\t<input type="hidden" name="rev" value="{$this->xQuote($nRev)}"/> \t\t<div id="panel"> \t\t\t<fieldset id="panel_current"> \t\t\t\t<legend>{$this->t_('translate_panel_currentarea')}</legend> \t\t\t\t<div style="text-align:center"> \t\t\t\t\t<input type="button" onclick="oTranslator.translatePrevious();return false;" class="inbutton" value="{$this->xQuote($sTranslatePreviousLabel)}"/> \t\t\t\t\t<input type="button" onclick="oTranslator.translateNext();return false;" class="inbutton" value="{$this->xQuote($sTranslateNextLabel)}"/><br/> \t\t\t\t\t<input type="checkbox" id="panel_skiptranslated" checked="checked"/><label for="panel_skiptranslated" title="will move to the next untranslated string">{$this->t_('translate_chk_skiptranslated')}</label> \t\t\t\t</div> \t\t\t\t \t\t\t\t{$sImgFlagFrom} {$this->t_('translate_original_value')}<br/> \t\t\t\t<div id="panel_original" dir="{$this->xQuote($sReferenceHtmlDir)}"></div><br/> \t\t\t\t{$sImgFlagTo} {$this->t_('translate_translated_value')}<br/> \t\t\t\t<textarea id="panel_translate" rows="2" dir="{$this->xQuote($sContentHtmlDir)}"></textarea><br/> \t\t\t\t<input type="checkbox" id="panel_done"/><label for="panel_done">{$this->t_('translate_chk_translated')}</label><br/> \t\t\t\t<div style="display:none"><input type="checkbox" id="panel_apply"/><label for="panel_apply">{$this->t_('translate_chk_apply')}</label><br/></div> \t\t\t\t<input type="checkbox" id="panel_autotranslate"/><label for="panel_autotranslate">{$this->t_('translate_chk_autotranslate')}</label> \t\t\t \t\t\t\t<div class="panel_buttons"> \t\t\t\t\t<input type="button" onclick="oTranslator.revert();return false;" class="inabort" value="{$this->xQuote($sTranslateRevertLabel)}"/> \t\t\t\t\t<input type="button" onclick="oTranslator.save();return false;" class="insubmit" value="{$this->xQuote($sTranslateSaveLabel)}"/> \t\t\t\t\t<input type="button" onclick="window.location=window.location+'&abort=1'" class="inabort" value="{$this->xQuote($sAbortLabel)}"/> \t\t\t\t\t<input type="button" onclick="oTranslator.hidePanel();return false;" class="inbutton" value="{$this->xQuote($sTranslateCloseLabel)}"/> \t\t\t\t</div> \t\t\t</fieldset> \t\t\t<fieldset id="panel_global"> \t\t\t\t<legend>{$this->t_('translate_panel_globalarea')}</legend> \t\t\t\t<div class="panel_buttons"> \t\t\t\t\t<input type="button" onclick="oTranslator.undoneall();return false;" class="inabort" value="{$this->xQuote($sTranslateUndoAllLabel)}"/> \t\t\t\t\t<input type="button" onclick="oTranslator.doneall();return false;" class="insubmit" value="{$this->xQuote($sTranslateDoneAllLabel)}"/> \t\t\t\t\t<input type="button" onclick="window.location=window.location" class="inabort" value="{$this->xQuote($sTranslateRefreshLabel)}"/> \t\t\t\t</div> \t\t\t</fieldset> \t\t\t<fieldset id="panel_shortcuts"> \t\t\t\t<legend>{$this->t_('translate_panel_shortcuts')}</legend> \t\t\t\t<label>CTRL+Enter</label>{$this->t_('translate_shortcut_next')}<br/> \t\t\t\t<label>CTRL+Shift+Enter</label>{$this->t_('translate_shortcut_nextandmark')}<br/> \t\t\t</fieldset> \t\t</div> \t\t<div id="translator"></div> \t</form> \t \t<div class="{$this->xQuote($sCss)}"> \t{$content} \t</div> EOF; return $HTML; }
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; }
static function rebuildUser($nId, $sLogin, $sDisplayName, $sEmail, $sLang, $nTimezone) { $oUser = new AnwUserById($nId); if (!AnwUsers::isValidLogin($sLogin)) { throw new AnwBadLoginException(); } $oUser->sLogin = $sLogin; if (!AnwUsers::isValidDisplayName($sDisplayName)) { throw new AnwBadDisplayNameException(); } $oUser->sDisplayName = $sDisplayName; if (!AnwUsers::isValidEmail($sEmail)) { throw new AnwBadEmailException(); } $oUser->sEmail = $sEmail; if (!Anwi18n::isValidLang($sLang)) { $sLang = AnwComponent::globalCfgLangDefault(); } $oUser->sLang = $sLang; if (!AnwUsers::isValidTimezone($nTimezone)) { $nTimezone = AnwComponent::globalCfgTimezoneDefault(); } $oUser->nTimezone = $nTimezone; $oUser->bExists = true; $oUser->bInfoLoaded = true; return $oUser; }
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); }