Server : Apache System : Linux indy02.toastserver.com 3.10.0-962.3.2.lve1.5.85.el7.x86_64 #1 SMP Thu Apr 18 15:18:36 UTC 2024 x86_64 User : palandch ( 1163) PHP Version : 7.1.33 Disable Function : NONE Directory : /home/palandch/www/core/model/modx/processors/context/ |
<?php /** * Grabs a list of contexts. * * @param integer $start (optional) The record to start at. Defaults to 0. * @param integer $limit (optional) The number of records to limit to. Defaults * to 20. * @param string $sort (optional) The column to sort by. Defaults to key. * @param string $dir (optional) The direction of the sort. Defaults to ASC. * * @package modx * @subpackage processors.context */ class modContextGetListProcessor extends modObjectGetListProcessor { public $classKey = 'modContext'; public $permission = 'view_context'; public $languageTopics = array('context'); public $defaultSortField = 'key'; /** @var boolean $canEdit Determines whether or not the user can edit a Context */ public $canEdit = false; /** @var boolean $canRemove Determines whether or not the user can remove a Context */ public $canRemove = false; public function initialize() { $initialized = parent::initialize(); $this->setDefaultProperties(array( 'search' => '', 'exclude' => '', )); $this->canEdit = $this->modx->hasPermission('edit_context'); $this->canRemove = $this->modx->hasPermission('delete_context'); return $initialized; } public function prepareQueryBeforeCount(xPDOQuery $c) { $search = $this->getProperty('search'); if (!empty($search)) { $c->where(array( 'key:LIKE' => '%'.$search.'%', 'OR:description:LIKE' => '%'.$search.'%', )); } $exclude = $this->getProperty('exclude'); if (!empty($exclude)) { $c->where(array( 'key:NOT IN' => is_string($exclude) ? explode(',',$exclude) : $exclude, )); } return $c; } /** * {@inheritDoc} * @param xPDOObject $object * @return array */ public function prepareRow(xPDOObject $object) { $contextArray = $object->toArray(); $contextArray['perm'] = array(); if ($this->canEdit) { $contextArray['perm'][] = 'pedit'; } if (!in_array($object->get('key'),array('mgr','web')) && $this->canRemove) { $contextArray['perm'][] = 'premove'; } return $contextArray; } } return 'modContextGetListProcessor';