function save() { // Check for request forgeries JRequest::checkToken() or die('COM_JOOMLEAGUE_GLOBAL_INVALID_TOKEN'); $post = JRequest::get('post'); $cid = JRequest::getVar('cid', array(0), 'post', 'array'); $post['id'] = (int) $cid[0]; // decription must be fetched without striping away html code $post['notes'] = JRequest::getVar('notes', 'none', 'post', 'STRING', JREQUEST_ALLOWHTML); $model = $this->getModel('playground'); if (!empty($post['address'])) { $address_parts[] = $post['address']; } if (!empty($post['state'])) { $address_parts[] = $post['state']; } if (!empty($post['location'])) { if (!empty($post['zipcode'])) { $address_parts[] = $post['zipcode'] . ' ' . $post['location']; } else { $address_parts[] = $post['location']; } } if (!empty($post['country'])) { $address_parts[] = Countries::getShortCountryName($post['country']); } $address = implode(', ', $address_parts); $coords = $model->resolveLocation($address); //$mainframe->enqueueMessage(JText::_('coords -> '.'<pre>'.print_r($coords,true).'</pre>' ),''); foreach ($coords as $key => $value) { $post['extended'][$key] = $value; } $post['latitude'] = $coords['latitude']; $post['longitude'] = $coords['longitude']; if ($model->store($post)) { $msg = JText::_('COM_JOOMLEAGUE_ADMIN_VENUE_CTRL_SAVED'); } else { $msg = JText::_('COM_JOOMLEAGUE_ADMIN_VENUE_CTRL_ERROR_SAVE') . $model->getError(); } // Check the table in so it can be edited.... we are done with it anyway $model->checkin(); if ($this->getTask() == 'save') { $link = 'index.php?option=com_joomleague&view=playgrounds'; } else { $link = 'index.php?option=com_joomleague&task=playground.edit&cid[]=' . $post['id']; } $this->setRedirect($link, $msg); }
/** * AddressString */ function getAddressString() { $club = $this->getClub(); if (!isset($club)) { return null; } $address_parts = array(); if (!empty($club->address)) { $address_parts[] = $club->address; } if (!empty($club->state)) { $address_parts[] = $club->state; } if (!empty($club->location)) { if (!empty($club->zipcode)) { $address_parts[] = $club->zipcode . ' ' . $club->location; } else { $address_parts[] = $club->location; } } if (!empty($club->country)) { $address_parts[] = Countries::getShortCountryName($club->country); } $address = implode(', ', $address_parts); return $address; }
function save() { // Check for request forgeries JRequest::checkToken() or die('COM_JOOMLEAGUE_GLOBAL_INVALID_TOKEN'); $post = JRequest::get('post'); $pid = JRequest::getInt('cid'); $post['id'] = $pid; //map cid to table pk: id //$mainframe->enqueueMessage(JText::_('post -> '.'<pre>'.print_r($post,true).'</pre>' ),''); // decription must be fetched without striping away html code $post['notes'] = JRequest::getVar('notes', 'none', 'post', 'STRING', JREQUEST_ALLOWHTML); $model = $this->getModel('person'); if (!empty($post['address'])) { $address_parts[] = $post['address']; } if (!empty($post['state'])) { $address_parts[] = $post['state']; } if (!empty($post['location'])) { if (!empty($post['zipcode'])) { $address_parts[] = $post['zipcode'] . ' ' . $post['location']; } else { $address_parts[] = $post['location']; } } if (!empty($post['country'])) { $address_parts[] = Countries::getShortCountryName($post['country']); } $address = implode(', ', $address_parts); $coords = $model->resolveLocation($address); //$mainframe->enqueueMessage(JText::_('coords -> '.'<pre>'.print_r($coords,true).'</pre>' ),''); if (count($post['extended']['COM_JOOMLEAGUE_EXT_PERSON_PARENT_POSITIONS']) > 0) { $post['extended']['COM_JOOMLEAGUE_EXT_PERSON_PARENT_POSITIONS'] = implode(",", $post['extended']['COM_JOOMLEAGUE_EXT_PERSON_PARENT_POSITIONS']); } foreach ($coords as $key => $value) { $post['extended'][$key] = $value; } $post['latitude'] = $coords['latitude']; $post['longitude'] = $coords['longitude']; if ($model->store($post)) { $msg = JText::_('COM_JOOMLEAGUE_ADMIN_PERSON_CTRL_SAVED'); if (JRequest::getVar('assignperson')) { // diddipoeler // wenn man im nächsten model mit einem array arbeitet // sollte man auch ein array übergeben $pid = array(); $pid[0] = $model->getDbo()->insertid(); $project_team_id = JRequest::getVar('team_id', 0, 'post', 'int'); $model = $this->getModel('teamplayers'); if ($model->storeassigned($pid, $project_team_id)) { $msg .= ' - ' . JText::_('COM_JOOMLEAGUE_ADMIN_PERSON_CTRL_PERSON_ASSIGNED'); } else { $msg .= ' - ' . JText::_('COM_JOOMLEAGUE_ADMIN_PERSON_CTRL_ERROR_PERSON_ASSIGNED') . $model->getError(); } $model = $this->getModel('person'); } } else { $msg = JText::_('COM_JOOMLEAGUE_ADMIN_PERSON_CTRL_ERROR_SAVE') . $model->getError(); } // Check the table in so it can be edited.... we are done with it anyway $model->checkin(); if ($this->getTask() == 'save') { $link = 'index.php?option=com_joomleague&view=persons'; } else { $link = 'index.php?option=com_joomleague&task=person.edit&cid=' . $pid; } #echo $msg; //-------extra fields-----------// if (isset($post['extraf']) && count($post['extraf'])) { for ($p = 0; $p < count($post['extraf']); $p++) { $tbl = JTable::getInstance("jlextuserextrafieldvalue", "Table"); // extra feld ist schon vorhanden if ($post['extra_value_id'][$p]) { $result = $post['extra_value_id'][$p]; $tbl->load($result); $tbl->field_id = $post['extra_id'][$p]; $tbl->jl_id = $post['id']; $tbl->fieldvalue = $post['extraf'][$p]; } else { $tbl->field_id = $post['extra_id'][$p]; $tbl->jl_id = $post['id']; $tbl->fieldvalue = $post['extraf'][$p]; } if (!$tbl->store()) { } } } $this->setRedirect($link, $msg); }
function save() { $mainframe = JFactory::getApplication(); // Check for request forgeries JRequest::checkToken() or die('COM_JOOMLEAGUE_GLOBAL_INVALID_TOKEN'); $msg = ''; $address_parts = array(); $post = JRequest::get('post'); //$mainframe->enqueueMessage(JText::_('post -> '.'<pre>'.print_r($post,true).'</pre>' ),''); $cid = JRequest::getVar('cid', array(0), 'post', 'array'); $post['id'] = (int) $cid[0]; $model = $this->getModel('club'); if (!empty($post['address'])) { $address_parts[] = $post['address']; } if (!empty($post['state'])) { $address_parts[] = $post['state']; } if (!empty($post['location'])) { if (!empty($post['zipcode'])) { $address_parts[] = $post['zipcode'] . ' ' . $post['location']; } else { $address_parts[] = $post['location']; } } if (!empty($post['country'])) { $address_parts[] = Countries::getShortCountryName($post['country']); } $address = implode(', ', $address_parts); $coords = $model->resolveLocation($address); //$mainframe->enqueueMessage(JText::_('coords -> '.'<pre>'.print_r($coords,true).'</pre>' ),''); foreach ($coords as $key => $value) { $post['extended'][$key] = $value; } $post['latitude'] = $coords['latitude']; $post['longitude'] = $coords['longitude']; if (isset($post['merge_teams'])) { if (count($post['merge_teams']) > 0) { $temp = implode(",", $post['merge_teams']); } else { $temp = ''; } $post['merge_teams'] = $temp; } else { $post['merge_teams'] = ''; } //$mainframe->enqueueMessage(JText::_('post -> '.'<pre>'.print_r($post,true).'</pre>' ),''); if ($model->store($post)) { $msg = JText::_('COM_JOOMLEAGUE_ADMIN_CLUB_CTRL_SAVED'); $createTeam = JRequest::getVar('createTeam'); if ($createTeam) { $team_name = JRequest::getVar('name'); $team_short_name = strtoupper(substr(ereg_replace("[^a-zA-Z]", "", $team_name), 0, 3)); $teammodel = $this->getModel('team'); $tpost['id'] = "0"; $tpost['name'] = $team_name; $tpost['short_name'] = $team_short_name; $tpost['club_id'] = $teammodel->getDbo()->insertid(); $teammodel->store($tpost); } $type = 'message'; } else { $msg = JText::_('COM_JOOMLEAGUE_ADMIN_CLUB_CTRL_ERROR_SAVE') . $model->getError(); $type = 'error'; } // Check the table in so it can be edited.... we are done with it anyway $model->checkin(); /* if ($this->getTask()=='save') { $link='index.php?option=com_joomleague&view=editclub'; } else { $link='index.php?option=com_joomleague&view=editclub&cid='.$post['id']; } */ //$link = JoomleagueHelperRoute::getClubInfoRoute( $project_id, $post['id'] ); //$this->setRedirect($link,$msg); $this->setRedirect('index.php?option=com_joomleague&close=' . JRequest::getString('close', 0) . '&tmpl=component&view=editclub&cid=' . $post['id'], $msg, $type); }
function display($tpl = null) { // Get a refrence of the page instance in joomla $document = JFactory::getDocument(); $uri = JFactory::getURI(); $version = urlencode(JoomleagueHelper::getVersion()); $css = 'components/com_joomleague/assets/css/tabs.css?v=' . $version; $document->addStyleSheet($css); $model = $this->getModel(); $config = $model->getTemplateConfig($this->getName()); $project = $model->getProject(); $rounds = JoomleagueHelper::getRoundsOptions($project->id, 'ASC', true); $model->setProjectId($project->id); $map_config = $model->getMapConfig(); $this->assignRef('mapconfig', $map_config); // Loads the project-template -settings for the GoogleMap $this->assignRef('model', $model); $this->assignRef('project', $project); $extended = $this->getExtended($this->project->extended, 'project'); $this->assignRef('extended', $extended); $this->assignRef('overallconfig', $model->getOverallConfig()); $this->assignRef('tableconfig', $config); $this->assignRef('config', $config); if ($this->overallconfig['show_project_rss_feed'] == 1) { $mod_name = "mod_jw_srfr"; $rssfeeditems = ''; $rssfeedlink = $this->extended->getValue('COM_JOOMLEAGUE_PROJECT_RSS_FEED'); if ($rssfeedlink) { $this->assignRef('rssfeeditems', $model->getRssFeeds($rssfeedlink, $this->overallconfig['rssitems'])); } else { $this->assignRef('rssfeeditems', $rssfeeditems); } } if ($this->config['show_half_of_season'] == 1) { $model->part = 1; $model->from = 0; $model->to = 0; unset($model->currentRanking); unset($model->previousRanking); $model->computeRanking(); $this->assignRef('firstRank', $model->currentRanking); $model->part = 2; $model->from = 0; $model->to = 0; unset($model->currentRanking); unset($model->previousRanking); $model->computeRanking(); $this->assignRef('secondRank', $model->currentRanking); $model->part = 0; unset($model->currentRanking); unset($model->previousRanking); } $model->computeRanking(); $this->assignRef('round', $model->round); $this->assignRef('part', $model->part); $this->assignRef('rounds', $rounds); $this->assignRef('divisions', $model->getDivisions()); $this->assignRef('type', $model->type); $this->assignRef('from', $model->from); $this->assignRef('to', $model->to); $this->assignRef('divLevel', $model->divLevel); $this->assignRef('currentRanking', $model->currentRanking); $this->assignRef('previousRanking', $model->previousRanking); $this->assignRef('homeRank', $model->homeRank); $this->assignRef('awayRank', $model->awayRank); $this->assignRef('current_round', $model->current_round); $this->assignRef('teams', $model->getTeamsIndexedByPtid()); $no_ranking_reason = ''; if ($this->config['show_notes'] == 1) { $ranking_reason = array(); foreach ($this->teams as $teams) { if ($teams->start_points) { if ($teams->start_points < 0) { $color = "red"; } else { $color = "green"; } $ranking_reason[$teams->name] = '<font color="' . $color . '">' . $teams->name . ': ' . $teams->start_points . ' Punkte Grund: ' . $teams->reason . '</font>'; } } } if (sizeof($ranking_reason) > 0) { $this->assign('ranking_notes', implode(", ", $ranking_reason)); } else { $this->assign('ranking_notes', $no_ranking_reason); } $this->assignRef('previousgames', $model->getPreviousGames()); $this->assign('action', $uri->toString()); $frommatchday[] = JHTML::_('select.option', '0', JText::_('COM_JOOMLEAGUE_RANKING_FROM_MATCHDAY')); $frommatchday = array_merge($frommatchday, $rounds); $lists['frommatchday'] = $frommatchday; $tomatchday[] = JHTML::_('select.option', '0', JText::_('COM_JOOMLEAGUE_RANKING_TO_MATCHDAY')); $tomatchday = array_merge($tomatchday, $rounds); $lists['tomatchday'] = $tomatchday; $opp_arr = array(); $opp_arr[] = JHTML::_('select.option', "0", JText::_('COM_JOOMLEAGUE_RANKING_FULL_RANKING')); $opp_arr[] = JHTML::_('select.option', "1", JText::_('COM_JOOMLEAGUE_RANKING_HOME_RANKING')); $opp_arr[] = JHTML::_('select.option', "2", JText::_('COM_JOOMLEAGUE_RANKING_AWAY_RANKING')); $lists['type'] = $opp_arr; $this->assignRef('lists', $lists); if (!isset($config['colors'])) { $config['colors'] = ""; } $this->assignRef('colors', $model->getColors($config['colors'])); //$this->assignRef('result', $model->getTeamInfo()); // $this->assignRef( 'pageNav', $model->pagenav( "ranking", count( $rounds ), $sr->to ) ); // $this->assignRef( 'pageNav2', $model->pagenav2( "ranking", count( $rounds ), $sr->to ) ); // diddipoeler $mdlTeams = JModel::getInstance("Teams", "JoomleagueModel"); $this->assignRef('allteams', $mdlTeams->getTeams()); if ($this->config['show_ranking_maps'] == 1) { $this->geo = new simpleGMapGeocoder(); $this->geo->genkml3($project->id, $this->allteams); // $this->map = new simpleGMapAPI(); // $this->geo = new simpleGMapGeocoder(); // $this->map->setWidth($this->mapconfig['width']); // $this->map->setHeight($this->mapconfig['height']); // $this->map->setZoomLevel($this->mapconfig['map_zoom']); // $this->map->setMapType($this->mapconfig['default_map_type']); // $this->map->setBackgroundColor('#d0d0d0'); // $this->map->setMapDraggable(true); // $this->map->setDoubleclickZoom(false); // $this->map->setScrollwheelZoom(true); // $this->map->showDefaultUI(false); // $this->map->showMapTypeControl(true, 'DROPDOWN_MENU'); // $this->map->showNavigationControl(true, 'DEFAULT'); // $this->map->showScaleControl(true); // $this->map->showStreetViewControl(true); // $this->map->setInfoWindowBehaviour('SINGLE_CLOSE_ON_MAPCLICK'); // $this->map->setInfoWindowTrigger('CLICK'); //echo 'allteams <br><pre>'.print_r($this->allteams,true).'</pre><br>'; foreach ($this->allteams as $row) { $address_parts = array(); if (!empty($row->club_address)) { $address_parts[] = $row->club_address; } if (!empty($row->club_state)) { $address_parts[] = $row->club_state; } if (!empty($row->club_location)) { if (!empty($row->club_zipcode)) { $address_parts[] = $row->club_zipcode . ' ' . $row->club_location; } else { $address_parts[] = $row->club_location; } } if (!empty($row->club_country)) { $address_parts[] = Countries::getShortCountryName($row->club_country); } $row->address_string = implode(', ', $address_parts); // $this->map->addMarkerByAddress($row->address_string, $row->team_name, '"<a href="'.$row->club_www.'" target="_blank">'.$row->club_www.'</a>"', "http://maps.google.com/mapfiles/kml/pal2/icon49.png"); /* $paramsdata = $row->club_extended; $paramsdefs = JLG_PATH_ADMIN . DS . 'assets' . DS . 'extended' . DS . 'club.xml'; $extended = new JLGExtraParams( $paramsdata, $paramsdefs ); foreach ( $extended->getGroups() as $key => $groups ) { $lat = $extended->get('JL_ADMINISTRATIVE_AREA_LEVEL_1_LATITUDE'); $lng = $extended->get('JL_ADMINISTRATIVE_AREA_LEVEL_1_LONGITUDE'); } if ( $lat && $lng ) { $adressecountry_flag = Countries::getCountryFlag($row->club_country); //echo JURI::root().'<br>'; if ( $row->logo_big ) { $path = JURI::root().$row->logo_big; } else { $path = JURI::root().'media/com_joomleague/placeholders/'.'placeholder_150.png'; } //echo $path.'<br>'; $this->map->addMarker($lat, $lng, $row->club_name, $adressecountry_flag.' '.$row->address_string.'<br>',$path); } */ } // $document->addScript($this->map->JLprintGMapsJS()); // $document->addScriptDeclaration($this->map->JLshowMap(false)); } $this->assign('show_debug_info', JComponentHelper::getParams('com_joomleague')->get('show_debug_info', 0)); // Set page title $pageTitle = JText::_('COM_JOOMLEAGUE_RANKING_PAGE_TITLE'); if (isset($this->project->name)) { $pageTitle .= ': ' . $this->project->name; } $document->setTitle($pageTitle); parent::display($tpl); }
function genkml3($project_id, $allteams) { $type = 'ranking'; /* echo 'genkml3 project_id<br><pre>'; print_r($project_id); echo '</pre><br>'; echo 'genkml3 allteams<br><pre>'; print_r($allteams); echo '</pre><br>'; */ foreach ($allteams as $row) { $address_parts = array(); if (!empty($row->club_address)) { $address_parts[] = $row->club_address; } if (!empty($row->club_state)) { $address_parts[] = $row->club_state; } if (!empty($row->club_location)) { if (!empty($row->club_zipcode)) { $address_parts[] = $row->club_zipcode . ' ' . $row->club_location; } else { $address_parts[] = $row->club_location; } } if (!empty($row->club_country)) { $address_parts[] = Countries::getShortCountryName($row->club_country); } $row->address_string = implode(', ', $address_parts); $row->type = 'bar'; $coords = $this->JLgetGeoCoords($row->address_string); if ($coords["status"] == 'OK') { $row->lat = $coords["results"][0]["geometry"]["location"]["lat"]; $row->lng = $coords["results"][0]["geometry"]["location"]["lng"]; } else { $osm = $this->getOSMGeoCoords($row->address_string); if ($osm) { $row->lat = $osm['lat']; $row->lng = $osm['lng']; } else { $row->lat = ''; $row->lng = ''; } } /* echo 'genkml3 allteams<br><pre>'; print_r($coords); echo '</pre><br>'; */ } /* echo 'genkml3 allteams<br><pre>'; print_r($allteams); echo '</pre><br>'; */ $this->writekml3($allteams, $project_id, $type); }
function save() { $mainframe = JFactory::getApplication(); // Check for request forgeries JRequest::checkToken() or die('COM_JOOMLEAGUE_GLOBAL_INVALID_TOKEN'); $msg = ''; $address_parts = array(); $post = JRequest::get('post'); // wurden jahre mitgegeben ? $founded_year = date('Y', strtotime($post['founded'])); $dissolved_year = date('Y', strtotime($post['dissolved'])); if ($founded_year != '0000') { $post['founded_year'] = $founded_year; } if ($dissolved_year != '0000') { $post['dissolved_year'] = $dissolved_year; } //$mainframe->enqueueMessage(JText::_('post -> '.'<pre>'.print_r($post,true).'</pre>' ),''); $cid = JRequest::getVar('cid', array(0), 'post', 'array'); $post['id'] = (int) $cid[0]; $model = $this->getModel('club'); if (!empty($post['address'])) { $address_parts[] = $post['address']; } if (!empty($post['state'])) { $address_parts[] = $post['state']; } if (!empty($post['location'])) { if (!empty($post['zipcode'])) { $address_parts[] = $post['zipcode'] . ' ' . $post['location']; } else { $address_parts[] = $post['location']; } } if (!empty($post['country'])) { $address_parts[] = Countries::getShortCountryName($post['country']); } $address = implode(', ', $address_parts); $coords = $model->resolveLocation($address); //$mainframe->enqueueMessage(JText::_('coords -> '.'<pre>'.print_r($coords,true).'</pre>' ),''); foreach ($coords as $key => $value) { $post['extended'][$key] = $value; } $post['latitude'] = $coords['latitude']; $post['longitude'] = $coords['longitude']; if (isset($post['merge_teams'])) { if (count($post['merge_teams']) > 0) { $temp = implode(",", $post['merge_teams']); } else { $temp = ''; } $post['merge_teams'] = $temp; } else { $post['merge_teams'] = ''; } //$mainframe->enqueueMessage(JText::_('post -> '.'<pre>'.print_r($post,true).'</pre>' ),''); if ($model->store($post)) { $msg = JText::_('COM_JOOMLEAGUE_ADMIN_CLUB_CTRL_SAVED'); $createTeam = JRequest::getVar('createTeam'); if ($createTeam) { $team_name = JRequest::getVar('name'); $team_short_name = strtoupper(substr(ereg_replace("[^a-zA-Z]", "", $team_name), 0, 3)); $teammodel = $this->getModel('team'); $tpost['id'] = "0"; $tpost['name'] = $team_name; $tpost['short_name'] = $team_short_name; $tpost['club_id'] = $teammodel->getDbo()->insertid(); $teammodel->store($tpost); } } else { $msg = JText::_('COM_JOOMLEAGUE_ADMIN_CLUB_CTRL_ERROR_SAVE') . $model->getError(); } // Check the table in so it can be edited.... we are done with it anyway $model->checkin(); if ($this->getTask() == 'save') { $link = 'index.php?option=com_joomleague&view=clubs&club.display'; } else { $link = 'index.php?option=com_joomleague&task=club.edit&cid[]=' . $post['id']; } //-------extra fields-----------// if (isset($post['extraf']) && count($post['extraf'])) { for ($p = 0; $p < count($post['extraf']); $p++) { $tbl = JTable::getInstance("jlextuserextrafieldvalue", "Table"); // extra feld ist schon vorhanden if ($post['extra_value_id'][$p]) { $result = $post['extra_value_id'][$p]; $tbl->load($result); $tbl->field_id = $post['extra_id'][$p]; $tbl->jl_id = $post['id']; $tbl->fieldvalue = $post['extraf'][$p]; } else { $tbl->field_id = $post['extra_id'][$p]; $tbl->jl_id = $post['id']; $tbl->fieldvalue = $post['extraf'][$p]; } if (!$tbl->store()) { } } } $this->setRedirect($link, $msg); }