| @@ -27,8 +27,9 @@ | ||
| 27 | 27 | public function __construct() { |
| 28 | 28 | parent::__construct(); |
| 29 | 29 | // Supported actions. |
| 30 | 30 | add_action('wp_ajax_cjtoolbox_get_info_view', array(&$this, '_doAction')); |
| 31 | + add_action('wp_ajax_cjtoolbox_set_property', array(&$this, '_doAction')); | |
| 31 | 32 | add_action('wp_ajax_cjtoolbox_get_revision', array(&$this, '_doAction')); |
| 32 | 33 | add_action('wp_ajax_cjtoolbox_get_revisions', array(&$this, '_doAction')); |
| 33 | 34 | // Redirects |
| 34 | 35 | $this->registryAction('getBlockBy'); |
| @@ -35,9 +36,8 @@ | ||
| 35 | 36 | $this->registryAction('getAPOP'); |
| 36 | 37 | $this->registryAction('restoreRevision'); |
| 37 | 38 | $this->registryAction('loadUrl'); |
| 38 | 39 | $this->registryAction('downloadCodeFile'); |
| 39 | - $this->registryAction('getAllAssignment'); | |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * put your comment there... |
| @@ -48,16 +48,8 @@ | ||
| 48 | 48 | // Pass to CJTBlockController! |
| 49 | 49 | $this->redirect('block'); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - /** | |
| 53 | - * put your comment there... | |
| 54 | - * | |
| 55 | - */ | |
| 56 | - protected function getAllAssignmentAction() { | |
| 57 | - $this->redirect('block'); | |
| 58 | - } | |
| 59 | - | |
| 60 | 52 | /** |
| 61 | 53 | * put your comment there... |
| 62 | 54 | * |
| 63 | 55 | * @deprecated this is just a redirect to the CJTBlockContoller::getAction(). |
| @@ -75,9 +67,9 @@ | ||
| 75 | 67 | protected function getBlockByAction() { |
| 76 | 68 | // Pass to CJTBlockController! |
| 77 | 69 | $this->redirect('block'); |
| 78 | 70 | } |
| 79 | - | |
| 71 | + | |
| 80 | 72 | /** |
| 81 | 73 | * put your comment there... |
| 82 | 74 | * |
| 83 | 75 | * @deprecated All will be moved to other controllers in the future versions. |
| @@ -116,15 +108,11 @@ | ||
| 116 | 108 | ->set('id', $revision->masterFile) |
| 117 | 109 | ->load() |
| 118 | 110 | ->getData()->code; |
| 119 | 111 | // Discard Pins. |
| 120 | - $customPins = array_keys( CJTBlockModel::getCustomPins() ); | |
| 121 | - | |
| 122 | - foreach ( $customPins as $customPinName ) | |
| 123 | - { | |
| 124 | - $revision->{$customPinName} = false; | |
| 125 | - } | |
| 126 | - | |
| 112 | + $revision->pages = false; | |
| 113 | + $revision->posts = false; | |
| 114 | + $revision->categories = false; | |
| 127 | 115 | // Return revision. |
| 128 | 116 | $this->response = $revision; |
| 129 | 117 | } |
| 130 | 118 | |
| @@ -150,9 +138,9 @@ | ||
| 150 | 138 | // Create view. |
| 151 | 139 | $view = $this->getView('blocks/revisions'); |
| 152 | 140 | // Push view vars. |
| 153 | 141 | $view->blockId = $blockId; |
| 154 | - $view->revisions = array_reverse($revisions); | |
| 142 | + $view->revisions = $revisions; | |
| 155 | 143 | // Set output header. |
| 156 | 144 | $this->httpContentType = 'text/html'; |
| 157 | 145 | // Return view content. |
| 158 | 146 | $this->response = $view->getTemplate('default'); |
| @@ -200,5 +188,45 @@ | ||
| 200 | 188 | // Return TRUE. |
| 201 | 189 | $this->response = true; |
| 202 | 190 | } |
| 203 | 191 | |
| 192 | + /** | |
| 193 | + * Update exists block property value. | |
| 194 | + * | |
| 195 | + * | |
| 196 | + * Call this method using POST method with the following parameters. | |
| 197 | + * - id integer Block id. | |
| 198 | + * - property string Property Name to change. | |
| 199 | + * - value mixed Property value to change. | |
| 200 | + * | |
| 201 | + * Response body is array with the following elements. | |
| 202 | + * - string oldValue Old property value. | |
| 203 | + * - string value New value. | |
| 204 | + * | |
| 205 | + * @deprecated | |
| 206 | + * @return void | |
| 207 | + */ | |
| 208 | + public function setPropertyAction() { | |
| 209 | + // Initialize. | |
| 210 | + $response = array(); | |
| 211 | + $blocks = $this->getModel('blocks'); | |
| 212 | + // Prepare parameters. | |
| 213 | + $blockId = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT); | |
| 214 | + $property = filter_input(INPUT_POST, 'property', FILTER_SANITIZE_STRING); | |
| 215 | + $newValue = filter_input(INPUT_POST, 'value', FILTER_UNSAFE_RAW); | |
| 216 | + // Get old value. | |
| 217 | + $block = $blocks->getBlock($blockId); | |
| 218 | + $oldValue = $block->$property; | |
| 219 | + // Update only if there is a change. | |
| 220 | + if ($oldValue != $newValue) { | |
| 221 | + // Update block property. | |
| 222 | + $block->$property = $newValue; | |
| 223 | + $blocks->setBlock($block); | |
| 224 | + $blocks->save(); | |
| 225 | + // Set response object. | |
| 226 | + $response['oldValue'] = $oldValue; | |
| 227 | + $response['value'] = $newValue; | |
| 228 | + } | |
| 229 | + $this->response = $response; | |
| 230 | + } | |
| 231 | + | |
| 204 | 232 | } // End class. |