function OnPreRender()
 {
     /* @var $o_season Season */
     /* @var $o_team Team */
     $this->SetCaption($this->o_competition->GetName());
     $o_headings = new XhtmlRow(array('Name of team', 'Ground address', 'Contact details'));
     $o_headings->SetIsHeader(true);
     $this->AddRow($o_headings);
     foreach ($this->o_competition->GetLatestSeason()->GetTeams() as $o_team) {
         if ($o_team instanceof Team) {
             $o_row = new XhtmlRow();
             $o_row->AddCell(new XhtmlAnchor(Html::Encode($o_team->GetName()), $o_team->GetEditTeamUrl()));
             $o_row->AddCell(new PostalAddressControl($o_team->GetGround()->GetAddress()));
             $private = $o_team->GetPrivateContact();
             $public = $o_team->GetContact();
             $private_header = '<h2 style="margin:0; font-size:1.1em; color: #900;">Private</h2>';
             if ($private and $public) {
                 $contact = $public . $private_header . $private;
             } else {
                 $contact = $private ? $private_header . $private : $public;
             }
             $o_row->AddCell(nl2br(XhtmlMarkup::ApplySimpleTags(XhtmlMarkup::ApplyLinks($contact, true))));
             $this->AddRow($o_row);
         }
     }
     parent::OnPreRender();
 }
 public function __construct(Competition $competition)
 {
     $this->competition = $competition;
     $season = $competition->GetLatestSeason();
     $teams = $season->GetTeams();
     $keywords = array();
     $content = array();
     $keywords[] = $competition->GetName();
     foreach ($teams as $team) {
         $keywords[] = $team->GetName();
         $keywords[] = $team->GetGround()->GetAddress()->GetLocality();
         $keywords[] = $team->GetGround()->GetAddress()->GetTown();
     }
     $content[] = $competition->GetIntro();
     $content[] = $competition->GetContact();
     $this->searchable = new SearchItem("competition", "competition" . $competition->GetId(), $competition->GetNavigateUrl(), $competition->GetName());
     $this->searchable->WeightOfType(700);
     $this->searchable->Description($this->GetSearchDescription());
     $this->searchable->Keywords(implode(" ", $keywords));
     $this->searchable->FullText(implode(" ", $content));
     $related = '<ul>';
     if ($season->GetShowTable()) {
         $related .= '<li><a href="' . $season->GetTableUrl() . '">Table</a></li>';
     }
     $related .= '<li><a href="' . $competition->GetCompetitionMapUrl() . '">Map</a></li>' . '<li><a href="' . $competition->GetStatisticsUrl() . '">Statistics</a></li>' . '</ul>';
     $this->searchable->RelatedLinksHtml($related);
 }
 function OnPrePageLoad()
 {
     /* @var $o_competition Competition */
     /* @var $o_season Season */
     $this->SetPageTitle(is_object($this->o_competition) ? $this->o_competition->GetName() . ': Edit stoolball competition' : 'New stoolball competition');
     $this->LoadClientScript("/scripts/tiny_mce/jquery.tinymce.js");
     $this->LoadClientScript("/scripts/tinymce.js");
 }
Example #4
0
 /**
  * @return Competition
  */
 public function getCompetition()
 {
     if (!$this->competition) {
         $this->competition = Competition::getByNefubId($this->competition_nefub_id);
     }
     return $this->competition;
 }
Example #5
0
 public function actionRender()
 {
     $competition = Competition::model()->findByPk($this->iRequest('competition_id'));
     $template = NewsTemplate::model()->findByPk($this->iRequest('template_id'));
     if ($competition === null || $template === null) {
         $this->ajaxOK(null);
     }
     $attributes = $template->attributes;
     $data = $this->generateTemplateData($competition);
     set_error_handler(function ($errno, $errstr) {
         throw new Exception($errstr);
     });
     try {
         foreach ($attributes as $key => $attribute) {
             $attributes[$key] = preg_replace_callback('|\\{([^}]+)\\}|i', function ($matches) use($data) {
                 $result = $this->evaluateExpression($matches[1], $data);
                 if (is_array($result)) {
                     $result = CHtml::normalizeUrl($result);
                 }
                 return $result;
             }, $attribute);
         }
     } catch (Exception $e) {
         $this->ajaxOK(null);
     }
     $this->ajaxOK($attributes);
 }
