public function renderFrontend()
 {
     $oCriteria = DocumentQuery::create()->filterByDocumentKind('image');
     if (!Session::getSession()->isAuthenticated()) {
         $oCriteria->filterByIsProtected(false);
     }
     if ($this->iCategoryId !== null) {
         $oCriteria->filterByDocumentCategoryId($this->iCategoryId);
     }
     $aDocuments = $oCriteria->find();
     $sTemplateName = 'helpers/gallery';
     try {
         $oListTemplate = new Template($sTemplateName);
         foreach ($aDocuments as $i => $oDocument) {
             $oItemTemplate = new Template($sTemplateName . DocumentListFrontendModule::LIST_ITEM_POSTFIX);
             $oItemTemplate->replaceIdentifier('model', 'Document');
             $oItemTemplate->replaceIdentifier('counter', $i + 1);
             $oDocument->renderListItem($oItemTemplate);
             $oListTemplate->replaceIdentifierMultiple('items', $oItemTemplate);
         }
     } catch (Exception $e) {
         $oListTemplate = new Template("", null, true);
     }
     return $oListTemplate;
 }
Example #2
0
 private function listInSidebar(Template $oTemplate)
 {
     $aWidgets = Module::listModulesByType(WidgetModule::getType());
     $oLinks = new Template(TemplateIdentifier::constructIdentifier('links'), null, true);
     foreach ($aWidgets as $sWidgetName => $aWidgetInfo) {
         $oLink = new Template('<a href="{{href}}">{{name}}</a><br />', null, true);
         $oLink->replaceIdentifier('href', LinkUtil::link(array($sWidgetName), get_class()));
         $oLink->replaceIdentifier('name', WidgetModule::getDisplayNameByName($sWidgetName));
         $oLinks->replaceIdentifierMultiple('links', $oLink);
     }
     $oTemplate->replaceIdentifierMultiple('sidebar_content', $oLinks);
 }
 /** send()
  * Description:
  * • This method is called when NewsletterMailer is instanciated
  * • All newsletter, sender and recipient info are ready
  *
  * @return boolean has_invalid email addresses
  */
 public function send()
 {
     // Get newsletter email main template and template body and css by template name
     $oEmailTemplate = new Template('main', array(DIRNAME_TEMPLATES, 'newsletter'));
     $oEmailTemplate->replaceIdentifier('newsletter_template_css', new Template("{$this->oNewsletter->getTemplateName()}.css", array(DIRNAME_TEMPLATES, 'newsletter')));
     // Parse links differently in text
     RichtextUtil::$USE_ABSOLUTE_LINKS = LinkUtil::isSSL();
     $oEMailContent = RichtextUtil::parseStorageForFrontendOutput(stream_get_contents($this->oNewsletter->getNewsletterBody()));
     RichtextUtil::$USE_ABSOLUTE_LINKS = null;
     // Replace add surrounding (body.tmpl) before content if exists. Template needs to contain a newsletter_content identifier
     if (ResourceFinder::findResource(array(DIRNAME_TEMPLATES, NewsletterDetailWidgetModule::NEWSLETTER_DIRNAME, "{$this->oNewsletter->getTemplateName()}.body.tmpl")) !== null) {
         $oEmailTemplate->replaceIdentifier('newsletter_content', new Template("{$this->oNewsletter->getTemplateName()}.body", array(DIRNAME_TEMPLATES, NewsletterDetailWidgetModule::NEWSLETTER_DIRNAME)), null, Template::LEAVE_IDENTIFIERS);
     }
     $oEmailTemplate->replaceIdentifier('newsletter_content', $oEMailContent, null, Template::LEAVE_IDENTIFIERS);
     $oEmailTemplate->replaceIdentifier('subject', $this->oNewsletter->getSubject());
     $oEmailTemplate->replaceIdentifier('language', $this->oNewsletter->getLanguageId());
     $oEmailTemplate->replaceIdentifier('newsletter_link', LinkUtil::absoluteLink($this->oNewsletter->getDisplayLink()));
     $oEmailTemplate->replaceIdentifier('newsletter_date', LocaleUtil::localizeDate(null, $this->oNewsletter->getLanguageId()));
     $oEmailTemplate->replaceIdentifier('newsletter_timestamp', time());
     // Process templates with each recipient, depending on whether recipient is object and object of Subscriber or string
     foreach ($this->aRecipients as $mRecipient) {
         $this->sendNewsletter($mRecipient, clone $oEmailTemplate);
     }
     return count($this->aInvalidEmails) === 0;
 }
 /**
  * @dataProvider validCalculations
  */
 public function testCalculations($sCalculation, $sExpectedResult = '0')
 {
     $oTemplate = new Template(TemplateIdentifier::constructIdentifier('doCalculation', $sCalculation), null, true);
     $oExpected = new Template(TemplateIdentifier::constructIdentifier('result'), null, true);
     $oExpected->replaceIdentifier('result', $sExpectedResult);
     $this->assertSame($oExpected->render(), $oTemplate->render());
 }
