当前位置: 首页>>代码示例>>PHP>>正文


PHP HC_Lib::time方法代码示例

本文整理汇总了PHP中HC_Lib::time方法的典型用法代码示例。如果您正苦于以下问题:PHP HC_Lib::time方法的具体用法?PHP HC_Lib::time怎么用?PHP HC_Lib::time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HC_Lib的用法示例。


在下文中一共展示了HC_Lib::time方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: todo

 function todo()
 {
     $conflict_ids = array();
     $t = HC_Lib::time();
     $today = $t->setNow()->formatDate_Db();
     /* find conflicts in upcoming shifts */
     $shifts = HC_App::model('shift');
     $shifts->where('date_end >=', $today)->where_related('user', 'id IS NOT ', 'NULL', FALSE);
     $shifts->get();
     $acl = HC_App::acl();
     $cmm = HC_App::model('conflict_manager');
     $count = 0;
     foreach ($shifts as $obj) {
         if (!$acl->set_object($obj)->can('conflicts::view')) {
             continue;
         }
         $entries = $cmm->get($obj, TRUE);
         if ($entries) {
             foreach ($entries as $e) {
                 $conflict_ids[$e->id] = 1;
             }
         }
     }
     if (!count($conflict_ids)) {
         return;
     }
     /* render view */
     $this->layout->set_partial('content', $this->render('conflicts/todo', array('count' => count($conflict_ids))));
     $this->layout();
 }
开发者ID:RCMmedia,项目名称:rubicon,代码行数:30,代码来源:conflicts.php

示例2: created

 function created($model, $vlevel = HC_PRESENTER::VIEW_HTML)
 {
     $value = $model->created;
     $t = HC_Lib::time();
     $t->setTimestamp($value);
     $return = array();
     switch ($vlevel) {
         case HC_PRESENTER::VIEW_HTML:
             $return[] = HC_Html::icon(HC_App::icon_for('date'));
             break;
     }
     $return[] = $t->formatDateFull();
     switch ($vlevel) {
         case HC_PRESENTER::VIEW_HTML:
             $return[] = HC_Html::icon(HC_App::icon_for('time'));
             break;
     }
     $return[] = $t->formatTime();
     switch ($vlevel) {
         case HC_PRESENTER::VIEW_TEXT:
         case HC_PRESENTER::VIEW_RAW:
             $return = join(' ', $return);
             break;
         default:
             $return = join('', $return);
             break;
     }
     return $return;
 }
开发者ID:RCMmedia,项目名称:rubicon,代码行数:29,代码来源:note.php

示例3: render

    function render()
    {
        $name = $this->name();
        $value = $this->value();
        $id = 'nts-' . $name;
        $t = HC_Lib::time();
        $t->setNow();
        $t->setStartDay();
        if ($value) {
            $t->modify('+' . $value . ' seconds');
            // $value = $t->formatTime();
        }
        $out = HC_Html_Factory::widget('container');
        /* hidden field to store our value */
        $hidden = HC_Html_Factory::input('hidden')->set_name($name)->set_value($value)->set_id($id);
        $out->add_item($hidden);
        /* text field to display */
        $display_name = $name . '_display';
        $display_id = 'nts-' . $display_name;
        $text = HC_Html_Factory::input('text')->set_name($display_name)->set_id($display_id)->add_attr('size', 7);
        if (strlen($value)) {
            $display_value = $t->formatTime();
            $text->set_value($display_value);
        }
        $out->add_item($text);
        $time_format = $t->timeFormat();
        $script = HC_Html_Factory::element('script');
        $script->add_attr('language', 'JavaScript');
        $js_code = <<<EOT

jQuery("#{$display_id}").timepicker(
{
\t'appendTo' : '#nts',
\t'timeFormat' :'{$time_format}',
\t'step' : 5,
}
);

jQuery("#{$display_id}").on('change', function(){
\tvar dbTime = jQuery(this).timepicker('getSecondsFromMidnight');
\tjQuery('#{$id}').val( dbTime );
});

EOT;
        $script->add_child($js_code);
        $out->add_item($script);
        $return = $this->decorate($out->render());
        return $return;
    }
开发者ID:kumarkvk,项目名称:vz_emp_shiftsSchedule,代码行数:49,代码来源:timepicker.php

