コード例 #1
0
 /**
  * put your comment there...
  * 
  */
 public function upgrade()
 {
     // Save backup in backup table!
     $backup = $this->current();
     // Change 'time' field to 'created'!
     // Convert formatted date to mysal date!
     $backup['created'] = $backup['time'];
     // User author Id instead of name and change 'author' field to 'owner'!
     $backup['owner'] = get_user_by('login', $backup['author'])->ID;
     $backup['type'] = 'blocks';
     // For now we support only blocks backups!
     // Load blocks into blocks iterator before destroying deprectaed fields.
     $blocks = new CJTInstallerBlocks03($backup['data'], CJTInstallerBlocks03::BLOCK_TYPE_BACKUP);
     // Remove deprecated fields!
     $backup = array_diff_key($backup, array_flip(array('time', 'author', 'data')));
     /// Add backup and get its ID using OLD style table (not xTable)!!
     // Import dependecneis.
     cssJSToolbox::import('tables:backups.php');
     // Insert backup record.
     $backupsTable = new CJTBackupsTable(cssJSToolbox::getInstance()->getDBDriver());
     $backupsTable->insert($backup);
     $backupId = $backupsTable->getDBDriver()->processQueue()->getInsertId();
     // Insert all blocks!
     foreach ($blocks as &$block) {
         // Associate every block with the created backup!
         $block['backupId'] = $backupId;
         // Upgrade block!
         $blocks->upgrade();
         $blocks->model->save();
     }
     return $this;
 }
コード例 #2
0
    /**
     * 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'));
    }
コード例 #3
0
ファイル: block.php プロジェクト: JSreactor/MarketCrater.com
 /**
  * put your comment there...
  * 
  */
 public function downloadCodeFileAction()
 {
     // BlockId, currentActiveFile.
     $blockId = $_GET['blockId'];
     $fileId = $_GET['fileId'];
     $returnAs = $_GET['returnAs'];
     // Get current File Code.
     $tblCodeFile = new CJTBlockFilesTable(cssJSToolbox::getInstance()->getDBDriver());
     $codeFile = $tblCodeFile->set('id', $fileId)->set('blockId', $blockId)->load()->getData();
     // Return as downloadable-file or JSON.
     if ($returnAs == 'file') {
         // Get Download File info.
         $extension = $codeFile->type ? cssJSToolbox::$config->templates->types[$codeFile->type]->extension : 'txt';
         $file = "{$codeFile->name}.{$extension}";
         // Response Header parameters.
         header('Content-Description: File Transfer');
         header("Content-Disposition: attachment; filename=\"{$file}\"");
         //<<< Note the " " surrounding the file name
         header('Content-Transfer-Encoding: binary');
         header('Connection: Keep-Alive');
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
         header('Content-Length: ' . strlen($codeFile->code));
         // AJAX Controller parameters.
         $this->httpContentType = 'application/octet-stream';
     }
     // Output code.
     $this->response = $codeFile->code;
 }
コード例 #4
0
 /**
  * put your comment there...
  * 
  */
 protected function prepareItems()
 {
     CJTxTable::import('author');
     $internalAuthorsFlag = CJTAuthorTable::FLAG_SYS_AUTHOR;
     // Query all dates (without time!) or internal authors.
     $query = " SELECT DISTINCT(DATE(t.creationDate)) `text`\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM #__cjtoolbox_templates t\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN #__cjtoolbox_authors a\n\t\t\t\t\t\t\t\t\t\t\t\t\tON  t.authorId = a.id\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE (a.attributes & {$internalAuthorsFlag}) = 0\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY `text`;";
     $this->items = cssJSToolbox::getInstance()->getDBDriver()->select($query);
 }
