Fix compatibility with PHP 5.4

This commit is contained in:
zhangrunyu
2022-01-13 10:14:15 +08:00
parent 8ab6050b34
commit 39e30fc64f
10 changed files with 77 additions and 35 deletions

View File

@@ -902,3 +902,39 @@ function htmlSpecialString($string, $flags = '', $encoding = 'UTF-8')
if(!$flags) $flags = defined('ENT_SUBSTITUTE') ? ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 : ENT_QUOTES; if(!$flags) $flags = defined('ENT_SUBSTITUTE') ? ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 : ENT_QUOTES;
return htmlspecialchars($string, $flags, $encoding); return htmlspecialchars($string, $flags, $encoding);
} }
if (!function_exists('array_column'))
{
function array_column(array $input, $columnKey, $indexKey = null)
{
$output = array();
foreach ($input as $row) {
$key = $value = null;
$keySet = $valueSet = false;
if (null !== $indexKey && array_key_exists($indexKey, $row)) {
$keySet = true;
$key = (string) $row[$indexKey];
}
if (null === $columnKey) {
$valueSet = true;
$value = $row;
} elseif (\is_array($row) && \array_key_exists($columnKey, $row)) {
$valueSet = true;
$value = $row[$columnKey];
}
if ($valueSet) {
if ($keySet) {
$output[$key] = $value;
} else {
$output[] = $value;
}
}
}
return $output;
}
}

View File

@@ -1901,7 +1901,7 @@ class bugModel extends model
{ {
$data->name = isset($executions[$executionID]) ? $executions[$executionID] : $this->lang->report->undefined; $data->name = isset($executions[$executionID]) ? $executions[$executionID] : $this->lang->report->undefined;
$data->title = $data->name; $data->title = $data->name;
if(mb_strlen($data->name) > $maxLength) $data->name = mb_substr($data->name, 0, $maxLength) . '...'; if(mb_strlen($data->name, 'UTF-8') > $maxLength) $data->name = mb_substr($data->name, 0, $maxLength, 'UTF-8') . '...';
} }
return $datas; return $datas;
} }

View File

@@ -1,29 +1,29 @@
<?php <?php
/** /**
* The html template file of index method of convert module of ZenTaoPMS. * The html template file of index method of convert module of ZenTaoPMS.
* *
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com) * @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html) * @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Chunsheng Wang <chunsheng@cnezsoft.com> * @author Chunsheng Wang <chunsheng@cnezsoft.com>
* @package ZenTaoPMS * @package ZenTaoPMS
* @version $Id: index.html.php 4129 2013-01-18 01:58:14Z wwccss $ * @version $Id: index.html.php 4129 2013-01-18 01:58:14Z wwccss $
*/ */
?> ?>
<?php include '../../common/view/header.html.php';?> <?php include '../../common/view/header.html.php';?>
<div class='container mw-700px'> <div class='container mw-700px'>
<div id='titlebar'> <div id='titlebar'>
<div class='heading'> <div class='heading'>
<span class='prefix'><?php echo html::icon('cloud-upload');?></span> <span class='prefix'><?php echo html::icon('cloud-upload');?></span>
<strong><?php echo $lang->convert->common;?></strong> <strong><?php echo $lang->convert->common;?></strong>
</div> </div>
</div> </div>
<div class='alert mg-0 bd-0'> <div class='alert mg-0 bd-0'>
<div class='content'> <div class='content'>
<?php echo nl2br($lang->convert->desc);?> <?php echo nl2br($lang->convert->desc);?>
<div class='text-center pdt-20'> <div class='text-center pdt-20'>
<?php echo html::a($this->createLink('convert', 'selectsource'), $lang->convert->start, '', 'class="btn btn-primary"');?> <?php echo html::a($this->createLink('convert', 'selectsource'), $lang->convert->start, '', 'class="btn btn-primary"');?>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<?php include '../../common/view/footer.html.php';?> <?php include '../../common/view/footer.html.php';?>

View File