Example #5
0
 public function testPStringWithHTMLAsTemplate()
 {
     $sString = TranslationPeer::getString('simple_quote', 'de', null, array('quoted' => 'String'));
     $oTemplate = new Template(TemplateIdentifier::constructIdentifier('string'), null, true);
     $oTemplate->replaceIdentifier('string', $sString);
     $this->assertSame("&gt;String&lt;", $oTemplate->render());
 }
Example #6
0
 public function getStringAsHTML($sKey, $aParams = array(), $sLanguageId = null, $sDefaultValue = null)
 {
     $mResult = TranslationPeer::getString($sKey, $sLanguageId, $sDefaultValue, $aParams, true);
     $oTemplate = new Template(TemplateIdentifier::constructIdentifier('result'), null, true);
     $oTemplate->replaceIdentifier('result', $mResult);
     return $oTemplate->render();
 }
    public function testSimpleInlineFlagForceHtmlEscape()
    {
        $sTemplateText = <<<EOT
{{test;templateFlag=FORCE_HTML_ESCAPE}}
EOT;
        $oTemplate = new Template($sTemplateText, null, true);
        $oTemplate->replaceIdentifier('test', new Template('<a>&nbsp;</a>', null, true));
        $this->assertSame('&lt;a&gt;&amp;nbsp;&lt;/a&gt;', $oTemplate->render());
    }
    public function testDirectOutputWithIdentifierAndValue()
    {
        $sTemplateText = <<<EOT
test{{id}}test2
EOT;
        $this->expectOutputString('test value test2');
        $oTemplate = new Template($sTemplateText, null, true, true);
        $oTemplate->replaceIdentifier("id", " value ");
    }
 public function display(Template $oTemplate, $bIsPreview = false)
 {
     $sTemplateName = $this->oPage->getTemplateNameUsed();
     $sLanguageId = Session::language();
     $oListTemplate = null;
     $oItemTemplatePrototype = null;
     try {
         $oListTemplate = new Template("search_results/{$sTemplateName}");
         $oItemTemplatePrototype = new Template("search_results/{$sTemplateName}_item");
     } catch (Exception $e) {
         $oListTemplate = new Template("search_results/default");
         $oItemTemplatePrototype = new Template("search_results/default_item");
     }
     $aResults = array();
     $sWords = isset($_REQUEST['q']) ? $_REQUEST['q'] : '';
     if ($sWords) {
         $aWords = StringUtil::getWords($sWords, false, '%');
         $oSearchWordQuery = SearchIndexWordQuery::create();
         foreach ($aWords as $sWord) {
             $sWord = Synonyms::rootFor($sWord);
             $sComparison = Criteria::EQUAL;
             if (strpos($sWord, '%') !== false) {
                 $sComparison = Criteria::LIKE;
             }
             $oSearchWordQuery->addOr(SearchIndexWordPeer::WORD, $sWord, $sComparison);
         }
         $oSearchWordQuery->joinSearchIndex()->useQuery('SearchIndex')->joinPage()->useQuery('Page')->active(true)->filterByIsProtected(false)->endUse()->endUse();
         foreach ($oSearchWordQuery->find() as $oSearchIndexWord) {
             $iId = $oSearchIndexWord->getSearchIndexId();
             if (isset($aResults[$iId])) {
                 $aResults[$iId] += $oSearchIndexWord->getCount();
             } else {
                 $aResults[$iId] = $oSearchIndexWord->getCount();
             }
         }
         arsort($aResults);
     }
     $oListTemplate->replaceIdentifier('count', count($aResults));
     $oListTemplate->replaceIdentifier('search_string', $sWords);
     if (count($aResults) === 0) {
         $oListTemplate->replaceIdentifier('no_results', TranslationPeer::getString('wns.search.no_results', null, null, array('search_string' => $sWords)));
     }
     foreach ($aResults as $iIndexId => $iCount) {
         $oIndex = SearchIndexQuery::create()->findPk(array($iIndexId, $sLanguageId));
         if (!$oIndex || !$oIndex->getPage()) {
             continue;
         }
         $oItemTemplate = clone $oItemTemplatePrototype;
         $oIndex->renderListItem($oItemTemplate);
         $oItemTemplate->replaceIdentifier('count', $iCount);
         $oListTemplate->replaceIdentifierMultiple('items', $oItemTemplate);
     }
     $oTemplate->replaceIdentifier('search_results', $oListTemplate);
 }
 public function onFillPageAttributes($oCurrentPage, $oTemplate)
 {
     $oSearchPage = $oCurrentPage->getPageOfType('search_result');
     if ($oSearchPage === null) {
         return;
     }
     $oTemplate->replaceIdentifier("search_action", LinkUtil::link($oSearchPage->getLinkArray()));
     foreach ($oTemplate->identifiersMatching('search_form', Template::$ANY_VALUE) as $oIdentifier) {
         $oSubTemplate = new Template($oIdentifier->getValue() ? $oIdentifier->getValue() : 'default', array(DIRNAME_TEMPLATES, 'search_form'));
         $oSubTemplate->replaceIdentifier("search_action", LinkUtil::link($oSearchPage->getLinkArray()));
         $oTemplate->replaceIdentifier($oIdentifier, $oSubTemplate);
     }
 }
 /**
  * renderFile()
  * @return string xhtml output
  */
 public function renderFile()
 {
     $oOutput = new XHTMLOutput(XHTMLOutput::SETTING_HTML_4_TRANSITIONAL, true, null, $this->oNewsletter->getLanguageId());
     $oOutput->render();
     $oNewsletterTemplate = new Template('main_display', array(DIRNAME_TEMPLATES, 'newsletter'), false, true);
     $oNewsletterTemplate->replaceIdentifier('newsletter_template_css', new Template("{$this->oNewsletter->getTemplateName()}.css", array(DIRNAME_TEMPLATES, 'newsletter')));
     $oNewsletterContent = RichtextUtil::parseStorageForFrontendOutput(stream_get_contents($this->oNewsletter->getNewsletterBody()));
     if (ResourceFinder::findResource(array(DIRNAME_TEMPLATES, NewsletterDetailWidgetModule::NEWSLETTER_DIRNAME, "{$this->oNewsletter->getTemplateName()}.body.tmpl")) !== null) {
         $oNewsletterTemplate->replaceIdentifier('newsletter_content', new Template("{$this->oNewsletter->getTemplateName()}.body", array(DIRNAME_TEMPLATES, NewsletterDetailWidgetModule::NEWSLETTER_DIRNAME)), null, Template::LEAVE_IDENTIFIERS);
     }
     $oNewsletterTemplate->replaceIdentifier('newsletter_content', $oNewsletterContent, null, Template::LEAVE_IDENTIFIERS);
     $oNewsletterTemplate->replaceIdentifier('language', $this->oNewsletter->getLanguageId());
     if ($this->oMailing !== null) {
         $oNewsletterTemplate->replaceIdentifier('newsletter_date', LocaleUtil::localizeDate($this->oMailing->getDateSent(null)->getTimestamp(), $this->oNewsletter->getLanguageId()));
         $oNewsletterTemplate->replaceIdentifier('newsletter_timestamp', $this->oMailing->getDateSent(null)->getTimestamp());
     } else {
         $oNewsletterTemplate->replaceIdentifier('newsletter_date', LocaleUtil::localizeDate($this->oNewsletter->getCreatedAt(null)->getTimestamp(), $this->oNewsletter->getLanguageId()));
         $oNewsletterTemplate->replaceIdentifier('newsletter_timestamp', $this->oNewsletter->getCreatedAt(null)->getTimestamp());
     }
     $oNewsletterTemplate->replaceIdentifier('recipient', TranslationPeer::getString('wns.newsletter.recipient', $this->oNewsletter->getLanguageId()));
     $oNewsletterTemplate->replaceIdentifier('subject', $this->oNewsletter->getSubject());
     $oNewsletterTemplate->render();
 }
 public function renderListItem(Template $oTemplate)
 {
     $oTemplate->replaceIdentifier("id", $this->getId());
     $oTemplate->replaceIdentifier("name", $this->getPage()->getName());
     $oTemplate->replaceIdentifier("link_text", $this->getLinkText());
     $oTemplate->replaceIdentifier("title", $this->getPageTitle());
     $oTemplate->replaceIdentifier("description", $this->getPage()->getDescription());
     $oTemplate->replaceIdentifier("url", $this->getLink());
 }
 public function testTypesInArrayReplace()
 {
     $oTestTemplate = new Template('{{test}}', null, true);
     $oTestTemplate->replaceIdentifier('test', array('SAMPLE', 1, 9999999999.0, 3.1415972, new TagWriter('a')));
     $this->assertSame("SAMPLE199999999993.1415972&lt;a&gt;&lt;/a&gt;", $oTestTemplate->render());
 }
    public function testIdentifierEscaping()
    {
        $sTemplateText = <<<EOT
{{test=\\\\}}{{test=\\{\\{t1=\\\\\\\\\\\\}\\}\\}}}{{test=val2}}
EOT;
        $oTemplate = new Template($sTemplateText, null, true);
        $this->assertSame("{{test=\\\\}}{{test=\\{\\{t1\\=\\\\\\}\\}\\}}}{{test=val2}}", $oTemplate->__toString());
        $oTemplate->replaceIdentifier('test', "val", '\\', Template::NO_IDENTIFIER_VALUE_REPLACEMENT);
        $this->assertSame("val{{test=\\{\\{t1\\=\\\\\\}\\}\\}}}{{test=val2}}", $oTemplate->__toString());
        $oTemplate->replaceIdentifier('t1', "val2");
        $this->assertSame("val{{test=\\{\\{t1\\=\\\\\\}\\}\\}}}{{test=val2}}", $oTemplate->__toString());
        /// @todo
        // $oTemplate->replaceIdentifier('t1', "val3", '\\}');
        // $this->assertSame("val{{test=val3}}{{test=val2}}", $oTemplate->__toString());
        $this->assertSame("val", $oTemplate->render());
    }
