@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | break; |
| 63 | 63 | |
| 64 | 64 | default: |
| 65 | - $function = '\ORM_' . $this->fieldtype . 'Field'; |
|
| 65 | + $function = '\ORM_'.$this->fieldtype.'Field'; |
|
| 66 | 66 | $field = $function($this->fieldname); |
| 67 | 67 | break; |
| 68 | 68 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | $labelledItem = $W->LabelledWidget($this->name, $widget, null); |
| 148 | 148 | $labelledItem->setName($this->fieldname); |
| 149 | 149 | |
| 150 | - if(! empty($this->description)){ |
|
| 150 | + if (!empty($this->description)) { |
|
| 151 | 151 | $labelledItem->setDescription($this->description); |
| 152 | 152 | } |
| 153 | 153 | |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function joinSource($sourceClass) |
| 104 | 104 | { |
| 105 | - if(! $this->sourceId instanceof $sourceClass){ |
|
| 106 | - $this->hasOne('sourceId', $sourceClass . 'Set'); |
|
| 105 | + if (!$this->sourceId instanceof $sourceClass) { |
|
| 106 | + $this->hasOne('sourceId', $sourceClass.'Set'); |
|
| 107 | 107 | $this->join('sourceId'); |
| 108 | 108 | } |
| 109 | 109 | } |
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function joinTarget($targetClass = null) |
| 115 | 115 | { |
| 116 | - if(! $this->targetId instanceof $targetClass){ |
|
| 117 | - $this->hasOne('targetId', $targetClass . 'Set'); |
|
| 116 | + if (!$this->targetId instanceof $targetClass) { |
|
| 117 | + $this->hasOne('targetId', $targetClass.'Set'); |
|
| 118 | 118 | $this->join('targetId'); |
| 119 | 119 | } |
| 120 | 120 | } |
@@ -162,21 +162,21 @@ discard block |
||
| 162 | 162 | { |
| 163 | 163 | $criteria = $this->sourceIs($object); |
| 164 | 164 | |
| 165 | - if(isset($targetClass)){ |
|
| 165 | + if (isset($targetClass)) { |
|
| 166 | 166 | $this->joinTarget($targetClass); |
| 167 | 167 | $criteria = $criteria->_AND_($this->targetClass->is($targetClass)); |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if(isset($linkType)){ |
|
| 171 | - if(is_array($linkType)){ |
|
| 170 | + if (isset($linkType)) { |
|
| 171 | + if (is_array($linkType)) { |
|
| 172 | 172 | $criteria = $criteria->_AND_($this->type->in($linkType)); |
| 173 | 173 | } |
| 174 | - else{ |
|
| 174 | + else { |
|
| 175 | 175 | $criteria = $criteria->_AND_($this->type->is($linkType)); |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if(is_a($this->targetId, 'app_TraceableRecordSet')){ |
|
| 179 | + if (is_a($this->targetId, 'app_TraceableRecordSet')) { |
|
| 180 | 180 | $criteria = $criteria->_AND_($this->targetId->deleted->is(false)); |
| 181 | 181 | } |
| 182 | 182 | |
@@ -191,24 +191,24 @@ discard block |
||
| 191 | 191 | $sourceClass = null; |
| 192 | 192 | $sourceIds = array(); |
| 193 | 193 | |
| 194 | - foreach ($objects as $obj){ |
|
| 195 | - if(is_null($sourceClass)){ |
|
| 194 | + foreach ($objects as $obj) { |
|
| 195 | + if (is_null($sourceClass)) { |
|
| 196 | 196 | $sourceClass = $obj->getClassName(); |
| 197 | 197 | } |
| 198 | 198 | $sourceIds[] = $obj->id; |
| 199 | 199 | } |
| 200 | 200 | $criteria = $this->sourceId->in($sourceIds)->_AND_($this->sourceClass->is($sourceClass)); |
| 201 | 201 | |
| 202 | - if(isset($targetClass)){ |
|
| 202 | + if (isset($targetClass)) { |
|
| 203 | 203 | $this->joinTarget($targetClass); |
| 204 | 204 | $criteria = $criteria->_AND_($this->targetClass->is($targetClass)); |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - if(isset($linkType)){ |
|
| 208 | - if(is_array($linkType)){ |
|
| 207 | + if (isset($linkType)) { |
|
| 208 | + if (is_array($linkType)) { |
|
| 209 | 209 | $criteria = $criteria->_AND_($this->type->in($linkType)); |
| 210 | 210 | } |
| 211 | - else{ |
|
| 211 | + else { |
|
| 212 | 212 | $criteria = $criteria->_AND_($this->type->is($linkType)); |
| 213 | 213 | } |
| 214 | 214 | } |
@@ -222,16 +222,16 @@ discard block |
||
| 222 | 222 | { |
| 223 | 223 | $criteria = $this->targetIs($object); |
| 224 | 224 | |
| 225 | - if(isset($sourceClass)){ |
|
| 225 | + if (isset($sourceClass)) { |
|
| 226 | 226 | $this->joinSource($sourceClass); |
| 227 | 227 | $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass)); |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - if(isset($linkType)){ |
|
| 231 | - if(is_array($linkType)){ |
|
| 230 | + if (isset($linkType)) { |
|
| 231 | + if (is_array($linkType)) { |
|
| 232 | 232 | $criteria = $criteria->_AND_($this->type->in($linkType)); |
| 233 | 233 | } |
| 234 | - else{ |
|
| 234 | + else { |
|
| 235 | 235 | $criteria = $criteria->_AND_($this->type->is($linkType)); |
| 236 | 236 | } |
| 237 | 237 | } |
@@ -247,24 +247,24 @@ discard block |
||
| 247 | 247 | $targetClass = null; |
| 248 | 248 | $targetIds = array(); |
| 249 | 249 | |
| 250 | - foreach ($objects as $obj){ |
|
| 251 | - if(is_null($targetClass)){ |
|
| 250 | + foreach ($objects as $obj) { |
|
| 251 | + if (is_null($targetClass)) { |
|
| 252 | 252 | $targetClass = $obj->getClassName(); |
| 253 | 253 | } |
| 254 | 254 | $targetIds[] = $obj->id; |
| 255 | 255 | } |
| 256 | 256 | $criteria = $this->targetId->in($targetIds)->_AND_($this->targetClass->is($targetClass)); |
| 257 | 257 | |
| 258 | - if(isset($sourceClass)){ |
|
| 258 | + if (isset($sourceClass)) { |
|
| 259 | 259 | $this->joinSource($sourceClass); |
| 260 | 260 | $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass)); |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - if(isset($linkType)){ |
|
| 264 | - if(is_array($linkType)){ |
|
| 263 | + if (isset($linkType)) { |
|
| 264 | + if (is_array($linkType)) { |
|
| 265 | 265 | $criteria = $criteria->_AND_($this->type->in($linkType)); |
| 266 | 266 | } |
| 267 | - else{ |
|
| 267 | + else { |
|
| 268 | 268 | $criteria = $criteria->_AND_($this->type->is($linkType)); |
| 269 | 269 | } |
| 270 | 270 | } |
@@ -288,17 +288,17 @@ discard block |
||
| 288 | 288 | |
| 289 | 289 | $criteria = $set->sourceId->is($object->id)->_AND_($set->sourceClass->is($object->getClassName())); |
| 290 | 290 | |
| 291 | - if(null !== $targetClass){ |
|
| 291 | + if (null !== $targetClass) { |
|
| 292 | 292 | $criteria = $criteria->_AND_($set->targetClass->is($targetClass)); |
| 293 | 293 | } |
| 294 | - if(null !== $linkType){ |
|
| 294 | + if (null !== $linkType) { |
|
| 295 | 295 | $criteria = $criteria->_AND_($set->type->is($linkType)); |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - if($deleteTarget){ |
|
| 299 | - foreach ($set->select($criteria) as $link){ |
|
| 298 | + if ($deleteTarget) { |
|
| 299 | + foreach ($set->select($criteria) as $link) { |
|
| 300 | 300 | |
| 301 | - $className = $link->targetClass . 'Set'; |
|
| 301 | + $className = $link->targetClass.'Set'; |
|
| 302 | 302 | |
| 303 | 303 | // remove prefix |
| 304 | 304 | |
@@ -326,11 +326,11 @@ discard block |
||
| 326 | 326 | ->_AND_($this->sourceClass->is($source->getClassName())) |
| 327 | 327 | ->_AND_($this->targetId->is($target->id)) |
| 328 | 328 | ->_AND_($this->targetClass->is($target->getClassName())); |
| 329 | - if(isset($linkType)){ |
|
| 330 | - if(is_array($linkType)){ |
|
| 329 | + if (isset($linkType)) { |
|
| 330 | + if (is_array($linkType)) { |
|
| 331 | 331 | $criteria = $criteria->_AND_($this->type->in($linkType)); |
| 332 | 332 | } |
| 333 | - else{ |
|
| 333 | + else { |
|
| 334 | 334 | $criteria = $criteria->_AND_($this->type->is($linkType)); |
| 335 | 335 | } |
| 336 | 336 | } |
@@ -170,8 +170,7 @@ discard block |
||
| 170 | 170 | if(isset($linkType)){ |
| 171 | 171 | if(is_array($linkType)){ |
| 172 | 172 | $criteria = $criteria->_AND_($this->type->in($linkType)); |
| 173 | - } |
|
| 174 | - else{ |
|
| 173 | + } else{ |
|
| 175 | 174 | $criteria = $criteria->_AND_($this->type->is($linkType)); |
| 176 | 175 | } |
| 177 | 176 | } |
@@ -207,8 +206,7 @@ discard block |
||
| 207 | 206 | if(isset($linkType)){ |
| 208 | 207 | if(is_array($linkType)){ |
| 209 | 208 | $criteria = $criteria->_AND_($this->type->in($linkType)); |
| 210 | - } |
|
| 211 | - else{ |
|
| 209 | + } else{ |
|
| 212 | 210 | $criteria = $criteria->_AND_($this->type->is($linkType)); |
| 213 | 211 | } |
| 214 | 212 | } |
@@ -230,8 +228,7 @@ discard block |
||
| 230 | 228 | if(isset($linkType)){ |
| 231 | 229 | if(is_array($linkType)){ |
| 232 | 230 | $criteria = $criteria->_AND_($this->type->in($linkType)); |
| 233 | - } |
|
| 234 | - else{ |
|
| 231 | + } else{ |
|
| 235 | 232 | $criteria = $criteria->_AND_($this->type->is($linkType)); |
| 236 | 233 | } |
| 237 | 234 | } |
@@ -263,8 +260,7 @@ discard block |
||
| 263 | 260 | if(isset($linkType)){ |
| 264 | 261 | if(is_array($linkType)){ |
| 265 | 262 | $criteria = $criteria->_AND_($this->type->in($linkType)); |
| 266 | - } |
|
| 267 | - else{ |
|
| 263 | + } else{ |
|
| 268 | 264 | $criteria = $criteria->_AND_($this->type->is($linkType)); |
| 269 | 265 | } |
| 270 | 266 | } |
@@ -329,8 +325,7 @@ discard block |
||
| 329 | 325 | if(isset($linkType)){ |
| 330 | 326 | if(is_array($linkType)){ |
| 331 | 327 | $criteria = $criteria->_AND_($this->type->in($linkType)); |
| 332 | - } |
|
| 333 | - else{ |
|
| 328 | + } else{ |
|
| 334 | 329 | $criteria = $criteria->_AND_($this->type->is($linkType)); |
| 335 | 330 | } |
| 336 | 331 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | protected function extractSetPrefixAndName($setName) |
| 96 | 96 | { |
| 97 | 97 | $pos = strrpos($setName, '\\'); |
| 98 | - if($pos === false){ |
|
| 98 | + if ($pos === false) { |
|
| 99 | 99 | return explode('_', $setName); |
| 100 | 100 | } |
| 101 | 101 | return array( |
@@ -113,13 +113,13 @@ discard block |
||
| 113 | 113 | public function join($fkFieldName) |
| 114 | 114 | { |
| 115 | 115 | $fkField = $this->getField($fkFieldName); |
| 116 | - if(! ($fkField instanceof \ORM_FkField)){ |
|
| 116 | + if (!($fkField instanceof \ORM_FkField)) { |
|
| 117 | 117 | return $this; |
| 118 | 118 | } |
| 119 | 119 | $setName = $fkField->getForeignSetName(); |
| 120 | 120 | |
| 121 | - if(! $setName || 'Set' === $setName){ |
|
| 122 | - throw new \Exception('The set name is missing on foreign key field ' . $fkFieldName); |
|
| 121 | + if (!$setName || 'Set' === $setName) { |
|
| 122 | + throw new \Exception('The set name is missing on foreign key field '.$fkFieldName); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | list ($prefix, $appSetName) = $this->extractSetPrefixAndName($setName); |
@@ -157,22 +157,22 @@ discard block |
||
| 157 | 157 | { |
| 158 | 158 | $App = $this->App(); |
| 159 | 159 | |
| 160 | - if(null === $this->customFields){ |
|
| 160 | + if (null === $this->customFields) { |
|
| 161 | 161 | $this->customFields = array(); |
| 162 | 162 | |
| 163 | - if(isset($App->CustomField)){ |
|
| 163 | + if (isset($App->CustomField)) { |
|
| 164 | 164 | $customFieldSet = $App->CustomFieldSet(); |
| 165 | 165 | $object = mb_substr(get_class($this), mb_strlen($App->classPrefix), - mb_strlen('Set')); |
| 166 | - try{ |
|
| 166 | + try { |
|
| 167 | 167 | $customFields = $customFieldSet->select($customFieldSet->object->is($object)); |
| 168 | 168 | |
| 169 | - foreach ($customFields as $customfield){ |
|
| 169 | + foreach ($customFields as $customfield) { |
|
| 170 | 170 | $this->customFields[] = $customfield; |
| 171 | 171 | |
| 172 | 172 | /*@var $customfield AppCustomField */ |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | - catch (\ORM_BackEndSelectException $e){ |
|
| 175 | + catch (\ORM_BackEndSelectException $e) { |
|
| 176 | 176 | // table does not exist, this error is thrown by the install program while creating the sets |
| 177 | 177 | } |
| 178 | 178 | } |
@@ -202,15 +202,15 @@ discard block |
||
| 202 | 202 | public function addCustomFields() |
| 203 | 203 | { |
| 204 | 204 | $customFields = $this->selectCustomFields(); |
| 205 | - foreach ($customFields as $customField){ |
|
| 205 | + foreach ($customFields as $customField) { |
|
| 206 | 206 | /*@var $customField AppCustomField */ |
| 207 | 207 | $description = $customField->name; |
| 208 | 208 | $ormField = $customField->getORMField()->setDescription($description); |
| 209 | - if($ormField instanceof \ORM_FkField){ |
|
| 209 | + if ($ormField instanceof \ORM_FkField) { |
|
| 210 | 210 | $this->hasOne($customField->fieldname, $ormField->getForeignSetName()) |
| 211 | 211 | ->setDescription($description); |
| 212 | 212 | } |
| 213 | - else{ |
|
| 213 | + else { |
|
| 214 | 214 | $this->addFields($ormField); |
| 215 | 215 | } |
| 216 | 216 | } |
@@ -239,12 +239,12 @@ discard block |
||
| 239 | 239 | public function request($mixedParam = null, $sPropertyName = null) |
| 240 | 240 | { |
| 241 | 241 | $record = $this->get($mixedParam, $sPropertyName); |
| 242 | - if(! isset($record)){ |
|
| 242 | + if (!isset($record)) { |
|
| 243 | 243 | // This will remove the default criteria for TraceableRecords and |
| 244 | 244 | // fetch even 'deleted' ones. |
| 245 | 245 | $this->setDefaultCriteria(null); |
| 246 | 246 | $record = $this->get($mixedParam, $sPropertyName); |
| 247 | - if(isset($record)){ |
|
| 247 | + if (isset($record)) { |
|
| 248 | 248 | throw new AppDeletedRecordException($record, $mixedParam); |
| 249 | 249 | } |
| 250 | 250 | throw new AppNotFoundException($this, $mixedParam); |
@@ -265,10 +265,10 @@ discard block |
||
| 265 | 265 | public function selectLinkedTo($source, $linkType = null) |
| 266 | 266 | { |
| 267 | 267 | $linkSet = $this->App()->LinkSet(); |
| 268 | - if(is_array($source) || ($source instanceof \Iterator)){ |
|
| 268 | + if (is_array($source) || ($source instanceof \Iterator)) { |
|
| 269 | 269 | return $linkSet->selectForSources($source, $this->getRecordClassName(), $linkType); |
| 270 | 270 | } |
| 271 | - else{ |
|
| 271 | + else { |
|
| 272 | 272 | return $linkSet->selectForSource($source, $this->getRecordClassName(), $linkType); |
| 273 | 273 | } |
| 274 | 274 | } |
@@ -286,10 +286,10 @@ discard block |
||
| 286 | 286 | public function selectLinkedFrom($target, $linkType = null) |
| 287 | 287 | { |
| 288 | 288 | $linkSet = $this->App()->LinkSet(); |
| 289 | - if(is_array($target) || ($target instanceof \Iterator)){ |
|
| 289 | + if (is_array($target) || ($target instanceof \Iterator)) { |
|
| 290 | 290 | return $linkSet->selectForTargets($target, $this->getRecordClassName(), $linkType); |
| 291 | 291 | } |
| 292 | - else{ |
|
| 292 | + else { |
|
| 293 | 293 | return $linkSet->selectForTarget($target, $this->getRecordClassName(), $linkType); |
| 294 | 294 | } |
| 295 | 295 | } |
@@ -313,11 +313,11 @@ discard block |
||
| 313 | 313 | ->_AND_($linkSet->targetId->is($target->id)) |
| 314 | 314 | ->_AND_($linkSet->sourceClass->is($this->newRecord() |
| 315 | 315 | ->getClassName())); |
| 316 | - if(isset($linkType)){ |
|
| 317 | - if(is_array($linkType)){ |
|
| 316 | + if (isset($linkType)) { |
|
| 317 | + if (is_array($linkType)) { |
|
| 318 | 318 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 319 | 319 | } |
| 320 | - else{ |
|
| 320 | + else { |
|
| 321 | 321 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 322 | 322 | } |
| 323 | 323 | } |
@@ -345,11 +345,11 @@ discard block |
||
| 345 | 345 | ->_AND_($linkSet->sourceId->is($source->id)) |
| 346 | 346 | ->_AND_($linkSet->targetClass->is($this->newRecord() |
| 347 | 347 | ->getClassName())); |
| 348 | - if(isset($linkType)){ |
|
| 349 | - if(is_array($linkType)){ |
|
| 348 | + if (isset($linkType)) { |
|
| 349 | + if (is_array($linkType)) { |
|
| 350 | 350 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 351 | 351 | } |
| 352 | - else{ |
|
| 352 | + else { |
|
| 353 | 353 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 354 | 354 | } |
| 355 | 355 | } |
@@ -374,26 +374,26 @@ discard block |
||
| 374 | 374 | $linkSet->hasOne('targetId', $recordClassName); |
| 375 | 375 | |
| 376 | 376 | $sourceIdsByClasses = array(); |
| 377 | - foreach ($sources as $source){ |
|
| 377 | + foreach ($sources as $source) { |
|
| 378 | 378 | $sourceClass = $source->getClassName(); |
| 379 | - if(! isset($sourceIdsByClasses[$sourceClass])){ |
|
| 379 | + if (!isset($sourceIdsByClasses[$sourceClass])) { |
|
| 380 | 380 | $sourceIdsByClasses[$sourceClass] = array(); |
| 381 | 381 | } |
| 382 | 382 | $sourceIdsByClasses[$sourceClass][] = $source->id; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | $sourcesCriteria = array(); |
| 386 | - foreach ($sourceIdsByClasses as $sourceClass => $sourceIds){ |
|
| 386 | + foreach ($sourceIdsByClasses as $sourceClass => $sourceIds) { |
|
| 387 | 387 | $sourcesCriteria[] = $linkSet->sourceClass->is($sourceClass)->_AND_($linkSet->sourceId->in($sourceIds)); |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | $criteria = $linkSet->all($linkSet->targetClass->is($this->newRecord() |
| 391 | 391 | ->getClassName()), $linkSet->any($sourcesCriteria)); |
| 392 | - if(isset($linkType)){ |
|
| 393 | - if(is_array($linkType)){ |
|
| 392 | + if (isset($linkType)) { |
|
| 393 | + if (is_array($linkType)) { |
|
| 394 | 394 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 395 | 395 | } |
| 396 | - else{ |
|
| 396 | + else { |
|
| 397 | 397 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 398 | 398 | } |
| 399 | 399 | } |
@@ -418,26 +418,26 @@ discard block |
||
| 418 | 418 | $linkSet->hasOne('sourceId', $recordClassName); |
| 419 | 419 | |
| 420 | 420 | $targetIdsByClasses = array(); |
| 421 | - foreach ($targets as $target){ |
|
| 421 | + foreach ($targets as $target) { |
|
| 422 | 422 | $targetClass = $target->getClassName(); |
| 423 | - if(! isset($targetIdsByClasses[$targetClass])){ |
|
| 423 | + if (!isset($targetIdsByClasses[$targetClass])) { |
|
| 424 | 424 | $targetIdsByClasses[$targetClass] = array(); |
| 425 | 425 | } |
| 426 | 426 | $targetIdsByClasses[$targetClass][] = $target->id; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | $targetsCriteria = array(); |
| 430 | - foreach ($targetIdsByClasses as $targetClass => $targetIds){ |
|
| 430 | + foreach ($targetIdsByClasses as $targetClass => $targetIds) { |
|
| 431 | 431 | $targetsCriteria[] = $linkSet->targetClass->is($targetClass)->_AND_($linkSet->targetId->in($targetIds)); |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | $criteria = $linkSet->all($linkSet->sourceClass->is($this->newRecord() |
| 435 | 435 | ->getClassName()), $linkSet->any($targetsCriteria)); |
| 436 | - if(isset($linkType)){ |
|
| 437 | - if(is_array($linkType)){ |
|
| 436 | + if (isset($linkType)) { |
|
| 437 | + if (is_array($linkType)) { |
|
| 438 | 438 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 439 | 439 | } |
| 440 | - else{ |
|
| 440 | + else { |
|
| 441 | 441 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 442 | 442 | } |
| 443 | 443 | } |
@@ -552,19 +552,19 @@ discard block |
||
| 552 | 552 | $criteria = $linkSet->sourceClass->is($this->getRecordClassName()) |
| 553 | 553 | ->_AND_($linkSet->targetClass->is($tagClassName)); |
| 554 | 554 | |
| 555 | - if(is_array($tagLabels)){ |
|
| 555 | + if (is_array($tagLabels)) { |
|
| 556 | 556 | $criteria = $criteria->_AND_($linkSet->targetId->label->in($tagLabels)); |
| 557 | 557 | } |
| 558 | - else{ |
|
| 558 | + else { |
|
| 559 | 559 | $criteria = $criteria->_AND_($linkSet->targetId->label->is($tagLabels)); |
| 560 | 560 | } |
| 561 | - if(isset($linkType)){ |
|
| 561 | + if (isset($linkType)) { |
|
| 562 | 562 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 563 | 563 | } |
| 564 | 564 | $links = $linkSet->select($criteria); |
| 565 | 565 | |
| 566 | 566 | $ids = array(); |
| 567 | - foreach ($links as $link){ |
|
| 567 | + foreach ($links as $link) { |
|
| 568 | 568 | $ids[$link->sourceId] = $link->sourceId; |
| 569 | 569 | } |
| 570 | 570 | |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | { |
| 576 | 576 | $fields = $this->getFields(); |
| 577 | 577 | $manyRelations = $this->getHasManyRelations(); |
| 578 | - foreach ($manyRelations as $fieldName => $manyRelation){ |
|
| 578 | + foreach ($manyRelations as $fieldName => $manyRelation) { |
|
| 579 | 579 | $fields[$fieldName] = $manyRelation; |
| 580 | 580 | } |
| 581 | 581 | return $fields; |
@@ -171,8 +171,7 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | /*@var $customfield AppCustomField */ |
| 173 | 173 | } |
| 174 | - } |
|
| 175 | - catch (\ORM_BackEndSelectException $e){ |
|
| 174 | + } catch (\ORM_BackEndSelectException $e){ |
|
| 176 | 175 | // table does not exist, this error is thrown by the install program while creating the sets |
| 177 | 176 | } |
| 178 | 177 | } |
@@ -209,8 +208,7 @@ discard block |
||
| 209 | 208 | if($ormField instanceof \ORM_FkField){ |
| 210 | 209 | $this->hasOne($customField->fieldname, $ormField->getForeignSetName()) |
| 211 | 210 | ->setDescription($description); |
| 212 | - } |
|
| 213 | - else{ |
|
| 211 | + } else{ |
|
| 214 | 212 | $this->addFields($ormField); |
| 215 | 213 | } |
| 216 | 214 | } |
@@ -267,8 +265,7 @@ discard block |
||
| 267 | 265 | $linkSet = $this->App()->LinkSet(); |
| 268 | 266 | if(is_array($source) || ($source instanceof \Iterator)){ |
| 269 | 267 | return $linkSet->selectForSources($source, $this->getRecordClassName(), $linkType); |
| 270 | - } |
|
| 271 | - else{ |
|
| 268 | + } else{ |
|
| 272 | 269 | return $linkSet->selectForSource($source, $this->getRecordClassName(), $linkType); |
| 273 | 270 | } |
| 274 | 271 | } |
@@ -288,8 +285,7 @@ discard block |
||
| 288 | 285 | $linkSet = $this->App()->LinkSet(); |
| 289 | 286 | if(is_array($target) || ($target instanceof \Iterator)){ |
| 290 | 287 | return $linkSet->selectForTargets($target, $this->getRecordClassName(), $linkType); |
| 291 | - } |
|
| 292 | - else{ |
|
| 288 | + } else{ |
|
| 293 | 289 | return $linkSet->selectForTarget($target, $this->getRecordClassName(), $linkType); |
| 294 | 290 | } |
| 295 | 291 | } |
@@ -316,8 +312,7 @@ discard block |
||
| 316 | 312 | if(isset($linkType)){ |
| 317 | 313 | if(is_array($linkType)){ |
| 318 | 314 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 319 | - } |
|
| 320 | - else{ |
|
| 315 | + } else{ |
|
| 321 | 316 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 322 | 317 | } |
| 323 | 318 | } |
@@ -348,8 +343,7 @@ discard block |
||
| 348 | 343 | if(isset($linkType)){ |
| 349 | 344 | if(is_array($linkType)){ |
| 350 | 345 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 351 | - } |
|
| 352 | - else{ |
|
| 346 | + } else{ |
|
| 353 | 347 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 354 | 348 | } |
| 355 | 349 | } |
@@ -392,8 +386,7 @@ discard block |
||
| 392 | 386 | if(isset($linkType)){ |
| 393 | 387 | if(is_array($linkType)){ |
| 394 | 388 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 395 | - } |
|
| 396 | - else{ |
|
| 389 | + } else{ |
|
| 397 | 390 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 398 | 391 | } |
| 399 | 392 | } |
@@ -436,8 +429,7 @@ discard block |
||
| 436 | 429 | if(isset($linkType)){ |
| 437 | 430 | if(is_array($linkType)){ |
| 438 | 431 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 439 | - } |
|
| 440 | - else{ |
|
| 432 | + } else{ |
|
| 441 | 433 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 442 | 434 | } |
| 443 | 435 | } |
@@ -554,8 +546,7 @@ discard block |
||
| 554 | 546 | |
| 555 | 547 | if(is_array($tagLabels)){ |
| 556 | 548 | $criteria = $criteria->_AND_($linkSet->targetId->label->in($tagLabels)); |
| 557 | - } |
|
| 558 | - else{ |
|
| 549 | + } else{ |
|
| 559 | 550 | $criteria = $criteria->_AND_($linkSet->targetId->label->is($tagLabels)); |
| 560 | 551 | } |
| 561 | 552 | if(isset($linkType)){ |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | \ORM_BoolField('visible')->setOutputOptions($App->translate('No'), $App->translate('Yes'))->setDescription($App->translate('Column in list')) |
| 70 | 70 | ); |
| 71 | 71 | |
| 72 | - if($App->onlineShop){ |
|
| 72 | + if ($App->onlineShop) { |
|
| 73 | 73 | $this->addFields(\ORM_BoolField('visible_in_shop')); |
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | public function save(\ORM_Record $record, $noTrace = false) |
| 78 | 78 | { |
| 79 | - if(! $record->fieldname){ |
|
| 79 | + if (!$record->fieldname) { |
|
| 80 | 80 | $record->fieldname = $this->getFieldName($record->name); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | $name = preg_replace('/[^a-zA-Z0-9]+/', '', $name); |
| 98 | 98 | $name = mb_strtolower($name); |
| 99 | 99 | |
| 100 | - if(empty($name)){ |
|
| 100 | + if (empty($name)) { |
|
| 101 | 101 | throw new AppSaveException($this->App()->translate('The name is mandatory')); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - return '_' . $name; |
|
| 104 | + return '_'.$name; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | $arr = array(); |
| 117 | 117 | |
| 118 | - if(isset($App->Article)){ |
|
| 118 | + if (isset($App->Article)) { |
|
| 119 | 119 | $arr['Article'] = $App->translate('Products database'); |
| 120 | 120 | } |
| 121 | 121 | |
@@ -66,8 +66,8 @@ |
||
| 66 | 66 | public function serialize(AppRecord $record) |
| 67 | 67 | { |
| 68 | 68 | $values = $record->getValues(); |
| 69 | - foreach ($values as $key => $value){ |
|
| 70 | - if($value instanceof \ORM_Set){ |
|
| 69 | + foreach ($values as $key => $value) { |
|
| 70 | + if ($value instanceof \ORM_Set) { |
|
| 71 | 71 | $values[$key] = $value->id; |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | { |
| 54 | 54 | static $layouts = null; |
| 55 | 55 | |
| 56 | - if(! isset($layouts)){ |
|
| 56 | + if (!isset($layouts)) { |
|
| 57 | 57 | $layouts = array( |
| 58 | 58 | self::LAYOUT_VERTICAL_BOX => app_translate('Vertical box'), |
| 59 | 59 | self::LAYOUT_HORIZONTAL_BOX => app_translate('Horizontal box'), |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function isVisibleForRecord(AppRecord $record) |
| 72 | 72 | { |
| 73 | - if(empty($this->visibilityCriteria)){ |
|
| 73 | + if (empty($this->visibilityCriteria)) { |
|
| 74 | 74 | return true; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -79,36 +79,36 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | $arrCriteria = json_decode($this->visibilityCriteria, true); |
| 81 | 81 | |
| 82 | - foreach ($arrCriteria as $fieldName => $condition){ |
|
| 83 | - if(strpos($fieldName, '/') !== false){ |
|
| 82 | + foreach ($arrCriteria as $fieldName => $condition) { |
|
| 83 | + if (strpos($fieldName, '/') !== false) { |
|
| 84 | 84 | list ($oneField, $foreignField) = explode('/', $fieldName); |
| 85 | 85 | $field = $recordSet->$oneField()->$foreignField; |
| 86 | 86 | } |
| 87 | - else{ |
|
| 87 | + else { |
|
| 88 | 88 | $field = $recordSet->$fieldName; |
| 89 | 89 | } |
| 90 | - foreach ($condition as $op => $value){ |
|
| 91 | - if(! is_array($value)){ |
|
| 90 | + foreach ($condition as $op => $value) { |
|
| 91 | + if (!is_array($value)) { |
|
| 92 | 92 | $criteria = $field->$op($value); |
| 93 | 93 | } |
| 94 | - else{ |
|
| 95 | - foreach ($value as $foreignClassName => $foreignValues){ |
|
| 96 | - $foreignClassName = str_replace($App->classPrefix, '', $foreignClassName) . 'Set'; |
|
| 94 | + else { |
|
| 95 | + foreach ($value as $foreignClassName => $foreignValues) { |
|
| 96 | + $foreignClassName = str_replace($App->classPrefix, '', $foreignClassName).'Set'; |
|
| 97 | 97 | $foreignSet = $App->$foreignClassName(); |
| 98 | 98 | $foreignField = ''; |
| 99 | 99 | $foreignCondition = ''; |
| 100 | - foreach ($foreignValues as $foreignFieldName => $foreignConditions){ |
|
| 101 | - if($foreignFieldName === '_foreignField'){ |
|
| 100 | + foreach ($foreignValues as $foreignFieldName => $foreignConditions) { |
|
| 101 | + if ($foreignFieldName === '_foreignField') { |
|
| 102 | 102 | $foreignField = $foreignConditions; |
| 103 | 103 | } |
| 104 | - else{ |
|
| 105 | - foreach ($foreignConditions as $key => $val){ |
|
| 104 | + else { |
|
| 105 | + foreach ($foreignConditions as $key => $val) { |
|
| 106 | 106 | $foreignCondition = $foreignSet->$foreignFieldName->$key($val); |
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | - if(method_exists($foreignSet, 'getDefaultCriteria')){ |
|
| 111 | + if (method_exists($foreignSet, 'getDefaultCriteria')) { |
|
| 112 | 112 | $foreignCondition = $foreignCondition->_AND_($foreignSet->getDefaultCriteria()); |
| 113 | 113 | } |
| 114 | 114 | $criteria = $field->in($foreignCondition, $foreignField); |
@@ -83,15 +83,13 @@ discard block |
||
| 83 | 83 | if(strpos($fieldName, '/') !== false){ |
| 84 | 84 | list ($oneField, $foreignField) = explode('/', $fieldName); |
| 85 | 85 | $field = $recordSet->$oneField()->$foreignField; |
| 86 | - } |
|
| 87 | - else{ |
|
| 86 | + } else{ |
|
| 88 | 87 | $field = $recordSet->$fieldName; |
| 89 | 88 | } |
| 90 | 89 | foreach ($condition as $op => $value){ |
| 91 | 90 | if(! is_array($value)){ |
| 92 | 91 | $criteria = $field->$op($value); |
| 93 | - } |
|
| 94 | - else{ |
|
| 92 | + } else{ |
|
| 95 | 93 | foreach ($value as $foreignClassName => $foreignValues){ |
| 96 | 94 | $foreignClassName = str_replace($App->classPrefix, '', $foreignClassName) . 'Set'; |
| 97 | 95 | $foreignSet = $App->$foreignClassName(); |
@@ -100,8 +98,7 @@ discard block |
||
| 100 | 98 | foreach ($foreignValues as $foreignFieldName => $foreignConditions){ |
| 101 | 99 | if($foreignFieldName === '_foreignField'){ |
| 102 | 100 | $foreignField = $foreignConditions; |
| 103 | - } |
|
| 104 | - else{ |
|
| 101 | + } else{ |
|
| 105 | 102 | foreach ($foreignConditions as $key => $val){ |
| 106 | 103 | $foreignCondition = $foreignSet->$foreignFieldName->$key($val); |
| 107 | 104 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | { |
| 44 | 44 | $App = $this->App(); |
| 45 | 45 | $sseSet = $App->SSESet(); |
| 46 | - $sseSet->newReloadSelector('.' . self::NOTIFICATION_PORTLET_CLASS); |
|
| 46 | + $sseSet->newReloadSelector('.'.self::NOTIFICATION_PORTLET_CLASS); |
|
| 47 | 47 | $sseSet->newBrowserNotification(array( |
| 48 | 48 | 'title' => $this->title, |
| 49 | 49 | 'body' => $this->description, |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $this->seen = true; |
| 59 | 59 | $this->save(); |
| 60 | 60 | $sseSet = $this->App()->SSESet(); |
| 61 | - $sseSet->newReloadSelector('.' . self::NOTIFICATION_PORTLET_CLASS); |
|
| 61 | + $sseSet->newReloadSelector('.'.self::NOTIFICATION_PORTLET_CLASS); |
|
| 62 | 62 | return true; |
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | \ No newline at end of file |
@@ -76,18 +76,18 @@ |
||
| 76 | 76 | public function __call($name, $arguments) |
| 77 | 77 | { |
| 78 | 78 | // We delegate all undefined methods to the $item object. |
| 79 | - if(isset($this->item)){ |
|
| 79 | + if (isset($this->item)) { |
|
| 80 | 80 | $returnedValue = call_user_func_array(array( |
| 81 | 81 | $this->item, |
| 82 | 82 | $name |
| 83 | 83 | ), $arguments); |
| 84 | - if($returnedValue === $this->item){ |
|
| 84 | + if ($returnedValue === $this->item) { |
|
| 85 | 85 | $returnedValue = $this; |
| 86 | 86 | } |
| 87 | 87 | return $returnedValue; |
| 88 | 88 | } |
| 89 | - else{ |
|
| 90 | - trigger_error('the method ' . $name . ' does not exists on ' . get_class($this) . ' and there is no widget defined with the setInheritedItem method'); |
|
| 89 | + else { |
|
| 90 | + trigger_error('the method '.$name.' does not exists on '.get_class($this).' and there is no widget defined with the setInheritedItem method'); |
|
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
@@ -85,8 +85,7 @@ |
||
| 85 | 85 | $returnedValue = $this; |
| 86 | 86 | } |
| 87 | 87 | return $returnedValue; |
| 88 | - } |
|
| 89 | - else{ |
|
| 88 | + } else{ |
|
| 90 | 89 | trigger_error('the method ' . $name . ' does not exists on ' . get_class($this) . ' and there is no widget defined with the setInheritedItem method'); |
| 91 | 90 | } |
| 92 | 91 | } |
@@ -50,14 +50,14 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | $this->setHiddenValue('tg', $App->controllerTg); |
| 52 | 52 | |
| 53 | - if(isset($customfield)){ |
|
| 53 | + if (isset($customfield)) { |
|
| 54 | 54 | $this->setHiddenValue('customfield[id]', $customfield->id); |
| 55 | 55 | $values = $customfield->getValues(); |
| 56 | 56 | |
| 57 | - if(! empty($this->customfield->enumvalues)){ |
|
| 57 | + if (!empty($this->customfield->enumvalues)) { |
|
| 58 | 58 | $values['enumvalues'] = unserialize($this->customfield->enumvalues); |
| 59 | 59 | } |
| 60 | - else{ |
|
| 60 | + else { |
|
| 61 | 61 | $values['enumvalues'] = array( |
| 62 | 62 | '0' => '' |
| 63 | 63 | ); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $this->addItem($this->searchable()); |
| 83 | 83 | $this->addItem($this->visible()); |
| 84 | 84 | $this->addItem($this->importable()); |
| 85 | - if($App->onlineShop){ |
|
| 85 | + if ($App->onlineShop) { |
|
| 86 | 86 | $this->addItem($this->visible_in_shop()); |
| 87 | 87 | } |
| 88 | 88 | } |
@@ -175,16 +175,16 @@ discard block |
||
| 175 | 175 | $fieldValuesItem->addItem($W->Label($App->translate('List of available values'))); |
| 176 | 176 | $values = array(); |
| 177 | 177 | |
| 178 | - if(isset($this->customfield) && ! empty($this->customfield->enumvalues)){ |
|
| 178 | + if (isset($this->customfield) && !empty($this->customfield->enumvalues)) { |
|
| 179 | 179 | $values = unserialize($this->customfield->enumvalues); |
| 180 | 180 | |
| 181 | - foreach ($values as $name => $text){ |
|
| 181 | + foreach ($values as $name => $text) { |
|
| 182 | 182 | $fieldValuesItem->addItem($W->LineEdit() |
| 183 | 183 | ->setName((string) $name)); |
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if(empty($values)){ |
|
| 187 | + if (empty($values)) { |
|
| 188 | 188 | $fieldValuesItem->addItem($W->LineEdit() |
| 189 | 189 | ->setName('1')); |
| 190 | 190 | } |
@@ -56,8 +56,7 @@ |
||
| 56 | 56 | |
| 57 | 57 | if(! empty($this->customfield->enumvalues)){ |
| 58 | 58 | $values['enumvalues'] = unserialize($this->customfield->enumvalues); |
| 59 | - } |
|
| 60 | - else{ |
|
| 59 | + } else{ |
|
| 61 | 60 | $values['enumvalues'] = array( |
| 62 | 61 | '0' => '' |
| 63 | 62 | ); |