/**
  * Recursively apply custom design settings to category if it's option
  * custom_use_parent_settings is setted to 1 while parent option is not
  *
  * @deprecated after 1.4.2.0-beta1, functionality moved to Mage_Catalog_Model_Design
  * @param EM_Blog_Model_Category $category
  *
  * @return EM_Blog_CategoryController
  */
 protected function _applyCustomDesignSettings($category)
 {
     if ($category->getCustomUseParentSettings() && $category->getLevel() > 1) {
         $parentCategory = $category->getParentCategory();
         if ($parentCategory && $parentCategory->getId()) {
             return $this->_applyCustomDesignSettings($parentCategory);
         }
     }
     $validityDate = $category->getCustomDesignDate();
     if (array_key_exists('from', $validityDate) && array_key_exists('to', $validityDate) && Mage::app()->getLocale()->isStoreDateInInterval(null, $validityDate['from'], $validityDate['to'])) {
         Mage::helper('blog')->setTheme($category->getData('custom_design'), $category->getData('custom_layout_update_xml'), $category->getData('custom_layout'), $this);
     } else {
         $this->loadLayout();
     }
     return $this;
 }
Example #2
0
 /**
  * Specify category filter for post collection
  *
  * @param EM_Blog_Model_Category $category
  * @return EM_Blog_Model_Resource_Post_Collection
  */
 public function addCategoryFilter(EM_Blog_Model_Category $category)
 {
     $this->_productLimitationFilters['category_id'] = $category->getId();
     if ($category->getIsAnchor()) {
         unset($this->_productLimitationFilters['category_is_anchor']);
     } else {
         $this->_productLimitationFilters['category_is_anchor'] = 1;
     }
     if ($this->getStoreId() == EM_Blog_Model_Abstract::DEFAULT_STORE_ID) {
         $this->_applyZeroStoreProductLimitations();
     } else {
         $this->_applyProductLimitations();
     }
     return $this;
 }
Example #3
0
 /**
  * Process positions of old parent category children and new parent category children.
  * Get position for moved category
  *
  * @param EM_Blog_Model_Category $category
  * @param EM_Blog_Model_Category $newParent
  * @param null|int $afterCategoryId
  * @return int
  */
 protected function _processPositions($category, $newParent, $afterCategoryId)
 {
     $table = $this->getEntityTable();
     $adapter = $this->_getWriteAdapter();
     $positionField = $adapter->quoteIdentifier('position');
     $bind = array('position' => new Zend_Db_Expr($positionField . ' - 1'));
     $where = array('parent_id = ?' => $category->getParentId(), $positionField . ' > ?' => $category->getPosition());
     $adapter->update($table, $bind, $where);
     /**
      * Prepare position value
      */
     if ($afterCategoryId) {
         $select = $adapter->select()->from($table, 'position')->where('entity_id = :entity_id');
         $position = $adapter->fetchOne($select, array('entity_id' => $afterCategoryId));
         $bind = array('position' => new Zend_Db_Expr($positionField . ' + 1'));
         $where = array('parent_id = ?' => $newParent->getId(), $positionField . ' > ?' => $position);
         $adapter->update($table, $bind, $where);
     } elseif ($afterCategoryId !== null) {
         $position = 0;
         $bind = array('position' => new Zend_Db_Expr($positionField . ' + 1'));
         $where = array('parent_id = ?' => $newParent->getId(), $positionField . ' > ?' => $position);
         $adapter->update($table, $bind, $where);
     } else {
         $select = $adapter->select()->from($table, array('position' => new Zend_Db_Expr('MIN(' . $positionField . ')')))->where('parent_id = :parent_id');
         $position = $adapter->fetchOne($select, array('parent_id' => $newParent->getId()));
     }
     $position += 1;
     return $position;
 }