示例4: index

 public function index()
 {
     $args = hc_parse_args(func_get_args(), TRUE);
     if (!isset($args['user'])) {
         echo 'PARAMS MISSING IN availability/index<br>';
         return;
     }
     $user_id = is_object($args['user']) ? $args['user']->id : $args['user'];
     $t = HC_Lib::time();
     $t->setNow();
     $date_start = $t->formatDate_Db();
     $t->setEndMonth();
     // $t->modify('+1 month');
     $date_end = $t->formatDate_Db();
     $form_values = array('user' => $user_id, 'date' => array('recurring' => 'single', 'datesingle' => $date_start, 'datestart' => $date_start, 'dateend' => $date_end, 'repeat' => 'daily'));
     $this->form_add->set_values($form_values);
     $this->layout->set_partial('content', $this->render('availability/add', array('form' => $this->form_add)));
     $this->layout();
 }
开发者ID:RCMmedia,项目名称:rubicon,代码行数:19,代码来源:add.php

示例5: open

 function open()
 {
     $t = HC_Lib::time();
     $today = $t->setNow()->formatDate_Db();
     $shifts = HC_App::model('shift');
     $shifts->where('date_end >=', $today)->where('status', $shifts->_const('STATUS_ACTIVE'))->where_related('user', 'id', NULL, TRUE);
     $shifts->get();
     $acl = HC_App::acl();
     $count = 0;
     foreach ($shifts as $obj) {
         if (!$acl->set_object($obj)->can('view')) {
             continue;
         }
         $count++;
     }
     /* view */
     $this->layout->set_partial('content', $this->render('admin/todo/open', array('count' => $count)));
     $this->layout();
 }
开发者ID:kumarkvk,项目名称:vz_emp_shiftsSchedule,代码行数:19,代码来源:todo.php

示例6: get

 function get($model)
 {
     $limit_qty = 2;
     $limit_duration = 4 * 60 * 60;
     $this->shift_id = $model->id;
     $return = array();
     /* find if the employee has more shifts that allowed per week */
     if (!(strlen($model->start) && strlen($model->end))) {
         return $return;
     }
     if (!($model->date && $model->date_end)) {
         return $return;
     }
     if (!$model->user_id) {
         return $return;
     }
     if ($model->type != $model->_const('TYPE_SHIFT')) {
         return $return;
     }
     $t = HC_Lib::time();
     $t->setDateDb($model->date);
     list($start_week, $end_week) = $t->getDates('week', TRUE);
     $my_qty = 0;
     $my_duration = 0;
     $sm = HC_App::model('shift');
     $sm->select('id, date, date_end, start, end')->where_related('user', 'id', $model->user_id)->where('date_end >=', $start_week)->where('date <=', $end_week);
     $sm->get_iterated_slim();
     foreach ($sm as $test) {
         $my_qty += 1;
         $my_duration += $test->get_duration();
     }
     if ($my_qty > $limit_qty) {
         $conflict = clone $this;
         $conflict->details = 'qty:' . $my_qty;
         $return[] = $conflict;
     }
     if ($my_duration > $limit_duration) {
         $conflict = clone $this;
         $conflict->details = 'duration:' . $my_duration;
         $return[] = $conflict;
     }
     return $return;
 }
开发者ID:RCMmedia,项目名称:rubicon,代码行数:43,代码来源:conflict_week_limit.php

示例7: __construct

 function __construct($name = '')
 {
     parent::__construct($name);
     // $this->add_attr('class', 'timepicker');
     $start_with = 0;
     $end_with = 24 * 60 * 60;
     /*
     		if( isset($more['conf']['min']) && ($more['conf']['min'] > $start_with) )
     		{
     			$start_with = $more['conf']['min'];
     		}
     		if( isset($more['conf']['max']) && ($more['conf']['max'] < $end_with) )
     		{
     			$end_with = $more['conf']['max'];
     		}
     		unset( $more['conf'] );
     */
     if ($end_with < $start_with) {
         $end_with = $start_with;
     }
     $step = 15 * 60;
     $options = array();
     $t = HC_Lib::time();
     $t->setDateDb(20130118);
     /*
     		if( $value && ($value > $end_with) )
     		{
     			$value = $value - 24 * 60 * 60;
     		}
     */
     if ($start_with) {
         $t->modify('+' . $start_with . ' seconds');
     }
     $no_of_steps = ($end_with - $start_with) / $step;
     for ($ii = 0; $ii <= $no_of_steps; $ii++) {
         $sec = $start_with + $ii * $step;
         $options[$sec] = $t->formatTime();
         $t->modify('+' . $step . ' seconds');
     }
     $this->set_options($options);
 }