コード例 #5
0
ファイル: groups.php プロジェクト: JSreactor/MarketCrater.com
 /**
  * put your comment there...
  * 
  * @param mixed $formId
  * @return CJT_Models_Block_Parameters_Form_Groups
  */
 public function __construct($formId)
 {
     // Initialize.
     $this->formId = $formId;
     $dbDriver = cssJSToolbox::getInstance()->getDBDriver();
     // Query groups.
     $groups = $dbDriver->select("SELECT * FROM #__cjtoolbox_form_groups g LEFT JOIN #__cjtoolbox_form_group_xfields xf ON g.id = xf.groupId WHERE g.formId = {$this->formId};", ARRAY_A);
     parent::__construct($groups);
 }
コード例 #6
0
 /**
  * put your comment there...
  * 
  */
 protected function prepareItems()
 {
     CJTxTable::import('author');
     $internalAuthorsFlag = CJTAuthorTable::FLAG_SYS_AUTHOR;
     // Query CJT Authors + Wordpress build-in local users.
     $query = " SELECT a.id, a.name `text`\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM #__cjtoolbox_authors a\n\t\t\t\t\t\t\t\t\t\t\t\t\tRIGHT JOIN #__cjtoolbox_templates t\n\t\t\t\t\t\t\t\t\t\t\t\t\tON a.id = t.authorId\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE (a.attributes & {$internalAuthorsFlag}) = 0\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY `text`";
     // Get all exists authors
     $this->items = cssJSToolbox::getInstance()->getDBDriver()->select($query);
 }
コード例 #7
0
    /**
     * put your comment there...
     * 
     */
    protected function prepareItems()
    {
        // Query CJT Authors + Wordpress build-in local users.
        $query = ' SELECT o.ID id, o.user_login `text`
													FROM #__wordpress_users o
													RIGHT JOIN #__cjtoolbox_templates t
													ON o.ID = t.ownerId ORDER BY `text`';
        // Get all exists authors
        $this->items = cssJSToolbox::getInstance()->getDBDriver()->select($query);
    }
コード例 #8
0
ファイル: block.php プロジェクト: JSreactor/MarketCrater.com
 /**
  * put your comment there...
  * 
  */
 public function getPackageInfo()
 {
     // Initialize.
     $driver = cssJSToolbox::getInstance()->getDBDriver();
     // Query package info for the current block.
     $query = "SELECT p.id, p.author, p.webSite\n\t\t\t\t\t\t\t\t\t\t\tFROM #__cjtoolbox_packages p RIGHT JOIN #__cjtoolbox_package_objects o\n\t\t\t\t\t\t\t\t\t\t\tON p.id = o.packageId AND o.objectType = 'block'\n\t\t\t\t\t\t\t\t\t\t\tWHERE o.objectId = {$this->id};";
     // Exec!
     $packageInfo = $driver->getRow($query, ARRAY_A);
     return $packageInfo;
 }
コード例 #9
0
 /**
  * put your comment there...
  * 
  */
 protected function prepareItems()
 {
     // Import dependencies.
     CJTxTable::import('template-revision');
     CJTxTable::import('author');
     $lastVersionFlag = CJTTemplateRevisionTable::FLAG_LAST_REVISION;
     $internalAuthorsFlag = CJTAuthorTable::FLAG_SYS_AUTHOR;
     // Query all dates (without time!).
     $query = " SELECT DISTINCT(DATE(r.dateCreated)) `text` \n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM #__cjtoolbox_template_revisions r\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN #__cjtoolbox_templates t\n\t\t\t\t\t\t\t\t\t\t\t\t\tON  r.templateId = t.id\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN #__cjtoolbox_authors a\n\t\t\t\t\t\t\t\t\t\t\t\t\tON  t.authorId = a.id\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE (r.attributes & {$lastVersionFlag}) AND (a.attributes & {$internalAuthorsFlag}) = 0\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY `text`";
     $this->items = cssJSToolbox::getInstance()->getDBDriver()->select($query);
 }
