@@ -93,12 +93,12 @@ discard block |
||
| 93 | 93 | public function registerScript($name, $params) |
| 94 | 94 | { |
| 95 | 95 | $out = ''; |
| 96 | - if (!isset($this->modx->loadedjscripts[$name])) { |
|
| 96 | + if ( ! isset($this->modx->loadedjscripts[$name])) { |
|
| 97 | 97 | $src = $params['src']; |
| 98 | 98 | $remote = strpos($src, "http") !== false; |
| 99 | - if (!$remote) { |
|
| 99 | + if ( ! $remote) { |
|
| 100 | 100 | $src = $this->modx->config['site_url'] . $src; |
| 101 | - if (!$this->fs->checkFile($params['src'])) { |
|
| 101 | + if ( ! $this->fs->checkFile($params['src'])) { |
|
| 102 | 102 | $this->modx->logEvent(0, 3, 'Cannot load ' . $src, 'Assets helper'); |
| 103 | 103 | |
| 104 | 104 | return $out; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | public function registerScriptsList($list = array()) |
| 129 | 129 | { |
| 130 | 130 | $out = ''; |
| 131 | - if (!is_array($list)) return $out; |
|
| 131 | + if ( ! is_array($list)) return $out; |
|
| 132 | 132 | |
| 133 | 133 | foreach ($list as $script => $params) { |
| 134 | 134 | $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,21 +60,25 @@ 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 (file_exists(MODX_MANAGER_PATH . 'media/script/jquery/jquery.min.js')) return $output; |
|
| 77 | - if (array_search('ManagerManager', $plugins['OnDocFormRender']) !== false) return $output; |
|
| 76 | + if (file_exists(MODX_MANAGER_PATH . 'media/script/jquery/jquery.min.js')) {
|
|
| 77 | + return $output; |
|
| 78 | + } |
|
| 79 | + if (array_search('ManagerManager', $plugins['OnDocFormRender']) !== false) {
|
|
| 80 | + return $output; |
|
| 81 | + } |
|
| 78 | 82 | |
| 79 | 83 | $output .= $this->registerScript('jQuery', array( |
| 80 | 84 | 'src' => 'assets/js/jquery/jquery-1.9.1.min.js', |
@@ -90,15 +94,15 @@ discard block |
||
| 90 | 94 | * @param $params |
| 91 | 95 | * @return string |
| 92 | 96 | */ |
| 93 | - public function registerScript($name, $params) |
|
| 94 | - { |
|
| 97 | + public function registerScript($name, $params) |
|
| 98 | + {
|
|
| 95 | 99 | $out = ''; |
| 96 | - if (!isset($this->modx->loadedjscripts[$name])) { |
|
| 100 | + if (!isset($this->modx->loadedjscripts[$name])) {
|
|
| 97 | 101 | $src = $params['src']; |
| 98 | 102 | $remote = strpos($src, "http") !== false; |
| 99 | - if (!$remote) { |
|
| 103 | + if (!$remote) {
|
|
| 100 | 104 | $src = $this->modx->config['site_url'] . $src; |
| 101 | - if (!$this->fs->checkFile($params['src'])) { |
|
| 105 | + if (!$this->fs->checkFile($params['src'])) {
|
|
| 102 | 106 | $this->modx->logEvent(0, 3, 'Cannot load ' . $src, 'Assets helper'); |
| 103 | 107 | |
| 104 | 108 | return $out; |
@@ -107,9 +111,9 @@ discard block |
||
| 107 | 111 | |
| 108 | 112 | $tmp = explode('.', $src); |
| 109 | 113 | $type = isset($params['type']) ? $params['type'] : end($tmp); |
| 110 | - if ($type == 'js') { |
|
| 114 | + if ($type == 'js') {
|
|
| 111 | 115 | $out = '<script type="text/javascript" src="' . $src . '"></script>'; |
| 112 | - } else { |
|
| 116 | + } else {
|
|
| 113 | 117 | $media = isset($params['media']) ? " media=\"{$params['media']}\"" : ''; |
| 114 | 118 | $out = "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$src}\"{$media}>"; |
| 115 | 119 | } |
@@ -125,12 +129,14 @@ discard block |
||
| 125 | 129 | * @param array $list |
| 126 | 130 | * @return string |
| 127 | 131 | */ |
| 128 | - public function registerScriptsList($list = array()) |
|
| 129 | - { |
|
| 132 | + public function registerScriptsList($list = array()) |
|
| 133 | + {
|
|
| 130 | 134 | $out = ''; |
| 131 | - if (!is_array($list)) return $out; |
|
| 135 | + if (!is_array($list)) {
|
|
| 136 | + return $out; |
|
| 137 | + } |
|
| 132 | 138 | |
| 133 | - foreach ($list as $script => $params) { |
|
| 139 | + foreach ($list as $script => $params) {
|
|
| 134 | 140 | $out .= $this->registerScript($script, $params); |
| 135 | 141 | } |
| 136 | 142 | |