Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class GalleryAlbumGetListProcessor extends modObjectGetListProcessor {
- public $classKey = 'galAlbum';
- public $objectType = 'gallery.album';
- public $defaultSortField = 'id';
- public $defaultSortDirection = 'DESC';
- public $languageTopics = array('gallery:default');
- /**
- * We do a special check of permissions
- * because our objects is not an instances of modAccessibleObject
- *
- * @return boolean|string
- */
- public function beforeQuery()
- {
- if (!$this->checkPermissions()) {
- return $this->modx->lexicon('access_denied');
- }
- return true;
- }
- /**
- * @param xPDOQuery $c
- *
- * @return xPDOQuery
- */
- public function prepareQueryBeforeCount(xPDOQuery $c)
- {
- $query = trim($this->getProperty('query'));
- if ($query) {
- $c->where(array(
- 'name:LIKE' => "%{$query}%",
- 'OR:gallery:LIKE' => "%{$query}%",
- ));
- }
- $c->where(array(
- 'active' => 1,
- ));
- return $c;
- }
- public function prepareRow(xPDOObject $object) {
- $objectArray = $object->toArray();
- $objectArray['menu'] = array();
- $objectArray['menu'][] = array(
- 'text' => $this->modx->lexicon('gallery.album_update'),
- 'handler' => 'this.updateAlbum',
- );
- $objectArray['menu'][] = '-';
- $objectArray['menu'][] = array(
- 'text' => $this->modx->lexicon('gallery.album_remove'),
- 'handler' => 'this.removeAlbum',
- );
- return $objectArray;
- }
- }
- return 'GalleryAlbumGetListProcessor';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement