PluginProbe
CSS & JavaScript Toolbox / 8.0
CSS & JavaScript Toolbox v8.0
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
← All changes | models/setup.php +64 -14 6.08.0 View file →
@@ -13,13 +13,8 @@
13 13
14 14 /**
15 15 *
16 16 */
17 - const EDD_PRODUCT_NAME = 'CJT V6';
18 -
19 - /**
20 - *
21 - */
22 17 const LICENSES_CACHE = 'cache.CJTSetupModel.licenses';
23 18
24 19 /**
25 20 * put your comment there...
@@ -34,8 +29,12 @@
34 29 */
35 30 public function __construct() {
36 31 // Read all cached licenses!
37 32 $this->licenses = get_option(self::LICENSES_CACHE);
33 + // Make sure its array!
34 + if (!is_array($this->licenses)) {
35 + $this->licenses = array();
36 + }
38 37 }
39 38
40 39 /**
41 40 * put your comment there...
@@ -73,9 +72,9 @@
73 72 $request['edd_action'] = "{$action}_license";
74 73 $request['item_name'] = urlencode($component['name']);
75 74 $request['license'] = $license['key'];
76 75 /* CJT Extra Fields For EDD */
77 - $request['CJTEFFEDD_licenseName'] = $license['name'];
76 + //$request['CJTEFFEDD_licenseName'] = $license['name'];
78 77 // Request the server!
79 78 $response = wp_remote_get(add_query_arg($request, cssJSToolbox::getCJTWebSiteURL()));
80 79 // We need only the JSON object returned by EDD APIs.
81 80 $response = @json_decode(wp_remote_retrieve_body($response), true);
@@ -92,10 +91,10 @@
92 91 */
93 92 public function getCJTComponentData() {
94 93 $component = array();
95 94 // Set info!
96 - $component['name'] = self::EDD_PRODUCT_NAME;
97 95 $component['pluginBase'] = CJTOOLBOX_PLUGIN_BASE;
96 + $component['title'] = 'CSS & Javascript Toolbox';
98 97 return $component;
99 98 }
100 99
101 100 /**
@@ -100,11 +99,45 @@
100 99
101 100 /**
102 101 * put your comment there...
103 102 *
103 + * @param mixed $component
104 104 */
105 + public function getExtensionProductTypes($component) {
106 + # Initialize
107 + $types = array();
108 + # Extension plugin file
109 + $pluginDirName = dirname($component['pluginBase']);
110 + $pluginXMLFile = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR .
111 + $pluginDirName . DIRECTORY_SEPARATOR .
112 + $pluginDirName . '.xml';
113 + # Use XML
114 + $exDef = new SimpleXMLElement(file_get_contents($pluginXMLFile));
115 + # Register XPath namespace
116 + $license = $exDef->license;
117 + $license->registerXPathNamespace('ext', 'http://css-javascript-toolbox.com/extensions/xmldeffile');
118 + # Get types
119 + $typesSrc = $exDef->license->xpath('name');
120 + foreach ($typesSrc as $type) {
121 + # Product name
122 + $name = (string) $type;
123 + # Old Definiton document doesnt support text attributes.
124 + # If not there use name node value as TEXT
125 + if (!$text = ((string) $type->attributes()->text)) {
126 + $text = $name;
127 + }
128 + # Add to list
129 + $types[$name] = array('name' => $name, 'text' => $text);
130 + }
131 + return $types;
132 + }
133 +
134 + /**
135 + * put your comment there...
136 + *
137 + */
105 138 public function & getLicenses() {
106 - return $this->licenses ? $this->licenses : array();
139 + return $this->licenses;
107 140 }
108 141
109 142 /**
110 143 * Get list of all cached licenses that has
@@ -128,18 +161,35 @@
128 161
129 162 /**
130 163 * put your comment there...
131 164 *
165 + * @param mixed $licenseTypes
132 166 * @param mixed $compoment
133 - * @param mixed $field
167 + * @param mixed $struct
134 168 */
135 - public function getStateStruct($compoment, $struct = null) {
169 + public function getStateStruct($licenseTypes, $struct = null) {
170 + // INit
171 + $state = null;
136 172 // Read all licenses from db!
137 173 $licensesCache =& $this->getLicenses();
138 - // If not set return clean empty array!
139 - $componentName = $compoment['name'];
140 - $state = isset($licensesCache[$componentName]) ? $licensesCache[$componentName] : false;
141 - return ($struct ? ($state[$struct] ? $state[$struct] : false) : $state);
174 + // Find license
175 + foreach ($licenseTypes as $type) {
176 + # Get product name to search
177 + $productName = $type['name'];
178 + if (isset($licensesCache[$productName])) {
179 + # Get product state
180 + $state = $licensesCache[$productName];
181 + # Filter to section
182 + if ($struct) {
183 + $state = $state[$struct];
184 + }
185 + # ALways push product name
186 + $state['productName'] = $productName;
187 + # Exit for
188 + break;
189 + }
190 + }
191 + return $state;
142 192 }
143 193
144 194 /**
145 195 * put your comment there...