本文整理汇总了PHP中Read::file方法的典型用法代码示例。如果您正苦于以下问题:PHP Read::file方法的具体用法?PHP Read::file怎么用?PHP Read::file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Read
的用法示例。
在下文中一共展示了Read::file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: factory
public static function factory($form_definitions_file, $initial_values = '')
{
// system based
if (strpos($form_definitions_file, 'system::') !== FALSE) {
$form_definitions_file = PATH_SYSTEM . '/forms/' . str_replace('system::', '', $form_definitions_file);
} else {
$form_definitions_file = PATH_APP . '/forms/' . $form_definitions_file;
}
Form::$skeleton = array();
Form::$rules = array();
Form::$hookup = array();
Form::$release = array();
Form::$conf = Read::file($form_definitions_file . '_form.php', $initial_values);
// cross site request forgery
Form::csrf();
// run through fields
foreach (Form::$conf['fields'] as $field_id => $field_setup) {
// global mark setting
if (Form::$conf['config']['mark'] !== TRUE) {
$field_setup['mark'] = FALSE;
}
if (empty($field_setup['group'])) {
// set default group
$field_setup['group'] = 'default';
}
// set field label
$form['labels'][$field_id] = $field_setup['label'];
// handle read only fields
if ($field_setup['metas']['readonly'] === TRUE) {
$field_setup['attr']['disabled'] = 'disabled';
$field_setup['attr']['class'] = 'readonly ' . $field_setup['attr']['class'];
$field_setup['rules'] = array();
}
// set defined and posted value ... and clean da shizzle
$field_setup['defined_value'] = $field_setup['value'];
$field_setup['value'] = Form::get_value($field_id, $field_setup);
// handle hookups (turn optional fields into required)
if (!empty($field_setup['metas']['hookup'])) {
foreach ($field_setup['metas']['hookup'] as $hu_val => $hu_fields) {
if ($field_setup['value'] == $hu_val) {
foreach ($hu_fields as $hu_field_id) {
Form::$hookup[] = $hu_field_id;
}
}
Session::cache('jsinline', 'system.form.hookup("' . $field_id . '", "' . $hu_val . '", ["' . Format::array_join($hu_fields, '","') . '"])');
}
}
if (in_array($field_id, Form::$hookup)) {
$field_setup['rules'] = array('required');
}
// handle releases (turn required fields into optional)
if (!empty($field_setup['metas']['release'])) {
foreach ($field_setup['metas']['release'] as $rl_val => $rl_fields) {
if ($field_setup['value'] == $rl_val) {
foreach ($rl_fields as $rl_field_id) {
Form::$release[] = $rl_field_id;
}
}
Session::cache('jsinline', 'system.form.release("' . $field_id . '", "' . $rl_val . '", ["' . Format::array_join($rl_fields, '","') . '"])');
}
}
if (in_array($field_id, Form::$release)) {
$field_setup['rules'] = array();
}
// if no rules array, set it as an array
if (empty($field_setup['rules'])) {
$field_setup['rules'] = array();
}
// create html field widget
$widget = Form::$field_setup['type']($field_id, $field_setup);
// cache field type & value
Form::$skeleton['types'][$field_id] = $field_setup['type'];
Form::$skeleton['values'][$field_id] = $field_setup['value'];
// cache field rules
Form::rules($field_id, $field_setup['rules']);
Form::$skeleton['rules'] = Form::$rules;
$is_single_buttonset = FALSE;
// no label for single checkbox/radio fields
if (in_array($field_setup['type'], array('radio', 'checkbox')) && empty($field_setup['options'])) {
$is_single_buttonset = $field_setup['metas']['buttonset'] ? TRUE : FALSE;
}
// set labels
Form::$skeleton['labels'][$field_id] = $field_setup['label'];
if (!isset($field_setup['metas']['label'])) {
$field_setup['metas']['label'] = TRUE;
}
// handle label
if ($field_setup['metas']['label'] === TRUE && !$is_single_buttonset && !($field_setup['type'] == 'upload' || $field_setup['type'] == 'hidden' || $field_setup['type'] == 'date' && ($field_setup['metas']['range'] === TRUE || $field_setup['metas']['time']))) {
$label = Form::label($field_id, $field_setup['label'] . ':' . Form::field_mark($field_id, $field_setup));
} else {
$label = NULL;
}
// set form view
Form::$skeleton['view'][$field_id] = array('label' => $label, 'widget' => $widget, 'note' => '<div class="form_field_note">' . $field_setup['note'] . '</div>');
// group input results
if (Form::is_submitted()) {
$multi = Format::string_explode(str_replace(']', '', $field_id), '[');
$data = array('old' => Format::string_clean($field_setup['defined_value']), 'set' => Format::string_clean($field_setup['value']));
// if multidimensional
if (count($multi) > 1) {
//.........这里部分代码省略.........