コード例 #10
0
 /**
  * put your comment there...
  * 
  */
 public function exec()
 {
     // Initialize!
     $driver = cssJSToolbox::getInstance()->getDBDriver();
     // Execute all statements!
     foreach ($this->statements as $statement) {
         // Terminate the statement with ;
         $statement = "{$statement};";
         // Execute statement!
         $driver->exec($statement);
     }
 }
コード例 #11
0
 /**
  * put your comment there...
  * 
  */
 public function getItems()
 {
     // Initializing!
     $driver = cssJSToolbox::getInstance()->getDBDriver();
     // Get common quiery parts!@
     $query = $this->getItemsQuery();
     // Add fields list!
     $query['select'] = 'b.id, b.name title, b.owner, f.name formTitle';
     $query = "SELECT {$query['select']} FROM {$query['from']} WHERE {$query['where']};";
     // Retrieve blocks!
     return $driver->select($query);
 }
コード例 #12
0
 /**
  * put your comment there...
  * 
  */
 public function id()
 {
     $id = false;
     // If its a normal block just get the id from the KEY!
     if ($this->type == self::BLOCK_TYPE_BACKUP) {
         $dbDriver = cssJSToolbox::getInstance()->getDBDriver();
         $blocksTable = new CJTBlocksTable($dbDriver);
         $id = $blocksTable->getNextId();
     } else {
         // If backup block generate new ID!
         $id = parent::id();
     }
     return $id;
 }
コード例 #13
0
 /**
  * put your comment there...
  * 
  */
 protected function prepareItems()
 {
     if (isset($this->options['result']) && $this->options['result'] == 'fullList') {
         $this->items['published']['text'] = cssJSToolbox::getText('published');
         $this->items['draft']['text'] = cssJSToolbox::getText('draft');
         $this->items['trash']['text'] = cssJSToolbox::getText('trash');
     } else {
         CJTxTable::import('author');
         $internalAuthorsFlag = CJTAuthorTable::FLAG_SYS_AUTHOR;
         // Query all template state exluding Internal authors.
         $query = "SELECT DISTINCT(state) `text` \n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM #__cjtoolbox_templates t\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN #__cjtoolbox_authors a\n\t\t\t\t\t\t\t\t\t\t\t\t\tON  t.authorId = a.id\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE (a.attributes & {$internalAuthorsFlag}) = 0\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY `text`";
         $this->items = cssJSToolbox::getInstance()->getDBDriver()->select($query);
     }
 }
コード例 #14
0
 /**
  * put your comment there...
  * 
  */
 protected function assignValues()
 {
     // Initialize.
     $driver = cssJSToolbox::getInstance()->getDBDriver();
     // For every parameter assign the values.
     foreach ($this->getParams() as $param) {
         // Query all values.
         $recset = $driver->select("SELECT * \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM #__cjtoolbox_parameter_typedef\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE parameterId = {$param->getId()}", ARRAY_A);
         foreach ($recset as $valueRow) {
             $param->addValue(new CJT_Models_Block_Parameters_Form_Value($valueRow));
         }
     }
     return $this;
 }
コード例 #15
0
ファイル: file.php プロジェクト: JSreactor/MarketCrater.com
 /**
  * put your comment there...
  * 
  */
 public function transit()
 {
     // Get block element.
     $register = $this->register();
     $blockId = $register['blockId'];
     // CodeFiles table.
     $tblCodeFile = new CJTBlockFilesTable(cssJSToolbox::getInstance()->getDBDriver());
     // Load Code Files if required.
     $register['packageParser']->fetchProperty($this->getNode(), 'code');
     // Fetch form data / All scalar elements!
     $codeFileData = new CJT_Framework_Xml_Fetchscalars($this->getNode());
     // Insert Code File.
     $tblCodeFile->setData($codeFileData)->set('blockId', $blockId)->save(true, true);
     // Chaining.
     return $this;
 }
