Example #1
0
 /**
  * Generates a 'List' element.
  *
  * @param array   $items   Array with the elements of the list
  * @param boolean $ordered Specifies ordered/unordered list; default unordered
  * @param array   $attribs Attributes for the ol/ul tag.
  * @return string The list XHTML.
  */
 public function htmlList(array $items, $ordered = false, $attribs = false, $escape = true)
 {
     if (!is_array($items)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
         $e = new IfwPsn_Vendor_Zend_View_Exception('First param must be an array');
         $e->setView($this->view);
         throw $e;
     }
     $list = '';
     foreach ($items as $item) {
         if (!is_array($item)) {
             if ($escape) {
                 $item = $this->view->escape($item);
             }
             $list .= '<li>' . $item . '</li>' . self::EOL;
         } else {
             if (6 < strlen($list)) {
                 $list = substr($list, 0, strlen($list) - 6) . $this->htmlList($item, $ordered, $attribs, $escape) . '</li>' . self::EOL;
             } else {
                 $list .= '<li>' . $this->htmlList($item, $ordered, $attribs, $escape) . '</li>' . self::EOL;
             }
         }
     }
     if ($attribs) {
         $attribs = $this->_htmlAttribs($attribs);
     } else {
         $attribs = '';
     }
     $tag = 'ul';
     if ($ordered) {
         $tag = 'ol';
     }
     return '<' . $tag . $attribs . '>' . self::EOL . $list . '</' . $tag . '>' . self::EOL;
 }
Example #2
0
 /**
  * Set translator
  *
  * @param  IfwPsn_Vendor_Zend_Translate|IfwPsn_Vendor_Zend_Translate_Adapter|null $translator
  * @return IfwPsn_Vendor_Zend_View_Helper_FormElement
  */
 public function setTranslator($translator = null)
 {
     if (null === $translator) {
         $this->_translator = null;
     } elseif ($translator instanceof IfwPsn_Vendor_Zend_Translate_Adapter) {
         $this->_translator = $translator;
     } elseif ($translator instanceof IfwPsn_Vendor_Zend_Translate) {
         $this->_translator = $translator->getAdapter();
     } else {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
         $e = new IfwPsn_Vendor_Zend_View_Exception('Invalid translator specified');
         $e->setView($this->view);
         throw $e;
     }
     return $this;
 }
Example #3
0
 /**
  * Constructor
  *
  * Grab local copies of various MVC objects
  *
  * @return void
  */
 public function __construct()
 {
     $front = IfwPsn_Vendor_Zend_Controller_Front::getInstance();
     $modules = $front->getControllerDirectory();
     if (empty($modules)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
         $e = new IfwPsn_Vendor_Zend_View_Exception('Action helper depends on valid front controller instance');
         $e->setView($this->view);
         throw $e;
     }
     $request = $front->getRequest();
     $response = $front->getResponse();
     if (empty($request) || empty($response)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
         $e = new IfwPsn_Vendor_Zend_View_Exception('Action view helper requires both a registered request and response object in the front controller instance');
         $e->setView($this->view);
         throw $e;
     }
     $this->request = clone $request;
     $this->response = clone $response;
     $this->dispatcher = clone $front->getDispatcher();
     $this->defaultModule = $front->getDefaultModule();
 }
Example #4
0
 /**
  * Override offsetSet
  *
  * @param  string|int $index
  * @param  mixed $value
  * @return void
  */
 public function offsetSet($index, $value)
 {
     if (!$this->_isValid($value)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
         $e = new IfwPsn_Vendor_Zend_View_Exception('Invalid argument passed to offsetSet(); please use one of the helper methods, offsetSetScript() or offsetSetFile()');
         $e->setView($this->view);
         throw $e;
     }
     return $this->getContainer()->offsetSet($index, $value);
 }
