Example #1
0
 /**
  * Create block metabox for specific post object.
  * 
  * @param integer Post id.
  * @return array New block object consist of block id and new block metabox view content.
  */
 public function createAction()
 {
     // Get reserved block id from post object.
     $blockId = $this->model->getMetaboxId();
     if ($blockId) {
         // Set request paremeters for blocks-ajax controller::createBlockAction.
         $_GET['name'] = cssJSToolbox::getText(sprintf(cssJSToolbox::getText('CJT Block - Post #%d'), $this->model->getPost()->ID));
         $_GET['state'] = 'active';
         // Create post metabox.
         $this->model->create($pin)->save();
         // Create new block.
         $blocksController = CJTController::create('blocks-ajax');
         $blocksController->createBlockAction($blockId, 'metabox', $pin->flag);
         // Get metabox block view object.
         $this->view = CJTView::create('blocks/metabox');
         $this->view->setBlock(CJTModel::create('blocks')->getBlock($blockId, array('returnCodeFile' => true)));
         $this->view->setSecurityToken($this->createSecurityToken());
         // Send Javascript & CSS files needed for the metabox view to work.
         $this->response['references'] = self::getReferencesQueue();
         $this->response['view'] = $this->view->setOption('customizeMetabox', true)->getTemplate('metabox');
     }
 }