コード例 #16
0
 /**
  * put your comment there...
  * 
  */
 protected function pinsMap()
 {
     // Initialize.
     $blockId = $this->getBlockId();
     $params = $this->getTypeParams();
     $pinsMap = array();
     // Prepare block pinned items.
     $dbDriver = cssJSToolbox::getInstance()->getDBDriver();
     $pinsTable = new CJTBlockPinsTable($dbDriver);
     $pins = $pinsTable->get(null, array('blockId' => $blockId, 'pin' => $params['group']));
     // Create ITEM-ID => VALUE array map for the retrieved pins.
     foreach ($pins as $pin) {
         $pinsMap[$pin->value] = true;
     }
     // Returns.
     return $pinsMap;
 }
コード例 #17
0
 /**
  * put your comment there...
  * 
  */
 protected function prepareItems()
 {
     if (isset($this->options['result']) && $this->options['result'] == 'fullList') {
         $this->items['release']['text'] = cssJSToolbox::getText('release');
         $this->items['beta']['text'] = cssJSToolbox::getText('beta');
         $this->items['alpha']['text'] = cssJSToolbox::getText('alpha');
         $this->items['release-candidate']['text'] = cssJSToolbox::getText('release-candidate');
         $this->items['revision']['text'] = cssJSToolbox::getText('revision');
     } else {
         // Import dependencies.
         CJTxTable::import('template-revision');
         CJTxTable::import('author');
         $lastVersionFlag = CJTTemplateRevisionTable::FLAG_LAST_REVISION;
         $internalAuthorsFlag = CJTAuthorTable::FLAG_SYS_AUTHOR;
         $query = "SELECT DISTINCT(r.state) `text` \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM #__cjtoolbox_template_revisions r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN #__cjtoolbox_templates t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tON  r.templateId = t.id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN #__cjtoolbox_authors a\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tON  t.authorId = a.id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE (r.attributes & {$lastVersionFlag}) AND (a.attributes & {$internalAuthorsFlag}) = 0\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY `text`";
         $this->items = cssJSToolbox::getInstance()->getDBDriver()->select($query);
     }
 }
コード例 #18
0
ファイル: blocks.php プロジェクト: JSreactor/MarketCrater.com
 /**
  * put your comment there...
  * 
  * @param mixed $state
  */
 public function setState($state)
 {
     # Initialize
     $dbDriver = cssJSToolbox::getInstance()->getDBDriver();
     $statePackages =& $this->statePackage;
     # Build packages Id SQL  IN-OPERATO list
     $pcksSQLIdList = array();
     foreach ($statePackages->getInstalledPackages() as $name => $pck) {
         # Push Id.
         $pcksSQLIdList[] = $pck['id'];
     }
     $pcksSQLIdList = implode(',', $pcksSQLIdList);
     # Build query
     $query = "UPDATE\n\t\t\t\t\t\t\t\t(#__cjtoolbox_packages p RIGHT JOIN #__cjtoolbox_package_objects po ON p.id = po.packageId\n\t\t\t\t\t\t\t\tLEFT JOIN #__cjtoolbox_blocks b ON po.objectId = b.id)\n\t\t\t\t\t\t\t\tSET state = '{$state}'\n\t\t\t\t\t\t\t\tWHERE p.id IN ({$pcksSQLIdList}) AND po.objectType = 'block';";
     # Update state for all blocks associated with all installed packages
     $dbDriver->exec($query);
     # Chain
     return $this;
 }
コード例 #19
0
 /**
  * put your comment there...
  * 
  */
 protected function queryParameters()
 {
     // Initialize.
     $parameters = array();
     $query = $this->getQuery();
     $recset = cssJSToolbox::getInstance()->getDBDriver()->select($query, ARRAY_A);
     // Prototype to parameter model.
     foreach (new ArrayIterator($recset) as $row) {
         // Instantiate parameter model object.
         $param = $this->createModelObject($row);
         // Add as child if it has a parent or add in the root if not.
         if (!$param->getParent()) {
             // Add to list.
             $parameters[$param->getId()] = $param;
         } else {
             // Add as child parameter!
             $parameters[$param->getParent()]->addChild($param);
         }
         // Flat parameters list.
         $this->params[] = $param;
     }
     // Return only root parameters.
     return $parameters;
 }
コード例 #20
0
 /**
  * put your comment there...
  * 
  */
 public function __construct()
 {
     $this->dbDriver =& cssJSToolbox::getInstance()->getDBDriver();
 }
コード例 #21
0
 /**
  * put your comment there...
  * 
  */
 public function switchAction()
 {
     // Block id.
     $blockId = (int) $_GET['blockId'];
     $fileId = (int) $_GET['codeFileId'];
     // Read Code File Record.
     $tblCodeFiles = new CJTBlockFilesTable(cssJSToolbox::getInstance()->getDBDriver());
     $codeFile = $tblCodeFiles->set('blockId', $blockId)->set('id', $fileId)->load()->getData();
     // Set author Active Code File Id.
     // TODO: Setting Active File ID should be in the MODEL!
     update_user_meta(get_current_user_id(), "cjt_block_active_file_{$blockId}", $fileId);
     // Return code file.
     $this->response = $codeFile;
 }
コード例 #22
0
 /**
  * put your comment there...
  * 
  * @param mixed $object
  * @param mixed $dbDriver
  * @return CJTxTable
  */
 public static function getInstance($type, $dbDriver = null, $query = null)
 {
     // Filter all parameters.
     extract(self::trigger('CJTxTable.instantiate', compact('type', 'dbDriver', 'query')));
     // Getting dbdriver!
     $dbDriver = !$dbDriver ? cssJSToolbox::getInstance()->getDBDriver() : $dbDriver;
     // Import table file.
     self::import($type);
     // Get class name.
     $type = str_replace(' ', '', ucwords(str_replace(array('-', '_'), ' ', $type)));
     $className = "CJT{$type}Table";
     $table = new $className($dbDriver);
     if ($query) {
         $table->load($query);
     }
     return $table;
 }
コード例 #23
0
ファイル: block.php プロジェクト: JSreactor/MarketCrater.com
 /**
  * put your comment there...
  * 
  * @param mixed $blockData
  */
 public static function arrangePins(&$blockData)
 {
     $pinsGroupNames = array_flip(array_merge(array_keys(self::getCustomPins()), array('pinPoint')));
     $dbDriver = cssJSToolbox::getInstance()->getDBDriver();
     $mdlBlock = new CJTBlocksModel();
     $block = $mdlBlock->getBlock($blockData->id, array(), array('id', 'pinPoint'));
     $submittedPins = array_intersect_key((array) $blockData, $pinsGroupNames);
     $assignedPins = array_intersect_key((array) $block, $pinsGroupNames);
     // Transfer assigned PinPoint from "FLAGGED INTEGER" TO "ARRAY" like
     // the other pins.
     $assignedPins['pinPoint'] = array_keys(CJT_Models_Block_Assignmentpanel_Helpers_Auxiliary::getInstance()->getPinsArray($assignedPins['pinPoint']));
     // Walk through all assigned pins.
     // Unassigned any item with 'value=false'.
     // Whenever an item is found on the submitted
     // pins it should be removed from the submitted list
     foreach ($submittedPins as $groupName => $submittedGroup) {
         // Get assigned pins group if found
         if (!isset($assignedPins[$groupName])) {
             // Initialize new assigned group array.
             $assignedPins[$groupName] = array();
         }
         $assignedGroup =& $assignedPins[$groupName];
         // For every submitted item there is three types.
         // 1. Already assigned :WHEN: (sync == true and value == true)
         // 2. Unassigned :WHEN: (value == false)
         // 3. Newly assigned :WHEN: (sync = false).
         foreach ($submittedGroup as $submittedPinId => $submittedPin) {
             // Unassigned pin
             if (!$submittedPin['value']) {
                 // Find the submittedPinId AssignedPins index.
                 $assignedIndex = array_search($submittedPinId, $assignedGroup);
                 // Unassigned it :REMOVE FROM ARRAY:
                 unset($assignedGroup[$assignedIndex]);
             } else {
                 if (!$submittedPin['sync']) {
                     // Add newly assigned item.
                     $assignedGroup[] = $submittedPinId;
                 }
             }
         }
     }
     // Copy all assigned pins back to the block object.
     foreach ($assignedPins as $groupName => $finalGroupAssigns) {
         $blockData->{$groupName} = $finalGroupAssigns;
     }
     // Important for caller short-circle condition.
     return true;
 }