开发者ID:RCMmedia,项目名称:rubicon,代码行数:41,代码来源:time.php

示例8: render

 function render()
 {
     $name = $this->name();
     $value = $this->value();
     $id = 'nts-' . $name;
     $t = HC_Lib::time();
     $value ? $t->setDateDb($value) : $t->setNow();
     $value = $t->formatDate_Db();
     $out = HC_Html_Factory::widget('container');
     /* hidden field to store our value */
     $hidden = HC_Html_Factory::input('hidden')->set_name($name)->set_value($value)->set_id($id);
     $out->add_item($hidden);
     /* text field to display */
     $display_name = $name . '_display';
     $display_id = 'nts-' . $display_name;
     $datepicker_format = $t->formatToDatepicker();
     $display_value = $t->formatDate();
     $text = HC_Html_Factory::input('text')->set_name($display_name)->set_value($display_value)->set_id($display_id)->add_attr('data-date-format', $datepicker_format)->add_attr('data-date-week-start', $t->weekStartsOn)->add_attr('style', 'width: 8em')->add_attr('class', 'hc-datepicker');
     $out->add_item($text);
     $return = $this->decorate($out->render());
     return $return;
 }
开发者ID:RCMmedia,项目名称:rubicon,代码行数:22,代码来源:date.php

示例9: render

 function render()
 {
     $name = $this->name();
     $value = $this->value();
     $id = 'nts-' . $name;
     $t = HC_Lib::time();
     $t->setNow();
     $t->setStartDay();
     if ($value) {
         $t->modify('+' . $value . ' seconds');
         // $value = $t->formatTime();
     }
     $out = HC_Html_Factory::widget('container');
     /* hidden field to store our value */
     $hidden = HC_Html_Factory::input('hidden')->set_name($name)->set_value($value)->set_id($id);
     $attr = $this->attr();
     foreach ($attr as $k => $v) {
         if (!in_array($k, array('disabled', 'readonly'))) {
             continue;
         }
         $hidden->add_attr($k, $v);
     }
     $out->add_item($hidden);
     /* text field to display */
     $display_name = $name . '_display';
     $display_id = 'nts-' . $display_name;
     $text = HC_Html_Factory::input('text')->set_name($display_name)->set_id($display_id)->add_attr('size', 7)->add_attr('class', 'hc-timepicker');
     if (strlen($value)) {
         $display_value = $t->formatTime();
         $text->set_value($display_value);
     }
     foreach ($attr as $k => $v) {
         $text->add_attr($k, $v);
     }
     $out->add_item($text);
     $return = $this->decorate($out->render());
     return $return;
 }
开发者ID:RCMmedia,项目名称:rubicon,代码行数:38,代码来源:timepicker.php

示例10: up

 public function up()
 {
     if (!$this->db->field_exists('date_end', 'shifts')) {
         $this->dbforge->add_column('shifts', array('date_end' => array('type' => 'INT', 'null' => FALSE)), 'start');
         // init date end
         $this->db->set('date_end', 'date', FALSE);
         $this->db->update('shifts');
         // now check those that go next day
         $this->db->where('end > ', 24 * 60 * 60);
         $this->db->set('end', 'end - ' . 24 * 60 * 60, FALSE);
         $this->db->update('shifts');
         $affected_count = 0;
         $t = HC_Lib::time();
         $query = $this->db->where('start >= ', 'end', FALSE)->get('shifts');
         foreach ($query->result_array() as $row) {
             $t->setDateDb($row['date']);
             $t->modify('+1 day');
             $date_end = $t->formatDate_Db();
             $this->db->where('id', $row['id'])->update('shifts', array('date_end' => $date_end));
             $affected_count++;
         }
     }
 }
开发者ID:RCMmedia,项目名称:rubicon,代码行数:23,代码来源:008_shift_date_end.php