Example #15
0
 public static function getString($sKey, $sLanguageId = null, $sDefaultValue = null, $aParameters = null, $bMayReturnTemplate = false, $iFlags = 0)
 {
     $bNoHTMLInReturnedString = $bMayReturnTemplate === null;
     if (Settings::getSetting('frontend', 'display_string_keys', false)) {
         return $sKey;
     }
     if (!is_string($sDefaultValue)) {
         $sDefaultValue = "Translation missing: {$sKey}";
     }
     if ($sLanguageId === null) {
         $sLanguageId = Session::language();
     }
     $oString = self::retrieveByPK($sLanguageId, $sKey);
     $sString = '';
     if ($oString === null) {
         $sString = self::getStaticString($sKey, $sLanguageId);
         if ($sString === null) {
             return $sDefaultValue;
         }
     } else {
         $sString = $oString->getText();
     }
     if (is_array($aParameters) && count($aParameters) > 0 || strpos($sString, TEMPLATE_IDENTIFIER_START) !== false) {
         if (!is_array($aParameters)) {
             $aParameters = array();
         }
         if (!$bMayReturnTemplate) {
             //NO_HTML_ESCAPE works in any case:
             //Case $bMayReturnTemplate === false: strings will always be included in templates and thus always be encoded correctly in a second step.
             //Case $bMayReturnTemplate === null: strings should not contain any HTML-characteristics, including entities. {{br}}-Tags will be stripped as well.
             $iFlags = $iFlags | Template::NO_HTML_ESCAPE;
         }
         if ($bMayReturnTemplate) {
             //If returned item is a template, it is assumed that nothing will run htmlentities on it later on so we have to run it now.
             $sString = Template::htmlEncode($sString);
         }
         if ($bNoHTMLInReturnedString) {
             $sString = str_replace('{{br}}', "\n", $sString);
         }
         $tmpl = new Template($sString, "db", true, false, Settings::getSetting("encoding", "db", "utf-8"), null, $iFlags);
         foreach ($aParameters as $sKey => $sValue) {
             $tmpl->replaceIdentifier($sKey, $sValue);
         }
         if ($bMayReturnTemplate) {
             return $tmpl;
         }
         $sString = $tmpl->render();
     }
     return $sString;
 }
