PluginProbe
CSS & JavaScript Toolbox / 6.1
CSS & JavaScript Toolbox v6.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
← All changes | controllers/block.php +18 -79 106.1 View file →
@@ -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");
@@ -11,9 +11,9 @@
11 11
12 12 /**
13 13 * This class should replace any other controllers that
14 14 * has methods for interacting with a single Block (e.g block-ajax!)
15 -*
15 +*
16 16 * All single Block actions (e.g edit, new and save) should be placed/moved here
17 17 * in the future!
18 18 */
19 19 class CJTBlockController extends CJTAjaxController {
@@ -19,16 +19,16 @@
19 19 class CJTBlockController extends CJTAjaxController {
20 20
21 21 /**
22 22 * put your comment there...
23 - *
23 + *
24 24 * @var mixed
25 25 */
26 26 protected $controllerInfo = array('model' => 'x-block', 'model_file' => 'xblock');
27 -
27 +
28 28 /**
29 29 * put your comment there...
30 - *
30 + *
31 31 */
32 32 public function __construct() {
33 33 parent::__construct();
34 34 // Actions!
@@ -33,52 +33,13 @@
33 33 parent::__construct();
34 34 // Actions!
35 35 $this->registryAction('getBlockBy');
36 36 $this->registryAction('getAPOP');
37 - $this->registryAction('loadUrl');
38 - $this->registryAction('getCode');
39 - $this->registryAction('downloadCodeFile');
40 37 }
41 -
38 +
42 39 /**
43 - * put your comment there...
44 - *
45 - */
46 - public function downloadCodeFileAction() {
47 - // BlockId, currentActiveFile.
48 - $blockId = sanitize_text_field( $_GET['blockId'] );
49 - $fileId = sanitize_text_field( $_GET['fileId'] );
50 - $returnAs = sanitize_text_field( $_GET['returnAs'] );
51 - // Get current File Code.
52 - $tblCodeFile = new CJTBlockFilesTable(cssJSToolbox::getInstance()->getDBDriver());
53 - $codeFile = $tblCodeFile->set('id', $fileId)
54 - ->set('blockId', $blockId)
55 - ->load()
56 - ->getData();
57 - // Return as downloadable-file or JSON.
58 - if ($returnAs == 'file') {
59 - // Get Download File info.
60 - $extension = $codeFile->type ? cssJSToolbox::$config->templates->types[$codeFile->type]->extension : 'txt';
61 - $file = "{$codeFile->name}.{$extension}";
62 - // Response Header parameters.
63 - header('Content-Description: File Transfer');
64 - header("Content-Disposition: attachment; filename=\"{$file}\""); //<<< Note the " " surrounding the file name
65 - header('Content-Transfer-Encoding: binary');
66 - header('Connection: Keep-Alive');
67 - header('Expires: 0');
68 - header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
69 - header('Pragma: public');
70 - header('Content-Length: ' . strlen($codeFile->code));
71 - // AJAX Controller parameters.
72 - $this->httpContentType = 'application/octet-stream';
73 - }
74 - // Output code.
75 - $this->response = $codeFile->code;
76 - }
77 -
78 - /**
79 40 * Query single block based on the provided criteria!
80 - *
41 + *
81 42 */
82 43 public function getBlockByAction() {
83 44 // Initialize.
84 45 $returns = array_flip($_GET['returns']);
@@ -87,35 +48,35 @@
87 48 $inputs['filter'] = $_GET['filter'];
88 49 // Query Block.
89 50 $this->response = array_intersect_key((array) $this->model->getBlockBy(), $returns);
90 51 }
91 -
52 +
92 53 /**
93 54 * Get assigment panel objects page.
94 - *
55 + *
95 56 */
96 57 public function getAPOPAction() {
97 58 // Read inputs.
98 59 $iPerPage = (int) $_GET['iPerPage'];
99 60 $blockId = (int) $_GET['block'];
100 - $oTypeParams = (array) $_GET['typeParams'];
101 - $offset = (int) $_GET['index'];
61 + $oTypeParams = $_GET['typeParams'];
62 + $offset = $_GET['index'];
102 63 $assignedOnly = ($_GET['assignedOnly'] == 'false') ? false : true;
103 64 $initialize = ($_GET['initialize'] == 'false') ? false : true;
104 65 // Get the corresponding type object
105 66 // for handling the request.
106 - $typeName = (string) $oTypeParams['targetType'];
67 + $typeName = $oTypeParams['targetType'];
107 68 /**
108 69 * put your comment there...
109 - *
70 + *
110 71 * @var CJT_Models_Block_Assignmentpanel_Base
111 72 */
112 73 $typeObject = CJT_Models_Block_Assignmentpanel_Base
113 - ::getInstance($assignedOnly,
74 + ::getInstance($assignedOnly,
114 75 $typeName,
115 - $offset,
116 - $iPerPage,
117 - $blockId,
76 + $offset,
77 + $iPerPage,
78 + $blockId,
118 79 $oTypeParams);
119 80 // Fetch next page.
120 81 $items = $typeObject->getItems();
121 82 // Return result
@@ -123,31 +84,9 @@
123 84 $this->response['items'] = $items;
124 85 // Return count only when the list is activated for
125 86 // the first time.
126 87 if ($initialize) {
127 - $this->response['total'] = $typeObject->getTotalCount();
128 - }
129 - }
130 -
131 - /**
132 - * put your comment there...
133 - *
134 - * @deprecated this is just a redirect to the CJTBlockContoller::getAction().
135 - */
136 - protected function loadUrlAction() {
137 - // Read inputs.
138 - $url = (string) $_GET['url'];
139 - // Read URL.
140 - $response = wp_remote_get($url);
141 - if ($error = $response instanceof WP_Error) {
142 - // State an error!
143 - $this->response['errorCode'] = $response->get_error_code();
144 - $this->response['message'] = $response->get_error_message($response['code']);
145 - //break;
146 - }
147 - else {
148 - // Read code content.
149 - $this->response['content'] = wp_remote_retrieve_body($response);
88 + $this->response['total'] = $typeObject->getTotalCount();
150 89 }
151 90 }
152 91
153 92 } // End class.