コード例 #24
0
 /**
  * put your comment there...
  * 
  */
 protected function restoreRevisionAction()
 {
     // Initialize.
     $mdlBlocks = new CJTBlocksModel();
     $tblCodeFile = new CJTBlockFilesTable(cssJSToolbox::getInstance()->getDBDriver());
     // Get revision ID.
     $rId = (int) $_GET['rid'];
     $bId = (int) $_GET['bid'];
     // Get Revision Block + Revision Code.
     $revisionBlock = $mdlBlocks->getBlock($rId, array(), array('id', 'pinPoint', 'links', 'expressions', 'masterFile'));
     $revisionBlock->code = $tblCodeFile->set('blockId', $rId)->set('id', $revisionBlock->masterFile)->load()->getData()->code;
     // If code === null set it to empoty string '' as null woulod
     // prevent the field from being in the query, cause SQL error.
     if ($revisionBlock->code === null) {
         $revisionBlock->code = '';
     }
     // Code File Fields.
     $revisionBlock->activeFileId = $revisionBlock->masterFile;
     $revisionBlock->masterFile = null;
     // This is just for querying CodeFile. DONT UPDATE.
     // Restore Block.
     $revisionBlock->id = $bId;
     $mdlBlocks->update($revisionBlock, true);
     $mdlBlocks->save();
     // Return TRUE.
     $this->response = true;
 }
コード例 #25
0
        {
            // Add meta array for all blocks.
            $blocks = (array) get_option(self::BLOCKS_OPTION_NAME);
            foreach ($blocks as $id => $block) {
                // Add meta field to the exists blocks.
                // This method should called one time but for any reason
                // don't overriding exists values.
                if (!array_key_exists('meta', $block)) {
                    $blocks[$id]['meta'] = array();
                }
                $blocks[$id] = $this->cleanSingleBlock($block);
            }
            // Save blocks.
            update_option(cssJSToolbox::BLOCKS_OPTION_NAME, $blocks);
        }
        /**
         * Print CSSJtoolbox Debug message.
         * 
         * @param mixed $message
         */
        public static function printDebugMessage($message)
        {
            if (CJTOOLBOX_DEBUG) {
                echo "{$message}<br />";
            }
        }
    }
    // END Class
    // Let's start the plugin
    cssJSToolbox::getInstance();
}
コード例 #26
0
 /**
  * put your comment there...
  * 
  */
 public function finalize()
 {
     // Delete old blocks data!
     delete_option(self::BLOCKS_POINTER);
     // Drop cjdata table as is it no longed needed!
     $driver = cssJSToolbox::getInstance()->getDBDriver();
     $driver->exec('DROP TABLE #__cjtoolbox_cjdata;');
     // Clean up metabox meta data!
     $orderUserMetaKey = 'meta-box-order_settings_page_' . CJTPlugin::PLUGIN_REQUEST_ID;
     $closedUserMetaKey = 'closedpostboxes_settings_page_' . CJTPlugin::PLUGIN_REQUEST_ID;
     $driver->exec("DELETE FROM #__wordpress_usermeta WHERE meta_key IN ('{$orderUserMetaKey}', '{$closedUserMetaKey}');");
     return $this;
 }
