Exemple #1
0
 /**
  * @param modResource $resource
  *
  * @return array
  */
 protected function _prepareResourceRow(modResource $resource)
 {
     $row = $resource->toArray('', false, true);
     $row['type'] = $row['children'] > 0 ? 'folder' : 'resource';
     $row['classes'] = $this->mxManager->getSubClasses($resource->get('class_key'), $this->_permissions);
     $row['pagetitle'] = html_entity_decode($row['pagetitle'], ENT_QUOTES, $this->modx->getOption('modx_charset', null, 'UTF-8'));
     unset($row['children']);
     return $row;
 }
Exemple #2
0
 /**
  * @return array|string
  */
 public function process()
 {
     $resource = $this->object->get($this->fields);
     //$this->formatDates($resource);
     $resource['preview_url'] = $this->getPreviewUrl();
     $resource['permissions'] = $this->getPermissions();
     $resource['type'] = $this->modx->getCount('modResource', array('parent' => $this->object->get('id'))) ? 'folder' : 'resource';
     $resource['syncsite'] = (bool) $this->modx->getOption('syncsite_default');
     /** @var modResource $parent */
     if (!empty($resource['parent']) && ($parent = $this->modx->getObject('modResource', $resource['parent']))) {
         $resource['parent_title'] = $parent->get('pagetitle');
     } else {
         $resource['parent_title'] = $this->modx->lexicon('no');
     }
     /** @var modTemplate $template */
     if (!empty($resource['template']) && ($template = $this->modx->getObject('modTemplate', $resource['template']))) {
         $resource['template_title'] = $template->get('templatename');
         $resource['tvs'] = $this->modx->getCount('modTemplateVarTemplate', array('templateid' => $template->get('id'))) > 0;
     } else {
         $resource['template_title'] = $this->modx->lexicon('no');
         $resource['tvs'] = false;
     }
     if (!empty($resource['content_type']) && ($content_type = $this->modx->getObject('modContentType', $resource['content_type']))) {
         $resource['content_type_title'] = $content_type->get('name');
     } else {
         $resource['content_type_title'] = $this->modx->lexicon('no');
     }
     if (!empty($resource['class_key']) && $resource['class_key'] == 'modWebLink') {
         if ($properties = $this->object->get('properties')) {
             $resource['responseCode'] = @$properties['core']['responseCode'];
         }
     }
     if (!empty($resource['parent']) && ($parent = $this->modx->getObject('modResource', $resource['parent']))) {
         $resource['classes'] = $this->mxManager->getSubClasses($parent->get('class_key'), $this->_permissions);
     } else {
         $resource['classes'] = $this->mxManager->getSubClasses('', $this->_permissions);
     }
     $resource = $this->_prepareResource($resource);
     return $this->success('', $resource);
 }