Example #1
0
 public function initialize()
 {
     $vers = $this->modx->getVersionData();
     $ver_comp = version_compare($vers['full_version'], '2.3.0');
     if ($ver_comp >= 0) {
         $this->editAction = 'resource/update';
     } else {
         $editAction = $this->modx->getObject('modAction', array('namespace' => 'core', 'controller' => 'resource/update'));
         $this->editAction = $editAction->get('id');
     }
     $parent = $this->getProperty('parent');
     if (empty($parent)) {
         return $this->failure($this->modx->lexicon('gridclasskey.parent_missing_err'));
     }
     $this->parentProperties = $this->modx->getObject('modResource', $parent)->getProperties('gridclasskey');
     $sort = $this->getProperty('sort');
     if (!empty($sort)) {
         $this->setProperty('sort', $this->modx->escape($sort));
     } else {
         if ($this->parentProperties && $this->parentProperties['grid-sortby']) {
             $this->setProperty('sort', $this->modx->escape($this->parentProperties['grid-sortby']));
             $this->setProperty('dir', in_array(strtolower($this->parentProperties['grid-sortdir']), array('asc', 'desc')) ? strtolower($this->parentProperties['grid-sortdir']) : 'desc');
         }
     }
     $condition = $this->getProperty('condition', 'or');
     $this->condition = $condition === 'or' ? 'orCondition' : 'andCondition';
     $limit = $this->getProperty('limit');
     if ($limit === 0) {
         $this->setProperty('limit', $this->modx->getOption('default_per_page'));
     }
     return parent::initialize();
 }