Skip to content

Commit dbea4c9

Browse files
committed
Multiple style fixes
1 parent a9a07be commit dbea4c9

File tree

7 files changed

+42
-27
lines changed

7 files changed

+42
-27
lines changed

framework/core/CController.php

+2
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ public function redirect($path, $isDirectUrl = false, $code = '')
110110
$calledController = str_replace('controller', '', strtolower($this->_getCalledClass()));
111111
$params = '';
112112
$baseUrl = A::app()->getRequest()->getBaseUrl();
113+
$controller = '';
114+
$action = '';
113115

114116
// Set controller and action according to given parameters
115117
if (!empty($path)) {

framework/db/CDatabase.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function __construct($params = [])
9797
}
9898
} else {
9999
if ( ! A::app()->isSetup()) {
100-
if (APPHP_MODE == 'debug') {
100+
if (APPHP_MODE === 'debug') {
101101
$startTime = CTime::getMicrotime();
102102
}
103103

@@ -173,7 +173,7 @@ public function __construct($params = [])
173173
}
174174

175175
// Save data for debug
176-
if (APPHP_MODE == 'debug') {
176+
if (APPHP_MODE === 'debug') {
177177
$finishTime = CTime::getMicrotime();
178178
$sqlConnectionTime = round((float)$finishTime - (float)$startTime, 5);
179179
CDebug::addSqlConnectionTime($sqlConnectionTime);
@@ -231,7 +231,10 @@ public function cacheOff()
231231
*/
232232
public function select($sql, $params = [], $method = 'fetchAll', $fetchMode = PDO::FETCH_ASSOC, $cacheId = '')
233233
{
234-
if (APPHP_MODE == 'debug') {
234+
$startTime = 0;
235+
$finishTime = 0;
236+
237+
if (APPHP_MODE === 'debug') {
235238
$startTime = CTime::getMicrotime();
236239
}
237240

@@ -280,7 +283,7 @@ public function select($sql, $params = [], $method = 'fetchAll', $fetchMode = PD
280283
$this->_query = $this->_interpolateQuery($sql, $params);
281284

282285
// Save data for debug
283-
if (APPHP_MODE == 'debug') {
286+
if (APPHP_MODE === 'debug') {
284287
$finishTime = CTime::getMicrotime();
285288
$sqlTotalTime = round((float)$finishTime - (float)$startTime, 5);
286289
CDebug::addSqlTime($sqlTotalTime);

framework/db/CDbCommand.php

+9-4
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function __construct($dbConnection = null)
114114
public function reset()
115115
{
116116
$this->_text = null;
117-
$this->_query = null;
117+
$this->_query = [];
118118
$this->_statement = null;
119119
$this->_params = [];
120120

@@ -726,7 +726,7 @@ public function getOffset()
726726
/**
727727
* Appends a SQL statement using UNION operator
728728
*
729-
* @param string $sql
729+
* @param array $sql
730730
*
731731
* @return CDbCommand the command object itself
732732
*/
@@ -736,7 +736,9 @@ public function union($sql)
736736
$this->_query['union'] = [$this->_query['union']];
737737
}
738738

739-
$this->_query['union'][] = $sql;
739+
if (isset($this->_query['union'])) {
740+
$this->_query['union'][] = $sql;
741+
}
740742

741743
return $this;
742744
}
@@ -865,7 +867,10 @@ private function _joinInternal($type, $table, $conditions = '', $params = [])
865867
$this->_query['join'] = [$this->_query['join']];
866868
}
867869

868-
$this->_query['join'][] = strtoupper($type).' '.$table.$conditions;
870+
if (isset($this->_query['join'])) {
871+
$this->_query['join'][] = strtoupper($type).' '.$table.$conditions;
872+
}
873+
869874
foreach ($params as $name => $value) {
870875
$this->_params[$name] = $value;
871876
}

framework/helpers/CAuth.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,18 @@ public static function isGuest()
9191
/**
9292
* Handles access for non-logged users (block access)
9393
* @param string $location
94-
* @param string $role
94+
* @param string $roleParam
9595
* @return string|void
9696
*/
97-
public static function handleLogin($location = 'index/index', $role = '')
97+
public static function handleLogin($location = 'index/index', $roleParam = '')
9898
{
99-
if (APPHP_MODE == 'test') return '';
99+
if (APPHP_MODE === 'test') return '';
100100

101101
$isLoggedIn = false;
102-
if (empty($role)) {
102+
if (empty($roleParam)) {
103103
$isLoggedIn = self::isLoggedInAsAdmin();
104104
} else {
105-
$roles = explode(',', $role);
105+
$roles = explode(',', $roleParam);
106106
foreach ($roles as $role) {
107107
if (self::isLoggedInAs($role)) {
108108
$isLoggedIn = true;
@@ -120,18 +120,18 @@ public static function handleLogin($location = 'index/index', $role = '')
120120
/**
121121
* Handles access for logged in users (redirect logged in users)
122122
* @param string $location
123-
* @param string $role
123+
* @param string $roleParam
124124
* @return string|void
125125
*/
126-
public static function handleLoggedIn($location = '', $role = '')
126+
public static function handleLoggedIn($location = '', $roleParam = '')
127127
{
128-
if (APPHP_MODE == 'test') return '';
128+
if (APPHP_MODE === 'test') return '';
129129

130130
$isLoggedIn = false;
131-
if (empty($role)) {
131+
if (empty($roleParam)) {
132132
$isLoggedIn = self::isLoggedInAsAdmin();
133133
} else {
134-
$roles = explode(',', $role);
134+
$roles = explode(',', $roleParam);
135135
foreach ($roles as $role) {
136136
if (self::isLoggedInAs($role)) {
137137
$isLoggedIn = true;

framework/helpers/CFilter.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ public static function sanitize($type, $data)
2727
{
2828

2929
$type = strtolower($type);
30+
$ciSecurity = null;
3031

3132
// Use CI_Security class for these special filters
32-
if ($type == 'filename' || $type == 'xss') {
33+
if ($type === 'filename' || $type === 'xss') {
3334
include(dirname(__FILE__) . '/../vendors/ci/security.php');
3435
$ciSecurity = new CI_Security();
3536
}
@@ -61,10 +62,10 @@ public static function sanitize($type, $data)
6162
} elseif ($type == 'dbfield') {
6263
// Leave only allowed characters for database field name
6364
return preg_replace('/[^A-Za-z0-9_\-]/', '', $data);
64-
} elseif ($type == 'filename') {
65+
} elseif ($type === 'filename') {
6566
// Sanitize filename
6667
return $ciSecurity->sanitize_filename($data);
67-
} elseif ($type == 'xss') {
68+
} elseif ($type === 'xss') {
6869
// Sanitize input with xss
6970
return $ciSecurity->xss_clean($data);
7071
}

framework/helpers/CString.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,14 @@ public static function humanize($string)
158158
*/
159159
function plural($string)
160160
{
161-
$result = strval($string);
162-
163-
if (!is_countable($result)) {
164-
return $result;
165-
}
166-
161+
$result = (string)$string;
162+
163+
if (PHP_VERSION_ID > 70300) {
164+
if (!is_countable($result)) {
165+
return $result;
166+
}
167+
}
168+
167169
$pluralRules = array(
168170
'/(quiz)$/' => '\1zes', // quizzes
169171
'/^(ox)$/' => '\1\2en', // ox

framework/helpers/widgets/CGridView.php

+2
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ public static function init($params = [])
196196
// ---------------------------------------
197197
$whereClause = (!empty($condition)) ? $condition : '';
198198
$filterUrl = '';
199+
$filterHalf = 1;
200+
199201
if (is_array($filters) && !empty($filters)) {
200202
// Boodstrap menu
201203
$filterMegaMenu = strtolower($filterType) == 'megamenu' ? true : false;

0 commit comments

Comments
 (0)