Example #5
0
 /**
  * Returns a DOMDocument containing the Sitemap XML for the given container
  *
  * @param  IfwPsn_Vendor_Zend_Navigation_Container $container  [optional] container to get
  *                                               breadcrumbs from, defaults
  *                                               to what is registered in the
  *                                               helper
  * @return DOMDocument                           DOM representation of the
  *                                               container
  * @throws IfwPsn_Vendor_Zend_View_Exception                   if schema validation is on
  *                                               and the sitemap is invalid
  *                                               according to the sitemap
  *                                               schema, or if sitemap
  *                                               validators are used and the
  *                                               loc element fails validation
  */
 public function getDomSitemap(IfwPsn_Vendor_Zend_Navigation_Container $container = null)
 {
     if (null === $container) {
         $container = $this->getContainer();
     }
     // check if we should validate using our own validators
     if ($this->getUseSitemapValidators()) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Validate/Sitemap/Changefreq.php';
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Validate/Sitemap/Lastmod.php';
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Validate/Sitemap/Loc.php';
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Validate/Sitemap/Priority.php';
         // create validators
         $locValidator = new IfwPsn_Vendor_Zend_Validate_Sitemap_Loc();
         $lastmodValidator = new IfwPsn_Vendor_Zend_Validate_Sitemap_Lastmod();
         $changefreqValidator = new IfwPsn_Vendor_Zend_Validate_Sitemap_Changefreq();
         $priorityValidator = new IfwPsn_Vendor_Zend_Validate_Sitemap_Priority();
     }
     // create document
     $dom = new DOMDocument('1.0', 'UTF-8');
     $dom->formatOutput = $this->getFormatOutput();
     // ...and urlset (root) element
     $urlSet = $dom->createElementNS(self::SITEMAP_NS, 'urlset');
     $dom->appendChild($urlSet);
     // create iterator
     $iterator = new RecursiveIteratorIterator($container, RecursiveIteratorIterator::SELF_FIRST);
     $maxDepth = $this->getMaxDepth();
     if (is_int($maxDepth)) {
         $iterator->setMaxDepth($maxDepth);
     }
     $minDepth = $this->getMinDepth();
     if (!is_int($minDepth) || $minDepth < 0) {
         $minDepth = 0;
     }
     // iterate container
     foreach ($iterator as $page) {
         if ($iterator->getDepth() < $minDepth || !$this->accept($page)) {
             // page should not be included
             continue;
         }
         // get absolute url from page
         if (!($url = $this->url($page))) {
             // skip page if it has no url (rare case)
             continue;
         }
         // create url node for this page
         $urlNode = $dom->createElementNS(self::SITEMAP_NS, 'url');
         $urlSet->appendChild($urlNode);
         if ($this->getUseSitemapValidators() && !$locValidator->isValid($url)) {
             require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
             $e = new IfwPsn_Vendor_Zend_View_Exception(sprintf('Encountered an invalid URL for Sitemap XML: "%s"', $url));
             $e->setView($this->view);
             throw $e;
         }
         // put url in 'loc' element
         $urlNode->appendChild($dom->createElementNS(self::SITEMAP_NS, 'loc', $url));
         // add 'lastmod' element if a valid lastmod is set in page
         if (isset($page->lastmod)) {
             $lastmod = strtotime((string) $page->lastmod);
             // prevent 1970-01-01...
             if ($lastmod !== false) {
                 $lastmod = date('c', $lastmod);
             }
             if (!$this->getUseSitemapValidators() || $lastmodValidator->isValid($lastmod)) {
                 $urlNode->appendChild($dom->createElementNS(self::SITEMAP_NS, 'lastmod', $lastmod));
             }
         }
         // add 'changefreq' element if a valid changefreq is set in page
         if (isset($page->changefreq)) {
             $changefreq = $page->changefreq;
             if (!$this->getUseSitemapValidators() || $changefreqValidator->isValid($changefreq)) {
                 $urlNode->appendChild($dom->createElementNS(self::SITEMAP_NS, 'changefreq', $changefreq));
             }
         }
         // add 'priority' element if a valid priority is set in page
         if (isset($page->priority)) {
             $priority = $page->priority;
             if (!$this->getUseSitemapValidators() || $priorityValidator->isValid($priority)) {
                 $urlNode->appendChild($dom->createElementNS(self::SITEMAP_NS, 'priority', $priority));
             }
         }
     }
     // validate using schema if specified
     if ($this->getUseSchemaValidation()) {
         if (!@$dom->schemaValidate(self::SITEMAP_XSD)) {
             require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
             $e = new IfwPsn_Vendor_Zend_View_Exception(sprintf('Sitemap is invalid according to XML Schema at "%s"', self::SITEMAP_XSD));
             $e->setView($this->view);
             throw $e;
         }
     }
     return $dom;
 }
