/** * Delete single package. * * This method is going to delete the package * and all the templates and blocks associated to it, * therefor it'll unlink/break-down the relationship * between those templates and blocks. * * @param Integer Package Id. * @return CJTPackageModel Return $this. */ public function delete($id) { // Initialize. $modelTemplates = CJTModel::getInstance('templates-manager'); $dbd = cssJSToolbox::getInstance()->getDBDriver(); $assoObjectsQueryTmp = 'SELECT objectId FROM #__cjtoolbox_package_objects WHERE packageId = %d AND objectType = "%s" AND relType = "%s";'; // Delete the package. CJTxTable::getInstance('package')->set('id', $id)->delete(); // Delete blocks. $blockIds = array_keys($dbd->select(sprintf($assoObjectsQueryTmp, $id, 'block', 'add'))); if (!empty($blockIds)) { // Delete blocks! CJTModel::getInstance('blocks')->delete($blockIds)->save(); } // Delete templates. $modelTemplates->inputs['ids'] = array_keys($dbd->select(sprintf($assoObjectsQueryTmp, $id, 'template', 'add'))); // Templates muct be in trash state before deleted! $modelTemplates->inputs['state'] = 'trash'; // Move to Trash + Delete only if there is at least one Id! empty($modelTemplates->inputs['ids']) or $modelTemplates->changeState() and $modelTemplates->delete(); // Delete package objects map. CJTxTable::getInstance('package-objects')->set('packageId', $id)->delete(array('packageId')); }
/** * put your comment there... * * @param mixed $templates * @return CJTInstallerTemplate */ public function __construct($templates) { // Initialize! $this->model = CJTModel::getInstance('template'); // Initialize Iterator! parent::__construct(is_array($templates) ? $templates : array()); }
/** * Uninstall CJT Plugin * installaion flags, setup-flags * and user data! * * @return void */ public function uninstallAction() { // Initializing! $model =& CJTModel::getInstance('uninstall'); // Uninstall everything! $model->expressUninstall(); }
/** * 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; }
/** * put your comment there... * */ public function _checkInstallationState() { # Initialize $extensionClass = $this->extensionClass; $extension =& $this->extension; $extensionDeDoc =& $extension['defDoc']; $extensionState = new CJT_Framework_Extensions_Package_State_Extension($extensionDeDoc); # Upgrade and Install is the same both # required checking the packages inside # Package-Extension is a only a wrapper for packages inside! if ($extensionState->getState() != CJT_Framework_Extensions_Package_State_Extension::INSTALLED) { # Initialize $packageFileModel = CJTModel::getInstance('package-file'); $packageModel = CJTModel::getInstance('package'); $extensionDir = ABSPATH . PLUGINDIR . DIRECTORY_SEPARATOR . $extension['dir']; $packagesFolderPath = $extensionDir . DIRECTORY_SEPARATOR . (string) $extensionDeDoc->packages->attributes()->folder; # Getting packages state $extensionPackagesState = new CJT_Framework_Extensions_Package_State_Packages($extensionDeDoc); # Check packages foreach ($extensionPackagesState as $pckName => $package) { # Get state $pckState = $extensionPackagesState->getState(); # If not yet installed or requied upgrade if ($pckState != CJT_Framework_Extensions_Package_State_Packages::INSTALLED) { # Take action based on package installation state switch ($pckState) { case CJT_Framework_Extensions_Package_State_Packages::UPGRADE: # Delete package $packageModel->delete($package['id']); break; } # Get package file info. $packageFile = $packagesFolderPath . DIRECTORY_SEPARATOR . $package['file']; # Add/Create Package $packageCJTToken = $packageFileModel->parse(uniqid(), $packageFile); $packageId = $packageFileModel->install($packageCJTToken); # Mark as installed/created/added $extensionPackagesState->packageInstalled($packageId); } # Remove from queue $extensionPackagesState->removeOld(); } # Packages to delete! foreach ($extensionPackagesState->getDeletedPackages() as $name => $deletedPack) { # Delete package $packageModel->delete($deletedPack['id']); } # Upgrade packages state $extensionPackagesState->upgrade(); # Upgrade extension state $extensionState->upgrade($extension['defFile']); # Register uninstaller register_uninstall_hook($extension['pluginFile'], array(__CLASS__, "uninstall_{$extensionClass}")); } }
/** * put your comment there... * * @return CJTV10CEUpgrade Return $this */ public function finalize() { // Temporary for a period of time we need to clean up // users database as the access points cache wordpress option // will not be used any more! delete_option(self::ACCESS_POINTS_CACHE_POINTER); // Delete all install operations for versions other than 'current' version! CJTModel::import('installer'); $operationsState = get_option(CJTInstallerModel::INSTALLATION_STATE); update_option(CJTInstallerModel::INSTALLATION_STATE, array(CJTPlugin::DB_VERSION => $operationsState[CJTPlugin::DB_VERSION])); // Chaining! return $this; }
/** * Do nothing! * */ public function transit() { // Initialize. $register = $this->register(); $modelPackage = CJTModel::getInstance('package'); // Fetch package information with all readme and license tags locatted if // bundled with external files! $packageInfo = $register['packageParser']->getItem($this->getNode(), array('readme' => 'readme.txt', 'license' => 'license.txt')); // Add package to database! $register['packageId'] = $modelPackage->save($packageInfo); // Chain. return $this; }
/** * put your comment there... * * @param mixed $name */ public function useTheme($name) { // Get template name from theme name. // Template name is [BLOCKNAME-THEMENAME-theme]. $templateName = "{$this->source->name} - {$name} theme"; // Load template record from database. $tblTemplate = CJTxTable::getInstance('template')->setData(array('name' => $templateName))->load(array('name')); $mdlTemplate = CJTModel::getInstance('template'); $mdlTemplate->inputs['id'] = $tblTemplate->get('id'); $template = $mdlTemplate->getItem(); // Link Style sheet. $queueObject = CJTModel::getInstance('coupling')->getQueueObject('styles'); $queueObject->add($template->queueName, "/{$template->file}"); $queueObject->enqueue($template->queueName); // Chaining. return $this; }
/** * put your comment there... * */ public function embedded() { // Read template revision. $revision = CJTxTable::getInstance('template-revision')->fetchLastRevision($this->inputs['templateId']); // Revision could not be queried!! if (!$revision->get('id')) { throw new Exception('Revision could not be found!!'); } $revisionFile = $revision->get('file'); // Read revision code. $code = file_get_contents(ABSPATH . "/{$revisionFile}"); // Decrypt PHP codes! if (preg_match('/\\.php$/', $revisionFile)) { $code = CJTModel::getInstance('template')->decryptCode($code); } return $code; }
/** * put your comment there... * */ public function transit() { // Initialize. $model = CJTModel::getInstance('blocks'); $register = $this->register(); // Prepare object + getting item to be saved into database. $block = $register['packageParser']->getItem($this->getNode()); // Set other block internal data. $block['created'] = $block['lastModified'] = current_time('mysql'); $block['owner'] = get_current_user_id(); // Create Block. /// Expose BlockId for other nodes. $register['blockId'] = $model->add($block); $model->save(); // Chaining. return $this; }
/** * put your comment there... * */ public function __construct($type) { // Save type data for later use! $this->type = cssJSToolbox::$config->templates->types[$type]; $this->type->name = $type; // Get which Wordpress queue (wp_script, wp_styles) object to fetch data from. $wpQueueName = self::$typesMap[$type]; /** * @var CJTCouplingModel */ $coupling = CJTModel::getInstance('coupling'); // Initialize ArrayIterator with templates list! parent::__construct($coupling->getQueueObject($wpQueueName)->registered); // Import dependencies! cssJSToolbox::import('framework:db:mysql:xtable.inc.php'); CJTxTable::import('template'); CJTxTable::import('author'); }
/** * Do nothing! * */ public function transit() { // Initialize. $model = CJTModel::getInstance('template'); $node = $this->getNode(); $register = $this->register(); // Prepare object + getting item to be saved into database. $template = $register['packageParser']->getItem($node); // Insert template only if not exists. if (!$model->exists($template['name'])) { // Import template(s) helper. cssJSToolbox::import('includes:templates:templates.class.php'); // Set template revision. $model->inputs['item']['revision']['code'] = $template['code']; unset($template['code']); // Set template main data. $model->inputs['item']['template'] = $template; /** Get template Type! * Get type from external file extension if * the template code was linked to file. * If the template code were inline * then the type must be provided under * TYPE element! */ // If no type specified get it from the external file extension if (!isset($model->inputs['item']['template']['type'])) { // @WARNING: Get locatted file! $codeFileName = (string) $node->code->attributes()->locatted; if ($codeFileName) { // Get type from extension. $fileComponent = pathinfo($codeFileName); $model->inputs['item']['template']['type'] = CJTTemplates::getExtensionType($fileComponent['extension']); } } // Add template. $addedTemplate = $model->save(); // Expose template fields to be by used by other objects. $register['templateId'] = $addedTemplate->templateId; $register['templateFile'] = $addedTemplate->file; } // Chaining. return $this; }
/** * put your comment there... * * @param mixed $blockId */ public function getExecTemplatesCode($blockId) { // Initialize. $code = ''; // Get all HTML and PHP templates linked to the block. $templates = $this->getLinkedTemplates($blockId, array('php', 'html')); if (!empty($templates)) { // Instantiate template model. $templateModel = CJTModel::getInstance('template'); // Concat their codes. foreach ($templates as $template) { // Fetch template record with code loaded from file and decrypted if PHP! $templateModel->inputs['id'] = $template->id; $template = $templateModel->getItem(); // Concat $code .= $template->code; } } return $code; }
/** * put your comment there... * */ public function upgrade() { // Read block! $srcBlock =& $this[$this->key()]; // Build block in new structure! $block = array_diff_key($srcBlock, array_flip(array('page', 'category'))); $pins = array(); // Set interna data! $block['id'] = $this->id(); $block['created'] = $block['lastModified'] = current_time('mysql'); $block['owner'] = get_current_user_id(); // Translate old assignment panel to use the new structure! if (isset($srcBlock['category'])) { $pins['categories'] = $srcBlock['category']; } // Translate named map from last versions to the value used in the new versions! CJTModel::import('block'); // Import CJTBlockModel $namedPins = array('allpages' => CJTBlockModel::PINS_PAGES_ALL_PAGES, 'allposts' => CJTBlockModel::PINS_POSTS_ALL_POSTS, 'frontpage' => CJTBlockModel::PINS_PAGES_FRONT_PAGE); foreach (isset($srcBlock['page']) ? $srcBlock['page'] : array() as $assignedObject) { // Translate named pin to flag! if (isset($namedPins[$assignedObject])) { // Set pinPoint flags! $block['pinPoint'][] = dechex($namedPins[$assignedObject]); } else { // Previous versions support only pages but not posts! $pins['pages'][] = $assignedObject; } } // Calculate Pin Points! $block['pinPoint'] = CJTBlockModel::calculatePinPoint($block, $pins); // Create new Block! $this->model->add($block); // Save Block pins/assigned objects as it doesnt saved when created! $pins['id'] = $block['id']; $this->model->update($pins, true); // Chaining return $this; }
/** * Link external Resources (CSS, HTML, JS and PHP) * * The action is to create external link as CJT template * and link it to the target block. */ protected function linkExternalAction() { // Import dependencies. cssJSToolbox::import('includes:templates:templates.class.php'); // Initialize response as successed until error occured! $this->response = array('code' => 0, 'message' => ''); // List of all the external templates records to create! $externalTemplates = array(); // Read inputs. $externals = explode(',', $_REQUEST['externals']); $blockId = (int) $_REQUEST['blockId']; // Add as templates. foreach ($externals as $externalResourceURI) { // Use URI base name as Template Name and the extension as Template Type. $externalPathInfo = pathinfo($externalResourceURI); // Template Item. $item = array(); $item['template']['name'] = $externalPathInfo['basename']; $item['template']['type'] = CJTTemplates::getExtensionType($externalPathInfo['extension']); $item['template']['state'] = 'published'; // Get external URI code! $externalResponse = wp_remote_get($externalResourceURI); if ($error = $externalResponse instanceof WP_Error) { // State an error! $this->response['code'] = $externalResponse->get_error_code(); $this->response['message'] = $externalResponse->get_error_message($this->response['code']); break; } else { // Read code content. $item['revision']['code'] = wp_remote_retrieve_body($externalResponse); // Add to the save list! $externalTemplates[] = $item; } } // Save all templates if no error occured // Single error will halt all the linked externals! They all added as a single transaction. if (!$this->response['code']) { // Instantiate Template Models. $modelLookup = CJTModel::getInstance('templates-lookup'); $modelTemplate = CJTModel::getInstance('template'); $modelBlockTemplates = CJTModel::getInstance('block-templates'); // Add all templates. foreach ($externalTemplates as $item) { // Check existance. $modelTemplate->inputs['filter']['field'] = 'name'; $modelTemplate->inputs['filter']['value'] = $item['template']['name']; if (!($existsItem = $modelTemplate->getTemplateBy()) || !property_exists($existsItem, 'id') || !$existsItem->id) { // Create template. $modelTemplate->inputs['item'] = $item; $item = (array) $modelTemplate->save(); } else { // The returned item has 'id' field not 'templateId'!! $item = array('templateId' => $existsItem->id); } // Link only if not already linked! if (!$modelBlockTemplates->isLinked($blockId, $item['templateId'])) { // Link template to the block. $modelLookup->inputs['templateId'] = $item['templateId']; $modelLookup->inputs['blockId'] = $blockId; $modelLookup->link(); } } } }
/** * 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'); }
/** * put your comment there... * */ public function __toString() { // Initialize. $replacement = ''; $model = CJTModel::getInstance('coupling'); // Get shortcode options. $this->options = array_merge($this->options, array_intersect_key($this->attributes, $this->options)); // Get shortcode parameters. $this->parameters = array_diff_key($this->attributes, array_flip(array('force', 'tag', 'name', 'id'))); // Get Block fields to be used to query the block. $blockQueryFields = array_intersect_key($this->attributes, array_flip(array('id', 'name'))); $coupling =& CJTBlocksCouplingController::theInstance(); // Import dependecies. cssJSToolbox::import('framework:db:mysql:xtable.inc.php', 'framework:php:evaluator:evaluator.inc.php'); // Query block. $block = CJTxTable::getInstance('block')->setData($blockQueryFields)->load(array_keys($blockQueryFields)); // Load using Creteria fields. // Get block code if exists and is active block. if ($block->get('id')) { if ($block->get('state') == 'active') { // Get stdCLass copy. $block = $block->getData(); // Output block if 'force="true" or only if it wasn't already in the header/footer! if ($this->options['force'] == 'true' || !in_array($block->id, $coupling->getOnActionIds())) { // Id is being used! $coupling->addOnActionIds((int) $block->id); // Retrieve block code-files. $block->code = $model->getBlockCode($block->id); // Import Executable (PHP and HTML) templates. $block->code = $block->code . $model->getExecTemplatesCode($block->id); // CJT Block Standard Parameters object. $spi = new CJT_Framework_Developer_Interface_Block_Shortcode_Shortcode($block, $this->parameters, $this->content); // Get block code, execute it as PHP! $blockCode = CJTPHPCodeEvaluator::getInstance($block)->exec(array('cb' => $spi))->getOutput(); // CJT Shortcode markup interface (CSMI)! // CSMI is HTML markup to identify the CJT block Shortcode replacement. $replacement = "<{$this->options['tag']} id='{$spi->containerElementId()}' class='csmi csmi-bid-{$block->id} csmi-{$block->name}'>{$this->content}{$blockCode}</{$this->options['tag']}>"; // Get linked templates. $linkedStylesheets = ''; $templates = $model->getLinkedTemplates($block->id); $reverseTypes = array_flip(CJTCouplingModel::$templateTypes); // Enqueue all scripts & Direct Output for all Style Sheets! foreach ($templates as $template) { // Get Template type name. $typeName = $reverseTypes[$template->type]; /** * @var WP_Dependencies */ $queue = $model->getQueueObject($typeName); if (!in_array($template->queueName, $queue->done)) { if (!isset($queue->registered[$template->queueName])) { $queue->add($template->queueName, "/{$template->file}", null, $template->version, 1); } // Enqueue template! $queue->enqueue($template->queueName); } } // Prepend linked Stylesheets to the replacement. if (isset($linkedStylesheets)) { $replacement = "<style type='text/css'>{$linkedStylesheets}</style>{$replacement}"; } } } } else { // Invalid Shortcode block query! $replacement = cssJSToolbox::getText('Could not find block specified! Please check out the Shortcode parameters.'); } // Return shortcode replacement string. return $replacement; }
/** * put your comment there... * */ public static function enqueueStyles() { $listTypeName = CJTModel::getInstance('extensions')->getListTypeName(); // Use related scripts. self::useStyles(__CLASS__, 'thickbox', "views:extensions:plugins-list:public:css:{CJTExtensionsPluginsListView-}{$listTypeName}"); }
/** * put your comment there... * * @param mixed $name */ public function getModel($name = null) { // Instantiate model if required! if ($name) { $this->model = CJTModel::getInstance($name); } return $this->ongetmodel($this->model); }
/** * 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... * */ 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); }
/** * 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... * */ 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; }