2 /* This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier,
3 and is published under the AGPL license. */
5 class Syj_View_Helper_HeadBase extends Zend_View_Helper_Placeholder_Container_Standalone
11 /* string to use as an indent of output */
12 protected $_indent = '';
14 public function headBase($href = null) {
15 $href = (string) $href;
17 $serverUrl = rtrim($this->view->serverUrl(), '/');
18 $baseUrl = trim($this->view->baseUrl(), '/');
19 $href = $serverUrl . '/' . ($baseUrl ? ($baseUrl . '/'): '');
25 public function toString($indent = null) {
26 $indent = (null !== $indent)
27 ? $this->getWhitespace($indent)
30 return $indent . '<base href="' . $this->href . '">';
33 /* following part of the file is copied from Zend_View_Helper_Placeholder_Container_Abstract */
36 * Retrieve whitespace representation of $indent
38 * @param int|string $indent
41 public function getWhitespace($indent)
43 if (is_int($indent)) {
44 $indent = str_repeat(' ', $indent);
47 return (string) $indent;
51 * Set the indentation string for __toString() serialization,
52 * optionally, if a number is passed, it will be the number of spaces
54 * @param string|int $indent
55 * @return Zend_View_Helper_Placeholder_Container_Abstract
57 public function setIndent($indent)
59 $this->_indent = $this->getWhitespace($indent);
64 * Retrieve indentation
68 public function getIndent()
70 return $this->_indent;