web/Zend/Tool/Framework/System/Provider/Manifest.php
changeset 0 4eba9c11703f
equal deleted inserted replaced
-1:000000000000 0:4eba9c11703f
       
     1 <?php
       
     2 /**
       
     3  * Zend Framework
       
     4  *
       
     5  * LICENSE
       
     6  *
       
     7  * This source file is subject to the new BSD license that is bundled
       
     8  * with this package in the file LICENSE.txt.
       
     9  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_Tool
       
    17  * @subpackage Framework
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  * @version    $Id: Manifest.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    21  */
       
    22 
       
    23 /**
       
    24  * @see Zend_Tool_Framework_Registry_EnabledInterface
       
    25  */
       
    26 require_once 'Zend/Tool/Framework/Registry/EnabledInterface.php';
       
    27 
       
    28 /**
       
    29  * @see Zend_Tool_Framework_Provider_Interface
       
    30  */
       
    31 require_once 'Zend/Tool/Framework/Provider/Interface.php';
       
    32 
       
    33 /**
       
    34  * @category   Zend
       
    35  * @package    Zend_Tool
       
    36  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    37  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    38  */
       
    39 class Zend_Tool_Framework_System_Provider_Manifest
       
    40     implements Zend_Tool_Framework_Provider_Interface, Zend_Tool_Framework_Registry_EnabledInterface
       
    41 {
       
    42 
       
    43     public function setRegistry(Zend_Tool_Framework_Registry_Interface $registry)
       
    44     {
       
    45         $this->_registry = $registry;
       
    46     }
       
    47 
       
    48     public function getName()
       
    49     {
       
    50         return 'Manifest';
       
    51     }
       
    52 
       
    53     public function show()
       
    54     {
       
    55 
       
    56         $manifestRepository = $this->_registry->getManifestRepository();
       
    57         $response           = $this->_registry->getResponse();
       
    58 
       
    59         $metadataTree = array();
       
    60 
       
    61         $longestAttrNameLen = 50;
       
    62 
       
    63         foreach ($manifestRepository as $metadata) {
       
    64 
       
    65             $metadataType  = $metadata->getType();
       
    66             $metadataName  = $metadata->getName();
       
    67             $metadataAttrs = $metadata->getAttributes('attributesParent');
       
    68 
       
    69             if (!$metadataAttrs) {
       
    70                 $metadataAttrs = '(None)';
       
    71             } else {
       
    72                 $metadataAttrs = urldecode(http_build_query($metadataAttrs, null, ', '));
       
    73             }
       
    74 
       
    75             if (!array_key_exists($metadataType, $metadataTree)) {
       
    76                 $metadataTree[$metadataType] = array();
       
    77             }
       
    78 
       
    79             if (!array_key_exists($metadataName, $metadataTree[$metadataType])) {
       
    80                 $metadataTree[$metadataType][$metadataName] = array();
       
    81             }
       
    82 
       
    83             if (!array_key_exists($metadataAttrs, $metadataTree[$metadataType][$metadataName])) {
       
    84                 $metadataTree[$metadataType][$metadataName][$metadataAttrs] = array();
       
    85             }
       
    86 
       
    87             $longestAttrNameLen = (strlen($metadataAttrs) > $longestAttrNameLen) ? strlen($metadataAttrs) : $longestAttrNameLen;
       
    88 
       
    89             $metadataValue = $metadata->getValue();
       
    90             if (is_array($metadataValue) && count($metadataValue) > 0) {
       
    91                 $metadataValue = urldecode(http_build_query($metadataValue, null, ', '));
       
    92             } elseif (is_array($metadataValue)) {
       
    93                 $metadataValue = '(empty array)';
       
    94             }
       
    95 
       
    96             $metadataTree[$metadataType][$metadataName][$metadataAttrs][] = $metadataValue;
       
    97         }
       
    98 
       
    99         foreach ($metadataTree as $metadataType => $metadatasByName) {
       
   100             $response->appendContent($metadataType);
       
   101             foreach ($metadatasByName as $metadataName => $metadatasByAttributes) {
       
   102                 $response->appendContent("   " . $metadataName);
       
   103                 foreach ($metadatasByAttributes as $metadataAttributeName => $metadataValues) {
       
   104                     foreach ($metadataValues as $metadataValue) {
       
   105                         $string = sprintf("      %-{$longestAttrNameLen}.{$longestAttrNameLen}s : ", $metadataAttributeName)
       
   106                             . $metadataValue;
       
   107                         $response->appendContent($string);
       
   108                     }
       
   109                 }
       
   110             }
       
   111         }
       
   112 
       
   113     }
       
   114 }