Example #6
0
 /**
  * Renders the given $container by invoking the partial view helper
  *
  * The container will simply be passed on as a model to the view script
  * as-is, and will be available in the partial script as 'container', e.g.
  * <code>echo 'Number of pages: ', count($this->container);</code>.
  *
  * @param  IfwPsn_Vendor_Zend_Navigation_Container $container  [optional] container to
  *                                               pass to view script. Default
  *                                               is to use the container
  *                                               registered in the helper.
  * @param  string|array             $partial     [optional] partial view
  *                                               script to use. Default is to
  *                                               use the partial registered
  *                                               in the helper. If an array
  *                                               is given, it is expected to
  *                                               contain two values; the
  *                                               partial view script to use,
  *                                               and the module where the
  *                                               script can be found.
  * @return string                                helper output
  *
  * @throws IfwPsn_Vendor_Zend_View_Exception   When no partial script is set
  */
 public function renderPartial(IfwPsn_Vendor_Zend_Navigation_Container $container = null, $partial = null)
 {
     if (null === $container) {
         $container = $this->getContainer();
     }
     if (null === $partial) {
         $partial = $this->getPartial();
     }
     if (empty($partial)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
         $e = new IfwPsn_Vendor_Zend_View_Exception('Unable to render menu: No partial view script provided');
         $e->setView($this->view);
         throw $e;
     }
     $model = array('container' => $container);
     if (is_array($partial)) {
         if (count($partial) != 2) {
             require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
             $e = new IfwPsn_Vendor_Zend_View_Exception('Unable to render menu: A view partial supplied as ' . 'an array must contain two values: partial view ' . 'script and module where script can be found');
             $e->setView($this->view);
             throw $e;
         }
         return $this->view->partial($partial[0], $partial[1], $model);
     }
     return $this->view->partial($partial, null, $model);
 }
Example #7
0
 /**
  * Renders the given $container by invoking the partial view helper
  *
  * The container will simply be passed on as a model to the view script,
  * so in the script it will be available in <code>$this->container</code>.
  *
  * @param  IfwPsn_Vendor_Zend_Navigation_Container $container  [optional] container to
  *                                               pass to view script.
  *                                               Default is to use the
  *                                               container registered in the
  *                                               helper.
  * @param  string|array             $partial     [optional] partial view
  *                                               script to use. Default is
  *                                               to use the partial
  *                                               registered in the helper.
  *                                               If an array is given, it is
  *                                               expected to contain two
  *                                               values; the partial view
  *                                               script to use, and the
  *                                               module where the script can
  *                                               be found.
  * @return string                                helper output
  */
 public function renderPartial(IfwPsn_Vendor_Zend_Navigation_Container $container = null, $partial = null)
 {
     if (null === $container) {
         $container = $this->getContainer();
     }
     if (null === $partial) {
         $partial = $this->getPartial();
     }
     if (empty($partial)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
         $e = new IfwPsn_Vendor_Zend_View_Exception('Unable to render menu: No partial view script provided');
         $e->setView($this->view);
         throw $e;
     }
     // put breadcrumb pages in model
     $model = array('pages' => array());
     if ($active = $this->findActive($container)) {
         $active = $active['page'];
         $model['pages'][] = $active;
         while ($parent = $active->getParent()) {
             if ($parent instanceof IfwPsn_Vendor_Zend_Navigation_Page) {
                 $model['pages'][] = $parent;
             } else {
                 break;
             }
             if ($parent === $container) {
                 // break if at the root of the given container
                 break;
             }
             $active = $parent;
         }
         $model['pages'] = array_reverse($model['pages']);
     }
     if (is_array($partial)) {
         if (count($partial) != 2) {
             require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
             $e = new IfwPsn_Vendor_Zend_View_Exception('Unable to render menu: A view partial supplied as ' . 'an array must contain two values: partial view ' . 'script and module where script can be found');
             $e->setView($this->view);
             throw $e;
         }
         return $this->view->partial($partial[0], $partial[1], $model);
     }
     return $this->view->partial($partial, null, $model);
 }
