import v1.1.0_beta1 | 2009-08-21
This commit is contained in:
88
libs/Zend/Tool/Framework/System/Provider/Version.php
Normal file
88
libs/Zend/Tool/Framework/System/Provider/Version.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
require_once 'Zend/Tool/Framework/Registry.php';
|
||||
require_once 'Zend/Tool/Framework/Provider/Interface.php';
|
||||
require_once 'Zend/Version.php';
|
||||
|
||||
/**
|
||||
* Version Provider
|
||||
*
|
||||
*/
|
||||
class Zend_Tool_Framework_System_Provider_Version
|
||||
implements Zend_Tool_Framework_Provider_Interface, Zend_Tool_Framework_Registry_EnabledInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Zend_Tool_Framework_Registry_Interface
|
||||
*/
|
||||
protected $_registry = null;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user