Esempio n. 1
0
 function render()
 {
     $sh = $this->shift();
     $t = HC_Lib::time();
     $titles = array();
     $iknow = $this->iknow();
     $wide = $this->wide();
     $use_color = FALSE;
     $use_color = TRUE;
     if ($wide && $wide === 'mini') {
         $use_color = TRUE;
     }
     if (in_array($sh->type, array($sh->_const("TYPE_TIMEOFF")))) {
         $display = array('date', 'time', 'user', 'location');
     } else {
         if (!$wide or $wide === 'mini') {
             $display = array('date', 'time', 'location', 'user');
         } elseif ($wide) {
             $display = array('date', 'time', 'user', 'location');
         }
     }
     foreach ($iknow as $ik) {
         $display = HC_Lib::remove_from_array($display, $ik);
     }
     // if( in_array($sh->type, array($sh->_const("TYPE_TIMEOFF"))) ){
     // $display = HC_Lib::remove_from_array($display, 'location');
     // }
     foreach ($display as $ds) {
         $title_view = '';
         switch ($ds) {
             case 'date':
                 $title_view = $sh->present_date(HC_PRESENTER::VIEW_RAW);
                 break;
             case 'time':
                 $title_view = $sh->present_time();
                 break;
             case 'location':
                 if (in_array($sh->type, array($sh->_const("TYPE_TIMEOFF")))) {
                     $title_view = '';
                     // $title_view = HCM::__('Timeoff');
                     // $title_view = $sh->present_location();
                 } else {
                     $title_view = $sh->present_location();
                 }
                 break;
             case 'user':
                 if ($sh->type == $sh->_const('TYPE_TIMEOFF') && !in_array('time', $display)) {
                     $title_view = $sh->present_type(HC_PRESENTER::VIEW_HTML_ICON) . $sh->present_user(HC_PRESENTER::VIEW_RAW);
                 } else {
                     // $titles[] = $sh->present_user();
                     if ($sh->user_id) {
                         $title_view = $sh->present_user(HC_PRESENTER::VIEW_RAW);
                     } else {
                         $title_view = $sh->present_user();
                     }
                 }
                 break;
         }
         // if( $title_view ){
         $titles[] = $title_view;
         // }
     }
     $wrap = HC_Html_Factory::element('div')->add_attr('class', array('alert', 'display-block'))->add_attr('class', array('alert-default-o'))->add_attr('class', array('no-underline'))->add_attr('class', array('alert-condensed2'))->add_attr('class', array('text-smaller'))->add_attr('class', array('squeeze-in'));
     foreach ($sh->present_status_class() as $status_class) {
         // $wrap->add_attr('class', 'alert-' . $status_class);
     }
     /* background color depends on location */
     if ($use_color) {
         $color = $sh->location->present_color();
     } else {
         $type = $sh->type;
         switch ($type) {
             case $sh->_const('TYPE_TIMEOFF'):
                 $wrap->add_attr('class', array('alert-archive'));
                 $color = '#ddd';
                 break;
             default:
                 $wrap->add_attr('class', array('alert-success-o'));
                 $color = '#dff0d8';
                 break;
         }
     }
     if ($sh->status == $sh->_const('STATUS_DRAFT')) {
         $color1 = HC_Lib::adjust_color_brightness($color, 0);
         $color2 = HC_Lib::adjust_color_brightness($color, 20);
         // $color1 = '#fff';
         // $color2 = '#eee';
         $wrap->add_attr('style', "background: repeating-linear-gradient(\r\n\t\t\t\t\t-45deg,\r\n\t\t\t\t\t{$color1},\r\n\t\t\t\t\t{$color1} 6px,\r\n\t\t\t\t\t{$color2} 6px,\r\n\t\t\t\t\t{$color2} 12px\r\n\t\t\t\t\t);\r\n\t\t\t\t");
     } else {
         $wrap->add_attr('style', 'background-color: ' . $color . ';');
         // $wrap->add_attr('class', 'alert-success');
     }
     if (!$sh->user_id) {
         $wrap->add_attr('class', 'hc-red-triangled');
     }
     //		echo $color;
     /* ID */
     if (in_array('id', $iknow)) {
         $wrap->add_child($sh->present_id());
     }
     /* build link title */
     $nolink = $this->nolink();
     $new_window = $this->new_window();
     $a_link = HC_Html_Factory::widget('titled', 'a');
     $link_to = 'shifts/zoom/index/id/' . $sh->id;
     $a_link->add_attr('href', HC_Lib::link($link_to)->url());
     if (!$new_window) {
         $a_link->add_attr('class', 'hc-flatmodal-loader');
     } else {
         $a_link->add_attr('target', '_blank');
         $a_link->add_attr('class', 'hc-parent-loader');
     }
     if ($nolink) {
         $a_title = HC_Html_Factory::widget('titled', 'span');
     } else {
         $a_title = HC_Html_Factory::widget('titled', 'a');
     }
     $a_title = HC_Html_Factory::widget('titled', 'span');
     $a_title->add_attr('class', array('squeeze-in'));
     // $a_title->add_attr('style', 'border: red 1px solid;');
     // $a_title->add_attr('style', 'border-color: ' . $sh->location->present_color());
     if ($wide === 'mini') {
         if (!$nolink) {
             $final_ttl = clone $a_link;
             $final_ttl->add_child(' ')->add_attr('style', 'display: block;');
             $final_ttl->add_attr('title', join(' ', $titles));
         }
         $a_title->add_child($final_ttl);
     } else {
         if (count($display) > 1) {
             if ($wide) {
                 $titles2 = HC_Html_Factory::widget('grid');
                 $titles2->set_slim();
                 $grid_width = array(2 => 6, 3 => 4, 4 => 3, 5 => 2, 6 => 2);
                 $grid_width = isset($grid_width[count($display)]) ? $grid_width[count($display)] : 2;
                 for ($ti = 0; $ti < count($titles); $ti++) {
                     $ttl = $titles[$ti];
                     // next title is empty?
                     if ($ti < count($titles) - 1 && !strlen($titles[$ti + 1])) {
                         $ti++;
                         $grid_width += $grid_width;
                     }
                     $final_ttl = $ttl;
                     if (!$nolink) {
                         $final_ttl = clone $a_link;
                         $final_ttl->add_child($ttl);
                     }
                     $titles2->add_item($final_ttl, $grid_width, array('class' => 'squeeze-in'));
                 }
             } else {
                 $titles2 = HC_Html_Factory::widget('list')->add_attr('class', 'list-unstyled');
                 $this_index = 0;
                 foreach ($titles as $ttl) {
                     if (!strlen($ttl)) {
                         continue;
                     }
                     $final_ttl = $ttl;
                     if (!$nolink) {
                         $final_ttl = clone $a_link;
                         $final_ttl->add_child($ttl);
                     }
                     $titles2->add_item($this_index, $final_ttl);
                     $titles2->add_item_attr($ttl, 'class', array('squeeze-in'));
                     $this_index++;
                 }
             }
             $a_title->add_attr('title', join(' ', $titles));
             $a_title->add_child($titles2);
         } else {
             $final_ttl = $titles;
             if (!$nolink) {
                 $final_ttl = clone $a_link;
                 $final_ttl->add_child($titles);
             }
             $final_ttl->add_attr('title', join(' ', $titles));
             $a_title->add_child($final_ttl);
         }
     }
     $wrap->add_child($a_title);
     /* EXTENSIONS */
     $extensions = HC_App::extensions();
     $more_content = $extensions->set_skip($iknow)->run('shifts/quickview', $sh, $wrap);
     if ($wide !== 'mini') {
         if ($more_content) {
             $more_wrap = HC_Html_Factory::widget('list')->add_attr('class', 'list-unstyled')->add_attr('class', 'list-separated')->add_attr('class', 'text-small');
             $added = 0;
             foreach ($more_content as $mck => $mc) {
                 if ($mck && in_array($mck, $iknow)) {
                     continue;
                 }
                 $more_wrap->add_item($mc);
                 $added++;
             }
             if ($added) {
                 $wrap->add_child($more_wrap);
             }
         }
     }
     /* THIS CHILDREN */
     if ($wide !== 'mini') {
         $children = $this->children();
         foreach ($children as $child) {
             $wrap->add_child($child);
         }
     }
     $wrap->add_attr('class', 'common-link-parent');
     return $wrap->render();
 }