Example #6
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $news = new News('search');
     $news->status = News::STATUS_SHOW;
     $upcomingCompetitions = Competition::getUpcomingCompetitions();
     $this->render('index', array('news' => $news, 'upcomingCompetitions' => $upcomingCompetitions));
 }
 public static function find($id)
 {
     $query = DB::connection()->prepare('SELECT * FROM Competition WHERE id = :id LIMIT 1');
     $query->execute(array('id' => $id));
     $row = $query->fetch();
     if ($row) {
         return new Competition(Competition::get_attributes($row));
     }
     return null;
 }
 public static function admin_edit($id, $errors = null)
 {
     self::check_admin_logged_in();
     $user = User::find($id);
     $competitions = array();
     if ($user->type == 'recorder') {
         $competitions = Competition::all('');
     }
     self::admin_edit_view($user, $competitions, $errors);
 }
    function OnPageLoad()
    {
        echo new XhtmlElement('h1', Html::Encode('Delete competition: ' . $this->data_object->GetName()));
        if ($this->deleted) {
            ?>
			<p>The competition has been deleted.</p>
			<p><a href="/competitions">View all competitions</a></p>
			<?php 
        } else {
            if ($this->has_permission) {
                ?>
				<p>Deleting a competition cannot be undone. All seasons will be deleted, and matches will no longer be part of this competition.</p>
				<p>Are you sure you want to delete this competition?</p>
				<form action="<?php 
                echo Html::Encode($this->data_object->GetDeleteCompetitionUrl());
                ?>
" method="post" class="deleteButtons">
				<div>
				<input type="submit" value="Delete competition" name="delete" />
				<input type="submit" value="Cancel" name="cancel" />
				</div>
				</form>
				<?php 
                $this->AddSeparator();
                require_once 'stoolball/user-edit-panel.class.php';
                $panel = new UserEditPanel($this->GetSettings(), 'this competition');
                $panel->AddLink('view this competition', $this->data_object->GetNavigateUrl());
                $panel->AddLink('edit this competition', $this->data_object->GetEditCompetitionUrl());
                echo $panel;
            } else {
                ?>
				<p>Sorry, you're not allowed to delete this competition.</p>
				<p><a href="<?php 
                echo Html::Encode($this->data_object->GetNavigateUrl());
                ?>
">Go back to the competition</a></p>
				<?php 
            }
        }
    }
 private function ShowOtherSeasons()
 {
     # Check for other seasons. Check is >2 because current season is there twice - added above
     if (count($this->competition->GetSeasons()) > 2) {
         require_once "stoolball/season-list-control.class.php";
         echo new XhtmlElement('h2', 'Other seasons in the ' . Html::Encode($this->competition->GetName()), "screen");
         $season_list = new SeasonListControl($this->competition->GetSeasons());
         $season_list->SetExcludedSeasons(array($this->season));
         $season_list->AddCssClass("screen");
         $season_list->SetUrlMethod('GetMapUrl');
         echo $season_list;
     }
 }
 /**
  * @return string
  * @desc Gets the name of the competition and season - eg Sussex Mixed League, 2005 season
  */
 public function GetCompetitionName()
 {
     if (!isset($this->o_competition)) {
         return $this->GetName();
     }
     $s_name = $this->o_competition->GetName();
     if ($this->GetName()) {
         $s_name .= ', ' . $this->GetName() . ' season';
     } else {
         $s_years = $this->GetYears();
         if ($s_years) {
             $s_name .= ', ' . $s_years . ' season';
         }
     }
     return $s_name;
 }
