Esempio n. 1
0
/**
 * Get the tempcode for a bank of tick boxes.
 *
 * @param  array			A list of tuples: (prettyname, name, value, description, [disabled])
 * @param  mixed			A description for this input field
 * @param  ?integer		The tab index of the field (NULL: not specified)
 * @param  mixed			A human intelligible name for this input field (blank: use default)
 * @param  boolean		Whether to place each tick on a new line
 * @return tempcode		The input field
 */
function form_input_various_ticks($options, $description, $_tabindex = NULL, $_pretty_name = '', $simple_style = false)
{
    if (count($options) == 0) {
        return new ocp_tempcode();
    }
    $options = array_values($options);
    if (is_null($_tabindex)) {
        $tabindex = get_form_field_tabindex(NULL);
    } else {
        $_tabindex++;
        $tabindex = $_tabindex;
    }
    if (is_string($_pretty_name) && $_pretty_name == '') {
        $_pretty_name = do_lang_tempcode('OPTIONS');
    }
    $input = new ocp_tempcode();
    if (count($options[0]) != 3) {
        $options = array(array($options, NULL, new ocp_tempcode()));
    }
    foreach ($options as $_option) {
        $out = array();
        foreach ($_option[0] as $option) {
            // $disabled has been added to the API, so we must emulate the
            // previous behaviour if it isn't supplied (ie. $disabled='0')
            if (count($option) == 4) {
                list($pretty_name, $name, $value, $_description) = $option;
                $disabled = '0';
            } elseif (count($option) == 5) {
                list($pretty_name, $name, $value, $_description, $_disabled) = $option;
                $disabled = $_disabled ? '1' : '0';
            }
            $value = filter_form_field_default($name, $value ? '1' : '0') == '1';
            $out[] = array('CHECKED' => $value, 'TABINDEX' => strval($tabindex), 'NAME' => $name, 'PRETTY_NAME' => $pretty_name, 'DESCRIPTION' => $_description, 'DISABLED' => $disabled);
        }
        $input->attach(do_template('FORM_SCREEN_INPUT_VARIOUS_TICKS', array('_GUID' => 'a6212f61304a101fb2754e334a8b4212', 'SECTION_TITLE' => $_option[2], 'EXPANDED' => $_option[1], 'SIMPLE_STYLE' => $simple_style, 'BRETHREN_COUNT' => strval(count($out)), 'OUT' => $out)));
    }
    return _form_input('', $_pretty_name, $description, $input, false, false, $tabindex);
}
Esempio n. 2
0
 /**
  * Get form inputter.
  *
  * @param  string			The field name
  * @param  string			The field description
  * @param  array			The field details
  * @param  ?string		The actual current value of the field (NULL: none)
  * @param  boolean		Whether this is for a new entry
  * @return ?tempcode		The Tempcode for the input field (NULL: skip the field - it's not input)
  */
 function get_field_inputter($_cf_name, $_cf_description, $field, $actual_value, $new)
 {
     if ($_cf_name == 'Longitude') {
         $pretty_name = $_cf_name;
         $description = $_cf_description;
         $name = 'field_' . strval($field['id']);
         $required = $field['cf_required'] == 1;
         if (isset($actual_value) && $actual_value != '' && $actual_value != do_lang('NA')) {
             $longitude = float_to_raw_string(floatval($actual_value), 10);
         }
         global $LATITUDE;
         if (isset($LATITUDE) && $LATITUDE != '' && $LATITUDE != do_lang('NA')) {
             $latitude = float_to_raw_string(floatval($LATITUDE), 10);
         }
         if ($latitude == '0.0000000000') {
             $latitude = '0';
         }
         if ($longitude == '0.0000000000') {
             $longitude = '0';
         }
         $input = do_template('FORM_SCREEN_INPUT_MAP_POSITION', array('REQUIRED' => $required, 'NAME' => $name, 'LATITUDE' => $latitude, 'LONGITUDE' => $longitude));
         return _form_input($name, 'Position', '', $input, $required, false);
     }
     if ($_cf_name == 'Latitude') {
         global $LATITUDE;
         $LATITUDE = $actual_value;
         // Store for when Longitude field is rendered - critical, else won't be entered
         return new ocp_tempcode();
     }
     return form_input_float($_cf_name, $_cf_description, 'field_' . strval($field['id']), is_null($actual_value) || $actual_value === '' ? NULL : floatval($actual_value), $field['cf_required'] == 1);
 }
Esempio n. 3
0
 /**
  * The form element for choosing a post template.
  *
  * @param  AUTO_LINK		The forum ID we are looking for post templates active in
  * @return array			A pair: The form element (tempcode) and the default post to make
  */
 function post_templates($forum_id)
 {
     if (!addon_installed('ocf_post_templates')) {
         return array(new ocp_tempcode(), '');
     }
     $specialisation = new ocp_tempcode();
     $templates = $this->ocf_get_post_templates($forum_id);
     $post_templates = new ocp_tempcode();
     $post = '';
     foreach ($templates as $template) {
         list($title, $text, $default) = $template;
         if ($default) {
             $post = $text;
         }
         $post_templates->attach(form_input_list_entry(str_replace(chr(10), '\\n', $text), $default == 1, $title));
     }
     if (!$post_templates->is_empty() && has_js()) {
         $post_templates2 = form_input_list_entry('', false, do_lang_tempcode('NA_EM'));
         $post_templates2->attach($post_templates);
         $input = do_template('OCF_POST_TEMPLATE_SELECT', array('_GUID' => '2e4270e8fb8050f0201f5aa2af56270a', 'TABINDEX' => '3', 'LIST' => $post_templates2));
         $specialisation->attach(_form_input('post_template', do_lang_tempcode('POST_TEMPLATE'), do_lang_tempcode('DESCRIPTION_POST_TEMPLATE'), $input, false, false));
     }
     return array($specialisation, $post);
 }
Esempio n. 4
0
/**
 * Get a captcha (aka security code) form field.
 *
 * @return tempcode		The field
 */
function form_input_captcha()
{
    $tabindex = get_form_field_tabindex(NULL);
    generate_captcha();
    // Show template
    $input = do_template('FORM_SCREEN_INPUT_CAPTCHA', array('_GUID' => 'f7452af9b83db36685ae8a86f9762d30', 'TABINDEX' => strval($tabindex)));
    return _form_input('security_image', do_lang_tempcode('SECURITY_IMAGE'), do_lang_tempcode('DESCRIPTION_SECURITY_IMAGE'), $input, true, false);
}
Esempio n. 5
0
/**
 * Get the tempcode for a float-only input.
 *
 * @param  mixed			A human intelligible name for this input field
 * @param  mixed			A description for this input field
 * @param  ID_TEXT		The name which this input field is for
 * @param  ?float			The default value for this input field (NULL: no default)
 * @param  boolean		Whether this is a required input field
 * @param  ?integer		The tab index of the field (NULL: not specified)
 * @return tempcode		The input field
 */
function form_input_float($pretty_name, $description, $name, $default, $required, $tabindex = NULL)
{
    $tabindex = get_form_field_tabindex($tabindex);
    $_default = filter_form_field_default($name, is_null($default) ? '' : strval($default));
    $default = $_default == '' ? NULL : floatval($_default);
    $_required = $required ? '_required' : '';
    $input = do_template('FORM_SCREEN_INPUT_FLOAT', array('TABINDEX' => strval($tabindex), 'REQUIRED' => $_required, 'NAME' => $name, 'DEFAULT' => is_null($default) ? '' : strval($default)));
    return _form_input($name, $pretty_name, $description, $input, $required, false, $tabindex);
}