PluginProbe
CSS & JavaScript Toolbox / 6.1.1
CSS & JavaScript Toolbox v6.1.1
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 / controllers / setup.php

setup.php in CSS & JavaScript Toolbox 6.1.1, at controllers/setup.php

109 lines 3.2 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 // import dependencies.
10 cssJSToolbox::import('framework:mvc:controller-ajax.inc.php');
11
12 /**
13 *
14 */
15 class CJTsetupController extends CJTAjaxController {
16
17 /**
18 * put your comment there...
19 *
20 * @var mixed
21 */
22 protected $controllerInfo = array('model' => 'setup');
23
24 /**
25 * put your comment there...
26 *
27 */
28 public function __construct() {
29 parent::__construct();
30 // Register actions!
31 $this->registryAction('activationFormView');
32 $this->registryAction('getState');
33 $this->registryAction('license');
34 $this->registryAction('reset');
35 }
36
37 /**
38 * Display Activation form!
39 *
40 */
41 protected function activationFormViewAction() {
42 // Display activation for for the requested component!
43 parent::displayAction();
44 }
45
46 /**
47 * put your comment there...
48 *
49 */
50 protected function getStateAction() {
51 $this->response = $this->model->getStateStruct($_REQUEST['component']);
52 }
53
54 /**
55 * put your comment there...
56 *
57 */
58 protected function licenseAction() {
59 // Read request parameters!
60 $action = $_REQUEST['eddAction'];
61 $state['component'] = $_REQUEST['component'];
62 $state['license'] = $_REQUEST['license'];
63 // Initializing!
64 $model =& $this->model;
65 // Request EDD through EDD SL APIs!
66 $state['response'] = $model->dispatchEddCall($action, $state['component'], $state['license']);
67 // Standarize response object! As check and activate responde by 'valid' and 'invalid' and deactivate responde
68 // by deactivated and faild we then need to make them all likce check and activate!
69 if (($action == 'deactivate') && ($state['response']['license'] != 'error')) {
70 $map = array('deactivated' => 'valid', 'failed' => 'invalid');
71 $deactivateResponseState = $state['response']['license'];
72 $state['response']['license'] = $map[$deactivateResponseState];
73 }
74 // Cahe only if the request is 'activate' or 'deactivate' and the returned state is valid or 'deactivated! respectively.
75 if (($action != 'check') && ($state['response']['license'] == 'valid')) {
76 // We need to standarize the response object so the access will be always the same
77 // EDD return 'deactivated' and 'valid' with the success request using 'deactivate' and 'activate' repectively!
78 // Use valid instead of deactivate!
79 if ($action == 'deactivate') {
80 $state['response']['license'] = 'valid';
81 }
82 $state['action'] = $model->cacheState($state['component'], $action, $state);
83 }
84 // Return state object includes (component, license, edd response [and action only if valid])
85 $this->response = $state;
86 }
87
88 /**
89 * put your comment there...
90 *
91 */
92 protected function resetAction() {
93 // Initializing!
94 $model =& $this->model;
95 // Read request parameters!
96 $state['component'] = $_REQUEST['component'];
97 $state['license'] = false;
98 // Remove License state cache!
99 $state['response']['license'] = $model->removeCachedLicense($state);
100 // Set response parameters.
101 $state['action'] = 'reset';
102 // With DUMMY EDD response so we're standarizing the response for all actions
103 // even those not belongs to EDD real requests!!
104 $state['response']['item_name'] = $state['component']['name'];
105 $this->response = $state;
106 }
107
108 } // End class.
109