Example #12
0
 public function actionUpdate()
 {
     $competitions = Competition::model()->findAllByAttributes(array('type' => Competition::TYPE_WCA), array('condition' => 'date < unix_timestamp() AND date > unix_timestamp() - 86400 * 20', 'order' => 'date ASC'));
     $wcaDb = intval(file_get_contents(dirname(__DIR__) . '/config/wcaDb'));
     $sql = "UPDATE `user` `u`\r\n\t\t\t\tINNER JOIN `registration` `r` ON `u`.`id`=`r`.`user_id`\r\n\t\t\t\tLEFT JOIN `competition` `c` ON `r`.`competition_id`=`c`.`id`\r\n\t\t\t\tLEFT JOIN `wca_{$wcaDb}`.`Results` `rs`\r\n\t\t\t\t\tON `c`.`wca_competition_id`=`rs`.`competitionId`\r\n\t\t\t\t\tAND `rs`.`personName`=CASE WHEN `u`.`name_zh`='' THEN `u`.`name` ELSE CONCAT(`u`.`name`, ' (', `u`.`name_zh`, ')') END\r\n\t\t\t\tSET `u`.`wcaid`=`rs`.`personId`\r\n\t\t\t\tWHERE `u`.`wcaid`='' and `r`.`competition_id`=%id%";
     $db = Yii::app()->db;
     $num = [];
     foreach ($competitions as $competition) {
         $num[$competition->id] = $db->createCommand(str_replace('%id%', $competition->id, $sql))->execute();
     }
     echo 'updated wcaid: ', array_sum($num), PHP_EOL;
     Yii::import('application.statistics.*');
     Yii::app()->cache->flush();
     $data = Statistics::getData(true);
     echo 'set results_statistics_data: ', $data ? 1 : 0, PHP_EOL;
 }
 public static function store()
 {
     $attributes = self::get_attributes();
     $split = new Split($attributes);
     $participant = Participant::find($split->participant_id);
     self::check_admin_or_recorder_logged_in($participant->competition_id);
     $competition_id = Competition::find($participant->competition_id)->id;
     $errors = $split->validate_split_time();
     if (count($errors) == 0) {
         $split->save();
         Participant::update_competition_standings($competition_id);
         Redirect::to('/competition/' . $competition_id . '/splits', array('message' => 'Väliaika lisätty.'));
     } else {
         self::creation_view($participant, $attributes, $errors);
     }
 }
 public static function update($id)
 {
     self::check_admin_logged_in();
     $attributes = self::get_attributes();
     $attributes['id'] = $id;
     $attributes['competition_name'] = Competition::find($attributes['competition_id'])->name;
     $attributes['competitor_name'] = Competitor::find($attributes['competitor_id'])->name;
     $attributes['standing'] = Participant::find($id)->standing;
     $participant = new Participant($attributes);
     $errors = $participant->validate_number();
     if (count($errors) == 0) {
         $participant->update();
         Redirect::to('/competition/' . $participant->competition_id . '/participants', array('message' => 'Kilpailijan numeroa muokattu onnistuneesti!'));
     } else {
         self::edit_view(array(Competition::find($participant->competition_id)), array(Competitor::find($participant->competitor_id)), $attributes, $errors);
     }
 }
Example #15
0
 public static function getCompetition($row)
 {
     $cacheKey = 'results_competition_data_' . $row['competitionId'];
     $cache = Yii::app()->cache;
     if (self::$_competitions === array()) {
         $competitions = Competition::model()->with('location', 'location.province', 'location.city')->cache(self::CACHE_EXPIRE)->findAll(array('condition' => 'wca_competition_id!=""', 'select' => 't.name, t.name_zh, t.wca_competition_id'));
         foreach ($competitions as $competition) {
             self::$_competitions[$competition->wca_competition_id] = array('name' => $competition->name, 'name_zh' => $competition->name_zh, 'city_name' => $competition->isMultiLocation() ? 'Multiple' : (in_array($competition->location[0]->province_id, array(215, 525, 567, 642)) ? $competition->location[0]->province->name : $competition->location[0]->city->name . ', ' . $competition->location[0]->province->name), 'city_name_zh' => $competition->isMultiLocation() ? '多地' : (in_array($competition->location[0]->province_id, array(215, 525, 567, 642)) ? $competition->location[0]->province->name_zh : $competition->location[0]->province->name_zh . $competition->location[0]->city->name_zh), 'url' => array('/results/c', 'id' => $competition->wca_competition_id));
         }
     }
     if (isset(self::$_competitions[$row['competitionId']])) {
         $data = self::$_competitions[$row['competitionId']];
     } elseif (($data = $cache->get($cacheKey)) === false) {
         $data['name'] = $data['name_zh'] = $row['cellName'];
         $data['city_name'] = $data['city_name_zh'] = $row['cityName'];
         $data['url'] = array('/results/c', 'id' => $row['competitionId']);
         $cache->set($cacheKey, $data, self::CACHE_EXPIRE);
         self::$_competitions[$row['competitionId']] = $data;
     }
     return array_merge($row, $data);
 }
Example #16
0
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         $criteria = new CDbCriteria();
         $criteria->with = array('organizer' => array('together' => true));
         $criteria->compare('organizer.organizer_id', Yii::app()->user->id);
         $criteria->compare('t.status', Competition::STATUS_SHOW);
         $competitions = Competition::model()->findAll($criteria);
         foreach ($competitions as $competition) {
             if (!$competition->isScheduleFinished()) {
                 $this->alerts[] = array('url' => array('/board/competition/edit', 'id' => $competition->id), 'label' => sprintf('"%s"赛程不完整', $competition->name_zh));
             }
         }
         Yii::app()->language = 'zh_cn';
         if (strpos($action->id, 'edit') !== false) {
             $this->setReferrer();
         }
         return true;
     }
     return false;
 }
Example #17
0
 public function actionUpcoming()
 {
     $competitions = Competition::getUpcomingRegistrableCompetitions(1000);
     $this->renderRss(array_reverse($competitions));
 }
