コード例 #1
0
ファイル: Term.php プロジェクト: shashankkanungo/magento
 /**
  * Loads a category by an array of slugs
  * The array should be the order of slugs found in the URI
  * The whole slug array must match (including parent relationsips)
  *
  * @param array $slugs
  * @param Fishpig_Wordpress_Model_Term $object
  * @return false
  */
 public function loadBySlugs(array $slugs, Fishpig_Wordpress_Model_Term $object)
 {
     $slugs = array_reverse($slugs);
     $primarySlug = array_shift($slugs);
     try {
         $object->loadBySlug($primarySlug);
         if ($object->getId()) {
             $category = $object;
             foreach ($slugs as $slug) {
                 $parent = Mage::getModel($object->getResourceName())->loadBySlug($slug);
                 if ($parent->getId() !== $category->getParent()) {
                     throw new Exception('This path just ain\'t right, bro!');
                 }
                 $category->setParentTerm($parent);
                 $category = $parent;
             }
             if (!$category->getParentId()) {
                 return true;
             }
         }
     } catch (Exception $e) {
     }
     $object->setData(array())->setId(null);
     return false;
 }
コード例 #2
0
ファイル: Tag.php プロジェクト: GaynorH/prestigedrinks
 /**
  * Loads the posts belonging to this category
  *
  * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
  */
 public function getPostCollection()
 {
     if (!$this->hasPostCollection()) {
         $this->setPostCollection(parent::getPostCollection()->addTagIdFilter($this->getId()));
     }
     return $this->_getData('post_collection');
 }
コード例 #3
0
ファイル: Category.php プロジェクト: xiaoguizhidao/beut
 /**
  * Retrieve the URI for the category
  * This is a wrapper for the parent method and injects
  * the category base if WordPress is configured to use this
  *
  * @return string|false
  */
 public function getUri()
 {
     $helper = Mage::helper('wordpress/router');
     $uri = substr(parent::getUri(), strlen($this->getTaxonomy()) + 1);
     if (!$helper->categoryUrlHasBase()) {
         return $uri;
     }
     return $helper->getCategoryBase() . '/' . $uri;
 }
コード例 #4
0
ファイル: Term.php プロジェクト: GaynorH/prestigedrinks
 /**
  * Determine whether $post is in the current term
  *
  * @param Fishpig_Wordpress_Model_Term $term
  * @param int|Fishpig_Wordpress_Model_Post_Abstract $object
  * @return bool
  */
 public function containsPost($term, $object)
 {
     $objectId = is_object($object) ? $object->getId() : $object;
     if (!$objectId || $term->getItemCount() === 0) {
         return false;
     }
     $select = $this->_getReadAdapter()->select()->from($this->getTable('wordpress/term_relationship'), 'object_id')->where('term_taxonomy_id = ?', $term->getTermTaxonomyId())->where('object_id = ?', $objectId)->limit(1);
     return $this->_getReadAdapter()->fetchOne($select) !== false;
 }
コード例 #5
0
 /**
  * Retrieve the URI for $term
  *
  * @param Fishpig_Wordpress_Model_Term $term
  * @return false|string
  */
 public function getTermUri(Fishpig_Wordpress_Model_Term $term)
 {
     return $this->getUriById($term->getId(), $term->getTaxonomyType());
 }