| @@ -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! |
| @@ -36,21 +36,19 @@ | ||
| 36 | 36 | $this->registryAction('getAPOP'); |
| 37 | 37 | $this->registryAction('loadUrl'); |
| 38 | 38 | $this->registryAction('getCode'); |
| 39 | 39 | $this->registryAction('downloadCodeFile'); |
| 40 | - $this->registryAction('getAllAssignment'); | |
| 41 | - $this->registryAction('getCodeFilesCount'); | |
| 42 | 40 | } |
| 43 | - | |
| 41 | + | |
| 44 | 42 | /** |
| 45 | 43 | * put your comment there... |
| 46 | - * | |
| 44 | + * | |
| 47 | 45 | */ |
| 48 | 46 | public function downloadCodeFileAction() { |
| 49 | 47 | // BlockId, currentActiveFile. |
| 50 | - $blockId = sanitize_text_field( $_GET['blockId'] ); | |
| 51 | - $fileId = sanitize_text_field( $_GET['fileId'] ); | |
| 52 | - $returnAs = sanitize_text_field( $_GET['returnAs'] ); | |
| 48 | + $blockId = $_GET['blockId']; | |
| 49 | + $fileId = $_GET['fileId']; | |
| 50 | + $returnAs = $_GET['returnAs']; | |
| 53 | 51 | // Get current File Code. |
| 54 | 52 | $tblCodeFile = new CJTBlockFilesTable(cssJSToolbox::getInstance()->getDBDriver()); |
| 55 | 53 | $codeFile = $tblCodeFile->set('id', $fileId) |
| 56 | 54 | ->set('blockId', $blockId) |
| @@ -76,40 +74,11 @@ | ||
| 76 | 74 | // Output code. |
| 77 | 75 | $this->response = $codeFile->code; |
| 78 | 76 | } |
| 79 | 77 | |
| 80 | - | |
| 81 | - /** | |
| 82 | - * put your comment there... | |
| 83 | - * | |
| 84 | - */ | |
| 85 | - public function getAllAssignmentAction() { | |
| 86 | - | |
| 87 | - $blockId = isset($_GET['blockId']) ? esc_html($_GET['blockId']) : null; | |
| 88 | - | |
| 89 | - try { | |
| 90 | - | |
| 91 | - if (!$blockId) { | |
| 92 | - | |
| 93 | - throw new Exception('Invalid Request parameters'); | |
| 94 | - } | |
| 95 | - | |
| 96 | - $blocks = new CJTBlocksModel(); | |
| 97 | - | |
| 98 | - $block = $blocks->getBlock($blockId); | |
| 99 | - | |
| 100 | - $this->response = count(CJTBlocksModel::getAllAssignments($block)); | |
| 101 | - } | |
| 102 | - catch (Exception $exception) { | |
| 103 | - | |
| 104 | - | |
| 105 | - } | |
| 106 | - | |
| 107 | - } | |
| 108 | - | |
| 109 | 78 | /** |
| 110 | 79 | * Query single block based on the provided criteria! |
| 111 | - * | |
| 80 | + * | |
| 112 | 81 | */ |
| 113 | 82 | public function getBlockByAction() { |
| 114 | 83 | // Initialize. |
| 115 | 84 | $returns = array_flip($_GET['returns']); |
| @@ -118,61 +87,35 @@ | ||
| 118 | 87 | $inputs['filter'] = $_GET['filter']; |
| 119 | 88 | // Query Block. |
| 120 | 89 | $this->response = array_intersect_key((array) $this->model->getBlockBy(), $returns); |
| 121 | 90 | } |
| 122 | - | |
| 123 | - /** | |
| 124 | - * put your comment there... | |
| 125 | - * | |
| 126 | - */ | |
| 127 | - protected function getCodeFilesCountAction() { | |
| 128 | - | |
| 129 | - | |
| 130 | - $blockId = isset($_GET['blockId']) ? esc_html($_GET['blockId']) : null; | |
| 131 | - | |
| 132 | - try { | |
| 133 | - | |
| 134 | - if (!$blockId) { | |
| 135 | - | |
| 136 | - throw new Exception('Invalid Request parameters'); | |
| 137 | - } | |
| 138 | - | |
| 139 | - $this->response = count(CJTBlocksModel::getCodeFilesCount($blockId)); | |
| 140 | - } | |
| 141 | - catch (Exception $exception) { | |
| 142 | - | |
| 143 | - | |
| 144 | - } | |
| 145 | - | |
| 146 | - | |
| 147 | - } | |
| 148 | - | |
| 91 | + | |
| 149 | 92 | /** |
| 150 | 93 | * Get assigment panel objects page. |
| 151 | - * | |
| 94 | + * | |
| 152 | 95 | */ |
| 153 | 96 | public function getAPOPAction() { |
| 154 | 97 | // Read inputs. |
| 155 | 98 | $iPerPage = (int) $_GET['iPerPage']; |
| 156 | 99 | $blockId = (int) $_GET['block']; |
| 157 | - $oTypeParams = (array) $_GET['typeParams']; | |
| 158 | - $offset = (int) $_GET['index']; | |
| 100 | + $oTypeParams = $_GET['typeParams']; | |
| 101 | + $offset = $_GET['index']; | |
| 159 | 102 | $assignedOnly = ($_GET['assignedOnly'] == 'false') ? false : true; |
| 160 | 103 | $initialize = ($_GET['initialize'] == 'false') ? false : true; |
| 161 | 104 | // Get the corresponding type object |
| 162 | 105 | // for handling the request. |
| 163 | - $typeName = (string) $oTypeParams['targetType']; | |
| 106 | + $typeName = $oTypeParams['targetType']; | |
| 164 | 107 | /** |
| 165 | 108 | * put your comment there... |
| 166 | - * | |
| 109 | + * | |
| 167 | 110 | * @var CJT_Models_Block_Assignmentpanel_Base |
| 168 | 111 | */ |
| 169 | 112 | $typeObject = CJT_Models_Block_Assignmentpanel_Base |
| 170 | - ::getInstance($assignedOnly, | |
| 113 | + ::getInstance($assignedOnly, | |
| 171 | 114 | $typeName, |
| 172 | - $offset, | |
| 173 | - $iPerPage, | |
| 174 | - $blockId, | |
| 115 | + $offset, | |
| 116 | + $iPerPage, | |
| 117 | + $blockId, | |
| 175 | 118 | $oTypeParams); |
| 176 | 119 | // Fetch next page. |
| 177 | 120 | $items = $typeObject->getItems(); |
| 178 | 121 | // Return result |
| @@ -180,20 +123,20 @@ | ||
| 180 | 123 | $this->response['items'] = $items; |
| 181 | 124 | // Return count only when the list is activated for |
| 182 | 125 | // the first time. |
| 183 | 126 | if ($initialize) { |
| 184 | - $this->response['total'] = $typeObject->getTotalCount(); | |
| 127 | + $this->response['total'] = $typeObject->getTotalCount(); | |
| 185 | 128 | } |
| 186 | 129 | } |
| 187 | - | |
| 130 | + | |
| 188 | 131 | /** |
| 189 | 132 | * put your comment there... |
| 190 | - * | |
| 133 | + * | |
| 191 | 134 | * @deprecated this is just a redirect to the CJTBlockContoller::getAction(). |
| 192 | 135 | */ |
| 193 | 136 | protected function loadUrlAction() { |
| 194 | 137 | // Read inputs. |
| 195 | - $url = (string) $_GET['url']; | |
| 138 | + $url = $_GET['url']; | |
| 196 | 139 | // Read URL. |
| 197 | 140 | $response = wp_remote_get($url); |
| 198 | 141 | if ($error = $response instanceof WP_Error) { |
| 199 | 142 | // State an error! |