public function __construct()
 {
     Form_builder::$TYPES = (object) array('TEXT' => 1, 'OPTION' => 2, 'CHECKBOX' => 3, 'DATE' => 4, 'RADIO' => 5, 'BUTTON' => 6, 'PASSSWORD' => 7);
 }
Exemple #2
0
		<th class='thr'><?php 
    echo _("Description");
    ?>
</th>
		<td class='left' style="border-width: 0px;">
			<div class='wf3'><textarea name="description" rows="10" cols="80" wrap="hard"><?php 
    echo $description;
    ?>
</textarea></div>
		</td>
	</tr>

<?php 
} elseif ($ref == "Custom") {
    $fields = Incident_custom::get_custom_types($conn, $type);
    $form_builder = new Form_builder();
    $params = array();
    $cont = 1;
    if (empty($fields)) {
        echo "<tr><td class='nobborder' colspan='2'>";
        $error = new OssimNotice();
        $info = array(_("You don't have added any custom types or your custom types have been deleted"));
        $error->display(_("DEFAULT"), $info, false);
        echo "</td></tr>";
    } else {
        foreach ($fields as $field) {
            echo "<tr id='item_" . $cont . "'><th id='name_" . $cont . "' class='thr'><span>" . utf8_decode($field['name']) . "</span></th>";
            echo "<td style='border-width: 0px;text-align:left'>";
            $params = get_params_field($field, $map_key);
            $form_builder->set_attributes($params);
            if (is_object($custom_values[$field['name']])) {
 /**
  * Creates a dropdown select of blocks and when selected, will display fields related to that block
  *
  * @access	public
  * @param	array Fields parameters
  * @return	string
  */
 public function block($params)
 {
     $form_builder =& $params['instance'];
     // check to make sure there is no conflict between page columns and layout vars
     if (!empty($params['block_name'])) {
         // check to make sure there is no conflict between page columns and layout vars
         $layout = $this->fuel->layouts->get($params['block_name'], 'block');
         if (!$layout) {
             return;
         }
         if (!isset($params['context'])) {
             $params['context'] = $params['key'];
         }
         $layout->set_context($params['context']);
         $fields = $layout->fields();
         $fb = new Form_builder();
         $fb->load_custom_fields(APPPATH . 'config/custom_fields.php');
         $fb->question_keys = array();
         $fb->submit_value = '';
         $fb->cancel_value = '';
         $fb->use_form_tag = FALSE;
         $fb->name_prefix = 'vars';
         $fb->set_fields($fields);
         $fb->display_errors = FALSE;
         if (!empty($params['value'])) {
             $fb->set_field_values($params['value']);
         }
         $form = $fb->render();
         return $form;
     } else {
         $params['type'] = 'select';
         if (!isset($params['options'])) {
             // if a folder is specified, we will look in that directory to get the list of blocks
             if (isset($params['folder'])) {
                 if (!isset($params['where'])) {
                     $params['where'] = array();
                 }
                 if (!isset($params['filter'])) {
                     $params['filter'] = '^_(.*)|\\.html$';
                 }
                 if (!isset($params['order'])) {
                     $params['order'] = TRUE;
                 }
                 // set options_list to not be recursive since block layout names won't have slashes in them (e.g. sections/right_image... it would just be right_image)
                 if (!isset($params['recursive'])) {
                     $params['recursive'] = FALSE;
                 }
                 $params['options'] = $this->CI->fuel->blocks->options_list($params['where'], $params['folder'], $params['filter'], $params['order'], $params['recursive']);
             } else {
                 if (!isset($params['group'])) {
                     $params['group'] = '';
                 }
                 $params['options'] = $this->CI->fuel->layouts->options_list(TRUE, $params['group']);
             }
         }
         $select_class = 'block_layout_select';
         $params['class'] = !empty($params['class']) ? $params['class'] . ' ' . $select_class : $select_class;
         if (!empty($params['ajax_url'])) {
             $params['data']['url'] = rawurlencode($params['ajax_url']);
         }
         $value = (is_array($params['value']) and isset($params['value']['block_name'])) ? $params['value']['block_name'] : (isset($params['value']) ? $params['value'] : '');
         $params['value'] = $value;
         $params['style'] = 'margin-bottom: 10px;';
         $field = $form_builder->create_select($params);
         $field = $field . '<div class="block_layout_fields"></div><div class="loader hidden"></div>';
         return $field;
     }
 }
Exemple #4
0
    protected function _process()
    {
        $this->load->helper('security');
        $this->_orig_post = $_POST;
        // filter placeholder $_POST values
        $callback = create_function('$matches', '
			if (isset($_POST[$matches["2"]]))
			{
				$str = $matches[1].$_POST[$matches["2"]].$matches[3];
			}
			else
			{
				$str = $matches[0];
			}
			return $str;
		');
        // first loop through and create simple non-namespaced $_POST values if they don't exist for convenience'
        foreach ($_POST as $key => $val) {
            $key_parts = explode('--', $key);
            $tmp_key = end($key_parts);
            $_POST[$tmp_key] = $val;
        }
        // now loop through and do any substitution
        foreach ($_POST as $key => $val) {
            if (is_string($val)) {
                $_POST[$key] = preg_replace_callback('#(.*)\\{(.+)\\}(.*)#U', $callback, $val);
            }
        }
        // set boolean fields
        if (!empty($this->model->boolean_fields) and is_array($this->model->boolean_fields)) {
            foreach ($this->model->boolean_fields as $val) {
                $_POST[$val] = isset($_POST[$val]) ? $_POST[$val] : 0;
            }
        }
        // if no permission to publish, then we revoke
        if (!$this->fuel->auth->has_permission($this->permission, 'publish')) {
            unset($_POST['published']);
        }
        // set key_field if it is not id
        if (!empty($_POST['id']) and $this->model->key_field() != 'id') {
            $_POST[$this->model->key_field()] = $_POST['id'];
        }
        // run any form field post processing hooks
        $this->load->library('form_builder');
        // use a new instance to prevent problems when duplicating
        $fb = new Form_builder();
        $fb->load_custom_fields(APPPATH . 'config/custom_fields.php');
        // $fields = $this->model->form_fields($_POST);
        $fields = $this->_block_processing($this->model->form_fields(), $_POST);
        $fb->set_fields($fields);
        $fb->post_process_field_values();
        // manipulates the $_POST values directly
        // sanitize input if set in module configuration
        $posted = $this->_sanitize($_POST);
        return $posted;
    }
 /**
  * Processes the layout's fields
  *
  * @access	public
  * @param	array	The new fields to process
  * @return	array
  */
 public function process_fields($fields = array())
 {
     // automatically add a field for the block name
     $fields['block_name'] = array('type' => 'hidden', 'value' => $this->name, 'class' => 'block_name');
     $fb = new Form_builder();
     if (!empty($this->context)) {
         foreach ($fields as $key => $val) {
             $fields[$key]['name'] = $this->context . '[' . $key . ']';
             if (empty($val['label'])) {
                 $fields[$key]['label'] = ($lang = $fb->label_lang($key)) ? $lang : ucfirst(str_replace('_', ' ', $key));
             }
         }
     }
     return $fields;
 }
Exemple #6
0
                            <label for="description"><?php 
    echo _('Description');
    ?>
</label>
                        </th>
                        <td class='left'>
                            <textarea class='vfield' id='description' name="description" rows="10" cols="80"><?php 
    echo $description;
    ?>
</textarea>
                        </td>
                    </tr>
                    <?php 
} elseif ($ref == 'Custom') {
    $fields = Incident_custom::get_custom_types($conn, $type);
    $form_builder = new Form_builder();
    $params = array();
    $cont = 1;
    if (empty($fields)) {
        echo "<tr>\n                                <td class='nobborder' colspan='2'>";
        $config_nt = array('content' => _("You don't have added any custom types or your custom types have been deleted"), 'options' => array('type' => 'nf_info', 'cancel_button' => false), 'style' => 'width: 90%; margin: 5px auto; text-center: left; padding:5px;');
        $nt = new Notification('c_nt_oss_error', $config_nt);
        $nt->show();
        echo "  </td>\n                            </tr>";
    } else {
        $req_f_inherent = array('Asset', 'Slider');
        $wf1_types = array('Select box', 'Date', 'Date Range', 'Checkbox', 'Radio button');
        foreach ($fields as $field) {
            $conf = $GLOBALS['CONF'];
            $map_key = $conf->get_conf('google_maps_key');
            $params = get_params_field($field, $map_key);