Exemple #1
0
 public function __invoke($start, $end, $recurrence)
 {
     if (!empty($recurrence)) {
         $startDate = new \DateTime($start);
         $endDate = new \DateTime($end);
         // Optional
         $translator = $this->getServiceLocator()->getServiceLocator()->get('translator');
         $locale = $translator->getTranslator()->getLocale();
         $fallbackLocale = $translator->getTranslator()->getFallbackLocale();
         setlocale(LC_TIME, $locale);
         $recurrence = str_replace("RRULE:", "", $recurrence);
         $rule = new \Recurr\Rule($recurrence, $startDate, $endDate, 'Europe/London');
         $transformer = new \Recurr\Transformer\ArrayTransformer();
         $trans = new \Recurr\Transformer\Translator();
         try {
             $trans->loadLocale(substr($locale, 0, 2));
         } catch (\Exception $e) {
             $trans->loadLocale(substr($fallbackLocale, 0, 2));
         }
         $textTransformer = new \Recurr\Transformer\TextTransformer($trans);
         return $textTransformer->transform($rule);
     }
     return false;
 }
 /**
  *
  * @param $recurRule recurrence rule - FREQ=YEARLY;INTERVAL=2;COUNT=3;
  * @return string recurrence string - every year for 3 times
  */
 public function recurTextTransform($recurRule, $lang = null)
 {
     //- Recurr's supported locales
     $locales = ['de', 'en', 'eu', 'fr', 'it', 'sv', 'es'];
     $locale = in_array(craft()->language, $locales) ? craft()->language : "en";
     if ($lang != null && in_array($lang, $locales)) {
         $locale = $lang;
     }
     $rule = new \Recurr\Rule($recurRule, new \DateTime());
     $textTransformer = new \Recurr\Transformer\TextTransformer(new \Recurr\Transformer\Translator($locale));
     return $textTransformer->transform($rule);
 }
Exemple #3
0
/* @var $model common\models\Season */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('igolf', 'Competitions'), 'url' => ['index']];
if ($bcs = $model->breadcrumbs()) {
    foreach ($bcs as $bc) {
        $this->params['breadcrumbs'][] = $bc;
    }
}
array_pop($this->params['breadcrumbs']);
$this->params['breadcrumbs'][] = $this->title;
$recurrence = $model->recurrence;
if ($model->recurrence) {
    // strips "RRULE:" at begining of string
    $str = strpos($model->recurrence, 'RRULE:') === 0 ? substr($model->recurrence, 6) : $model->recurrence;
    $rrule = new Recurr\Rule($str);
    $textTransformer = new Recurr\Transformer\TextTransformer();
    $recurrence = ucfirst($textTransformer->transform($rrule));
}
?>
<div class="competition-view">

    <?php 
