Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Get a list of Categories
- *
- * @package miniShop
- * @subpackage processors
- */
- class CatsGetListProcessor extends modObjectGetListProcessor {
- public $classKey = 'modResource';
- public $languageTopics = array('resource');
- public $defaultSortField = 'pagetitle';
- public function prepareQueryBeforeCount(xPDOQuery $c) {
- $query = $this->getProperty('query');
- $c->select(array('modResource.id','modResource.pagetitle'));
- $c->where(array(
- 'isfolder' => 1,
- 'template' => 13,
- 'deleted' => 0,
- 'published' => 1
- ));
- if (!empty($query)) {
- $c->where(array(
- 'pagetitle:LIKE' => $query.'%'
- ));
- }
- return $c;
- }
- public function getData() {
- $data = array();
- $limit = intval($this->getProperty('limit'));
- $start = intval($this->getProperty('start'));
- /* query for chunks */
- $c = $this->modx->newQuery($this->classKey);
- $c = $this->prepareQueryBeforeCount($c);
- $data['total'] = $this->modx->getCount($this->classKey,$c);
- $c = $this->prepareQueryAfterCount($c);
- $sortClassKey = $this->getSortClassKey();
- $sortKey = $this->modx->getSelectColumns($sortClassKey,$this->getProperty('sortAlias',$sortClassKey),'',array($this->getProperty('sort')));
- if (empty($sortKey)) $sortKey = $this->getProperty('sort');
- $c->sortby($sortKey,$this->getProperty('dir'));
- if ($limit > 0) {
- $c->limit($limit,$start);
- }
- if ($c->prepare() && $c->stmt->execute()) {
- $data['results'] = $c->stmt->fetchAll(PDO::FETCH_ASSOC);
- }
- return $data;
- }
- public function prepareRow($array) {
- return $array;
- }
- }
- return 'CatsGetListProcessor';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement