public function transform() { if ($this->display) { return parent::transform(); } return ''; }
/** * Fills the model information and includes the guest book's main template. * * @author Christian Achatz * @version * Version 0.1, 16.05.2009<br /> */ public function onParseTime() { /* @var $model GuestbookModel */ $model = $this->getServiceObject(GuestbookModel::class); $guestbookId = $this->getAttribute('gbid'); // do not include the guestbook, if gbid is not set/existent if ($guestbookId == null || (int) $guestbookId == 0) { throw new InvalidArgumentException('[GuestbookImportTemplateTag::onParseTime()] The attribute ' . '"gbid" is empty or not present or the value is not an id. Please specify the ' . 'attribute correctly in order to include the guestbook module!'); } $model->setGuestbookId($guestbookId); $this->setAttribute('namespace', 'APF\\modules\\guestbook2009\\pres\\templates'); $this->setAttribute('template', 'guestbook'); parent::onParseTime(); }
/** * Implements the onParseTime() method from the Document class. Includes the desired template * as a new DOM node into the current APF DOM tree. * * @author jw-lighting, Christian Achatz * @version * Version 0.1, 16.07.2010, Christian Achatz (See more here: http://forum.adventure-php-framework.org/viewtopic.php?f=3&t=359#p3075)<br /> * Version 0.2, 28.08.2010, jw-lighting (Added functionality and improved the code of v0.1 to this class)<br /> * Version 0.3, 02.09.2010, jw-lighting (Added short-scripting support with the fallback attribute)<br /> * Version 0.4, 03.09.2010, jw-lighting (Removed Bug: empty() can not use function return values, used temporary variables instead) <br /> * (Removed Bug: The class HeaderManager is designed for static use) <br /> * (Improved functionality: Added parameter 'errormsg' for failed fallback-templates include) <br /> */ public function onParseTime() { try { parent::onParseTime(); } catch (IncludeException $ie) { $fallback = $this->getAttribute('fallback'); if (!empty($fallback)) { $this->setAttribute('template', $this->getAttribute('fallback')); } else { $fallbackNamespace = $this->getAttribute('fallbackNamespace'); if (!empty($fallbackNamespace)) { $this->setAttribute('namespace', $fallbackNamespace); } $this->setAttribute('template', $this->getAttribute('fallbackTemplate')); } $fallbackIncparam = $this->getAttribute('fallbackIncparam'); if (!empty($fallbackIncparam)) { $this->setAttribute('incparam', $this->getAttribute('fallbackIncparam')); } // it can be necessary to send an 404-HTTP Error, check it here $send404Header = $this->getAttribute('send404Header'); if ($send404Header != null && $send404Header != 'false') { $this->getResponse()->setStatusCode(Response::CODE_NOT_FOUND)->setHeader(new HeaderImpl('X-APF-Error', 'Template not found')); } // try to load the fallback template now try { parent::onParseTime(); } catch (IncludeException $ie) { // if the template is not necessary needed, give the last chance to ignore the failure here $fallbackFailureIgnore = $this->getAttribute('fallbackFailureIgnore'); if ($fallbackFailureIgnore != null && in_array($fallbackFailureIgnore, ['true', 'yes'])) { $this->content = $this->getAttribute('errormsg'); } throw $ie; } } }
public function onParseTime() { /** @var $SMSM SMSManager */ $SMSM = $this->getDIServiceObject('APF\\extensions\\apfelsms', 'Manager'); $SMSS = $SMSM->getSite(); //// // fetch not found template name $notFoundTemplate = $this->getAttribute('notFoundTemplate'); if (empty($notFoundTemplate)) { $_404page = $SMSS->get404Page(); if ($_404page !== null) { $notFoundTemplate = $_404page->getTemplateName(); } } //// // try to load template for current/given page id try { // get page id, current as default $currentPageId = $SMSS->getCurrentPageId(); $pageId = $this->getAttribute('pageId', $currentPageId); // get template for given page $page = $SMSM->getPage($pageId); $template = $page->getTemplateName(); // check if template is protected and fall back on notAllowedTemplate if necessary if ($page->isAccessProtected()) { $notAllowedTemplate = $this->getAttribute('notAllowedTemplate'); if (empty($notAllowedTemplate)) { $_403page = $SMSS->get403Page(); if ($_403page !== null) { $notAllowedTemplate = $_403page->getTemplateName(); } } $template = $notAllowedTemplate; } } catch (SMSException $e) { // on exception (e.g. given page id is not existent) fall back on notFoundTemplate $template = $notFoundTemplate; } // check if template name is set if (empty($template)) { throw new SMSException('[SMSImportDesignTag::onParseTime()] No template found.'); } // inject template name $this->setAttribute('template', $template); //// // template inclusion try { parent::onParseTime(); } catch (IncludeException $ie) { //// // fall back on notFoundTemplate if missing template was reason of exception $message = $ie->getMessage(); $strPosDesign = strpos($message, 'Template'); // Changed from "Design" to "Template" since APF v2.0 $strPosExists = strpos($message, 'not existent'); if ($strPosDesign === false || $strPosExists === false) { throw $ie; // other reason, abort and throw exception } $this->setAttribute('template', $notFoundTemplate); parent::onParseTime(); } }