@@ -25,7 +25,7 @@ |
||
25 | 25 | |
26 | 26 | public static function addMigration($direction, $migration) |
27 | 27 | { |
28 | - switch($direction) { |
|
28 | + switch ($direction) { |
|
29 | 29 | case 'up': |
30 | 30 | self::$upMigrations[] = $migration; |
31 | 31 | break; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * requests to the database within one call |
23 | 23 | * @var array |
24 | 24 | */ |
25 | - private static $_mapResultsCache=[]; |
|
25 | + private static $_mapResultsCache = []; |
|
26 | 26 | /** |
27 | 27 | * The set of map requests |
28 | 28 | * An array with the requests and the maximum number in the chain |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | /** |
46 | 46 | * @inheritdoc |
47 | 47 | */ |
48 | - public function getObjectMap($classType, $filters=[], $fields=[], $start=0, $length=1000, $includeDeleted=false) |
|
48 | + public function getObjectMap($classType, $filters = [], $fields = [], $start = 0, $length = 1000, $includeDeleted = false) |
|
49 | 49 | { |
50 | 50 | if (!$classType) |
51 | 51 | throw new \InvalidArgumentException("Invalid classType '$classType' in getObjectMap. Correct calling code"); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $cacheKey = md5(serialize(func_get_args())); |
54 | 54 | if (empty(self::$_mapResultsCache[$cacheKey])) { |
55 | 55 | try { |
56 | - $limit = ['start' => max(0, (integer)$start), 'length' => min(1000, (integer)$length)]; |
|
56 | + $limit = ['start' => max(0, (integer) $start), 'length' => min(1000, (integer) $length)]; |
|
57 | 57 | $classType = $this->canonicaliseRef($classType); |
58 | 58 | $fieldsClause = ''; |
59 | 59 | $linkJoins = []; |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $filterClause = ''; |
110 | 110 | $filterValues = []; |
111 | 111 | if ($filters) { |
112 | - $ddsObjectFields = ['_uuid','_created','_deleted','_updated']; |
|
112 | + $ddsObjectFields = ['_uuid', '_created', '_deleted', '_updated']; |
|
113 | 113 | // whitelist filter keys to prevent sql injection |
114 | 114 | $members = $this->getClassMembers($classType); |
115 | 115 | $filterSubClause = []; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $filterValues[":$field$vcount"] = $v; |
132 | 132 | $vcount++; |
133 | 133 | } |
134 | - $inClause = implode(',',$inClause); |
|
134 | + $inClause = implode(',', $inClause); |
|
135 | 135 | if (!empty($members[$field]) && $members[$field]['data_type_ref'] == 'link_multi') { |
136 | 136 | $linkName = "link$field"; |
137 | 137 | if (!isset($linkJoins[$linkName])) |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | $filterSubClause[] = "AND $keyClause IN ($inClause)"; |
142 | 142 | } |
143 | 143 | } |
144 | - $filterClause = implode (' ', $filterSubClause); |
|
144 | + $filterClause = implode(' ', $filterSubClause); |
|
145 | 145 | } |
146 | 146 | $linkJoinsClause = implode(' ', $linkJoins); |
147 | 147 | |
148 | - $query = "SELECT DISTINCT `o`.`_uuid`, $fieldsClause FROM `dds_object` `o` LEFT JOIN `$table` `t` ON `o`.`_uuid`=`t`.`_uuid` " . |
|
149 | - "$linkJoinsClause WHERE `o`.`_class_type` = '$classType' $filterClause $notDeleted ORDER BY $fieldsClause " . |
|
148 | + $query = "SELECT DISTINCT `o`.`_uuid`, $fieldsClause FROM `dds_object` `o` LEFT JOIN `$table` `t` ON `o`.`_uuid`=`t`.`_uuid` ". |
|
149 | + "$linkJoinsClause WHERE `o`.`_class_type` = '$classType' $filterClause $notDeleted ORDER BY $fieldsClause ". |
|
150 | 150 | "LIMIT $limit[start], $limit[length]"; |
151 | 151 | $command = neon()->db->createCommand($query); |
152 | 152 | if ($filters) |
@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | unset($r['_uuid']); |
159 | 159 | |
160 | 160 | // set the map |
161 | - $map[$uuid] = (count($fields)==1) ? current($r) : $r; |
|
161 | + $map[$uuid] = (count($fields) == 1) ? current($r) : $r; |
|
162 | 162 | } |
163 | 163 | self::$_mapResultsCache[$cacheKey] = $map; |
164 | 164 | } catch (\Exception $e) { |
165 | 165 | $errorMessage = "Exception during getting a map. This may be caused by empty filters - you cannot filter on null. ". |
166 | - "Your filters were: ".print_r($filters,true).". The error message is ".$e->getMessage(); |
|
166 | + "Your filters were: ".print_r($filters, true).". The error message is ".$e->getMessage(); |
|
167 | 167 | \Neon::error($errorMessage, 'DDS'); |
168 | 168 | debug_message($errorMessage); |
169 | 169 | return []; |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | /** |
176 | 176 | * @inheritdoc |
177 | 177 | */ |
178 | - public function makeMapLookupRequest($objectUuids, $chainMapFields=[], $classType=null) |
|
178 | + public function makeMapLookupRequest($objectUuids, $chainMapFields = [], $classType = null) |
|
179 | 179 | { |
180 | 180 | if (empty($objectUuids)) |
181 | 181 | return null; |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | foreach ($linkedMembers as $lm) { |
199 | 199 | $requestKeys[] = $this->makeMapChainLookupRequest($objectUuids, [$lm]); |
200 | 200 | } |
201 | - return implode('|',$requestKeys); |
|
201 | + return implode('|', $requestKeys); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | foreach ($partials[0] as $u=>$p) { |
218 | 218 | foreach ($p as $i=>$v) { |
219 | 219 | if ($this->isUuid($v)) { |
220 | - for ($i=1; $i<count($requestKeys); $i++) { |
|
220 | + for ($i = 1; $i < count($requestKeys); $i++) { |
|
221 | 221 | if (array_key_exists($v, $partials[$i][1])) { |
222 | 222 | $partials[0][$u][$i] = $partials[$i][1][$v]; |
223 | 223 | continue; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | /** |
234 | 234 | * @inheritdoc |
235 | 235 | */ |
236 | - public function makeMapChainLookupRequest($objectUuids, $chainMembers=[], $chainMapFields=[], $inReverse=false) |
|
236 | + public function makeMapChainLookupRequest($objectUuids, $chainMembers = [], $chainMapFields = [], $inReverse = false) |
|
237 | 237 | { |
238 | 238 | if (empty($objectUuids)) |
239 | 239 | return null; |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | $this->getMapLookupByLevel($chain); |
274 | 274 | foreach ($chain as $k=>$r) { |
275 | 275 | if ($r['next_uuid']) |
276 | - $requests['chains'][($i+1)][$k]['uuid'] = $r['next_uuid']; |
|
276 | + $requests['chains'][($i + 1)][$k]['uuid'] = $r['next_uuid']; |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | $this->convertMapRequestResults(); |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | $requestsByUuid[$r['uuid']][] = $r; |
333 | 333 | } |
334 | 334 | $objectRows = DdsObject::find() |
335 | - ->select(['_uuid','_class_type']) |
|
335 | + ->select(['_uuid', '_class_type']) |
|
336 | 336 | ->where(['_uuid'=>$endpoints]) |
337 | 337 | ->andWhere(['_deleted'=>0]) |
338 | 338 | ->asArray() |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | |
353 | 353 | // now find all the maps members for the required classes |
354 | 354 | $mapFields = DdsMember::find() |
355 | - ->select(['class_type','member_ref']) |
|
355 | + ->select(['class_type', 'member_ref']) |
|
356 | 356 | ->where(['class_type'=>$classTypes, 'deleted'=>0, 'map_field'=>1]) |
357 | 357 | ->asArray() |
358 | 358 | ->all(); |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | foreach ($objectsByClassMapsAndChain as $class => $chainMapObjects) { |
369 | 369 | foreach ($chainMapObjects as $chain => $mapObjects) { |
370 | 370 | foreach ($mapObjects as $mapField => $objectUuids) { |
371 | - $objs = "'".implode("','",$objectUuids)."'"; |
|
371 | + $objs = "'".implode("','", $objectUuids)."'"; |
|
372 | 372 | // make sure a map field can be created |
373 | 373 | $mapFieldsClause = ''; |
374 | 374 | if ($mapField === self::$_defaultMapChain) { |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | $mapFieldsClause = "CAST(`$mapsByClass[$class]` AS CHAR)"; |
378 | 378 | } else { |
379 | 379 | $mapFieldsClause = "CONCAT_WS('$hackySeparator'"; |
380 | - foreach (explode(',',$mapField) as $m) { |
|
380 | + foreach (explode(',', $mapField) as $m) { |
|
381 | 381 | $mapFieldsClause .= ",CAST(`$m` AS CHAR)"; |
382 | 382 | } |
383 | 383 | $mapFieldsClause .= ')'; |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | $mapsByChainAndUuid = []; |
403 | 403 | foreach ($maps as $m) { |
404 | 404 | if (strpos($m['map'], $hackySeparator) !== false) { |
405 | - $m['map'] = explode($hackySeparator,$m['map']); |
|
405 | + $m['map'] = explode($hackySeparator, $m['map']); |
|
406 | 406 | } |
407 | 407 | $mapsByChainAndUuid[$m['chain']][$m['mapFields']][$m['uuid']] = $m; |
408 | 408 | } |
@@ -473,14 +473,14 @@ discard block |
||
473 | 473 | $chainCount = count($chainMembers); |
474 | 474 | // split the chain up into requests per chain level if there are any |
475 | 475 | foreach ($chainMembers as $i=>$mc) { |
476 | - $mapFieldKey = ($i == 0 ? 0 : $chainMembers[$i-1]); |
|
477 | - $mapFields = !empty($chainMapFields[$mapFieldKey]) ? implode(',',$chainMapFields[$mapFieldKey]) : self::$_defaultMapChain; |
|
478 | - $requests['chains'][$i][$requestKey] = ['uuid'=>($i===0?$objectUuid:null), 'map'=>null, 'mapFields'=>$mapFields, 'chain'=>$mc, 'key'=>$requestKey]; |
|
476 | + $mapFieldKey = ($i == 0 ? 0 : $chainMembers[$i - 1]); |
|
477 | + $mapFields = !empty($chainMapFields[$mapFieldKey]) ? implode(',', $chainMapFields[$mapFieldKey]) : self::$_defaultMapChain; |
|
478 | + $requests['chains'][$i][$requestKey] = ['uuid'=>($i === 0 ? $objectUuid : null), 'map'=>null, 'mapFields'=>$mapFields, 'chain'=>$mc, 'key'=>$requestKey]; |
|
479 | 479 | } |
480 | 480 | // add a final chain for the last item |
481 | - $mapFieldKey = ($chainCount == 0 ? 0 : $chainMembers[$chainCount-1]); |
|
482 | - $mapFields = !empty($chainMapFields[$mapFieldKey]) ? implode(',',$chainMapFields[$mapFieldKey]) : self::$_defaultMapChain; |
|
483 | - $requests['chains'][$chainCount][$requestKey] = ['uuid'=>($chainCount===0?$objectUuid:null), 'map'=>null, 'mapFields'=>$mapFields, 'chain'=>'__FINAL__', 'key'=>$requestKey]; |
|
481 | + $mapFieldKey = ($chainCount == 0 ? 0 : $chainMembers[$chainCount - 1]); |
|
482 | + $mapFields = !empty($chainMapFields[$mapFieldKey]) ? implode(',', $chainMapFields[$mapFieldKey]) : self::$_defaultMapChain; |
|
483 | + $requests['chains'][$chainCount][$requestKey] = ['uuid'=>($chainCount === 0 ? $objectUuid : null), 'map'=>null, 'mapFields'=>$mapFields, 'chain'=>'__FINAL__', 'key'=>$requestKey]; |
|
484 | 484 | |
485 | 485 | // and add the requestKey so we don't calculate this again |
486 | 486 | $requests['keys'][$requestKey] = [ |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | $results = &static::$_mapResults; |
510 | 510 | |
511 | 511 | $tempResults = []; |
512 | - if (count($chains)===0) |
|
512 | + if (count($chains) === 0) |
|
513 | 513 | return; |
514 | 514 | foreach ($chains as $level => $maps) { |
515 | 515 | foreach ($maps as $key=>$map) { |
@@ -86,7 +86,7 @@ |
||
86 | 86 | { |
87 | 87 | // return choices as decoded json or null |
88 | 88 | if (!empty($this->choices)) |
89 | - $this->choices = json_decode($this->choices,true); |
|
89 | + $this->choices = json_decode($this->choices, true); |
|
90 | 90 | parent::afterFind(); |
91 | 91 | } |
92 | 92 |
@@ -18,7 +18,7 @@ |
||
18 | 18 | /** |
19 | 19 | * @inheritdoc |
20 | 20 | */ |
21 | - public function addObjectDeletionChecksOnJoin(\yii\db\Query $query, $tables, $join='innerJoin') |
|
21 | + public function addObjectDeletionChecksOnJoin(\yii\db\Query $query, $tables, $join = 'innerJoin') |
|
22 | 22 | { |
23 | 23 | foreach ($tables as $table) { |
24 | 24 | if ($join == 'innerJoin') { |
@@ -244,7 +244,7 @@ |
||
244 | 244 | if ($count) |
245 | 245 | $classes = array_merge($classes, $nextSet); |
246 | 246 | $start += $count; |
247 | - } while ($count>0); |
|
247 | + } while ($count > 0); |
|
248 | 248 | $classesByType = array_column($classes, null, 'class_type'); |
249 | 249 | |
250 | 250 | // get the full definition of these |
@@ -65,7 +65,7 @@ |
||
65 | 65 | } catch (\Exception $e) { |
66 | 66 | // error occured lets see if it's because the class does not exist |
67 | 67 | if (neon()->getDds()->IDdsClassManagement->getClass($class) === null) { |
68 | - throw new HttpException(404, 'No class exists with name ' . $class); |
|
68 | + throw new HttpException(404, 'No class exists with name '.$class); |
|
69 | 69 | } |
70 | 70 | throw new HttpException(500, $e->getMessage()); |
71 | 71 | } |
@@ -47,15 +47,15 @@ discard block |
||
47 | 47 | * @return array uuid => map field |
48 | 48 | * @throws |
49 | 49 | */ |
50 | - public function actionObjects($class, $filter='', $length=100, $member='', $value='', $start=0) |
|
50 | + public function actionObjects($class, $filter = '', $length = 100, $member = '', $value = '', $start = 0) |
|
51 | 51 | { |
52 | 52 | $mapFilter = []; |
53 | 53 | if (!$class) |
54 | 54 | throw new HttpException(404, "No class name provided"); |
55 | 55 | if ($member && $value) |
56 | - $mapFilter[$member]=$value; |
|
56 | + $mapFilter[$member] = $value; |
|
57 | 57 | if ($filter && is_string($filter)) |
58 | - $mapFilter['_map_field_']=$filter; |
|
58 | + $mapFilter['_map_field_'] = $filter; |
|
59 | 59 | return neon()->getDds()->IDdsObjectManagement->getObjectMap($class, $mapFilter, [], $start, $length); |
60 | 60 | } |
61 | 61 | |
@@ -64,17 +64,17 @@ discard block |
||
64 | 64 | return neon('user')->getDataMapTypes(); |
65 | 65 | } |
66 | 66 | |
67 | - public function actionUsers($filter='') |
|
67 | + public function actionUsers($filter = '') |
|
68 | 68 | { |
69 | 69 | return neon('user')->getDataMap('users', $filter); |
70 | 70 | } |
71 | 71 | |
72 | - public function actionPages($filter='') |
|
72 | + public function actionPages($filter = '') |
|
73 | 73 | { |
74 | 74 | return neon('cms')->getDataMap('pages', $filter); |
75 | 75 | } |
76 | 76 | |
77 | - public function actionPhoebe($type='', $filter='') |
|
77 | + public function actionPhoebe($type = '', $filter = '') |
|
78 | 78 | { |
79 | 79 | $filters = []; |
80 | 80 | if (!$filter) { |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | ]); |
40 | 40 | } |
41 | 41 | |
42 | - public function actionList($type, $uuid=null) |
|
42 | + public function actionList($type, $uuid = null) |
|
43 | 43 | { |
44 | 44 | // sort out where we're going back to |
45 | 45 | $goBackTo = url(['index/list', 'type'=>$type]); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $goBackTo = url(['index/list', 'type'=>$type, 'uuid' => $uuid]); |
48 | 48 | |
49 | 49 | // check the class has a change log |
50 | - $class = ['class_type' => $type, 'label'=>ucwords(str_replace('_',' ',$type))]; |
|
50 | + $class = ['class_type' => $type, 'label'=>ucwords(str_replace('_', ' ', $type))]; |
|
51 | 51 | $hasChangeLog = $this->cl->hasChangeLog($type); |
52 | 52 | if (!$hasChangeLog) { |
53 | 53 | return $this->render('list.tpl', [ |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | case 'COMMENT': |
103 | 103 | if (!$uuid) |
104 | 104 | $render['title'] = "Comment added on ".date("d-m-Y \\a\\t H:i:s", strtotime($logEntry['when'])); |
105 | - if (is_array($logEntry['associated_objects']) && count($logEntry['associated_objects'])>0) |
|
105 | + if (is_array($logEntry['associated_objects']) && count($logEntry['associated_objects']) > 0) |
|
106 | 106 | $render['associated_objects'] = implode(', ', $logEntry['associated_objects']); |
107 | 107 | case 'DESTROY': |
108 | 108 | case 'DELETE': |
@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | public function safeDown() |
16 | 16 | { |
17 | - $this->execute("ALTER TABLE dds_change_log MODIFY `object_uuid` char(22) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL COMMENT 'The object that was changed'"); $this->execute("ALTER TABLE dds_change_log DROP COLUMN `before`;"); |
|
17 | + $this->execute("ALTER TABLE dds_change_log MODIFY `object_uuid` char(22) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL COMMENT 'The object that was changed'"); $this->execute("ALTER TABLE dds_change_log DROP COLUMN `before`;"); |
|
18 | 18 | $this->execute("ALTER TABLE dds_change_log DROP COLUMN `after`;"); |
19 | 19 | $this->execute("ALTER TABLE dds_change_log ADD `changes` longblob COMMENT 'What the changes were' AFTER `when`;"); |
20 | 20 | } |