import v1.1.0_beta1 | 2009-08-21
This commit is contained in:
@ -50,7 +50,7 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
|
||||
* @var array
|
||||
*/
|
||||
protected $_mediaTypes = array(
|
||||
'all', 'aural', 'braille', 'handheld', 'print',
|
||||
'all', 'aural', 'braille', 'handheld', 'print',
|
||||
'projection', 'screen', 'tty', 'tv'
|
||||
);
|
||||
|
||||
@ -76,7 +76,7 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
|
||||
* Constructor
|
||||
*
|
||||
* Set separator to PHP_EOL.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
@ -84,11 +84,11 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
|
||||
parent::__construct();
|
||||
$this->setSeparator(PHP_EOL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return headStyle object
|
||||
*
|
||||
* Returns headStyle helper object; optionally, allows specifying
|
||||
* Returns headStyle helper object; optionally, allows specifying
|
||||
*
|
||||
* @param string $content Stylesheet contents
|
||||
* @param string $placement Append, prepend, or set
|
||||
@ -124,9 +124,9 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
|
||||
* - offsetSetStyle($index, $content, $attributes = array())
|
||||
* - prependStyle($content, $attributes = array())
|
||||
* - setStyle($content, $attributes = array())
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $args
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $args
|
||||
* @return void
|
||||
* @throws Zend_View_Exception When no $content provided or invalid method
|
||||
*/
|
||||
@ -171,9 +171,9 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
|
||||
|
||||
/**
|
||||
* Determine if a value is a valid style tag
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param string $method
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param string $method
|
||||
* @return boolean
|
||||
*/
|
||||
protected function _isValid($value)
|
||||
@ -190,8 +190,8 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
|
||||
|
||||
/**
|
||||
* Override append to enforce style creation
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function append($value)
|
||||
@ -203,12 +203,12 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
|
||||
|
||||
return $this->getContainer()->append($value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Override offsetSet to enforce style creation
|
||||
*
|
||||
*
|
||||
* @param string|int $index
|
||||
* @param mixed $value
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($index, $value)
|
||||
@ -223,8 +223,8 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
|
||||
|
||||
/**
|
||||
* Override prepend to enforce style creation
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function prepend($value)
|
||||
@ -239,8 +239,8 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
|
||||
|
||||
/**
|
||||
* Override set to enforce style creation
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function set($value)
|
||||
@ -255,9 +255,9 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
|
||||
|
||||
/**
|
||||
* Start capture action
|
||||
*
|
||||
* @param mixed $captureType
|
||||
* @param string $typeOrAttrs
|
||||
*
|
||||
* @param mixed $captureType
|
||||
* @param string $typeOrAttrs
|
||||
* @return void
|
||||
*/
|
||||
public function captureStart($type = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $attrs = null)
|
||||
@ -272,10 +272,10 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
|
||||
$this->_captureType = $type;
|
||||
ob_start();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* End capture action and store
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function captureEnd()
|
||||
@ -301,9 +301,9 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
|
||||
|
||||
/**
|
||||
* Convert content and attributes into valid style tag
|
||||
*
|
||||
*
|
||||
* @param stdClass $item Item to render
|
||||
* @param string $indent Indentation to use
|
||||
* @param string $indent Indentation to use
|
||||
* @return string
|
||||
*/
|
||||
public function itemToString(stdClass $item, $indent)
|
||||
@ -315,8 +315,20 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
|
||||
continue;
|
||||
}
|
||||
if ('media' == $key) {
|
||||
if (!in_array($value, $this->_mediaTypes)) {
|
||||
continue;
|
||||
if(false === strpos($value, ',')) {
|
||||
if (!in_array($value, $this->_mediaTypes)) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
$media_types = explode(',', $value);
|
||||
$value = '';
|
||||
foreach($media_types as $type) {
|
||||
if (!in_array($type, $this->_mediaTypes)) {
|
||||
continue;
|
||||
}
|
||||
$value .= $type .',';
|
||||
}
|
||||
$value = substr($value, 0, -1);
|
||||
}
|
||||
}
|
||||
$attrString .= sprintf(' %s="%s"', $key, htmlspecialchars($value));
|
||||
@ -327,13 +339,20 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
|
||||
. $indent . '<!--' . PHP_EOL . $indent . $item->content . PHP_EOL . $indent . '-->' . PHP_EOL
|
||||
. '</style>';
|
||||
|
||||
if (isset($item->attributes['conditional'])
|
||||
&& !empty($item->attributes['conditional'])
|
||||
&& is_string($item->attributes['conditional']))
|
||||
{
|
||||
$html = '<!--[if ' . $item->attributes['conditional'] . ']> ' . $html . '<![endif]-->';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create string representation of placeholder
|
||||
*
|
||||
* @param string|int $indent
|
||||
*
|
||||
* @param string|int $indent
|
||||
* @return string
|
||||
*/
|
||||
public function toString($indent = null)
|
||||
@ -343,6 +362,7 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
|
||||
: $this->getIndent();
|
||||
|
||||
$items = array();
|
||||
$this->getContainer()->ksort();
|
||||
foreach ($this as $item) {
|
||||
if (!$this->_isValid($item)) {
|
||||
continue;
|
||||
@ -357,15 +377,17 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
|
||||
|
||||
/**
|
||||
* Create data item for use in stack
|
||||
*
|
||||
* @param string $content
|
||||
* @param array $attributes
|
||||
*
|
||||
* @param string $content
|
||||
* @param array $attributes
|
||||
* @return stdClass
|
||||
*/
|
||||
public function createData($content, array $attributes)
|
||||
{
|
||||
if (!isset($attributes['media'])) {
|
||||
$attributes['media'] = 'screen';
|
||||
} else if(is_array($attributes['media'])) {
|
||||
$attributes['media'] = implode(',', $attributes['media']);
|
||||
}
|
||||
|
||||
$data = new stdClass();
|
||||
|
Reference in New Issue
Block a user