/** * @param \Mirasvit\Blog\Model\Category $category * @return bool */ public function isCurrent($category) { if ($this->getCurrentCategory() && $this->getCurrentCategory()->getId() == $category->getId()) { return true; } return false; }
/** * @param Category $category * @return string */ public function getRssUrl($category = null) { if ($category) { return $this->getUrl('/rss/' . $category->getUrlKey(), 'rss'); } return $this->getUrl('/rss', 'rss'); }
/** * @param \Mirasvit\Blog\Model\Category $row * @return string */ public function getRowUrl($row) { return $this->getUrl('*/*/edit', ['id' => $row->getId()]); }
/** * @param \Mirasvit\Blog\Model\Category $category * @return $this */ public function addCategoryFilter($category) { $this->getSelect()->where("EXISTS (SELECT * FROM `{$this->getTable('mst_blog_category_post')}`\n AS `category_post`\n WHERE e.entity_id = category_post.post_id\n AND category_post.category_id in (?))", [0, $category->getId()]); return $this; }
/** * @param \Mirasvit\Blog\Model\Category $category * @param \Mirasvit\Blog\Model\Category $newParent * @param null|int $afterCategoryId * @return int */ protected function processPositions($category, $newParent, $afterCategoryId) { $table = $this->getEntityTable(); $connection = $this->getConnection(); $positionField = $connection->quoteIdentifier('position'); $bind = ['position' => new \Zend_Db_Expr($positionField . ' - 1')]; $where = ['parent_id = ?' => $category->getParentId(), $positionField . ' > ?' => $category->getPosition()]; $connection->update($table, $bind, $where); /** * Prepare position value */ if ($afterCategoryId) { $select = $connection->select()->from($table, 'position')->where('entity_id = :entity_id'); $position = $connection->fetchOne($select, ['entity_id' => $afterCategoryId]); $position += 1; } else { $position = 1; } $bind = ['position' => new \Zend_Db_Expr($positionField . ' + 1')]; $where = ['parent_id = ?' => $newParent->getId(), $positionField . ' >= ?' => $position]; $connection->update($table, $bind, $where); return $position; }