示例11: render

    function render()
    {
        $name = $this->name();
        $value = $this->value();
        $id = 'nts-' . $name;
        $t = HC_Lib::time();
        $value ? $t->setDateDb($value) : $t->setNow();
        $value = $t->formatDate_Db();
        $out = HC_Html_Factory::widget('container');
        /* hidden field to store our value */
        $hidden = HC_Html_Factory::input('hidden')->set_name($name)->set_value($value)->set_id($id);
        $out->add_item($hidden);
        /* text field to display */
        $display_name = $name . '_display';
        $display_id = 'nts-' . $display_name;
        $datepicker_format = $t->formatToDatepicker();
        $display_value = $t->formatDate();
        $text = HC_Html_Factory::input('text')->set_name($display_name)->set_value($display_value)->set_id($display_id)->add_attr('data-date-format', $datepicker_format)->add_attr('data-date-week-start', $t->weekStartsOn)->add_attr('style', 'width: 8em');
        $out->add_item($text);
        /* JavaScript to make it work */
        $js_options = array();
        $options = $this->options();
        foreach ($options as $k => $v) {
            switch ($k) {
                case 'startDate':
                    if ($v > $value) {
                        $value = $v;
                    }
                    $t->setDateDb($v);
                    $v = $t->formatDate();
                    break;
            }
            $js_options[] = "{$k}: \"{$v}\"";
        }
        $js_options[] = "weekStart: " . $t->weekStartsOn;
        $js_options = join(",\n", $js_options);
        $script = HC_Html_Factory::element('script');
        $script->add_attr('language', 'JavaScript');
        $cal_language = array('days' => array(HCM::__('Sun'), HCM::__('Mon'), HCM::__('Tue'), HCM::__('Wed'), HCM::__('Thu'), HCM::__('Fri'), HCM::__('Sat'), HCM::__('Sun')), 'daysShort' => array(HCM::__('Sun'), HCM::__('Mon'), HCM::__('Tue'), HCM::__('Wed'), HCM::__('Thu'), HCM::__('Fri'), HCM::__('Sat'), HCM::__('Sun')), 'daysMin' => array(HCM::__('Sun'), HCM::__('Mon'), HCM::__('Tue'), HCM::__('Wed'), HCM::__('Thu'), HCM::__('Fri'), HCM::__('Sat'), HCM::__('Sun')), 'months' => array(HCM::__('Jan'), HCM::__('Feb'), HCM::__('Mar'), HCM::__('Apr'), HCM::__('May'), HCM::__('Jun'), HCM::__('Jul'), HCM::__('Aug'), HCM::__('Sep'), HCM::__('Oct'), HCM::__('Nov'), HCM::__('Dec')), 'monthsShort' => array(HCM::__('Jan'), HCM::__('Feb'), HCM::__('Mar'), HCM::__('Apr'), HCM::__('May'), HCM::__('Jun'), HCM::__('Jul'), HCM::__('Aug'), HCM::__('Sep'), HCM::__('Oct'), HCM::__('Nov'), HCM::__('Dec')), 'today' => 'Today', 'clear' => 'Clear');
        $cal_language_js_code = array();
        foreach ($cal_language as $k => $v) {
            $cal_language_js_code_line = '';
            $cal_language_js_code_line .= $k . ': ';
            if (is_array($v)) {
                $cal_language_js_code_line .= '[';
                $cal_language_js_code_line .= join(', ', array_map(create_function('$v', 'return "\\"" . $v . "\\"";'), $v));
                $cal_language_js_code_line .= ']';
            } else {
                $cal_language_js_code_line .= '"' . $v . '"';
            }
            $cal_language_js_code[] = $cal_language_js_code_line;
        }
        $cal_language_js_code = join(",\n", $cal_language_js_code);
        // echo $cal_language_js_code;
        $js_code = <<<EOT

;(function(\$){
\t\$.fn.datepicker.dates['en'] = {
\t\t{$cal_language_js_code}
\t};
}(jQuery));

jQuery('#{$display_id}').datepicker({
\t{$js_options},
\tdateFormat: '{$datepicker_format}',
\tautoclose: true,
\t})
\t.on('changeDate', function(ev)
\t\t{
\t\tvar dbDate = 
\t\t\tev.date.getFullYear() 
\t\t\t+ "" + 
\t\t\t("00" + (ev.date.getMonth()+1) ).substr(-2)
\t\t\t+ "" + 
\t\t\t("00" + ev.date.getDate()).substr(-2);
\t\tjQuery('#{$id}').val( dbDate );
\t\t});

EOT;
        $script->add_child($js_code);
        $out->add_item($script);
        $return = $this->decorate($out->render());
        return $return;
    }