Example #16
0
    private static function compileSchemaXml()
    {
        $sSchemaTemplate = <<<EOT
<?xml version="1.0" encoding="UTF-8"?>
<!-- {{comment}} -->
<database name="{{name}}" defaultIdMethod="native">
\t{{schema_content}}
</database>
EOT;
        foreach (self::groupedSchemaXml() as $sSchemaName => $aSchemas) {
            $oSchemaTemplate = new Template($sSchemaTemplate, null, true);
            $oSchemaTemplate->replaceIdentifier('comment', "This file is generated by the generate-model.sh script, edit schema.xml in the config dir or the plugins or site's schema.xml file instead", null, Template::NO_HTML_ESCAPE);
            $oSchemaTemplate->replaceIdentifier('name', $sSchemaName);
            foreach ($aSchemas as $oSchemaFile) {
                $oSchemaTemplate->replaceIdentifierMultiple('schema_content', file_get_contents($oSchemaFile->getFullPath()), null, Template::NO_HTML_ESCAPE);
            }
            $sSchemaOutputPath = MAIN_DIR . '/' . DIRNAME_GENERATED . "/{$sSchemaName}.schema.xml";
            file_put_contents($sSchemaOutputPath, $oSchemaTemplate->render());
        }
    }
Example #17
0
 public static function sendResetMail($oUser, $bShowUserName = false, $sLinkBase = null, $bForceReset = false)
 {
     UserPeer::ignoreRights(true);
     $oUser->setPasswordRecoverHint(PasswordHash::generateHint());
     $oUser->save();
     $oEmailTemplate = new Template('e_mail_pw_recover', array(DIRNAME_TEMPLATES, 'login'));
     $oEmailTemplate->replaceIdentifier('full_name', $oUser->getFullName());
     $oEmailTemplate->replaceIdentifier('first_name', $oUser->getFirstName());
     $oEmailTemplate->replaceIdentifier('last_name', $oUser->getLastName());
     $oEmailTemplate->replaceIdentifier('username', $oUser->getUsername());
     if ($bShowUserName) {
         $oEmailTemplate->replaceIdentifier('username_info', TranslationPeer::getString('wns.login.password_reset.your_username') . ': ' . $oUser->getUsername());
     }
     $sInfoTextKey = 'wns.login.password_recover_email_text2';
     if ($bForceReset) {
         $sInfoTextKey = 'wns.login.password_recover_email_text2_force';
     }
     $oEmailTemplate->replaceIdentifier('ignore_or_reset_info', TranslationPeer::getString($sInfoTextKey));
     if ($sLinkBase === null) {
         if (Manager::$CURRENT_MANAGER instanceof FrontendManager) {
             // We’re most likely on a login page: link to self should be ok
             $sLinkBase = LinkUtil::linkToSelf(null, null, true);
         } else {
             // Use the login manager
             $sLinkBase = LinkUtil::link(array(), 'LoginManager');
         }
     }
     $aParams = array('recover_hint' => md5($oUser->getPasswordRecoverHint()), 'recover_username' => $oUser->getUsername());
     if (Session::getSession()->hasAttribute('login_referrer')) {
         $aParams['recover_referrer'] = Session::getSession()->getAttribute('login_referrer');
     }
     $sLink = "http://" . $_SERVER['HTTP_HOST'] . $sLinkBase . LinkUtil::prepareLinkParameters($aParams);
     $oEmailTemplate->replaceIdentifier('new_pw_url', $sLink);
     $oEmail = new EMail(TranslationPeer::getString('wns.login.password_recover_email_subject'), $oEmailTemplate);
     $sSenderAddress = LinkUtil::getDomainHolderEmail('cms');
     $oEmail->setSender(Settings::getSetting('domain_holder', 'name', 'rapila on ' . $_SERVER['HTTP_HOST']), $sSenderAddress);
     $oEmail->addRecipient($oUser->getEmail(), $oUser->getFullName());
     $oEmail->send();
 }
 private function embedVideo($sLocation)
 {
     $oTemplateLocation = ResourceFinder::create(array('modules', 'frontend', 'media_object', 'templates', 'text', 'html.tmpl'))->returnObjects()->find();
     $oVideoTempl = new Template($oTemplateLocation);
     $oVideoTempl->replaceIdentifier('src', $sLocation);
     $oVideoTempl->replaceIdentifier('width', 420);
     $oVideoTempl->replaceIdentifier('height', 250);
     return $oVideoTempl->render();
 }
    public function testCaseFromJM2()
    {
        $sText = <<<EOT
{{if;1=\\{\\{comment_count\\}\\};2=0}}Keine Kommentare{{endIf}}{{if=!=;1=\\{\\{comment_count\\}\\};2=0}}{{comment_count}} Kommentar{{if=>;1=\\{\\{comment_count\\}\\};2=1}}e{{endIf}}{{endIf}}
EOT;
        $oTemplate = new Template($sText, null, true);
        $oTemplate->replaceIdentifier("comment_count", 0);
        $this->assertSame("Keine Kommentare", $oTemplate->render());
        $oTemplate = new Template($sText, null, true);
        $oTemplate->replaceIdentifier("comment_count", 1);
        $this->assertSame("1 Kommentar", $oTemplate->render());
        $oTemplate = new Template($sText, null, true);
        $oTemplate->replaceIdentifier("comment_count", 2);
        $this->assertSame("2 Kommentare", $oTemplate->render());
    }
 public function renderFrontend()
 {
     $aOptions = @unserialize($this->getData());
     if (!$aOptions) {
         $aOptions = array();
     }
     $oTemplate = new Template(TemplateIdentifier::constructIdentifier("content"), null, true);
     foreach ($aOptions as $aDocumentInfo) {
         $oDocument = DocumentQuery::create()->findPk($aDocumentInfo['document_id']);
         $sMimeType = @$aDocumentInfo['mimetype'];
         $sSrc = null;
         if ($oDocument !== null) {
             $aParameters = array();
             if (@$aDocumentInfo['max_width']) {
                 $aParameters['max_width'] = $aDocumentInfo['max_width'];
             }
             if (@$aDocumentInfo['max_height']) {
                 $aParameters['max_height'] = $aDocumentInfo['max_width'];
             }
             if (@$aDocumentInfo['force_refresh']) {
                 $aParameters['refresh'] = time();
             }
             $sSrc = $oDocument->getDisplayUrl($aParameters);
             if (!$sMimeType) {
                 $sMimeType = $oDocument->getMimetype();
             }
         } else {
             if (@$aDocumentInfo['url']) {
                 $sSrcToCheck = $aDocumentInfo['url'];
                 if (($iQSPos = strrpos($sSrcToCheck, '?')) !== false) {
                     $sSrcToCheck = substr($sSrcToCheck, 0, $iQSPos);
                 }
                 if (file_exists(MAIN_DIR . '/' . $sSrcToCheck)) {
                     $aDocumentInfo['url'] = MAIN_DIR_FE . $aDocumentInfo['url'];
                 }
                 $sSrc = @$aDocumentInfo['url'];
             } else {
                 continue;
             }
         }
         $oSubTemplate = null;
         try {
             try {
                 $oSubTemplate = $this->constructTemplate($sMimeType);
             } catch (Exception $e) {
                 $sMimeTypePrefix = explode('/', $sMimeType);
                 $sMimeTypePrefix = $sMimeTypePrefix[0];
                 $oSubTemplate = $this->constructTemplate("{$sMimeTypePrefix}/generic");
             }
         } catch (Exception $e) {
             $oSubTemplate = $this->constructTemplate("generic");
         }
         if (@$aDocumentInfo['width']) {
             $oSubTemplate->replaceIdentifier('width', $aDocumentInfo['width']);
         }
         if (@$aDocumentInfo['height']) {
             $oSubTemplate->replaceIdentifier('height', $aDocumentInfo['height']);
         }
         $oSubTemplate->replaceIdentifier('src', $sSrc);
         $oSubTemplate->replaceIdentifier('mimeType', $sMimeType);
         $oTemplate->replaceIdentifier("content", $oSubTemplate, null, Template::LEAVE_IDENTIFIERS);
     }
     return $oTemplate;
 }
