| @@ -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... |
| @@ -77,9 +72,9 @@ | ||
| 77 | 72 | $request['edd_action'] = "{$action}_license"; |
| 78 | 73 | $request['item_name'] = urlencode($component['name']); |
| 79 | 74 | $request['license'] = $license['key']; |
| 80 | 75 | /* CJT Extra Fields For EDD */ |
| 81 | - $request['CJTEFFEDD_licenseName'] = $license['name']; | |
| 76 | + //$request['CJTEFFEDD_licenseName'] = $license['name']; | |
| 82 | 77 | // Request the server! |
| 83 | 78 | $response = wp_remote_get(add_query_arg($request, cssJSToolbox::getCJTWebSiteURL())); |
| 84 | 79 | // We need only the JSON object returned by EDD APIs. |
| 85 | 80 | $response = @json_decode(wp_remote_retrieve_body($response), true); |
| @@ -96,10 +91,10 @@ | ||
| 96 | 91 | */ |
| 97 | 92 | public function getCJTComponentData() { |
| 98 | 93 | $component = array(); |
| 99 | 94 | // Set info! |
| 100 | - $component['name'] = self::EDD_PRODUCT_NAME; | |
| 101 | 95 | $component['pluginBase'] = CJTOOLBOX_PLUGIN_BASE; |
| 96 | + $component['title'] = 'CSS & Javascript Toolbox'; | |
| 102 | 97 | return $component; |
| 103 | 98 | } |
| 104 | 99 | |
| 105 | 100 | /** |
| @@ -104,9 +99,43 @@ | ||
| 104 | 99 | |
| 105 | 100 | /** |
| 106 | 101 | * put your comment there... |
| 107 | 102 | * |
| 103 | + * @param mixed $component | |
| 108 | 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 | + */ | |
| 109 | 138 | public function & getLicenses() { |
| 110 | 139 | return $this->licenses; |
| 111 | 140 | } |
| 112 | 141 | |
| @@ -132,18 +161,35 @@ | ||
| 132 | 161 | |
| 133 | 162 | /** |
| 134 | 163 | * put your comment there... |
| 135 | 164 | * |
| 165 | + * @param mixed $licenseTypes | |
| 136 | 166 | * @param mixed $compoment |
| 137 | - * @param mixed $field | |
| 167 | + * @param mixed $struct | |
| 138 | 168 | */ |
| 139 | - public function getStateStruct($compoment, $struct = null) { | |
| 169 | + public function getStateStruct($licenseTypes, $struct = null) { | |
| 170 | + // INit | |
| 171 | + $state = null; | |
| 140 | 172 | // Read all licenses from db! |
| 141 | 173 | $licensesCache =& $this->getLicenses(); |
| 142 | - // If not set return clean empty array! | |
| 143 | - $componentName = $compoment['name']; | |
| 144 | - $state = isset($licensesCache[$componentName]) ? $licensesCache[$componentName] : false; | |
| 145 | - 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; | |
| 146 | 192 | } |
| 147 | 193 | |
| 148 | 194 | /** |
| 149 | 195 | * put your comment there... |