开发者ID:kumarkvk,项目名称:vz_emp_shiftsSchedule,代码行数:84,代码来源:date.php

示例12: differ

 function differ($other)
 {
     if (!is_object($other)) {
         $other_date = $other;
         $other = HC_Lib::time();
         $other->setDateDb($other_date);
     } else {
         $other_date = $other->formatDate_Db();
     }
     $this_date = $this->formatDate_Db();
     if ($this_date == $other_date) {
         $delta = 0;
     } elseif ($this_date > $other_date) {
         $delta = $this->getTimestamp() - $other->getTimestamp();
     } else {
         $delta = $other->getTimestamp() - $this->getTimestamp();
     }
     if ($delta) {
         $return = floor($delta / (24 * 60 * 60));
     }
     return $return;
 }
开发者ID:kumarkvk,项目名称:vz_emp_shiftsSchedule,代码行数:22,代码来源:hc_time.php

示例13: render

    function render()
    {
        $enabled = $this->enabled();
        $value = $this->value(TRUE);
        $t = HC_Lib::time();
        if (isset($value['datestart'])) {
            $t->setDateDb($value['datestart']);
        }
        /* single date part */
        $wrap_single = HC_Html_Factory::widget('list')->add_attr('class', array('list-unstyled', 'list-separated'));
        $wrap_single->add_item($this->fields['datesingle']);
        /* recurring part */
        $wrap = HC_Html_Factory::widget('list')->add_attr('class', array('list-unstyled', 'list-separated'))->add_attr('class', 'hc-radio-info-container');
        /* DATES */
        $item_dates = HC_Html_Factory::widget('list')->add_attr('class', array('list-inline', 'list-separated'));
        $item_dates->add_item($this->fields['datestart']);
        $item_dates->add_item(' - ');
        $item_dates->add_item($this->fields['dateend']);
        $wrap->add_item($item_dates);
        /* RECURRING OPTIONS */
        $repeat = clone $this->fields['repeat'];
        $repeat->add_option('daily', HCM::__('Daily'));
        $repeat->add_option('weekday', HCM::__('Every Weekday') . ' (' . $t->formatWeekdayShort(1) . ' - ' . $t->formatWeekdayShort(5) . ')');
        $repeat->add_option('weekly', HCM::__('Weekly') . ' (' . $t->formatWeekdayShort() . ')');
        $wkds = array(0, 1, 2, 3, 4, 5, 6);
        $wkds = $t->sortWeekdays($wkds);
        /* weekly custom */
        $weekly_custom = clone $this->fields['weeklycustom'];
        $this_weekday = $t->getWeekday();
        if (!$weekly_custom->value()) {
            $weekly_custom->set_value(array($this_weekday));
        }
        reset($wkds);
        foreach ($wkds as $wkd) {
            $weekly_custom->add_option($wkd, $t->formatWeekdayShort($wkd));
        }
        // $weekly_custom->set_readonly($this_weekday);
        $repeat->add_option('weeklycustom', HCM::__('Weekly') . ' (' . HCM::__('Selected Days') . ')', $weekly_custom);
        /* biweekly custom */
        $this_weekday = $t->getWeekday();
        $biweekly_custom1 = clone $this->fields['biweeklycustom1'];
        if (!$biweekly_custom1->value()) {
            $biweekly_custom1->set_value(array($this_weekday));
        }
        $biweekly_custom2 = clone $this->fields['biweeklycustom2'];
        if (!$biweekly_custom2->value()) {
            $biweekly_custom2->set_value(array($this_weekday));
        }
        reset($wkds);
        foreach ($wkds as $wkd) {
            $biweekly_custom1->add_option($wkd, $t->formatWeekdayShort($wkd));
            $biweekly_custom2->add_option($wkd, $t->formatWeekdayShort($wkd));
        }
        // $weekly_custom->set_readonly($this_weekday);
        $repeat->add_option('biweeklycustom', HCM::__('Biweekly') . ' (' . HCM::__('Selected Days') . ')', array($biweekly_custom1, $biweekly_custom2));
        /* in/out */
        if (!$this->fields['inoutin']->value()) {
            $this->fields['inoutin']->set_value(2);
        }
        if (!$this->fields['inoutout']->value()) {
            $this->fields['inoutout']->set_value(2);
        }
        $repeat->add_option('inout', join(' / ', array(sprintf(HCM::_n('%s Day On', '%s Days On', 100), 'X'), sprintf(HCM::_n('%s Day Off', '%s Days Off', 100), 'Y'))), HC_Html_Factory::widget('list')->add_attr('class', array('list-inline', 'list-separated'))->add_item($this->fields['inoutin']->add_attr('size', 2))->add_item('/')->add_item($this->fields['inoutout']->add_attr('size', 2)));
        $repeat->add_option('monthlyday', HCM::__('Monthly') . ' (' . join(', ', array($t->formatWeekdayShort(), $t->formatWeekOfMonth())) . ')');
        $repeat->add_option('monthlydayend', HCM::__('Monthly') . ' (' . join(', ', array($t->formatWeekdayShort(), $t->formatWeekOfMonthFromEnd())) . ')');
        $repeat->add_option('monthlydate', HCM::__('Monthly') . ' (' . HCM::__('Day') . ': ' . $t->getDay() . ')');
        $wrap->add_item($repeat);
        /* build output */
        // $recurring_part = $wrap->render();
        // $recurring_part = $this->decorate( $recurring_part );
        // $single_part = $wrap_single->render();
        // $single_part = $this->decorate( $wrap_single );
        $return = HC_Html_Factory::widget('container');
        if (count($enabled) > 1) {
            $tabs = HC_Html_Factory::widget('tabs');
            $tabs_id = 'nts' . hc_random();
            $tabs->set_id($tabs_id);
            $tabs->add_tab('single', HCM::__('Single Day'), $wrap_single);
            $tabs->add_tab('recurring', HCM::__('Multiple Days'), $wrap);
            $value_recurring = $value['recurring'];
            $tabs->set_active($value_recurring);
            $return->add_item($this->fields['recurring']);
            $return->add_item($tabs);
            $name_recurring = $this->fields['recurring']->name();
            $tabs_js = <<<EOT

<script language="JavaScript">
jQuery('#{$tabs_id}').closest('form').find('[name={$name_recurring}]').val( "{$value_recurring}" )
jQuery('#{$tabs_id} a.hc-tab-toggler').on('shown.hc.tab', function(e)
{
\tvar active_tab = jQuery(this).data('toggle-tab');
\tjQuery(this).closest('form').find('[name={$name_recurring}]').val( active_tab );
});
</script>

EOT;
            $return->add_item($tabs_js);
        } else {
            if (in_array('single', $enabled)) {
                $return->add_item($wrap_single);
//.........这里部分代码省略.........
开发者ID:RCMmedia,项目名称:rubicon,代码行数:101,代码来源:recurring_date.php

示例14: date

 function date($model, $vlevel = HC_PRESENTER::VIEW_HTML, $with_change = FALSE)
 {
     $t = HC_Lib::time();
     $t->setDateDb($model->date);
     $return = array();
     switch ($vlevel) {
         case HC_PRESENTER::VIEW_HTML:
             $return[] = HC_Html::icon(HC_App::icon_for('date'));
             break;
         case HC_PRESENTER::VIEW_TEXT:
             $return[] = HCM::__('Date');
             $return[] = ': ';
             break;
     }
     $return[] = $t->formatDateFull();
     if ($with_change) {
         $changes = $model->get_changes();
         if (isset($changes['date'])) {
             $t->setDateDb($changes['date']);
             $return[] = ' [' . HCM::__('Old Value') . ': ' . $t->formatDateFull() . ']';
         }
     }
     $return = join('', $return);
     return $return;
 }
开发者ID:RCMmedia,项目名称:rubicon,代码行数:25,代码来源:shift.php

示例15: render

 function render($readonly = FALSE)
 {
     if (!$readonly && !($link = $this->link())) {
         return 'HC_Html_Widget_Date_Nav: link is not set!';
     }
     $t = HC_Lib::time();
     $nav_title = $this->_nav_title($readonly);
     if ($readonly) {
         $return = HC_Html_Factory::element('span')->add_attr('class', array('btn', 'btn-default'))->add_child($nav_title);
         return $return;
     }
     switch ($this->range()) {
         case 'all':
             $t->setNow();
             $start_date = $end_date = 0;
             // $start_date = $end_date = $t->formatDate_Db();
             break;
         case 'upcoming':
             $t->setNow();
             $start_date = $end_date = 0;
             break;
         case 'custom':
             list($start_date, $end_date) = explode('_', $this->date());
             $t->setDateDb($start_date)->modify('-1 day');
             $before_date = $t->formatDate_Db();
             $t->setDateDb($end_date)->modify('+1 day');
             $after_date = $t->formatDate_Db();
             break;
         case 'day':
             $t->setDateDb($this->date());
             $start_date = $end_date = $t->formatDate_Db();
             $t->modify('-1 day');
             $before_date = $t->formatDate_Db();
             $t->setDateDb($this->date());
             $t->modify('+1 day');
             $after_date = $t->formatDate_Db();
             break;
         case 'week':
             $t->setDateDb($this->date());
             $start_date = $t->setStartWeek()->formatDate_Db();
             $end_date = $t->setEndWeek()->formatDate_Db();
             $t->setDateDb($this->date());
             $t->modify('-1 week');
             $t->setStartWeek();
             $before_date = $t->formatDate_Db();
             $t->setDateDb($this->date());
             $t->setEndWeek();
             $t->modify('+1 day');
             $after_date = $t->formatDate_Db();
             break;
         case 'month':
             $t->setDateDb($this->date());
             $start_date = $t->setStartMonth()->formatDate_Db();
             $end_date = $t->setEndMonth()->formatDate_Db();
             $month_view = $t->getMonthName() . ' ' . $t->getYear();
             $t->setDateDb($this->date());
             $t->modify('-1 month');
             $t->setStartMonth();
             $before_date = $t->formatDate_Db();
             $t->setDateDb($this->date());
             $t->setEndMonth();
             $t->modify('+1 day');
             $after_date = $t->formatDate_Db();
             break;
     }
     // $this->add_attr('class', array('nav', 'nav-pills'));
     $this->add_attr('class', array('list-inline', 'list-separated'));
     $wrap_nav_title = HC_Html_Factory::element('a')->add_attr('class', array('btn', 'btn-default'))->add_child($nav_title);
     $current_nav = HC_Html_Factory::widget('dropdown')->set_title($wrap_nav_title);
     $range_options = array();
     /* week */
     $this_params = array($this->range_param() => 'week', $this->date_param() => $start_date ? $start_date : NULL);
     $range_options['week'] = HC_Html_Factory::element('a')->add_child(HCM::__('Week'))->add_attr('href', $link->url($this_params));
     /* month */
     $this_params = array($this->range_param() => 'month', $this->date_param() => $start_date ? $start_date : NULL);
     $range_options['month'] = HC_Html_Factory::element('a')->add_child(HCM::__('Month'))->add_attr('href', $link->url($this_params));
     /* day */
     $this_params = array($this->range_param() => 'day', $this->date_param() => $start_date ? $start_date : NULL);
     $range_options['day'] = HC_Html_Factory::element('a')->add_child(HCM::__('Day'))->add_attr('href', $link->url($this_params));
     /* custom */
     $date_param = '';
     if ($start_date && $end_date) {
         $date_param = $start_date . '_' . $end_date;
     } elseif ($start_date) {
         $date_param = $start_date;
     }
     $this_params = array($this->range_param() => 'custom', $this->date_param() => $date_param ? $date_param : NULL);
     $range_options['custom'] = HC_Html_Factory::element('a')->add_child(HCM::__('Custom Range'))->add_attr('href', $link->url($this_params));
     /* upcoming */
     $this_params = array($this->range_param() => 'upcoming', $this->date_param() => NULL);
     $range_options['upcoming'] = HC_Html_Factory::element('a')->add_child(HCM::__('Upcoming'))->add_attr('href', $link->url($this_params));
     /* all */
     $this_params = array($this->range_param() => 'all', $this->date_param() => NULL);
     $range_options['all'] = HC_Html_Factory::element('a')->add_child(HCM::__('All Time'))->add_attr('href', $link->url($this_params));
     $enabled = $this->enabled();
     foreach ($range_options as $k => $v) {
         if (!in_array($k, $enabled)) {
             continue;
         }
         if ($k != $this->range()) {
//.........这里部分代码省略.........
开发者ID:RCMmedia,项目名称:rubicon,代码行数:101,代码来源:date_nav.php


注:本文中的HC_Lib::time方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。