예제 #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;
 }