Оптимизации и исправления топов.

This commit is contained in:
CORP\phedor 2018-03-23 12:35:10 +03:00
parent 77fa3dbd5e
commit 0f4b2fb722
25 changed files with 109 additions and 53 deletions

View file

@ -40,7 +40,8 @@ class Tools_Drawing
$first_word = true;
$last_width = 0;
for ($i = 0; $i < count($words); $i++) {
$count = count($words);
for ($i = 0; $i < $count; $i++) {
$item = $words[$i];
$dimensions = imagettfbbox($size, $angle, $font, $current_line . ($first_word ? '' : ' ') . $item);
$line_width = $dimensions[2] - $dimensions[0];

View file

@ -111,7 +111,7 @@ class Tools_SQLStatementExtractor {
if ($check === "" || $check === $string) {
return true;
} else {
return (strpos($string, $check) === 0) ? true : false;
return (strpos($string, $check) === 0);
}
}
@ -125,7 +125,7 @@ class Tools_SQLStatementExtractor {
if ($check === "" || $check === $string) {
return true;
} else {
return (strpos(strrev($string), strrev($check)) === 0) ? true : false;
return (strpos(strrev($string), strrev($check)) === 0);
}
}

View file

@ -15,7 +15,7 @@ class Tools_String {
if ($in_subarr > 0) { // already in sub-array?
$subarr[$in_subarr][] = $tok;
if ('}' === substr($tok, -1, 1)) { // check to see if we just added last component
$res[] = strToArray(implode(',', $subarr[$in_subarr]));
$res[] = self::strToArray(implode(',', $subarr[$in_subarr]));
$in_subarr--;
}
} elseif ($tok{0} === '{') { // we're inside a new sub-array
@ -25,7 +25,7 @@ class Tools_String {
$subarr[$in_subarr] = array();
$subarr[$in_subarr][] = $tok;
} else {
$res[] = strToArray($tok);
$res[] = self::strToArray($tok);
}
} else { // not sub-array
$val = trim($tok, '"'); // remove " (surrounding strings)

View file

@ -33,13 +33,16 @@ class Tools_TemplateImage
protected $data = array();
protected $base = "c:\\windows\\fonts\\";
protected $image;
protected $prepare = true;
protected $_prepare = true;
public $debug = false;
function __construct ($template = false)
public $resource;
public $filename;
function __construct ($template = null)
{
// assert(is_string($src));
if($template) {
if ($template) {
$this->data = $template;
}
}
@ -116,7 +119,7 @@ class Tools_TemplateImage
return "";
}
function imageText($text, $value)
function imageText($text, /*.stdClass.*/$value)
{
assert(is_string($text));
@ -134,7 +137,7 @@ class Tools_TemplateImage
}
if ($value->valign[0]) {
$valign = Drawing::ALIGN_TOP;
$valign = Tools_Drawing::ALIGN_TOP;
} elseif ($value->valign[1]) {
$valign = Tools_Drawing::ALIGN_CENTER;
} else {
@ -159,7 +162,7 @@ class Tools_TemplateImage
{
$width = imagesx($this->image);
$height = imagesy($this->image);
if($new_height == false) {
if ($new_height == null) {
$new_height = ceil($height * $new_width / $width);
}
@ -171,8 +174,8 @@ class Tools_TemplateImage
}
function prepare() {
if($this->prepare) {
$this->prepare = false;
if($this->_prepare) {
$this->_prepare = false;
foreach ($this->data as $value) {
$this->imageText($value->text, $value); // break;
}