/** * 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; }
/** * put your comment there... * * @param mixed $ids */ public function getBlocks($ids = array(), $filters = array(), $fields = array('*'), $returnType = OBJECT_K, $orderBy = array(), $useDefaultBackupFltr = true) { // initialize. $blocks = array(); $returnCodeFile = isset($filters['returnCodeFile']) && $filters['returnCodeFile'] == true; unset($filters['returnCodeFile']); // Create Tables objects. $blocksTable = new CJTBlocksTable($this->dbDriver); $pinsTable = new CJTBlockPinsTable($this->dbDriver); $blockFiles = new CJTBlockFilesTable($this->dbDriver); // Read blocks. $blocks = $blocksTable->get($ids, $fields, $filters, $returnType, $orderBy, $useDefaultBackupFltr); // Get only pins for retrieved blocks. $ids = array_keys($blocks); $pins = empty($ids) ? array() : $pinsTable->get($ids); // Push pins into blocks. foreach ($pins as $pin) { // Use pin name as object member. // Each pin is an array. // e.g blocks[ID]->pages[] = PAGE-ID. $blocks[$pin->blockId]->{$pin->pin}[] = $pin->value; } // Get active file code. // There always should be active file unless that the // requested block is never switched by current author before. // However we'll do that only if filters['returnCodeFile'] set to TRUE. if ($returnCodeFile) { foreach ($ids as $id) { if (!($activeFileId = $this->getCurrentAuthorBlockActiveFileId($id))) { // If first time use masterFile ID as he default. $activeFileId = $blocks[$id]->masterFile; } // Retreive code for block code file. $codeFile = (array) $blockFiles->setData(array('blockId' => $id, 'id' => $activeFileId))->load()->getData(); unset($codeFile['description']); $blocks[$id]->file = (object) $codeFile; // Also return the active file id withing the set. $blocks[$id]->activeFileId = $activeFileId; } } return $blocks; }
/** * put your comment there... * */ public function saveAction() { // Block id. $blockId = (int) $_POST['blockId']; $codeFile = filter_input(INPUT_POST, 'codeFile', FILTER_UNSAFE_RAW, FILTER_REQUIRE_ARRAY); // Add blockId to codeFile record. $codeFile['blockId'] = (int) $blockId; // Get Code Files Table. $tblCodeFiles = new CJTBlockFilesTable(cssJSToolbox::getInstance()->getDBDriver()); // Fill $tblCodeFiles->setData($codeFile)->save(false, true); // Return New CodeFile Data. $this->response = (array) $tblCodeFiles->getData(); }