Advertisement
Guest User

Untitled

a guest
Nov 24th, 2020
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.70 KB | None | 0 0
  1. <?php
  2.  
  3. class GalleryAlbumGetListProcessor extends modObjectGetListProcessor {
  4.  
  5.     public $classKey = 'galAlbum';
  6.     public $objectType = 'gallery.album';
  7.     public $defaultSortField = 'id';
  8.     public $defaultSortDirection = 'DESC';
  9.     public $languageTopics = array('gallery:default');
  10.  
  11.  
  12.     /**
  13.      * We do a special check of permissions
  14.      * because our objects is not an instances of modAccessibleObject
  15.      *
  16.      * @return boolean|string
  17.      */
  18.     public function beforeQuery()
  19.     {
  20.         if (!$this->checkPermissions()) {
  21.             return $this->modx->lexicon('access_denied');
  22.         }
  23.  
  24.         return true;
  25.     }
  26.  
  27.  
  28.     /**
  29.      * @param xPDOQuery $c
  30.      *
  31.      * @return xPDOQuery
  32.      */
  33.     public function prepareQueryBeforeCount(xPDOQuery $c)
  34.     {
  35.         $query = trim($this->getProperty('query'));
  36.  
  37.         if ($query) {
  38.             $c->where(array(
  39.                 'name:LIKE' => "%{$query}%",
  40.                 'OR:gallery:LIKE' => "%{$query}%",
  41.             ));
  42.         }
  43.         $c->where(array(
  44.             'active' => 1,
  45.         ));
  46.  
  47.         return $c;
  48.     }
  49.  
  50.     public function prepareRow(xPDOObject $object) {
  51.         $objectArray = $object->toArray();
  52.         $objectArray['menu'] = array();
  53.         $objectArray['menu'][] = array(
  54.             'text' => $this->modx->lexicon('gallery.album_update'),
  55.             'handler' => 'this.updateAlbum',
  56.         );
  57.         $objectArray['menu'][] = '-';
  58.         $objectArray['menu'][] = array(
  59.             'text' => $this->modx->lexicon('gallery.album_remove'),
  60.             'handler' => 'this.removeAlbum',
  61.         );
  62.         return $objectArray;
  63.     }
  64. }
  65. return 'GalleryAlbumGetListProcessor';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement