PageRenderTime 208ms CodeModel.GetById 29ms RepoModel.GetById 5ms app.codeStats 0ms

/library/Zend/Tool/Framework/System/Provider/Manifest.php

https://bitbucket.org/hamidrezas/melobit
PHP | 114 lines | 62 code | 20 blank | 32 comment | 7 complexity | f394bcee5fec05bed2a0f80425608627 MD5 | raw file
Possible License(s): AGPL-1.0
  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-2012 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 24594 2012-01-05 21:27:01Z matthew $
  21. */
  22. /**
  23. * @see Zend_Tool_Framework_Registry_EnabledInterface
  24. */
  25. require_once 'Zend/Tool/Framework/Registry/EnabledInterface.php';
  26. /**
  27. * @see Zend_Tool_Framework_Provider_Interface
  28. */
  29. require_once 'Zend/Tool/Framework/Provider/Interface.php';
  30. /**
  31. * @category Zend
  32. * @package Zend_Tool
  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
  35. */
  36. class Zend_Tool_Framework_System_Provider_Manifest
  37. implements Zend_Tool_Framework_Provider_Interface, Zend_Tool_Framework_Registry_EnabledInterface
  38. {
  39. public function setRegistry(Zend_Tool_Framework_Registry_Interface $registry)
  40. {
  41. $this->_registry = $registry;
  42. }
  43. public function getName()
  44. {
  45. return 'Manifest';
  46. }
  47. public function show()
  48. {
  49. $manifestRepository = $this->_registry->getManifestRepository();
  50. $response = $this->_registry->getResponse();
  51. $metadataTree = array();
  52. $longestAttrNameLen = 50;
  53. foreach ($manifestRepository as $metadata) {
  54. $metadataType = $metadata->getType();
  55. $metadataName = $metadata->getName();
  56. $metadataAttrs = $metadata->getAttributes('attributesParent');
  57. if (!$metadataAttrs) {
  58. $metadataAttrs = '(None)';
  59. } else {
  60. $metadataAttrs = urldecode(http_build_query($metadataAttrs, null, ', '));
  61. }
  62. if (!array_key_exists($metadataType, $metadataTree)) {
  63. $metadataTree[$metadataType] = array();
  64. }
  65. if (!array_key_exists($metadataName, $metadataTree[$metadataType])) {
  66. $metadataTree[$metadataType][$metadataName] = array();
  67. }
  68. if (!array_key_exists($metadataAttrs, $metadataTree[$metadataType][$metadataName])) {
  69. $metadataTree[$metadataType][$metadataName][$metadataAttrs] = array();
  70. }
  71. $longestAttrNameLen = (strlen($metadataAttrs) > $longestAttrNameLen) ? strlen($metadataAttrs) : $longestAttrNameLen;
  72. $metadataValue = $metadata->getValue();
  73. if (is_array($metadataValue) && count($metadataValue) > 0) {
  74. $metadataValue = urldecode(http_build_query($metadataValue, null, ', '));
  75. } elseif (is_array($metadataValue)) {
  76. $metadataValue = '(empty array)';
  77. }
  78. $metadataTree[$metadataType][$metadataName][$metadataAttrs][] = $metadataValue;
  79. }
  80. foreach ($metadataTree as $metadataType => $metadatasByName) {
  81. $response->appendContent($metadataType);
  82. foreach ($metadatasByName as $metadataName => $metadatasByAttributes) {
  83. $response->appendContent(" " . $metadataName);
  84. foreach ($metadatasByAttributes as $metadataAttributeName => $metadataValues) {
  85. foreach ($metadataValues as $metadataValue) {
  86. $string = sprintf(" %-{$longestAttrNameLen}.{$longestAttrNameLen}s : ", $metadataAttributeName)
  87. . $metadataValue;
  88. $response->appendContent($string);
  89. }
  90. }
  91. }
  92. }
  93. }
  94. }