Example #21
0
 protected function preRender()
 {
     $oConstants = new Template('constants.js', array(DIRNAME_TEMPLATES, 'admin'));
     $oConstants->replaceIdentifier('current_admin_module', $this->sModuleName ? $this->sModuleName : self::DEFAULT_MODULE);
     $oConstants->replaceIdentifier('is_logged_in', Session::getSession()->isAuthenticated() && Session::getSession()->getUser()->getIsBackendLoginEnabled());
     $this->oResourceIncluder->addJavaScriptLibrary('jquery', self::JQUERY_VERSION);
     $this->oResourceIncluder->addCustomJs($oConstants);
     $this->oResourceIncluder->addJavaScriptLibrary('jqueryui', AdminManager::JQUERY_UI_VERSION);
     $this->oResourceIncluder->addResource('admin/admin-skeleton.css');
     $this->oResourceIncluder->addResource('admin/theme/jquery-ui-1.10.2.custom.min.css');
     $this->oResourceIncluder->addResource('widget/widget.css');
     $this->oResourceIncluder->addResource('admin/admin-ui.css');
     $this->oResourceIncluder->addResource('admin/print.css', null, null, array('media' => 'print'), ResourceIncluder::PRIORITY_NORMAL, null, true);
     $this->oResourceIncluder->addResource('widget/widget.js');
     $this->oResourceIncluder->addResource('widget/widget_skeleton.js');
     //Provides some basic overrides for tooltip, notifyuser and stuff
     $this->oResourceIncluder->addResource('admin/admin.js');
     $this->oResourceIncluder->addResource('admin/skeleton.js');
     $this->oResourceIncluder->addResource('backend/additions.js', null, null, null, ResourceIncluder::PRIORITY_NORMAL, null, true);
     $this->oResourceIncluder->addResource('admin/additions.js', null, null, null, ResourceIncluder::PRIORITY_NORMAL, null, true);
     $this->oResourceIncluder->addResource('backend/additions.css', null, null, null, ResourceIncluder::PRIORITY_NORMAL, null, true);
     $this->oResourceIncluder->addResource('admin/additions.css', null, null, null, ResourceIncluder::PRIORITY_NORMAL, null, true);
     $oOutput = new XHTMLOutput('html5');
     $oOutput->render();
 }
    public function testUnusedContextsReplacedFilled()
    {
        $sTemplateText = <<<EOT
{{identifierContext=start;name=test1}}
\t{{test2}}{{test1}}
{{identifierContext=end;name=test1}}

{{test2}}

EOT;
        $oTemplate = new Template($sTemplateText, null, true);
        $oTemplate->replaceIdentifier('test2', 'text');
        $oTemplate->replaceIdentifier('test1', 'text');
        $this->assertSame(<<<EOT

\ttexttext


text

EOT
, $oTemplate->render());
    }