Esempio n. 2
0
 function url()
 {
     $return = NULL;
     $append_controller = '';
     $change_params = array();
     $args = func_get_args();
     $ri = HC_Lib::ri();
     if ($ri && count($args) == 0 && count($this->params) == 0) {
         switch ($this->controller) {
             case 'auth/login':
                 $return = Modules::run($ri . '/auth/login_url');
                 break;
             case 'auth/logout':
                 $return = Modules::run($ri . '/auth/logout_url');
                 break;
         }
     }
     if ($return) {
         return $return;
     }
     if (count($args) == 1) {
         list($change_params) = $args;
     } elseif (count($args) == 2) {
         list($append_controller, $change_params) = $args;
     }
     $slug = array();
     if ($this->controller) {
         $slug[] = $this->controller;
     }
     if ($append_controller) {
         $slug[] = $append_controller;
     }
     $params = array_merge($this->params, $change_params);
     $params = $this->params;
     foreach ($change_params as $k => $v) {
         if (substr($k, -1) == '+' or substr($k, -1) == '-') {
             $operation = substr($k, -1);
             $k = substr($k, 0, -1);
             if (isset($params[$k])) {
                 if (!is_array($params[$k])) {
                     $params[$k] = array($params[$k]);
                 }
             } else {
                 $params[$k] = array();
             }
             if ($operation == '+') {
                 $params[$k][] = $v;
             } else {
                 $params[$k] = HC_Lib::remove_from_array($params[$k], $v);
             }
         } else {
             $params[$k] = $v;
         }
     }
     foreach ($params as $k => $v) {
         if (is_array($v)) {
             if (!$v) {
                 continue;
             }
             $v = join('.', $v);
         }
         if ($v !== NULL) {
             $slug[] = $k;
             $slug[] = $v;
         }
     }
     $CI =& ci_get_instance();
     $return = $CI->config->site_url($slug);
     return $return;
 }