@@ -87,7 +87,7 @@ $dataType = '';
</div> </div>
<?php if($col == 'story' or $dataType == 'bug'):?> <?php if($col == 'story' or $dataType == 'bug'):?>
<?php $desc = $col == 'story' ? $storySpecs[$content->id]->spec : $content->steps;?> <?php $desc = $col == 'story' ? $storySpecs[$content->id]->spec : $content->steps;?>
<div class='board-content'><?php echo mb_substr(strip_tags($desc, "<p><br/>"), 0, 90, 'utf8')?></div> <div class='board-content'><?php echo mb_substr(strip_tags($desc, "<p><br>"), 0, 90, 'utf8')?></div>
<?php endif;?> <?php endif;?>
</div> </div>
<div class="board-footer <?php echo $col == 'story' ? 'story' : 'task'?>"> <div class="board-footer <?php echo $col == 'story' ? 'story' : 'task'?>">

View File

@@ -23,7 +23,7 @@
<?php if($removeCommands):?> <?php if($removeCommands):?>
<div class='container mw-500px'> <div class='container mw-500px'>
<p><strong><?php echo $lang->extension->unremovedFiles;?></strong></p> <p><strong><?php echo $lang->extension->unremovedFiles;?></strong></p>
<code><?php echo join($removeCommands, '<br />');?></code> <code><?php echo join('<br />', $removeCommands);?></code>
</div> </div>
<?php endif;?> <?php endif;?>
<hr> <hr>

View File

@@ -26,7 +26,7 @@
<h3><?php echo $title;?></h3> <h3><?php echo $title;?></h3>
<?php if($removeCommands):?> <?php if($removeCommands):?>
<p><strong><?php echo $lang->extension->unremovedFiles;?></strong></p> <p><strong><?php echo $lang->extension->unremovedFiles;?></strong></p>
<p><?php echo join($removeCommands, '<br />');?></p> <p><?php echo join('<br />', $removeCommands);?></p>
<?php endif;?> <?php endif;?>
<p class='text-center'><?php echo html::commonButton($lang->extension->viewAvailable, 'onclick=parent.location.href="' . inlink('browse', 'type=available') . '"');?></p> <p class='text-center'><?php echo html::commonButton($lang->extension->viewAvailable, 'onclick=parent.location.href="' . inlink('browse', 'type=available') . '"');?></p>
</div> </div>

View File

@@ -51,7 +51,7 @@
if($removeCommands) if($removeCommands)
{ {
echo "<p class='strong'>{$lang->extension->unremovedFiles}</p>"; echo "<p class='strong'>{$lang->extension->unremovedFiles}</p>";
echo join($removeCommands, '<br />'); echo join('<br />', $removeCommands);
} }
echo "<p class='text-center'>" . html::commonButton($lang->extension->viewAvailable, 'onclick=parent.location.href="' . inlink('browse', 'type=available') . '"') . '</p>'; echo "<p class='text-center'>" . html::commonButton($lang->extension->viewAvailable, 'onclick=parent.location.href="' . inlink('browse', 'type=available') . '"') . '</p>';
?> ?>

View File

@@ -501,7 +501,7 @@ class groupModel extends model
$data = new stdclass(); $data = new stdclass();
$data->group = $groupID; $data->group = $groupID;
$data->account = $account; $data->account = $account;
$data->project = implode($programs[$account], ','); $data->project = implode(',', $programs[$account]);
$this->dao->replace(TABLE_USERGROUP)->data($data)->exec(); $this->dao->replace(TABLE_USERGROUP)->data($data)->exec();
foreach($programs[$account] as $programID) foreach($programs[$account] as $programID)

View File

@@ -1953,9 +1953,9 @@ class testtaskModel extends model
{ {
$result->stepResults[0]['real'] = (string)$matchNode->$failure; $result->stepResults[0]['real'] = (string)$matchNode->$failure;
} }
elseif(isset($matchNode->$failure[0])) elseif(isset($matchNode->{$failure}[0]))
{ {
$result->stepResults[0]['real'] = (string)$matchNode->$failure[0]; $result->stepResults[0]['real'] = (string)$matchNode->{$failure}[0];
} }
else else
{ {

View File

@@ -1,3 +1,9 @@
#!/usr/bin/env bash
set -eu
cd "$(dirname $0)"
php phpcs.phar --config-set installed_paths $PWD/PHPCompatibility > /dev/null; php phpcs.phar --config-set installed_paths $PWD/PHPCompatibility > /dev/null;
php ./phpcs.phar --standard=ruleset.xml --ignore=*.css ../../module; php ./phpcs.phar --standard=ruleset.xml --ignore=*.css ../../module;