public function print_html($return = false) { $get_property_value = parent::_get_property_value_func(); $that = $this; $structure = $this->_structure; $rows = $get_property_value($structure->row, array('if_closure' => function ($rows) use($that) { return SmartUI::run_callback($rows, array($that)); }, 'if_other' => function ($rows) { SmartUI::err('SmartUI::ProfileInfo::row requires array'); return null; })); if (!is_array($rows)) { parent::err("SmartUI::ProfileInfo::row requires array"); return null; } $rows_html_list = array(); foreach ($rows as $key => $info) { $row_prop = array('icon' => isset($structure->icon[$key]) ? $structure->icon[$key] : '', 'value' => isset($structure->value[$key]) ? $structure->value[$key] : '', 'name' => isset($structure->name[$key]) ? $structure->name[$key] : $key, 'action' => isset($structure->action[$key]) ? $structure->action[$key] : ''); $new_row_prop = parent::get_clean_structure($row_prop, $info, array($that, $rows, $key), 'value'); $icon = $new_row_prop['icon'] ? '<i class="' . SmartUI::$icon_source . ' ' . $new_row_prop['icon'] . '"></i> ' : ''; $row_html = '<div class="info-row">'; $row_html .= ' <div class="info-name"> ' . $new_row_prop['name'] . ' </div>'; $row_html .= ' <div class="info-action"> ' . $new_row_prop['action'] . ' </div>'; $row_html .= ' <div class="info-value"> ' . $icon . $new_row_prop['value'] . ' </div>'; $row_html .= '</div>'; $rows_html_list[] = $row_html; } $classes = array(); if ($structure->options['stripped']) { $classes[] = 'info-stripped'; } if ($structure->options['grouped']) { $classes[] = 'info-grouped'; } $classes[] = $structure->options['class']; $result = '<div class="info' . ($classes ? ' ' . implode(' ', $classes) : '') . '">'; $result .= $structure->title ? '<div class="info-title">' . $structure->title . '</div>' : ''; $result .= implode('', $rows_html_list); $result .= '</div>'; if ($return) { return $result; } else { echo $result; } }
public function print_html($return = false) { $get_property_value = parent::_get_property_value_func(); $that = $this; $structure = $this->_structure; $nav_items = $get_property_value($structure->nav, array('if_closure' => function ($nav_items) use($that) { return SmartUI::run_callback($nav_items, array($that)); }, 'if_other' => function ($nav_items) { SmartUI::err('SmartUI::Nav:nav requires array'); return null; })); if (!is_array($nav_items)) { parent::err("SmartUI::Nav:nav requires array"); return null; } $list_items = $this->parse_nav($nav_items, true); $result = parent::print_list($list_items, null, true); if ($return) { return $result; } else { echo $result; } }
public function print_html($return = false) { $get_property_value = parent::_get_property_value_func(); $that = $this; $structure = $this->_structure; $structure->options = parent::set_array_prop_def($this->_options_map, $structure->options); $tabs = $get_property_value($structure->tab, array('if_closure' => function ($tabs) use($that) { return SmartUI::run_callback($tabs, array($that)); }, 'if_other' => function ($tabs) { SmartUI::err('SmartUI::Tab::tab requires array'); return null; })); if (!is_array($tabs)) { parent::err("SmartUI::Tab::tab requires array"); return null; } $li_list = array(); $tab_content_list = array(); $has_active = false; foreach ($tabs as $tab_id => $tab_prop) { $tab_structure = array('content' => isset($structure->content[$tab_id]) ? $structure->content[$tab_id] : '', 'title' => isset($structure->title[$tab_id]) ? $structure->title[$tab_id] : '', 'icon' => isset($structure->icon[$tab_id]) ? $structure->icon[$tab_id] : '', 'dropdown' => isset($structure->dropdown[$tab_id]) ? $structure->dropdown[$tab_id] : '', 'position' => isset($structure->position[$tab_id]) ? $structure->position[$tab_id] : '', 'active' => isset($structure->active[$tab_id]) && $structure->active[$tab_id] === true, 'fade' => false); $new_tab_prop = parent::get_clean_structure($tab_structure, $tab_prop, array($that, $tabs, $tab_id), 'title'); foreach ($new_tab_prop as $tab_prop_key => $tab_prop_vaue) { $new_tab_prop_value = $get_property_value($tab_prop_vaue, array('if_closure' => function ($prop_value) use($that, $tabs) { return SmartUI::run_callback($prop_value, array($that, $tabs)); })); $new_tab_prop[$tab_prop_key] = $new_tab_prop_value; } $tab_content_classes = array(); $tab_content_classes[] = 'tab-pane'; $li_classes = array(); $a_classes = array(); $a_attr = array(); if (!$structure->active && !$has_active || $new_tab_prop['active'] === true && !$has_active) { $li_classes[] = 'active'; $tab_content_classes[] = 'in active'; $has_active = true; } $title = $new_tab_prop['title']; $dropdown_html = ''; if ($new_tab_prop['dropdown']) { $dropdown = $new_tab_prop['dropdown']; $li_classes[] = 'dropdown'; $href = 'javascript:void(0);'; $dropdown_html = is_array($dropdown) ? parent::print_dropdown($dropdown, false, true) : $dropdown; $a_classes[] = 'dropdown-toggle'; $a_attr[] = 'data-toggle="dropdown"'; $title .= ' <b class="caret"></b>'; } else { $href = '#' . $tab_id; $a_attr[] = 'data-toggle="tab"'; } if ($new_tab_prop['position']) { $li_classes[] = 'pull-' . $new_tab_prop['position']; } $icon = $new_tab_prop['icon'] ? '<i class="fa ' . $new_tab_prop['icon'] . '"></i> ' : ''; $class = $li_classes ? ' class="' . implode(' ', $li_classes) . '"' : ''; $li_html = '<li' . $class . '>'; $li_html .= '<a href="' . $href . '" ' . ($a_classes ? 'class="' . implode(' ', $a_classes) . '"' : '') . ($a_attr ? ' ' . implode(' ', $a_attr) : '') . '>' . $icon . $title . '</a>'; $li_html .= $dropdown_html; $li_html .= '</li>'; $li_list[] = $li_html; if ($new_tab_prop['fade']) { $tab_content_classes[] = 'fade'; } $tab_content_html = '<div class="' . implode(' ', $tab_content_classes) . '" id="' . $tab_id . '">'; $tab_content_html .= $new_tab_prop['content']; $tab_content_html .= '</div>'; $tab_content_list[] = $tab_content_html; } $ul_classes = array(); $ul_attr = array(); $ul_classes[] = 'nav nav-tabs'; $ul_id = $structure->tabs_id ? 'id="' . $structure->tabs_id . '"' : ''; $ul_attr[] = $ul_id; $content_classes = array(); $content_classes[] = 'tab-content'; if ($structure->content_class) { $content_classes[] = is_array($structure->content_class) ? implode(' ', $structure->content_class) : $structure->content_class; } $content_id = $structure->content_id ? 'id="' . $structure->content_id . '"' : ''; if ($structure->options['padding']) { $content_classes[] = 'padding-' . $structure->options['padding']; } $content_html = '<div class="' . implode(' ', $content_classes) . '" ' . $content_id . '>'; $content_html .= implode('', $tab_content_list); $content_html .= '</div>'; $main_content_html = ''; if ($structure->options['widget']) { $ul_classes[] = $structure->options['pull'] ? 'pull-' . $structure->options['pull'] : 'pull-left'; $ul_html = '<ul class="' . implode(' ', $ul_classes) . '" ' . implode(' ', $ul_attr) . '>'; $ul_html .= implode('', $li_list); $ul_html .= '</ul>'; $widget = $structure->options['widget']; if (!$widget instanceof Widget) { $ui = new parent(); $widget = $ui->create_widget(); } $widget->body('content', $content_html); $widget->options('colorbutton', false)->options('editbutton', false); $widget->header('title', $ul_html); $result = $widget->print_html(true); } else { if ($structure->options['bordered']) { $ul_classes[] = 'bordered'; } if ($structure->options['pull']) { $ul_classes[] = 'tabs-pull-' . $structure->options['pull']; } $ul_html = '<ul class="' . implode(' ', $ul_classes) . '" ' . implode(' ', $ul_attr) . '>'; $ul_html .= implode('', $li_list); $ul_html .= '</ul>'; $container_classes = array(); $container_classes[] = 'tabbable'; switch ($structure->options['position']) { case 'right': case 'left': $container_classes[] = 'tabs-' . $structure->options['position']; $main_content_html = $ul_html . $content_html; break; case 'below': $container_classes[] = 'tabs-' . $structure->options['position']; $main_content_html = $content_html . $ul_html; break; default: $main_content_html = $ul_html . $content_html; break; } $result = '<div class="' . implode(' ', $container_classes) . '">'; $result .= $main_content_html; $result .= '</div>'; } if ($return) { return $result; } else { echo $result; } }
public function print_html($return = false) { $get_property_value = parent::_get_property_value_func(); $that = $this; $structure = $this->_structure; $fields = $get_property_value($structure->field, array('if_closure' => function ($fields) use($that) { return SmartUI::run_callback($fields, array($that)); }, 'if_other' => function ($fields) { SmartUI::err('SmartUI::SmartForm:field requires array'); return null; })); if (!is_array($fields)) { parent::err("SmartUI::SmartForm:field requires array"); return null; } if (!$structure->fieldset || !is_array($structure->fieldset)) { $structure->fieldset[] = array_keys($fields); } $fieldsets_html_list = array(); $hidden_fields_list = array(); $fieldsets = count($structure->fieldset); for ($fs_index = 0; $fs_index < $fieldsets; $fs_index++) { $fs_fields = $structure->fieldset[$fs_index]; $groups = array(); $with_col_cntr = 0; $grouped = false; if (is_string($fs_fields)) { $fs_fields = array($fs_fields); } foreach ($fs_fields as $field_name) { $field = $structure->field[$field_name]; $field_prop = array('type' => self::FORM_FIELD_INPUT, 'col' => 0, 'properties' => array()); $new_field_prop = parent::get_clean_structure($field_prop, $field, array($this, $fs_index, $fs_fields), 'type'); if ($new_field_prop['type'] == self::FORM_FIELD_HIDDEN) { $field_html = self::print_field($field_name, self::FORM_FIELD_HIDDEN, $new_field_prop['properties'], true); $hidden_fields_list[] = $field_html; continue; } if (isset($structure->property[$field_name])) { $new_field_prop['properties'] = $structure->property[$field_name]; } if (isset($structure->col[$field_name])) { $new_field_prop['col'] = $structure->col[$field_name]; } if (isset($structure->type[$field_name])) { $new_field_prop['type'] = $structure->type[$field_name]; } $field_html = self::print_field($field_name, $new_field_prop['type'], $new_field_prop['properties'], $new_field_prop['col'], true); $collumned = $new_field_prop['col'] > 0 && $new_field_prop['col'] < 12; if (!$grouped) { $last_group_key = SmartUtil::create_id(); $group = self::_create_field_group($collumned, $field_html, $new_field_prop['col']); $groups[$last_group_key] = $group; $grouped = true; } else { $last_group = $groups[$last_group_key]; if ($last_group->collumned === $collumned && $last_group->total < 12) { $last_group->items[] = $field_html; $last_group->total = $last_group->total + (int) $new_field_prop['col']; } else { $last_group_key = SmartUtil::create_id(); $group = self::_create_field_group($collumned, $field_html, $new_field_prop['col']); $groups[$last_group_key] = $group; $grouped = true; } } } $fields_html_list = array(); foreach ($groups as $group) { $group_html = ''; $fields_html = implode('', $group->items); if ($group->collumned) { $group_html .= '<div class="row">'; $group_html .= $fields_html; $group_html .= '</div>'; } else { $group_html .= $fields_html; } $fields_html_list[] = $group_html; } $fieldsets_html_list[] = '<fieldset>' . implode('', $fields_html_list) . '</fieldset>'; } $header = $get_property_value($structure->header, array('if_closure' => function ($header) use($that) { return SmartUI::run_callback($header, array($that)); })); $footer = $get_property_value($structure->footer, array('if_closure' => function ($footer) use($that) { return SmartUI::run_callback($footer, array($that)); })); $form_attrs = array(); $form_attrs[] = 'class="smart-form ' . (is_array($structure->class) ? implode(' ', $structure->class) : $structure->class) . '"'; $form_attrs[] = 'id="' . ($structure->id ? $structure->id : SmartUtil::create_id()) . '"'; $form_attrs = array_merge($form_attrs, array_map(function ($attr, $value) { return $attr . '="' . $value . '"'; }, array_keys($structure->attr), $structure->attr)); $form_html = '<' . $structure->options['wrapper'] . ' ' . implode(' ', $form_attrs) . '>'; $form_html .= $header ? '<header>' . $header . '</header>' : ''; $form_html .= implode('', $fieldsets_html_list); $form_html .= implode(' ', $hidden_fields_list); $form_html .= $footer ? '<footer>' . $footer . '</footer>' : ''; $form_html .= '</' . $structure->options['wrapper'] . '>'; if (isset($structure->options["in_widget"]) && $structure->options["in_widget"]) { $structure->widget->body("content", $form_html); if ($structure->title) { $structure->widget->header('title', $structure->title); } $result = $structure->widget->print_html(true); } else { $result = $form_html; } if ($return) { return $result; } else { echo $result; } }
private function _get_bootstrap_result() { $get_property_value = parent::_get_property_value_func(); $that = $this; $structure = $this->_structure; $steps = $get_property_value($structure->step, array('if_closure' => function ($steps) use($that) { return SmartUI::run_callback($steps, array($that)); }, 'if_other' => function ($steps) { SmartUI::err('SmartUI::Wizard::step requires array'); return null; })); if (!is_array($steps)) { parent::err("SmartUI::Wizard::step requires array"); return null; } $li_list = array(); $step_content_list = array(); $has_active = false; $step = 1; foreach ($steps as $step_id => $step_prop) { $step_structure = array('content' => isset($structure->content[$step_id]) ? $structure->content[$step_id] : '', 'title' => isset($structure->title[$step_id]) ? $structure->title[$step_id] : '', 'step' => $step, 'active' => isset($structure->active[$step_id]) && $structure->active[$step_id] === true); $new_step_prop = parent::get_clean_structure($step_structure, $step_prop, array($that, $steps, $step_id), 'title'); foreach ($new_step_prop as $step_prop_key => $step_prop_vaue) { $new_step_prop_value = $get_property_value($step_prop_vaue, array('if_closure' => function ($prop_value) use($that, $steps) { return SmartUI::run_callback($prop_value, array($that, $steps)); })); $new_step_prop[$step_prop_key] = $new_step_prop_value; } $step_content_classes = array(); $step_content_classes[] = 'tab-pane'; $li_classes = array(); $a_classes = array(); $a_attr = array(); if (!$structure->active && !$has_active || $new_step_prop['active'] === true && !$has_active) { $li_classes[] = 'active'; $step_content_classes[] = 'active'; $has_active = true; } $title = $new_step_prop['title']; $href = '#' . $step_id; $a_attr[] = 'data-toggle="tab"'; $class = $li_classes ? ' class="' . implode(' ', $li_classes) . '"' : ''; $li_html = '<li' . $class . ' data-target="#' . $step_id . '">'; $li_html .= '<a href="' . $href . '" ' . ($a_classes ? 'class="' . implode(' ', $a_classes) . '"' : '') . ($a_attr ? ' ' . implode(' ', $a_attr) : '') . '>'; $li_html .= '<span class="step">' . $new_step_prop['step'] . '</span> <span class="title">' . $title . '</span>'; $li_html .= '</a>'; $li_html .= '</li>'; $li_list[] = $li_html; $step_content_html = '<div class="' . implode(' ', $step_content_classes) . '" id="' . $step_id . '">'; $step_content_html .= $new_step_prop['content']; $step_content_html .= '</div>'; $step_content_list[] = $step_content_html; $step++; } $ul_classes = array(); $ul_classes[] = 'bootstrapWizard'; $ul_classes[] = $structure->tabl_class; $content_classes = array(); $content_classes[] = 'tab-content'; $content_html = '<div class="' . implode(' ', $content_classes) . '">'; $content_html .= implode('', $step_content_list); $content_html .= ' <div class="form-actions"> <div class="row"> <div class="col-sm-12"> <ul class="pager wizard no-margin"> <!--<li class="previous first disabled"> <a href="javascript:void(0);" class="btn btn-lg btn-default"> First </a> </li>--> <li class="previous disabled"> <a href="javascript:void(0);" class="btn btn-lg btn-default"> Previous </a> </li> <!--<li class="next last"> <a href="javascript:void(0);" class="btn btn-lg btn-primary"> Last </a> </li>--> <li class="next"> <a href="javascript:void(0);" class="btn btn-lg txt-color-darken"> Next </a> </li> </ul> </div> </div> </div>'; $content_html .= '</div>'; $ul_html = '<div class="form-bootstrapWizard">'; $ul_html .= ' <ul class="' . implode(' ', $ul_classes) . '">'; $ul_html .= implode('', $li_list); $ul_html .= ' </ul>'; $ul_html .= ' <div class="clearfix"></div>'; $ul_html .= '</div>'; $main_content_html = '<div class="row">'; $main_content_html .= ' <div class="col-sm-12" id="' . $structure->id . '">'; $main_content_html .= $ul_html . $content_html; $main_content_html .= ' </div>'; $main_content_html .= '</div>'; if (isset($structure->options["in_widget"]) && $structure->options["in_widget"]) { $structure->widget->body("content", $main_content_html); if ($structure->title) { $structure->widget->header('title', $structure->title); } $result = $structure->widget->print_html(true); } else { $result = $main_content_html; } return $result; }
public function print_html($return = false) { $get_property_value = parent::_get_property_value_func(); $that = $this; $structure = $this->_structure; $items = $get_property_value($structure->item, array('if_closure' => function ($items) use($that) { return SmartUI::run_callback($items, array($that)); }, 'if_other' => function ($items) { SmartUI::err('SmartUI::Carousel:item requires array'); return null; })); if (!is_array($items)) { parent::err("SmartUI::Carousel:item requires array"); return null; } $indicators_list = array(); $items_list = array(); $has_active = false; $index = 0; foreach ($items as $item_key => $item) { $item_structure = array('img' => isset($structure->img[$item_key]) ? $structure->img[$item_key] : '', 'caption' => isset($structure->caption[$item_key]) ? $structure->caption[$item_key] : '', 'active' => isset($structure->active[$item_key]) ? $structure->active[$item_key] : ''); $new_item_prop = parent::get_clean_structure($item_structure, $item, array($this, $items), 'img'); foreach ($new_item_prop as $tab_item_key => $item_prop_value) { $new_item_prop_value = $get_property_value($item_prop_value, array('if_closure' => function ($prop_value) use($that, $items) { return SmartUI::run_callback($prop_value, array($that, $items)); })); $new_item_prop[$tab_item_key] = $new_item_prop_value; } $image_prop = array('src' => '', 'alt' => ''); $new_image_prop = parent::get_clean_structure($image_prop, $new_item_prop['img'], array($this, $items, $new_item_prop), 'src'); $indicator_classes = array(); $item_classes = array(); $item_classes[] = 'item'; if (!$structure->active && !$has_active || $new_item_prop['active'] === true && !$has_active) { $has_active = true; $indicator_classes[] = 'active'; $item_classes[] = 'active'; } $indicators_list[] = '<li data-target="#' . $structure->id . '" data-slide-to="' . $index . '" class="' . implode(' ', $indicator_classes) . '"></li>'; $item_html = '<div class="' . implode(' ', $item_classes) . '">'; $item_html .= ' <img src="' . $new_image_prop['src'] . '" alt="' . $new_image_prop['alt'] . '">'; $item_html .= ' <div class="carousel-caption">'; $item_html .= $new_item_prop['caption']; $item_html .= ' </div>'; $item_html .= '</div>'; $items_list[] = $item_html; $index++; } $controls_html = ''; if ($structure->options['controls']) { $controls_html .= ' <a class="left carousel-control" href="#' . $structure->id . '" data-slide="prev">'; $controls_html .= $structure->options['controls'][0]; $controls_html .= ' </a>'; $controls_html .= ' <a class="right carousel-control" href="#' . $structure->id . '" data-slide="next">'; $controls_html .= $structure->options['controls'][1]; $controls_html .= ' </a>'; } $result = '<div id="' . $structure->id . '" class="carousel ' . $structure->options['style'] . '">'; $result .= ' <ol class="carousel-indicators">'; $result .= implode('', $indicators_list); $result .= ' </ol>'; $result .= ' <div class="carousel-inner">'; $result .= implode('', $items_list); $result .= ' </div>'; $result .= $controls_html; $result .= '</div>'; if ($return) { return $result; } else { echo $result; } }
public function print_html($return = false) { $get_property_value = parent::_get_property_value_func(); $that = $this; $structure = $this->_structure; $panels = $get_property_value($structure->panel, array('if_closure' => function ($panels) use($that) { return SmartUI::run_callback($panels, array($that)); }, 'if_other' => function ($panels) { SmartUI::err('SmartUI::Accordion:panel requires array'); return null; })); if (!is_array($panels)) { parent::err("SmartUI::Accordion:panel requires array"); return null; } $panel_html_list = array(); foreach ($panels as $panel_id => $panel_prop) { $panel_structure = array('header' => isset($structure->header[$panel_id]) ? $structure->header[$panel_id] : '', 'content' => isset($structure->content[$panel_id]) ? $structure->content[$panel_id] : '', 'expand' => isset($structure->expand[$panel_id]) ? $structure->expand[$panel_id] : false, 'padding' => isset($structure->padding[$panel_id]) ? $structure->padding[$panel_id] : null); $new_panel_prop = parent::get_clean_structure($panel_structure, $panel_prop, array($this, $panels), 'header'); foreach ($new_panel_prop as $panel_prop_key => $panel_prop_vaue) { $new_panel_prop_value = $get_property_value($panel_prop_vaue, array('if_closure' => function ($prop_value) use($that, $panels) { return SmartUI::run_callback($prop_value, array($that, $panels)); })); $new_panel_prop[$panel_prop_key] = $new_panel_prop_value; } // header $header_structure = array('content' => '', 'container' => 'h4', 'icons' => isset($structure->icons[$panel_id]) ? $structure->icons[$panel_id] : $structure->options['global_icons']); $new_header_prop = parent::get_clean_structure($header_structure, $new_panel_prop['header'], array($that, $panels), 'content'); $a_classes = array(); if (!$new_panel_prop['expand']) { $a_classes[] = 'collapsed'; } $a_attr = array(); $a_attr[] = 'data-parent="#' . $structure->id . '"'; $a_attr[] = 'href="#' . $panel_id . '"'; $a_attr[] = 'data-toggle="collapse"'; $icons = is_array($new_header_prop['icons']) ? implode(' ', array_map(function ($icon) { return '<i class="' . SmartUI::$icon_source . ' ' . $icon . '"></i> '; }, $new_header_prop['icons'])) : $new_header_prop['icons']; $body_classes = array(); $body_classes[] = 'panel-body'; if (isset($new_panel_prop['padding'])) { $body_classes[] = $new_panel_prop['padding'] ? 'padding-' . $new_panel_prop['padding'] : 'no-padding'; } $panel_html = '<div class="panel panel-default">'; $panel_html .= ' <div class="panel-heading">'; $panel_html .= ' <' . $new_header_prop['container'] . ' class="panel-title">'; $panel_html .= ' <a ' . implode(' ', $a_attr) . ' class="' . implode(' ', $a_classes) . '"> '; $panel_html .= $icons; $panel_html .= $new_header_prop['content']; $panel_html .= ' </a>'; $panel_html .= ' </' . $new_header_prop['container'] . '>'; $panel_html .= ' </div>'; $panel_html .= ' <div id="' . $panel_id . '" class="panel-collapse collapse ' . ($new_panel_prop['expand'] ? 'in' : '') . '">'; $panel_html .= ' <div class="' . implode(' ', $body_classes) . '">'; $panel_html .= $new_panel_prop['content']; $panel_html .= ' </div>'; $panel_html .= ' </div>'; $panel_html .= '</div>'; $panel_html_list[] = $panel_html; } $result = '<div class="panel-group smart-accordion-default" id="' . $structure->id . '">'; $result .= implode('', $panel_html_list); $result .= '</div>'; if ($return) { return $result; } else { echo $result; } }