Example #18
0
 public static function canShowAwardField($competition_id)
 {
     $superuser = Generic::isSuperAdmin();
     if (!$superuser) {
         // check if visible by competition settings
         $cache_key = 'CCompetition-mentor-awards-timestamp-' . $competition_id;
         $cache = Yii::app()->cache->get($cache_key);
         if ($cache == null) {
             $competition = Competition::model()->findByPk($competition_id);
             if ($competition != null) {
                 $cache = $competition->timestamp_mentor_awards == null ? '-' : $competition->timestamp_mentor_awards;
             } else {
                 $cache = '-';
             }
             Yii::app()->cache->set($cache_key, $cache, 600);
         }
         if ($cache == '-') {
             return false;
         } else {
             $timestamp = strtotime($cache);
             if ($timestamp > time()) {
                 return false;
             }
         }
     }
     return true;
 }
Example #19
0
 /**
  * 
  * @param int $nefubId
  */
 public function showClub($nefubId)
 {
     $this->subdirectory = '/club';
     $this->path = '/' . $nefubId;
     $this->template = '/club/club.tpl';
     if ($this->getClearRender()) {
         $oClub = Club::getByNefubId($nefubId);
         if ($oClub) {
             $competitionGenders = array('Heren', 'Dames', 'Mixed');
             $aCompetitions = array();
             foreach ($competitionGenders as $competitionGender) {
                 $oGender = Gender::getByNefubName($competitionGender);
                 $aGenreCompetitions = Competition::getAll(array('gender_id' => $oGender->getId(), 'season_nefub_id' => $this->season->nefub_id), 'genre_id`,`name');
                 $aCompetitions = array_merge($aCompetitions, $aGenreCompetitions);
             }
             $aCompetitionTeams = array();
             foreach ($aCompetitions as $oCompetition) {
                 $aTeams = Team::getAll(array('competition_nefub_id' => $oCompetition->nefub_id, 'club_nefub_id' => $oClub->nefub_id, 'season_nefub_id' => $oCompetition->season_nefub_id), 'name');
                 if (count($aTeams)) {
                     $aCompetitionTeams[] = array('competition' => $oCompetition, 'teams' => $aTeams);
                 }
             }
             $this->assign('oClub', $oClub);
             $this->assign('aCompetitionTeams', $aCompetitionTeams);
         } else {
             $this->redirect();
         }
     }
     $this->showOutput();
 }
Example #20
0
 public function actionCompetition()
 {
     $provinces = CHtml::listData(Region::getRegionsByPid(1), 'id', 'name_zh');
     $cities = Yii::app()->db->cache(86400)->createCommand()->select('*')->from('region')->where('pid>1')->order('id')->queryAll();
     $allCities = array();
     foreach ($cities as $city) {
         if (!isset($allCities[$city['pid']])) {
             $allCities[$city['pid']] = array();
         }
         $allCities[$city['pid']][$city['id']] = $city['name_zh'];
     }
     $cities = $allCities;
     $db = Yii::app()->db;
     $db->createCommand()->truncateTable('old_competition');
     $oldEvents = $db->createCommand()->select('*')->from('cubingchina_mf8.比赛项目')->order('项目顺序')->queryAll();
     $oldEvents = array_combine(array_map(function ($event) {
         return $event['项目顺序'];
     }, $oldEvents), $oldEvents);
     $oldCompetitions = $db->createCommand()->select('*')->from('cubingchina_mf8.比赛事件')->order('比赛id')->queryAll();
     foreach ($oldCompetitions as $oldCompetition) {
         $competition = new Competition();
         //基本信息
         $competition->name_zh = str_replace(' ', '', $oldCompetition['比赛名称']);
         $competition->date = strtotime($oldCompetition['比赛日期']);
         if ($oldCompetition['天数'] > 1) {
             $competition->end_date = $competition->date + 86400 * ($oldCompetition['天数'] - 1);
         }
         $competition->reg_end = $competition->date - 86400;
         $competition->old_competition_id = $oldCompetition['比赛id'];
         //地点
         $location = new CompetitionLocation();
         $detected = false;
         $address = $oldCompetition['地址'] . $oldCompetition['比赛名称'];
         foreach ($provinces as $provinceId => $province) {
             if (strpos($address, $province) !== false) {
                 $location->province_id = $provinceId;
                 $location->city_id = $this->_cityId;
                 foreach ($cities[$provinceId] as $cityId => $city) {
                     if (mb_strlen($city, 'utf-8') > 2) {
                         $city = mb_substr($city, 0, -1, 'utf-8');
                     }
                     if (strpos($address, $city) !== false) {
                         $location->city_id = $cityId;
                         break;
                     }
                 }
                 $detected = true;
                 break;
             }
         }
         if (!$detected) {
             $location->province_id = $this->_provinceId;
             $location->city_id = $this->_cityId;
         }
         $location->venue_zh = $oldCompetition['地址'];
         $competition->location = array($location);
         if ($oldCompetition['是否wca']) {
             $competition->type = Competition::TYPE_WCA;
             $wcaCompetitions = Competitions::model()->findAllByAttributes(array('countryId' => 'China', 'year' => date('Y', $competition->date), 'month' => date('m', $competition->date), 'day' => date('d', $competition->date)));
             $wcaCompetition = null;
             if (count($wcaCompetitions) == 1) {
                 $wcaCompetition = $wcaCompetitions[0];
             } else {
                 foreach ($wcaCompetitions as $value) {
                     if (strpos($value->website, '=' . $competition->old_competition_id) !== false) {
                         $wcaCompetition = $value;
                         break;
                     }
                 }
             }
             if ($wcaCompetition !== null) {
                 $competition->name = $wcaCompetition->name;
                 $competition->wca_competition_id = $wcaCompetition->id;
                 $location->venue = $wcaCompetition->venueDetails . ', ' . $wcaCompetition->venueAddress;
             }
         } else {
             $competition->type = Competition::TYPE_OTHER;
         }
         //代表和主办
         $oldComp = new OldCompetition();
         $oldComp->id = $oldCompetition['比赛id'];
         $oldComp->delegate_zh = OldCompetition::generateInfo($this->makeInfo($oldCompetition['监督代表']));
         $organizer = $this->makeInfo($oldCompetition['主办方']);
         if ($oldCompetition['主办电邮']) {
             $organizer[0]['email'] = $oldCompetition['主办电邮'];
         }
         $oldComp->organizer_zh = OldCompetition::generateInfo($organizer);
         $oldComp->save(false);
         //项目
         $events = array();
         $resultEvents = $db->createCommand()->select('*')->from('cubingchina_mf8.比赛成绩')->leftJoin('cubingchina_mf8.比赛项目', '比赛项目.项目id=比赛成绩.项目id')->where('比赛成绩.事件id=' . $oldCompetition['比赛id'])->group('比赛成绩.项目id, 比赛成绩.第N轮')->queryAll();
         if ($resultEvents !== array()) {
             foreach ($resultEvents as $value) {
                 $eventName = $value['项目名'];
                 $event = isset($this->_eventsMap[$eventName]) ? $this->_eventsMap[$eventName] : 'funny';
                 if (!isset($events[$event])) {
                     $events[$event] = array('round' => 0, 'fee' => 0);
                 }
                 $events[$event]['round']++;
             }
         }
         if ($events === array() && $competition->wca_competition_id !== '') {
             $resultEvents = Results::model()->findAllByAttributes(array('competitionId' => $competition->wca_competition_id), array('group' => 'eventId,roundId'));
             if ($resultEvents !== array()) {
                 foreach ($resultEvents as $value) {
                     $event = $value->eventId;
                     if (!isset($events[$event])) {
                         $events[$event] = array('round' => 0, 'fee' => 0);
                     }
                     $events[$event]['round']++;
                 }
             }
         }
         if ($events === array()) {
             for ($i = 0; $i < strlen($oldCompetition['比赛项目']); $i++) {
                 if ($oldCompetition['比赛项目'][$i]) {
                     $eventName = $oldEvents[$i + 1]['项目名'];
                     $event = isset($this->_eventsMap[$eventName]) ? $this->_eventsMap[$eventName] : 'funny';
                     $events[$event] = array('round' => 1, 'fee' => 0);
                 }
             }
         }
         $competition->events = $events;
         $competition->handleEvents();
         $ret = $competition->save(false);
         $location->competition_id = $competition->id;
         $location->save(false);
     }
 }
 /**
  * Gets the short URL formats for the site
  *
  * @return ShortUrlFormat[]
  */
 public function GetShortUrlFormats()
 {
     require_once 'http/short-url-format.class.php';
     $a_formats = array();
     require_once 'stoolball/clubs/club.class.php';
     $a_formats[] = Club::GetShortUrlFormatForType($this);
     require_once 'stoolball/competition.class.php';
     $a_formats[] = Competition::GetShortUrlFormatForType($this);
     require_once 'stoolball/ground.class.php';
     $a_formats[] = Ground::GetShortUrlFormatForType($this);
     require_once 'stoolball/match.class.php';
     $a_formats[] = Match::GetShortUrlFormatForType($this);
     require_once 'stoolball/season.class.php';
     $a_formats[] = Season::GetShortUrlFormatForType($this);
     require_once 'stoolball/team.class.php';
     $a_formats[] = Team::GetShortUrlFormatForType($this);
     require_once 'stoolball/player.class.php';
     $a_formats[] = Player::GetShortUrlFormatForType($this);
     return $a_formats;
 }
