예제 #1
0
 /**
  * see html::wysiwyg();
  */
 public static function wysiwyg($options = [])
 {
     // tinymce library
     library::add('tinymce');
     $options['class'] = $options['class'] ?? '';
     $options['class'] .= ' wysiwyg';
     layout::onload("tinymce.init({selector: 'textarea.wysiwyg', height: 500, plugins: ['advlist autolink lists link image charmap print preview hr anchor pagebreak','searchreplace wordcount visualblocks visualchars code fullscreen','insertdatetime media nonbreaking save table contextmenu directionality','emoticons template paste textcolor colorpicker textpattern imagetools'],toolbar1: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',toolbar2: 'print preview media | forecolor backcolor emoticons'});");
     return html::textarea($options);
 }
예제 #2
0
 /**
  * see html::calendar()
  */
 public static function calendar($options = [])
 {
     // include js & css files
     if (empty($options['readonly'])) {
         layout::add_js('/numbers/media_submodules/numbers_frontend_components_calendar_numbers_media_js_base.js');
         layout::add_css('/numbers/media_submodules/numbers_frontend_components_calendar_numbers_media_css_base.css');
     }
     // font awesome icons
     library::add('fontawesome');
     // widget parameters
     $type = $options['calendar_type'] ?? $options['type'] ?? 'date';
     $widget_options = ['id' => $options['id'], 'type' => $type, 'format' => $options['calendar_format'] ?? format::get_date_format($type), 'date_week_start_day' => $options['calendar_date_week_start_day'] ?? 1, 'date_disable_week_days' => $options['calendar_date_disable_week_days'] ?? null, 'master_id' => $options['calendar_master_id'] ?? null, 'slave_id' => $options['calendar_slave_id'] ?? null];
     $options['type'] = 'text';
     // determine input size
     $placeholder = format::get_date_placeholder($widget_options['format']);
     $options['size'] = strlen($placeholder);
     // set placeholder
     if (!empty($options['placeholder']) && $options['placeholder'] == 'format::get_date_placeholder') {
         $options['placeholder'] = $placeholder;
         $options['title'] = ($options['title'] ?? '') . ' (' . $placeholder . ')';
     }
     if (isset($options['calendar_icon']) && ($options['calendar_icon'] == 'left' || $options['calendar_icon'] == 'right')) {
         $position = $options['calendar_icon'];
         if (i18n::rtl()) {
             if ($position == 'left') {
                 $position = 'right';
             } else {
                 $position = 'left';
             }
         }
         $icon_type = $type == 'time' ? 'clock-o' : 'calendar';
         unset($options['calendar_icon']);
         if (empty($options['readonly'])) {
             $icon_onclick = 'numbers_calendar_var_' . $options['id'] . '.show();';
         } else {
             $icon_onclick = null;
         }
         $icon_value = html::span(['onclick' => $icon_onclick, 'class' => 'numbers_calendar_icon numbers_prevent_selection', 'value' => html::icon(['type' => $icon_type])]);
         $result = html::input_group(['value' => html::input($options), $position => $icon_value, 'dir' => 'ltr']);
         $div_id = $options['id'] . '_div_holder';
         $result .= html::div(['id' => $div_id, 'class' => 'numbers_calendar_div_holder']);
         $widget_options['holder_div_id'] = $div_id;
     } else {
         $result = html::input($options);
     }
     // we do not render a widget if readonly
     if (empty($options['readonly'])) {
         layout::onload('numbers_calendar(' . json_encode($widget_options) . ');');
     }
     return $result;
 }
예제 #3
0
 /**
  * @see html::icon()
  */
 public static function icon($options = [])
 {
     // if we are rendering image
     if (isset($options['file'])) {
         return numbers_frontend_html_class_base::icon($options);
     } else {
         if (isset($options['type'])) {
             library::add('fontawesome');
             // generating class & rendering tag
             $options['class'] = array_add_token($options['class'] ?? [], 'fa fa-' . $options['type'], ' ');
             if (!empty($options['class_only'])) {
                 return implode(' ', $options['class']);
             } else {
                 $options['tag'] = $options['tag'] ?? 'i';
                 return html::tag($options);
             }
         }
     }
 }
예제 #4
0
 /**
  * see html::select();
  */
 public static function select($options = [])
 {
     // we do not process readonly selects
     if (empty($options['readonly'])) {
         // include js & css files
         layout::add_js('/numbers/media_submodules/numbers_frontend_components_select_numbers_media_js_base.js', 10000);
         layout::add_css('/numbers/media_submodules/numbers_frontend_components_select_numbers_media_css_base.css', 10000);
         // font awesome icons
         library::add('fontawesome');
         // id with name
         if (empty($options['id']) && !empty($options['name'])) {
             $options['id'] = $options['name'];
         }
         layout::onload('numbers_select(' . json_encode(['id' => $options['id']]) . ');');
     }
     // must gain proper class from previous submodule
     $options['flag_call_previous_parent'] = true;
     return html::select($options);
 }