/** * * @return Ajde_Collection */ public function getCollection() { if (!isset($this->_collection)) { $collectionName = ucfirst($this->getModelName()) . 'Collection'; $this->_collection = new $collectionName(); $langFilter = false; if ($this->hasFilterLang()) { $langFilter = $this->getFilterLang(); } $lang = false; // Filter lang by parent (model) language if ($langFilter == 'parent') { $fieldName = $this->getName(); $parent = $this->getCrud()->getModel(); if (method_exists($parent, 'getLanguageField')) { $lang = $parent->get($parent->getLanguageField()); } } // Filter lang by current (page) language if ($langFilter == 'page') { $lang = Config::get('lang'); } if ($langFilter && $lang && method_exists($this->_collection, 'getLanguageField')) { $languageField = $this->_collection->getLanguageField(); $this->_collection->addFilter(new Where($languageField, Filter::FILTER_EQUALS, $lang)); } } return $this->_collection; }
public function getRowCount(Ajde_Collection $collection = null) { if (isset($collection)) { return $collection->count(true); } if (!isset($this->_rowCount)) { $sql = 'SELECT COUNT(*) AS count FROM ' . $this->_tableName; $connection = Ajde_Db::getInstance()->getConnection(); $statement = $connection->prepare($sql); $statement->execute(); $result = $statement->fetch(PDO::FETCH_ASSOC); $this->_rowCount = $result['count']; } return $this->_rowCount; }
public function load() { if (Ajde::app()->getRequest()->getParam('filterPublished', false) == true) { $this->filterPublished(); } return parent::load(); }
public function __construct(Ajde_Shop_Cart $cart = null) { parent::__construct(); if (isset($cart)) { $this->setCart($cart); $this->addFilter(new Ajde_Filter_Where('cart', Ajde_Filter::FILTER_EQUALS, $cart->getPK())); } }
public function load() { parent::load(); if ($this->count()) { $aclTimer = Ajde::app()->addTimer('<i>ACL validation for collection</i>'); $this->validateModels(); Ajde::app()->endTimer($aclTimer); } return $this->_items; }
/** * @param Ajde_Model|Ajde_Collection $object */ public function touchCache($object = null) { Ajde_Cache::getInstance()->updateHash(isset($object) ? $object->hash() : time()); }