Esempio n. 1
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;
 }
Esempio n. 2
0
 /**
  * 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;
 }