web/lib/Zend/View/Helper/HeadLink.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_View
    16  * @package    Zend_View
    17  * @subpackage Helper
    17  * @subpackage Helper
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @version    $Id: HeadLink.php 23249 2010-10-26 12:46:47Z matthew $
    19  * @version    $Id: HeadLink.php 24858 2012-06-01 01:24:17Z adamlundrigan $
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    21  */
    21  */
    22 
    22 
    23 /** Zend_View_Helper_Placeholder_Container_Standalone */
    23 /** Zend_View_Helper_Placeholder_Container_Standalone */
    24 require_once 'Zend/View/Helper/Placeholder/Container/Standalone.php';
    24 require_once 'Zend/View/Helper/Placeholder/Container/Standalone.php';
    28  *
    28  *
    29  * @see        http://www.w3.org/TR/xhtml1/dtds.html
    29  * @see        http://www.w3.org/TR/xhtml1/dtds.html
    30  * @uses       Zend_View_Helper_Placeholder_Container_Standalone
    30  * @uses       Zend_View_Helper_Placeholder_Container_Standalone
    31  * @package    Zend_View
    31  * @package    Zend_View
    32  * @subpackage Helper
    32  * @subpackage Helper
    33  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    33  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    34  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    34  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    35  */
    35  */
    36 class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_Standalone
    36 class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_Standalone
    37 {
    37 {
    38     /**
    38     /**
    39      * $_validAttributes
    39      * $_validAttributes
    40      *
    40      *
    41      * @var array
    41      * @var array
    42      */
    42      */
    43     protected $_itemKeys = array('charset', 'href', 'hreflang', 'id', 'media', 'rel', 'rev', 'type', 'title', 'extras');
    43     protected $_itemKeys = array(
       
    44         'charset',
       
    45         'href',
       
    46         'hreflang',
       
    47         'id',
       
    48         'media',
       
    49         'rel',
       
    50         'rev',
       
    51         'type',
       
    52         'title',
       
    53         'extras',
       
    54         'sizes',
       
    55     );
    44 
    56 
    45     /**
    57     /**
    46      * @var string registry key
    58      * @var string registry key
    47      */
    59      */
    48     protected $_regKey = 'Zend_View_Helper_HeadLink';
    60     protected $_regKey = 'Zend_View_Helper_HeadLink';
   377             $extras = array_shift($args);
   389             $extras = array_shift($args);
   378             $extras = (array) $extras;
   390             $extras = (array) $extras;
   379         }
   391         }
   380 
   392 
   381         $attributes = compact('rel', 'type', 'href', 'media', 'conditionalStylesheet', 'extras');
   393         $attributes = compact('rel', 'type', 'href', 'media', 'conditionalStylesheet', 'extras');
   382         return $this->createData($attributes);
   394         return $this->createData($this->_applyExtras($attributes));
   383     }
   395     }
   384 
   396 
   385     /**
   397     /**
   386      * Is the linked stylesheet a duplicate?
   398      * Is the linked stylesheet a duplicate?
   387      *
   399      *
   430         $href  = (string) $href;
   442         $href  = (string) $href;
   431         $type  = (string) $type;
   443         $type  = (string) $type;
   432         $title = (string) $title;
   444         $title = (string) $title;
   433 
   445 
   434         $attributes = compact('rel', 'href', 'type', 'title', 'extras');
   446         $attributes = compact('rel', 'href', 'type', 'title', 'extras');
   435         return $this->createData($attributes);
   447         return $this->createData($this->_applyExtras($attributes));
       
   448     }
       
   449 
       
   450     /**
       
   451      * Apply any overrides specified in the 'extras' array
       
   452      * @param array $attributes
       
   453      * @return array
       
   454      */
       
   455     protected function _applyExtras($attributes)
       
   456     {
       
   457         if (isset($attributes['extras'])) {
       
   458             foreach ($attributes['extras'] as $eKey=>$eVal) {
       
   459                 if (isset($attributes[$eKey])) {
       
   460                     $attributes[$eKey] = $eVal;
       
   461                     unset($attributes['extras'][$eKey]);
       
   462                 }
       
   463             }
       
   464         }
       
   465         return $attributes;
   436     }
   466     }
   437 }
   467 }