Example #8
0
 /**
  * Returns the helper matching $proxy
  *
  * The helper must implement the interface
  * {@link IfwPsn_Vendor_Zend_View_Helper_Navigation_Helper}.
  *
  * @param string $proxy                        helper name
  * @param bool   $strict                       [optional] whether
  *                                             exceptions should be
  *                                             thrown if something goes
  *                                             wrong. Default is true.
  * @return IfwPsn_Vendor_Zend_View_Helper_Navigation_Helper  helper instance
  * @throws IfwPsn_Vendor_Zend_Loader_PluginLoader_Exception  if $strict is true and
  *                                             helper cannot be found
  * @throws IfwPsn_Vendor_Zend_View_Exception                 if $strict is true and
  *                                             helper does not implement
  *                                             the specified interface
  */
 public function findHelper($proxy, $strict = true)
 {
     if (isset($this->_helpers[$proxy])) {
         return $this->_helpers[$proxy];
     }
     if (!$this->view->getPluginLoader('helper')->getPaths(self::NS)) {
         // Add navigation helper path at the beginning
         $paths = $this->view->getHelperPaths();
         $this->view->setHelperPath(null);
         $this->view->addHelperPath(str_replace('_', '/', self::NS), self::NS);
         foreach ($paths as $ns => $path) {
             $this->view->addHelperPath($path, $ns);
         }
     }
     if ($strict) {
         $helper = $this->view->getHelper($proxy);
     } else {
         try {
             $helper = $this->view->getHelper($proxy);
         } catch (IfwPsn_Vendor_Zend_Loader_PluginLoader_Exception $e) {
             return null;
         }
     }
     if (!$helper instanceof IfwPsn_Vendor_Zend_View_Helper_Navigation_Helper) {
         if ($strict) {
             require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
             $e = new IfwPsn_Vendor_Zend_View_Exception(sprintf('Proxy helper "%s" is not an instance of ' . 'IfwPsn_Vendor_Zend_View_Helper_Navigation_Helper', get_class($helper)));
             $e->setView($this->view);
             throw $e;
         }
         return null;
     }
     $this->_inject($helper);
     $this->_helpers[$proxy] = $helper;
     return $helper;
 }
Example #9
0
 /**
  * Returns the set locale for translations
  *
  * @throws IfwPsn_Vendor_Zend_View_Exception When no IfwPsn_Vendor_Zend_Translate instance was set
  * @return string|IfwPsn_Vendor_Zend_Locale
  */
 public function getLocale()
 {
     $translate = $this->getTranslator();
     if ($translate === null) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
         $e = new IfwPsn_Vendor_Zend_View_Exception('You must set an instance of IfwPsn_Vendor_Zend_Translate or IfwPsn_Vendor_Zend_Translate_Adapter');
         $e->setView($this->view);
         throw $e;
     }
     return $translate->getLocale();
 }
Example #10
0
 /**
  * Overload
  *
  * Proxy to container methods
  *
  * @param  string $method
  * @param  array $args
  * @return mixed
  */
 public function __call($method, $args)
 {
     $container = $this->getContainer();
     if (method_exists($container, $method)) {
         $return = call_user_func_array(array($container, $method), $args);
         if ($return === $container) {
             // If the container is returned, we really want the current object
             return $this;
         }
         return $return;
     }
     require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
     $e = new IfwPsn_Vendor_Zend_View_Exception('Method "' . $method . '" does not exist');
     $e->setView($this->view);
     throw $e;
 }
Example #11
0
 /**
  * Set or retrieve doctype
  *
  * @param  string $doctype
  * @return IfwPsn_Vendor_Zend_View_Helper_Doctype
  */
 public function doctype($doctype = null)
 {
     if (null !== $doctype) {
         switch ($doctype) {
             case self::XHTML11:
             case self::XHTML1_STRICT:
             case self::XHTML1_TRANSITIONAL:
             case self::XHTML1_FRAMESET:
             case self::XHTML_BASIC1:
             case self::XHTML1_RDFA:
             case self::XHTML1_RDFA11:
             case self::XHTML5:
             case self::HTML4_STRICT:
             case self::HTML4_LOOSE:
             case self::HTML4_FRAMESET:
             case self::HTML5:
                 $this->setDoctype($doctype);
                 break;
             default:
                 if (substr($doctype, 0, 9) != '<!DOCTYPE') {
                     require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
                     $e = new IfwPsn_Vendor_Zend_View_Exception('The specified doctype is malformed');
                     $e->setView($this->view);
                     throw $e;
                 }
                 if (stristr($doctype, 'xhtml')) {
                     $type = self::CUSTOM_XHTML;
                 } else {
                     $type = self::CUSTOM;
                 }
                 $this->setDoctype($type);
                 $this->_registry['doctypes'][$type] = $doctype;
                 break;
         }
     }
     return $this;
 }
Example #12
0
 /**
  * Create item for alternate link item
  *
  * @param  array $args
  * @return stdClass
  */
 public function createDataAlternate(array $args)
 {
     if (3 > count($args)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
         $e = new IfwPsn_Vendor_Zend_View_Exception(sprintf('Alternate tags require 3 arguments; %s provided', count($args)));
         $e->setView($this->view);
         throw $e;
     }
     $rel = 'alternate';
     $href = array_shift($args);
     $type = array_shift($args);
     $title = array_shift($args);
     if (0 < count($args) && is_array($args[0])) {
         $extras = array_shift($args);
         $extras = (array) $extras;
         if (isset($extras['media']) && is_array($extras['media'])) {
             $extras['media'] = implode(',', $extras['media']);
         }
     }
     $href = (string) $href;
     $type = (string) $type;
     $title = (string) $title;
     $attributes = compact('rel', 'href', 'type', 'title', 'extras');
     return $this->createData($this->_applyExtras($attributes));
 }
Example #13
0
 /**
  * Build meta HTML string
  *
  * @param  string $type
  * @param  string $typeValue
  * @param  string $content
  * @param  array $modifiers
  * @return string
  */
 public function itemToString(stdClass $item)
 {
     if (!in_array($item->type, $this->_typeKeys)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
         $e = new IfwPsn_Vendor_Zend_View_Exception(sprintf('Invalid type "%s" provided for meta', $item->type));
         $e->setView($this->view);
         throw $e;
     }
     $type = $item->type;
     $modifiersString = '';
     foreach ($item->modifiers as $key => $value) {
         if (!is_null($this->view) && $this->view->doctype()->isHtml5() && $key == 'scheme') {
             require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
             throw new IfwPsn_Vendor_Zend_View_Exception('Invalid modifier ' . '"scheme" provided; not supported by HTML5');
         }
         if (!in_array($key, $this->_modifierKeys)) {
             continue;
         }
         $modifiersString .= $key . '="' . $this->_escape($value) . '" ';
     }
     if ($this->view instanceof IfwPsn_Vendor_Zend_View_Abstract) {
         if ($this->view->doctype()->isHtml5() && $type == 'charset') {
             $tpl = $this->view->doctype()->isXhtml() ? '<meta %s="%s"/>' : '<meta %s="%s">';
         } elseif ($this->view->doctype()->isXhtml()) {
             $tpl = '<meta %s="%s" content="%s" %s/>';
         } else {
             $tpl = '<meta %s="%s" content="%s" %s>';
         }
     } else {
         $tpl = '<meta %s="%s" content="%s" %s/>';
     }
     $meta = sprintf($tpl, $type, $this->_escape($item->{$type}), $this->_escape($item->content), $modifiersString);
     if (isset($item->modifiers['conditional']) && !empty($item->modifiers['conditional']) && is_string($item->modifiers['conditional'])) {
         $meta = '<!--[if ' . $this->_escape($item->modifiers['conditional']) . ']>' . $meta . '<![endif]-->';
     }
     return $meta;
 }