Example #22
0
 public function actionBbs()
 {
     $upcomingCompetitions = Competition::getUpcomingRegistrableCompetitions(100);
     $this->renderPartial('bbs', array('upcomingCompetitions' => $upcomingCompetitions));
 }
Example #23
0
<?php

include '../../../models/config.php';
include '../../../models/helpers.php';
function __autoload($name)
{
    include_once "../../../models/classes/{$name}.class.php";
}
session_start();
$err = array();
$profil = new Profil($_SESSION['profil_id']);
$competitions = new Competition();
$container = '<table border="1px">';
$n = 0;
foreach ($competitions->getResultList($_POST['id']) as $list) {
    $n++;
    $container .= "<tr><td>{$n}</td><td>{$list['user']}</td><td>{$list['prone']}</td><td>{$list['standing']}</td><td>{$list['time_points']}</td></tr>";
}
$container .= '</table>';
print $container;
Example #24
0
<?php

include '../../../models/config.php';
include '../../../models/helpers.php';
function __autoload($name)
{
    include_once "../../../models/classes/{$name}.class.php";
}
session_start();
$err = array();
$profil = new Profil($_SESSION['profil_id']);
$competitions = new Competition();
$container = '<table border="1px">';
$n = 0;
foreach ($competitions->getStartList($_POST['id']) as $list) {
    $n++;
    $container .= "<tr><td>{$n}</td><td>{$list['user']}</td></tr>";
}
$container .= '</table>';
print $container;
Example #25
0
<div class="col-lg-12">
  <?php 
$form = $this->beginWidget('ActiveForm', array('htmlOptions' => array('role' => 'form', 'class' => 'form-inline'), 'method' => 'get', 'action' => array('/competition/index')));
?>
  <?php 
echo Html::formGroup($model, 'year', array(), $form->labelEx($model, 'year'), CHtml::dropDownList('year', $model->year, Competition::getYears(), array('class' => 'form-control', 'prompt' => Yii::t('common', 'All'))));
?>
  <?php 
echo Html::formGroup($model, 'type', array(), $form->labelEx($model, 'type'), CHtml::dropDownList('type', $model->type, Competition::getTypes(), array('class' => 'form-control', 'prompt' => Yii::t('common', 'All'))));
?>
  <?php 
echo Html::formGroup($model, 'province', array(), $form->labelEx($model, 'province'), CHtml::dropDownList('province', $model->province, Region::getProvinces(false), array('class' => 'form-control', 'prompt' => Yii::t('common', 'All'))));
?>
  <?php 
echo Html::formGroup($model, 'event', array(), $form->labelEx($model, 'event'), CHtml::dropDownList('event', $model->event, Events::getNormalTranslatedEvents(), array('class' => 'form-control', 'prompt' => Yii::t('common', 'All'))));
?>
  <button type="submit" class="btn btn-theme"><?php 
echo Yii::t('common', 'Submit');
?>
</button>
  <?php 
$this->endWidget();
?>
  <?php 
$this->widget('GridView', array('dataProvider' => $model->search(), 'template' => '{summary}{items}{pager}', 'enableSorting' => false, 'front' => true, 'emptyText' => Yii::t('Competition', 'No competitions now.'), 'rowCssClassExpression' => '$data->isInProgress() ? "success" : ($data->isEnded() ? "active" : "info")', 'columns' => array(array('name' => 'date', 'type' => 'raw', 'value' => '$data->getDisplayDate()'), array('name' => 'name', 'type' => 'raw', 'value' => '$data->getCompetitionLink()'), array('name' => 'province_id', 'type' => 'raw', 'value' => '$data->getLocationInfo("province")'), array('name' => 'city_id', 'type' => 'raw', 'value' => '$data->getLocationInfo("city")'), array('name' => 'venue', 'type' => 'raw', 'value' => '$data->getLocationInfo("venue")'))));
?>
</div>
 public static function destroy($id)
 {
     self::check_admin_logged_in();
     Competition::delete($id);
     Redirect::to('/competition', array('message' => 'Kilpailu on poistettu onnistuneesti!'));
 }
Example #27
0
      <div class="portlet-heading">
          <div class="portlet-title">
              <h4>新闻信息</h4>
          </div>
          <div class="clearfix"></div>
      </div>
      <div class="panel-collapse collapse in">
          <div class="portlet-body">
            <?php 
$form = $this->beginWidget('ActiveForm', array('htmlOptions' => array('class' => 'clearfix row'), 'enableClientValidation' => true));
?>
            <?php 
