@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | } |
21 | 21 | |
22 | 22 | if(!is_array($modx->event->params)){ |
23 | - $modx->event->params = array(); |
|
23 | + $modx->event->params = array(); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | $ajax = (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'); |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | |
53 | 53 | $tpl = \RedirectMap\Action::$TPL; |
54 | 54 | if(!is_null($tpl)){ |
55 | - $out = $TPL->showHeader(); |
|
56 | - $out .= $TPL->showBody($tpl, $data); |
|
57 | - $out .= $TPL->showFooter(); |
|
55 | + $out = $TPL->showHeader(); |
|
56 | + $out .= $TPL->showBody($tpl, $data); |
|
57 | + $out .= $TPL->showFooter(); |
|
58 | 58 | }else{ |
59 | - header('Content-type: application/json'); |
|
60 | - $out = json_encode($data); |
|
59 | + header('Content-type: application/json'); |
|
60 | + $out = json_encode($data); |
|
61 | 61 | } |
62 | 62 | echo $out; |
63 | 63 | \ No newline at end of file |
@@ -38,7 +38,7 @@ |
||
38 | 38 | $out = $TPL->showHeader(); |
39 | 39 | $out .= $TPL->showBody($tpl, $data); |
40 | 40 | $out .= $TPL->showFooter(); |
41 | -}else{ |
|
41 | +} else{ |
|
42 | 42 | header('Content-type: application/json'); |
43 | 43 | $out = json_encode($data); |
44 | 44 | } |
@@ -16,29 +16,29 @@ discard block |
||
16 | 16 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the MODX Content Manager instead of accessing this file directly."); |
17 | 17 | } |
18 | 18 | if (!$modx->hasPermission('exec_module')) { |
19 | - header("location: " . $modx->getManagerPath() . "?a=106"); |
|
19 | + header("location: ".$modx->getManagerPath()."?a=106"); |
|
20 | 20 | } |
21 | 21 | |
22 | -if(!is_array($modx->event->params)){ |
|
22 | +if (!is_array($modx->event->params)) { |
|
23 | 23 | $modx->event->params = array(); |
24 | 24 | } |
25 | 25 | |
26 | 26 | $ajax = (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'); |
27 | 27 | $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
28 | 28 | |
29 | -include_once(dirname(__FILE__) . "/src/modRedirectMap.class.php"); |
|
29 | +include_once(dirname(__FILE__)."/src/modRedirectMap.class.php"); |
|
30 | 30 | include_once(MODX_BASE_PATH.'assets/lib/Module/Action.php'); |
31 | 31 | include_once(MODX_BASE_PATH.'assets/lib/Module/Helper.php'); |
32 | 32 | include_once(MODX_BASE_PATH.'assets/lib/Module/Template.php'); |
33 | 33 | include_once(MODX_BASE_PATH.'assets/lib/Helpers/FS.php'); |
34 | 34 | |
35 | -include_once(dirname(__FILE__) . "/src/Helper.class.php"); |
|
35 | +include_once(dirname(__FILE__)."/src/Helper.class.php"); |
|
36 | 36 | \RedirectMap\Helper::init($modx); |
37 | 37 | |
38 | -include_once(dirname(__FILE__) . "/src/Template.class.php"); |
|
38 | +include_once(dirname(__FILE__)."/src/Template.class.php"); |
|
39 | 39 | $TPL = new \RedirectMap\Template($modx, $ajax, dirname(__FILE__)); |
40 | 40 | |
41 | -include_once(dirname(__FILE__) . "/src/Action.class.php"); |
|
41 | +include_once(dirname(__FILE__)."/src/Action.class.php"); |
|
42 | 42 | \RedirectMap\Action::init($modx, $TPL, new \RedirectMap\modRedirectMap($modx)); |
43 | 43 | |
44 | 44 | if (!empty($action) && method_exists('\RedirectMap\Action', $action)) { |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | $tpl = \RedirectMap\Action::$TPL; |
54 | -if(!is_null($tpl)){ |
|
54 | +if (!is_null($tpl)) { |
|
55 | 55 | $out = $TPL->showHeader(); |
56 | 56 | $out .= $TPL->showBody($tpl, $data); |
57 | 57 | $out .= $TPL->showFooter(); |
58 | -}else{ |
|
58 | +} else { |
|
59 | 59 | header('Content-type: application/json'); |
60 | 60 | $out = json_encode($data); |
61 | 61 | } |
@@ -25,21 +25,21 @@ |
||
25 | 25 | \DLCity\Action::init($modx, $TPL, new modResource($modx)); |
26 | 26 | |
27 | 27 | if (!empty($action) && method_exists('\DLCity\Action', $action)) { |
28 | - $data = call_user_func_array(array('\DLCity\Action', $action), array()); |
|
29 | - if (!is_array($data)) { |
|
30 | - $data = array(); |
|
31 | - } |
|
28 | + $data = call_user_func_array(array('\DLCity\Action', $action), array()); |
|
29 | + if (!is_array($data)) { |
|
30 | + $data = array(); |
|
31 | + } |
|
32 | 32 | } else { |
33 | - $data = array(); |
|
33 | + $data = array(); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | $tpl = \DLCity\Action::$TPL; |
37 | 37 | if(!is_null($tpl)){ |
38 | - $out = $TPL->showHeader(); |
|
39 | - $out .= $TPL->showBody($tpl, $data); |
|
40 | - $out .= $TPL->showFooter(); |
|
38 | + $out = $TPL->showHeader(); |
|
39 | + $out .= $TPL->showBody($tpl, $data); |
|
40 | + $out .= $TPL->showFooter(); |
|
41 | 41 | }else{ |
42 | - header('Content-type: application/json'); |
|
43 | - $out = json_encode($data); |
|
42 | + header('Content-type: application/json'); |
|
43 | + $out = json_encode($data); |
|
44 | 44 | } |
45 | 45 | echo $out; |
46 | 46 | \ No newline at end of file |
@@ -38,7 +38,7 @@ |
||
38 | 38 | $out = $TPL->showHeader(); |
39 | 39 | $out .= $TPL->showBody($tpl, $data); |
40 | 40 | $out .= $TPL->showFooter(); |
41 | -}else{ |
|
41 | +} else{ |
|
42 | 42 | header('Content-type: application/json'); |
43 | 43 | $out = json_encode($data); |
44 | 44 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the MODX Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | if (!$modx->hasPermission('exec_module')) { |
6 | - header("location: " . $modx->getManagerPath() . "?a=106"); |
|
6 | + header("location: ".$modx->getManagerPath()."?a=106"); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $ajax = (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'); |
@@ -15,13 +15,13 @@ discard block |
||
15 | 15 | include_once(MODX_BASE_PATH.'assets/lib/Helpers/FS.php'); |
16 | 16 | include_once(MODX_BASE_PATH.'assets/lib/MODxAPI/modResource.php'); |
17 | 17 | |
18 | -include_once(dirname(__FILE__) . "/Helper.class.php"); |
|
18 | +include_once(dirname(__FILE__)."/Helper.class.php"); |
|
19 | 19 | \DLCity\Helper::init($modx, isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 'city'); |
20 | 20 | |
21 | -include_once(dirname(__FILE__) . "/Template.class.php"); |
|
21 | +include_once(dirname(__FILE__)."/Template.class.php"); |
|
22 | 22 | $TPL = new \DLCity\Template($modx, $ajax, dirname(__FILE__)); |
23 | 23 | |
24 | -include_once(dirname(__FILE__) . "/Action.class.php"); |
|
24 | +include_once(dirname(__FILE__)."/Action.class.php"); |
|
25 | 25 | \DLCity\Action::init($modx, $TPL, new modResource($modx)); |
26 | 26 | |
27 | 27 | if (!empty($action) && method_exists('\DLCity\Action', $action)) { |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | $tpl = \DLCity\Action::$TPL; |
37 | -if(!is_null($tpl)){ |
|
37 | +if (!is_null($tpl)) { |
|
38 | 38 | $out = $TPL->showHeader(); |
39 | 39 | $out .= $TPL->showBody($tpl, $data); |
40 | 40 | $out .= $TPL->showFooter(); |
41 | -}else{ |
|
41 | +} else { |
|
42 | 42 | header('Content-type: application/json'); |
43 | 43 | $out = json_encode($data); |
44 | 44 | } |
@@ -125,7 +125,7 @@ |
||
125 | 125 | for ($i = $len; $i > 0; $i--) { |
126 | 126 | switch ($data[rand(0, ($opt - 1))]) { |
127 | 127 | case 'A': |
128 | - $tmp = rand(65, 90); |
|
128 | + $tmp = rand(65, 90); |
|
129 | 129 | break; |
130 | 130 | case 'a': |
131 | 131 | $tmp = rand(97, 122); |
@@ -41,7 +41,7 @@ |
||
41 | 41 | $text = mb_substr($text, 0, $len+1, $encoding); |
42 | 42 | if(mb_substr($text, -1, null, $encoding) == ' '){ |
43 | 43 | $out = trim($text); |
44 | - }else{ |
|
44 | + } else{ |
|
45 | 45 | $out = mb_substr($text, 0, mb_strripos($text, ' ', null, $encoding), $encoding); |
46 | 46 | } |
47 | 47 | return preg_replace("/(([\.,\-:!?;\s])|(&\w+;))+$/ui", "", $out); |
@@ -8,8 +8,8 @@ discard block |
||
8 | 8 | * @param string $encoding - кодировка, по-умолчанию UTF-8 |
9 | 9 | * @return string |
10 | 10 | */ |
11 | - public static function mb_lcfirst($str, $encoding='UTF-8'){ |
|
12 | - return mb_strtolower(mb_substr($str, 0, 1, $encoding), $encoding).mb_substr($str,1, mb_strlen($str), $encoding); |
|
11 | + public static function mb_lcfirst($str, $encoding = 'UTF-8') { |
|
12 | + return mb_strtolower(mb_substr($str, 0, 1, $encoding), $encoding).mb_substr($str, 1, mb_strlen($str), $encoding); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | /** |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param string $encoding - кодировка, по-умолчанию UTF-8 |
19 | 19 | * @return string |
20 | 20 | */ |
21 | - public static function mb_ucfirst($str, $encoding='UTF-8') |
|
21 | + public static function mb_ucfirst($str, $encoding = 'UTF-8') |
|
22 | 22 | { |
23 | 23 | $str = mb_ereg_replace('^[\ ]+', '', $str); |
24 | 24 | $str = mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding).mb_substr($str, 1, mb_strlen($str), $encoding); |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | * @param string $encoding кодировка |
37 | 37 | * @return string |
38 | 38 | */ |
39 | - public static function mb_trim_word($html, $len, $encoding = 'UTF-8'){ |
|
39 | + public static function mb_trim_word($html, $len, $encoding = 'UTF-8') { |
|
40 | 40 | $text = trim(preg_replace('|\s+|', ' ', strip_tags($html))); |
41 | - $text = mb_substr($text, 0, $len+1, $encoding); |
|
42 | - if(mb_substr($text, -1, null, $encoding) == ' '){ |
|
41 | + $text = mb_substr($text, 0, $len + 1, $encoding); |
|
42 | + if (mb_substr($text, -1, null, $encoding) == ' ') { |
|
43 | 43 | $out = trim($text); |
44 | - }else{ |
|
44 | + } else { |
|
45 | 45 | $out = mb_substr($text, 0, mb_strripos($text, ' ', null, $encoding), $encoding); |
46 | 46 | } |
47 | 47 | return preg_replace("/(([\.,\-:!?;\s])|(&\w+;))+$/ui", "", $out); |
@@ -216,8 +216,8 @@ discard block |
||
216 | 216 | '[' => '[', '%5B' => '[', ']' => ']', '%5D' => ']', |
217 | 217 | '{' => '{', '%7B' => '{', '}' => '}', '%7D' => '}', |
218 | 218 | '`' => '`', '%60' => '`' |
219 | - )){ |
|
220 | - switch(true){ |
|
219 | + )) { |
|
220 | + switch (true) { |
|
221 | 221 | case is_scalar($data): |
222 | 222 | $out = str_replace( |
223 | 223 | array_keys($chars), |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | break; |
228 | 228 | case is_array($data): |
229 | 229 | $out = $data; |
230 | - foreach($out as $key => &$val){ |
|
230 | + foreach ($out as $key => &$val) { |
|
231 | 231 | $val = self::sanitarTag($val, $charset, $chars); |
232 | 232 | } |
233 | 233 | break; |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | return $out; |
238 | 238 | } |
239 | 239 | |
240 | - public static function e($text, $charset = 'UTF-8'){ |
|
240 | + public static function e($text, $charset = 'UTF-8') { |
|
241 | 241 | return is_scalar($text) ? htmlspecialchars($text, ENT_QUOTES, $charset, false) : ''; |
242 | 242 | } |
243 | 243 | /** |
@@ -319,12 +319,12 @@ discard block |
||
319 | 319 | if ($prefix == '' && $suffix == '') { |
320 | 320 | $out = $data; |
321 | 321 | } else { |
322 | - $InsertPrefix = ($prefix != '') ? ($prefix . $addPS) : ''; |
|
323 | - $InsertSuffix = ($suffix != '') ? ($addPS. $suffix) : ''; |
|
322 | + $InsertPrefix = ($prefix != '') ? ($prefix.$addPS) : ''; |
|
323 | + $InsertSuffix = ($suffix != '') ? ($addPS.$suffix) : ''; |
|
324 | 324 | foreach ($data as $key => $item) { |
325 | - $key = $InsertPrefix . $key; |
|
325 | + $key = $InsertPrefix.$key; |
|
326 | 326 | $val = null; |
327 | - switch(true){ |
|
327 | + switch (true) { |
|
328 | 328 | case is_scalar($item): |
329 | 329 | $val = $item; |
330 | 330 | break; |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | $val = ''; |
335 | 335 | break; |
336 | 336 | } |
337 | - $out[$key . $InsertSuffix] = $val; |
|
337 | + $out[$key.$InsertSuffix] = $val; |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | return $out; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @license GNU General Public License (GPL), http://www.gnu.org/copyleft/gpl.html |
74 | 74 | * @param string $email проверяемый email |
75 | 75 | * @param boolean $dns проверять ли DNS записи |
76 | - * @return boolean Результат проверки почтового ящика |
|
76 | + * @return false|string Результат проверки почтового ящика |
|
77 | 77 | * @author Anton Shevchuk |
78 | 78 | */ |
79 | 79 | public static function emailValidate($email, $dns = true) |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
149 | - * @param $data |
|
149 | + * @param string $data |
|
150 | 150 | * @return bool|false|string |
151 | 151 | */ |
152 | 152 | private function _getEnv($data) |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $textMethod = $data['key'].'Text'; |
60 | 60 | if(method_exists($modObj, $textMethod)){ |
61 | 61 | $out['value'] = $modObj->$textMethod(); |
62 | - }else{ |
|
62 | + } else{ |
|
63 | 63 | $out['value'] = $modObj->get($data['key']); |
64 | 64 | } |
65 | 65 | } |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | ), self::$modx->getFullTableName(self::TABLE()), "id = ".$dataID); |
85 | 85 | if($q){ |
86 | 86 | $data['log'] = $oldValue ? 'Запись с ID '.$dataID.' восстановлена' : 'Запись с ID '.$dataID.' удалена'; |
87 | - }else{ |
|
87 | + } else{ |
|
88 | 88 | $data['log'] = $oldValue ? 'Не удалось восстановить запись с ID '.$dataID : 'Не удалось удалить запись с ID '.$dataID; |
89 | 89 | } |
90 | - }else{ |
|
90 | + } else{ |
|
91 | 91 | $data['log'] = '<span class="error">Ошибка</span>. Не удалось определить обновляему запись'; |
92 | 92 | } |
93 | 93 | return $data; |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | public static $TPL = null; |
10 | 10 | protected static $TABLE = "site_content"; |
11 | 11 | protected static $classTable = null; |
12 | - protected static $_tplObj = null; |
|
12 | + protected static $_tplObj = null; |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * @param \DocumentParser $modx |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | public static function init(\DocumentParser $modx, Template $tpl, \MODxAPI $classTable){ |
27 | 27 | self::setMODX($modx); |
28 | 28 | self::$TPL = Template::showLog(); |
29 | - self::$_tplObj = $tpl; |
|
29 | + self::$_tplObj = $tpl; |
|
30 | 30 | self::$classTable = $classTable; |
31 | 31 | } |
32 | 32 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @return array |
125 | 125 | */ |
126 | 126 | public static function deleted(){ |
127 | - $data = array(); |
|
127 | + $data = array(); |
|
128 | 128 | $dataID = (int)Template::getParam('docId', $_GET); |
129 | 129 | if($dataID>0 && self::_checkObj($dataID)){ |
130 | 130 | $oldValue = self::_getValue('deleted_at', $dataID); |
@@ -149,6 +149,6 @@ discard block |
||
149 | 149 | * @return null |
150 | 150 | */ |
151 | 151 | public static function getClassTable(){ |
152 | - return self::$classTable; |
|
153 | - } |
|
152 | + return self::$classTable; |
|
153 | + } |
|
154 | 154 | } |
155 | 155 | \ No newline at end of file |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * Class Action |
5 | 5 | * @package Module |
6 | 6 | */ |
7 | -abstract class Action{ |
|
7 | +abstract class Action { |
|
8 | 8 | protected static $modx = null; |
9 | 9 | public static $TPL = null; |
10 | 10 | protected static $TABLE = "site_content"; |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * @param \DocumentParser $modx |
16 | 16 | */ |
17 | - public static function setMODX(\DocumentParser $modx){ |
|
17 | + public static function setMODX(\DocumentParser $modx) { |
|
18 | 18 | self::$modx = $modx; |
19 | 19 | } |
20 | 20 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param Template $tpl |
24 | 24 | * @param \MODxAPI $classTable |
25 | 25 | */ |
26 | - public static function init(\DocumentParser $modx, Template $tpl, \MODxAPI $classTable){ |
|
26 | + public static function init(\DocumentParser $modx, Template $tpl, \MODxAPI $classTable) { |
|
27 | 27 | self::setMODX($modx); |
28 | 28 | self::$TPL = Template::showLog(); |
29 | 29 | self::$_tplObj = $tpl; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * @return string |
35 | 35 | */ |
36 | - public static function TABLE(){ |
|
36 | + public static function TABLE() { |
|
37 | 37 | return static::$TABLE; |
38 | 38 | } |
39 | 39 | |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | * @param $id |
42 | 42 | * @return bool |
43 | 43 | */ |
44 | - protected static function _checkObj($id){ |
|
44 | + protected static function _checkObj($id) { |
|
45 | 45 | $q = self::$modx->db->select('id', self::$modx->getFullTableName(self::TABLE()), "id = ".$id); |
46 | - return (self::$modx->db->getRecordCount($q)==1); |
|
46 | + return (self::$modx->db->getRecordCount($q) == 1); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param $id |
52 | 52 | * @return mixed |
53 | 53 | */ |
54 | - protected static function _getValue($field, $id){ |
|
54 | + protected static function _getValue($field, $id) { |
|
55 | 55 | $q = self::$modx->db->select($field, self::$modx->getFullTableName(self::TABLE()), "id = ".$id); |
56 | 56 | return self::$modx->db->getValue($q); |
57 | 57 | } |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | /** |
60 | 60 | * @return array|mixed |
61 | 61 | */ |
62 | - public static function listValue(){ |
|
63 | - $out = self::_workValue(function($data, $modObj){ |
|
62 | + public static function listValue() { |
|
63 | + $out = self::_workValue(function($data, $modObj) { |
|
64 | 64 | $listFunction = $data['key'].'Lists'; |
65 | 65 | $out = method_exists($modObj, $listFunction) ? $modObj->$listFunction() : array(); |
66 | - $out['selected'] = $modObj->get($data['key']); |
|
66 | + $out['selected'] = $modObj->get($data['key']); |
|
67 | 67 | return $out; |
68 | 68 | }); |
69 | 69 | self::$TPL = null; |
@@ -75,14 +75,14 @@ discard block |
||
75 | 75 | * @param $callback |
76 | 76 | * @return array|mixed |
77 | 77 | */ |
78 | - protected static function _workValue($callback){ |
|
78 | + protected static function _workValue($callback) { |
|
79 | 79 | self::$TPL = 'ajax/getValue'; |
80 | 80 | $data = Helper::jeditable('data'); |
81 | 81 | $out = array(); |
82 | - if(!empty($data)){ |
|
82 | + if (!empty($data)) { |
|
83 | 83 | $modObj = self::$classTable; |
84 | 84 | $modObj->edit($data['id']); |
85 | - if($modObj->getID() && ((is_object($callback) && ($callback instanceof \Closure)) || is_callable($callback))){ |
|
85 | + if ($modObj->getID() && ((is_object($callback) && ($callback instanceof \Closure)) || is_callable($callback))) { |
|
86 | 86 | $out = call_user_func($callback, $data, $modObj); |
87 | 87 | } |
88 | 88 | } |
@@ -92,15 +92,15 @@ discard block |
||
92 | 92 | /** |
93 | 93 | * @return array|mixed |
94 | 94 | */ |
95 | - public static function saveValue(){ |
|
96 | - return self::_workValue(function($data, $modObj){ |
|
95 | + public static function saveValue() { |
|
96 | + return self::_workValue(function($data, $modObj) { |
|
97 | 97 | $out = array(); |
98 | - if(isset($_POST['value']) && is_scalar($_POST['value'])){ |
|
99 | - if($modObj->set($data['key'], $_POST['value'])->save()){ |
|
98 | + if (isset($_POST['value']) && is_scalar($_POST['value'])) { |
|
99 | + if ($modObj->set($data['key'], $_POST['value'])->save()) { |
|
100 | 100 | $textMethod = $data['key'].'Text'; |
101 | - if(method_exists($modObj, $textMethod)){ |
|
101 | + if (method_exists($modObj, $textMethod)) { |
|
102 | 102 | $out['value'] = $modObj->$textMethod(); |
103 | - }else{ |
|
103 | + } else { |
|
104 | 104 | $out['value'] = $modObj->get($data['key']); |
105 | 105 | } |
106 | 106 | } |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | /** |
113 | 113 | * @return array|mixed |
114 | 114 | */ |
115 | - public static function getValue(){ |
|
116 | - return self::_workValue(function($data, $modObj){ |
|
115 | + public static function getValue() { |
|
116 | + return self::_workValue(function($data, $modObj) { |
|
117 | 117 | return array( |
118 | 118 | 'value' => $modObj->get($data['key']) |
119 | 119 | ); |
@@ -123,32 +123,32 @@ discard block |
||
123 | 123 | /** |
124 | 124 | * @return array |
125 | 125 | */ |
126 | - public static function deleted(){ |
|
126 | + public static function deleted() { |
|
127 | 127 | $data = array(); |
128 | 128 | $dataID = (int)Template::getParam('docId', $_GET); |
129 | - if($dataID>0 && self::_checkObj($dataID)){ |
|
129 | + if ($dataID > 0 && self::_checkObj($dataID)) { |
|
130 | 130 | $oldValue = self::_getValue('deleted_at', $dataID); |
131 | 131 | $q = self::$modx->db->update(array( |
132 | 132 | 'deleted_at' => empty($oldValue) ? date('Y-m-d H:i:s') : null |
133 | 133 | ), self::$modx->getFullTableName(self::TABLE()), "id = ".$dataID); |
134 | - if($q){ |
|
134 | + if ($q) { |
|
135 | 135 | $data['log'] = $oldValue ? 'Запись с ID '.$dataID.' восстановлена' : 'Запись с ID '.$dataID.' удалена'; |
136 | - }else{ |
|
136 | + } else { |
|
137 | 137 | $data['log'] = $oldValue ? 'Не удалось восстановить запись с ID '.$dataID : 'Не удалось удалить запись с ID '.$dataID; |
138 | 138 | } |
139 | - }else{ |
|
139 | + } else { |
|
140 | 140 | $data['log'] = '<span class="error">Ошибка</span>. Не удалось определить обновляему запись'; |
141 | 141 | } |
142 | 142 | return $data; |
143 | 143 | } |
144 | - public static function lists(){ |
|
144 | + public static function lists() { |
|
145 | 145 | self::$TPL = 'ajax/lists'; |
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
149 | 149 | * @return null |
150 | 150 | */ |
151 | - public static function getClassTable(){ |
|
151 | + public static function getClassTable() { |
|
152 | 152 | return self::$classTable; |
153 | 153 | } |
154 | 154 | } |
155 | 155 | \ No newline at end of file |
@@ -22,8 +22,9 @@ |
||
22 | 22 | '<span style="color:'.$tag.';">$1</span>', |
23 | 23 | '<span style="font-style:italic;">$1</span>', |
24 | 24 | ); |
25 | - if($decode) |
|
26 | - $string = htmlentities($string); |
|
25 | + if($decode) { |
|
26 | + $string = htmlentities($string); |
|
27 | + } |
|
27 | 28 | return '<pre>'.preg_replace($find, $replace, $string).'</pre>'; |
28 | 29 | } |
29 | 30 | } |
30 | 31 | \ No newline at end of file |
@@ -4,24 +4,24 @@ discard block |
||
4 | 4 | * Class HtmlFormatter |
5 | 5 | * @package Formatter |
6 | 6 | */ |
7 | -class HtmlFormatter{ |
|
7 | +class HtmlFormatter { |
|
8 | 8 | /** |
9 | 9 | * @param $string |
10 | 10 | * @param bool $decode |
11 | 11 | * @return string |
12 | 12 | */ |
13 | - public static function format($string, $decode = TRUE){ |
|
13 | + public static function format($string, $decode = TRUE) { |
|
14 | 14 | $tag = '#0000ff'; |
15 | 15 | $att = '#ff0000'; |
16 | 16 | $val = '#8000ff'; |
17 | 17 | $com = '#34803a'; |
18 | 18 | $find = array( |
19 | - '~(\s[a-z].*?=)~', // Highlight the attributes |
|
20 | - '~(<\!--.*?-->)~s', // Hightlight comments |
|
21 | - '~("[a-zA-Z0-9\/].*?")~', // Highlight the values |
|
22 | - '~(<[a-z].*?>)~', // Highlight the beginning of the opening tag |
|
23 | - '~(</[a-z].*?>)~', // Highlight the closing tag |
|
24 | - '~(&.*?;)~', // Stylize HTML entities |
|
19 | + '~(\s[a-z].*?=)~', // Highlight the attributes |
|
20 | + '~(<\!--.*?-->)~s', // Hightlight comments |
|
21 | + '~("[a-zA-Z0-9\/].*?")~', // Highlight the values |
|
22 | + '~(<[a-z].*?>)~', // Highlight the beginning of the opening tag |
|
23 | + '~(</[a-z].*?>)~', // Highlight the closing tag |
|
24 | + '~(&.*?;)~', // Stylize HTML entities |
|
25 | 25 | ); |
26 | 26 | $replace = array( |
27 | 27 | '<span style="color:'.$att.';">$1</span>', |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | '<span style="color:'.$tag.';">$1</span>', |
32 | 32 | '<span style="font-style:italic;">$1</span>', |
33 | 33 | ); |
34 | - if($decode) |
|
34 | + if ($decode) |
|
35 | 35 | $string = htmlentities($string); |
36 | 36 | return '<pre>'.preg_replace($find, $replace, $string).'</pre>'; |
37 | 37 | } |
@@ -42,7 +42,9 @@ discard block |
||
42 | 42 | public function place($ids, $dir, $rid) { |
43 | 43 | $table = $this->makeTable($this->table); |
44 | 44 | $ids = $this->cleanIDs($ids, ',', array(0)); |
45 | - if(empty($ids) || is_scalar($ids)) return false; |
|
45 | + if(empty($ids) || is_scalar($ids)) { |
|
46 | + return false; |
|
47 | + } |
|
46 | 48 | $rows = $this->query("SELECT count(`{$this->pkName}`) FROM {$table} WHERE `{$this->rfName}`={$rid}"); |
47 | 49 | $index = $this->modx->db->getValue($rows); |
48 | 50 | $cnt = count($ids); |
@@ -67,15 +69,25 @@ discard block |
||
67 | 69 | */ |
68 | 70 | public function deleteThumb($url, $cache = false) { |
69 | 71 | $url = $this->fs->relativePath($url); |
70 | - if (empty($url)) return; |
|
71 | - if ($this->fs->checkFile($url)) unlink(MODX_BASE_PATH . $url); |
|
72 | + if (empty($url)) { |
|
73 | + return; |
|
74 | + } |
|
75 | + if ($this->fs->checkFile($url)) { |
|
76 | + unlink(MODX_BASE_PATH . $url); |
|
77 | + } |
|
72 | 78 | $dir = $this->fs->takeFileDir($url); |
73 | 79 | $iterator = new \FilesystemIterator($dir); |
74 | - if (!$iterator->valid()) rmdir($dir); |
|
75 | - if ($cache) return; |
|
80 | + if (!$iterator->valid()) { |
|
81 | + rmdir($dir); |
|
82 | + } |
|
83 | + if ($cache) { |
|
84 | + return; |
|
85 | + } |
|
76 | 86 | $thumbsCache = isset($this->params['thumbsCache']) ? $this->params['thumbsCache'] : $this->thumbsCache; |
77 | 87 | $thumb = $thumbsCache.$url; |
78 | - if ($this->fs->checkFile($thumb)) $this->deleteThumb($thumb, true); |
|
88 | + if ($this->fs->checkFile($thumb)) { |
|
89 | + $this->deleteThumb($thumb, true); |
|
90 | + } |
|
79 | 91 | } |
80 | 92 | |
81 | 93 | public function delete($ids, $fire_events = NULL) { |
@@ -141,7 +153,9 @@ discard block |
||
141 | 153 | * @return bool |
142 | 154 | */ |
143 | 155 | public function makeThumb($folder,$url,$options) { |
144 | - if (empty($url)) return false; |
|
156 | + if (empty($url)) { |
|
157 | + return false; |
|
158 | + } |
|
145 | 159 | $thumb = new \Helpers\PHPThumb(); |
146 | 160 | $inputFile = MODX_BASE_PATH . $this->fs->relativePath($url); |
147 | 161 | $outputFile = MODX_BASE_PATH. $this->fs->relativePath($folder). '/' . $this->fs->relativePath($url); |
@@ -6,9 +6,9 @@ |
||
6 | 6 | class dataTable extends \autoTable { |
7 | 7 | protected $params = array(); |
8 | 8 | protected $fs = null; |
9 | - protected $indexName = null; |
|
10 | - protected $rfName = null; |
|
11 | - protected $thumbsCache = null; |
|
9 | + protected $indexName = null; |
|
10 | + protected $rfName = null; |
|
11 | + protected $thumbsCache = null; |
|
12 | 12 | |
13 | 13 | public function __construct($modx, $debug = false) { |
14 | 14 | parent::__construct($modx, $debug); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php namespace SimpleTab; |
2 | -require_once (MODX_BASE_PATH . 'assets/lib/MODxAPI/autoTable.abstract.php'); |
|
3 | -require_once (MODX_BASE_PATH . 'assets/lib/Helpers/FS.php'); |
|
4 | -require_once (MODX_BASE_PATH . 'assets/lib/Helpers/PHPThumb.php'); |
|
2 | +require_once (MODX_BASE_PATH.'assets/lib/MODxAPI/autoTable.abstract.php'); |
|
3 | +require_once (MODX_BASE_PATH.'assets/lib/Helpers/FS.php'); |
|
4 | +require_once (MODX_BASE_PATH.'assets/lib/Helpers/PHPThumb.php'); |
|
5 | 5 | |
6 | 6 | class dataTable extends \autoTable { |
7 | 7 | protected $params = array(); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | return $out; |
31 | 31 | } |
32 | 32 | |
33 | - public function touch($field){ |
|
33 | + public function touch($field) { |
|
34 | 34 | $this->set($field, date('Y-m-d H:i:s', time() + $this->modx->config['server_offset_time'])); |
35 | 35 | return $this; |
36 | 36 | } |
@@ -43,19 +43,19 @@ discard block |
||
43 | 43 | public function place($ids, $dir, $rid) { |
44 | 44 | $table = $this->makeTable($this->table); |
45 | 45 | $ids = $this->cleanIDs($ids, ',', array(0)); |
46 | - if(empty($ids) || is_scalar($ids)) return false; |
|
46 | + if (empty($ids) || is_scalar($ids)) return false; |
|
47 | 47 | $rows = $this->query("SELECT count(`{$this->pkName}`) FROM {$table} WHERE `{$this->rfName}`={$rid}"); |
48 | 48 | $index = $this->modx->db->getValue($rows); |
49 | 49 | $cnt = count($ids); |
50 | - $ids = implode(',',$ids); |
|
50 | + $ids = implode(',', $ids); |
|
51 | 51 | if ($dir == 'top') { |
52 | - $this->query("SET @index := " . ($index - $cnt - 1)); |
|
52 | + $this->query("SET @index := ".($index - $cnt - 1)); |
|
53 | 53 | $this->query("UPDATE {$table} SET `{$this->indexName}` = (@index := @index + 1) WHERE (`{$this->pkName}` IN ({$ids})) ORDER BY `{$this->indexName}` ASC"); |
54 | 54 | $this->query("SET @index := -1"); |
55 | 55 | } else { |
56 | 56 | $this->query("SET @index := -1"); |
57 | 57 | $this->query("UPDATE {$table} SET `{$this->indexName}` = (@index := @index + 1) WHERE (`{$this->pkName}` IN ({$ids})) ORDER BY `{$this->indexName}` ASC"); |
58 | - $this->query("SET @index := " . ($cnt - 1)); |
|
58 | + $this->query("SET @index := ".($cnt - 1)); |
|
59 | 59 | } |
60 | 60 | $this->query("UPDATE {$table} SET `{$this->indexName}` = (@index := @index + 1) WHERE (`{$this->pkName}` NOT IN ({$ids})) AND `{$this->rfName}` = {$rid} ORDER BY `{$this->indexName}` ASC"); |
61 | 61 | $out = $this->modx->db->getAffectedRows(); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | public function deleteThumb($url, $cache = false) { |
70 | 70 | $url = $this->fs->relativePath($url); |
71 | 71 | if (empty($url)) return; |
72 | - if ($this->fs->checkFile($url)) unlink(MODX_BASE_PATH . $url); |
|
72 | + if ($this->fs->checkFile($url)) unlink(MODX_BASE_PATH.$url); |
|
73 | 73 | $dir = $this->fs->takeFileDir($url); |
74 | 74 | $iterator = new \FilesystemIterator($dir); |
75 | 75 | if (!$iterator->valid()) rmdir($dir); |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | return $out; |
86 | 86 | } |
87 | 87 | |
88 | - public function deleteAll ($ids, $rid, $fire_events = NULL) { |
|
88 | + public function deleteAll($ids, $rid, $fire_events = NULL) { |
|
89 | 89 | $this->clearIndexes($ids, $rid); |
90 | 90 | return $this->delete($ids, $fire_events); |
91 | 91 | } |
92 | 92 | |
93 | - public function fieldNames(){ |
|
93 | + public function fieldNames() { |
|
94 | 94 | $fields = array_keys($this->getDefaultFields()); |
95 | 95 | $fields[] = $this->fieldPKName(); |
96 | 96 | return $fields; |
@@ -118,19 +118,19 @@ discard block |
||
118 | 118 | /* more refactoring needed */ |
119 | 119 | if ($targetIndex < $sourceIndex) { |
120 | 120 | if (($point == 'top' && $orderDir == 'asc') || ($point == 'bottom' && $orderDir == 'desc')) { |
121 | - $this->modx->db->update("`{$this->indexName}`=`{$this->indexName}`+1",$table,"`{$this->indexName}`>={$targetIndex} AND `{$this->indexName}`<{$sourceIndex} AND `{$this->rfName}`={$rid}"); |
|
122 | - $rows = $this->modx->db->update("`{$this->indexName}`={$targetIndex}",$table,"`{$this->pkName}`={$sourceId}"); |
|
121 | + $this->modx->db->update("`{$this->indexName}`=`{$this->indexName}`+1", $table, "`{$this->indexName}`>={$targetIndex} AND `{$this->indexName}`<{$sourceIndex} AND `{$this->rfName}`={$rid}"); |
|
122 | + $rows = $this->modx->db->update("`{$this->indexName}`={$targetIndex}", $table, "`{$this->pkName}`={$sourceId}"); |
|
123 | 123 | } elseif (($point == 'bottom' && $orderDir == 'asc') || ($point == 'top' && $orderDir == 'desc')) { |
124 | - $this->modx->db->update("`{$this->indexName}`=`{$this->indexName}`+1",$table,"`{$this->indexName}`>{$targetIndex} AND `{$this->indexName}`<{$sourceIndex} AND `{$this->rfName}`={$rid}"); |
|
125 | - $rows = $this->modx->db->update("`{$this->indexName}`=1+{$targetIndex}",$table,"`{$this->pkName}`={$sourceId}"); |
|
124 | + $this->modx->db->update("`{$this->indexName}`=`{$this->indexName}`+1", $table, "`{$this->indexName}`>{$targetIndex} AND `{$this->indexName}`<{$sourceIndex} AND `{$this->rfName}`={$rid}"); |
|
125 | + $rows = $this->modx->db->update("`{$this->indexName}`=1+{$targetIndex}", $table, "`{$this->pkName}`={$sourceId}"); |
|
126 | 126 | } |
127 | 127 | } else { |
128 | 128 | if (($point == 'bottom' && $orderDir == 'asc') || ($point == 'top' && $orderDir == 'desc')) { |
129 | - $this->modx->db->update("`{$this->indexName}`=`{$this->indexName}`-1",$table,"`{$this->indexName}`<={$targetIndex} AND `{$this->indexName}`>={$sourceIndex} AND `{$this->rfName}`={$rid}"); |
|
130 | - $rows = $this->modx->db->update("`{$this->indexName}`={$targetIndex}",$table,"`{$this->pkName}`={$sourceId}"); |
|
129 | + $this->modx->db->update("`{$this->indexName}`=`{$this->indexName}`-1", $table, "`{$this->indexName}`<={$targetIndex} AND `{$this->indexName}`>={$sourceIndex} AND `{$this->rfName}`={$rid}"); |
|
130 | + $rows = $this->modx->db->update("`{$this->indexName}`={$targetIndex}", $table, "`{$this->pkName}`={$sourceId}"); |
|
131 | 131 | } elseif (($point == 'top' && $orderDir == 'asc') || ($point == 'bottom' && $orderDir == 'desc')) { |
132 | - $this->modx->db->update("`{$this->indexName}`=`{$this->indexName}`-1",$table,"`{$this->indexName}`<{$targetIndex} AND `{$this->indexName}`>={$sourceIndex} AND `{$this->rfName}`={$rid}"); |
|
133 | - $rows = $this->modx->db->update("`{$this->indexName}`=-1+{$targetIndex}",$table,"`{$this->pkName}`={$sourceId}"); |
|
132 | + $this->modx->db->update("`{$this->indexName}`=`{$this->indexName}`-1", $table, "`{$this->indexName}`<{$targetIndex} AND `{$this->indexName}`>={$sourceIndex} AND `{$this->rfName}`={$rid}"); |
|
133 | + $rows = $this->modx->db->update("`{$this->indexName}`=-1+{$targetIndex}", $table, "`{$this->pkName}`={$sourceId}"); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
@@ -143,17 +143,17 @@ discard block |
||
143 | 143 | * @param $options |
144 | 144 | * @return bool |
145 | 145 | */ |
146 | - public function makeThumb($folder,$url,$options) { |
|
146 | + public function makeThumb($folder, $url, $options) { |
|
147 | 147 | if (empty($url)) return false; |
148 | 148 | $thumb = new \Helpers\PHPThumb(); |
149 | - $inputFile = MODX_BASE_PATH . $this->fs->relativePath($url); |
|
150 | - $outputFile = MODX_BASE_PATH. $this->fs->relativePath($folder). '/' . $this->fs->relativePath($url); |
|
149 | + $inputFile = MODX_BASE_PATH.$this->fs->relativePath($url); |
|
150 | + $outputFile = MODX_BASE_PATH.$this->fs->relativePath($folder).'/'.$this->fs->relativePath($url); |
|
151 | 151 | $dir = $this->fs->takeFileDir($outputFile); |
152 | 152 | $this->fs->makeDir($dir, $this->modx->config['new_folder_permissions']); |
153 | - if ($thumb->create($inputFile,$outputFile,$options)) { |
|
153 | + if ($thumb->create($inputFile, $outputFile, $options)) { |
|
154 | 154 | return true; |
155 | 155 | } else { |
156 | - $this->modx->logEvent(0, 3, $thumb->debugMessages, __NAMESPACE__); |
|
156 | + $this->modx->logEvent(0, 3, $thumb->debugMessages, __NAMESPACE__); |
|
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | } |
@@ -45,9 +45,10 @@ discard block |
||
45 | 45 | } |
46 | 46 | //overload plugin and class properties |
47 | 47 | $_params = $modx->parseProperties('&template=;;'.$this->params['template'].' &id=;;'.$this->params['id'],$modx->event->activePlugin,'plugin'); |
48 | - foreach ($_params as $key=>$value) |
|
49 | - if (property_exists ($this, $key)) |
|
50 | - $this->$key = $value; |
|
48 | + foreach ($_params as $key=>$value) { |
|
49 | + if (property_exists ($this, $key)) |
|
50 | + $this->$key = $value; |
|
51 | + } |
|
51 | 52 | |
52 | 53 | $this->params = array_merge($this->params,$_params); |
53 | 54 | $modx->event->_output = ""; |
@@ -57,7 +58,9 @@ discard block |
||
57 | 58 | } |
58 | 59 | |
59 | 60 | public function clearFolders($ids = array(), $folder) { |
60 | - foreach ($ids as $id) $this->fs->rmDir($folder.$id.'/'); |
|
61 | + foreach ($ids as $id) { |
|
62 | + $this->fs->rmDir($folder.$id.'/'); |
|
63 | + } |
|
61 | 64 | } |
62 | 65 | |
63 | 66 | public function checkPermissions() { |
@@ -124,7 +127,9 @@ discard block |
||
124 | 127 | $scripts = isset($scripts['scripts']) ? $scripts['scripts'] : $scripts['styles']; |
125 | 128 | foreach ($scripts as $name => $params) { |
126 | 129 | $script = $this->assets->registerScript($name,$params); |
127 | - if ($script !== false) $js .= $script; |
|
130 | + if ($script !== false) { |
|
131 | + $js .= $script; |
|
132 | + } |
|
128 | 133 | } |
129 | 134 | } else { |
130 | 135 | if ($list == $this->jsListDefault) { |
@@ -197,7 +202,9 @@ discard block |
||
197 | 202 | $result = $this->modx->db->select('`id`',$eventsTable,"`name` = '{$event}'"); |
198 | 203 | if (!$this->modx->db->getRecordCount($result)) { |
199 | 204 | $sql = "INSERT INTO {$eventsTable} VALUES (NULL, '{$event}', '{$eventsType}', '{$this->pluginName} Events')"; |
200 | - if (!$this->modx->db->query($sql)) $this->modx->logEvent(0, 3, "Cannot register {$event} event.", $this->pluginName); |
|
205 | + if (!$this->modx->db->query($sql)) { |
|
206 | + $this->modx->logEvent(0, 3, "Cannot register {$event} event.", $this->pluginName); |
|
207 | + } |
|
201 | 208 | } |
202 | 209 | } |
203 | 210 | } |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace SimpleTab; |
3 | -include_once (MODX_BASE_PATH . 'assets/snippets/DocLister/lib/DLTemplate.class.php'); |
|
4 | -include_once (MODX_BASE_PATH . 'assets/lib/APIHelpers.class.php'); |
|
5 | -require_once (MODX_BASE_PATH . 'assets/lib/Helpers/FS.php'); |
|
6 | -require_once (MODX_BASE_PATH . 'assets/lib/Helpers/Assets.php'); |
|
3 | +include_once (MODX_BASE_PATH.'assets/snippets/DocLister/lib/DLTemplate.class.php'); |
|
4 | +include_once (MODX_BASE_PATH.'assets/lib/APIHelpers.class.php'); |
|
5 | +require_once (MODX_BASE_PATH.'assets/lib/Helpers/FS.php'); |
|
6 | +require_once (MODX_BASE_PATH.'assets/lib/Helpers/Assets.php'); |
|
7 | 7 | |
8 | 8 | abstract class Plugin { |
9 | 9 | public $modx = null; |
@@ -40,16 +40,16 @@ discard block |
||
40 | 40 | $this->lang_attribute = $lang_attribute; |
41 | 41 | $this->params = $modx->event->params; |
42 | 42 | if ($this->checkTemplate && !isset($this->params['template']) && $modx->event->name != 'OnEmptyTrash') { |
43 | - $doc = $modx->getDocument($this->params['id'],'template','all','all'); |
|
43 | + $doc = $modx->getDocument($this->params['id'], 'template', 'all', 'all'); |
|
44 | 44 | $this->params['template'] = is_array($doc) ? end($doc) : null; |
45 | 45 | } |
46 | 46 | //overload plugin and class properties |
47 | - $_params = $modx->parseProperties('&template=;;'.$this->params['template'].' &id=;;'.$this->params['id'],$modx->event->activePlugin,'plugin'); |
|
47 | + $_params = $modx->parseProperties('&template=;;'.$this->params['template'].' &id=;;'.$this->params['id'], $modx->event->activePlugin, 'plugin'); |
|
48 | 48 | foreach ($_params as $key=>$value) |
49 | - if (property_exists ($this, $key)) |
|
49 | + if (property_exists($this, $key)) |
|
50 | 50 | $this->$key = $value; |
51 | 51 | |
52 | - $this->params = array_merge($this->params,$_params); |
|
52 | + $this->params = array_merge($this->params, $_params); |
|
53 | 53 | $modx->event->_output = ""; |
54 | 54 | $this->DLTemplate = \DLTemplate::getInstance($this->modx); |
55 | 55 | $this->fs = \Helpers\FS::getInstance(); |
@@ -61,18 +61,18 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | public function checkPermissions() { |
64 | - $templates = isset($this->params['templates']) ? explode(',',$this->params['templates']) : false; |
|
65 | - $roles = isset($this->params['roles']) ? explode(',',$this->params['roles']) : false; |
|
64 | + $templates = isset($this->params['templates']) ? explode(',', $this->params['templates']) : false; |
|
65 | + $roles = isset($this->params['roles']) ? explode(',', $this->params['roles']) : false; |
|
66 | 66 | |
67 | - $tplFlag = ($this->checkTemplate && !$templates || ($templates && !in_array($this->params['template'],$templates))); |
|
67 | + $tplFlag = ($this->checkTemplate && !$templates || ($templates && !in_array($this->params['template'], $templates))); |
|
68 | 68 | |
69 | - $documents = isset($this->params['documents']) ? explode(',',$this->params['documents']) : false; |
|
69 | + $documents = isset($this->params['documents']) ? explode(',', $this->params['documents']) : false; |
|
70 | 70 | $docFlag = ($this->checkId && $tplFlag) ? !($documents && in_array($this->params['id'], $documents)) : $tplFlag; |
71 | 71 | |
72 | - $ignoreDocs = isset($this->params['ignoreDoc']) ? explode(',',$this->params['ignoreDoc']) : false; |
|
72 | + $ignoreDocs = isset($this->params['ignoreDoc']) ? explode(',', $this->params['ignoreDoc']) : false; |
|
73 | 73 | $ignoreFlag = ($this->checkId && $ignoreDocs && in_array($this->params['id'], $ignoreDocs)); |
74 | 74 | |
75 | - return ($docFlag || $ignoreFlag || ($roles && !in_array($_SESSION['mgrRole'],$roles))); |
|
75 | + return ($docFlag || $ignoreFlag || ($roles && !in_array($_SESSION['mgrRole'], $roles))); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -89,18 +89,18 @@ discard block |
||
89 | 89 | } |
90 | 90 | $output = ''; |
91 | 91 | $plugins = $this->modx->pluginEvent; |
92 | - if(($this->renderEvent!=='OnDocFormRender' || (array_search('ManagerManager', $plugins['OnDocFormRender']) === false))) { |
|
93 | - $jquery = $this->assets->registerScript('jQuery',array( |
|
92 | + if (($this->renderEvent !== 'OnDocFormRender' || (array_search('ManagerManager', $plugins['OnDocFormRender']) === false))) { |
|
93 | + $jquery = $this->assets->registerScript('jQuery', array( |
|
94 | 94 | 'version' => '1.9.1', |
95 | 95 | 'src' => 'assets/js/jquery/jquery-1.9.1.min.js' |
96 | 96 | )); |
97 | 97 | if ($jquery !== false) { |
98 | 98 | $output .= $jquery; |
99 | - $output .='<script type="text/javascript">var jQuery = jQuery.noConflict(true);</script>'; |
|
99 | + $output .= '<script type="text/javascript">var jQuery = jQuery.noConflict(true);</script>'; |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | $tpl = MODX_BASE_PATH.$this->tpl; |
103 | - if($this->fs->checkFile($tpl)) { |
|
103 | + if ($this->fs->checkFile($tpl)) { |
|
104 | 104 | $output .= '[+js+][+styles+]'.file_get_contents($tpl); |
105 | 105 | } else { |
106 | 106 | $this->modx->logEvent(0, 3, "Cannot load {$this->tpl} .", $this->pluginName); |
@@ -114,16 +114,16 @@ discard block |
||
114 | 114 | * @param array $ph |
115 | 115 | * @return string |
116 | 116 | */ |
117 | - public function renderJS($list,$ph = array()) { |
|
117 | + public function renderJS($list, $ph = array()) { |
|
118 | 118 | $js = ''; |
119 | 119 | $scripts = MODX_BASE_PATH.$list; |
120 | - if($this->fs->checkFile($scripts)) { |
|
120 | + if ($this->fs->checkFile($scripts)) { |
|
121 | 121 | $scripts = @file_get_contents($scripts); |
122 | - $scripts = $this->DLTemplate->parseChunk('@CODE:'.$scripts,$ph); |
|
123 | - $scripts = json_decode($scripts,true); |
|
122 | + $scripts = $this->DLTemplate->parseChunk('@CODE:'.$scripts, $ph); |
|
123 | + $scripts = json_decode($scripts, true); |
|
124 | 124 | $scripts = isset($scripts['scripts']) ? $scripts['scripts'] : $scripts['styles']; |
125 | 125 | foreach ($scripts as $name => $params) { |
126 | - $script = $this->assets->registerScript($name,$params); |
|
126 | + $script = $this->assets->registerScript($name, $params); |
|
127 | 127 | if ($script !== false) $js .= $script; |
128 | 128 | } |
129 | 129 | } else { |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @return array |
141 | 141 | */ |
142 | 142 | public function getTplPlaceholders() { |
143 | - $ph = array (); |
|
143 | + $ph = array(); |
|
144 | 144 | return $ph; |
145 | 145 | } |
146 | 146 | |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | $output = $this->prerender(); |
153 | 153 | if ($output !== false) { |
154 | 154 | $ph = $this->getTplPlaceholders(); |
155 | - $ph['js'] = $this->renderJS($this->jsListDefault,$ph) . $this->renderJS($this->jsListCustom,$ph); |
|
156 | - $ph['styles'] = $this->renderJS($this->cssListDefault,$ph) . $this->renderJS($this->cssListCustom,$ph); |
|
157 | - $output = $this->DLTemplate->parseChunk('@CODE:'.$output,$ph); |
|
155 | + $ph['js'] = $this->renderJS($this->jsListDefault, $ph).$this->renderJS($this->jsListCustom, $ph); |
|
156 | + $ph['styles'] = $this->renderJS($this->cssListDefault, $ph).$this->renderJS($this->cssListCustom, $ph); |
|
157 | + $output = $this->DLTemplate->parseChunk('@CODE:'.$output, $ph); |
|
158 | 158 | } |
159 | 159 | return $output; |
160 | 160 | } |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | public function renderEmpty() { |
167 | 167 | if (!$this->checkPermissions()) { |
168 | 168 | $tpl = MODX_BASE_PATH.$this->emptyTpl; |
169 | - if($this->fs->checkFile($tpl)) { |
|
169 | + if ($this->fs->checkFile($tpl)) { |
|
170 | 170 | $output = '[+js+]'.file_get_contents($tpl); |
171 | 171 | $ph = $this->getTplPlaceholders(); |
172 | - $ph['js'] = $this->renderJS($this->jsListEmpty,$ph); |
|
173 | - $output = $this->DLTemplate->parseChunk('@CODE:'.$output,$ph); |
|
172 | + $ph['js'] = $this->renderJS($this->jsListEmpty, $ph); |
|
173 | + $output = $this->DLTemplate->parseChunk('@CODE:'.$output, $ph); |
|
174 | 174 | return $output; |
175 | 175 | } else { |
176 | 176 | $this->modx->logEvent(0, 3, "Cannot load {$this->emptyTpl} .", $this->pluginName); |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public function checkTable() { |
185 | 185 | $sql = "SHOW TABLES LIKE '{$this->_table}'"; |
186 | - return $this->modx->db->getRecordCount( $this->modx->db->query($sql)); |
|
186 | + return $this->modx->db->getRecordCount($this->modx->db->query($sql)); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | public function createTable() { |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | public function registerEvents($events = array(), $eventsType = '6') { |
195 | 195 | $eventsTable = $this->modx->getFullTableName('system_eventnames'); |
196 | 196 | foreach ($events as $event) { |
197 | - $result = $this->modx->db->select('`id`',$eventsTable,"`name` = '{$event}'"); |
|
197 | + $result = $this->modx->db->select('`id`', $eventsTable, "`name` = '{$event}'"); |
|
198 | 198 | if (!$this->modx->db->getRecordCount($result)) { |
199 | 199 | $sql = "INSERT INTO {$eventsTable} VALUES (NULL, '{$event}', '{$eventsType}', '{$this->pluginName} Events')"; |
200 | 200 | if (!$this->modx->db->query($sql)) $this->modx->logEvent(0, 3, "Cannot register {$event} event.", $this->pluginName); |
@@ -10,31 +10,31 @@ discard block |
||
10 | 10 | * @package SimpleTab |
11 | 11 | */ |
12 | 12 | abstract class Plugin { |
13 | - public $modx = null; |
|
14 | - public $pluginName = ''; |
|
15 | - public $params = array(); |
|
13 | + public $modx = null; |
|
14 | + public $pluginName = ''; |
|
15 | + public $params = array(); |
|
16 | 16 | public $table = ''; |
17 | - public $tpl = ''; |
|
18 | - public $jsListDefault = ''; |
|
19 | - public $jsListCustom = ''; |
|
20 | - public $cssListDefault = ''; |
|
21 | - public $cssListCustom = ''; |
|
22 | - public $pluginEvents = array(); |
|
17 | + public $tpl = ''; |
|
18 | + public $jsListDefault = ''; |
|
19 | + public $jsListCustom = ''; |
|
20 | + public $cssListDefault = ''; |
|
21 | + public $cssListCustom = ''; |
|
22 | + public $pluginEvents = array(); |
|
23 | 23 | public $_table = ''; |
24 | - protected $fs = null; |
|
24 | + protected $fs = null; |
|
25 | 25 | protected $assets = null; |
26 | - protected $emptyTpl = null; |
|
27 | - protected $jsListEmpty = ''; |
|
26 | + protected $emptyTpl = null; |
|
27 | + protected $jsListEmpty = ''; |
|
28 | 28 | |
29 | - public $DLTemplate = null; |
|
30 | - public $lang_attribute = ''; |
|
29 | + public $DLTemplate = null; |
|
30 | + public $lang_attribute = ''; |
|
31 | 31 | |
32 | - protected $checkTemplate = true; |
|
33 | - protected $renderEvent = 'OnDocFormRender'; |
|
32 | + protected $checkTemplate = true; |
|
33 | + protected $renderEvent = 'OnDocFormRender'; |
|
34 | 34 | |
35 | - protected $checkId = true; |
|
35 | + protected $checkId = true; |
|
36 | 36 | |
37 | - /** |
|
37 | + /** |
|
38 | 38 | * @param $modx |
39 | 39 | * @param string $lang_attribute |
40 | 40 | */ |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $this->lang_attribute = $lang_attribute; |
45 | 45 | $this->params = $modx->event->params; |
46 | 46 | if ($this->checkTemplate && !isset($this->params['template']) && $modx->event->name != 'OnEmptyTrash') { |
47 | - $doc = $modx->getDocument($this->params['id'],'template','all','all'); |
|
47 | + $doc = $modx->getDocument($this->params['id'],'template','all','all'); |
|
48 | 48 | $this->params['template'] = is_array($doc) ? end($doc) : null; |
49 | 49 | } |
50 | 50 | //overload plugin and class properties |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | $this->modx->logEvent(0, 3, "Cannot create {$this->table} table.", $this->pluginName); |
97 | 97 | return; |
98 | 98 | } |
99 | - $this->registerEvents($this->pluginEvents); |
|
99 | + $this->registerEvents($this->pluginEvents); |
|
100 | 100 | } |
101 | 101 | $output = ''; |
102 | - $plugins = $this->modx->pluginEvent; |
|
103 | - if(($this->renderEvent!=='OnDocFormRender' || (array_search('ManagerManager', $plugins['OnDocFormRender']) === false))) { |
|
104 | - $jquery = $this->assets->registerScript('jQuery',array( |
|
102 | + $plugins = $this->modx->pluginEvent; |
|
103 | + if(($this->renderEvent!=='OnDocFormRender' || (array_search('ManagerManager', $plugins['OnDocFormRender']) === false))) { |
|
104 | + $jquery = $this->assets->registerScript('jQuery',array( |
|
105 | 105 | 'version' => '1.9.1', |
106 | 106 | 'src' => 'assets/js/jquery/jquery-1.9.1.min.js' |
107 | 107 | )); |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | $output .= $jquery; |
110 | 110 | $output .='<script type="text/javascript">var jQuery = jQuery.noConflict(true);</script>'; |
111 | 111 | } |
112 | - } |
|
113 | - $tpl = MODX_BASE_PATH.$this->tpl; |
|
114 | - if($this->fs->checkFile($tpl)) { |
|
115 | - $output .= '[+js+][+styles+]'.file_get_contents($tpl); |
|
116 | - } else { |
|
117 | - $this->modx->logEvent(0, 3, "Cannot load {$this->tpl} .", $this->pluginName); |
|
112 | + } |
|
113 | + $tpl = MODX_BASE_PATH.$this->tpl; |
|
114 | + if($this->fs->checkFile($tpl)) { |
|
115 | + $output .= '[+js+][+styles+]'.file_get_contents($tpl); |
|
116 | + } else { |
|
117 | + $this->modx->logEvent(0, 3, "Cannot load {$this->tpl} .", $this->pluginName); |
|
118 | 118 | return false; |
119 | - } |
|
119 | + } |
|
120 | 120 | return $output; |
121 | 121 | } |
122 | 122 | |
@@ -126,48 +126,48 @@ discard block |
||
126 | 126 | * @return string |
127 | 127 | */ |
128 | 128 | public function renderJS($list,$ph = array()) { |
129 | - $js = ''; |
|
130 | - $scripts = MODX_BASE_PATH.$list; |
|
131 | - if($this->fs->checkFile($scripts)) { |
|
132 | - $scripts = @file_get_contents($scripts); |
|
133 | - $scripts = $this->DLTemplate->parseChunk('@CODE:'.$scripts,$ph); |
|
134 | - $scripts = json_decode($scripts,true); |
|
135 | - $scripts = isset($scripts['scripts']) ? $scripts['scripts'] : $scripts['styles']; |
|
136 | - foreach ($scripts as $name => $params) { |
|
137 | - $script = $this->assets->registerScript($name,$params); |
|
129 | + $js = ''; |
|
130 | + $scripts = MODX_BASE_PATH.$list; |
|
131 | + if($this->fs->checkFile($scripts)) { |
|
132 | + $scripts = @file_get_contents($scripts); |
|
133 | + $scripts = $this->DLTemplate->parseChunk('@CODE:'.$scripts,$ph); |
|
134 | + $scripts = json_decode($scripts,true); |
|
135 | + $scripts = isset($scripts['scripts']) ? $scripts['scripts'] : $scripts['styles']; |
|
136 | + foreach ($scripts as $name => $params) { |
|
137 | + $script = $this->assets->registerScript($name,$params); |
|
138 | 138 | if ($script !== false) $js .= $script; |
139 | - } |
|
140 | - } else { |
|
141 | - if ($list == $this->jsListDefault) { |
|
142 | - $this->modx->logEvent(0, 3, "Cannot load {$this->jsListDefault} .", $this->pluginName); |
|
143 | - } elseif ($list == $this->cssListDefault) { |
|
144 | - $this->modx->logEvent(0, 3, "Cannot load {$this->cssListDefault} .", $this->pluginName); |
|
145 | - } |
|
146 | - } |
|
147 | - return $js; |
|
139 | + } |
|
140 | + } else { |
|
141 | + if ($list == $this->jsListDefault) { |
|
142 | + $this->modx->logEvent(0, 3, "Cannot load {$this->jsListDefault} .", $this->pluginName); |
|
143 | + } elseif ($list == $this->cssListDefault) { |
|
144 | + $this->modx->logEvent(0, 3, "Cannot load {$this->cssListDefault} .", $this->pluginName); |
|
145 | + } |
|
146 | + } |
|
147 | + return $js; |
|
148 | 148 | } |
149 | 149 | |
150 | - /** |
|
151 | - * @return array |
|
152 | - */ |
|
153 | - public function getTplPlaceholders() { |
|
154 | - $ph = array (); |
|
155 | - return $ph; |
|
156 | - } |
|
150 | + /** |
|
151 | + * @return array |
|
152 | + */ |
|
153 | + public function getTplPlaceholders() { |
|
154 | + $ph = array (); |
|
155 | + return $ph; |
|
156 | + } |
|
157 | 157 | |
158 | 158 | /** |
159 | 159 | * @return string |
160 | 160 | */ |
161 | 161 | public function render() { |
162 | - if (!$this->checkPermissions()) { |
|
162 | + if (!$this->checkPermissions()) { |
|
163 | 163 | $output = $this->prerender(); |
164 | - if ($output !== false) { |
|
165 | - $ph = $this->getTplPlaceholders(); |
|
166 | - $ph['js'] = $this->renderJS($this->jsListDefault,$ph) . $this->renderJS($this->jsListCustom,$ph); |
|
167 | - $ph['styles'] = $this->renderJS($this->cssListDefault,$ph) . $this->renderJS($this->cssListCustom,$ph); |
|
168 | - $output = $this->DLTemplate->parseChunk('@CODE:'.$output,$ph); |
|
169 | - } |
|
170 | - return $output; |
|
164 | + if ($output !== false) { |
|
165 | + $ph = $this->getTplPlaceholders(); |
|
166 | + $ph['js'] = $this->renderJS($this->jsListDefault,$ph) . $this->renderJS($this->jsListCustom,$ph); |
|
167 | + $ph['styles'] = $this->renderJS($this->cssListDefault,$ph) . $this->renderJS($this->cssListCustom,$ph); |
|
168 | + $output = $this->DLTemplate->parseChunk('@CODE:'.$output,$ph); |
|
169 | + } |
|
170 | + return $output; |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | * @return mixed |
202 | 202 | */ |
203 | 203 | public function createTable() { |
204 | - $sql = ''; |
|
205 | - return $this->modx->db->query($sql); |
|
204 | + $sql = ''; |
|
205 | + return $this->modx->db->query($sql); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -210,13 +210,13 @@ discard block |
||
210 | 210 | * @param string $eventsType |
211 | 211 | */ |
212 | 212 | public function registerEvents($events = array(), $eventsType = '6') { |
213 | - $eventsTable = $this->modx->getFullTableName('system_eventnames'); |
|
214 | - foreach ($events as $event) { |
|
215 | - $result = $this->modx->db->select('`id`',$eventsTable,"`name` = '{$event}'"); |
|
216 | - if (!$this->modx->db->getRecordCount($result)) { |
|
217 | - $sql = "INSERT INTO {$eventsTable} VALUES (NULL, '{$event}', '{$eventsType}', '{$this->pluginName} Events')"; |
|
218 | - if (!$this->modx->db->query($sql)) $this->modx->logEvent(0, 3, "Cannot register {$event} event.", $this->pluginName); |
|
219 | - } |
|
220 | - } |
|
221 | - } |
|
213 | + $eventsTable = $this->modx->getFullTableName('system_eventnames'); |
|
214 | + foreach ($events as $event) { |
|
215 | + $result = $this->modx->db->select('`id`',$eventsTable,"`name` = '{$event}'"); |
|
216 | + if (!$this->modx->db->getRecordCount($result)) { |
|
217 | + $sql = "INSERT INTO {$eventsTable} VALUES (NULL, '{$event}', '{$eventsType}', '{$this->pluginName} Events')"; |
|
218 | + if (!$this->modx->db->query($sql)) $this->modx->logEvent(0, 3, "Cannot register {$event} event.", $this->pluginName); |
|
219 | + } |
|
220 | + } |
|
221 | + } |
|
222 | 222 | } |
223 | 223 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
10 | 10 | public $isExit = false; |
11 | 11 | public $output = null; |
12 | 12 | public $params = null; |
13 | - public $fireEvents = true; |
|
13 | + public $fireEvents = true; |
|
14 | 14 | |
15 | 15 | public $dlParams = array( |
16 | 16 | "controller" => "onetable", |
@@ -101,7 +101,9 @@ discard block |
||
101 | 101 | $this->dlParams['table'] = $this->data->tableName(); |
102 | 102 | $this->dlParams['idField'] = $this->data->fieldPKName(); |
103 | 103 | $this->dlParams['addWhereList'] = "`{$this->rfName}`={$this->rid}"; |
104 | - if (isset($_REQUEST['rows'])) $this->dlParams['display'] = (int)$_REQUEST['rows']; |
|
104 | + if (isset($_REQUEST['rows'])) { |
|
105 | + $this->dlParams['display'] = (int)$_REQUEST['rows']; |
|
106 | + } |
|
105 | 107 | $offset = isset($_REQUEST['page']) ? (int)$_REQUEST['page'] : 1; |
106 | 108 | $offset = $offset ? $offset : 1; |
107 | 109 | $offset = $this->dlParams['display']*abs($offset-1); |
@@ -113,7 +115,9 @@ discard block |
||
113 | 115 | $this->dlParams['sortDir'] = $_REQUEST['order']; |
114 | 116 | } |
115 | 117 | foreach ($this->dlParams as &$param) { |
116 | - if (empty($param)) unset($param); |
|
118 | + if (empty($param)) { |
|
119 | + unset($param); |
|
120 | + } |
|
117 | 121 | } |
118 | 122 | } |
119 | 123 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php namespace SimpleTab; |
2 | 2 | |
3 | -require_once (MODX_BASE_PATH . 'assets/lib/Helpers/FS.php'); |
|
3 | +require_once (MODX_BASE_PATH.'assets/lib/Helpers/FS.php'); |
|
4 | 4 | |
5 | 5 | abstract class AbstractController { |
6 | 6 | public $rfName = ''; |
@@ -30,15 +30,15 @@ discard block |
||
30 | 30 | |
31 | 31 | protected $modx = null; |
32 | 32 | |
33 | - public function __construct(\DocumentParser $modx){ |
|
33 | + public function __construct(\DocumentParser $modx) { |
|
34 | 34 | $this->FS = \Helpers\FS::getInstance(); |
35 | 35 | $this->modx = $modx; |
36 | 36 | $this->params = $modx->event->params; |
37 | 37 | $this->rid = isset($_REQUEST[$this->rfName]) ? (int)$_REQUEST[$this->rfName] : 0; |
38 | 38 | } |
39 | 39 | |
40 | - public function callExit(){ |
|
41 | - if($this->isExit){ |
|
40 | + public function callExit() { |
|
41 | + if ($this->isExit) { |
|
42 | 42 | echo $this->output; |
43 | 43 | exit; |
44 | 44 | } |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | if (isset($_REQUEST['rows'])) $this->dlParams['display'] = (int)$_REQUEST['rows']; |
105 | 105 | $offset = isset($_REQUEST['page']) ? (int)$_REQUEST['page'] : 1; |
106 | 106 | $offset = $offset ? $offset : 1; |
107 | - $offset = $this->dlParams['display']*abs($offset-1); |
|
107 | + $offset = $this->dlParams['display'] * abs($offset - 1); |
|
108 | 108 | $this->dlParams['offset'] = $offset; |
109 | - if(isset($_REQUEST['sort'])){ |
|
109 | + if (isset($_REQUEST['sort'])) { |
|
110 | 110 | $this->dlParams['sortBy'] = preg_replace('/[^A-Za-z0-9_\-]/', '', $_REQUEST['sort']); |
111 | 111 | } |
112 | - if(isset($_REQUEST['order']) && in_array(strtoupper($_REQUEST['order']), array("ASC","DESC"))){ |
|
112 | + if (isset($_REQUEST['order']) && in_array(strtoupper($_REQUEST['order']), array("ASC", "DESC"))) { |
|
113 | 113 | $this->dlParams['sortDir'] = $_REQUEST['order']; |
114 | 114 | } |
115 | 115 | foreach ($this->dlParams as &$param) { |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | public function getLanguageCode() { |
121 | 121 | $manager_language = $this->modx->config['manager_language']; |
122 | - if(file_exists(MODX_MANAGER_PATH."includes/lang/".$manager_language.".inc.php")) { |
|
122 | + if (file_exists(MODX_MANAGER_PATH."includes/lang/".$manager_language.".inc.php")) { |
|
123 | 123 | include_once MODX_MANAGER_PATH."includes/lang/".$manager_language.".inc.php"; |
124 | 124 | } |
125 | 125 | return $modx_lang_attribute; |
@@ -7,17 +7,17 @@ discard block |
||
7 | 7 | |
8 | 8 | private $thumb = null; |
9 | 9 | protected $fs = null; |
10 | - public $debugMessages = ''; |
|
10 | + public $debugMessages = ''; |
|
11 | 11 | |
12 | 12 | public function __construct() |
13 | 13 | { |
14 | - $this->thumb = new \phpthumb(); |
|
15 | - $this->fs = FS::getInstance(); |
|
14 | + $this->thumb = new \phpthumb(); |
|
15 | + $this->fs = FS::getInstance(); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | public function create($inputFile, $outputFile, $options) { |
19 | 19 | $this->thumb->sourceFilename = $inputFile; |
20 | - $ext = explode('.',$inputFile); |
|
20 | + $ext = explode('.',$inputFile); |
|
21 | 21 | $ext = str_replace('jpeg','jpg',strtolower(array_pop($ext))); |
22 | 22 | $options = 'f='.$ext.'&'.$options; |
23 | 23 | $this->setOptions($options); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | public function optimize($file, $type = 'jpg') { |
33 | 33 | switch ($type) { |
34 | 34 | case 'jpg': |
35 | - $ext = $this->fs->takeFileExt($file); |
|
35 | + $ext = $this->fs->takeFileExt($file); |
|
36 | 36 | if ($ext == 'jpeg' || $ext == 'jpg') { |
37 | 37 | $cmd = '/usr/bin/jpegtran -optimize -progressive -copy none -outfile '.escapeshellarg($file.'_').' '.escapeshellarg($file); |
38 | 38 | exec($cmd, $result, $return_var); |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php namespace Helpers; |
2 | 2 | |
3 | 3 | include_once(MODX_BASE_PATH.'assets/snippets/phpthumb/phpthumb.class.php'); |
4 | -require_once(MODX_BASE_PATH . 'assets/lib/Helpers/FS.php'); |
|
4 | +require_once(MODX_BASE_PATH.'assets/lib/Helpers/FS.php'); |
|
5 | 5 | |
6 | -class PHPThumb{ |
|
6 | +class PHPThumb { |
|
7 | 7 | |
8 | 8 | private $thumb = null; |
9 | 9 | protected $fs = null; |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | |
18 | 18 | public function create($inputFile, $outputFile, $options) { |
19 | 19 | $this->thumb->sourceFilename = $inputFile; |
20 | - $ext = explode('.',$inputFile); |
|
21 | - $ext = str_replace('jpeg','jpg',strtolower(array_pop($ext))); |
|
20 | + $ext = explode('.', $inputFile); |
|
21 | + $ext = str_replace('jpeg', 'jpg', strtolower(array_pop($ext))); |
|
22 | 22 | $options = 'f='.$ext.'&'.$options; |
23 | 23 | $this->setOptions($options); |
24 | 24 | if ($this->thumb->GenerateThumbnail() && $this->thumb->RenderToFile($outputFile)) { |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | - * @param $inputFile |
|
27 | - * @param $outputFile |
|
26 | + * @param string $inputFile |
|
27 | + * @param string $outputFile |
|
28 | 28 | * @param $options |
29 | 29 | * @return bool |
30 | 30 | */ |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | - * @param $options |
|
69 | + * @param string $options |
|
70 | 70 | */ |
71 | 71 | private function setOptions($options) { |
72 | 72 | $options = strtr($options, Array("," => "&", "_" => "=", '{' => '[', '}' => ']')); |