Version Description
- Fix: Block Code file name moving away when open/close Block metabox
- Fix: Shortcode list is too small for Shortcode names
- Enhance: CJT Framework for packages and extensions updates
Download this release
Release Info
Developer | xpointer |
Plugin | CSS & JavaScript Toolbox |
Version | 7.2 |
Comparing to | |
See all releases |
Code changes from version 7.1.2 to 7.2
- css-js-toolbox.php +13 -4
- framework/autoload/loader.php +1 -1
- framework/db/mysql/queue-driver.inc.php +6 -1
- framework/developer/interface/block/parameters/parameters.php +1 -1
- framework/developer/interface/block/parameters/types/array.php +1 -1
- framework/developer/interface/block/shortcode/parameters/base/abstract.php +1 -1
- framework/extensions/extensions.class.php +36 -12
- framework/extensions/package/activator.php +50 -0
- framework/extensions/package/blocks.php +67 -0
- framework/extensions/package/extension.php +164 -0
- framework/extensions/package/state/extension.php +192 -0
- framework/extensions/package/state/packages.php +187 -0
- framework/version/version.php +1 -1
- models/package-file.php +3 -3
- models/package.php +1 -0
- readme.txt +10 -2
- views/blocks/block/public/css/block.css +4 -6
- views/blocks/block/public/js/codefile/codefile.js +1 -1
- views/tinymce/shortcodes/public/plugins/shortcode/shortcode.js +1 -1
css-js-toolbox.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: CSS & JavaScript Toolbox
|
4 |
Plugin URI: http://css-javascript-toolbox.com/css-javascript-toolbox-free
|
5 |
Description: CJT Plugin for WordPress to easily add custom CSS and JavaScript to individual pages
|
6 |
-
Version: 7.
|
7 |
Author: Wipeout Media
|
8 |
Author URI: http://css-javascript-toolbox.com
|
9 |
License:
|
@@ -100,12 +100,12 @@ class CJTPlugin extends CJTHookableClass {
|
|
100 |
/**
|
101 |
*
|
102 |
*/
|
103 |
-
const FW_Version = '
|
104 |
|
105 |
/**
|
106 |
*
|
107 |
*/
|
108 |
-
const VERSION = '7.
|
109 |
|
110 |
/**
|
111 |
*
|
@@ -180,6 +180,13 @@ class CJTPlugin extends CJTHookableClass {
|
|
180 |
*/
|
181 |
protected $onimportmodel = array('parameters' => array('file'));
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
/**
|
184 |
* put your comment there...
|
185 |
*
|
@@ -204,7 +211,7 @@ class CJTPlugin extends CJTHookableClass {
|
|
204 |
* put your comment there...
|
205 |
*
|
206 |
*/
|
207 |
-
public function extensions() {
|
208 |
return $this->extensions;
|
209 |
}
|
210 |
|
@@ -296,6 +303,8 @@ class CJTPlugin extends CJTHookableClass {
|
|
296 |
* @return $this
|
297 |
*/
|
298 |
protected function main() {
|
|
|
|
|
299 |
// Access point base class is a dependency!
|
300 |
require_once 'framework/access-points/access-point.class.php';
|
301 |
// Run Main Acces Point!
|
3 |
Plugin Name: CSS & JavaScript Toolbox
|
4 |
Plugin URI: http://css-javascript-toolbox.com/css-javascript-toolbox-free
|
5 |
Description: CJT Plugin for WordPress to easily add custom CSS and JavaScript to individual pages
|
6 |
+
Version: 7.2
|
7 |
Author: Wipeout Media
|
8 |
Author URI: http://css-javascript-toolbox.com
|
9 |
License:
|
100 |
/**
|
101 |
*
|
102 |
*/
|
103 |
+
const FW_Version = '3.0';
|
104 |
|
105 |
/**
|
106 |
*
|
107 |
*/
|
108 |
+
const VERSION = '7.2-CE' ;
|
109 |
|
110 |
/**
|
111 |
*
|
180 |
*/
|
181 |
protected $onimportmodel = array('parameters' => array('file'));
|
182 |
|
183 |
+
/**
|
184 |
+
* put your comment there...
|
185 |
+
*
|
186 |
+
* @var mixed
|
187 |
+
*/
|
188 |
+
protected $onload = array('parameters' => array('instance'));
|
189 |
+
|
190 |
/**
|
191 |
* put your comment there...
|
192 |
*
|
211 |
* put your comment there...
|
212 |
*
|
213 |
*/
|
214 |
+
public function & extensions() {
|
215 |
return $this->extensions;
|
216 |
}
|
217 |
|
303 |
* @return $this
|
304 |
*/
|
305 |
protected function main() {
|
306 |
+
// Fire laod event
|
307 |
+
$this->onload($this);
|
308 |
// Access point base class is a dependency!
|
309 |
require_once 'framework/access-points/access-point.class.php';
|
310 |
// Run Main Acces Point!
|
framework/autoload/loader.php
CHANGED
@@ -138,7 +138,7 @@ class CJT_Framework_Autoload_Loader {
|
|
138 |
$classFile = $this->getClassAbsolutePath($this->getClassComponent($class));
|
139 |
}
|
140 |
// Whatever a class file is set, import it!
|
141 |
-
if ($classFile) {
|
142 |
require $classFile;
|
143 |
}
|
144 |
}
|
138 |
$classFile = $this->getClassAbsolutePath($this->getClassComponent($class));
|
139 |
}
|
140 |
// Whatever a class file is set, import it!
|
141 |
+
if ($classFile && file_exists($classFile)) {
|
142 |
require $classFile;
|
143 |
}
|
144 |
}
|
framework/db/mysql/queue-driver.inc.php
CHANGED
@@ -128,6 +128,11 @@ class CJTMYSQLQueueDriver extends CJTHookableClass {
|
|
128 |
* @return string
|
129 |
*/
|
130 |
public function escapeValue($data, $field) {
|
|
|
|
|
|
|
|
|
|
|
131 |
switch ($field->numeric) {
|
132 |
case 0:
|
133 |
$data = esc_sql($data);
|
@@ -165,7 +170,7 @@ class CJTMYSQLQueueDriver extends CJTHookableClass {
|
|
165 |
*/
|
166 |
public function getColumns($table) {
|
167 |
$columns = array();
|
168 |
-
$this->select("SELECT * FROM {$table} WHERE 1!=1;");
|
169 |
// Use field name as element key.
|
170 |
foreach ($this->wpdb->col_info as $index => $column) {
|
171 |
$columns[$column->name] = $column;
|
128 |
* @return string
|
129 |
*/
|
130 |
public function escapeValue($data, $field) {
|
131 |
+
# MYSQLI doesn't has numeric field.
|
132 |
+
if ($this->wpdb->use_mysqli) {
|
133 |
+
$field->numeric = $field->flags & MYSQLI_NUM_FLAG;
|
134 |
+
}
|
135 |
+
# Check if numeric
|
136 |
switch ($field->numeric) {
|
137 |
case 0:
|
138 |
$data = esc_sql($data);
|
170 |
*/
|
171 |
public function getColumns($table) {
|
172 |
$columns = array();
|
173 |
+
$this->select("SELECT * FROM {$table} WHERE 1!=1 LIMIT 0,1;");
|
174 |
// Use field name as element key.
|
175 |
foreach ($this->wpdb->col_info as $index => $column) {
|
176 |
$columns[$column->name] = $column;
|
framework/developer/interface/block/parameters/parameters.php
CHANGED
@@ -60,7 +60,7 @@ abstract class CJT_Framework_Developer_Interface_Block_Parameters_Parameters {
|
|
60 |
* put your comment there...
|
61 |
*
|
62 |
*/
|
63 |
-
public function getParams() {
|
64 |
return $this->params;
|
65 |
}
|
66 |
|
60 |
* put your comment there...
|
61 |
*
|
62 |
*/
|
63 |
+
public function & getParams() {
|
64 |
return $this->params;
|
65 |
}
|
66 |
|
framework/developer/interface/block/parameters/types/array.php
CHANGED
@@ -16,7 +16,7 @@ CJT_Framework_Developer_Interface_Block_Parameters_Types_Base_Scalar {
|
|
16 |
* put your comment there...
|
17 |
*
|
18 |
*/
|
19 |
-
public function getValue() {
|
20 |
// Initialize.
|
21 |
$value = array();
|
22 |
// Get final value!
|
16 |
* put your comment there...
|
17 |
*
|
18 |
*/
|
19 |
+
public function getValue($useRealNames = null) {
|
20 |
// Initialize.
|
21 |
$value = array();
|
22 |
// Get final value!
|
framework/developer/interface/block/shortcode/parameters/base/abstract.php
CHANGED
@@ -65,7 +65,7 @@ CJT_Framework_Developer_Interface_Block_Shortcode_Parameters_Interface_Type {
|
|
65 |
* put your comment there...
|
66 |
*
|
67 |
*/
|
68 |
-
|
69 |
return $this->getTypeObject()->getFactory();
|
70 |
}
|
71 |
|
65 |
* put your comment there...
|
66 |
*
|
67 |
*/
|
68 |
+
public function getFactory() {
|
69 |
return $this->getTypeObject()->getFactory();
|
70 |
}
|
71 |
|
framework/extensions/extensions.class.php
CHANGED
@@ -201,6 +201,7 @@ class CJTExtensions extends CJTHookableClass {
|
|
201 |
$extension = array();
|
202 |
$extension['pluginFile'] = $file;
|
203 |
$extension['file'] = basename($file);
|
|
|
204 |
// Its useful to use ABS path only at runtime as it might changed as host might get moved.
|
205 |
$extension['dir'] = str_replace((ABSPATH . PLUGINDIR . '/'), '', $pluginDir) ;
|
206 |
$extension['name'] = $pluginName;
|
@@ -211,6 +212,7 @@ class CJTExtensions extends CJTHookableClass {
|
|
211 |
// Read Basic XML Definition!
|
212 |
$definitionXML = $this->onloaddefinition(new SimpleXMLElement($extension['definition']['raw']));
|
213 |
$attrs = $definitionXML->attributes();
|
|
|
214 |
$extension['definition']['primary']['loadMethod'] = (string) $attrs->loadMethod;
|
215 |
$extension['definition']['primary']['requiredLicense'] = (string) $definitionXML->license;
|
216 |
$className = ((string) $attrs->class);
|
@@ -218,7 +220,6 @@ class CJTExtensions extends CJTHookableClass {
|
|
218 |
$extensions[$className] = $extension;
|
219 |
// Map Plugin FILE-2-CLASS name!
|
220 |
$this->file2Classmap["{$extension['dir']}/{$extension['file']}"] = $className;
|
221 |
-
$definitionXML = null;
|
222 |
}
|
223 |
}
|
224 |
}
|
@@ -241,27 +242,53 @@ class CJTExtensions extends CJTHookableClass {
|
|
241 |
spl_autoload_register($this->ontregisterautoload(array($this, '__autoload')));
|
242 |
// Load all CJT extensions!
|
243 |
foreach ($this->getExtensions() as $class => $extension) {
|
|
|
244 |
extract($this->onload($extension, compact('class', 'extension')));
|
245 |
-
//
|
246 |
-
$callback = $this->onloadcallback(array($class, $this->loadMethod));
|
247 |
$pluginPath = ABSPATH . PLUGINDIR . "/{$extension['name']}";
|
248 |
// Set runtime variables.
|
249 |
$this->extensions[$class]['runtime']['classFile'] = "{$pluginPath}/{$extension['name']}.class.php";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
// If auto load is speicifd then import class file and bind events.
|
251 |
if ($extension['definition']['primary']['loadMethod'] == 'auto') {
|
252 |
-
// Load definition.
|
253 |
-
$definitionXML = new SimpleXMLElement($extension['definition']['raw']);
|
254 |
// If frameworkVersion is not provided assume its 0 (Older version)
|
255 |
// before frameworkversion chech even supported.
|
256 |
// otherwise compare it with current frameworkversion
|
257 |
// If the version MAJOR is different current
|
258 |
// then its incompatible.
|
259 |
$extensionVer = new CJT_Framework_Version_Version((int) ((string) $definitionXML->attributes()->requireFrameworkVersion));
|
260 |
-
if ($frameworkVersion->getMajor()
|
|
|
|
|
|
|
261 |
// Add to incomaptibility list.
|
262 |
$this->incompatibilies[$pluginPath] = $extension;
|
263 |
}
|
264 |
else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
// Bind events for compatible extensions.
|
266 |
foreach ($definitionXML->getInvolved->event as $event) {
|
267 |
// filter!
|
@@ -298,14 +325,11 @@ class CJTExtensions extends CJTHookableClass {
|
|
298 |
*/
|
299 |
public function processIncompatibles() {
|
300 |
// Proces only if in CJT page.
|
301 |
-
if (!
|
302 |
return;
|
303 |
}
|
304 |
// INitialize.
|
305 |
-
$message = cssJSToolbox::getText('CJT detects incompatible installed extensions
|
306 |
-
Please upgrade those extensions from Wordpress Plugins or update page.
|
307 |
-
Those extensions are now stopped until the upgrade is done.
|
308 |
-
If you\'ve any problem upgrading them please visit CJT website by clicking extension links below.');
|
309 |
$list = '';
|
310 |
// For every compatible extension add
|
311 |
// an list item with details
|
@@ -316,7 +340,7 @@ class CJTExtensions extends CJTHookableClass {
|
|
316 |
// Show details.
|
317 |
$pluginInfo = get_plugin_data($extension['pluginFile']);
|
318 |
// List item Markup
|
319 |
-
$list .= "<li><a target='_blank' href='{$pluginInfo['PluginURI']}'>{$pluginInfo['Name']}</a
|
320 |
}
|
321 |
// Output full message.
|
322 |
// TODO: BAD PRACTICE1!!!!! NEVER MIX HTML WITH PHP, JUST TEMPORARY1!!!
|
201 |
$extension = array();
|
202 |
$extension['pluginFile'] = $file;
|
203 |
$extension['file'] = basename($file);
|
204 |
+
$extension['defFile'] = basename($pluginDir) . DIRECTORY_SEPARATOR . basename($xmlFile);
|
205 |
// Its useful to use ABS path only at runtime as it might changed as host might get moved.
|
206 |
$extension['dir'] = str_replace((ABSPATH . PLUGINDIR . '/'), '', $pluginDir) ;
|
207 |
$extension['name'] = $pluginName;
|
212 |
// Read Basic XML Definition!
|
213 |
$definitionXML = $this->onloaddefinition(new SimpleXMLElement($extension['definition']['raw']));
|
214 |
$attrs = $definitionXML->attributes();
|
215 |
+
$extension['defDoc'] = $definitionXML;
|
216 |
$extension['definition']['primary']['loadMethod'] = (string) $attrs->loadMethod;
|
217 |
$extension['definition']['primary']['requiredLicense'] = (string) $definitionXML->license;
|
218 |
$className = ((string) $attrs->class);
|
220 |
$extensions[$className] = $extension;
|
221 |
// Map Plugin FILE-2-CLASS name!
|
222 |
$this->file2Classmap["{$extension['dir']}/{$extension['file']}"] = $className;
|
|
|
223 |
}
|
224 |
}
|
225 |
}
|
242 |
spl_autoload_register($this->ontregisterautoload(array($this, '__autoload')));
|
243 |
// Load all CJT extensions!
|
244 |
foreach ($this->getExtensions() as $class => $extension) {
|
245 |
+
// Filters!
|
246 |
extract($this->onload($extension, compact('class', 'extension')));
|
247 |
+
// Build Extension plugin path
|
|
|
248 |
$pluginPath = ABSPATH . PLUGINDIR . "/{$extension['name']}";
|
249 |
// Set runtime variables.
|
250 |
$this->extensions[$class]['runtime']['classFile'] = "{$pluginPath}/{$extension['name']}.class.php";
|
251 |
+
// Load definition.
|
252 |
+
$definitionXML = $extension['defDoc'];
|
253 |
+
// Extensions below version 1.0 use static classes
|
254 |
+
// while version 1.0 and up use objects
|
255 |
+
if (((string) $definitionXML->attributes()->version) == '1.0') {
|
256 |
+
// Instantiate extension object
|
257 |
+
$extensionObject = new $class($extension);
|
258 |
+
// Hold extension object
|
259 |
+
$extension['exObject'] = $extensionObject;
|
260 |
+
// Obejct callback
|
261 |
+
$callback = array($extensionObject, $this->loadMethod);
|
262 |
+
}
|
263 |
+
else {
|
264 |
+
# Static callback
|
265 |
+
$callback = array($class, $this->loadMethod);
|
266 |
+
}
|
267 |
+
// Callback filter
|
268 |
+
$callback = $this->onloadcallback($callback);
|
269 |
// If auto load is speicifd then import class file and bind events.
|
270 |
if ($extension['definition']['primary']['loadMethod'] == 'auto') {
|
|
|
|
|
271 |
// If frameworkVersion is not provided assume its 0 (Older version)
|
272 |
// before frameworkversion chech even supported.
|
273 |
// otherwise compare it with current frameworkversion
|
274 |
// If the version MAJOR is different current
|
275 |
// then its incompatible.
|
276 |
$extensionVer = new CJT_Framework_Version_Version((int) ((string) $definitionXML->attributes()->requireFrameworkVersion));
|
277 |
+
if ($frameworkVersion->getMajor() < $extensionVer->getMajor()) {
|
278 |
+
// Detects which requird updates CJT or the Extension itself.
|
279 |
+
$extension['incompatibleMessage']['msg'] = cssJSToolbox::getText('Extension is required CJT Framework Version higher than currently installed, CJT need to get updated!!!');
|
280 |
+
$extension['incompatibleMessage']['flag'] = cssJSToolbox::getText('Aborted');
|
281 |
// Add to incomaptibility list.
|
282 |
$this->incompatibilies[$pluginPath] = $extension;
|
283 |
}
|
284 |
else {
|
285 |
+
# Detect extensions required old Framework
|
286 |
+
if ($frameworkVersion->getMajor() > $extensionVer->getMajor()) {
|
287 |
+
$extension['incompatibleMessage']['msg'] = cssJSToolbox::getText('Extension is required old CJT Framework Version than the installed. This extension might need to get update. Please check if this extension is currently behaving correctly!!!');
|
288 |
+
$extension['incompatibleMessage']['flag'] = cssJSToolbox::getText('Ignored');
|
289 |
+
// Add to incomaptibility list.
|
290 |
+
$this->incompatibilies[$pluginPath] = $extension;
|
291 |
+
}
|
292 |
// Bind events for compatible extensions.
|
293 |
foreach ($definitionXML->getInvolved->event as $event) {
|
294 |
// filter!
|
325 |
*/
|
326 |
public function processIncompatibles() {
|
327 |
// Proces only if in CJT page.
|
328 |
+
if (!preg_match('/\/plugins\.php|page\=cjtoolbox/', $_SERVER['REQUEST_URI'])) {
|
329 |
return;
|
330 |
}
|
331 |
// INitialize.
|
332 |
+
$message = cssJSToolbox::getText('CJT detects incompatible installed extensions, listed below with status message for every extension:');
|
|
|
|
|
|
|
333 |
$list = '';
|
334 |
// For every compatible extension add
|
335 |
// an list item with details
|
340 |
// Show details.
|
341 |
$pluginInfo = get_plugin_data($extension['pluginFile']);
|
342 |
// List item Markup
|
343 |
+
$list .= "<li><a target='_blank' href='{$pluginInfo['PluginURI']}'>{$pluginInfo['Name']}</a> (Status: {$extension['incompatibleMessage']['flag']}, Message: {$extension['incompatibleMessage']['msg']})</li>\n";
|
344 |
}
|
345 |
// Output full message.
|
346 |
// TODO: BAD PRACTICE1!!!!! NEVER MIX HTML WITH PHP, JUST TEMPORARY1!!!
|
framework/extensions/package/activator.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
*/
|
5 |
+
|
6 |
+
/**
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
class CJT_Framework_Extensions_Package_Activator {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* put your comment there...
|
13 |
+
*
|
14 |
+
* @var mixed
|
15 |
+
*/
|
16 |
+
protected $extensionPluginObject;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* put your comment there...
|
20 |
+
*
|
21 |
+
* @param mixed $extensionPluginObject
|
22 |
+
* @return CJT_Framework_Extensions_Package_Activator
|
23 |
+
*/
|
24 |
+
public function __construct(& $extensionPluginObject) {
|
25 |
+
# getting class name
|
26 |
+
$this->extensionPluginObject = $extensionPluginObject;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* put your comment there...
|
31 |
+
*
|
32 |
+
*/
|
33 |
+
public function & activate() {
|
34 |
+
# Getting extension class
|
35 |
+
$extensionClass = CJT_Framework_Extensions_Package_Extension::getPluginExtensionClass($this->extensionPluginObject);
|
36 |
+
# No activation process until the Plugin is deactivated before
|
37 |
+
# It must be installed first.
|
38 |
+
if (CJT_Framework_Extensions_Package_State_Extension::isInstalled($extensionClass)) {
|
39 |
+
# Initialize
|
40 |
+
$stateExtension = CJT_Framework_Extensions_Package_State_Extension::create($extensionClass);
|
41 |
+
$statePackage = new CJT_Framework_Extensions_Package_State_Packages($stateExtension->getExtensionDeDoc());
|
42 |
+
$extBlocks = new CJT_Framework_Extensions_Package_Blocks($statePackage);
|
43 |
+
# Enable all Blocks associated with extension packages
|
44 |
+
$extBlocks->setState(CJT_Framework_Extensions_Package_Blocks::ACTIVE);
|
45 |
+
}
|
46 |
+
# Chain
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
|
50 |
+
} # End class
|
framework/extensions/package/blocks.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
*/
|
5 |
+
|
6 |
+
/**
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
class CJT_Framework_Extensions_Package_Blocks {
|
10 |
+
|
11 |
+
/**
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
const ACTIVE = 'active';
|
15 |
+
|
16 |
+
/**
|
17 |
+
*
|
18 |
+
*/
|
19 |
+
const INACTIVE = 'inactive';
|
20 |
+
|
21 |
+
/**
|
22 |
+
* put your comment there...
|
23 |
+
*
|
24 |
+
* @var mixed
|
25 |
+
*/
|
26 |
+
protected $statePackage;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* put your comment there...
|
30 |
+
*
|
31 |
+
* @param CJT_Framework_Extensions_Package_State_Packages $statePackages
|
32 |
+
* @return {CJT_Framework_Extensions_Package_Blocks|CJT_Framework_Extensions_Package_State_Packages}
|
33 |
+
*/
|
34 |
+
public function __construct(CJT_Framework_Extensions_Package_State_Packages & $statePackages) {
|
35 |
+
# INitialize
|
36 |
+
$this->statePackage =& $statePackages;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* put your comment there...
|
41 |
+
*
|
42 |
+
* @param mixed $state
|
43 |
+
*/
|
44 |
+
public function setState($state) {
|
45 |
+
# Initialize
|
46 |
+
$dbDriver = cssJSToolbox::getInstance()->getDBDriver();
|
47 |
+
$statePackages =& $this->statePackage;
|
48 |
+
# Build packages Id SQL IN-OPERATO list
|
49 |
+
$pcksSQLIdList = array();
|
50 |
+
foreach ($statePackages->getInstalledPackages() as $name => $pck) {
|
51 |
+
# Push Id.
|
52 |
+
$pcksSQLIdList[] = $pck['id'];
|
53 |
+
}
|
54 |
+
$pcksSQLIdList = implode(',', $pcksSQLIdList);
|
55 |
+
# Build query
|
56 |
+
$query = "UPDATE
|
57 |
+
(#__cjtoolbox_packages p RIGHT JOIN #__cjtoolbox_package_objects po ON p.id = po.packageId
|
58 |
+
LEFT JOIN #__cjtoolbox_blocks b ON po.objectId = b.id)
|
59 |
+
SET state = '{$state}'
|
60 |
+
WHERE p.id IN ({$pcksSQLIdList}) AND po.objectType = 'block';";
|
61 |
+
# Update state for all blocks associated with all installed packages
|
62 |
+
$dbDriver->exec($query);
|
63 |
+
# Chain
|
64 |
+
return $this;
|
65 |
+
}
|
66 |
+
|
67 |
+
} # End class
|
framework/extensions/package/extension.php
ADDED
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
*/
|
5 |
+
|
6 |
+
/**
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
abstract class CJT_Framework_Extensions_Package_Extension extends CJTHookableClass {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* put your comment there...
|
13 |
+
*
|
14 |
+
* @var mixed
|
15 |
+
*/
|
16 |
+
protected $extension;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* put your comment there...
|
20 |
+
*
|
21 |
+
* @var mixed
|
22 |
+
*/
|
23 |
+
protected $extensionClass;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* put your comment there...
|
27 |
+
*
|
28 |
+
* @param mixed $extension
|
29 |
+
* @return CJT_Framework_Extensions_Package_Extension
|
30 |
+
*/
|
31 |
+
public function __construct($extension) {
|
32 |
+
# Hold extension class
|
33 |
+
$this->extensionClass = get_class($this);
|
34 |
+
$this->extension =& $extension;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Uninstaller for all Package Extension
|
39 |
+
*
|
40 |
+
* @param mixed $method
|
41 |
+
* @param mixed $params
|
42 |
+
* @return CJTWordpressEvents
|
43 |
+
*/
|
44 |
+
public static function __callStatic($method, $params) {
|
45 |
+
# Initialize
|
46 |
+
$packageModel = CJTModel::getInstance('package');
|
47 |
+
# Getting extension package class name
|
48 |
+
$extensionClass = basename(str_replace('_', DIRECTORY_SEPARATOR, $method));
|
49 |
+
# Extension state
|
50 |
+
$extensionState = CJT_Framework_Extensions_Package_State_Extension::create($extensionClass);
|
51 |
+
$extensionPackagesState = new CJT_Framework_Extensions_Package_State_Packages($extensionState->getExtensionDeDoc());
|
52 |
+
# Delete extension packages
|
53 |
+
foreach ($extensionPackagesState->getInstalledPackages() as $name => $iPack) {
|
54 |
+
# Remove package
|
55 |
+
$packageModel->delete($iPack['id']);
|
56 |
+
}
|
57 |
+
# Remove install information
|
58 |
+
$extensionPackagesState->clearInstallInfo();
|
59 |
+
$extensionState->clearInstallInfo();
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* put your comment there...
|
64 |
+
*
|
65 |
+
*/
|
66 |
+
public function _checkInstallationState() {
|
67 |
+
# Initialize
|
68 |
+
$extensionClass = $this->extensionClass;
|
69 |
+
$extension =& $this->extension;
|
70 |
+
$extensionDeDoc =& $extension['defDoc'];
|
71 |
+
$extensionState = new CJT_Framework_Extensions_Package_State_Extension($extensionDeDoc);
|
72 |
+
# Upgrade and Install is the same both
|
73 |
+
# required checking the packages inside
|
74 |
+
# Package-Extension is a only a wrapper for packages inside!
|
75 |
+
if ($extensionState->getState() != CJT_Framework_Extensions_Package_State_Extension::INSTALLED) {
|
76 |
+
# Initialize
|
77 |
+
$packageFileModel = CJTModel::getInstance('package-file');
|
78 |
+
$packageModel = CJTModel::getInstance('package');
|
79 |
+
$extensionDir = ABSPATH . PLUGINDIR . DIRECTORY_SEPARATOR . $extension['dir'];
|
80 |
+
$packagesFolderPath = $extensionDir . DIRECTORY_SEPARATOR . ((string) $extensionDeDoc->packages->attributes()->folder);
|
81 |
+
# Getting packages state
|
82 |
+
$extensionPackagesState = new CJT_Framework_Extensions_Package_State_Packages($extensionDeDoc);
|
83 |
+
# Check packages
|
84 |
+
foreach ($extensionPackagesState as $pckName => $package) {
|
85 |
+
# Get state
|
86 |
+
$pckState = $extensionPackagesState->getState();
|
87 |
+
# If not yet installed or requied upgrade
|
88 |
+
if ($pckState != CJT_Framework_Extensions_Package_State_Packages::INSTALLED) {
|
89 |
+
# Take action based on package installation state
|
90 |
+
switch ($pckState) {
|
91 |
+
case CJT_Framework_Extensions_Package_State_Packages::UPGRADE;
|
92 |
+
# Delete package
|
93 |
+
$packageModel->delete($package['id']);
|
94 |
+
break;
|
95 |
+
}
|
96 |
+
# Get package file info.
|
97 |
+
$packageFile = $packagesFolderPath . DIRECTORY_SEPARATOR . $package['file'];
|
98 |
+
# Add/Create Package
|
99 |
+
$packageCJTToken = $packageFileModel->parse(uniqid(), $packageFile);
|
100 |
+
$packageId = $packageFileModel->install($packageCJTToken);
|
101 |
+
# Mark as installed/created/added
|
102 |
+
$extensionPackagesState->packageInstalled($packageId);
|
103 |
+
}
|
104 |
+
# Remove from queue
|
105 |
+
$extensionPackagesState->removeOld();
|
106 |
+
}
|
107 |
+
# Packages to delete!
|
108 |
+
foreach ($extensionPackagesState->getDeletedPackages() as $name => $deletedPack) {
|
109 |
+
# Delete package
|
110 |
+
$packageModel->delete($deletedPack['id']);
|
111 |
+
}
|
112 |
+
# Upgrade packages state
|
113 |
+
$extensionPackagesState->upgrade();
|
114 |
+
# Upgrade extension state
|
115 |
+
$extensionState->upgrade($extension['defFile']);
|
116 |
+
# Register uninstaller
|
117 |
+
register_uninstall_hook($extension['pluginFile'], array(__CLASS__, "uninstall_{$extensionClass}"));
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* put your comment there...
|
123 |
+
*
|
124 |
+
*/
|
125 |
+
public function _extensionDeactivated() {
|
126 |
+
# Initialize
|
127 |
+
$extension =& $this->extension;
|
128 |
+
$statePackage = new CJT_Framework_Extensions_Package_State_Packages($extension['defDoc']);
|
129 |
+
$extBlocks = new CJT_Framework_Extensions_Package_Blocks($statePackage);
|
130 |
+
# Enable all Blocks associated with extension packages
|
131 |
+
$extBlocks->setState(CJT_Framework_Extensions_Package_Blocks::INACTIVE);
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* put your comment there...
|
136 |
+
*
|
137 |
+
*/
|
138 |
+
public function getInvolved() {
|
139 |
+
# Check installation state
|
140 |
+
if (CJTPlugin::getInstance()->isInstalled()) {
|
141 |
+
# INitialize
|
142 |
+
$extensionClass = $this->extensionClass;
|
143 |
+
$extension =& $this->extension;
|
144 |
+
$extensionFile = ABSPATH . PLUGINDIR . DIRECTORY_SEPARATOR . $extension['dir'] . DIRECTORY_SEPARATOR . $extension['file'];
|
145 |
+
# Load/install extensions packages hook
|
146 |
+
add_action('init', array($this, '_checkInstallationState'));
|
147 |
+
# Deactivation hooks
|
148 |
+
register_deactivation_hook($extensionFile, array($this, '_extensionDeactivated'));
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* put your comment there...
|
154 |
+
*
|
155 |
+
* @param mixed $class
|
156 |
+
*/
|
157 |
+
public static function getPluginExtensionClass($object) {
|
158 |
+
return str_replace('_Plugin', '', get_class($object));
|
159 |
+
}
|
160 |
+
|
161 |
+
} # End class
|
162 |
+
|
163 |
+
// Hiookable!
|
164 |
+
CJT_Framework_Extensions_Package_Extension::define('CJT_Framework_Extensions_Package_Extension', array('hookType' => CJTWordpressEvents::HOOK_FILTER));
|
framework/extensions/package/state/extension.php
ADDED
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
*/
|
5 |
+
|
6 |
+
/**
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
class CJT_Framework_Extensions_Package_State_Extension {
|
10 |
+
|
11 |
+
/**
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
const INSTALLED = 3;
|
15 |
+
|
16 |
+
/**
|
17 |
+
*
|
18 |
+
*/
|
19 |
+
const NOT_INSTALLED = 1;
|
20 |
+
|
21 |
+
/**
|
22 |
+
*
|
23 |
+
*/
|
24 |
+
const UPGRADE = 2;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* put your comment there...
|
28 |
+
*
|
29 |
+
* @var mixed
|
30 |
+
*/
|
31 |
+
protected $data;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* put your comment there...
|
35 |
+
*
|
36 |
+
* @var mixed
|
37 |
+
*/
|
38 |
+
protected $dbOptionName;
|
39 |
+
|
40 |
+
/**
|
41 |
+
* put your comment there...
|
42 |
+
*
|
43 |
+
* @var mixed
|
44 |
+
*/
|
45 |
+
protected $extDefDoc;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* put your comment there...
|
49 |
+
*
|
50 |
+
* @var mixed
|
51 |
+
*/
|
52 |
+
protected $name;
|
53 |
+
|
54 |
+
/**
|
55 |
+
* put your comment there...
|
56 |
+
*
|
57 |
+
* @var mixed
|
58 |
+
*/
|
59 |
+
protected $newVersion;
|
60 |
+
|
61 |
+
/**
|
62 |
+
* put your comment there...
|
63 |
+
*
|
64 |
+
* @var mixed
|
65 |
+
*/
|
66 |
+
protected $state;
|
67 |
+
|
68 |
+
/**
|
69 |
+
* put your comment there...
|
70 |
+
*
|
71 |
+
* @param mixed $name
|
72 |
+
* @return CJT_Framework_Extensions_Package_InfoStructure
|
73 |
+
*/
|
74 |
+
public function __construct(SimpleXMLElement & $extDeDoc) {
|
75 |
+
# Initialize
|
76 |
+
$this->extDefDoc =& $extDeDoc;
|
77 |
+
$this->name = (string) $extDeDoc->attributes()->class;
|
78 |
+
$this->newVersion = (string) $extDeDoc->packages->attributes()->version;
|
79 |
+
# Getting DB Option name
|
80 |
+
$this->dbOptionName = self::getDbOptionName($this->name);
|
81 |
+
# Read from database
|
82 |
+
$this->data = get_option($this->dbOptionName, array());
|
83 |
+
# Cache state
|
84 |
+
$this->getState();
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* put your comment there...
|
89 |
+
*
|
90 |
+
* @param mixed $extensionClass
|
91 |
+
*/
|
92 |
+
public static function create($extensionClass) {
|
93 |
+
# Option name
|
94 |
+
$dbOptionName = self::getDbOptionName($extensionClass);
|
95 |
+
# Reading cached state
|
96 |
+
$state = get_option($dbOptionName);
|
97 |
+
# Getting extension defFile
|
98 |
+
$defFile = ABSPATH . PLUGINDIR . DIRECTORY_SEPARATOR . $state['defFile'];
|
99 |
+
$deDoc = new SimpleXMLElement(file_get_contents($defFile));
|
100 |
+
# Returns new instance
|
101 |
+
return new CJT_Framework_Extensions_Package_State_Extension($deDoc);
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* put your comment there...
|
106 |
+
*
|
107 |
+
*/
|
108 |
+
public function clearInstallInfo() {
|
109 |
+
return delete_option($this->dbOptionName);
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* put your comment there...
|
114 |
+
*
|
115 |
+
* @param mixed $name
|
116 |
+
*/
|
117 |
+
protected function getDBVar($name) {
|
118 |
+
return isset($this->data[$name]) ? $this->data[$name] : null;
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* put your comment there...
|
123 |
+
*
|
124 |
+
* @param mixed $extensionClass
|
125 |
+
*/
|
126 |
+
protected static function getDbOptionName($extensionClass) {
|
127 |
+
return "{$extensionClass}.state";
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* put your comment there...
|
132 |
+
*
|
133 |
+
*/
|
134 |
+
public function & getExtensionDeDoc() {
|
135 |
+
return $this->extDefDoc;
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* put your comment there...
|
140 |
+
*
|
141 |
+
*/
|
142 |
+
protected function getInstalledVersion() {
|
143 |
+
return $this->getDBVar('version');
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* put your comment there...
|
148 |
+
*
|
149 |
+
*/
|
150 |
+
public function getState() {
|
151 |
+
# Initialize
|
152 |
+
$deDoc =& $this->getExtensionDeDoc();
|
153 |
+
$installedVersion = $this->getInstalledVersion();
|
154 |
+
$newVersion = $this->newVersion;
|
155 |
+
# Check extension installation state
|
156 |
+
if (!$installedVersion) {
|
157 |
+
$this->state = self::NOT_INSTALLED;
|
158 |
+
}
|
159 |
+
elseif ($installedVersion != $newVersion) {
|
160 |
+
$this->state = self::UPGRADE;
|
161 |
+
}
|
162 |
+
else {
|
163 |
+
$this->state = self::INSTALLED;
|
164 |
+
}
|
165 |
+
# Retrun state
|
166 |
+
return $this->state;
|
167 |
+
}
|
168 |
+
|
169 |
+
public static function isInstalled($extensionClass) {
|
170 |
+
# Getting DB Option name
|
171 |
+
$dbOptionName = self::getDbOptionName($extensionClass);
|
172 |
+
# Get data
|
173 |
+
$state = get_option($dbOptionName, array());
|
174 |
+
# Returns
|
175 |
+
return !empty($state);
|
176 |
+
}
|
177 |
+
/**
|
178 |
+
* put your comment there...
|
179 |
+
*
|
180 |
+
* @param mixed $pluginFile
|
181 |
+
* @return bool
|
182 |
+
*/
|
183 |
+
public function upgrade($defFile) {
|
184 |
+
# Set version
|
185 |
+
$this->data['version'] = $this->newVersion;
|
186 |
+
# Hold path to XML file to be used when uninstalling extension data
|
187 |
+
$this->data['defFile'] = $defFile;
|
188 |
+
# Save
|
189 |
+
return update_option($this->dbOptionName, $this->data);
|
190 |
+
}
|
191 |
+
|
192 |
+
} # End class
|
framework/extensions/package/state/packages.php
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
*/
|
5 |
+
|
6 |
+
/**
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
class CJT_Framework_Extensions_Package_State_Packages extends ArrayIterator {
|
10 |
+
|
11 |
+
/**
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
const INSTALLED = 1;
|
15 |
+
|
16 |
+
/**
|
17 |
+
*
|
18 |
+
*/
|
19 |
+
const NOT_INSTALLED = 2;
|
20 |
+
|
21 |
+
/**
|
22 |
+
*
|
23 |
+
*/
|
24 |
+
const UPGRADE = 3;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* put your comment there...
|
28 |
+
*
|
29 |
+
* @var mixed
|
30 |
+
*/
|
31 |
+
protected $extDeDoc;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* put your comment there...
|
35 |
+
*
|
36 |
+
* @var SimpleXMLElement
|
37 |
+
*/
|
38 |
+
protected $dbOptionName;
|
39 |
+
|
40 |
+
/**
|
41 |
+
* put your comment there...
|
42 |
+
*
|
43 |
+
* @var mixed
|
44 |
+
*/
|
45 |
+
protected $deDocPackages;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* put your comment there...
|
49 |
+
*
|
50 |
+
* @var mixed
|
51 |
+
*/
|
52 |
+
protected $installedPackages;
|
53 |
+
|
54 |
+
/**
|
55 |
+
* put your comment there...
|
56 |
+
*
|
57 |
+
* @var mixed
|
58 |
+
*/
|
59 |
+
protected $oldPackagesQueue;
|
60 |
+
|
61 |
+
/**
|
62 |
+
* put your comment there...
|
63 |
+
*
|
64 |
+
* @param SimpleXMLElement $exDeDoc
|
65 |
+
* @return {CJT_Framework_Extensions_Package_State_Packages|SimpleXMLElement}
|
66 |
+
*/
|
67 |
+
public function __construct(SimpleXMLElement & $extDeDoc) {
|
68 |
+
# Initialize
|
69 |
+
$extensionName = (string) $extDeDoc->attributes()->class;
|
70 |
+
$this->dbOptionName = "{$extensionName}.state.packages";
|
71 |
+
$this->extDeDoc =& $extDeDoc;
|
72 |
+
# Reading Database packages
|
73 |
+
$this->installedPackages = get_option($this->dbOptionName, array());
|
74 |
+
# Caching DeDoc packages
|
75 |
+
foreach ($extDeDoc->packages->package as $package) {
|
76 |
+
# Package data
|
77 |
+
$pckData = $package->attributes();
|
78 |
+
# Cache package data
|
79 |
+
$this->deDocPackages[(string) $pckData->name] = array(
|
80 |
+
'version' => ((string) $pckData->version),
|
81 |
+
'file' => ((string) $pckData->file)
|
82 |
+
);
|
83 |
+
}
|
84 |
+
# Support dedoc iteration side
|
85 |
+
parent::__construct($this->deDocPackages);
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* put your comment there...
|
90 |
+
*
|
91 |
+
*/
|
92 |
+
public function clearInstallInfo() {
|
93 |
+
return delete_option($this->dbOptionName);
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* put your comment there...
|
98 |
+
*
|
99 |
+
*/
|
100 |
+
public function & getDeletedPackages() {
|
101 |
+
return $this->oldPackagesQueue;
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* put your comment there...
|
106 |
+
*
|
107 |
+
*/
|
108 |
+
public function getInstalledPackages() {
|
109 |
+
return $this->installedPackages;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* put your comment there...
|
114 |
+
*
|
115 |
+
*/
|
116 |
+
public function getState() {
|
117 |
+
# INitialize
|
118 |
+
$state = null;
|
119 |
+
$currentPckKey = $this->key();
|
120 |
+
$newPck = $this->current();
|
121 |
+
$oldPck = isset($this->oldPackagesQueue[$currentPckKey]) ? $this->oldPackagesQueue[$currentPckKey] : array('version' => null);
|
122 |
+
$package = $this->current();
|
123 |
+
$oldVersion = $oldPck['version'];
|
124 |
+
$newVersion = $package['version'];
|
125 |
+
# Compare packages state
|
126 |
+
if (!$oldVersion) {
|
127 |
+
# Not installed
|
128 |
+
$state = self::NOT_INSTALLED;
|
129 |
+
}
|
130 |
+
else if ($oldVersion != $newVersion) {
|
131 |
+
# Upgrading package
|
132 |
+
$state = self::UPGRADE;
|
133 |
+
}
|
134 |
+
else {
|
135 |
+
# Already installed, same version, no changes
|
136 |
+
$state = self::INSTALLED;
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* put your comment there...
|
142 |
+
*
|
143 |
+
* @param mixed $id
|
144 |
+
*/
|
145 |
+
public function packageInstalled($id) {
|
146 |
+
# Get current package
|
147 |
+
$package =& $this->deDocPackages[$this->key()];
|
148 |
+
# Hold package id for installed package
|
149 |
+
$package['id'] = $id;
|
150 |
+
# Chain
|
151 |
+
return $this;
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* put your comment there...
|
156 |
+
*
|
157 |
+
*/
|
158 |
+
public function removeOld() {
|
159 |
+
# INitialize
|
160 |
+
$currentKey = $this->key();
|
161 |
+
# Remove from installed packages working queue
|
162 |
+
unset($this->oldPackagesQueue[$currentKey]);
|
163 |
+
# Chain
|
164 |
+
return $this;
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* put your comment there...
|
169 |
+
*
|
170 |
+
*/
|
171 |
+
public function rewind() {
|
172 |
+
# Reset
|
173 |
+
$this->oldPackagesQueue = $this->installedPackages;
|
174 |
+
# ArrayIterator
|
175 |
+
return parent::rewind();
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* put your comment there...
|
180 |
+
*
|
181 |
+
*/
|
182 |
+
public function upgrade() {
|
183 |
+
# Save new deDoc packages into database, drop previous state
|
184 |
+
return update_option($this->dbOptionName, $this->deDocPackages);
|
185 |
+
}
|
186 |
+
|
187 |
+
} # End class
|
framework/version/version.php
CHANGED
@@ -31,7 +31,7 @@ class CJT_Framework_Version_Version {
|
|
31 |
*
|
32 |
*/
|
33 |
public function getMajor() {
|
34 |
-
return $this->version[0];
|
35 |
}
|
36 |
|
37 |
} // End class.
|
31 |
*
|
32 |
*/
|
33 |
public function getMajor() {
|
34 |
+
return (int) $this->version[0];
|
35 |
}
|
36 |
|
37 |
} // End class.
|
models/package-file.php
CHANGED
@@ -181,9 +181,9 @@ class CJTPackageFileModel extends CJTHookableClass {
|
|
181 |
}
|
182 |
}
|
183 |
// Add package to database!
|
184 |
-
$modelPackage->save($packageInfo, $addedObjects);
|
185 |
-
//
|
186 |
-
return $
|
187 |
}
|
188 |
|
189 |
/**
|
181 |
}
|
182 |
}
|
183 |
// Add package to database!
|
184 |
+
$packageId = $modelPackage->save($packageInfo, $addedObjects);
|
185 |
+
// Return package Id
|
186 |
+
return $packageId;
|
187 |
}
|
188 |
|
189 |
/**
|
models/package.php
CHANGED
@@ -130,6 +130,7 @@ class CJTPackageModel extends CJTHookableClass {
|
|
130 |
->save();
|
131 |
}
|
132 |
}
|
|
|
133 |
}
|
134 |
|
135 |
/**
|
130 |
->save();
|
131 |
}
|
132 |
}
|
133 |
+
return $tablePackage->get('id');
|
134 |
}
|
135 |
|
136 |
/**
|
readme.txt
CHANGED
@@ -6,14 +6,17 @@ Tags: post, posts, admin, sidebar, page, pages, image, plug, plugin, customise,
|
|
6 |
License: GPLv2 or later
|
7 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
8 |
Requires at least: 3.9
|
9 |
-
Tested up to: 3.9.
|
10 |
-
Stable tag: 7.
|
11 |
|
12 |
Easily add custom CSS, JavaScript, HTML and PHP code to unique CJT code blocks and assign them wherever you want.
|
13 |
|
14 |
== Description ==
|
15 |
CSS & JavaScript Toolbox is a powerful code management plugin that gives you the tools to easily and safely modify or extend the functionality and appearance of your WordPress-powered website. You do this by adding custom code directly into unique code blocks and assign them to pages, posts, custom posts, categories, URLs, expressions, and loads more!
|
16 |
|
|
|
|
|
|
|
17 |
= Like CJT Free – Upgrade to CJT Pro/Dev =
|
18 |
If you like CJT Free, we hope you can support the continued development by upgrading to CJT Pro or CJT Dev.
|
19 |
Click to learn about the [benefits of upgrading to CJT Pro/Dev](http://css-javascript-toolbox.com/pricing).
|
@@ -127,6 +130,11 @@ Due to the overwhelming amount of emails we get for users requesting support for
|
|
127 |
27. Block Info Dialog
|
128 |
|
129 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
130 |
= 7.1.2 =
|
131 |
* Enhance: Show Latest News on Dashboard Widget
|
132 |
|
6 |
License: GPLv2 or later
|
7 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
8 |
Requires at least: 3.9
|
9 |
+
Tested up to: 3.9.2
|
10 |
+
Stable tag: 7.2
|
11 |
|
12 |
Easily add custom CSS, JavaScript, HTML and PHP code to unique CJT code blocks and assign them wherever you want.
|
13 |
|
14 |
== Description ==
|
15 |
CSS & JavaScript Toolbox is a powerful code management plugin that gives you the tools to easily and safely modify or extend the functionality and appearance of your WordPress-powered website. You do this by adding custom code directly into unique code blocks and assign them to pages, posts, custom posts, categories, URLs, expressions, and loads more!
|
16 |
|
17 |
+
= CJT Comes with Unlimited number of Extensions =
|
18 |
+
CJT is providing a cool extensions that can be used through CJT Shortcode Form. Both [FREE CJT Extensions](https://wordpress.org/plugins/search.php?q=cjte) and [Premium CJT Extensions](http://css-javascript-toolbox.com/script-extensions/) are available for downloads.
|
19 |
+
|
20 |
= Like CJT Free – Upgrade to CJT Pro/Dev =
|
21 |
If you like CJT Free, we hope you can support the continued development by upgrading to CJT Pro or CJT Dev.
|
22 |
Click to learn about the [benefits of upgrading to CJT Pro/Dev](http://css-javascript-toolbox.com/pricing).
|
130 |
27. Block Info Dialog
|
131 |
|
132 |
== Changelog ==
|
133 |
+
= 7.2 =
|
134 |
+
* Fix: Block Code file name moving away when open/close Block metabox
|
135 |
+
* Fix: Shortcode list is too small for Shortcode names
|
136 |
+
* Enhance: CJT Framework for packages and extensions updates
|
137 |
+
|
138 |
= 7.1.2 =
|
139 |
* Enhance: Show Latest News on Dashboard Widget
|
140 |
|
views/blocks/block/public/css/block.css
CHANGED
@@ -200,15 +200,13 @@
|
|
200 |
}
|
201 |
.hndle .file {
|
202 |
font-size: 15px;
|
203 |
-
|
204 |
-
top: 8px;
|
205 |
-
margin-left: 18px;
|
206 |
cursor: pointer;
|
207 |
}
|
208 |
.hndle .name-file-separator {
|
209 |
-
font-size:
|
210 |
-
position:
|
211 |
-
top:
|
212 |
margin-left: 5px;
|
213 |
cursor: pointer;
|
214 |
}
|
200 |
}
|
201 |
.hndle .file {
|
202 |
font-size: 15px;
|
203 |
+
margin-left: 7px;
|
|
|
|
|
204 |
cursor: pointer;
|
205 |
}
|
206 |
.hndle .name-file-separator {
|
207 |
+
font-size: 14px;
|
208 |
+
position: relative;
|
209 |
+
top: -1px;
|
210 |
margin-left: 5px;
|
211 |
cursor: pointer;
|
212 |
}
|
views/blocks/block/public/js/codefile/codefile.js
CHANGED
@@ -133,7 +133,7 @@
|
|
133 |
// File name and files list.
|
134 |
this.currentFileName = $('<a>').addClass('file').text(this.file.name)
|
135 |
.insertAfter(block.elements.blockName)
|
136 |
-
.before($('<span class="name-file-separator"
|
137 |
.click($.proxy(_onclickfilename, this));
|
138 |
};
|
139 |
|
133 |
// File name and files list.
|
134 |
this.currentFileName = $('<a>').addClass('file').text(this.file.name)
|
135 |
.insertAfter(block.elements.blockName)
|
136 |
+
.before($('<span class="name-file-separator">|</span>'))
|
137 |
.click($.proxy(_onclickfilename, this));
|
138 |
};
|
139 |
|
views/tinymce/shortcodes/public/plugins/shortcode/shortcode.js
CHANGED
@@ -58,7 +58,7 @@ if (CJT === undefined) {
|
|
58 |
type : 'menubutton',
|
59 |
title : CJTBlockShortcode.title,
|
60 |
icon : 'cjt-blocks-list-tinymce-button',
|
61 |
-
menu : {style : 'overflow:true;max-height:356px'},
|
62 |
onCreateMenu : function() {
|
63 |
// Get Menu Object created by tinyMCE behind the sense.
|
64 |
var menu = editor.controlManager.buttons.CJTBlockShortcode.menu;
|
58 |
type : 'menubutton',
|
59 |
title : CJTBlockShortcode.title,
|
60 |
icon : 'cjt-blocks-list-tinymce-button',
|
61 |
+
menu : {style : 'overflow:true;max-height:356px;width:280px'},
|
62 |
onCreateMenu : function() {
|
63 |
// Get Menu Object created by tinyMCE behind the sense.
|
64 |
var menu = editor.controlManager.buttons.CJTBlockShortcode.menu;
|