PluginProbe
CSS & JavaScript Toolbox / 12.0.7
CSS & JavaScript Toolbox v12.0.7
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
css-javascript-toolbox / css-js-toolbox.class.php

css-js-toolbox.class.php in CSS & JavaScript Toolbox 12.0.7, at css-js-toolbox.class.php

304 lines 6.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 */
5
6 // Disallow direct access.
7 defined( 'ABSPATH' ) or die( 'Access denied' );
8
9
10
11 /** Change active profile to development state */
12 define( 'CJTOOLBOX_PROFILE_DEVELOPMENT', 'development' );
13
14 /** Change active profile to production state */
15 define( 'CJTOOLBOX_PROFILE_PRODUCTION', 'production' );
16
17 /** Set development state */
18 define( 'CJTOOLBOX_ACTIVE_PROFILE', CJTOOLBOX_PROFILE_DEVELOPMENT );
19
20 /** MVC library framework */
21 define( 'CJTOOLBOX_MVC_FRAMEWOK', CJTOOLBOX_INCLUDE_PATH . '/mvc' );
22
23 /** Models dir path */
24 define( 'CJTOOLBOX_MODELS_PATH', CJTOOLBOX_PATH . '/models' );
25
26 /** Tables dir path */
27 define( 'CJTOOLBOX_TABLES_PATH', CJTOOLBOX_PATH . '/tables' );
28
29 /** Models views path */
30 define( 'CJTOOLBOX_VIEWS_PATH', CJTOOLBOX_PATH . '/views' );
31
32 /** Views controllers path */
33 define( 'CJTOOLBOX_CONTROLLERS_PATH', CJTOOLBOX_PATH . '/controllers' );
34
35 /** URI to CJT Plugin dir */
36 define( 'CJTOOLBOX_URL', WP_PLUGIN_URL . '/' . CJTOOLBOX_NAME );
37
38 /** URI to CJT Views directory */
39 define( 'CJTOOLBOX_VIEWS_URL', CJTOOLBOX_URL . '/views' );
40
41 /** HTML Components URI */
42 define( 'CJTOOLBOX_HTML_CONPONENTS_URL', CJTOOLBOX_URL . '/framework/html/components' );
43
44 /**
45 * CJT Core class.
46 *
47 * @package CJT
48 * @author Original Developer
49 * @version 0.3
50 */
51 class cssJSToolbox extends CJTHookableClass
52 {
53
54 /**
55 *
56 */
57 const CJT_WEB_SITE_DOMAIN = 'css-javascript-toolbox.com';
58
59 /**
60 * put your comment there...
61 *
62 * @todo remove this and use configuration instead
63 *
64 * @var mixed
65 */
66 public static $config = null;
67
68 /**
69 * put your comment there...
70 *
71 * @var mixed
72 */
73 private $dbDriver;
74
75 /**
76 * Reference of CJT Plugin object.
77 *
78 * @var cssJSToolbox
79 */
80 public static $instance = null;
81
82 /**
83 * put your comment there...
84 *
85 * @var mixed
86 */
87 protected static $ongettext = [ 'parameters' => [ 'text' ] ];
88
89 /**
90 * put your comment there...
91 *
92 * @var mixed
93 */
94 protected static $onimport = [ 'parameters' => [ 'vpaths' ] ];
95
96 /**
97 * put your comment there...
98 *
99 * @var mixed
100 */
101 protected static $oninstantiate = [ 'parameters' => [ 'instance' ] ];
102
103 /**
104 * put your comment there...
105 *
106 * @var mixed
107 */
108 protected $onloadconfiguration = [ 'parameters' => [ 'configuration' ] ];
109
110 /**
111 * put your comment there...
112 *
113 * @var mixed
114 */
115 protected $onloaddbdriver = [ 'parameters' => [ 'dbdriver' ] ];
116
117 /**
118 * put your comment there...
119 *
120 * @var mixed
121 */
122 protected static $onresolvepath = [ 'parameters' => [ 'path', 'vpath' ] ];
123
124 /**
125 * put your comment there...
126 *
127 * @param mixed $text
128 */
129 public static function _( $formattedText )
130 {
131
132 // Get formats as single args
133 $args = func_get_args();
134 array_shift( $args );
135
136 // Shift localized text into first array items
137 array_unshift( $args, self::getText( $formattedText ) );
138
139 // Return formatted text
140 return call_user_func_array( 'sprintf', $args );
141 }
142
143 /**
144 * Initialize Plugin.
145 *
146 * @return void
147 */
148 protected function __construct()
149 {
150
151 parent::__construct();
152
153 // Load configuration.
154 self::$config = $this->onloadconfiguration( require( self::resolvePath( 'configuration.inc.php' ) ) );
155
156
157 self::import( 'framework:db:mysql:queue-driver.inc.php' );
158
159 $this->dbDriver = $this->onloaddbdriver( new CJTMYSQLQueueDriver( $GLOBALS[ 'wpdb' ] ) );
160 }
161
162 /**
163 * put your comment there...
164 *
165 */
166 public static function getCJTWebSiteURL( $path = null )
167 {
168 $domain = self::CJT_WEB_SITE_DOMAIN;
169
170 return "https://{$domain}/{$path}";
171 }
172
173 /**
174 * put your comment there...
175 *
176 */
177 public function & getDBDriver()
178 {
179 return $this->dbDriver;
180 }
181
182 /**
183 * Get CJT Plugin object.
184 *
185 * @return cssJSToolbox
186 */
187 public static function & getInstance()
188 {
189
190 if ( ! self::$instance )
191 {
192 self::$instance = self::trigger( 'cssJSToolbox.instantiate', ( new cssJSToolbox() ) );
193 }
194
195 return self::$instance;
196 }
197
198 /**
199 * put your comment there...
200 *
201 */
202 public static function getSecurityToken()
203 {
204 return wp_create_nonce( CJTController::NONCE_ACTION );
205 }
206
207 /**
208 * put your comment there...
209 *
210 * @param mixed $text
211 */
212 public static function getText( $text )
213 {
214 // Simply return text without any translation attempts
215 return $text;
216 }
217
218 /**
219 * put your comment there...
220 *
221 * @param mixed $path
222 */
223 public static function getURI( $vPath, $uriBase = null )
224 {
225 // PHP wrapper however its not imlpemented as wrapper yet
226 // because this is not the point right now!
227 if ( strpos( $vPath, 'extension://' ) === 0)
228 {
229 // Expression for getting plugin/extension name!
230 $exp = '/^extension\:\/\/([^\/]+)/';
231 preg_match( $exp, $vPath, $extensionPath );
232
233 // Get base URI + removing extension:// wrapper!
234 $uriBase = plugins_url( $extensionPath[ 1 ] );
235
236 $uri = self::getURI( preg_replace( $exp, '', $vPath ), $uriBase );
237
238 }
239 else
240 {
241 // Translate Virtual path to real path.
242 $path = str_replace( ':', '/', $vPath );
243
244 // Get full URI.
245 if ( ! isset( $uriBase ) )
246 {
247
248 $uriBase = plugin_dir_url( __FILE__ );
249
250 }
251
252 $uri = "{$uriBase}{$path}";
253 }
254
255 return $uri;
256 }
257
258 /**
259 * put your comment there...
260 *
261 */
262 public static function import()
263 {
264
265 $params = func_get_args();
266
267 // Allow vriables list parameters.
268 $vPaths = self::trigger( 'cssJSToolbox.import', $params );
269 foreach ( $vPaths as $vPath )
270 {
271 require_once self::resolvePath( $vPath );
272 }
273
274 }
275
276 /**
277 * put your comment there...
278 *
279 * @param mixed $vPath
280 * @param mixed $base
281 */
282 public static function resolvePath( $vPath, $base = CJTOOLBOX_PATH )
283 {
284 // Resolve CJT extensions path
285 if ( strpos( $vPath, 'extension://' ) === 0 )
286 {
287 // Remove extension wrapper
288 $vPath = str_replace( 'extension://', '', $vPath );
289
290 // Point to plugin directory
291 $base = WP_PLUGIN_DIR;
292
293 }
294 // Replace all :'s with /'s.
295 $path = str_replace( ':', '/', $vPath );
296 $path = "{$base}/{$path}";
297
298 return self::trigger( 'cssJSToolbox.resolvepath', $path, $vPath );
299 }
300
301 }// End Class
302
303 // Hookable!
304 cssJSToolbox::define( 'cssJSToolbox', array( 'hookType' => CJTWordpressEvents::HOOK_FILTER ) );