mirror of
https://github.com/Mibew/mibew.git
synced 2024-11-15 16:44:11 +03:00
Move "format_version_id" func to Maintenance\Utils class
This commit is contained in:
parent
f82d42e729
commit
47851c9ed2
@ -120,7 +120,7 @@ class Installer
|
||||
}
|
||||
$this->log[] = getlocal(
|
||||
'PHP version {0}',
|
||||
array(format_version_id($this->getPhpVersionId()))
|
||||
array(Utils::formatVersionId($this->getPhpVersionId()))
|
||||
);
|
||||
|
||||
if (!$this->checkFsPermissions()) {
|
||||
@ -465,8 +465,8 @@ class Installer
|
||||
$this->errors[] = getlocal(
|
||||
"PHP version is {0}, but Mibew works with {1} and later versions.",
|
||||
array(
|
||||
format_version_id($current_version),
|
||||
format_version_id(self::MIN_PHP_VERSION)
|
||||
Utils::formatVersionId($current_version),
|
||||
Utils::formatVersionId(self::MIN_PHP_VERSION)
|
||||
)
|
||||
);
|
||||
|
||||
|
58
src/mibew/libs/classes/Mibew/Maintenance/Utils.php
Normal file
58
src/mibew/libs/classes/Mibew/Maintenance/Utils.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is a part of Mibew Messenger.
|
||||
*
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace Mibew\Maintenance;
|
||||
|
||||
/**
|
||||
* Contains a set of utility methods.
|
||||
*/
|
||||
class Utils
|
||||
{
|
||||
/**
|
||||
* Converts version ID to human readable representation.
|
||||
*
|
||||
* Example of usage:
|
||||
* <code>
|
||||
* $version = 50303;
|
||||
* echo(format_version_id($version)); // Outputs "5.3.3"
|
||||
* </code>
|
||||
*
|
||||
* @param int $version_id Version ID
|
||||
* @return string Human readable version.
|
||||
*/
|
||||
public static function formatVersionId($version_id)
|
||||
{
|
||||
$parts = array();
|
||||
$tmp = (int)$version_id;
|
||||
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$parts[] = $tmp % 100;
|
||||
$tmp = floor($tmp / 100);
|
||||
}
|
||||
|
||||
return implode('.', array_reverse($parts));
|
||||
}
|
||||
|
||||
/**
|
||||
* This class should not be instantiated
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
}
|
@ -164,28 +164,3 @@ function safe_htmlspecialchars($string)
|
||||
$string = preg_replace('/[\x00-\x08\x0b\x0c\x0e-\x1f]/', '', $string);
|
||||
return htmlspecialchars($string, ENT_QUOTES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts version ID to human readable representation.
|
||||
*
|
||||
* Example of usage:
|
||||
* <code>
|
||||
* $version = 50303;
|
||||
* echo(format_version_id($version)); // Outputs "5.3.3"
|
||||
* </code>
|
||||
*
|
||||
* @param int $version_id Version ID
|
||||
* @return string Human readable version.
|
||||
*/
|
||||
function format_version_id($version_id)
|
||||
{
|
||||
$parts = array();
|
||||
$tmp = (int)$version_id;
|
||||
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$parts[] = $tmp % 100;
|
||||
$tmp = floor($tmp / 100);
|
||||
}
|
||||
|
||||
return implode('.', array_reverse($parts));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user