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


PHP HC_Lib::replace_in_array方法代码示例

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


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

示例1: _grab_state

 private function _grab_state($args, $tab = 'browse')
 {
     $t = HC_Lib::time();
     $state = array('range' => 'week', 'date' => $t->formatDate_Db(), 'by' => NULL, 'location' => array(), 'staff' => array(), 'type' => NULL, 'wide' => NULL, 'filter' => NULL);
     $default_params = $this->default_params;
     $supplied = hc_parse_args($args);
     $supplied = array_merge($default_params, $supplied);
     foreach ($supplied as $k => $v) {
         if (in_array($k, array('staff', 'location', 'type'))) {
             if (strpos($v, '.') !== FALSE) {
                 $v = explode('.', $v);
             } elseif (strpos($v, ',') !== FALSE) {
                 $v = explode(',', $v);
             } else {
                 $v = array($v);
             }
         }
         $state[$k] = $v;
     }
     /* check _current_user_id_ */
     if (isset($state['staff'])) {
         $check_current_user = array('_current_user_id_', '_current_user_id', 'current_user_id', 'current_user', '_current_user_');
         $current_user_key = '';
         foreach ($check_current_user as $cuk) {
             if (in_array($cuk, $state['staff'])) {
                 $current_user_key = $cuk;
                 break;
             }
         }
         if ($current_user_key) {
             $current_user_id = 0;
             if ($test_user = $this->auth->user()) {
                 $current_user_id = $test_user->id;
             }
             $state['staff'] = HC_Lib::replace_in_array($state['staff'], $current_user_key, $current_user_id);
         }
     }
     /* fixed ? */
     $force_fixed = array('location', 'staff');
     foreach ($default_params as $k => $v) {
         if (in_array($k, $force_fixed)) {
             $this->fix[$k] = $state[$k];
         }
     }
     switch ($state['range']) {
         case 'all':
             $t = HC_Lib::time();
             $shifts = HC_App::model('shift');
             $min_date = $shifts->select_min('date')->get()->date;
             $max_date = $shifts->select_max('date_end')->get()->date_end;
             if ($min_date && $max_date) {
                 $state['date'] = $min_date . '_' . $max_date;
             }
             break;
         case 'upcoming':
             $t = HC_Lib::time();
             $shifts = HC_App::model('shift');
             $min_date = $t->setNow()->formatDate_Db();
             $max_date = $shifts->select_max('date_end')->get()->date_end;
             if ($min_date && $max_date) {
                 $state['date'] = $min_date . '_' . $max_date;
             }
             break;
         case 'day':
         case 'week':
         case 'month':
             if (!$state['date']) {
                 $t->setNow();
                 $state['date'] = $t->formatDate_Db();
             }
             break;
         case 'custom':
             if (strpos($state['date'], '_') !== FALSE) {
                 list($start_date, $end_date) = explode('_', $state['date']);
             } else {
                 $start_date = $end_date = $state['date'];
             }
             $t->setNow();
             if (!$start_date) {
                 $start_date = $t->formatDate_Db();
             }
             if (!$end_date) {
                 $end_date = $t->formatDate_Db();
             }
             $state['date'] = join('_', array($start_date, $end_date));
             break;
         default:
             // attempt to parse the range text in time
             $start_date = $state['date'];
             if (!$start_date) {
                 $t->setNow();
                 $start_date = $t->formatDate_Db();
             }
             $t->setDateDb($start_date);
             $t->modify('+' . $state['range']);
             $end_date = $t->formatDate_Db();
             $state['date'] = join('_', array($start_date, $end_date));
             $state['range'] = 'custom';
             break;
     }
//.........这里部分代码省略.........
开发者ID:RCMmedia,项目名称:rubicon,代码行数:101,代码来源:list.php


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