echo DetailView::widget(['model' => $model, 'panel' => ['heading' => '<h3>' . Yii::t('igolf', $model->competition_type) . ' ' . $model->name . '</h3>'], 'labelColOptions' => ['style' => 'width: 30%'], 'attributes' => ['name', 'description', ['attribute' => 'parent_id', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => $model->getParentCandidates(), 'label' => Yii::t('igolf', 'Parent'), 'value' => $model->parent ? $model->parent->name . Html::a(' <span class="glyphicon glyphicon-share"></span>', ['view', 'id' => $model->parent_id]) : '', 'visible' => $model->competition_type != Competition::TYPE_SEASON, 'format' => 'raw'], ['attribute' => 'course_id', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'label' => Yii::t('igolf', 'Course'), 'items' => Course::getCourseList(true), 'value' => $model->course ? $model->course->getFullName() . Html::a(' <span class="glyphicon glyphicon-share"></span>', ['course/view', 'id' => $model->course_id]) : '', 'format' => 'raw'], ['attribute' => 'holes', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => array(18 => '18', 9 => '9')], ['attribute' => 'rule_id', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => ArrayHelper::map(['' => ''] + Rule::find()->where(['competition_type' => $model->competition_type])->asArray()->all(), 'id', 'name'), 'value' => $model->rule->name . Html::a(' <span class="glyphicon glyphicon-share"></span>', ['rule/view', 'id' => $model->rule_id]), 'format' => 'raw'], ['attribute' => 'final_rule_id', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => ArrayHelper::map(['' => ''] + Rule::find()->where(['competition_type' => $model->competition_type])->asArray()->all(), 'id', 'name'), 'value' => $model->final_rule_id ? $model->finalRule->name . Html::a(' <span class="glyphicon glyphicon-share"></span>', ['rule/view', 'id' => $model->final_rule_id]) : '', 'format' => 'raw'], ['attribute' => 'start_date', 'format' => 'datetime', 'type' => DetailView::INPUT_DATETIME, 'widgetOptions' => ['pluginOptions' => ['format' => 'yyyy-mm-dd hh:ii:ss', 'todayHighlight' => true]], 'value' => $model->registration_begin ? new DateTime($model->start_date) : ''], ['attribute' => 'recurrence', 'format' => 'raw', 'type' => DetailView::INPUT_TEXT, 'value' => $recurrence], ['attribute' => 'registration_begin', 'format' => 'datetime', 'type' => DetailView::INPUT_DATETIME, 'widgetOptions' => ['pluginOptions' => ['format' => 'yyyy-mm-dd hh:ii:ss', 'todayHighlight' => true]], 'value' => $model->registration_begin ? new DateTime($model->registration_begin) : ''], ['attribute' => 'registration_end', 'format' => 'datetime', 'type' => DetailView::INPUT_DATETIME, 'widgetOptions' => ['pluginOptions' => ['format' => 'yyyy-mm-dd hh:ii:ss', 'todayHighlight' => true]], 'value' => $model->registration_end ? new DateTime($model->registration_end) : ''], 'handicap_min', 'handicap_max', 'age_min', 'age_max', ['attribute' => 'gender', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => ['' => ''] + Competition::getLocalizedConstants('GENDER_')], 'max_players', ['attribute' => 'registration_special', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => ['' => ''] + Competition::getLocalizedConstants('SPECIAL_')], 'registration_time', 'flight_size', 'flight_time', ['attribute' => 'status', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => Competition::getLocalizedConstants('STATUS_')]]]);
?>

<?php 
if (in_array($model->competition_type, [Competition::TYPE_SEASON, Competition::TYPE_TOURNAMENT])) {
    switch ($model->competition_type) {
        case Competition::TYPE_SEASON:
            $searchModel = new TournamentSearch();
            $dataProvider = $searchModel->search(['TournamentSearch' => ['parent_id' => $model->id]]);
Exemple #4
0
<?php

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use dosamigos\datetimepicker\DateTimePicker;
$summary = '';
if ($model->recurrence_rule) {
    $rule = new \Recurr\Rule($model->recurrence_rule);
    $transformer = new \Recurr\Transformer\ArrayTransformer();
    $transformerConfig = new \Recurr\Transformer\ArrayTransformerConfig();
    $transformerConfig->enableLastDayOfMonthFix();
    $transformer->setConfig($transformerConfig);
    $textTransformer = new \Recurr\Transformer\TextTransformer(new \Recurr\Transformer\Translator('en'));
    $summary = $textTransformer->transform($rule);
}
?>

<?php 
$form = ActiveForm::begin(['id' => 'event-form', 'layout' => 'horizontal', 'fieldConfig' => ['template' => "{label}\n{beginWrapper}\n{input}\n{endWrapper}", 'horizontalCssClasses' => ['label' => 'col-sm-3', 'offset' => 'col-sm-offset-3', 'wrapper' => 'col-sm-8']]]);
?>

<?php 
echo Html::activeHiddenInput($model, 'id');
?>
   
<?php 
echo Html::activeHiddenInput($model, 'calendar_id');
echo Html::activeHiddenInput($model, 'created_by');
echo Html::activeHiddenInput($model, 'recurrence_rule');
?>