예제 #1
0
 protected function toHtmlContent($node, $refUrl = NULL)
 {
     if ($node == NULL || !$node->HasVal()) {
         return '<span class="text-muted">' . ATTR_VAL_NOT_SET . '</span>';
     }
     $o = '';
     $value = $node->Get(CNode::FLD_VAL);
     $err = $node->Get(CNode::FLD_ERR);
     if ($this->_type == 'sel1' && $value != NULL && !array_key_exists($value, $this->_maxVal)) {
         $err = 'Invalid value - ' . htmlspecialchars($value, ENT_QUOTES);
     } else {
         if ($err != NULL) {
             $type3 = substr($this->_type, 0, 3);
             if ($type3 == 'fil' || $type3 == 'pat') {
                 $validator = new ConfValidation();
                 $validator->chkAttr_file_val($this, $value, $err);
             }
         }
     }
     if ($err) {
         $node->SetErr($err);
         $o .= '<span class="field_error">*' . $err . '</span><br>';
     }
     if ($this->_href) {
         $link = $this->_hrefLink;
         if (strpos($link, '$V')) {
             $link = str_replace('$V', urlencode($value), $link);
         }
         $o .= '<span class="field_url"><a href="' . $link . '">';
     } elseif ($refUrl != NULL) {
         $o .= '<span class="field_refUrl"><a href="' . $refUrl . '">';
     }
     if ($this->_type === 'bool') {
         if ($value === '1') {
             $o .= ATTR_VAL_BOOL_YES;
         } elseif ($value === '0') {
             $o .= ATTR_VAL_BOOL_NO;
         } else {
             $o .= '<span class="text-muted">' . ATTR_VAL_NOT_SET . '</span>';
         }
     } elseif ($this->_type == 'ctxseq') {
         $o = $value . ' <a href="javascript:lst_ctxseq(' . $value . ')" class="btn bg-color-blueLight btn-xs txt-color-white"><i class="fa fa-plus"></i></a> <a href="javascript:lst_ctxseq(-' . $value . ')" class="btn bg-color-blueLight btn-xs txt-color-white"><i class="fa fa-minus"></i></a>';
     } else {
         if ($this->_key == "note") {
             $o .= '<textarea readonly style="width:100%;height:auto">' . htmlspecialchars($value, ENT_QUOTES) . '</textarea>';
         } elseif ($this->_type === 'sel' || $this->_type === 'sel1') {
             if ($this->_maxVal != NULL && array_key_exists($value, $this->_maxVal)) {
                 $o .= $this->_maxVal[$value];
             } else {
                 $o .= htmlspecialchars($value, ENT_QUOTES);
             }
         } elseif ($this->_type === 'checkboxOr') {
             if ($this->_minVal !== NULL && ($value === '' || $value === NULL)) {
                 // has default value, for "Not set", set default val
                 $value = $this->_minVal;
             }
             foreach ($this->_maxVal as $val => $name) {
                 if ($value & $val || $value === $val || $value === '0' && $val === 0) {
                     $o .= '<i class="fa fa-check-square-o">';
                 } else {
                     $o .= '<i class="fa fa-square-o">';
                 }
                 $o .= '</i> ';
                 $o .= $name . '&nbsp;&nbsp;&nbsp;&nbsp;';
             }
         } elseif ($this->_inputType === 'textarea1') {
             $o .= '<textarea readonly style="width:100%;"' . $this->_inputAttr . '>' . htmlspecialchars($value, ENT_QUOTES) . '</textarea>';
         } elseif ($this->_inputType === 'text') {
             $o .= '<span class="field_text">' . htmlspecialchars($value, ENT_QUOTES) . '</span>';
         } else {
             $o .= htmlspecialchars($value);
         }
     }
     if ($this->_href || $refUrl != NULL) {
         $o .= '</a></span>';
     }
     return $o;
 }
예제 #2
0
 protected function process_config()
 {
     //init here
     $this->_disp->InitConf();
     $this->loadConfig();
     $confdata = $this->getConfData($this->_disp);
     $needTrim = 0;
     $tblDef = DTblDef::GetInstance();
     $disp_act = $this->_disp->Get(DInfo::FLD_ACT);
     if ($disp_act == 's') {
         $validator = new ConfValidation();
         $extracted = $validator->ExtractPost($this->_disp);
         if ($extracted->HasErr()) {
             $this->_disp->Set(DInfo::FLD_ACT, 'S');
             $this->_disp->Set(DInfo::FLD_TopMsg, $extracted->Get(CNode::FLD_ERR));
             return $extracted;
         } else {
             $confdata->SavePost($extracted, $this->_disp);
             $this->setChanged(true);
             $needTrim = 2;
         }
     } elseif ($disp_act == 'a') {
         $added = new CNode(CNode::K_EXTRACTED, '');
         return $added;
     } elseif ($disp_act == 'c' || $disp_act == 'n') {
         // 'c': change, 'n': next
         $validator = new ConfValidation();
         $extracted = $validator->ExtractPost($this->_disp);
         if ($disp_act == 'n') {
             $this->_disp->SwitchToSubTid($extracted);
         }
         return $extracted;
     } elseif ($disp_act == 'D') {
         $confdata->DeleteEntry($this->_disp);
         $needTrim = 1;
     } elseif ($disp_act == 'I') {
         if ($this->instantiateTemplate()) {
             $needTrim = 1;
         }
     } elseif ($disp_act == 'd' || $disp_act == 'i') {
         if ($disp_act == 'd') {
             $actions = 'DC';
             $mesg = DMsg::UIStr('note_confirm_delete');
         } else {
             $actions = 'IC';
             $mesg = DMsg::UIStr('note_confirm_instantiate');
         }
         $adata = $this->_disp->GetActionData($actions);
         $mesg = '<p>' . $mesg . '</p>' . UI::GetActionButtons($adata, 'text');
         $this->_disp->Set(DInfo::FLD_TopMsg, $mesg);
     }
     $ctxseq = UIBase::GrabGoodInputWithReset('ANY', 'ctxseq', 'int');
     if ($ctxseq != 0) {
         if ($this->_curOne->ChangeContextSeq($ctxseq)) {
             $needTrim = 1;
         }
     }
     if ($needTrim) {
         $this->_disp->TrimLastId();
         // need reload
         $this->loadConfig();
         $confdata = $this->getConfData($this->_disp);
     }
     return $confdata;
 }