From 6a1b226cdb3a86fd7d2969e4c8a594e47f1db5e3 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Mon, 20 May 2013 23:59:41 +0200 Subject: [PATCH] code style and UI improvements to requirements checker also changed PHP Intl support to optional. --- yii/requirements/YiiRequirementChecker.php | 32 +++++++++++++++--------------- yii/requirements/requirements.php | 6 +++--- yii/requirements/views/web/index.php | 26 +++++++++++++++++------- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/yii/requirements/YiiRequirementChecker.php b/yii/requirements/YiiRequirementChecker.php index 03413d1..160a5db 100644 --- a/yii/requirements/YiiRequirementChecker.php +++ b/yii/requirements/YiiRequirementChecker.php @@ -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 * ) * */ - 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; diff --git a/yii/requirements/requirements.php b/yii/requirements/requirements.php index 125ff60..846eafc 100644 --- a/yii/requirements/requirements.php +++ b/yii/requirements/requirements.php @@ -1,6 +1,6 @@ 'Intl extension', - 'mandatory' => true, + 'mandatory' => false, 'condition' => $this->checkPhpExtensionVersion('intl', '1.0.2'), 'by' => 'Internationalization 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 IDN-feature of EmailValidator or UrlValidator.' ), ); \ No newline at end of file diff --git a/yii/requirements/views/web/index.php b/yii/requirements/views/web/index.php index 2f8da15..3760e52 100644 --- a/yii/requirements/views/web/index.php +++ b/yii/requirements/views/web/index.php @@ -8,7 +8,7 @@ Yii Application Requirement Checker - renderViewFile(dirname(__FILE__).DIRECTORY_SEPARATOR.'css.php'); ?> + renderViewFile(__DIR__ . '/css.php'); ?>
@@ -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.

+

+ 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. +

Conclusion

- 0): ?> - Unfortunately your server configuration does not satisfy the requirements by this application. - 0): ?> - 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. + 0): ?> +
+ Unfortunately your server configuration does not satisfy the requirements by this application.
Please refer to the table below for detailed explanation.
+
+ 0): ?> +
+ Your server configuration satisfies the minimum requirements by this application.
Please pay attention to the warnings listed below and check if your application will use the corresponding features.
+
- Congratulations! Your server configuration satisfies all requirements. +
+ Congratulations! Your server configuration satisfies all requirements. +

Details

@@ -62,7 +74,7 @@