Example #14
0
 /**
  * Finds a view script from the available directories.
  *
  * @param string $name The base name of the script.
  * @return void
  */
 protected function _script($name)
 {
     if ($this->isLfiProtectionOn() && preg_match('#\\.\\.[\\\\/]#', $name)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
         $e = new IfwPsn_Vendor_Zend_View_Exception('Requested scripts may not include parent directory traversal ("../", "..\\" notation)');
         $e->setView($this);
         throw $e;
     }
     if (0 == count($this->_path['script'])) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
         $e = new IfwPsn_Vendor_Zend_View_Exception('no view script directory set; unable to determine location for view script');
         $e->setView($this);
         throw $e;
     }
     foreach ($this->_path['script'] as $dir) {
         if (is_readable($dir . $name)) {
             return $dir . $name;
         }
     }
     require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
     $message = "script '{$name}' not found in path (" . implode(PATH_SEPARATOR, $this->_path['script']) . ")";
     $e = new IfwPsn_Vendor_Zend_View_Exception($message);
     $e->setView($this);
     throw $e;
 }
Example #15
0
 /**
  * Render the provided pages.  This checks if $view->paginator is set and,
  * if so, uses that.  Also, if no scrolling style or partial are specified,
  * the defaults will be used (if set).
  *
  * @param  IfwPsn_Vendor_Zend_Paginator (Optional) $paginator
  * @param  string $scrollingStyle (Optional) Scrolling style
  * @param  string $partial (Optional) View partial
  * @param  array|string $params (Optional) params to pass to the partial
  * @return string
  * @throws IfwPsn_Vendor_Zend_View_Exception
  */
 public function paginationControl(IfwPsn_Vendor_Zend_Paginator $paginator = null, $scrollingStyle = null, $partial = null, $params = null)
 {
     if ($paginator === null) {
         if (isset($this->view->paginator) and $this->view->paginator !== null and $this->view->paginator instanceof IfwPsn_Vendor_Zend_Paginator) {
             $paginator = $this->view->paginator;
         } else {
             /**
              * @see IfwPsn_Vendor_Zend_View_Exception
              */
             require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
             $e = new IfwPsn_Vendor_Zend_View_Exception('No paginator instance provided or incorrect type');
             $e->setView($this->view);
             throw $e;
         }
     }
     if ($partial === null) {
         if (self::$_defaultViewPartial === null) {
             /**
              * @see IfwPsn_Vendor_Zend_View_Exception
              */
             require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
             $e = new IfwPsn_Vendor_Zend_View_Exception('No view partial provided and no default set');
             $e->setView($this->view);
             throw $e;
         }
         $partial = self::$_defaultViewPartial;
     }
     $pages = get_object_vars($paginator->getPages($scrollingStyle));
     if ($params !== null) {
         $pages = array_merge($pages, (array) $params);
     }
     if (is_array($partial)) {
         if (count($partial) != 2) {
             /**
              * @see IfwPsn_Vendor_Zend_View_Exception
              */
             require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
             $e = new IfwPsn_Vendor_Zend_View_Exception('A view partial supplied as an array must contain two values: the filename and its module');
             $e->setView($this->view);
             throw $e;
         }
         if ($partial[1] !== null) {
             return $this->view->partial($partial[0], $partial[1], $pages);
         }
         $partial = $partial[0];
     }
     return $this->view->partial($partial, $pages);
 }
Example #16
0
 /**
  * Sets a translation Adapter for translation
  *
  * @param  IfwPsn_Vendor_Zend_Translate|IfwPsn_Vendor_Zend_Translate_Adapter $translate
  * @return IfwPsn_Vendor_Zend_View_Helper_HeadTitle
  */
 public function setTranslator($translate)
 {
     if ($translate instanceof IfwPsn_Vendor_Zend_Translate_Adapter) {
         $this->_translator = $translate;
     } elseif ($translate instanceof IfwPsn_Vendor_Zend_Translate) {
         $this->_translator = $translate->getAdapter();
     } else {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
         $e = new IfwPsn_Vendor_Zend_View_Exception("You must set an instance of IfwPsn_Vendor_Zend_Translate or IfwPsn_Vendor_Zend_Translate_Adapter");
         $e->setView($this->view);
         throw $e;
     }
     return $this;
 }
Example #17
0
 /**
  * Sets ACL role(s) to use when iterating pages
  *
  * Implements {@link IfwPsn_Vendor_Zend_View_Helper_Navigation_Helper::setRole()}.
  *
  * @param  mixed $role                                 [optional] role to
  *                                                     set. Expects a string,
  *                                                     an instance of type
  *                                                     {@link IfwPsn_Vendor_Zend_Acl_Role_Interface},
  *                                                     or null. Default is
  *                                                     null, which will set
  *                                                     no role.
  * @throws IfwPsn_Vendor_Zend_View_Exception                         if $role is invalid
  * @return IfwPsn_Vendor_Zend_View_Helper_Navigation_HelperAbstract  fluent interface,
  *                                                     returns self
  */
 public function setRole($role = null)
 {
     if (null === $role || is_string($role) || $role instanceof IfwPsn_Vendor_Zend_Acl_Role_Interface) {
         $this->_role = $role;
     } else {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
         $e = new IfwPsn_Vendor_Zend_View_Exception(sprintf('$role must be a string, null, or an instance of ' . 'IfwPsn_Vendor_Zend_Acl_Role_Interface; %s given', gettype($role)));
         $e->setView($this->view);
         throw $e;
     }
     return $this;
 }
Example #18
0
 /**
  * Renders the given $page as a link element, with $attrib = $relation
  *
  * @param  IfwPsn_Vendor_Zend_Navigation_Page $page      the page to render the link for
  * @param  string               $attrib    the attribute to use for $type,
  *                                         either 'rel' or 'rev'
  * @param  string               $relation  relation type, muse be one of;
  *                                         alternate, appendix, bookmark,
  *                                         chapter, contents, copyright,
  *                                         glossary, help, home, index, next,
  *                                         prev, section, start, stylesheet,
  *                                         subsection
  * @return string                          rendered link element
  * @throws IfwPsn_Vendor_Zend_View_Exception             if $attrib is invalid
  */
 public function renderLink(IfwPsn_Vendor_Zend_Navigation_Page $page, $attrib, $relation)
 {
     if (!in_array($attrib, array('rel', 'rev'))) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
         $e = new IfwPsn_Vendor_Zend_View_Exception(sprintf('Invalid relation attribute "%s", must be "rel" or "rev"', $attrib));
         $e->setView($this->view);
         throw $e;
     }
     if (!($href = $page->getHref())) {
         return '';
     }
     // TODO: add more attribs
     // http://www.w3.org/TR/html401/struct/links.html#h-12.2
     $attribs = array($attrib => $relation, 'href' => $href, 'title' => $page->getLabel());
     return '<link' . $this->_htmlAttribs($attribs) . $this->getClosingBracket();
 }
Example #19
0
 /**
  * Override set to enforce style creation
  *
  * @param  mixed $value
  * @return void
  */
 public function set($value)
 {
     if (!$this->_isValid($value)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Exception.php';
         $e = new IfwPsn_Vendor_Zend_View_Exception('Invalid value passed to set; please use setStyle()');
         $e->setView($this->view);
         throw $e;
     }
     return $this->getContainer()->set($value);
 }