echo Html::formGroup($model, 'date', array('class' => 'col-lg-6'), $form->labelEx($model, 'date', array('label' => '时间')), Html::activeTextField($model, 'date', array('class' => 'datetime-picker', 'data-date-format' => 'yyyy-mm-dd hh:ii:ss')), $form->error($model, 'date', array('class' => 'text-danger')));
?>
            <?php 
echo Html::formGroup($model, 'competition_id', array('class' => 'col-lg-6'), $form->labelEx($model, 'competition_id', array('label' => '比赛')), $form->dropDownList($model, 'competition_id', Competition::getRegistrationCompetitions(), array('class' => 'form-control', 'prompt' => '')), $form->error($model, 'competition_id', array('class' => 'text-danger')));
?>
            <div class="clearfix"></div>
            <?php 
echo Html::formGroup($model, 'organizer_id', array('class' => 'col-lg-6'), $form->labelEx($model, 'organizer_id', array('label' => '主办方')), $form->hiddenField($model, 'organizer_id'), CHtml::textField('', '', array('class' => 'form-control tokenfield', 'placeholder' => '输入名字或拼音')), $form->error($model, 'organizer_id', array('class' => 'text-danger')));
?>
            <?php 
echo Html::formGroup($model, 'rank', array('class' => 'col-lg-6'), $form->labelEx($model, 'rank', array('label' => '评级')), $form->dropDownList($model, 'rank', Review::getRanks(), array('class' => 'form-control', 'prompt' => '')), $form->error($model, 'rank', array('class' => 'text-danger')));
?>
            <div class="clearfix"></div>
            <?php 
echo Html::formGroup($model, 'comments', array('class' => 'col-lg-12'), $form->labelEx($model, 'comments', array('label' => '备注')), $form->textArea($model, 'comments', array('class' => 'editor form-control', 'rows' => 6)), $form->error($model, 'comments', array('class' => 'text-danger')));
?>
            <div class="col-lg-12">
              <button type="submit" class="btn btn-default btn-square"><?php 
echo Yii::t('common', 'Submit');
 /**
  * @return void
  * @desc Re-build from data posted by this control the data object this control is editing
  */
 function BuildPostedDataObject()
 {
     /* @var $o_season Season */
     $o_season = new Season($this->GetSettings());
     if (isset($_POST['start']) and is_numeric($_POST['start'])) {
         $o_season->SetStartYear($_POST['start']);
     }
     $i_year_span = isset($_POST['when']) ? (int) $_POST['when'] : 0;
     $o_season->SetEndYear($o_season->GetStartYear() + $i_year_span);
     $o_season->SetName($o_season->GetYears());
     if (isset($_POST['item'])) {
         $o_season->SetId($_POST['item']);
     } else {
         $this->b_saving_new = true;
         $this->match_types_editor->SetMinimumItems(0);
         # because will be populated from previous season (if there is one)
     }
     $o_season->SetIntro(ucfirst(trim($_POST['intro'])));
     $o_season->SetShortUrl($_POST[$this->GetNamingPrefix() . 'ShortUrl']);
     # Get the competition short URL and generate a season URL, rather than providing
     # a direct interface for season URLs.
     $o_comp = new Competition($this->GetSettings());
     $o_comp->SetId($_POST['competition']);
     $o_season->SetCompetition($o_comp);
     # Match types - get from aggregated editor
     $selected_match_types = $this->match_types_editor->DataObjects()->GetItems();
     foreach ($selected_match_types as $id_value) {
         $o_season->MatchTypes()->Add($id_value->GetId());
     }
     # Results and rules
     if (isset($_POST['results'])) {
         $o_season->SetResults($_POST['results']);
     }
     foreach ($this->result_types as $o_result) {
         /*@var $o_result MatchResult */
         $s_key = $this->GetNamingPrefix() . 'Result' . $o_result->GetResultType() . 'Home';
         if (isset($_POST[$s_key]) and strlen($_POST[$s_key]) and is_numeric($_POST[$s_key])) {
             $o_result->SetHomePoints($_POST[$s_key]);
         }
         $s_key = $this->GetNamingPrefix() . 'Result' . $o_result->GetResultType() . 'Away';
         if (isset($_POST[$s_key]) and strlen($_POST[$s_key]) and is_numeric($_POST[$s_key])) {
             $o_result->SetAwayPoints($_POST[$s_key]);
         }
         if (!is_null($o_result->GetHomePoints()) or !is_null($o_result->GetAwayPoints())) {
             $o_season->PossibleResults()->Add($o_result);
         }
     }
     # Points adjustments - get from aggregated editor
     $o_season->PointsAdjustments()->SetItems($this->adjustments_editor->DataObjects()->GetItems());
     # Show league table?
     $o_season->SetShowTable(isset($_POST['showTable']));
     $o_season->SetShowTableRunsScored(isset($_POST['runsScored']));
     $o_season->SetShowTableRunsConceded(isset($_POST['runsConceded']));
     # Teams - get from aggregated editor
     $a_teams_in_season = $this->teams_editor->DataObjects()->GetItems();
     foreach ($a_teams_in_season as $team_in_season) {
         /* @var $team_in_season TeamInSeason */
         $o_season->AddTeam($team_in_season->GetTeam());
         if ($team_in_season->GetWithdrawnFromLeague()) {
             $o_season->TeamsWithdrawnFromLeague()->Add($team_in_season->GetTeam());
         }
     }
     $this->SetDataObject($o_season);
 }
