function __construct(modTemplateVar $tv, array $config = array())
 {
     $corePath = dirname(dirname(dirname(__FILE__))) . '/';
     $this->tv =& $tv;
     $this->modx =& $tv->xpdo;
     $this->config = array_merge($this->config, $config);
     $template = $this->getTemplate();
     $xtype_template = str_replace('.tpl', '.xtype.tpl', $template);
     $this->tv->set('xtype_template', $corePath . 'templates/' . $xtype_template);
     $this->controller = new migxfeChunkie('@FILE ' . $template, $corePath . 'templates/');
     $this->setReplaceonlyfields('tv.value');
 }
 function __construct(modTemplateVar $tv, array $config = array())
 {
     $this->tv =& $tv;
     $this->modx =& $tv->xpdo;
     $this->config = array_merge($this->config, $config);
     $template = $this->getTemplate();
     $templatesRoot = $this->getTemplateRoot();
     $xtype_template = str_replace('.tpl', '.xtype.tpl', $template);
     $this->tv->set('xtype_template', $templatesRoot . $xtype_template);
     $this->controller = new migxangularChunkie('@FILE ' . $template, $templatesRoot);
     $this->setReplaceonlyfields('tv.value');
 }
コード例 #3
0
 /**
  * Prepare radio boxes.
  *
  * @param modTemplateVar $tv
  * @return modTemplateVar
  */
 public function prepareRadio($tv)
 {
     $value = $tv->get('value');
     $default = $tv->get('default_text');
     // handles radio buttons
     $options = $tv->parseInputOptions($tv->processBindings($tv->get('elements'), $tv->get('name')));
     $items = array();
     $defaultIndex = '';
     $i = 0;
     foreach ($options as $option) {
         $opt = explode("==", $option);
         if (!isset($opt[1])) {
             $opt[1] = $opt[0];
         }
         /* set checked status */
         $checked = strcmp($opt[1], $value) == 0 ? ' checked="checked"' : '';
         /* set default value */
         if (strcmp($opt[1], $default) == 0) {
             $defaultIndex = 'tv' . $tv->get('id') . '-' . $i;
             $tv->set('default_text', $defaultIndex);
         }
         if (is_string($opt[1])) {
             $opt[1] = str_replace('"', '"', $opt[1]);
         }
         $items[] = array('text' => htmlspecialchars($opt[0], ENT_COMPAT, 'UTF-8'), 'name' => 'tv' . $tv->get('id'), 'value' => $opt[1], 'checked' => $checked, 'idx' => $i);
         $i++;
     }
     $list = array();
     foreach ($items as $item) {
         $list[] = $this->hm->getTpl('fields/radio.option', $item);
     }
     $tv->set('options', implode("\n", $list));
     return $tv;
 }