コード例 #1
0
ファイル: field.php プロジェクト: kotsios5/openclassifieds2
 /**
  * get the custom fields for an ad
  * @return array/class
  */
 public static function get_all($as_array = TRUE)
 {
     if (!is_null($fields = json_decode(core::config('advertisement.fields'), $as_array))) {
         // Pre-populate country select values
         if ($as_array === TRUE) {
             foreach ($fields as $key => $field) {
                 if ($field['type'] == 'country') {
                     $fields[$key]['values'] = EUVAT::countries();
                 }
             }
         }
         return $fields;
     } else {
         return array();
     }
 }
コード例 #2
0
ファイル: payment.php プロジェクト: kotsios5/openclassifieds2
echo FORM::select($forms['alternative']['key'], $pages, $forms['alternative']['value'], array('class' => 'tips form-control', 'id' => $forms['alternative']['key']));
?>
 
                        <span class="help-block">
                            <?php 
echo __("A button with the page title appears next to other pay button, onclick model opens with description.");
?>
                        </span>
                    </div>

                    <div class="form-group">
                        <?php 
echo FORM::label($forms['vat_country']['key'], __('VAT Country'), array('class' => 'control-label', 'for' => $forms['vat_country']['key']));
?>
                        <?php 
echo Form::select($forms['vat_country']['key'], EUVAT::countries(), $forms['vat_country']['value']);
?>
                    </div>

                    <div class="form-group">
                        <?php 
echo FORM::label($forms['vat_number']['key'], __('VAT Number'), array('class' => 'control-label', 'for' => $forms['vat_number']['key']));
?>
                        <?php 
echo FORM::input($forms['vat_number']['key'], $forms['vat_number']['value'], array('placeholder' => "", 'class' => 'tips form-control', 'id' => $forms['vat_number']['key']));
?>
                    </div>

                    <hr>

                    <div class="form-group">
コード例 #3
0
 /**
  * get the custom fields for a user
  * 
  * @return array/class
  */
 public static function get_all($hide_admin = TRUE, $as_array = TRUE)
 {
     $user_fields = json_decode(core::config('user.user_fields'), TRUE);
     //remove only admin values
     if ($hide_admin === TRUE) {
         foreach ($user_fields as $field => $options) {
             if (isset($options['admin_privilege']) and $options['admin_privilege'] == TRUE) {
                 unset($user_fields[$field]);
             }
         }
     }
     //convert to a class
     if ($as_array === FALSE) {
         foreach ($user_fields as $field => $values) {
             $user_fields[$field] = (object) $user_fields[$field];
         }
         $user_fields = (object) $user_fields;
     }
     // Pre-populate country select values
     if ($as_array === TRUE) {
         foreach ($user_fields as $key => $field) {
             if ($field['type'] == 'country') {
                 $user_fields[$key]['values'] = EUVAT::countries();
             }
         }
     }
     return $user_fields;
 }
コード例 #4
0
ファイル: form.php プロジェクト: kotsios5/openclassifieds2
 /**
  * get field html code for a custom field
  * @param  string $name input name
  * @param  array  $options as defined
  * @param  mixed $value value of the field, optional.
  * @return string        HTML
  */
 public static function cf_form_field($name, $options, $value = NULL)
 {
     if ($value === NULL) {
         $value = isset($options['default']) ? $options['default'] : NULL;
     }
     // dependent classes on type
     $class = 'form-control ' . 'cf_' . $options['display'] . '_fields data-custom ';
     switch ($options['display']) {
         case 'checkbox':
             $class = 'cf_' . $options['display'] . '_fields data-custom';
             break;
         case 'radio':
             $class = 'cf_' . $options['display'] . 'fields data-custom';
             $required = (isset($options['required']) and $options['required'] == TRUE) ? 'required' : NULL;
             $data_categories = isset($options['categories']) ? json_encode($options['categories']) : NULL;
             $title = isset($options['tooltip']) ? $options['tooltip'] : NULL;
             break;
         default:
             $class .= " ";
             break;
     }
     $attributes = array('placeholder' => isset($options['placeholder']) ? $options['placeholder'] : (isset($options['label']) ? $options['label'] : $name), 'data-placeholder' => isset($options['data-placeholder']) ? $options['data-placeholder'] : (isset($options['label']) ? $options['label'] : $name), 'title' => isset($options['tooltip']) ? $options['tooltip'] : NULL, 'data-categories' => isset($options['categories']) ? json_encode($options['categories']) : NULL, 'class' => $class, 'id' => $name, (isset($options['required']) and $options['required'] == TRUE) ? 'required' : NULL);
     switch ($options['display']) {
         case 'select':
             $input = FORM::select($name, $options['options'], !is_array($value) ? $value : NULL, $attributes);
             break;
         case 'text':
             $input = FORM::input($name, $value, $attributes);
             break;
         case 'textarea':
             $input = FORM::textarea($name, $value, $attributes);
             break;
         case 'hidden':
             $input = FORM::hidden($name, $value, $attributes);
             break;
         case 'date':
             $attributes['data-date'] = "data-date";
             $attributes['data-date-format'] = "yyyy-mm-dd";
             $input = FORM::input($name, $value, $attributes);
             break;
         case 'checkbox':
             $checked = isset($value);
             // value can be 1 or 'on'
             $input = '<div class="checkbox"><label>' . FORM::checkbox($name, NULL, $checked, $attributes) . '</label></div>';
             break;
         case 'radio':
             $input = '';
             $index = 0;
             foreach ($options['options'] as $id => $radio_name) {
                 $checked = $value == $index ? TRUE : FALSE;
                 if ($id !== "") {
                     $input .= '<div class="radio"><label>' . Form::radio($name, $index, $checked, $attributes) . ' ' . $radio_name . '</label></div>';
                 }
                 $index++;
             }
             break;
         case 'email':
             $attributes['type'] = 'email';
             $input = FORM::input($name, $value, $attributes);
             break;
         case 'country':
             $input = FORM::select($name, EUVAT::countries(), !is_array($value) ? $value : NULL, $attributes);
             break;
         case 'file':
             $input = FORM::hidden($name, $value, $attributes);
             break;
         case 'string':
         default:
             $input = FORM::input($name, $value, $attributes);
             break;
     }
     return $input;
 }