/** * @param xPDOObject $object * * @return array */ public function prepareRow(xPDOObject $object) { $array = parent::prepareRow($object); $allowedFields = array('id' => true, 'template' => true, 'pagetitle' => true, 'parent' => true, 'published' => true, 'deleted' => true, 'menuindex' => true, 'createdon' => true, 'publishedon' => true, 'context_key' => true); $array = array_intersect_key($array, $allowedFields); $datetime = date_create($array['createdon']); $array['createdon'] = date_format($datetime, $this->modx->getOption('manager_date_format') . ' ' . $this->modx->getOption('manager_time_format')); $array['preview_url'] = $this->modx->makeUrl($array['id'], $array['context_key']); $array['actions'] = array(); if ($this->modx->hasPermission('edit_document')) { $array['actions'][] = array('cls' => '', 'icon' => 'icon icon-pencil-square-o', 'title' => $this->modx->lexicon('edit'), 'action' => 'editResource', 'button' => true, 'menu' => true); } $array['actions'][] = array('cls' => '', 'icon' => 'icon icon-globe', 'title' => $this->modx->lexicon('preview'), 'action' => 'previewResource', 'button' => true, 'menu' => true); if ($this->modx->hasPermission('save_document')) { $array['actions'][] = array('cls' => '', 'icon' => 'icon icon-wrench', 'title' => $this->modx->lexicon('moddevtools_template_change'), 'action' => 'changeTemplate', 'button' => true, 'menu' => true); } if ($this->modx->hasPermission('publish_document')) { if (!$array['published']) { $array['actions'][] = array('cls' => '', 'icon' => 'icon icon-power-off action-green', 'title' => $this->modx->lexicon('publish'), 'action' => 'publishResource', 'button' => true, 'menu' => true); } else { $array['actions'][] = array('cls' => '', 'icon' => 'icon icon-power-off action-gray', 'title' => $this->modx->lexicon('unpublish'), 'action' => 'unpublishResource', 'button' => true, 'menu' => true); } } if ($this->modx->hasPermission('delete_document')) { if (!$array['deleted']) { // Remove $array['actions'][] = array('cls' => '', 'icon' => 'icon icon-trash-o action-red', 'title' => $this->modx->lexicon('remove'), 'action' => 'removeResource', 'button' => true, 'menu' => true); } else { $array['actions'][] = array('cls' => '', 'icon' => 'icon icon-trash-o action-green', 'title' => $this->modx->lexicon('undelete'), 'action' => 'undeleteResource', 'button' => true, 'menu' => true); } } return $array; }
public function prepareRow(xPDOObject $object) { $objectArray = parent::prepareRow($object); if ($this->getProperty('combo', false)) { $objectArray = array('id' => $objectArray['id'], 'pagetitle' => $objectArray['pagetitle']); } return $objectArray; }
/** * @param object $object * @return array */ public function prepareRow(xPDOObject $object) { $resourceArray = parent::prepareRow($object); foreach ($resourceArray as $field => $value) { if (!in_array($field, $this->selectedFields) && $field !== 'published' && $field !== 'deleted' && $field !== 'hidemenu' && $field !== 'context_key' && $field !== 'isfolder') { unset($resourceArray[$field]); continue; } // avoid null on returns $resourceArray[$field] = $resourceArray[$field] !== null ? $resourceArray[$field] : ''; if (!empty($this->selectedTVFields)) { $key = array_search($field, $this->selectedTVFields); if (is_numeric($key)) { $resourceArray[$field . '_output'] = $object->getTVValue($field); } } } if (isset($resourceArray['publishedon'])) { $publishedon = strtotime($resourceArray['publishedon']); $resourceArray['publishedon_date'] = strftime($this->modx->getOption('gridclasskey.mgr_date_format', null, '%b %d'), $publishedon); $resourceArray['publishedon_time'] = strftime($this->modx->getOption('gridclasskey.mgr_time_format', null, '%H:%I %p'), $publishedon); $resourceArray['publishedon'] = strftime('%b %d, %Y %H:%I %p', $publishedon); } if (!empty($this->parentProperties)) { foreach ($this->parentProperties['fields'] as $field) { if ($field['type'] === 'snippet') { $scriptProperties = $resourceArray; unset($scriptProperties[$field['name']]); $resourceArray[$field['name']] = $this->modx->runSnippet($field['name'], $scriptProperties); } if (!empty($field['output_filter'])) { $resourceArray[$field['name']] = $this->_outputFilter($resourceArray[$field['name']], $field['output_filter']); if (isset($resourceArray[$field['name'] . '_output']) && !empty($resourceArray[$field['name'] . '_output'])) { $resourceArray[$field['name'] . '_output'] = $this->_outputFilter($resourceArray[$field['name'] . '_output'], $field['output_filter']); } } } } $resourceArray['action_edit'] = '?a=' . $this->editAction . '&id=' . $resourceArray['id']; $this->modx->getContext($resourceArray['context_key']); $resourceArray['preview_url'] = $this->modx->makeUrl($resourceArray['id'], $resourceArray['context_key'], null, 'full'); $c = $this->modx->newQuery('modResource'); $c->where(array('parent' => $resourceArray['id'])); $c->limit(1); $resourceArray['has_children'] = (bool) $this->modx->getCount('modResource', $c); return $resourceArray; }