CommunityID/libs/Zend/Tool/Framework/System/Provider/Version.php

112 lines
3.4 KiB
PHP
Raw Permalink Normal View History

2019-07-17 20:16:19 +00:00
<?php
2019-07-17 20:19:00 +00:00
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Tool
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Version.php 18951 2009-11-12 16:26:19Z alexander $
2019-07-17 20:19:00 +00:00
*/
2019-07-17 20:16:19 +00:00
require_once 'Zend/Tool/Framework/Registry.php';
require_once 'Zend/Tool/Framework/Provider/Interface.php';
require_once 'Zend/Version.php';
/**
* Version Provider
*
2019-07-17 20:19:00 +00:00
* @category Zend
* @package Zend_Tool
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
2019-07-17 20:16:19 +00:00
*/
class Zend_Tool_Framework_System_Provider_Version
2019-07-17 20:16:19 +00:00
implements Zend_Tool_Framework_Provider_Interface, Zend_Tool_Framework_Registry_EnabledInterface
{
/**
* @var Zend_Tool_Framework_Registry_Interface
*/
protected $_registry = null;
2019-07-17 20:16:19 +00:00
const MODE_MAJOR = 'major';
const MODE_MINOR = 'minor';
const MODE_MINI = 'mini';
protected $_specialties = array('MajorPart', 'MinorPart', 'MiniPart');
public function setRegistry(Zend_Tool_Framework_Registry_Interface $registry)
{
$this->_registry = $registry;
return $this;
}
2019-07-17 20:16:19 +00:00
/**
* Show Action
*
* @param string $mode The mode switch can be one of: major, minor, or mini (default)
* @param bool $nameincluded
*/
public function show($mode = self::MODE_MINI, $nameIncluded = true)
{
$versionInfo = $this->_splitVersion();
switch($mode) {
case self::MODE_MINOR:
unset($versionInfo['mini']);
break;
case self::MODE_MAJOR:
unset($versionInfo['mini'], $versionInfo['minor']);
break;
}
$output = implode('.', $versionInfo);
if ($nameIncluded) {
$output = 'Zend Framework Version: ' . $output;
}
$this->_registry->response->appendContent($output);
}
public function showMajorPart($nameIncluded = true)
{
$versionNumbers = $this->_splitVersion();
$output = (($nameIncluded == true) ? 'ZF Major Version: ' : null) . $versionNumbers['major'];
$this->_registry->response->appendContent($output);
}
public function showMinorPart($nameIncluded = true)
{
$versionNumbers = $this->_splitVersion();
$output = (($nameIncluded == true) ? 'ZF Minor Version: ' : null) . $versionNumbers['minor'];
$this->_registry->response->appendContent($output);
}
public function showMiniPart($nameIncluded = true)
{
$versionNumbers = $this->_splitVersion();
$output = (($nameIncluded == true) ? 'ZF Mini Version: ' : null) . $versionNumbers['mini'];
$this->_registry->response->appendContent($output);
}
protected function _splitVersion()
{
list($major, $minor, $mini) = explode('.', Zend_Version::VERSION);
return array('major' => $major, 'minor' => $minor, 'mini' => $mini);
}
}