Example #1
0
    /**
     * put your comment there...
     * 
     */
    public function getItem()
    {
        $tManager = CJTModel::create('templates-manager');
        $query = $tManager->getItemsQuery();
        $query['select'] = 'SELECT t.id, 
																					t.queueName,
																					t.name, 
																					t.type, 
																					t.description, 
																					t.creationDate, 
																					t.keywords,
																					r.dateCreated lastModified,
																					t.state, 
																					a.name author,
																					r.changeLog,
																					r.version,
																					r.file,
																					r.state developmentState';
        $query['where'] .= " AND t.id = {$this->inputs['id']}";
        // Filering!
        $query = $this->onqueryitem($query);
        // Build and query!
        $query = "{$query['select']} {$query['from']} {$query['where']}";
        $item = cssJSToolbox::getInstance()->getDBDriver()->getRow($query);
        // Get code.
        $code = file_get_contents(ABSPATH . "/{$item->file}");
        // Decode if its a PHP template!
        if ($item->type == 'php') {
            $code = $this->decryptCode($code);
        }
        $item->code = $this->onloadcodefile($code, $item);
        // Return PHP StdClass object.
        return $item;
    }
Example #2
0
 /**
  * Check whether is the current post type
  * can has CJT Block metabox?
  * 
  */
 public function doPost()
 {
     // Get all post types selected by user.
     $metaboxSettings = CJTModel::create('settings')->loadPage('metabox');
     // Return true is post types selected, otherwise return false.
     $allowedPostTypes = $metaboxSettings->postTypes;
     return in_array($this->getPost()->post_type, $allowedPostTypes);
 }
 /**
  * put your comment there...
  * 
  */
 protected function setRequestFilters()
 {
     // Get request blocks.
     $filters = $this->ondefaultfilters((object) array('pinPoint' => 0x0, 'customPins' => array(), 'moreToOrder' => array(), 'currentObject' => null, 'currentCustomPin' => 0, 'params' => array()));
     if (is_admin()) {
         // Include all backend blocks.
         $filters->pinPoint |= CJTBlockModel::PINS_BACKEND;
     } else {
         $filters->pinPoint |= CJTBlockModel::PINS_FRONTEND;
         // Pages.
         if (is_page()) {
             // Blocks with ALL PAGES selected.
             $filters->pinPoint |= CJTBlockModel::PINS_PAGES_ALL_PAGES;
             $filters->currentObject = $GLOBALS['post'];
             $filters->currentCustomPin = CJTBlockModel::PINS_PAGES_CUSTOM_PAGE;
             // Blocks with PAGE-ID selected.
             $filters->customPins[] = array('pin' => 'pages', 'pins' => array($filters->currentObject->ID), 'flag' => CJTBlockModel::PINS_PAGES_CUSTOM_PAGE);
             // Blocks with FRONT-PAGE selected.
             if (is_front_page()) {
                 $filters->pinPoint |= CJTBlockModel::PINS_PAGES_FRONT_PAGE;
             }
             /**
              * In order for metabox block to get in the output we need
              * to add metabox order for it.
              * @see CJTBlocksCouplingController::getBlocks.
              */
             $metabox = CJTModel::create('metabox', array($filters->currentObject->ID));
             $filters->moreToOrder[][1] = $metabox->getMetaboxId();
         } else {
             if (is_attachment()) {
                 $filters->pinPoint |= CJTBlockModel::PINS_ATTACHMENT;
             } else {
                 if (is_single()) {
                     // Blocks with ALL POSTS & ALL CATEGORIES selected.
                     $filters->pinPoint |= CJTBlockModel::PINS_POSTS_ALL_POSTS | CJTBlockModel::PINS_CATEGORIES_ALL_CATEGORIES;
                     $filters->currentObject = $GLOBALS['post'];
                     $filters->currentCustomPin = CJTBlockModel::PINS_POSTS_CUSTOM_POST;
                     // Blocks with POST-ID selected.
                     $filters->customPins[] = array('pin' => 'posts', 'pins' => array($filters->currentObject->ID), 'flag' => CJTBlockModel::PINS_POSTS_CUSTOM_POST);
                     // Include POST PARENT CATRGORIES blocks.
                     $parentCategoriesIds = wp_get_post_categories($filters->currentObject->ID, array('fields' => 'ids'));
                     /**
                      * Custom-Posts just added "ON THE RUN/FLY"
                      * Need simple fix by confirming that the post is belong to
                      * specific category or not.
                      * Custom posts NOW unlike Posts, it doesn't inherit parent
                      * taxonomis Code Blocks!!
                      */
                     if (!empty($parentCategoriesIds)) {
                         $filters->params['hasCategories'] = true;
                         $filters->params['parentCategories'] = $parentCategoriesIds;
                         $filters->customPins[] = array('pin' => 'categories', 'pins' => $parentCategoriesIds, 'flag' => CJTBlockModel::PINS_CATEGORIES_CUSTOM_CATEGORY);
                     }
                     /**
                      * In order for metabox block to get in the output we need
                      * to add metabox order for it.
                      * @see CJTBlocksCouplingController::getBlocks.
                      */
                     $metabox = CJTModel::create('metabox', array($filters->currentObject->ID));
                     $filters->moreToOrder[][1] = $metabox->getMetaboxId();
                     /** 
                      * @TODO check for recent posts Based on user configuration.
                      * Recent posts should be detcted by comparing
                      * user condifguration with post date.
                      */
                     if (0) {
                     }
                 } else {
                     if (is_category()) {
                         // Blocks with ALL CATEGORIES selected.
                         $filters->pinPoint |= CJTBlockModel::PINS_CATEGORIES_ALL_CATEGORIES;
                         $filters->currentObject = get_queried_object();
                         $filters->currentCustomPin = CJTBlockModel::PINS_CATEGORIES_CUSTOM_CATEGORY;
                         // Blocks with CATEGORY-ID selected.
                         $filters->customPins[] = array('pin' => 'categories', 'pins' => array($filters->currentObject->term_id), 'flag' => CJTBlockModel::PINS_CATEGORIES_CUSTOM_CATEGORY);
                     } else {
                         if (is_home()) {
                             $filters->pinPoint |= CJTBlockModel::PINS_POSTS_BLOG_INDEX;
                         } else {
                             if (is_search()) {
                                 $filters->pinPoint |= CJTBlockModel::PINS_SEARCH;
                             } else {
                                 if (is_tag()) {
                                     $filters->pinPoint |= CJTBlockModel::PINS_TAG;
                                 } else {
                                     if (is_author()) {
                                         $filters->pinPoint |= CJTBlockModel::PINS_AUTHOR;
                                     } else {
                                         if (is_archive()) {
                                             $filters->pinPoint |= CJTBlockModel::PINS_ARCHIVE;
                                         } else {
                                             if (is_404()) {
                                                 $filters->pinPoint |= CJTBlockModel::PINS_404_ERROR;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $this->filters = $this->onsetfilters($filters);
 }
 /**
  * put your comment there...
  * 
  * @param mixed $hasView
  * @param mixed $request
  * @param mixed $overrideControllerPath
  * @param mixed $overrideContollerPrefix
  * @return CJTController
  */
 public function __construct($hasView = null, $request = null, $overrideControllerPath = null, $overrideContollerPrefix = null)
 {
     // Initialize hookable!
     parent::__construct();
     // Read request parameters.
     $this->request = array_merge((array) $_REQUEST, (array) $request);
     // Create default model.
     if (isset($this->controllerInfo['model'])) {
         // E_ALL complain!
         if (!isset($this->controllerInfo['model_file'])) {
             $this->controllerInfo['model_file'] = null;
         }
         $this->model = CJTModel::create($this->controllerInfo['model'], $this->request, $this->controllerInfo['model_file'], dirname($overrideControllerPath), $overrideContollerPrefix);
     }
     // Create default view.
     if ($hasView === null) {
         // Default value for $hasView = true
         // Request/passed parameters has priority over controller default view!
         $view = $this->ongetviewname(isset($this->request['view']) ? $this->request['view'] : (isset($this->controllerInfo['view']) ? $this->controllerInfo['view'] : null));
         if ($view) {
             $this->view = self::getView($view, null, dirname($overrideControllerPath), $overrideContollerPrefix)->setModel($this->model)->setRequest($this->request);
         }
     }
 }
 /**
  * put your comment there...
  * 
  */
 public function loadBlockAction()
 {
     // Block Id.
     $blockId = (int) $_GET['blockId'];
     // Get block content.
     $view = CJTView::getInstance('blocks/cjt-block');
     $view->setBlock(CJTModel::create('blocks')->getBlock($blockId, array('returnCodeFile' => true)));
     // Return View content.
     $view->getTemplate('default');
     $this->response = $view->structuredContent;
 }
Example #6
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');
 }