| @@ -115,8 +115,15 @@ | ||
| 115 | 115 | * put your comment there... |
| 116 | 116 | * |
| 117 | 117 | * @var mixed |
| 118 | 118 | */ |
| 119 | + protected $params = null; | |
| 120 | + | |
| 121 | + /** | |
| 122 | + * put your comment there... | |
| 123 | + * | |
| 124 | + * @var mixed | |
| 125 | + */ | |
| 119 | 126 | protected $request; |
| 120 | 127 | |
| 121 | 128 | /** |
| 122 | 129 | * put your comment there... |
| @@ -134,12 +141,16 @@ | ||
| 134 | 141 | |
| 135 | 142 | /** |
| 136 | 143 | * put your comment there... |
| 137 | 144 | * |
| 145 | + * @param mixed $info | |
| 146 | + * @param mixed $params | |
| 147 | + * @return CJTView | |
| 138 | 148 | */ |
| 139 | - public function __construct($info) { | |
| 149 | + public function __construct($info, $params = null) { | |
| 140 | 150 | // Initialize vars! |
| 141 | 151 | $this->viewInfo = $info; |
| 152 | + $this->params = $params ? $params : array(); | |
| 142 | 153 | // Initialize events engine! |
| 143 | 154 | parent::__construct(); |
| 144 | 155 | // Fire created event! |
| 145 | 156 | $this->oncreated($info); |
| @@ -157,11 +168,12 @@ | ||
| 157 | 168 | /** |
| 158 | 169 | * put your comment there... |
| 159 | 170 | * |
| 160 | 171 | * @param mixed $view |
| 172 | + * @param mixed $params | |
| 161 | 173 | */ |
| 162 | - public static function getInstance($view) { | |
| 163 | - return self::trigger('CJTView.createview', CJTController::getView($view)); | |
| 174 | + public static function getInstance($view, $params = null) { | |
| 175 | + return self::trigger('CJTView.createview', CJTController::getView($view, $params)); | |
| 164 | 176 | } |
| 165 | 177 | |
| 166 | 178 | /** |
| 167 | 179 | * put your comment there... |
| @@ -178,8 +190,17 @@ | ||
| 178 | 190 | |
| 179 | 191 | /** |
| 180 | 192 | * put your comment there... |
| 181 | 193 | * |
| 194 | + * @param mixed $name | |
| 195 | + */ | |
| 196 | + public function getParam($name) { | |
| 197 | + return isset($this->params[$name]) ? $this->params[$name] : null; | |
| 198 | + } | |
| 199 | + | |
| 200 | + /** | |
| 201 | + * put your comment there... | |
| 202 | + * | |
| 182 | 203 | * @param mixed $destination |
| 183 | 204 | */ |
| 184 | 205 | public function getPath($destination) { |
| 185 | 206 | return self::getViewPath($this->viewInfo['name'], $destination); |
| @@ -199,9 +220,9 @@ | ||
| 199 | 220 | * @param mixed $name |
| 200 | 221 | * @param mixed $value |
| 201 | 222 | */ |
| 202 | 223 | public function getRequestParameter($name) { |
| 203 | - return $this->request[$name]; | |
| 224 | + return isset($this->request[$name]) ? $this->request[$name] : null; | |
| 204 | 225 | } |
| 205 | 226 | |
| 206 | 227 | /** |
| 207 | 228 | * put your comment there... |
| @@ -320,8 +341,20 @@ | ||
| 320 | 341 | /** |
| 321 | 342 | * put your comment there... |
| 322 | 343 | * |
| 323 | 344 | */ |
| 345 | + protected function & suppressPrintScriptsHook() { | |
| 346 | + // Access Global. | |
| 347 | + global $wp_actions; | |
| 348 | + // Mark as triggered. | |
| 349 | + $wp_actions['wp_print_scripts'] = true; | |
| 350 | + // Chain. | |
| 351 | + return $this; | |
| 352 | + } | |
| 353 | + /** | |
| 354 | + * put your comment there... | |
| 355 | + * | |
| 356 | + */ | |
| 324 | 357 | protected static function useScripts($className, $scripts = null) { |
| 325 | 358 | wp_enqueue_script('Just Load Default Scripts, this works great!!!!'); |
| 326 | 359 | // Use current class name is $className is not provided! |
| 327 | 360 | if (!$className) { |
| @@ -341,19 +374,22 @@ | ||
| 341 | 374 | // Get script name. |
| 342 | 375 | preg_match($nameExp, $script, $scriptObject); |
| 343 | 376 | // [[2]Prefix], [4] name. Prefix may be not presented. |
| 344 | 377 | $name = "{$scriptObject[2]}{$scriptObject[4]}"; |
| 345 | - if (!$stack[$name]) { | |
| 378 | + $location = isset($scriptObject[7]) ? $scriptObject[7] : null; | |
| 379 | + $scriptParameters = isset($scriptObject[5]) ? $scriptObject[5] : ''; | |
| 380 | + if (!isset($stack[$name])) { | |
| 346 | 381 | // Any JS lib file should named the same as the parent folder with the extension added. |
| 347 | - $libPath = ":{$scriptObject[4]}:{$scriptObject[4]}"; | |
| 382 | + // Except files with _ at the begning | |
| 383 | + $libPath = ':' . ((strpos($scriptObject[4], '_') === 0) ? substr($scriptObject[4], 1) : "{$scriptObject[4]}:{$scriptObject[4]}"); | |
| 348 | 384 | // Pass virtual path to getURI and resolvePath to |
| 349 | 385 | // get JS file URI and localization file path. |
| 350 | 386 | $jsFile = cssJSToolbox::getURI(preg_replace($nameExp, "{$libPath}.js", $script)); |
| 351 | 387 | $localizationFile = cssJSToolbox::resolvePath(preg_replace($nameExp, "{$libPath}.localization.php", $script)); |
| 352 | 388 | // Enqueue script file. |
| 353 | - wp_enqueue_script($name, $jsFile, null, null, $scriptObject[7]); | |
| 389 | + wp_enqueue_script($name, $jsFile, null, null, $location); | |
| 354 | 390 | // Set script parameters. |
| 355 | - if (preg_match_all('/(\w+)=(\w+)/', $scriptObject[5], $params, PREG_SET_ORDER) ) { | |
| 391 | + if (preg_match_all('/(\w+)=(\w+)/', $scriptParameters, $params, PREG_SET_ORDER) ) { | |
| 356 | 392 | // Set parameters. |
| 357 | 393 | foreach ($params as $param) { |
| 358 | 394 | $stack[$name]->cjt[$param[1]] = $param[2]; |
| 359 | 395 | } |
| @@ -375,9 +411,9 @@ | ||
| 375 | 411 | } |
| 376 | 412 | } |
| 377 | 413 | // Enqueue already registered scripts! |
| 378 | 414 | else { |
| 379 | - wp_enqueue_script($name, $jsFile, null, null, $scriptObject[7]); | |
| 415 | + wp_enqueue_script($name, null, null, null, $location); | |
| 380 | 416 | } |
| 381 | 417 | } |
| 382 | 418 | } |
| 383 | 419 | |
| @@ -404,9 +440,9 @@ | ||
| 404 | 440 | // Get script name. |
| 405 | 441 | preg_match($nameExp, $style, $styleObject); |
| 406 | 442 | // [[2]Prefix], [4] name. Prefix may be not presented. |
| 407 | 443 | $name = "{$styleObject[2]}{$styleObject[4]}"; |
| 408 | - if (!$GLOBALS['wp_styles']->registered[$name]) { | |
| 444 | + if (!isset($GLOBALS['wp_styles']->registered[$name])) { | |
| 409 | 445 | // Make all enqueued styles names unique from enqueued scripts. |
| 410 | 446 | // This is useful when merging styles & scripts is required. |
| 411 | 447 | $name = "CSS-{$name}"; |
| 412 | 448 | // Any JS lib file should named the same as the parent folder with the extension added. |
| @@ -417,9 +453,9 @@ | ||
| 417 | 453 | wp_enqueue_style($name, $cssFile); |
| 418 | 454 | } |
| 419 | 455 | else { |
| 420 | 456 | // Enqueue already registered styles. |
| 421 | - wp_enqueue_style($name, $cssFile); | |
| 457 | + wp_enqueue_style($name); | |
| 422 | 458 | } |
| 423 | 459 | } |
| 424 | 460 | } |
| 425 | 461 | |