Commit 6a1b226c by Carsten Brandt

code style and UI improvements to requirements checker

also changed PHP Intl support to optional.
parent 4ad93228
......@@ -16,7 +16,7 @@ if (version_compare(PHP_VERSION, '4.3', '<')) {
*
* Example:
*
* ~~~
* ~~~php
* require_once('path/to/YiiRequirementChecker.php');
* $requirementsChecker = new YiiRequirementChecker();
* $requirements = array(
......@@ -62,7 +62,7 @@ class YiiRequirementChecker
* If a string, it is treated as the path of the file, which contains the requirements;
* @return YiiRequirementChecker self instance.
*/
function check($requirements)
public function check($requirements)
{
if (is_string($requirements)) {
$requirements = require($requirements);
......@@ -132,7 +132,7 @@ class YiiRequirementChecker
* )
* </code>
*/
function getResult()
public function getResult()
{
if (isset($this->result)) {
return $this->result;
......@@ -145,7 +145,7 @@ class YiiRequirementChecker
* Renders the requirements check result.
* The output will vary depending is a script running from web or from console.
*/
function render()
public function render()
{
if (!isset($this->result)) {
$this->usageError('Nothing to render!');
......@@ -166,7 +166,7 @@ class YiiRequirementChecker
* @param string $compare comparison operator, by default '>='
* @return boolean if PHP extension version matches.
*/
function checkPhpExtensionVersion($extensionName, $version, $compare = '>=')
public function checkPhpExtensionVersion($extensionName, $version, $compare = '>=')
{
if (!extension_loaded($extensionName)) {
return false;
......@@ -183,7 +183,7 @@ class YiiRequirementChecker
* @param string $name configuration option name.
* @return boolean option is on.
*/
function checkPhpIniOn($name)
public function checkPhpIniOn($name)
{
$value = ini_get($name);
if (empty($value)) {
......@@ -197,7 +197,7 @@ class YiiRequirementChecker
* @param string $name configuration option name.
* @return boolean option is off.
*/
function checkPhpIniOff($name)
public function checkPhpIniOff($name)
{
$value = ini_get($name);
if (empty($value)) {
......@@ -214,7 +214,7 @@ class YiiRequirementChecker
* @param string $compare comparison operator, by default '>='.
* @return boolean comparison result.
*/
function compareByteSize($a, $b, $compare = '>=')
public function compareByteSize($a, $b, $compare = '>=')
{
$compareExpression = '(' . $this->getByteSize($a) . $compare . $this->getByteSize($b) . ')';
return $this->evaluateExpression($compareExpression);
......@@ -226,7 +226,7 @@ class YiiRequirementChecker
* @param string $verboseSize verbose size representation.
* @return integer actual size in bytes.
*/
function getByteSize($verboseSize)
public function getByteSize($verboseSize)
{
if (empty($verboseSize)) {
return 0;
......@@ -265,7 +265,7 @@ class YiiRequirementChecker
* @param string|null $max verbose file size maximum required value, pass null to skip maximum check.
* @return boolean success.
*/
function checkUploadMaxFileSize($min = null, $max = null)
public function checkUploadMaxFileSize($min = null, $max = null)
{
$postMaxSize = ini_get('post_max_size');
$uploadMaxFileSize = ini_get('upload_max_filesize');
......@@ -292,7 +292,7 @@ class YiiRequirementChecker
* @param boolean $_return_ whether the rendering result should be returned as a string
* @return string the rendering result. Null if the rendering result is not required.
*/
function renderViewFile($_viewFile_, $_data_ = null, $_return_ = false)
public function renderViewFile($_viewFile_, $_data_ = null, $_return_ = false)
{
// we use special variable names here to avoid conflict when extracting data
if (is_array($_data_)) {
......@@ -316,7 +316,7 @@ class YiiRequirementChecker
* @param int $requirementKey requirement key in the list.
* @return array normalized requirement.
*/
function normalizeRequirement($requirement, $requirementKey = 0)
public function normalizeRequirement($requirement, $requirementKey = 0)
{
if (!is_array($requirement)) {
$this->usageError('Requirement must be an array!');
......@@ -354,7 +354,7 @@ class YiiRequirementChecker
* This method will then terminate the execution of the current application.
* @param string $message the error message
*/
function usageError($message)
public function usageError($message)
{
echo "Error: $message\n\n";
exit(1);
......@@ -365,7 +365,7 @@ class YiiRequirementChecker
* @param string $expression a PHP expression to be evaluated.
* @return mixed the expression result.
*/
function evaluateExpression($expression)
public function evaluateExpression($expression)
{
return eval('return ' . $expression . ';');
}
......@@ -374,7 +374,7 @@ class YiiRequirementChecker
* Returns the server information.
* @return string server information.
*/
function getServerInfo()
public function getServerInfo()
{
$info = isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '';
return $info;
......@@ -384,7 +384,7 @@ class YiiRequirementChecker
* Returns the now date if possible in string representation.
* @return string now date.
*/
function getNowDate()
public function getNowDate()
{
$nowDate = @strftime('%Y-%m-%d %H:%M', time());
return $nowDate;
......
<?php
/**
* This is the Yii core requirements for the [[YiiRequirementChecker]] instance.
* These are the Yii core requirements for the [[YiiRequirementChecker]] instance.
* These requirements are mandatory for any Yii application.
*
* @var $this YiiRequirementChecker
......@@ -40,9 +40,9 @@ return array(
),
array(
'name' => 'Intl extension',
'mandatory' => true,
'mandatory' => false,
'condition' => $this->checkPhpExtensionVersion('intl', '1.0.2'),
'by' => '<a href="http://www.php.net/manual/en/book.intl.php">Internationalization</a> support',
'memo' => 'PHP Intl extension 1.0.2 or higher is required.'
'memo' => 'PHP Intl extension 1.0.2 or higher is required when you want to use <abbr title="Internationalized domain names">IDN</abbr>-feature of EmailValidator or UrlValidator.'
),
);
\ No newline at end of file
......@@ -8,7 +8,7 @@
<head>
<meta charset="utf-8"/>
<title>Yii Application Requirement Checker</title>
<?php $this->renderViewFile(dirname(__FILE__).DIRECTORY_SEPARATOR.'css.php'); ?>
<?php $this->renderViewFile(__DIR__ . '/css.php'); ?>
</head>
<body>
<div class="container">
......@@ -25,14 +25,26 @@
It checks if the server is running the right version of PHP,
if appropriate PHP extensions have been loaded, and if php.ini file settings are correct.
</p>
<p>
There are two kinds of requirements being checked. Mandatory requirements are those that have to be met
to allow Yii to work as expected. There are also some optional requirements beeing checked which will
show you a warning when they do not meet. You can use Yii framework without them but some specific
functionality may be not available in this case.
</p>
<h3>Conclusion</h3>
<?php if ($summary['errors']>0): ?>
<strong class="text-error">Unfortunately your server configuration does not satisfy the requirements by this application.</strong>
<?php elseif ($summary['warnings']>0): ?>
<strong class="text-warning">Your server configuration satisfies the minimum requirements by this application. Please pay attention to the warnings listed below if your application will use the corresponding features.</strong>
<?php if ($summary['errors'] > 0): ?>
<div class="alert alert-error">
<strong>Unfortunately your server configuration does not satisfy the requirements by this application.<br>Please refer to the table below for detailed explanation.</strong>
</div>
<?php elseif ($summary['warnings'] > 0): ?>
<div class="alert alert-info">
<strong>Your server configuration satisfies the minimum requirements by this application.<br>Please pay attention to the warnings listed below and check if your application will use the corresponding features.</strong>
</div>
<?php else: ?>
<strong class="text-success">Congratulations! Your server configuration satisfies all requirements.</strong>
<div class="alert alert-success">
<strong>Congratulations! Your server configuration satisfies all requirements.</strong>
</div>
<?php endif; ?>
<h3>Details</h3>
......@@ -62,7 +74,7 @@
<hr>
<div class="footer">
<p>Server: <?php echo $this->getServerInfo().' '.$this->getNowDate(); ?></p>
<p>Server: <?php echo $this->getServerInfo() . ' ' . $this->getNowDate(); ?></p>
<p>Powered by <a href="http://www.yiiframework.com/" rel="external">Yii Framework</a></p>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment