| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | -* | |
| 3 | +* | |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | // Disallow direct access. |
| 7 | 7 | defined('ABSPATH') or die("Access denied"); |
| @@ -6,27 +6,27 @@ | ||
| 6 | 6 | // Disallow direct access. |
| 7 | 7 | defined('ABSPATH') or die("Access denied"); |
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | -* | |
| 10 | +* | |
| 11 | 11 | */ |
| 12 | 12 | class CJTSetupModel { |
| 13 | - | |
| 13 | + | |
| 14 | 14 | /** |
| 15 | - * | |
| 15 | + * | |
| 16 | 16 | */ |
| 17 | 17 | const LICENSES_CACHE = 'cache.CJTSetupModel.licenses'; |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * put your comment there... |
| 21 | - * | |
| 21 | + * | |
| 22 | 22 | * @var mixed |
| 23 | 23 | */ |
| 24 | 24 | protected $licenses; |
| 25 | - | |
| 25 | + | |
| 26 | 26 | /** |
| 27 | 27 | * put your comment there... |
| 28 | - * | |
| 28 | + * | |
| 29 | 29 | */ |
| 30 | 30 | public function __construct() { |
| 31 | 31 | // Read all cached licenses! |
| 32 | 32 | $this->licenses = get_option(self::LICENSES_CACHE); |
| @@ -34,12 +34,12 @@ | ||
| 34 | 34 | if (!is_array($this->licenses)) { |
| 35 | 35 | $this->licenses = array(); |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | - | |
| 38 | + | |
| 39 | 39 | /** |
| 40 | 40 | * put your comment there... |
| 41 | - * | |
| 41 | + * | |
| 42 | 42 | * @param mixed $component |
| 43 | 43 | * @param mixed $action |
| 44 | 44 | * @param mixed $state |
| 45 | 45 | * @param mixed $pluginBase |
| @@ -49,9 +49,9 @@ | ||
| 49 | 49 | $cache =& $this->getLicenses(); |
| 50 | 50 | // Add action to the state object! |
| 51 | 51 | $state['action'] = $action; |
| 52 | 52 | // Cache Plugin data! |
| 53 | - $state['plugin'] = get_plugin_data(WP_PLUGIN_DIR . "/{$component['pluginBase']}", false); | |
| 53 | + $state['plugin'] = get_plugin_data(ABSPATH . PLUGINDIR . "/{$component['pluginBase']}", false); | |
| 54 | 54 | // Cache object! |
| 55 | 55 | $cache[$component['name']] = $state; |
| 56 | 56 | update_option(self::LICENSES_CACHE, $cache); |
| 57 | 57 | // update local Cache! |
| @@ -56,14 +56,14 @@ | ||
| 56 | 56 | update_option(self::LICENSES_CACHE, $cache); |
| 57 | 57 | // update local Cache! |
| 58 | 58 | $this->licenses = $cache; |
| 59 | 59 | // return action name |
| 60 | - return $action; | |
| 60 | + return $action; | |
| 61 | 61 | } |
| 62 | - | |
| 62 | + | |
| 63 | 63 | /** |
| 64 | 64 | * put your comment there... |
| 65 | - * | |
| 65 | + * | |
| 66 | 66 | * @param mixed $action |
| 67 | 67 | * @param mixed $component |
| 68 | 68 | * @param mixed $license |
| 69 | 69 | */ |
| @@ -87,44 +87,44 @@ | ||
| 87 | 87 | $response['license'] = 'invalid'; |
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | catch ( CJTServicesAPICallException $exception ) { |
| 91 | - // If request error compaitble the response object to be used! | |
| 91 | + // If request error compaitble the response object to be used! | |
| 92 | 92 | $response = array('license' => 'error', 'component' => $component['name']); |
| 93 | 93 | } |
| 94 | 94 | return $response; |
| 95 | 95 | } |
| 96 | - | |
| 96 | + | |
| 97 | 97 | /** |
| 98 | 98 | * put your comment there... |
| 99 | - * | |
| 99 | + * | |
| 100 | 100 | */ |
| 101 | 101 | public function getCJTComponentData() { |
| 102 | 102 | $component = array(); |
| 103 | 103 | // Set info! |
| 104 | 104 | $component['pluginBase'] = CJTOOLBOX_PLUGIN_BASE; |
| 105 | - $component['title'] = 'CSS & JavaScript Toolbox'; | |
| 105 | + $component['title'] = 'CSS & Javascript Toolbox'; | |
| 106 | 106 | return $component; |
| 107 | 107 | } |
| 108 | - | |
| 108 | + | |
| 109 | 109 | /** |
| 110 | 110 | * put your comment there... |
| 111 | - * | |
| 111 | + * | |
| 112 | 112 | * @param mixed $component |
| 113 | 113 | */ |
| 114 | 114 | public function getExtensionProductTypes($component) { |
| 115 | - # Initialize | |
| 115 | + # Initialize | |
| 116 | 116 | $types = array(); |
| 117 | 117 | # Extension plugin file |
| 118 | 118 | $pluginDirName = dirname($component['pluginBase']); |
| 119 | - $pluginXMLFile = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . | |
| 120 | - $pluginDirName . DIRECTORY_SEPARATOR . | |
| 119 | + $pluginXMLFile = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . | |
| 120 | + $pluginDirName . DIRECTORY_SEPARATOR . | |
| 121 | 121 | $pluginDirName . '.xml'; |
| 122 | 122 | # Use XML |
| 123 | 123 | $exDef = new SimpleXMLElement(file_get_contents($pluginXMLFile)); |
| 124 | 124 | # Register XPath namespace |
| 125 | 125 | $license = $exDef->license; |
| 126 | - $license->registerXPathNamespace('ext', 'https://css-javascript-toolbox.com/extensions/xmldeffile'); | |
| 126 | + $license->registerXPathNamespace('ext', 'http://css-javascript-toolbox.com/extensions/xmldeffile'); | |
| 127 | 127 | # Get types |
| 128 | 128 | $typesSrc = $exDef->license->xpath('name'); |
| 129 | 129 | foreach ($typesSrc as $type) { |
| 130 | 130 | # Product name |
| @@ -141,18 +141,18 @@ | ||
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
| 144 | 144 | * put your comment there... |
| 145 | - * | |
| 145 | + * | |
| 146 | 146 | */ |
| 147 | 147 | public function & getLicenses() { |
| 148 | 148 | return $this->licenses; |
| 149 | 149 | } |
| 150 | - | |
| 150 | + | |
| 151 | 151 | /** |
| 152 | - * Get list of all cached licenses that has | |
| 152 | + * Get list of all cached licenses that has | |
| 153 | 153 | * a license key in $state state! |
| 154 | - * | |
| 154 | + * | |
| 155 | 155 | * @param mixed $state |
| 156 | 156 | */ |
| 157 | 157 | public function getStatedLicenses($state = 'activate') { |
| 158 | 158 | // Initializing! |
| @@ -166,22 +166,22 @@ | ||
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | return $statedList; |
| 169 | 169 | } |
| 170 | - | |
| 170 | + | |
| 171 | 171 | /** |
| 172 | 172 | * put your comment there... |
| 173 | - * | |
| 173 | + * | |
| 174 | 174 | * @param mixed $licenseTypes |
| 175 | 175 | * @param mixed $compoment |
| 176 | 176 | * @param mixed $struct |
| 177 | 177 | */ |
| 178 | 178 | public function getStateStruct($licenseTypes, $struct = null) { |
| 179 | - // INit | |
| 179 | + // INit | |
| 180 | 180 | $state = null; |
| 181 | 181 | // Read all licenses from db! |
| 182 | 182 | $licensesCache =& $this->getLicenses(); |
| 183 | - // Find license | |
| 183 | + // Find license | |
| 184 | 184 | foreach ($licenseTypes as $type) { |
| 185 | 185 | # Get product name to search |
| 186 | 186 | $productName = $type['name']; |
| 187 | 187 | if (isset($licensesCache[$productName])) { |
| @@ -198,12 +198,12 @@ | ||
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | return $state; |
| 201 | 201 | } |
| 202 | - | |
| 202 | + | |
| 203 | 203 | /** |
| 204 | 204 | * put your comment there... |
| 205 | - * | |
| 205 | + * | |
| 206 | 206 | * @param mixed $state |
| 207 | 207 | */ |
| 208 | 208 | public function removeCachedLicense($state) { |
| 209 | 209 | // Initializing! |
| @@ -211,9 +211,9 @@ | ||
| 211 | 211 | // Read all cached licenses! |
| 212 | 212 | $cachedStates =& $this->getLicenses(); |
| 213 | 213 | // Set return value! |
| 214 | 214 | $result = isset($cachedStates[$componentName]) ? 'valid' : 'invalid'; |
| 215 | - // Remove component license even if its not exists, nothing will happen! | |
| 215 | + // Remove component license even if its not exists, nothing will happen! | |
| 216 | 216 | unset($cachedStates[$componentName]); |
| 217 | 217 | // Update cache list! |
| 218 | 218 | update_option(self::LICENSES_CACHE, $cachedStates); |
| 219 | 219 | // Update local cache! |
| @@ -219,6 +219,6 @@ | ||
| 219 | 219 | // Update local cache! |
| 220 | 220 | $this->licenses = $cachedStates; |
| 221 | 221 | return $result; |
| 222 | 222 | } |
| 223 | - | |
| 223 | + | |
| 224 | 224 | } // End class. |