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


PHP Duration::setRepeatPeriod方法代码示例

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


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

示例1: createFromRequest

 /**
  * @return Duration|null
  */
 public static function createFromRequest()
 {
     $dt = Loader::helper('form/date_time');
     $dateStart = $dt->translate('pdStartDate');
     $dateEnd = $dt->translate('pdEndDate');
     if ($dateStart || $dateEnd) {
         // create a Duration object
         $pd = new Duration();
         if ($_REQUEST['pdStartDateAllDayActivate']) {
             $pd->setStartDateAllDay(1);
             $dateStart = date('Y-m-d 00:00:00', strtotime($dateStart));
         } else {
             $pd->setStartDateAllDay(0);
         }
         if ($_REQUEST['pdEndDateAllDayActivate']) {
             $pd->setEndDateAllDay(1);
             $dateEnd = date('Y-m-d 23:59:59', strtotime($dateEnd));
         } else {
             $pd->setEndDateAllDay(0);
         }
         $pd->setStartDate($dateStart);
         $pd->setEndDate($dateEnd);
         if ($_POST['pdRepeatPeriod'] && $_POST['pdRepeat']) {
             if ($_POST['pdRepeatPeriod'] == 'daily') {
                 $pd->setRepeatPeriod(Duration::REPEAT_DAILY);
                 $pd->setRepeatEveryNum($_POST['pdRepeatPeriodDaysEvery']);
             } elseif ($_POST['pdRepeatPeriod'] == 'weekly') {
                 $pd->setRepeatPeriod(Duration::REPEAT_WEEKLY);
                 $pd->setRepeatEveryNum($_POST['pdRepeatPeriodWeeksEvery']);
                 $pd->setRepeatPeriodWeekDays($_POST['pdRepeatPeriodWeeksDays']);
             } elseif ($_POST['pdRepeatPeriod'] == 'monthly') {
                 $pd->setRepeatPeriod(Duration::REPEAT_MONTHLY);
                 $repeat_by = $_POST['pdRepeatPeriodMonthsRepeatBy'];
                 $repeat = self::MONTHLY_REPEAT_WEEKLY;
                 switch ($repeat_by) {
                     case 'week':
                         $repeat = self::MONTHLY_REPEAT_WEEKLY;
                         break;
                     case 'month':
                         $repeat = self::MONTHLY_REPEAT_MONTHLY;
                         break;
                     case 'lastweekday':
                         $repeat = self::MONTHLY_REPEAT_LAST_WEEKDAY;
                         $dotw = $_POST['pdRepeatPeriodMonthsRepeatLastDay'] ?: 0;
                         $pd->setRepeatMonthLastWeekday($dotw);
                         break;
                 }
                 $pd->setRepeatMonthBy($repeat);
                 $pd->setRepeatEveryNum($_POST['pdRepeatPeriodMonthsEvery']);
             }
             $pd->setRepeatPeriodEnd($dt->translate('pdEndRepeatDateSpecific'));
         } else {
             $pd->setRepeatPeriod(Duration::REPEAT_NONE);
         }
         $pd->save();
         return $pd;
     } else {
         unset($pd);
     }
     return null;
 }
开发者ID:ngreimel,项目名称:kovent,代码行数:64,代码来源:Duration.php

示例2: testGenerateMonthlyMonthly

 public function testGenerateMonthlyMonthly()
 {
     $repetition = new Duration();
     $repetition->setRepeatPeriod($repetition::REPEAT_MONTHLY);
     $repetition->setRepeatMonthBy($repetition::MONTHLY_REPEAT_MONTHLY);
     $repetition->setRepeatEveryNum(3);
     $repetition->setStartDate('1/14/2015 1:00:00');
     $repetition->setEndDate('1/14/2015 3:00:00');
     $now = strtotime('2/13/2014');
     $end = strtotime('+5 years', $now);
     $occurrences = $repetition->activeRangesBetween($now, $end);
     $all_active = true;
     foreach ($occurrences as $occurrence) {
         $window = $repetition->getActiveRange($occurrence[0]);
         if (!$window) {
             $all_active = false;
             break;
         }
         if ($window[0] != $occurrence[0] || $window[1] != $occurrence[1]) {
             $all_active = false;
             break;
         }
     }
     $this->assertTrue($all_active, 'EventOccurrenceFactory generated inactive occurrences.');
 }
开发者ID:ceko,项目名称:concrete5-1,代码行数:25,代码来源:DurationTest.php

示例3: translateFromRequest

 public static function translateFromRequest()
 {
     $dt = Loader::helper('form/date_time');
     $dateStart = $dt->translate('pdStartDate');
     $dateEnd = $dt->translate('pdEndDate');
     if ($dateStart || $dateEnd) {
         // create a Duration object
         if ($_REQUEST['pdID']) {
             $pd = Duration::getByID($_REQUEST['pdID']);
         } else {
             $pd = new Duration();
         }
         if ($_REQUEST['pdStartDateAllDayActivate']) {
             $pd->setStartDateAllDay(1);
             $dateStart = date('Y-m-d 00:00:00', strtotime($dateStart));
         } else {
             $pd->setStartDateAllDay(0);
         }
         if ($_REQUEST['pdEndDateAllDayActivate']) {
             $pd->setEndDateAllDay(1);
             $dateEnd = date('Y-m-d 23:59:59', strtotime($dateEnd));
         } else {
             $pd->setEndDateAllDay(0);
         }
         $pd->setStartDate($dateStart);
         $pd->setEndDate($dateEnd);
         if ($_POST['pdRepeatPeriod'] && $_POST['pdRepeat']) {
             $pd->setRepeatPeriod($_POST['pdRepeatPeriod']);
             if ($_POST['pdRepeatPeriod'] == 'daily') {
                 $pd->setRepeatEveryNum($_POST['pdRepeatPeriodDaysEvery']);
             } elseif ($_POST['pdRepeatPeriod'] == 'weekly') {
                 $pd->setRepeatEveryNum($_POST['pdRepeatPeriodWeeksEvery']);
                 $pd->setRepeatPeriodWeekDays($_POST['pdRepeatPeriodWeeksDays']);
             } elseif ($_POST['pdRepeatPeriod'] == 'monthly') {
                 $pd->setRepeatMonthBy($_POST['pdRepeatPeriodMonthsRepeatBy']);
                 $pd->setRepeatEveryNum($_POST['pdRepeatPeriodMonthsEvery']);
             }
             $pd->setRepeatPeriodEnd($dt->translate('pdEndRepeatDateSpecific'));
         } else {
             $pd->setRepeatPeriod(false);
         }
         $pd->save();
     } else {
         unset($pd);
     }
     return $pd;
 }
开发者ID:meixelsberger,项目名称:concrete5-5.7.0,代码行数:47,代码来源:Duration.php


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