Beispiel #1
0
 /**
  * Get all resource fields
  * @return void
  */
 public function getResourceFields()
 {
     $tplOptions = $this->getTemplateList();
     $fields = array('published' => array('type' => 'boolean', 'value' => $this->modx->getOption('publish_default')), 'template' => array('type' => 'select', 'options' => $tplOptions, 'value' => $this->template->get('id')), 'pagetitle' => array('type' => 'text'), 'longtitle' => array('type' => 'text'), 'description' => array('type' => 'text'), 'alias' => array('type' => 'text'), 'link_attributes' => array('type' => 'text'), 'introtext' => array('type' => 'textarea'), 'parent' => array('type' => 'text', 'value' => $this->config['gpc']['parent']), 'context_key' => array('type' => 'hidden', 'value' => $this->config['gpc']['ctx'] ? $this->config['gpc']['ctx'] : 'web'), 'menutitle' => array('type' => 'text'), 'menuindex' => array('type' => 'text'), 'hidemenu' => array('type' => 'boolean', 'value' => $this->modx->getOption('hidemenu_default'), 'title' => $this->modx->lexicon('resource_hide_from_menus')));
     $list = array();
     foreach ($fields as $name => $details) {
         $details['title'] = $details['title'] ? $details['title'] : ($this->modx->lexicon->exists($name) ? $this->modx->lexicon($name) : $this->modx->lexicon('resource_' . $name));
         $details['name'] = $name;
         $list[$name] = $this->renderer->render($details['type'], $details);
     }
     $this->setPlaceholder('fields', implode("\n", $list));
 }
 /**
  * Prepare object for iteration
  *
  * @param modTemplate $template
  * @return array
  */
 public function prepareRow(modTemplate $template)
 {
     $templateArray = $template->toArray();
     $templateArray['access'] = $template->get('tmplvarid');
     $templateArray['access'] = empty($templateArray['access']) ? false : true;
     unset($templateArray['content']);
     return $templateArray;
 }
Beispiel #3
0
 /**
  * Prepare the element and get the static openTo path if needed
  *
  * @return void|string
  */
 public function prepareElement()
 {
     $this->templateArray['openTo'] = '/';
     if (!empty($this->templateArray['static'])) {
         $file = $this->template->get('static_file');
         $this->templateArray['openTo'] = dirname($file) . '/';
     }
     return $this->templateArray['openTo'];
 }
Beispiel #4
0
 /**
  * Process this page, load the resource, and present its values
  * @return void
  */
 public function process()
 {
     $this->setPlaceholders($this->resource->toArray());
     $this->template = $this->resource->getOne('Template');
     if ($this->template) {
         $this->setPlaceholder('template', $this->template->get('templatename'));
     }
     $contentType = $this->resource->getOne('ContentType');
     if ($contentType) {
         $this->setPlaceholder('content_type', $contentType->get('name'));
     }
     $this->getContent();
     $this->getResourceFields();
     $this->getResourceSettings();
     if ($this->template) {
         $this->getTemplateVariables();
     }
 }
 public static function listTemplateVars(modTemplate &$template, array $sort = array('name' => 'ASC'), $limit = 0, $offset = 0, array $conditions = array())
 {
     $result = array('collection' => array(), 'total' => 0);
     $c = $template->xpdo->newQuery('modTemplateVar');
     $result['total'] = $template->xpdo->getCount('modTemplateVar', $c);
     $c->select($template->xpdo->getSelectColumns('modTemplateVar', 'modTemplateVar'));
     $c->leftJoin('modTemplateVarTemplate', 'modTemplateVarTemplate', array("modTemplateVarTemplate.tmplvarid = modTemplateVar.id", 'modTemplateVarTemplate.templateid' => $template->get('id')));
     $c->leftJoin('modCategory', 'Category');
     if (!empty($conditions)) {
         $c->where($conditions);
     }
     $c->select(array("CASE modTemplateVarTemplate.tmplvarid WHEN NULL THEN 0 ELSE 1 END AS access", "ISNULL(modTemplateVarTemplate.rank, 0) AS tv_rank", 'category_name' => 'Category.category'));
     foreach ($sort as $sortKey => $sortDir) {
         $c->sortby($sortKey, $sortDir);
     }
     if ($limit > 0) {
         $c->limit($limit, $offset);
     }
     $result['collection'] = $template->xpdo->getCollection('modTemplateVar', $c);
     return $result;
 }
Beispiel #6
0
 /**
  * @param string $content
  * @dataProvider providerSetContent
  * @depends testGetContent
  */
 public function testSetContent($content)
 {
     $this->template->setContent($content);
     $this->assertEquals($content, $this->template->get('content'));
 }