示例#1
0
 public function __construct(&$field)
 {
     parent::__construct($field);
     if ($this->method == 'fixed') {
         $this->editable = true;
         $this->editLimit = 5;
     }
     if ($this->method == 'fixed' && in_array(SPRequest::task(), array('entry.add', 'entry.edit'))) {
         $this->isOutputOnly = true;
     }
     if ($this->method == 'fixed') {
         $this->editable = true;
     }
 }
示例#2
0
 public function __construct(&$field)
 {
     parent::__construct($field);
     /* @var SPdb $db */
     $db =& SPFactory::db();
     $options = array();
     try {
         $db->select('*', 'spdb_field_option', array('fid' => $this->fid));
         $o = $db->loadObjectList();
         $db->select(array('sValue', 'language', 'sKey'), 'spdb_language', array('fid' => $this->fid, 'oType' => 'field_option'));
         $l = $db->loadObjectList();
     } catch (SPException $x) {
         Sobi::Error($this->name(), SPLang::e('CANNOT_GET_FIELD_POSITION_DB_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
     }
     static $lang, $defLang = null;
     if (!$lang) {
         $lang = Sobi::Lang(false);
         $defLang = Sobi::DefLang();
     }
     if (count($o)) {
         $labels = array();
         if (count($l)) {
             foreach ($l as $label) {
                 if (!isset($labels[$label->sKey])) {
                     $labels[$label->sKey] = array();
                 }
                 $labels[$label->sKey][$label->language] = $label->sValue;
             }
         }
         /* re-label */
         foreach ($o as $opt) {
             $option = array();
             $option['id'] = $opt->optValue;
             $option['label'] = isset($labels[$opt->optValue][$lang]) ? $labels[$opt->optValue][$lang] : (isset($labels[$opt->optValue][$defLang]) ? $labels[$opt->optValue][SOBI_DEFLANG] : (isset($labels[$opt->optValue][0]) ? $labels[$opt->optValue][0] : $opt->optValue));
             $option['position'] = $opt->optPos;
             $option['parent'] = $opt->optParent;
             if ($option['parent']) {
                 if (!isset($options[$option['parent']])) {
                     $options[$option['parent']] = array();
                 }
                 $options[$option['parent']]['options'][$option['id']] = $option;
                 $this->optionsById[$option['id']] = $option;
             } else {
                 if (!isset($options[$option['id']])) {
                     $options[$option['id']] = array();
                 }
                 $options[$option['id']] = array_merge($options[$option['id']], $option);
                 $this->optionsById[$option['id']] = $options[$option['id']];
             }
         }
         $this->options = $this->sortOpt($options);
     } else {
         $this->options[0]['id'] = 'option-id';
         $this->options[0]['label'] = Sobi::Txt('FD.SELECT_OPTION_NAME');
         $this->options[0]['position'] = 1;
         $this->options[0]['parent'] = null;
     }
 }