function type($model, $vlevel = HC_PRESENTER::VIEW_HTML) { switch ($model->type) { case $model->_const('TYPE_TIMEOFF'): $type_text = HCM::__('Timeoff'); $type_icon = 'timeoff'; break; default: $type_text = HCM::__('Shift'); $type_icon = 'shift'; break; } switch ($vlevel) { case HC_PRESENTER::VIEW_HTML: $label_class = $this->status_class($model); $return = HC_Html_Factory::widget('titled', 'span')->add_attr('class', array('alert'))->add_attr('class', array('alert-condensed'))->add_child(HC_Html::icon(HC_App::icon_for($type_icon)))->add_child($type_text); if (!is_array($label_class)) { $label_class = array($label_class); } foreach ($label_class as $lc) { $return->add_attr('class', 'alert-' . $lc); } break; case HC_PRESENTER::VIEW_HTML_ICON: $return = HC_Html::icon(HC_App::icon_for($type_icon)); list($label_text, $label_class) = $this->_status_details($model); // $return->add_attr('class', 'text-' . $label_class); $title = array(); $title[] = $model->present_type(HC_PRESENTER::VIEW_RAW); $title[] = $label_text; $title = join(': ', $title); $return->add_attr('title', $title); break; case HC_PRESENTER::VIEW_TEXT: $return = HCM::_x('Type', 'noun') . ': ' . $type_text; break; case HC_PRESENTER::VIEW_RAW: $return = $type_text; break; } return $return; }
function render() { if (!($link = $this->link())) { return 'HC_Html_Widget_Filter: link is not set!'; } // $this->set_panel('default'); $add_title = $this->title(); $readonly = $this->readonly(); $allow_multiple = $this->allow_multiple(); $require_one = $this->require_one(); $fixed = $this->fixed(); $title = $add_title; $selected = $this->selected(); if ($selected) { $title = array(); foreach ($selected as $sel) { $title[] = $this->option($sel); } $title = join(' ', $title); } $filter_icon = HC_Html_Factory::element('span')->add_attr('class', 'btn')->add_attr('class', 'btn-default')->add_child(HC_Html::icon('glass')); $filter_icon = ''; if ($readonly && !$this->selected()) { return NULL; } $title = $filter_icon . $title; $this->set_title($title); $content = HC_Html_Factory::widget('list')->add_attr('class', 'list-inline')->add_attr('class', 'list-separated')->add_attr('class', 'list-separated-ver'); $btn_size = $this->btn_size(); $btn_size = 'btn-' . $btn_size; /* remaining possible options */ $remain_options = FALSE; if (!$this->selected() or $allow_multiple) { $param_name = $this->param_name(); foreach ($this->options() as $id => $label) { if (!in_array($id, $this->selected())) { $option_wrap = HC_Html_Factory::widget('titled', 'a')->add_attr('class', 'btn')->add_attr('class', $btn_size)->add_attr('class', 'btn-default')->add_attr('class', 'squeeze-in')->add_attr('class', 'text-left')->add_attr('style', 'width: 10em;')->add_attr('style', 'text-align: left;'); if ($param_name === NULL) { $option_wrap->add_attr('href', $link->url($id, array())); } else { $option_wrap->add_attr('href', $link->url(array($param_name . '+' => $id))); } $option_wrap->add_child($label); $attr = isset($this->option_attr[$id]) ? $this->option_attr[$id] : array(); foreach ($attr as $attr_k => $attr_v) { $option_wrap->add_attr($attr_k, $attr_v); } $content->add_item($id, $option_wrap); $remain_options = TRUE; } } } $this->set_content($content); $panel = $this->panel(); $out = HC_Html_Factory::widget('list')->add_attr('class', 'list-unstyled')->add_attr('class', 'collapse-panel'); if ($panel) { $out->add_attr('class', array('panel', 'panel-' . $panel)); $out->add_attr('class', array('panel-condensed')); } /* build trigger */ $title = HC_Html_Factory::widget('list')->add_attr('class', 'list-separated')->add_attr('class', 'list-inline'); /* current selection */ $selected = $this->selected(); if ($selected) { foreach ($selected as $sel) { if ($require_one) { $option_wrap = HC_Html_Factory::widget('titled', 'a')->add_attr('href', '#')->add_attr('class', 'hc-collapse-next'); } else { $option_wrap = HC_Html_Factory::widget('titled', 'div'); if (!$fixed) { $option_wrap->add_child(HC_Html_Factory::element('a')->add_attr('href', $link->url(array($this->param_name() . '-' => $sel)))->add_attr('class', 'btn-close')->add_attr('class', 'btn')->add_attr('class', 'btn-danger-o')->add_child(HC_Html::icon('times'))); } } $option_wrap->add_attr('class', 'btn')->add_attr('class', $btn_size)->add_attr('class', 'btn-default')->add_attr('class', 'btn')->add_attr('class', 'squeeze-in')->add_attr('class', 'text-left')->add_attr('style', 'width: 10em;')->add_attr('style', 'text-align: left;'); $option_label = $this->option($sel); $option_wrap->add_child($option_label); if ($require_one) { $option_wrap->add_child(' ')->add_child(HC_Html_Factory::element('b')->add_attr('class', 'caret')); } $attr = isset($this->option_attr[$sel]) ? $this->option_attr[$sel] : array(); foreach ($attr as $attr_k => $attr_v) { $option_wrap->add_attr($attr_k, $attr_v); } $title->add_item($sel, $option_wrap); } } if ($remain_options && !$require_one) { $trigger = HC_Html_Factory::element('a')->add_child(HC_Html::icon('plus') . HCM::_x('Filter', 'noun') . ': ' . $add_title)->add_attr('href', '#')->add_attr('class', 'hc-collapse-next')->add_attr('class', 'btn')->add_attr('class', 'btn-success-o')->add_attr('class', $btn_size); $title->add_item($trigger); } $out->add_item('header', $title); if ($panel) { $out->add_item_attr('header', 'class', 'panel-heading'); } $out->add_item_attr('content', 'class', 'collapse'); if ($panel) { $out->add_item_attr('content', 'class', 'panel-collapse'); } if ($this->default_in()) { $out->add_item_attr('content', 'class', 'in'); } if ($panel) { $out->add_item('content', HC_Html_Factory::element('div')->add_attr('class', 'panel-body')->add_child($this->content())); } else { $out->add_item('content', $this->content()); } return $out->render(); return parent::render(); }
function label($model, $vlevel = HC_PRESENTER::VIEW_HTML) { $return = HCM::_x('Comment', 'noun'); return $return; }