public function render($content) { $element = $this->getElement(); $separator = $this->getSeparator(); $placement = $this->getPlacement(); $title = $element->getTitle(); $tag = $this->getTag(); $translator = Engine_Content::getInstance()->getTranslator(); if (!$this->getParam('disableTranslate')) { $title = $translator->_($title); } if (!empty($title)) { if (null !== $tag) { $title = '<' . $tag . '>' . $title . '</' . $tag . '>'; } switch ($placement) { default: case self::APPEND: $content .= $separator . $title; break; case self::PREPEND: $content = $title . $separator . $content; break; } } return $content; }
protected function _render() { try { $contentInstance = Engine_Content::getInstance(); $this->_widget = $contentInstance->loadWidget($this->getName()); $this->_widget->setElement($this); if (null !== $this->_request) { $this->_widget->setRequest($this->_request); } $this->_widget->render($this->_action); return $this->_widget->getContent(); } catch (Exception $e) { $this->setNoRender(); if ($this->_throwExceptions) { throw $e; } else { if (!$e instanceof Engine_Exception) { $log = Zend_Registry::get('Zend_Log'); $log->log($e->__toString(), Zend_Log::CRIT); } // Silence //if( APPLICATION_ENV === 'development' ) { // trigger_error('Exception thrown while rendering widget: ' . $e->__toString(), E_USER_WARNING); //} } return ''; } }
public function getContent() { if (null === $this->_content) { $this->_content = Engine_Content::getInstance(); } return $this->_content; }
/** * Render a content area by name * * @param string $name * @return string */ public function content($name = null) { // Direct access if (func_num_args() == 0) { return $this; } if (func_num_args() > 1) { $name = func_get_args(); } $content = Engine_Content::getInstance(); return $content->render($name); }
public function getView() { if (null === $this->_view) { return Engine_Content::getInstance()->getView(); } return $this->_view; }
public static function setInstance(Engine_Content $content = null) { self::$_instance = null; }
public function render($action = null) { try { ob_start(); // Check action if (null !== $action && !is_string($action)) { throw new Engine_Content_Widget_Exception('Action must be a string'); } if (empty($action)) { $action = 'index'; } $this->_action = $action; $method = $this->inflect($action) . 'Action'; if (!method_exists($this, $method)) { throw new Engine_Content_Widget_Exception(sprintf('Action "%s" does not exist in widget "%s"', $action, get_class($this))); } // Caching (pre) $isCached = false; $cache = Engine_Content::getInstance()->getCache(); $key = $this->getCacheKey(); if ($cache instanceof Zend_Cache_Core && $key) { if ($key === true) { $key = get_class($this); } else { $key = get_class($this) . '_' . $key; } $cacheData = $cache->load($key); if (!empty($cacheData) && is_array($cacheData) && count($cacheData) == 2) { $this->setContent($cacheData[0]); $this->setCacheExtraData($cacheData[1]); $isCached = true; } } if (!$isCached) { // Prepare stuff $view = $this->getView(); $view->clearVars(); $this->view = $view; // Pre-assign some info $view->identity = $this->getElement()->getIdentity(); $view->element = $this->getElement(); // Begin generation $content = ''; // Call action $this->{$method}(); // Render if (!$this->getNoRender()) { $content = $this->renderScript(); } $content .= ob_get_clean(); $this->appendContent($content); // Caching (post) if ($cache instanceof Zend_Cache_Core && null !== $key) { $content = $this->getContent(); $extraContent = $this->getCacheExtraContent(); if (!empty($content) || !empty($extraContent)) { $cache->save(array($content, $extraContent), $key, array(), $this->getCacheSpecificLifetime()); } } } } catch (Exception $e) { ob_end_clean(); throw $e; } return; }
protected function _initContent() { $content = Engine_Content::getInstance(); // Set storage $contentTable = Engine_Api::_()->getDbtable('pages', 'core'); $content->setStorage($contentTable); // Load content helper $contentRenderer = new Engine_Content_Controller_Action_Helper_Content(); $contentRenderer->setContent($content); Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-85, $contentRenderer); // Set cache object if (isset($this->getContainer()->cache)) { $content->setCache($this->getContainer()->cache); } // Set translator if (isset($this->getContainer()->translate)) { $content->setTranslator($this->getContainer()->translate); } // Save to registry Zend_Registry::set('Engine_Content', $content); return $content; }