adding zend project folders into old campcaster.
This commit is contained in:
parent
56abfaf28e
commit
7ef0c18b26
4045 changed files with 1054952 additions and 0 deletions
181
library/Zend/View/Helper/HeadTitle.php
Normal file
181
library/Zend/View/Helper/HeadTitle.php
Normal file
|
@ -0,0 +1,181 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_View
|
||||
* @subpackage Helper
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @version $Id: HeadTitle.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
/** Zend_View_Helper_Placeholder_Container_Standalone */
|
||||
require_once 'Zend/View/Helper/Placeholder/Container/Standalone.php';
|
||||
|
||||
/**
|
||||
* Helper for setting and retrieving title element for HTML head
|
||||
*
|
||||
* @uses Zend_View_Helper_Placeholder_Container_Standalone
|
||||
* @package Zend_View
|
||||
* @subpackage Helper
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_View_Helper_HeadTitle extends Zend_View_Helper_Placeholder_Container_Standalone
|
||||
{
|
||||
/**
|
||||
* Registry key for placeholder
|
||||
* @var string
|
||||
*/
|
||||
protected $_regKey = 'Zend_View_Helper_HeadTitle';
|
||||
|
||||
/**
|
||||
* Whether or not auto-translation is enabled
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_translate = false;
|
||||
|
||||
/**
|
||||
* Translation object
|
||||
*
|
||||
* @var Zend_Translate_Adapter
|
||||
*/
|
||||
protected $_translator;
|
||||
|
||||
/**
|
||||
* Retrieve placeholder for title element and optionally set state
|
||||
*
|
||||
* @param string $title
|
||||
* @param string $setType
|
||||
* @param string $separator
|
||||
* @return Zend_View_Helper_HeadTitle
|
||||
*/
|
||||
public function headTitle($title = null, $setType = Zend_View_Helper_Placeholder_Container_Abstract::APPEND)
|
||||
{
|
||||
$title = (string) $title;
|
||||
if ($title !== '') {
|
||||
if ($setType == Zend_View_Helper_Placeholder_Container_Abstract::SET) {
|
||||
$this->set($title);
|
||||
} elseif ($setType == Zend_View_Helper_Placeholder_Container_Abstract::PREPEND) {
|
||||
$this->prepend($title);
|
||||
} else {
|
||||
$this->append($title);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a translation Adapter for translation
|
||||
*
|
||||
* @param Zend_Translate|Zend_Translate_Adapter $translate
|
||||
* @return Zend_View_Helper_HeadTitle
|
||||
*/
|
||||
public function setTranslator($translate)
|
||||
{
|
||||
if ($translate instanceof Zend_Translate_Adapter) {
|
||||
$this->_translator = $translate;
|
||||
} elseif ($translate instanceof Zend_Translate) {
|
||||
$this->_translator = $translate->getAdapter();
|
||||
} else {
|
||||
require_once 'Zend/View/Exception.php';
|
||||
$e = new Zend_View_Exception("You must set an instance of Zend_Translate or Zend_Translate_Adapter");
|
||||
$e->setView($this->view);
|
||||
throw $e;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve translation object
|
||||
*
|
||||
* If none is currently registered, attempts to pull it from the registry
|
||||
* using the key 'Zend_Translate'.
|
||||
*
|
||||
* @return Zend_Translate_Adapter|null
|
||||
*/
|
||||
public function getTranslator()
|
||||
{
|
||||
if (null === $this->_translator) {
|
||||
require_once 'Zend/Registry.php';
|
||||
if (Zend_Registry::isRegistered('Zend_Translate')) {
|
||||
$this->setTranslator(Zend_Registry::get('Zend_Translate'));
|
||||
}
|
||||
}
|
||||
return $this->_translator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables translation
|
||||
*
|
||||
* @return Zend_View_Helper_HeadTitle
|
||||
*/
|
||||
public function enableTranslation()
|
||||
{
|
||||
$this->_translate = true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables translation
|
||||
*
|
||||
* @return Zend_View_Helper_HeadTitle
|
||||
*/
|
||||
public function disableTranslation()
|
||||
{
|
||||
$this->_translate = false;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn helper into string
|
||||
*
|
||||
* @param string|null $indent
|
||||
* @param string|null $locale
|
||||
* @return string
|
||||
*/
|
||||
public function toString($indent = null, $locale = null)
|
||||
{
|
||||
$indent = (null !== $indent)
|
||||
? $this->getWhitespace($indent)
|
||||
: $this->getIndent();
|
||||
|
||||
$items = array();
|
||||
|
||||
if($this->_translate && $translator = $this->getTranslator()) {
|
||||
foreach ($this as $item) {
|
||||
$items[] = $translator->translate($item, $locale);
|
||||
}
|
||||
} else {
|
||||
foreach ($this as $item) {
|
||||
$items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
$separator = $this->getSeparator();
|
||||
$output = '';
|
||||
if(($prefix = $this->getPrefix())) {
|
||||
$output .= $prefix;
|
||||
}
|
||||
$output .= implode($separator, $items);
|
||||
if(($postfix = $this->getPostfix())) {
|
||||
$output .= $postfix;
|
||||
}
|
||||
|
||||
$output = ($this->_autoEscape) ? $this->_escape($output) : $output;
|
||||
|
||||
return $indent . '<title>' . $output . '</title>';
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue