File indexing completed on 2025-01-19 05:21:36

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Tool
0017  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0018  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0019  * @version    $Id$
0020  */
0021 
0022 // require_once 'Zend/Tool/Framework/Registry.php';
0023 // require_once 'Zend/Tool/Framework/Provider/Interface.php';
0024 // require_once 'Zend/Version.php';
0025 
0026 /**
0027  * Version Provider
0028  *
0029  * @category   Zend
0030  * @package    Zend_Tool
0031  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0032  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0033  */
0034 class Zend_Tool_Framework_System_Provider_Version
0035     implements Zend_Tool_Framework_Provider_Interface, Zend_Tool_Framework_Registry_EnabledInterface
0036 {
0037 
0038     /**
0039      * @var Zend_Tool_Framework_Registry_Interface
0040      */
0041     protected $_registry = null;
0042 
0043     const MODE_MAJOR = 'major';
0044     const MODE_MINOR = 'minor';
0045     const MODE_MINI  = 'mini';
0046 
0047     protected $_specialties = array('MajorPart', 'MinorPart', 'MiniPart');
0048 
0049     public function setRegistry(Zend_Tool_Framework_Registry_Interface $registry)
0050     {
0051         $this->_registry = $registry;
0052         return $this;
0053     }
0054 
0055     /**
0056      * Show Action
0057      *
0058      * @param string $mode The mode switch can be one of: major, minor, or mini (default)
0059      * @param bool $nameIncluded
0060      */
0061     public function show($mode = self::MODE_MINI, $nameIncluded = true)
0062     {
0063 
0064         $versionInfo = $this->_splitVersion();
0065 
0066         switch($mode) {
0067             case self::MODE_MINOR:
0068                 unset($versionInfo['mini']);
0069                 break;
0070             case self::MODE_MAJOR:
0071                 unset($versionInfo['mini'], $versionInfo['minor']);
0072                 break;
0073         }
0074 
0075         $output = implode('.', $versionInfo);
0076 
0077         if ($nameIncluded) {
0078             $output = 'Zend Framework Version: ' . $output;
0079         }
0080 
0081         $this->_registry->response->appendContent($output);
0082     }
0083 
0084     public function showMajorPart($nameIncluded = true)
0085     {
0086         $versionNumbers = $this->_splitVersion();
0087         $output = (($nameIncluded == true) ? 'ZF Major Version: ' : null) . $versionNumbers['major'];
0088         $this->_registry->response->appendContent($output);
0089     }
0090 
0091     public function showMinorPart($nameIncluded = true)
0092     {
0093         $versionNumbers = $this->_splitVersion();
0094         $output = (($nameIncluded == true) ? 'ZF Minor Version: ' : null) . $versionNumbers['minor'];
0095         $this->_registry->response->appendContent($output);
0096     }
0097 
0098     public function showMiniPart($nameIncluded = true)
0099     {
0100         $versionNumbers = $this->_splitVersion();
0101         $output = (($nameIncluded == true) ? 'ZF Mini Version: ' : null)  . $versionNumbers['mini'];
0102         $this->_registry->response->appendContent($output);
0103     }
0104 
0105     protected function _splitVersion()
0106     {
0107         list($major, $minor, $mini) = explode('.', Zend_Version::VERSION);
0108         return array('major' => $major, 'minor' => $minor, 'mini' => $mini);
0109     }
0110 
0111 }