Пример #1
0
 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);
 }
Пример #2
0
 protected function previewForm()
 {
     try {
         //check captcha
         if ($this->needsCaptcha()) {
             $this->checkCaptcha();
         }
         //update content from post
         $oEditContent = $this->getEditionForm()->updateContentFromEdition();
         //show again edit form on the top
         $this->editForm(AnwEnv::_POST("comment"), AnwEnv::_GET("draft"));
         //render preview
         try {
             $oHtml = $oEditContent->toHtml($this->getoPage());
             $oHtml->disableCaching();
             $sPreview = $oHtml->runHead() . $oHtml->runBody();
             $this->out .= $this->tpl()->preview($sPreview, AnwUtils::cssViewContent($this->getoPage()));
             $this->headJsOnload($this->tpl()->preview_jsOnload());
         } catch (AnwException $e) {
             $this->out .= 'error';
         }
     } catch (AnwStructuredContentEditionFormException $e) {
         $sError = $e->getMessage();
         $this->editForm(AnwEnv::_POST("comment"), AnwEnv::_POST("draft"), $sError);
     } catch (AnwBadCaptchaException $e) {
         $sError = $this->g_("err_badcaptcha");
         $this->editForm(AnwEnv::_POST("comment"), AnwEnv::_POST("draft"), $sError);
     }
 }
Пример #3
0
 private function translateForm($oPageRef)
 {
     //preload original lang
     $fOnValue = "preloadOriginalLang_onContentFieldValue";
     AnwUtils::runCallbacksOnTranslatableField($this, $oPageRef->getContent(), $fOnValue);
     //now, generate translation form
     $fOnValue = "genTranslateForm_onContentFieldValue";
     $this->genTranslateForm_html = "";
     AnwUtils::runCallbacksOnTranslatableField($this, $this->getoPage()->getContent(), $fOnValue);
     $sTranslateForm = $this->genTranslateForm_html;
     //TODO : translate PHPVARS
     //PageRef list selection
     $aoTranslations = $this->getoPage()->getPageGroup()->getPages();
     $HTMLPageRef = $this->tpl()->selectPageRef_open();
     foreach ($aoTranslations as $oTranslation) {
         if ($oTranslation->getName() == $oPageRef->getName()) {
             $HTMLPageRef .= $this->tpl()->selectPageRef_row_selected($oTranslation);
         } else {
             $HTMLPageRef .= $this->tpl()->selectPageRef_row($oTranslation);
         }
     }
     $HTMLPageRef .= $this->tpl()->selectPageRef_close();
     //output
     $sContentHtmlDir = self::g_("local_html_dir", array(), AnwAction::getActionLang());
     $sReferenceHtmlDir = self::g_("local_html_dir", array(), $oPageRef->getLang());
     $this->out .= $this->tpl()->translateform($sContentHtmlDir, AnwUtils::cssViewContent($oPageRef), $sReferenceHtmlDir, AnwUtils::link($this->getoPage(), "translate"), $sTranslateForm, $this->getoPage()->getChangeId(), $oPageRef->getLang(), $this->getoPage()->getLang(), $HTMLPageRef);
     $this->head($this->getJsSrcComponent("class_translator.js"));
     $this->headJsOnload($this->tpl()->jsOnload($this->hiddenTags, self::EMPTY_VALUE, $this->getEmptyValueSrc()));
     //lock
     $aaObservers = array();
     $aaObservers[] = array('INPUT' => 'panel_translate', 'EVENT' => 'keypress');
     $this->lockObserver(AnwLock::TYPE_PAGEONLY, "translateform", $aaObservers);
 }