/** * Return formatted match time * * @param object $game * @param array $config * @param array $overallconfig * @param object $project * @return string html */ public static function showMatchTime(&$game, &$config, &$overallconfig, &$project) { $output = ''; if (!isset($overallconfig['time_format'])) { $overallconfig['time_format'] = 'H:i'; } $timeSuffix = JText::_('COM_JOOMLEAGUE_GLOBAL_CLOCK'); if ($timeSuffix == 'COM_JOOMLEAGUE_GLOBAL_CLOCK') { $timeSuffix = '%1$s h'; } if ($game->match_date) { $matchTime = JoomleagueHelper::getMatchTime($game, $overallconfig['time_format']); if ($config['show_time_suffix'] == 1) { $output .= sprintf($timeSuffix, $matchTime); } else { $output .= $matchTime; } $config['mark_now_playing'] = isset($config['mark_now_playing']) ? $config['mark_now_playing'] : 0; if ($config['mark_now_playing']) { $totalMatchDuration = $project->halftime * ($project->game_parts - 1) + $project->game_regular_time; if ($project->allow_add_time == 1 && $game->team1_result == $game->team2_result) { $totalMatchDuration += $project->add_time; } $project_tz = new DateTimeZone($game->timezone); $startTimestamp = JoomleagueHelper::getMatchStartTimestamp($game); $startTime = new DateTime($startTimestamp, $project_tz); $endTime = new DateTime($startTimestamp, $project_tz); $endTime->add(new DateInterval('PT' . $totalMatchDuration . 'M')); $now = new DateTime('now', $project_tz); if ($now >= $startTime && $now <= $endTime) { $match_begin = $output . ' '; $title = str_replace('%STARTTIME%', $match_begin, trim(htmlspecialchars($config['mark_now_playing_alt_text']))); $title = str_replace('%ACTUALTIME%', self::mark_now_playing($thistime, $match_stamp, $config, $project), $title); $styletext = ''; if (isset($config['mark_now_playing_blink']) && $config['mark_now_playing_blink']) { $styletext = ' style="text-decoration:blink"'; } $output = '<b><i><acronym title="' . $title . '"' . $styletext . '>'; $output .= $config['mark_now_playing_text']; $output .= '</acronym></i></b>'; } } } else { $matchTime = '-- : --'; if ($config['show_time_suffix']) { $output .= sprintf($timeSuffix, $matchTime); } else { $output .= $matchTime; } } return $output; }
function _displayForm($tpl) { $app = JFactory::getApplication(); $option = JRequest::getCmd('option'); $user = JFactory::getUser(); $model = $this->getModel(); $lists = array(); // get the match $match = $this->get('data'); $isNew = $match->id < 1; if (!$match->projectteam1_id and !$match->projectteam2_id) { JError::raiseWarning(440, '<br />' . JText::_('COM_JOOMLEAGUE_ADMIN_MATCH_NO_TEAMS') . '<br /><br />'); return false; } // fail if checked out not by 'me' if ($model->isCheckedOut($user->get('id'))) { $msg = JText::sprintf('DESCBEINGEDITTED', JText::_('COM_JOOMLEAGUE_ADMIN_MATCH_THE_MATCH'), $match->name); $app->redirect('index.php?option=com_joomleague', $msg); } // Edit or Create? if (!$isNew) { $model->checkout($user->get('id')); } // build the html select booleanlist for published $lists['published'] = JHtml::_('select.booleanlist', 'published', 'class="inputbox"', $match->published); // get the home team standard playground $tblProjectHomeTeam = JTable::getInstance('ProjectTeam', 'Table'); $tblProjectHomeTeam->load($match->projectteam1_id); $standard_playground_id = !empty($tblProjectHomeTeam->standard_playground) && $tblProjectHomeTeam->standard_playground > 0 ? $tblProjectHomeTeam->standard_playground : null; $playground_id = !empty($match->playground_id) && $match->playground_id > 0 ? $match->playground_id : $standard_playground_id; // build the html select booleanlist for count match result $lists['count_result'] = JHtml::_('select.booleanlist', 'count_result', 'class="inputbox"', $match->count_result); // build the html select booleanlist which team got the won $myoptions = array(); $myoptions[] = JHtml::_('select.option', '0', JText::_('COM_JOOMLEAGUE_ADMIN_MATCHES_NO_TEAM')); $myoptions[] = JHtml::_('select.option', '1', JText::_('COM_JOOMLEAGUE_ADMIN_MATCHES_HOME_TEAM')); $myoptions[] = JHtml::_('select.option', '2', JText::_('COM_JOOMLEAGUE_ADMIN_MATCHES_AWAY_TEAM')); $myoptions[] = JHtml::_('select.option', '3', JText::_('COM_JOOMLEAGUE_ADMIN_MATCHES_LOSS_BOTH_TEAMS')); $myoptions[] = JHtml::_('select.option', '4', JText::_('COM_JOOMLEAGUE_ADMIN_MATCHES_WON_BOTH_TEAMS')); $lists['team_won'] = JHtml::_('select.genericlist', $myoptions, 'team_won', 'class="inputbox" size="1"', 'value', 'text', $match->team_won); $projectws = $this->get('Data', 'project'); $model = $this->getModel('project'); $overall_config = $model->getTemplateConfig('overall'); $table_config = $model->getTemplateConfig('ranking'); $extended = $this->getExtended($match->extended, 'match'); // match relation tab $mdlMatch = JModelLegacy::getInstance('match', 'JoomleagueModel'); $oldmatches[] = JHtml::_('select.option', '0', JText::_('COM_JOOMLEAGUE_ADMIN_MATCH_OLD_MATCH')); $res = array(); $new_match_id = $match->new_match_id ? $match->new_match_id : 0; if ($res = $mdlMatch->getMatchRelationsOptions($app->getUserState($option . 'project', 0), $match->id . "," . $new_match_id)) { foreach ($res as $m) { $m->text = '(' . JoomleagueHelper::getMatchStartTimestamp($m) . ') - ' . $m->t1_name . ' - ' . $m->t2_name; } $oldmatches = array_merge($oldmatches, $res); } $lists['old_match'] = JHtml::_('select.genericlist', $oldmatches, 'old_match_id', 'class="inputbox" size="1"', 'value', 'text', $match->old_match_id); $newmatches[] = JHtml::_('select.option', '0', JText::_('COM_JOOMLEAGUE_ADMIN_MATCH_NEW_MATCH')); $res = array(); $old_match_id = $match->old_match_id ? $match->old_match_id : 0; if ($res = $mdlMatch->getMatchRelationsOptions($app->getUserState($option . 'project', 0), $match->id . "," . $old_match_id)) { foreach ($res as $m) { $m->text = '(' . JoomleagueHelper::getMatchStartTimestamp($m) . ') - ' . $m->t1_name . ' - ' . $m->t2_name; } $newmatches = array_merge($newmatches, $res); } $lists['new_match'] = JHtml::_('select.genericlist', $newmatches, 'new_match_id', 'class="inputbox" size="1"', 'value', 'text', $match->new_match_id); $this->overall_config = $overall_config; $this->table_config = $table_config; $this->projectws = $projectws; $this->lists = $lists; $this->match = $match; $this->extended = $extended; $form = $this->get('form'); $form->setValue('playground_id', null, $playground_id); $this->form = $form; parent::display($tpl); }
function formatMatches($rows, &$matches) { $newrows = array(); $teamnames = $this->xparams->get('team_names', 'short_name'); $teams = JoomleagueConnector::getTeamsFromMatches($rows); $teams[0]->name = $teams[0]->{$teamnames} = $teams[0]->logo_small = $teams[0]->logo_middle = $teams[0]->logo_big = ''; foreach ($rows as $key => $row) { $newrows[$key]['type'] = 'jlm'; $newrows[$key]['homepic'] = isset($teams[$row->matchpart1]) ? JoomleagueConnector::buildImage($teams[$row->matchpart1]) : ''; $newrows[$key]['awaypic'] = isset($teams[$row->matchpart2]) ? JoomleagueConnector::buildImage($teams[$row->matchpart2]) : ''; $newrows[$key]['date'] = JoomleagueHelper::getMatchStartTimestamp($row); $newrows[$key]['result'] = !is_null($row->matchpart1_result) ? $row->matchpart1_result . ':' . $row->matchpart2_result : '-:-'; $newrows[$key]['headingtitle'] = parent::jl_utf8_convert($row->name . '-' . $row->roundname, 'iso-8859-1', 'utf-8'); $newrows[$key]['homename'] = isset($teams[$row->matchpart1]) ? JoomleagueConnector::formatTeamName($teams[$row->matchpart1]) : 'n/a'; $newrows[$key]['awayname'] = isset($teams[$row->matchpart2]) ? JoomleagueConnector::formatTeamName($teams[$row->matchpart2]) : 'n/a'; $newrows[$key]['matchcode'] = $row->matchcode; $newrows[$key]['project_id'] = $row->project_id; $matches[] = $newrows[$key]; if (isset($teams[$row->matchpart1])) { parent::addTeam($row->matchpart1, parent::jl_utf8_convert($teams[$row->matchpart1]->name, 'iso-8859-1', 'utf-8'), $newrows[$key]['homepic']); } if (isset($teams[$row->matchpart2])) { parent::addTeam($row->matchpart2, parent::jl_utf8_convert($teams[$row->matchpart2]->name, 'iso-8859-1', 'utf-8'), $newrows[$key]['awaypic']); } } return $newrows; }
function formatMatches($rows, &$matches) { $newrows = array(); $teamnames = $this->xparams->get('team_names', 'short_name'); $teams = JoomleagueConnector::getTeamsFromMatches($rows); $teams[0] = new stdclass(); $teams[0]->name = $teams[0]->{$teamnames} = $teams[0]->logo_small = $teams[0]->logo_middle = $teams[0]->logo_big = ''; foreach ($rows as $key => $row) { $newrows[$key]['type'] = 'jlm'; $newrows[$key]['homepic'] = JoomleagueConnector::buildImage($teams[$row->projectteam1_id]); $newrows[$key]['awaypic'] = JoomleagueConnector::buildImage($teams[$row->projectteam2_id]); $newrows[$key]['date'] = JoomleagueHelper::getMatchStartTimestamp($row); //$newrows[$key]['result'] = (!is_null($row->matchpart1_result)) ? $row->matchpart1_result . ':' . $row->matchpart2_result : '-:-'; $newrows[$key]['result'] = !is_null($row->team1_result) ? $row->team1_result . ':' . $row->team2_result : '-:-'; $newrows[$key]['headingtitle'] = parent::jl_utf8_convert($row->name . '-' . $row->roundname, 'iso-8859-1', 'utf-8'); $newrows[$key]['homename'] = JoomleagueConnector::formatTeamName($teams[$row->projectteam1_id]); $newrows[$key]['awayname'] = JoomleagueConnector::formatTeamName($teams[$row->projectteam2_id]); $newrows[$key]['matchcode'] = $row->matchcode; $newrows[$key]['project_id'] = $row->project_id; // insert matchdetaillinks $newrows[$key]['link'] = JoomleagueHelperRoute::getNextMatchRoute($row->project_id, $row->matchcode); $matches[] = $newrows[$key]; parent::addTeam($row->projectteam1_id, parent::jl_utf8_convert($teams[$row->projectteam1_id]->name, 'iso-8859-1', 'utf-8'), $newrows[$key]['homepic']); parent::addTeam($row->projectteam2_id, parent::jl_utf8_convert($teams[$row->projectteam2_id]->name, 'iso-8859-1', 'utf-8'), $newrows[$key]['awaypic']); } return $newrows; }
function display($tpl = null) { // Get a reference of the page instance in joomla $document = JFactory::getDocument(); $model = $this->getModel(); $project = $model->getProject(); //$config = $model->getTemplateConfig($this->getName()); if (isset($project)) { $this->project = $project; } $this->overallconfig = $model->getOverallConfig(); $this->config = $this->overallconfig; $this->matches = $model->getMatches(); $this->teams = $model->getTeamsFromMatches($this->matches); // load a class that handles ical formats. require_once JLG_PATH_SITE . DS . 'helpers' . DS . 'iCalcreator.class.php'; // create a new calendar instance $v = new vcalendar(); foreach ($this->matches as $match) { $hometeam = $this->teams[$match->team1]; $home = sprintf('%s', $hometeam->name); $guestteam = $this->teams[$match->team2]; $guest = sprintf('%s', $guestteam->name); $summary = $match->project_name . ': ' . $home . ' - ' . $guest; // check if match gots a date, if not it will not be included in ical if ($match->match_date) { $totalMatchTime = isset($project) ? $project->halftime * ($project->game_parts - 1) + $project->game_regular_time : 90; $start = JoomleagueHelper::getMatchStartTimestamp($match, 'Y-m-d H:i:s'); $end = JoomleagueHelper::getMatchEndTimestamp($match, $totalMatchTime, 'Y-m-d H:i:s'); // check if exist a playground in match or team or club $stringlocation = ''; $stringname = ''; if (!empty($match->playground_id)) { $stringlocation = $match->playground_address . ", " . $match->playground_zipcode . " " . $match->playground_city; $stringname = $match->playground_name; } elseif (!empty($match->team_playground_id)) { $stringlocation = $match->team_playground_address . ", " . $match->team_playground_zipcode . " " . $match->team_playground_city; $stringname = $match->team_playground_name; } elseif (!empty($match->club_playground_id)) { $stringlocation = $match->club_playground_address . ", " . $match->club_playground_zipcode . " " . $match->club_playground_city; $stringname = $match->club_playground_name; } $location = $stringlocation; //if someone want to insert more in description here is the place $description = $stringname; // create an event and insert it in calendar $vevent = new vevent(); $timezone = JoomleagueHelper::getMatchTimezone($match); $vevent->setProperty("dtstart", $start, array("TZID" => $timezone)); $vevent->setProperty("dtend", $end, array("TZID" => $timezone)); $vevent->setProperty('LOCATION', $location); $vevent->setProperty('summary', $summary); $vevent->setProperty('description', $description); $v->setComponent($vevent); } } $v->setProperty("X-WR-TIMEZONE", $timezone); $xprops = array("X-LIC-LOCATION" => $timezone); iCalUtilityFunctions::createTimezone($v, $timezone, $xprops); $v->returnCalendar(); //$debugstr = $v->createCalendar(); //echo "<pre>"; //echo $debugstr; // exit before display // parent::display( $tpl ); }