@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | /** |
141 | 141 | * @param $ids |
142 | - * @param null $fire_events |
|
142 | + * @param false|null $fire_events |
|
143 | 143 | * @return $this |
144 | 144 | */ |
145 | 145 | public function delete($ids, $fire_events = false) |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | /** |
154 | 154 | * @param $ids |
155 | 155 | * @param $rid |
156 | - * @param null $fire_events |
|
156 | + * @param false|null $fire_events |
|
157 | 157 | * @return $this |
158 | 158 | */ |
159 | 159 | public function deleteAll($ids, $rid, $fire_events = false) |
@@ -8,8 +8,8 @@ discard block |
||
8 | 8 | * Class dataTable |
9 | 9 | * @package SimpleTab |
10 | 10 | */ |
11 | -class dataTable extends \autoTable |
|
12 | -{ |
|
11 | +class dataTable extends \autoTable |
|
12 | +{ |
|
13 | 13 | /** |
14 | 14 | * @var array |
15 | 15 | */ |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | * @param \DocumentParser $modx |
41 | 41 | * @param bool $debug |
42 | 42 | */ |
43 | - public function __construct($modx, $debug = false) |
|
44 | - { |
|
43 | + public function __construct($modx, $debug = false) |
|
44 | + { |
|
45 | 45 | parent::__construct($modx, $debug); |
46 | 46 | $this->modx = $modx; |
47 | 47 | $this->params = (isset($modx->event->params) && is_array($modx->event->params)) ? $modx->event->params : array(); |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | * @param $ids |
53 | 53 | * @param $rid |
54 | 54 | */ |
55 | - protected function clearIndexes($ids, $rid) |
|
56 | - { |
|
55 | + protected function clearIndexes($ids, $rid) |
|
56 | + { |
|
57 | 57 | $ids = $this->cleanIDs($ids, ',', array(0)); |
58 | 58 | $ids = $this->sanitarIn($ids); |
59 | 59 | $table = $this->makeTable($this->table); |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * @param $field |
72 | 72 | * @return $this |
73 | 73 | */ |
74 | - public function touch($field) |
|
75 | - { |
|
74 | + public function touch($field) |
|
75 | + { |
|
76 | 76 | $this->set($field, date('Y-m-d H:i:s', time() + $this->modx->config['server_offset_time'])); |
77 | 77 | |
78 | 78 | return $this; |
@@ -83,22 +83,22 @@ discard block |
||
83 | 83 | * @param $dir |
84 | 84 | * @param $rid |
85 | 85 | */ |
86 | - public function place($ids, $dir, $rid) |
|
87 | - { |
|
86 | + public function place($ids, $dir, $rid) |
|
87 | + { |
|
88 | 88 | $table = $this->makeTable($this->table); |
89 | 89 | $ids = $this->cleanIDs($ids, ',', array(0)); |
90 | - if (empty($ids) || is_scalar($ids)) { |
|
90 | + if (empty($ids) || is_scalar($ids)) { |
|
91 | 91 | return false; |
92 | 92 | } |
93 | 93 | $rows = $this->query("SELECT count(`{$this->pkName}`) FROM {$table} WHERE `{$this->rfName}`={$rid}"); |
94 | 94 | $index = $this->modx->db->getValue($rows); |
95 | 95 | $cnt = count($ids); |
96 | 96 | $ids = implode(',', $ids); |
97 | - if ($dir == 'top') { |
|
97 | + if ($dir == 'top') { |
|
98 | 98 | $this->query("SET @index := " . ($index - $cnt - 1)); |
99 | 99 | $this->query("UPDATE {$table} SET `{$this->indexName}` = (@index := @index + 1) WHERE (`{$this->pkName}` IN ({$ids})) ORDER BY `{$this->indexName}` ASC"); |
100 | 100 | $this->query("SET @index := -1"); |
101 | - } else { |
|
101 | + } else { |
|
102 | 102 | $this->query("SET @index := -1"); |
103 | 103 | $this->query("UPDATE {$table} SET `{$this->indexName}` = (@index := @index + 1) WHERE (`{$this->pkName}` IN ({$ids})) ORDER BY `{$this->indexName}` ASC"); |
104 | 104 | $this->query("SET @index := " . ($cnt - 1)); |
@@ -113,26 +113,26 @@ discard block |
||
113 | 113 | * @param $url |
114 | 114 | * @param bool $cache |
115 | 115 | */ |
116 | - public function deleteThumb($url, $cache = false) |
|
117 | - { |
|
116 | + public function deleteThumb($url, $cache = false) |
|
117 | + { |
|
118 | 118 | $url = $this->fs->relativePath($url); |
119 | - if (empty($url)) { |
|
119 | + if (empty($url)) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | - if ($this->fs->checkFile($url)) { |
|
122 | + if ($this->fs->checkFile($url)) { |
|
123 | 123 | unlink(MODX_BASE_PATH . $url); |
124 | 124 | } |
125 | 125 | $dir = $this->fs->takeFileDir($url); |
126 | 126 | $iterator = new \FilesystemIterator($dir); |
127 | - if (!$iterator->valid()) { |
|
127 | + if (!$iterator->valid()) { |
|
128 | 128 | rmdir($dir); |
129 | 129 | } |
130 | - if ($cache) { |
|
130 | + if ($cache) { |
|
131 | 131 | return; |
132 | 132 | } |
133 | 133 | $thumbsCache = isset($this->params['thumbsCache']) ? $this->params['thumbsCache'] : $this->thumbsCache; |
134 | 134 | $thumb = $thumbsCache . $url; |
135 | - if ($this->fs->checkFile($thumb)) { |
|
135 | + if ($this->fs->checkFile($thumb)) { |
|
136 | 136 | $this->deleteThumb($thumb, true); |
137 | 137 | } |
138 | 138 | } |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | * @param null $fire_events |
143 | 143 | * @return $this |
144 | 144 | */ |
145 | - public function delete($ids, $fire_events = false) |
|
146 | - { |
|
145 | + public function delete($ids, $fire_events = false) |
|
146 | + { |
|
147 | 147 | $out = parent::delete($ids, $fire_events); |
148 | 148 | $this->query("ALTER TABLE {$this->makeTable($this->table)} AUTO_INCREMENT = 1"); |
149 | 149 | |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | * @param null $fire_events |
157 | 157 | * @return $this |
158 | 158 | */ |
159 | - public function deleteAll($ids, $rid, $fire_events = false) |
|
160 | - { |
|
159 | + public function deleteAll($ids, $rid, $fire_events = false) |
|
160 | + { |
|
161 | 161 | $this->clearIndexes($ids, $rid); |
162 | 162 | |
163 | 163 | return $this->delete($ids, $fire_events); |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | /** |
167 | 167 | * @return array |
168 | 168 | */ |
169 | - public function fieldNames() |
|
170 | - { |
|
169 | + public function fieldNames() |
|
170 | + { |
|
171 | 171 | $fields = array_keys($this->getDefaultFields()); |
172 | 172 | $fields[] = $this->fieldPKName(); |
173 | 173 | |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | * @param string $name |
179 | 179 | * @return string |
180 | 180 | */ |
181 | - public function stripName($name) |
|
182 | - { |
|
181 | + public function stripName($name) |
|
182 | + { |
|
183 | 183 | |
184 | 184 | $filename = $this->fs->takeFileName($name); |
185 | 185 | $ext = $this->fs->takeFileExt($name); |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | * @param $orderDir |
196 | 196 | * @return int|void |
197 | 197 | */ |
198 | - public function reorder($source, $target, $point, $rid, $orderDir) |
|
199 | - { |
|
198 | + public function reorder($source, $target, $point, $rid, $orderDir) |
|
199 | + { |
|
200 | 200 | $rid = (int)$rid; |
201 | 201 | $point = strtolower($point); |
202 | 202 | $orderDir = strtolower($orderDir); |
@@ -206,25 +206,25 @@ discard block |
||
206 | 206 | $table = $this->makeTable($this->table); |
207 | 207 | $rows = 0; |
208 | 208 | /* more refactoring needed */ |
209 | - if ($targetIndex < $sourceIndex) { |
|
210 | - if (($point == 'top' && $orderDir == 'asc') || ($point == 'bottom' && $orderDir == 'desc')) { |
|
209 | + if ($targetIndex < $sourceIndex) { |
|
210 | + if (($point == 'top' && $orderDir == 'asc') || ($point == 'bottom' && $orderDir == 'desc')) { |
|
211 | 211 | $this->modx->db->update("`{$this->indexName}`=`{$this->indexName}`+1", $table, |
212 | 212 | "`{$this->indexName}`>={$targetIndex} AND `{$this->indexName}`<{$sourceIndex} AND `{$this->rfName}`={$rid}"); |
213 | 213 | $rows = $this->modx->db->update("`{$this->indexName}`={$targetIndex}", $table, |
214 | 214 | "`{$this->pkName}`={$sourceId}"); |
215 | - } elseif (($point == 'bottom' && $orderDir == 'asc') || ($point == 'top' && $orderDir == 'desc')) { |
|
215 | + } elseif (($point == 'bottom' && $orderDir == 'asc') || ($point == 'top' && $orderDir == 'desc')) { |
|
216 | 216 | $this->modx->db->update("`{$this->indexName}`=`{$this->indexName}`+1", $table, |
217 | 217 | "`{$this->indexName}`>{$targetIndex} AND `{$this->indexName}`<{$sourceIndex} AND `{$this->rfName}`={$rid}"); |
218 | 218 | $rows = $this->modx->db->update("`{$this->indexName}`=1+{$targetIndex}", $table, |
219 | 219 | "`{$this->pkName}`={$sourceId}"); |
220 | 220 | } |
221 | - } else { |
|
222 | - if (($point == 'bottom' && $orderDir == 'asc') || ($point == 'top' && $orderDir == 'desc')) { |
|
221 | + } else { |
|
222 | + if (($point == 'bottom' && $orderDir == 'asc') || ($point == 'top' && $orderDir == 'desc')) { |
|
223 | 223 | $this->modx->db->update("`{$this->indexName}`=`{$this->indexName}`-1", $table, |
224 | 224 | "`{$this->indexName}`<={$targetIndex} AND `{$this->indexName}`>={$sourceIndex} AND `{$this->rfName}`={$rid}"); |
225 | 225 | $rows = $this->modx->db->update("`{$this->indexName}`={$targetIndex}", $table, |
226 | 226 | "`{$this->pkName}`={$sourceId}"); |
227 | - } elseif (($point == 'top' && $orderDir == 'asc') || ($point == 'bottom' && $orderDir == 'desc')) { |
|
227 | + } elseif (($point == 'top' && $orderDir == 'asc') || ($point == 'bottom' && $orderDir == 'desc')) { |
|
228 | 228 | $this->modx->db->update("`{$this->indexName}`=`{$this->indexName}`-1", $table, |
229 | 229 | "`{$this->indexName}`<{$targetIndex} AND `{$this->indexName}`>={$sourceIndex} AND `{$this->rfName}`={$rid}"); |
230 | 230 | $rows = $this->modx->db->update("`{$this->indexName}`=-1+{$targetIndex}", $table, |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | * @param $options |
242 | 242 | * @return bool |
243 | 243 | */ |
244 | - public function makeThumb($folder, $url, $options) |
|
245 | - { |
|
246 | - if (empty($url)) { |
|
244 | + public function makeThumb($folder, $url, $options) |
|
245 | + { |
|
246 | + if (empty($url)) { |
|
247 | 247 | return false; |
248 | 248 | } |
249 | 249 | $thumb = new \Helpers\PHPThumb(); |
@@ -251,9 +251,9 @@ discard block |
||
251 | 251 | $outputFile = MODX_BASE_PATH . $this->fs->relativePath($folder) . '/' . $this->fs->relativePath($url); |
252 | 252 | $dir = $this->fs->takeFileDir($outputFile); |
253 | 253 | $this->fs->makeDir($dir, $this->modx->config['new_folder_permissions']); |
254 | - if ($thumb->create($inputFile, $outputFile, $options)) { |
|
254 | + if ($thumb->create($inputFile, $outputFile, $options)) { |
|
255 | 255 | return true; |
256 | - } else { |
|
256 | + } else { |
|
257 | 257 | $this->modx->logEvent(0, 3, $thumb->debugMessages, __NAMESPACE__); |
258 | 258 | |
259 | 259 | return false; |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | * Class Plugin |
11 | 11 | * @package SimpleTab |
12 | 12 | */ |
13 | -abstract class Plugin |
|
14 | -{ |
|
13 | +abstract class Plugin |
|
14 | +{ |
|
15 | 15 | /** |
16 | 16 | * Объект DocumentParser - основной класс MODX |
17 | 17 | * @var \DocumentParser |
@@ -54,21 +54,21 @@ discard block |
||
54 | 54 | * @param $modx |
55 | 55 | * @param string $lang_attribute |
56 | 56 | */ |
57 | - public function __construct($modx, $lang_attribute = 'en') |
|
58 | - { |
|
57 | + public function __construct($modx, $lang_attribute = 'en') |
|
58 | + { |
|
59 | 59 | $this->modx = $modx; |
60 | 60 | $this->_table = $modx->getFullTableName($this->table); |
61 | 61 | $this->lang_attribute = $lang_attribute; |
62 | 62 | $this->params = $modx->event->params; |
63 | - if ($this->checkTemplate && !isset($this->params['template']) && $modx->event->name != 'OnEmptyTrash') { |
|
63 | + if ($this->checkTemplate && !isset($this->params['template']) && $modx->event->name != 'OnEmptyTrash') { |
|
64 | 64 | $doc = $modx->getDocument($this->params['id'], 'template', 'all', 'all'); |
65 | 65 | $this->params['template'] = is_array($doc) ? end($doc) : null; |
66 | 66 | } |
67 | 67 | //overload plugin and class properties |
68 | 68 | $_params = $modx->parseProperties('&template=;;' . $this->params['template'] . ' &id=;;' . $this->params['id'], |
69 | 69 | $modx->event->activePlugin, 'plugin'); |
70 | - foreach ($_params as $key => $value) { |
|
71 | - if (property_exists($this, $key)) { |
|
70 | + foreach ($_params as $key => $value) { |
|
71 | + if (property_exists($this, $key)) { |
|
72 | 72 | $this->$key = $value; |
73 | 73 | } |
74 | 74 | } |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | * @param array $ids |
85 | 85 | * @param $folder |
86 | 86 | */ |
87 | - public function clearFolders($ids = array(), $folder) |
|
88 | - { |
|
89 | - foreach ($ids as $id) { |
|
87 | + public function clearFolders($ids = array(), $folder) |
|
88 | + { |
|
89 | + foreach ($ids as $id) { |
|
90 | 90 | $this->fs->rmDir($folder . $id . '/'); |
91 | 91 | } |
92 | 92 | } |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * @return bool |
96 | 96 | */ |
97 | - public function checkPermissions() |
|
98 | - { |
|
97 | + public function checkPermissions() |
|
98 | + { |
|
99 | 99 | $templates = isset($this->params['templates']) ? explode(',', $this->params['templates']) : false; |
100 | 100 | $roles = isset($this->params['roles']) ? explode(',', $this->params['roles']) : false; |
101 | 101 | |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | /** |
115 | 115 | * @return string |
116 | 116 | */ |
117 | - public function prerender() |
|
118 | - { |
|
119 | - if (!$this->checkTable()) { |
|
117 | + public function prerender() |
|
118 | + { |
|
119 | + if (!$this->checkTable()) { |
|
120 | 120 | $result = $this->createTable(); |
121 | - if (!$result) { |
|
121 | + if (!$result) { |
|
122 | 122 | $this->modx->logEvent(0, 3, "Cannot create {$this->table} table.", $this->pluginName); |
123 | 123 | |
124 | 124 | return; |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | } |
128 | 128 | $output = $this->assets->registerJQuery(); |
129 | 129 | $tpl = MODX_BASE_PATH . $this->tpl; |
130 | - if ($this->fs->checkFile($tpl)) { |
|
130 | + if ($this->fs->checkFile($tpl)) { |
|
131 | 131 | $output .= '[+js+][+styles+]' . file_get_contents($tpl); |
132 | - } else { |
|
132 | + } else { |
|
133 | 133 | $this->modx->logEvent(0, 3, "Cannot load {$this->tpl} .", $this->pluginName); |
134 | 134 | |
135 | 135 | return false; |
@@ -143,20 +143,20 @@ discard block |
||
143 | 143 | * @param array $ph |
144 | 144 | * @return string |
145 | 145 | */ |
146 | - public function renderJS($list, $ph = array()) |
|
147 | - { |
|
146 | + public function renderJS($list, $ph = array()) |
|
147 | + { |
|
148 | 148 | $js = ''; |
149 | 149 | $scripts = MODX_BASE_PATH . $list; |
150 | - if ($this->fs->checkFile($scripts)) { |
|
150 | + if ($this->fs->checkFile($scripts)) { |
|
151 | 151 | $scripts = @file_get_contents($scripts); |
152 | 152 | $scripts = $this->DLTemplate->parseChunk('@CODE:' . $scripts, $ph); |
153 | 153 | $scripts = json_decode($scripts, true); |
154 | 154 | $scripts = isset($scripts['scripts']) ? $scripts['scripts'] : $scripts['styles']; |
155 | 155 | $js = $this->assets->registerScriptsList($scripts); |
156 | - } else { |
|
157 | - if ($list == $this->jsListDefault) { |
|
156 | + } else { |
|
157 | + if ($list == $this->jsListDefault) { |
|
158 | 158 | $this->modx->logEvent(0, 3, "Cannot load {$this->jsListDefault} .", $this->pluginName); |
159 | - } elseif ($list == $this->cssListDefault) { |
|
159 | + } elseif ($list == $this->cssListDefault) { |
|
160 | 160 | $this->modx->logEvent(0, 3, "Cannot load {$this->cssListDefault} .", $this->pluginName); |
161 | 161 | } |
162 | 162 | } |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | /** |
168 | 168 | * @return array |
169 | 169 | */ |
170 | - public function getTplPlaceholders() |
|
171 | - { |
|
170 | + public function getTplPlaceholders() |
|
171 | + { |
|
172 | 172 | $ph = array(); |
173 | 173 | |
174 | 174 | return $ph; |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | /** |
178 | 178 | * @return string |
179 | 179 | */ |
180 | - public function render() |
|
181 | - { |
|
182 | - if (!$this->checkPermissions()) { |
|
180 | + public function render() |
|
181 | + { |
|
182 | + if (!$this->checkPermissions()) { |
|
183 | 183 | $output = $this->prerender(); |
184 | - if ($output !== false) { |
|
184 | + if ($output !== false) { |
|
185 | 185 | $ph = $this->getTplPlaceholders(); |
186 | 186 | $ph['js'] = $this->renderJS($this->jsListDefault, $ph) . $this->renderJS($this->jsListCustom, $ph); |
187 | 187 | $ph['styles'] = $this->renderJS($this->cssListDefault, $ph) . $this->renderJS($this->cssListCustom, |
@@ -196,18 +196,18 @@ discard block |
||
196 | 196 | /** |
197 | 197 | * @return string |
198 | 198 | */ |
199 | - public function renderEmpty() |
|
200 | - { |
|
201 | - if (!$this->checkPermissions()) { |
|
199 | + public function renderEmpty() |
|
200 | + { |
|
201 | + if (!$this->checkPermissions()) { |
|
202 | 202 | $tpl = MODX_BASE_PATH . $this->emptyTpl; |
203 | - if ($this->fs->checkFile($tpl)) { |
|
203 | + if ($this->fs->checkFile($tpl)) { |
|
204 | 204 | $output = '[+js+]' . file_get_contents($tpl); |
205 | 205 | $ph = $this->getTplPlaceholders(); |
206 | 206 | $ph['js'] = $this->renderJS($this->jsListEmpty, $ph); |
207 | 207 | $output = $this->DLTemplate->parseChunk('@CODE:' . $output, $ph); |
208 | 208 | |
209 | 209 | return $output; |
210 | - } else { |
|
210 | + } else { |
|
211 | 211 | $this->modx->logEvent(0, 3, "Cannot load {$this->emptyTpl} .", $this->pluginName); |
212 | 212 | } |
213 | 213 | } |
@@ -216,8 +216,8 @@ discard block |
||
216 | 216 | /** |
217 | 217 | * @return bool |
218 | 218 | */ |
219 | - public function checkTable() |
|
220 | - { |
|
219 | + public function checkTable() |
|
220 | + { |
|
221 | 221 | $sql = "SHOW TABLES LIKE '{$this->_table}'"; |
222 | 222 | |
223 | 223 | return $this->modx->db->getRecordCount($this->modx->db->query($sql)); |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | /** |
227 | 227 | * @return mixed |
228 | 228 | */ |
229 | - public function createTable() |
|
230 | - { |
|
229 | + public function createTable() |
|
230 | + { |
|
231 | 231 | $sql = ''; |
232 | 232 | |
233 | 233 | return $this->modx->db->query($sql); |
@@ -237,14 +237,14 @@ discard block |
||
237 | 237 | * @param array $events |
238 | 238 | * @param string $eventsType |
239 | 239 | */ |
240 | - public function registerEvents($events = array(), $eventsType = '6') |
|
241 | - { |
|
240 | + public function registerEvents($events = array(), $eventsType = '6') |
|
241 | + { |
|
242 | 242 | $eventsTable = $this->modx->getFullTableName('system_eventnames'); |
243 | - foreach ($events as $event) { |
|
243 | + foreach ($events as $event) { |
|
244 | 244 | $result = $this->modx->db->select('`id`', $eventsTable, "`name` = '{$event}'"); |
245 | - if (!$this->modx->db->getRecordCount($result)) { |
|
245 | + if (!$this->modx->db->getRecordCount($result)) { |
|
246 | 246 | $sql = "INSERT INTO {$eventsTable} VALUES (NULL, '{$event}', '{$eventsType}', '{$this->pluginName} Events')"; |
247 | - if (!$this->modx->db->query($sql)) { |
|
247 | + if (!$this->modx->db->query($sql)) { |
|
248 | 248 | $this->modx->logEvent(0, 3, "Cannot register {$event} event.", $this->pluginName); |
249 | 249 | } |
250 | 250 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $output = ''; |
74 | 74 | $plugins = $this->modx->pluginEvent; |
75 | 75 | //файл проверяется чтобы определить новую админку |
76 | - if ((array_search('ManagerManager', $plugins['OnDocFormRender']) === false) || !file_exists(MODX_MANAGER_PATH . 'media/script/jquery/jquery.min.js')) { |
|
76 | + if ((array_search('ManagerManager', $plugins['OnDocFormRender']) === false) || ! file_exists(MODX_MANAGER_PATH . 'media/script/jquery/jquery.min.js')) { |
|
77 | 77 | $output .= $this->registerScript('jQuery', array( |
78 | 78 | 'src' => 'assets/js/jquery/jquery-1.9.1.min.js', |
79 | 79 | 'version' => '1.9.1' |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | public function registerScript($name, $params) |
93 | 93 | { |
94 | 94 | $out = ''; |
95 | - if (!isset($this->modx->loadedjscripts[$name])) { |
|
95 | + if ( ! isset($this->modx->loadedjscripts[$name])) { |
|
96 | 96 | $src = $params['src']; |
97 | 97 | $remote = strpos($src, "http") !== false; |
98 | - if (!$remote) { |
|
98 | + if ( ! $remote) { |
|
99 | 99 | $src = $this->modx->config['site_url'] . $src; |
100 | - if (!$this->fs->checkFile($params['src'])) { |
|
100 | + if ( ! $this->fs->checkFile($params['src'])) { |
|
101 | 101 | $this->modx->logEvent(0, 3, 'Cannot load ' . $src, 'Assets helper'); |
102 | 102 | |
103 | 103 | return $out; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | public function registerScriptsList($list = array()) |
128 | 128 | { |
129 | 129 | $out = ''; |
130 | - if (!is_array($list)) return $out; |
|
130 | + if ( ! is_array($list)) return $out; |
|
131 | 131 | |
132 | 132 | foreach ($list as $script => $params) { |
133 | 133 | $out .= $this->registerScript($script, $params); |
@@ -5,8 +5,8 @@ discard block |
||
5 | 5 | /** |
6 | 6 | * Class AssetsHelper |
7 | 7 | */ |
8 | -class AssetsHelper |
|
9 | -{ |
|
8 | +class AssetsHelper |
|
9 | +{ |
|
10 | 10 | /** |
11 | 11 | * Объект DocumentParser - основной класс MODX |
12 | 12 | * @var \DocumentParser |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @return self |
27 | 27 | */ |
28 | - public static function getInstance(DocumentParser $modx) |
|
29 | - { |
|
28 | + public static function getInstance(DocumentParser $modx) |
|
29 | + { |
|
30 | 30 | |
31 | - if (null === self::$instance) { |
|
31 | + if (null === self::$instance) { |
|
32 | 32 | self::$instance = new self($modx); |
33 | 33 | } |
34 | 34 | |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | * is not allowed to call from outside: private! |
40 | 40 | * |
41 | 41 | */ |
42 | - private function __construct(DocumentParser $modx) |
|
43 | - { |
|
42 | + private function __construct(DocumentParser $modx) |
|
43 | + { |
|
44 | 44 | $this->modx = $modx; |
45 | 45 | $this->fs = \Helpers\FS::getInstance(); |
46 | 46 | } |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @return void |
52 | 52 | */ |
53 | - private function __clone() |
|
54 | - { |
|
53 | + private function __clone() |
|
54 | + { |
|
55 | 55 | |
56 | 56 | } |
57 | 57 | |
@@ -60,20 +60,20 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return void |
62 | 62 | */ |
63 | - private function __wakeup() |
|
64 | - { |
|
63 | + private function __wakeup() |
|
64 | + { |
|
65 | 65 | |
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @return string |
70 | 70 | */ |
71 | - public function registerJQuery() |
|
72 | - { |
|
71 | + public function registerJQuery() |
|
72 | + { |
|
73 | 73 | $output = ''; |
74 | 74 | $plugins = $this->modx->pluginEvent; |
75 | 75 | //файл проверяется чтобы определить новую админку |
76 | - if ((array_search('ManagerManager', $plugins['OnDocFormRender']) === false) || !file_exists(MODX_MANAGER_PATH . 'media/script/jquery/jquery.min.js')) { |
|
76 | + if ((array_search('ManagerManager', $plugins['OnDocFormRender']) === false) || !file_exists(MODX_MANAGER_PATH . 'media/script/jquery/jquery.min.js')) { |
|
77 | 77 | $output .= $this->registerScript('jQuery', array( |
78 | 78 | 'src' => 'assets/js/jquery/jquery-1.9.1.min.js', |
79 | 79 | 'version' => '1.9.1' |
@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | * @param $params |
90 | 90 | * @return string |
91 | 91 | */ |
92 | - public function registerScript($name, $params) |
|
93 | - { |
|
92 | + public function registerScript($name, $params) |
|
93 | + { |
|
94 | 94 | $out = ''; |
95 | - if (!isset($this->modx->loadedjscripts[$name])) { |
|
95 | + if (!isset($this->modx->loadedjscripts[$name])) { |
|
96 | 96 | $src = $params['src']; |
97 | 97 | $remote = strpos($src, "http") !== false; |
98 | - if (!$remote) { |
|
98 | + if (!$remote) { |
|
99 | 99 | $src = $this->modx->config['site_url'] . $src; |
100 | - if (!$this->fs->checkFile($params['src'])) { |
|
100 | + if (!$this->fs->checkFile($params['src'])) { |
|
101 | 101 | $this->modx->logEvent(0, 3, 'Cannot load ' . $src, 'Assets helper'); |
102 | 102 | |
103 | 103 | return $out; |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | |
107 | 107 | $tmp = explode('.', $src); |
108 | 108 | $type = isset($params['type']) ? $params['type'] : end($tmp); |
109 | - if ($type == 'js') { |
|
109 | + if ($type == 'js') { |
|
110 | 110 | $out = '<script type="text/javascript" src="' . $src . '"></script>'; |
111 | - } else { |
|
111 | + } else { |
|
112 | 112 | $media = isset($params['media']) ? " media=\"{$params['media']}\"" : ''; |
113 | 113 | $out = "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$src}\"{$media}>"; |
114 | 114 | } |
@@ -124,12 +124,14 @@ discard block |
||
124 | 124 | * @param array $list |
125 | 125 | * @return string |
126 | 126 | */ |
127 | - public function registerScriptsList($list = array()) |
|
128 | - { |
|
127 | + public function registerScriptsList($list = array()) |
|
128 | + { |
|
129 | 129 | $out = ''; |
130 | - if (!is_array($list)) return $out; |
|
130 | + if (!is_array($list)) { |
|
131 | + return $out; |
|
132 | + } |
|
131 | 133 | |
132 | - foreach ($list as $script => $params) { |
|
134 | + foreach ($list as $script => $params) { |
|
133 | 135 | $out .= $this->registerScript($script, $params); |
134 | 136 | } |
135 | 137 |