예제 #1
0
 /**
  * @param string $indent
  * @param string $name
  * @param array $content
  * @return array
  */
 private static function _format_field($indent, $name, $content)
 {
     $type = Lib_Helper::get_data_from_array($content, Const_Interface::FIELD_ATTR_TYPE, Const_Interface::NODE_TYPE_UNKNOW);
     $label = $content[Const_Interface::FIELD_ATTR_NAME];
     $is_global = isset($content[Const_Interface::FIELD_ATTR_IS_GLOBAL]) && $content[Const_Interface::FIELD_ATTR_IS_GLOBAL] ? true : false;
     $desc = isset($content[Const_Interface::FIELD_ATTR_DESC]) ? $content[Const_Interface::FIELD_ATTR_DESC] : '';
     $weight = isset($content[Const_Interface::FIELD_ATTR_WEIGHT]) ? $content[Const_Interface::FIELD_ATTR_WEIGHT] : 100;
     $set = [Const_Interface::FIELD_ATTR_KEY => $name, Const_Interface::FIELD_ATTR_MODULE => $indent, Const_Interface::FIELD_ATTR_NAME => $label, Const_Interface::FIELD_ATTR_TYPE => $type, Const_Interface::FIELD_ATTR_IS_GLOBAL => $is_global, Const_Interface::FIELD_ATTR_DESC => $desc, Const_Interface::FIELD_ATTR_WEIGHT => $weight];
     switch ($type) {
         case Const_Interface::NODE_TYPE_INPUT:
             $set[Const_Interface::FIELD_ATTR_PLACEHOLDER] = Lib_Helper::get_data_from_array($content, Const_Interface::FIELD_ATTR_PLACEHOLDER, $label);
             $set[Const_Interface::FIELD_ATTR_DEFAULT] = Lib_Helper::get_data_from_array($content, Const_Interface::FIELD_ATTR_DEFAULT, '');
             break;
         case Const_Interface::NODE_TYPE_SELECT:
         case Const_Interface::NODE_TYPE_RSELECT:
             $value = $content[Const_Interface::FIELD_ATTR_DATA];
             $set[Const_Interface::FIELD_ATTR_VALUE] = self::_format_field_value($indent, $value);
             $set[Const_Interface::FIELD_ATTR_DEFAULT] = Lib_Helper::get_data_from_array($content, Const_Interface::FIELD_ATTR_DEFAULT, array_keys($value)[0]);
             break;
         case Const_Interface::NODE_TYPE_MINPUT:
             $set[Const_Interface::FIELD_ATTR_DEFAULT] = Lib_Helper::get_data_from_array($content, Const_Interface::FIELD_ATTR_DEFAULT, []);
             break;
         default:
             $set = [];
     }
     return $set;
 }