/** * put your comment there... * * @deprecated All will be moved to other controllers in the future versions. */ public function getInfoViewAction() { $model = $this->getModel('blocks'); // Set content type as HTML. $this->httpContentType = "text/html"; // Get block info. $id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT); $Info = $model->getInfo($id); // Create info view object. $view = CJTController::getView('blocks/info'); // Get view info content. $view->info = $Info; $this->response = $view->getTemplate('default'); }
/** * 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'); } }
/** * Initialize controller object. * * @see CJTController for more details * @return void */ public function __construct() { // Only one instance is allowed. if (self::$instance) { throw new Exception('Trying to instantiate multiple coupling instances!!'); } // Hold the single instance we've! self::$instance = $this; $siteHook = cssJSToolbox::$config->core->siteHook; // Initialize controller. parent::__construct(false); // Import related libraries CJTModel::import('block'); // Not default action needed. $this->defaultAction = null; // Initialize controller. $initCouplingCallback = $this->onassigncouplingcallback(array(&$this, 'initCoupling')); add_action('admin_init', $initCouplingCallback); add_action($siteHook->tag, $initCouplingCallback, $siteHook->priority); // Add Shortcode callbacks. add_shortcode('cjtoolbox', array(&$this, 'shortcode')); }
/** * put your comment there... * */ public function displayAction() { echo parent::displayAction(); }
/** * */ public static function import($path) { $viewInfo = CJTController::getViewInfo($path); // Import view. require_once $viewInfo['viewFile']; }
$name = basename($path); // View info struct. $viewInfo = array('name' => $path, 'url' => "{$viewsUrl}/{$path}", 'path' => "{$pathToViews}/{$path}", 'viewsPath' => $pathToViews, 'viewsUrl' => $viewsUrl, 'viewFile' => "{$pathToViews}/{$path}/view.php"); return $viewInfo; } /** * put your comment there... * * @param mixed $action */ public function setAction($action) { $this->action = $action; return $this; } /** * put your comment there... * * @param mixed $name * @param mixed $value */ public function setRequestParameter($name, $value) { $this->request[$name] = $value; return $this; } } // End class. // Hookable! CJTController::define('CJTController', array('hookType' => CJTWordpressEvents::HOOK_FILTER));
/** * Redirect the request to another controller. * * Why this method is created anyway is to allow * deprecating old controllers and start to create new one * a quiet manner! * * The idea is to create the new controller, adding new Action there * and redirect the call throught current deprecated controller. * * @param mixed $controller */ protected function redirect($controller) { // Initialize vars. $currentFilter = current_filter(); // Remove current Action! remove_action($currentFilter, array(&$this, '_doAction')); // activate the target CTR! CJTController::getInstance($controller); // Fire the action manually. do_action($currentFilter); }
/** * Get view content through ajax request. * * The method is useful for requesting Popup forms through ajax (e.g ThickBox). * You can request any view specified in the $allowedViews array. * * Call this method using GET method with the following parameters. * - viewName string Name of the view. * * Response body is the view content string. * * @return void */ public function getViewAction() { // Some views required objects to be pushed into it before displaying // the controller element is a callback that a Dummy Controller from which // this variables should be pushed. $allowedViews = array('blocks/new' => array()); // Prepare parameters. $viewName = filter_input(INPUT_GET, 'viewName', FILTER_SANITIZE_STRING); if (array_key_exists($viewName, $allowedViews) === FALSE) { $this->httpCode = '403 Forbidden'; } else { // Import view file. $viewInfo = $allowedViews[$viewName]; // Get view object. $view = CJTController::getView($viewName); // Push view variables. foreach (isset($viewInfo['vars']) ? $viewInfo['vars'] : array() as $var) { $view->{$var} = $_GET["view.{$var}"]; } // Some views required custom pushing, this is can // be done by the registered controller. if (isset($viewInfo['controller'])) { $viewController = $viewInfo['controller']; $this->{$viewController}($view); } // Set Content type. $this->httpContentType = "text/html"; // Get view content. $this->response = $view->getTemplate('default'); } }
/** * put your comment there... * * @param mixed $request */ public function route($loadView = null, $request = null) { // Only loading one controller is allowed. if (!$this->controller) { // Import view class. require_once CJTOOLBOX_MVC_FRAMEWOK . '/view.inc.php'; // Instantiate controller! $this->controller = $this->onsetcontroller(CJTController::getInstance($this->controllerName, $loadView, $request, $this->overrideControllersPath, $this->overrideControllersPrefix)); } return $this->controller; }
/** * put your comment there... * * @param mixed $model * @param mixed $params * @param mixed $file */ public static function getInstance($model, $params = array(), $file = null, $overrideModelsPath = null, $overrideModelsPrefix = null) { return CJTController::getModel($model, $params, $file, $overrideModelsPath, $overrideModelsPrefix); }