Esempio n. 1
0
 /**
  * put your comment there...
  * 
  * @param mixed $id
  */
 public function getMetaboxId()
 {
     // Use the same id as regular CJT block.
     $blockView = CJTView::create('blocks/block');
     // To avoid outputing script and styles for block box Remove scripts and styles actions!
     remove_action('admin_print_scripts', array('CJTBlocksBlockView', 'enqueueScripts'));
     remove_action('admin_print_styles', array('CJTBlocksBlockView', 'enqueueStyles'));
     // Get metabox id.
     $blockView->setBlock($this->getBlock());
     return $blockView->getMetaboxId();
 }
Esempio n. 2
0
 /**
  * Select which metabox to load.
  * 
  * create-metabox view will be loaded if user doesnt 
  * created a block for current post yet.
  * 
  * metabox view will be loaded if there is a block
  * already created for current post.
  * 
  * Callback for add_meta_boxes action.
  */
 public function showMetabox()
 {
     // Import blocks view.
     CJTView::import('blocks/manager');
     /// Get block id.
     $metaboxId = $this->model->reservedMetaboxBlockId();
     // User didn't create block for this post yet.
     // Show create-metabox view.
     if (!$this->model->hasBlock()) {
         // Set view template name.
         $viewName = 'create-metabox';
         // Create DUMMY block object.
         $block = (object) array();
         $block->id = $metaboxId;
         $block->name = cssJSToolbox::getText('CJT Block');
     } else {
         // Set view template name.
         $viewName = 'metabox';
         // Get real block data.
         $block = CJTModel::create('blocks')->getBlock($metaboxId, array('returnCodeFile' => true));
     }
     // Get block meta box view object instance.
     $this->view = CJTView::create("blocks/{$viewName}");
     // Push view vars.
     $this->view->setBlock($block);
     $this->view->setSecurityToken($this->createSecurityToken());
     // Add metabox.
     add_meta_box($this->view->getMetaboxId(), $this->view->getMetaboxName(), array(&$this->view, 'display'), $this->model->getPost()->post_type, 'normal');
 }