예제 #1
0
 /**
  * put your comment there...
  * 
  * @deprecated All will be moved to other controllers in the future versions.
  */
 public function getRevisionAction()
 {
     // Initialize
     $model = $this->getModel('blocks');
     $tblCodeFile = new CJTBlockFilesTable(cssJSToolbox::getInstance()->getDBDriver());
     // Inputs.
     $revisionId = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
     // Get request parameters.
     $revision['id'] = $revisionId;
     $revision['fields'] = array('id', 'links', 'expressions', 'masterFile');
     $revision = $model->getBlock($revision['id'], array(), $revision['fields']);
     // Get revisioned code file.
     $revision->code = $tblCodeFile->set('blockId', $revisionId)->set('id', $revision->masterFile)->load()->getData()->code;
     // Discard Pins.
     $customPins = array_keys(CJTBlockModel::getCustomPins());
     foreach ($customPins as $customPinName) {
         $revision->{$customPinName} = false;
     }
     // Return revision.
     $this->response = $revision;
 }
예제 #2
0
 /**
  * put your comment there...
  * 
  * @param mixed $block
  */
 public function update($block, $updatePins)
 {
     $block = (array) $block;
     $blocks = new CJTBlocksTable($this->dbDriver);
     $pins = new CJTBlockPinsTable($this->dbDriver);
     // Update block pins if requested.
     if ($updatePins) {
         // Isolate block pins freom native block data.
         $pinsData = array_intersect_key($block, array_flip(array_keys(CJTBlockModel::getCustomPins())));
         do_action(CJTPluggableHelper::FILTER_BLOCK_MODEL_PRE_UPDATE_BLOCK_PINS, $block, $pinsData);
         $pins->update($block['id'], $pinsData);
     }
     // Update code file
     if (isset($block['activeFileId'])) {
         $codeFile = new CJTBlockFilesTable($this->dbDriver);
         $codeFile->set('blockId', $block['id'])->set('id', $block['activeFileId'])->set('code', $block['code'])->save();
     }
     // Isolate block fields.
     $blockData = array_intersect_key($block, $blocks->getFields());
     do_action(CJTPluggableHelper::FILTER_BLOCK_MODEL_PRE_UPDATE_BLOCK, $updatePins, $blockData);
     $blocks->update($blockData);
 }