SHARE
TWEET

getlist.class.php

vanchelo Oct 10th, 2012 123 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * Get a list of Categories
  4.  *
  5.  * @package miniShop
  6.  * @subpackage processors
  7.  */
  8. class CatsGetListProcessor extends modObjectGetListProcessor {
  9.     public $classKey = 'modResource';
  10.     public $languageTopics = array('resource');
  11.     public $defaultSortField = 'pagetitle';
  12.  
  13.     public function prepareQueryBeforeCount(xPDOQuery $c) {
  14.         $query = $this->getProperty('query');
  15.         $c->select(array('modResource.id','modResource.pagetitle'));
  16.         $c->where(array(
  17.             'isfolder' => 1,
  18.             'template' => 13,
  19.             'deleted' => 0,
  20.             'published' => 1
  21.             ));
  22.         if (!empty($query)) {
  23.             $c->where(array(
  24.                 'pagetitle:LIKE' => $query.'%'
  25.             ));
  26.         }
  27.         return $c;
  28.     }
  29.     public function getData() {
  30.         $data = array();
  31.         $limit = intval($this->getProperty('limit'));
  32.         $start = intval($this->getProperty('start'));
  33.  
  34.         /* query for chunks */
  35.         $c = $this->modx->newQuery($this->classKey);
  36.         $c = $this->prepareQueryBeforeCount($c);
  37.         $data['total'] = $this->modx->getCount($this->classKey,$c);
  38.         $c = $this->prepareQueryAfterCount($c);
  39.  
  40.         $sortClassKey = $this->getSortClassKey();
  41.         $sortKey = $this->modx->getSelectColumns($sortClassKey,$this->getProperty('sortAlias',$sortClassKey),'',array($this->getProperty('sort')));
  42.         if (empty($sortKey)) $sortKey = $this->getProperty('sort');
  43.         $c->sortby($sortKey,$this->getProperty('dir'));
  44.         if ($limit > 0) {
  45.             $c->limit($limit,$start);
  46.         }
  47.         if ($c->prepare() && $c->stmt->execute()) {
  48.             $data['results'] = $c->stmt->fetchAll(PDO::FETCH_ASSOC);
  49.         }
  50.         return $data;
  51.     }
  52.     public function prepareRow($array) {
  53.         return $array;
  54.     }
  55. }
  56. return 'CatsGetListProcessor';
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top