Skip to content

Commit 40c9336

Browse files
committed
Reformat code
1 parent 4569404 commit 40c9336

File tree

72 files changed

+2032
-1676
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2032
-1676
lines changed

assets/components/collections/connector.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@
33
* Collections Connector
44
*
55
* @package collections
6+
*
7+
* @var modX $modx
68
*/
7-
require_once dirname(dirname(dirname(dirname(__FILE__)))).'/config.core.php';
8-
require_once MODX_CORE_PATH.'config/'.MODX_CONFIG_KEY.'.inc.php';
9-
require_once MODX_CONNECTORS_PATH.'index.php';
9+
require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/config.core.php';
10+
require_once MODX_CORE_PATH . 'config/' . MODX_CONFIG_KEY . '.inc.php';
11+
require_once MODX_CONNECTORS_PATH . 'index.php';
1012

11-
$corePath = $modx->getOption('collections.core_path',null,$modx->getOption('core_path').'components/collections/');
12-
require_once $corePath.'model/collections/collections.class.php';
13+
$corePath = $modx->getOption('collections.core_path', null, $modx->getOption('core_path') . 'components/collections/');
14+
require_once $corePath . 'model/collections/collections.class.php';
1315
$modx->collections = new Collections($modx);
1416

1517
$modx->lexicon->load('collections:default');
1618

1719
/* handle request */
18-
$path = $modx->getOption('processorsPath',$modx->collections->config,$corePath.'processors/');
20+
$path = $modx->getOption('processorsPath', $modx->collections->config, $corePath . 'processors/');
1921
$modx->request->handleRequest(array(
2022
'processors_path' => $path,
2123
'location' => '',

core/components/collections/elements/plugins/collections.plugin.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* This plugin inject JS to handle proper working of close buttons in Resource's panel (OnDocFormPrerender)
88
* This plugin handles setting proper show_in_tree parameter (OnBeforeDocFormSave, OnResourceSort)
99
*
10+
* @var modX $modx
11+
* @var array $scriptProperties
1012
*/
1113
$corePath = $modx->getOption('collections.core_path', null, $modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/collections/');
1214
/** @var Collections $collections */
@@ -25,6 +27,7 @@
2527
$modx->loadClass($className, $collections->getOption('modelPath') . 'collections/events/', true, true);
2628

2729
if (class_exists($className)) {
30+
/** @var CollectionsPlugin $handler */
2831
$handler = new $className($modx, $scriptProperties);
2932
$handler->run();
3033
}

core/components/collections/elements/snippets/getselections.snippet.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,21 @@
2222
* [[getSelections? &selections=`1` &tpl=`rowTpl`]]
2323
* [[getSelections? &selections=`1` &tpl=`rowTpl` &sortby=`RAND()`]]
2424
*
25+
* @var modX $modx
26+
* @var array $scriptProperties
2527
*/
2628

27-
$collections = $modx->getService('collections','Collections',$modx->getOption('collections.core_path',null,$modx->getOption('core_path').'components/collections/').'model/collections/',$scriptProperties);
29+
$corePath = $modx->getOption('collections.core_path', null, $modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/collections/');
30+
31+
/** @var Collections $collections */
32+
$collections = $modx->getService(
33+
'collections',
34+
'Collections',
35+
$corePath . 'model/collections/',
36+
array(
37+
'core_path' => $corePath
38+
)
39+
);
2840
if (!($collections instanceof Collections)) return '';
2941

3042
$getResourcesSnippet = $modx->getOption('getResourcesSnippet', $scriptProperties, 'getResources');
@@ -36,7 +48,7 @@
3648
$selections = $modx->getOption('selections', $scriptProperties, '');
3749
$sortBy = $modx->getOption('sortby', $scriptProperties, '');
3850

39-
$selections = $modx->collections->explodeAndClean($selections);
51+
$selections = $collections->explodeAndClean($selections);
4052

4153
if ($sortDir != 'asc') {
4254
$sortDir = 'desc';
@@ -65,7 +77,7 @@
6577
$linkedResources = $linkedResourcesQuery->stmt->fetchAll(PDO::FETCH_COLUMN, 0);
6678

6779
$excludedResources = $modx->getOption('excludeResources', $scriptProperties, '');
68-
$excludedResources = $modx->collections->explodeAndClean($excludedResources);
80+
$excludedResources = $collections->explodeAndClean($excludedResources);
6981

7082
if (!empty($excludedResources)) {
7183
$linkedResources = array_diff($linkedResources, $excludedResources);

core/components/collections/model/collections/collectioncontainer.class.php

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,47 @@
11
<?php
2-
require_once MODX_CORE_PATH.'model/modx/modprocessor.class.php';
3-
require_once MODX_CORE_PATH.'model/modx/processors/resource/create.class.php';
4-
require_once MODX_CORE_PATH.'model/modx/processors/resource/update.class.php';
2+
require_once MODX_CORE_PATH . 'model/modx/modprocessor.class.php';
3+
require_once MODX_CORE_PATH . 'model/modx/processors/resource/create.class.php';
4+
require_once MODX_CORE_PATH . 'model/modx/processors/resource/update.class.php';
55

66
/**
77
* @package collections
88
*/
9-
class CollectionContainer extends modResource {
9+
class CollectionContainer extends modResource
10+
{
1011
public $showInContextMenu = true;
1112
public $allowDrop = 1;
12-
function __construct(xPDO & $xpdo) {
13-
parent :: __construct($xpdo);
14-
$this->set('class_key','CollectionContainer');
13+
14+
function __construct(xPDO & $xpdo)
15+
{
16+
parent:: __construct($xpdo);
17+
$this->set('class_key', 'CollectionContainer');
1518
}
1619

17-
public static function getControllerPath(xPDO &$modx) {
18-
return $modx->getOption('collections.core_path',null,$modx->getOption('core_path').'components/collections/').'controllers/';
20+
public static function getControllerPath(xPDO &$modx)
21+
{
22+
return $modx->getOption('collections.core_path', null, $modx->getOption('core_path') . 'components/collections/') . 'controllers/';
1923
}
2024

21-
public function getContextMenuText() {
25+
public function getContextMenuText()
26+
{
2227
$this->xpdo->lexicon->load('collections:default');
2328
return array(
2429
'text_create' => $this->xpdo->lexicon('collections.system.text_create'),
2530
'text_create_here' => $this->xpdo->lexicon('collections.system.text_create_here'),
2631
);
2732
}
2833

29-
public function getResourceTypeName() {
34+
public function getResourceTypeName()
35+
{
3036
$this->xpdo->lexicon->load('collections:default');
3137
return $this->xpdo->lexicon('collections.system.type_name');
3238
}
3339
}
3440

35-
class CollectionContainerCreateProcessor extends modResourceCreateProcessor {
36-
public function afterSave() {
41+
class CollectionContainerCreateProcessor extends modResourceCreateProcessor
42+
{
43+
public function afterSave()
44+
{
3745
$collectionsTemplate = $this->getProperty('collections_template');
3846
if ($collectionsTemplate === null) {
3947
return parent::afterSave();
@@ -56,11 +64,13 @@ public function afterSave() {
5664
}
5765
}
5866

59-
class CollectionContainerUpdateProcessor extends modResourceUpdateProcessor {
60-
public function afterSave() {
67+
class CollectionContainerUpdateProcessor extends modResourceUpdateProcessor
68+
{
69+
public function afterSave()
70+
{
6171
$collectionsTemplate = $this->getProperty('collections_template');
6272
if ($collectionsTemplate === null) {
63-
return parent::afterSave();
73+
return parent::afterSave();
6474
}
6575

6676
$collectionsTemplate = (int)$collectionsTemplate;
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @property int $collection_template
45
* @property int $resource_template
@@ -8,5 +9,6 @@
89
*
910
* @package collections
1011
*/
11-
class CollectionResourceTemplate extends xPDOObject {}
12-
?>
12+
class CollectionResourceTemplate extends xPDOObject
13+
{
14+
}

core/components/collections/model/collections/collections.class.php

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?php
2+
23
/**
34
* The base class for Collections.
45
*
56
* @package collections
67
*/
7-
class Collections {
8+
class Collections
9+
{
810
/** @var \modX $modx */
911
public $modx;
1012
public $namespace = 'collections';
@@ -13,13 +15,14 @@ class Collections {
1315
/** @var array $chunks */
1416
public $chunks = array();
1517

16-
function __construct(modX &$modx,array $config = array()) {
18+
function __construct(modX &$modx, array $config = array())
19+
{
1720
$this->modx =& $modx;
1821
$this->namespace = $this->getOption('namespace', $config, 'collections');
1922

2023
$corePath = $this->getOption('core_path', $config, $this->modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/collections/');
2124
$assetsUrl = $this->getOption('assets_url', $config, $this->modx->getOption('assets_url', null, MODX_ASSETS_URL) . 'components/collections/');
22-
$connectorUrl = $assetsUrl.'connector.php';
25+
$connectorUrl = $assetsUrl . 'connector.php';
2326

2427
$taggerCorePath = $modx->getOption('tagger.core_path', null, $modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/tagger/');
2528

@@ -58,25 +61,25 @@ function __construct(modX &$modx,array $config = array()) {
5861
'core_path' => $corePath,
5962

6063
'assetsUrl' => $assetsUrl,
61-
'cssUrl' => $assetsUrl.'css/',
62-
'jsUrl' => $assetsUrl.'js/',
63-
'imagesUrl' => $assetsUrl.'images/',
64+
'cssUrl' => $assetsUrl . 'css/',
65+
'jsUrl' => $assetsUrl . 'js/',
66+
'imagesUrl' => $assetsUrl . 'images/',
6467

6568
'connectorUrl' => $connectorUrl,
6669

6770
'corePath' => $corePath,
68-
'modelPath' => $corePath.'model/',
69-
'chunksPath' => $corePath.'elements/chunks/',
71+
'modelPath' => $corePath . 'model/',
72+
'chunksPath' => $corePath . 'elements/chunks/',
7073
'chunkSuffix' => '.chunk.tpl',
71-
'snippetsPath' => $corePath.'elements/snippets/',
72-
'processorsPath' => $corePath.'processors/',
73-
'templatesPath' => $corePath.'templates/',
74+
'snippetsPath' => $corePath . 'elements/snippets/',
75+
'processorsPath' => $corePath . 'processors/',
76+
'templatesPath' => $corePath . 'templates/',
7477

7578
'taggerInstalled' => $tagger instanceof Tagger,
7679
'quipInstalled' => $quip instanceof Quip,
77-
),$config);
80+
), $config);
7881

79-
$this->modx->addPackage('collections',$this->config['modelPath']);
82+
$this->modx->addPackage('collections', $this->config['modelPath']);
8083
$this->modx->lexicon->load('collections:default');
8184
$this->modx->lexicon->load('collections:selections');
8285
}
@@ -90,7 +93,8 @@ function __construct(modX &$modx,array $config = array()) {
9093
* namespaced system setting; by default this value is null.
9194
* @return mixed The option value or the default value specified.
9295
*/
93-
public function getOption($key, $options = array(), $default = null) {
96+
public function getOption($key, $options = array(), $default = null)
97+
{
9498
$option = $default;
9599
if (!empty($key) && is_string($key)) {
96100
if ($options != null && array_key_exists($key, $options)) {
@@ -104,7 +108,8 @@ public function getOption($key, $options = array(), $default = null) {
104108
return $option;
105109
}
106110

107-
public function explodeAndClean($array, $delimiter = ',', $keepDuplicates = 0) {
111+
public function explodeAndClean($array, $delimiter = ',', $keepDuplicates = 0)
112+
{
108113
$array = explode($delimiter, $array); // Explode fields to array
109114
$array = array_map('trim', $array); // Trim array's values
110115

@@ -121,7 +126,8 @@ public function explodeAndClean($array, $delimiter = ',', $keepDuplicates = 0) {
121126
* @param modResource $collection
122127
* @return CollectionTemplate
123128
*/
124-
public function getCollectionsView($collection) {
129+
public function getCollectionsView($collection)
130+
{
125131
$template = null;
126132

127133
/** @var CollectionSetting $collectionSetting */

core/components/collections/model/collections/collectionselection.class.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @property int $collection
45
* @property int $resource
@@ -10,5 +11,6 @@
1011
*
1112
* @package collections
1213
*/
13-
class CollectionSelection extends xPDOObject {}
14-
?>
14+
class CollectionSelection extends xPDOObject
15+
{
16+
}

core/components/collections/model/collections/collectionsetting.class.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
*
45
* @property int $id
@@ -10,5 +11,6 @@
1011
*
1112
* @package collections
1213
*/
13-
class CollectionSetting extends xPDOSimpleObject {}
14-
?>
14+
class CollectionSetting extends xPDOSimpleObject
15+
{
16+
}

core/components/collections/model/collections/collectiontemplate.class.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
*
45
* @property int $id
@@ -42,8 +43,10 @@
4243
*
4344
* @package collections
4445
*/
45-
class CollectionTemplate extends xPDOSimpleObject {
46-
public function setTemplates($templates) {
46+
class CollectionTemplate extends xPDOSimpleObject
47+
{
48+
public function setTemplates($templates)
49+
{
4750
$this->xpdo->removeCollection('CollectionResourceTemplate', array('collection_template' => $this->id));
4851

4952
if (!empty($templates)) {
@@ -58,5 +61,4 @@ public function setTemplates($templates) {
5861
return true;
5962
}
6063

61-
}
62-
?>
64+
}

core/components/collections/model/collections/collectiontemplatecolumn.class.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
*
45
* @property int $id
@@ -18,5 +19,6 @@
1819
*
1920
* @package collections
2021
*/
21-
class CollectionTemplateColumn extends xPDOSimpleObject {}
22-
?>
22+
class CollectionTemplateColumn extends xPDOSimpleObject
23+
{
24+
}

0 commit comments

Comments
 (0)