/** * Add media to layout */ public static function add() { layout::add_css('//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css', 10000); layout::add_js('//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js', 10000); layout::add_css('/numbers/media_submodules/numbers_frontend_html_bootstrap_media_css_base.css', 10001); layout::add_js('/numbers/media_submodules/numbers_frontend_html_bootstrap_media_js_base.js', 10001); }
/** * 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; }
/** * 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); }
/** * Add media to layout */ public static function add() { layout::add_js('/numbers/media_submodules/numbers_frontend_media_libraries_loadmask_media_js_spinner.js', 10005); layout::add_js('/numbers/media_submodules/numbers_frontend_media_libraries_loadmask_media_js_base.js', 10010); layout::add_css('/numbers/media_submodules/numbers_frontend_media_libraries_loadmask_media_css_base.css', 10000); }
/** * Add media to layout */ public static function add() { layout::add_css('//oss.maxcdn.com/semantic-ui/2.1.8/semantic.min.css'); layout::add_js('//oss.maxcdn.com/semantic-ui/2.1.8/semantic.min.js'); }
/** * Add media to layout */ public static function add() { layout::add_css('https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'); }
/** * Render form * * @return mixed */ public function render() { // ajax requests from another form if ($this->flag_another_ajax_call) { return null; } $this->tabindex = 1; // css & js numbers_frontend_media_libraries_jssha_base::add(); layout::add_js('/numbers/media_submodules/numbers_frontend_html_form_media_js_base.js', -10000); // include master js if (!empty($this->master_object) && method_exists($this->master_object, 'add_js')) { $this->master_object->add_js(); } // include js $filename = str_replace('_model_', '_media_js_', $this->form_class) . '.js'; if (file_exists('./../libraries/vendor/' . str_replace('_', '/', $filename))) { layout::add_js('/numbers/media_submodules/' . $filename); } $this->misc_settings['extended_js_class'] = 'numbers.' . $this->form_class; // include css $filename = str_replace('_model_', '_media_css_', $this->form_class) . '.css'; if (file_exists('./../libraries/vendor/' . str_replace('_', '/', $filename))) { layout::add_css('/numbers/media_submodules/' . $filename); } // load mask numbers_frontend_media_libraries_loadmask_base::add(); // new record action $mvc = application::get('mvc'); if (object_controller::can('record_new')) { $onclick = 'return confirm(\'' . strip_tags(i18n(null, object_content_messages::confirm_blank)) . '\');'; $this->actions['form_new'] = ['value' => 'New', 'sort' => -31000, 'icon' => 'file-o', 'href' => $mvc['full'] . '?' . $this::button_submit_blank . '=1', 'onclick' => $onclick, 'internal_action' => true]; } // back to list if (object_controller::can('list_view')) { $this->actions['form_back'] = ['value' => 'Back', 'sort' => -32000, 'icon' => 'arrow-left', 'href' => $mvc['controller'] . '/_index', 'internal_action' => true]; } // reload button if ($this->values_loaded) { $url = $mvc['full'] . '?' . http_build_query2($this->pk); $this->actions['form_refresh'] = ['value' => 'Refresh', 'sort' => 32000, 'icon' => 'refresh', 'href' => $url, 'internal_action' => true]; } // handling override_field_value method if (!empty($this->wrapper_methods['pre_render']['main'])) { call_user_func_array($this->wrapper_methods['pre_render']['main'], [&$this]); } // assembling everything into result variable $result = []; // order containers based on order column array_key_sort($this->data, ['order' => SORT_ASC]); foreach ($this->data as $k => $v) { if (!$v['flag_child']) { if ($v['type'] == 'fields' || $v['type'] == 'details') { // reset tabs $this->current_tab = []; $temp = $this->render_container($k); if ($temp['success']) { $result[$k] = $temp['data']; } } else { if ($v['type'] == 'tabs') { // tabs $tab_id = "form_tabs_{$this->form_link}_{$k}"; $tab_header = []; $tab_values = []; $tab_options = []; $have_tabs = false; // sort rows array_key_sort($v['rows'], ['order' => SORT_ASC]); foreach ($v['rows'] as $k2 => $v2) { $this->current_tab[] = "{$tab_id}_{$k2}"; $labels = ''; foreach (['records', 'danger', 'warning', 'success', 'info'] as $v78) { $labels .= html::label2(['type' => $v78 == 'records' ? 'primary' : $v78, 'style' => 'display: none;', 'value' => 0, 'id' => implode('__', $this->current_tab) . '__' . $v78]); } $tab_header[$k2] = i18n(null, $v2['options']['label_name']) . $labels; $tab_values[$k2] = ''; // handling override_tabs method if (!empty($this->wrapper_methods['override_tabs']['main'])) { $tab_options[$k2] = call_user_func_array($this->wrapper_methods['override_tabs']['main'], [&$this, &$v2, &$k2, &$this->values]); if (empty($tab_options[$k2]['hidden'])) { $have_tabs = true; } } else { $have_tabs = true; } // tab index for not hidden tabs if (empty($tab_options[$k2]['hidden'])) { $tab_options[$k2]['tabindex'] = $this->tabindex; $this->tabindex++; } // render containers array_key_sort($v2['elements'], ['order' => SORT_ASC]); foreach ($v2['elements'] as $k3 => $v3) { $temp = $this->render_container($v3['options']['container']); if ($temp['success']) { $tab_values[$k2] .= $temp['data']['html']; } } // remove last element from an array array_pop($this->current_tab); } // if we do not have tabs if ($have_tabs) { $result[$k]['html'] = html::tabs(['id' => $tab_id, 'class' => 'form-tabs', 'header' => $tab_header, 'options' => $tab_values, 'tab_options' => $tab_options]); } } } } } // formatting data $temp = []; foreach ($result as $k => $v) { $temp[] = $v['html']; } $result = implode('', $temp); // we need to skip internal actions if (!empty($this->options['no_actions'])) { foreach ($this->actions as $k0 => $v0) { if (!empty($v0['internal_action'])) { unset($this->actions[$k0]); } } } // rendering actions if (!empty($this->actions)) { $value = '<div style="text-align: right;">' . $this->render_actions() . '</div>'; $value .= '<hr class="simple" />'; $result = $value . $result; } // messages if (!empty($this->errors['general'])) { $messages = ''; foreach ($this->errors['general'] as $k => $v) { $messages .= html::message(['options' => $v, 'type' => $k]); } $result = '<div class="form_message_container">' . $messages . '</div>' . $result; } // couple hidden fields $result .= html::hidden(['name' => '__form_link', 'value' => $this->form_link]); $result .= html::hidden(['name' => '__form_values_loaded', 'value' => $this->values_loaded]); $result .= html::hidden(['name' => '__form_onchange_field_values_key', 'value' => '']); if (!empty($this->options['bypass_hidden_values'])) { foreach ($this->options['bypass_hidden_values'] as $k => $v) { $result .= html::hidden(['name' => $k, 'value' => $v]); } } // js to update counters in tabs if (!empty($this->errors['tabs'])) { foreach ($this->errors['tabs'] as $k => $v) { layout::onload("\$('#{$k}').html({$v}); \$('#{$k}').show();"); } } // if we have form if (empty($this->options['skip_form'])) { $mvc = application::get('mvc'); $result = html::form(['action' => $mvc['full'], 'name' => "form_{$this->form_link}_form", 'id' => "form_{$this->form_link}_form", 'value' => $result, 'onsubmit' => empty($this->options['no_ajax_form_reload']) ? 'return numbers.form.on_form_submit(this);' : null]); } // if we came from ajax we return as json object if (!empty($this->options['input']['__ajax'])) { $result = ['success' => true, 'error' => [], 'html' => $result, 'js' => layout::$onload]; layout::render_as($result, 'application/json'); } $result = "<div id=\"form_{$this->form_link}_form_mask\"><div id=\"form_{$this->form_link}_form_wrapper\">" . $result . '</div></div>'; // if we have segment if (isset($this->options['segment'])) { $temp = is_array($this->options['segment']) ? $this->options['segment'] : []; $temp['value'] = $result; $result = html::segment($temp); } return $result; }
/** * Render list * * @return string */ public final function render() { $result = ''; // css & js layout::add_css('/numbers/media_submodules/numbers_frontend_html_list_media_css_base.css', 9000); layout::add_js('/numbers/media_submodules/numbers_frontend_html_list_media_js_base.js', 9000); // load mask numbers_frontend_media_libraries_loadmask_base::add(); // hidden fields $result .= html::hidden(['name' => 'offset', 'id' => 'offset', 'value' => $this->offset]); $result .= html::hidden(['name' => 'limit', 'id' => 'limit', 'value' => $this->limit]); // get total number of rows from count datasource if (!empty($this->datasources['count'])) { $temp = factory::model($this->datasources['count']['model'])->get($this->datasources['count']['options']); $this->total = $temp[0]['count'] ?? 0; } // get rows if (!empty($this->datasources['data'])) { $this->rows = factory::model($this->datasources['data']['model'])->get($this->datasources['data']['options']); $this->num_rows = count($this->rows); } // new record if (object_controller::can('record_new')) { $mvc = application::get('mvc'); $url = $mvc['controller'] . '/_edit'; $this->actions['list_new'] = ['value' => 'New', 'sort' => -32000, 'icon' => 'file-o', 'href' => $url]; } // filter if (!empty($this->filter)) { $this->actions['list_filter'] = ['value' => 'Filter', 'sort' => 1, 'icon' => 'filter', 'onclick' => "numbers.modal.show('list_{$this->list_link}_filter');"]; $result .= numbers_frontend_html_list_filter::render($this); } // order by $this->actions['list_sort'] = ['value' => 'Sort', 'sort' => 2, 'icon' => 'sort-alpha-asc', 'onclick' => "numbers.modal.show('list_{$this->list_link}_sort');"]; $result .= numbers_frontend_html_list_sort::render($this); // export, before pagination if (object_controller::can('list_export')) { // add export link to the panel $result .= numbers_frontend_html_list_export::render($this); $this->actions['list_export'] = ['value' => 'Export/Print', 'sort' => 3, 'icon' => 'print', 'onclick' => "numbers.modal.show('list_{$this->list_link}_export');"]; // if we are exporting if (!empty($this->options['input']['submit_export']) && !empty($this->options['input']['export']['format'])) { $result .= numbers_frontend_html_list_export::export($this, $this->options['input']['export']['format']); goto finish; } } // refresh $this->actions['form_refresh'] = ['value' => 'Refresh', 'sort' => 32000, 'icon' => 'refresh', 'href' => 'javascript:location.reload();', 'internal_action' => true]; // pagination top if (!empty($this->pagination['top'])) { $result .= factory::model($this->pagination['top'])->render($this, 'top'); } // data $result .= '<hr class="simple"/>'; if (method_exists($this, 'render_data')) { $result .= $this->render_data(); } else { $result .= $this->render_data_default(); } $result .= '<hr class="simple"/>'; // pagination bottom if (!empty($this->pagination['bottom'])) { $result .= factory::model($this->pagination['bottom'])->render($this, 'bottom'); } finish: $value = ''; if (!empty($this->actions)) { $value .= '<div style="text-align: right;">' . $this->render_actions() . '</div>'; $value .= '<hr class="simple" />'; } // we add hidden submit element $result .= html::submit(['name' => 'submit_hidden', 'value' => 1, 'style' => 'display: none;']); // build a form $value .= html::form(['name' => "list_{$this->list_link}_form", 'id' => "list_{$this->list_link}_form", 'value' => $result, 'onsubmit' => 'return numbers.frontend_list.on_form_submit(this);']); // if we came from ajax we return as json object if (!empty($this->options['input']['__ajax'])) { $result = ['success' => true, 'html' => $value, 'js' => layout::$onload]; layout::render_as($result, 'application/json'); } $value = "<div id=\"list_{$this->list_link}_form_mask\"><div id=\"list_{$this->list_link}_form_wrapper\">" . $value . '</div></div>'; $temp = ['type' => 'primary', 'value' => $value]; return html::segment($temp); }