Example #23
0
 public function renderFormObject($iFormId)
 {
     $oKeyValueTemplate = new Template("{{label}} {{field}} {{identifierContext=start;name=writeFlashValue;value=\\{\\{name\\}\\}}}<br />{{writeFlashValue=\\{\\{name\\}\\}}}{{identifierContext=end;name=writeFlashValue;value=\\{\\{name\\}\\}}}", null, true);
     $oKeyValueTemplate->replaceIdentifier('field', $this->getFieldCode($iFormId));
     $oKeyValueTemplate->replaceIdentifier("name", $this->sName);
     $sTagName = 'p';
     if ($this->isVisibleFormElement()) {
         if ($this->sLabel === '') {
             $this->sLabel = new Template(' ', null, true);
             //nbsp
         }
         $oKeyValueTemplate->replaceIdentifier("label", TagWriter::quickTag("label", array('for' => $this->getFormObjectId($iFormId), 'class' => $this->sClassName), $this->sLabel));
     } else {
         $sTagName = 'span';
     }
     return TagWriter::quickTag($sTagName, array('class' => $this->sClassName), $oKeyValueTemplate);
 }
Example #24
0
 public static function listItemsFromArray($aArray)
 {
     if (count($aArray) === 0) {
         return "";
     }
     $oTemplate = new Template(TemplateIdentifier::constructIdentifier('result'), null, true);
     foreach ($aArray as $sListItem) {
         $oOptionTemplate = new Template('<li>' . TemplateIdentifier::constructIdentifier('value') . '</li>', null, true);
         $oOptionTemplate->replaceIdentifier("value", $sListItem);
         $oTemplate->replaceIdentifierMultiple("result", $oOptionTemplate);
     }
     return $oTemplate;
 }
 /**
  * renderGallery()
  *
  * description: display image gallery
  * @return Template object
  */
 private function renderGallery(JournalEntry $oEntry)
 {
     $oEntryTemplate = $this->constructTemplate('journal_gallery');
     $oListTemplate = new Template('helpers/gallery');
     $oListTemplate->replaceIdentifier('title', $this->oEntry->getTitle());
     foreach ($this->oEntry->getImages() as $oJournalEntryImage) {
         $oDocument = $oJournalEntryImage->getDocument();
         $oItemTemplate = new Template('helpers/gallery_item');
         $oItemTemplate->replaceIdentifier('jounal_entry_id', $this->oEntry->getId());
         $oDocument->renderListItem($oItemTemplate);
         $oListTemplate->replaceIdentifierMultiple('items', $oItemTemplate);
     }
     $oEntryTemplate->replaceIdentifier('gallery', $oListTemplate);
     return $oEntryTemplate;
 }