Example #29
0
<?php

include '../../../models/config.php';
include '../../../models/helpers.php';
function __autoload($name)
{
    include_once "../../../models/classes/{$name}.class.php";
}
session_start();
$err = array();
$profil = new Profil($_SESSION['profil_id']);
$competitions = new Competition();
if ($competitions->userIsRegistratedOnCompetition($profil->getId(), $_POST['id']) == false) {
    if (isset($_POST['registrate']) && $_POST['registrate'] == 'true') {
        $competitions->registrateUserForCompetition($profil->getId(), $_POST['id']);
    }
}
$competition = $competitions->getCompetition($_POST['id'], $profil->getLevel());
$container = "<h3>{$competition['title']}</h3>";
$container .= "<p>{$competition['description']}</p>";
$container .= "<div>startovné: {$competition['start_price']} EUR</div>";
$date = date('j. n. Y - H:i:s', $competition['date']);
$container .= "<div>start: {$date}</div>";
if ($competitions->userIsRegistratedOnCompetition($profil->getId(), $_POST['id']) == true) {
    $container .= "<div id='registrationToCompetition' onclick='showStartlist(\"{$_POST['id']}\")'>Startovní listina</div>";
    $container .= "<div id='startList'></div>";
} else {
    $container .= "<div id='registrationToCompetition' onclick='registrateOnCompetition(\"{$_POST['id']}\")'>Přihlásit se na závod</div>";
}
print $container;
Example #30
0
      <div class="portlet-heading">
          <div class="portlet-title">
              <h4>新闻信息</h4>
          </div>
          <div class="clearfix"></div>
      </div>
      <div class="panel-collapse collapse in">
          <div class="portlet-body">
            <?php 
$form = $this->beginWidget('ActiveForm', array('htmlOptions' => array('class' => 'clearfix row'), 'enableClientValidation' => true));
?>
            <?php 
echo Html::formGroup($model, '', array('class' => 'col-lg-6'), '<label for="template_id">新闻模板</label>', CHtml::dropDownList('template_id', '', CHtml::listData(NewsTemplate::model()->findAll(), 'id', 'name'), array('prompt' => '', 'class' => 'form-control')), $form->error($model, 'title_zh', array('class' => 'text-danger')));
?>
            <?php 
echo Html::formGroup($model, '', array('class' => 'col-lg-6'), '<label for="template_id">比赛事件</label>', CHtml::dropDownList('competition_id', '', Competition::getRegistrationCompetitions(), array('prompt' => '', 'class' => 'form-control')), $form->error($model, 'title_zh', array('class' => 'text-danger')));
?>
            <div class="clearfix"></div>
            <?php 
echo Html::formGroup($model, 'title_zh', array('class' => 'col-lg-6'), $form->labelEx($model, 'title_zh', array('label' => '中文标题')), Html::activeTextField($model, 'title_zh'), $form->error($model, 'title_zh', array('class' => 'text-danger')));
?>
            <?php 
echo Html::formGroup($model, 'title', array('class' => 'col-lg-6'), $form->labelEx($model, 'title', array('label' => '英文标题')), Html::activeTextField($model, 'title'), $form->error($model, 'title', array('class' => 'text-danger')));
?>
            <div class="clearfix"></div>
            <?php 
echo Html::formGroup($model, 'date', array('class' => 'col-lg-6'), $form->labelEx($model, 'date', array('label' => '时间')), Html::activeTextField($model, 'date', array('class' => 'datetime-picker', 'data-date-format' => 'yyyy-mm-dd hh:ii:ss')), $form->error($model, 'date', array('class' => 'text-danger')));
?>
            <?php 
echo Html::formGroup($model, 'weight', array('class' => 'col-lg-6'), $form->labelEx($model, 'weight', array('label' => '是否置顶')), $form->dropDownList($model, 'weight', News::getWeights(), array('class' => 'form-control')), $form->error($model, 'weight', array('class' => 'text-danger')));
?>