コード例 #27
0
    /**
     * put your comment there...
     * 
     */
    public function getItems()
    {
        // Build query.
        $select = 'SELECT t.id, 
																					t.name, 
																					t.type, 
																					t.description, 
																					t.creationDate,
																					t.state, 
																					a.name author,
																					r.dateCreated lastModified,
																					r.version,
																					r.state developmentState';
        $queryBase = $this->getItemsQuery();
        // Paging.
        $itemsPerPage = $this->getItemsPerPage();
        // Get page no#.
        $page = !isset($this->inputs['paged']) ? 1 : $this->inputs['paged'];
        // Calculate start offset.
        $start = ($page - 1) * $itemsPerPage;
        $limit = " LIMIT {$start},{$itemsPerPage}";
        // Order.
        $orderBy = isset($this->inputs['orderby']) ? " ORDER BY {$this->inputs['orderby']} {$this->inputs['order']}" : '';
        // final query.
        $query = "{$select}{$queryBase['from']}{$queryBase['where']}{$orderBy}{$limit}";
        // Execute our query using MYSQL queue driver.
        $result = cssJSToolbox::getInstance()->getDBDriver()->select($query);
        return $result;
    }
コード例 #28
0
    /**
     * put your comment there...
     * 
     * @param mixed $blocks
     * @param mixed $types
     */
    public function getLinkedTemplates($blocks, $types = array('javascript', 'css'))
    {
        // Accept single id too!
        $blocks = (array) $blocks;
        // Import dependencies!
        cssJSToolbox::import('framework:db:mysql:xtable.inc.php', 'tables:template-revision.php');
        // Initialize vars.
        $templates = array();
        $query['select'] = 'SELECT t.id, t.type, t.queueName, r.version, r.file, bt.blockId';
        $query['from'] = 'FROM #__cjtoolbox_block_templates bt LEFT JOIN #__cjtoolbox_templates t
																				ON bt.templateId = t.id
																				LEFT JOIN #__cjtoolbox_template_revisions r
																				ON bt.templateId = r.templateId';
        // Filter by blocks ids and getting the last revision of the template!
        $query['where']['blocks'] = implode(',', $blocks);
        $query['where']['attributes'] = CJTTemplateRevisionTable::FLAG_LAST_REVISION;
        // Filter by type.
        $query['where']['types'] = '"' . implode('","', $types) . '"';
        // Where clause.
        $query['where'] = "WHERE bt.blockId IN ({$query['where']['blocks']}) AND \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(r.attributes & {$query['where']['attributes']}) AND \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.type IN ({$query['where']['types']})";
        // Filering!
        $query = $this->onquerylinkedtemplates($query);
        $query = "{$query['select']} {$query['from']} {$query['where']}";
        $templates = cssJSToolbox::getInstance()->getDBDriver()->select($query);
        return $templates;
    }
コード例 #29
0
 /**
  * put your comment there...
  * 
  */
 public function unlinkAll()
 {
     $query = "DELETE FROM #__cjtoolbox_block_templates \n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE blockId = {$this->inputs['blockId']}";
     cssJSToolbox::getInstance()->getDBDriver()->delete($query)->processQueue();
 }
コード例 #30
0
 /**
  * put your comment there...
  * 
  */
 protected function load()
 {
     // Bootstrap the Plugin!
     require_once $this->onimportbasefile('css-js-toolbox.class.php');
     cssJSToolbox::getInstance();
     // Load MVC framework core!
     require_once $this->onimportmodel(CJTOOLBOX_MVC_FRAMEWOK . '/model.inc.php');
     require_once $this->onimportcontroller(CJTOOLBOX_MVC_FRAMEWOK . '/controller.inc.php');
     // Chaining!
     return $this;
 }