Example #26
0
 private function renderDoctype($sDoctype)
 {
     $oTemplate = new Template($sDoctype, null, true, true);
     $oTemplate->replaceIdentifier('language', $this->sLanguage);
     $oTemplate->replaceIdentifier('charset', $this->sCharset);
     $oTemplate->replaceIdentifier('className', $this->sClassName);
     $oTemplate->render();
 }
Example #27
0
 protected function fillContent()
 {
     $this->oPageTypeWidget->setPageTypeModule($this->oPageType);
     $oResourceIncluder = ResourceIncluder::defaultIncluder();
     $oConstants = new Template('constants.js', array(DIRNAME_TEMPLATES, 'preview'));
     $oConstants->replaceIdentifier('language_id', Session::getSession()->getUser()->getLanguageId());
     $oConstants->replaceIdentifier('page_type', $this->oPageType->getModuleName());
     $oConstants->replaceIdentifier('page_type_widget_session', $this->oPageTypeWidget->getSessionKey());
     $oConstants->replaceIdentifier('admin_menu_widget_session', $this->oAdminMenuWidget->getSessionKey());
     $oConstants->replaceIdentifier('current_page_id', self::$CURRENT_PAGE->getId());
     $oResourceIncluder->addCustomJs($oConstants);
     $oResourceIncluder->addResource('preview/preview.js');
     return parent::fillContent();
 }