{$name}; $value = null; $key = null; if (count($args) > 1 && is_array($structure->{$name})) { $key = $args[0]; $value = $args[1]; if (!is_string($key) && !is_int($key)) { self::err("SmartUI structure property: $name must be string or int."); return null; } $structure->{$name}[$key] = $value; if (isset($args[2]) && Util::is_closure($args[2])) { //process callback $callback = $args[2]; Util::run_callback($callback, array($ui_member)); } return $ui_member; } else { if (isset($args[1]) && Util::is_closure($args[1])) { $value = $args[0]; $structure->{$name} = $value; $callback = $args[1]; Util::run_callback($callback, array($ui_member)); return $ui_member; } else if (is_array($structure->{$name}) && (is_string($args[0]) || is_int($args[0]))) { $key = $args[0]; if (!is_string($key) && !is_int($key)) { self::err("SmartUI property key: $key must be string or int."); return null; } return $structure->{$name}[$key]; } else { $value = $args[0]; $structure->{$name} = $value; return $ui_member; } } } self::err('Undefined structure property: '.$name); return null; } public function start_track() { $this->_track_start_time = microtime(true); } public function __call($name, $args) { $calls = explode('_', $name); if (!in_array($calls[0], self::$_ui_calls)) { self::err("Undefined call: $calls[0]"); return null; } $ui_class = strtolower($calls[1]); if (isset(self::$_uis[$ui_class]) && $calls[0] == 'create') { $reflection = new \ReflectionClass(self::$_uis[$ui_class]); $new_ui = $args ? $reflection->newInstanceArgs($args) : $reflection->newInstance(); $this->start_track(); return $new_ui; } else if ($calls[0] == 'print' && in_array($calls[1], self::$_alerts)) { $alert_args = array($args[0], $calls[1]); for ($i = 1; $i < count($args); $i++) { $alert_args[] = $args[$i]; } return call_user_func_array(array($this, 'print_alert'), $alert_args); } self::err("\"$ui_class\" is not a registered member of SmartUI: Class not found"); } public function run_time($print = true) { $time_end = microtime(true); $execution_time = number_format($time_end - $this->_track_start_time, 4); if ($print) echo $execution_time.'s'; else return $execution_time.'s'; } public static function err($message = "SmartUI Error notice:") { if (self::$debug) { $trace = debug_backtrace(); trigger_error($message.' in '.$trace[0]['file'].' on line '.$trace[0]['line'], E_USER_NOTICE); } } public static function get_progress($value, $type = '', $options = array()) { $real_value = str_replace('%', '', $value); $percent_value = $real_value.'%'; $options_map = array( 'transitional' => false, 'class' => array(), 'attr' => array(), 'background' => '', 'container' => 'div' ); $new_options_map = Util::set_array_prop_def($options_map, $options, 'class'); $classes = array(); $classes[] = 'progress-bar'; if ($type) $classes[] = 'progress-bar-'.$type; // add additional user classes if (is_array($new_options_map['class'])) { array_merge($classes, $new_options_map['class']); } else { $classes[] = $new_options_map['class']; } if ($new_options_map['background']) $classes[] = 'bg-color-'.$new_options_map['background']; $attrs = array(); $attrs_html = array(); if ($new_options_map['transitional']) $attrs['aria-valuetransitiongoal'] = $real_value; else $attrs['style'] = 'width: '.$percent_value; // add additional user attributes if (is_array($new_options_map['attr'])) { array_merge($attrs, $new_options_map['attr']); } else { $attrs_html[] = $new_options_map['attr']; } foreach ($attrs as $attr => $attr_value) { $attrs_html[] = $attr.'="'.$attr_value.'"'; } return'<'.$new_options_map['container'].' class="'.implode(' ', $classes).'" '.implode(' ', $attrs_html).'>'.$new_options_map['container'].'>'; } public static function print_stack_progress($progress_bars, $base_options = array(), $return = false) { $options_map = array( 'tooltip' => array(), 'position' => 'left', // left, right, bottom (for vertical) 'wide' => false, 'size' => 'md', // sm, xs, md, xl, micro 'striped' => false, // true or 'active' 'vertical' => false ); $new_options_map = Util::set_array_prop_def($options_map, $base_options, 'class'); $container_classes = array(); $container_classes[] = "progress"; if ($new_options_map['vertical']) $container_classes[] = 'vertical'; if ($new_options_map['position']) $container_classes[] = $new_options_map['position']; if ($new_options_map['wide']) $container_classes[] = 'wide-bar'; if ($new_options_map['striped']) { $container_classes[] = 'progress-striped'; if ($new_options_map['striped'] === 'active') $container_classes[] = 'active'; } $container_classes[] = 'progress-'.$new_options_map['size']; $container_attrs = array(); $container_attrs_html = array(); if ($new_options_map['tooltip']) { $tooltip_prop = array( 'placement' => 'top', 'title' => '' ); $tooltip = $new_options_map['tooltip']; $new_tooltip_prop = Util::set_array_prop_def($tooltip_prop, $tooltip, 'title'); $container_attrs['rel'] = 'tooltip'; $container_attrs['data-original-title'] = $new_tooltip_prop['title']; $container_attrs['data-placement'] = $new_tooltip_prop['placement']; } foreach ($container_attrs as $container_attr => $attr_value) { $container_attrs_html[] = $container_attr.'="'.$attr_value.'"'; } $result = '