Ejemplo n.º 1
0
 public static function getBlockDetailsByLangID($blockID, $langID)
 {
     $blockIndex = new BlocksIndex();
     $select = $blockIndex->select()->setIntegrityCheck(false)->from('BlocksIndex')->join('Blocks', 'Blocks.B_ID = BlocksIndex.BI_BlockID')->where('BlocksIndex.BI_LanguageID = ?', $langID)->where('BlocksIndex.BI_BlockID= ?', $blockID);
     $block = $blockIndex->fetchRow($select);
     if (empty($block)) {
         $newrow = $blockIndex->createRow(array('BI_BlockID' => $blockID, 'BI_LanguageID' => $langID));
         $newrow->save();
         $block = $blockIndex->fetchRow($select);
     }
     return $block;
 }
Ejemplo n.º 2
0
 protected function deleteBlock($blockID)
 {
     /*         * ******************************* */
     /* DELETE ROW IN BLOCK TABLE      */
     /*         * ******************************* */
     // define block
     $block = new Blocks();
     $where = 'B_ID = ' . $blockID;
     // get informations of the block to delete
     $blockDetails = $block->fetchRow($where);
     $position = $blockDetails->B_Position;
     $pageID = $blockDetails->B_PageID;
     // delete the block
     $block->delete($where);
     /*         * ******************************* */
     /* DELETE ROWS IN BLOCKINDEX TABLE */
     /*         * ******************************* */
     // define blockIndex
     $blockIndex = new BlocksIndex();
     $where = 'BI_BlockID = ' . $blockID;
     // delete all blockIndex
     $blockIndex->delete($where);
     /*         * ******************************* */
     /* UPDATE POSITION ON BLOCK TABLE */
     /*         * ******************************* */
     // update position of all block in the same page
     $db = Zend_Registry::get("db");
     $where = "(B_Position > " . $position . ") AND B_PageID = " . $pageID;
     $db->update('Blocks', array('B_Position' => new Zend_Db_Expr('B_Position - 1')), $where);
     /*         * ******************************* */
     /* DELETE ROWS IN PARAMETERS TABLE */
     /*         * ******************************* */
     $blockParameters = new Parameters();
     $where = 'P_BlockID = ' . $blockID;
     $blockParameters->delete($where);
 }