public function actionManage() { $model = new Sport('search'); $model->unsetAttributes(); if (isset($_GET['Sport'])) { $model->attributes = $_GET['Sport']; } $this->render('manage', array('model' => $model)); }
public function getListSport() { $q = $this->_db->query('SELECT id_sport, nom_sport FROM sport ORDER BY nom_sport'); while ($donnees = $q->fetch(PDO::FETCH_ASSOC)) { $sport = new Sport(); $sport->hydrate($donnees); $tab_sport[] = $sport; } return $tab_sport; }
public static function saveUser(Sport $user) { $conn = connection::getConnectionObject(); $con = $conn->getConnection(); $sql = $con->prepare("INSERT INTO AppUser VALUES (?,?,?,?)"); $userid = $user->getUserId(); $username = $user->getUsername(); $roll = $user->getRole(); $passsword = $user->getPassword(); $sql->bind_param("ssss", $userid, $username, $roll, $passsword); if ($sql->execute() == TRUE) { echo "New record created successfully (sport added)"; } else { //echo "Error in adding sport: " . $sql . "<br>" ; echo "Error in adding sport:"; } }
/** * Run the database seeds. * * @return void */ public function run() { $sport = new Sport(); $sport->sport = 'Football'; $sport->save(); $sport = new Sport(); $sport->sport = 'Soccer'; $sport->save(); $sport = new Sport(); $sport->sport = 'Quidditch'; $sport->save(); $sport = new Sport(); $sport->sport = 'Bocce Ball'; $sport->save(); $sport = new Sport(); $sport->sport = 'Rugby'; $sport->save(); $sport = new Sport(); $sport->sport = 'Disc Golf'; $sport->save(); }
public function run() { DB::table('sports')->delete(); Sport::create(array('description' => 'Voleibol')); Sport::create(array('description' => 'Clavados')); Sport::create(array('description' => 'Ciclismo')); Sport::create(array('description' => 'Tiro con arco')); Sport::create(array('description' => 'Esgrima')); Sport::create(array('description' => 'Canotaje')); Sport::create(array('description' => 'Tiro deportivo')); Sport::create(array('description' => 'Bádminton')); Sport::create(array('description' => 'Natación')); Sport::create(array('description' => 'Tae Kwon Do')); Sport::create(array('description' => 'Judo')); Sport::create(array('description' => 'Otro')); }
public function showWelcome() { $sports = Sport::all(); $cities = Location::all(); /* pull list of cities for events from events table city column */ $sportDropdown = []; $sportDropdown[-1] = 'Select a Sport'; $cityDropdown = []; $cityDropdown[-1] = 'Select a City'; foreach ($sports as $sport) { $sportDropdown[$sport->id] = $sport->sport; } foreach ($cities as $city) { $cityDropdown[$city->id] = $city->city; } return View::make('home')->with('sportDropdown', $sportDropdown)->with('cityDropdown', $cityDropdown); }
public function setSportsListAttribute($value) { $sportIds = []; $sports = explode(',', $value); foreach ($sports as $sportName) { /* firstOrCreate uses first instance or creates a new instantiation - stops sports table from duplicating sport names*/ $sport = Sport::firstOrCreate(array('sport' => $sportName)); $sportIds[] = $sport->id; if (!$sport->id) { dd($sport); } /* sync is a Laravel method to attach related models; sync accepts array of ids to be placed on pivot table only the ids in the array will be on the intermediate table sport_user pivot table*/ } $this->sports()->sync($sportIds); }
/** * Run the database seeds. * * @return void */ public function run() { $location = Location::firstOrFail(); $user = User::firstOrFail(); $sport = Sport::all(); $event = new GameEvent(); $event->sport_id = 2; $event->event_name = 'Fútbol Game'; $event->start_time = 'Monday, Oct. 5, 2015 1:00 pm'; $event->end_time = 'Monday, Oct. 5, 2015 4:00 pm'; $event->location_id = $location->id; $event->gender = 'Co-Ed'; $event->skill_level = 'Intermediate'; $event->amount = 2.0; $event->organizer_id = 1; $event->event_image = 'http://lorempixel.com/200/200/sports/6/'; $event->description = 'testing 123'; $event->save(); }
/** * test grabbing all Player Statistics **/ public function testGetAllValidPlayerStatistics() { // count the number of rows and save it for later $numRows = $this->getConnection()->getRowCount("playerStatistic"); // create a new Player Statistic and insert to into mySQL $playerStatistic = new PlayerStatistic(null, $this->profile->getProfileId(), $this->VALID_TWEETCONTENT, $this->VALID_TWEETDATE); $playerStatistic->insert($this->getPDO()); // grab the data from mySQL and enforce the fields match our expectations $results = PlayerStatistic::getAllPlayerStatistics($this->getPDO()); $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("playerStatistic")); $this->assertCount(1, $results); $this->assertContainsOnlyInstancesOf("Edu\\Cnm\\Sprots\\Public_html\\Php\\Classes\\PlayerStatistic", $results); // grab the result from the array and validate it $pdoPlayerStatistic = $results[0]; $this->assertEquals($pdoPlayerStatistic->getSportId(), $this->sport->getSportId()); $this->assertEquals($pdoPlayerStatistic->getGame(), $this->VALID_GAME); $this->assertEquals($pdoPlayerStatistic->getPlayer(), $this->VALID_TWEETDATE); $this->assertEquals($pdoPlayerStatistic->getPlayerStatistic(), $this->VALID_TWEETDATE); $this->assertEquals($pdoPlayerStatistic->getStatistic(), $this->VALID_TWEETDATE); }
/** * Obtiene la información de un perfil * * @param Profile $profile perfil del cual obtener los datos * @return array arreglo que contiene la información del perfil */ public static function getProfileData($profile) { $profile->load('city.state.cities', 'city.sports', 'profileValues.field.values.parent', 'profileValues.value'); $roles = Role::all()->lists('description', 'idRole'); $states = State::all()->lists('description', 'idState'); $cities = $profile->city->state->cities->lists('description', 'idCity'); $sports = $profile->city->sports->filter(function ($sport) { return $sport->description != "Otro"; }); $sports->add(Sport::where("description", "=", "Otro")->first()); $sports = $sports->lists('description', 'idSport'); $fields = array(); foreach ($profile->profileValues as $profileValue) { $parent = $profileValue->value->parent->first(); self::solveParentValue($fields, $profileValue->field, $parent); self::addField($fields, $profileValue->field, $profileValue->value, $parent); } $data = array('roles' => $roles, 'states' => $states, 'cities' => $cities, 'sports' => $sports, 'fields' => $fields, 'profile' => $profile); return $data; }
echo "Something went wrong: " . $typeError->getMessage() . PHP_EOL; } //downloader for players NFL try { $seasoning = ["2015", "2016"]; foreach ($seasoning as $season) { $pdo = connectToEncryptedMySQL("/etc/apache2/capstone-mysql/sprots.ini"); $config = readConfig("/etc/apache2/capstone-mysql/sprots.ini"); $apiKeys = json_decode($config["fantasyData"]); $opts = array('http' => array('method' => "GET", 'header' => "Content-Type: application/json\r\nOcp-Apim-Subscription-key: " . $apiKeys->NFL, 'content' => "{body}")); $context = stream_context_create($opts); //response from Api $response = file_get_contents("https://api.fantasydata.net/nfl/v2/JSON/Players/{$season}", false, $context); $data = json_decode($response); $stats = ["PlayerID ", "Team", "Number ", "FirstName ", "LastName", "Status ", "Height ", "Weight", "BirthDate ", "College ", "Experience ", "Active ", "PositionCategory ", "Name", "Age ", "ExperienceString ", "BirthDateString", "PhotoUrl ", "ByeWeek ", "UpcomingGameOpponent ", "UpcomingGameWeek", "ShortName ", "AverageDraftPosition ", "DepthPositionCategory ", "DepthPosition ", "DepthOrder ", "DepthDisplayOrder ", "CurrentTeam ", "HeightFeet ", "UpcomingOpponentRank ", "UpcomingOpponentPositionRank ", "CurrentStatus"]; $sport = Sport::getSportBySportLeague($pdo, "NFL"); foreach ($data as $player) { $team = Team::getTeamByTeamApiId($pdo, $player->TeamID); if ($team !== null) { $playerToInsert = new Player(null, $player->PlayerID, $team->getTeamId(), $sport->getSportId(), $player->FirstName . " " . $player->LastName); $playerToInsert->insert($pdo); $game = Game::getGameByGameFirstTeamId($pdo, $team->getTeamId()); if ($game === null) { $game = Game::getGameByGameSecondTeamId($pdo, $team->getTeamId()); } //get player statistic by game //response from api for ($week = 1; $week <= 21; $week++) { $response = file_get_contents("https://api.fantasydata.net/nfl/v2/JSON/PlayerGameStatsByPlayerID/{$season}/{$week}/{$player->PlayerID}", false, $context); $statisticData = json_decode($response); //adds statistic to database
$this->Dataset->setActivityData($short); $this->Dataset->displayShortLink(); } echo '</td> <td class="l as-small-as-possible">' . Dataset::getDateString($day['date']) . '</td> <td colspan="' . ($this->Dataset->cols() + $this->showPublicLink) . '"></td> </tr>'; } } echo '</tbody>'; echo '<tbody>'; // Z U S A M M E N F A S S U N G $WhereNotPrivate = FrontendShared::$IS_SHOWN && !\Runalyze\Configuration::Privacy()->showPrivateActivitiesInList() ? 'AND is_public=1' : ''; $sports = DB::getInstance()->query('SELECT `id`, `time`, `sportid`, SUM(1) as `num` FROM `' . PREFIX . 'training` WHERE `time` BETWEEN ' . ($this->timestamp_start - 10) . ' AND ' . ($this->timestamp_end - 10) . ' AND accountid = ' . SessionAccountHandler::getId() . ' ' . $WhereNotPrivate . ' GROUP BY `sportid` ORDER BY `num` DESC')->fetchAll(); foreach ($sports as $i => $sportdata) { $Sport = new Sport($sportdata['sportid']); echo '<tr class="r no-zebra"> <td colspan="' . $this->additionalColumns . '"> <small>' . $sportdata['num'] . 'x</small> ' . $Sport->name() . ' </td>'; $this->Dataset->loadGroupOfTrainings($sportdata['sportid'], $this->timestamp_start, $this->timestamp_end); $this->Dataset->displayTableColumns(); echo ' </tr>'; } ?> </tbody> </table> </div> </div>
public function getFields($idSport) { if (Request::ajax()) { $fields = Sport::find($idSport)->fields; $fields->load('values.parent'); return $fields; } }
<?php require_once 'imports.php'; $standard = new StandardEngine(1300); $saloon = new Saloon($standard); $ferarri = new Sport(new TurboEngine(3000), Vehicle::RED); ?> <html> <body> <p><?php echo $standard; ?> </p> <p><?php echo $saloon; ?> </p> <p><?php echo $ferarri; ?> </p> <p><?php echo $ferarri->getColour(); ?> </p> </body> </html>
<?php require_once 'imports.php'; $myCar = new Sport(new StandardEngine(2000)); $myCar->setSpeed(20); $myCar->setSpeed(40); // Swithing on sports mode gearbox... $myCar->setGearboxStrategy(new SportGearboxStrategy()); $myCar->setSpeed(20); $myCar->setSpeed(40);
/** * Display the analysis */ private function displayAnalysis() { if (empty($this->AnalysisData)) { echo HTML::info(__('There is no data for this sport.')); } foreach ($this->AnalysisData as $i => $Data) { if (!is_array($Data)) { continue; } $this->printTableStart($Data['name']); if (empty($Data['foreach'])) { echo '<tr class="c">' . HTML::emptyTD($this->colspan, '<em>' . __('No data available.') . '</em>') . '</tr>'; } else { foreach ($Data['foreach'] as $i => $Each) { echo '<tr><td class="c b">' . $Each['name'] . '</td>'; for ($t = $this->timer_start; $t <= $this->timer_end; $t++) { if (isset($Data['array'][$Each['id']][$t])) { $num = $Data['array'][$Each['id']][$t]['num']; $dist = $Data['array'][$Each['id']][$t]['distance']; $time = $Data['array'][$Each['id']][$t]['s']; if ($this->dat == 'km') { $percent = $Data['array']['timer_sum_km'][$t] > 0 ? round(100 * $dist / $Data['array']['timer_sum_km'][$t], 1) : 0; } else { $percent = $Data['array']['timer_sum_s'][$t] > 0 ? round(100 * $time / $Data['array']['timer_sum_s'][$t], 1) : 0; } $this->displayTDfor($num, $time, $dist, $percent); } else { echo HTML::emptyTD(); } } if (isset($Data['array']['id_sum_s'][$Each['id']])) { $num = $Data['array']['id_sum_num'][$Each['id']]; $time = $Data['array']['id_sum_s'][$Each['id']]; $dist = $Data['array']['id_sum_km'][$Each['id']]; if ($this->dat == 'km') { $percent = $Data['array']['all_sum_km'] > 0 ? round(100 * $dist / $Data['array']['all_sum_km'], 1) : 0; } else { $percent = $Data['array']['all_sum_s'] > 0 ? round(100 * $time / $Data['array']['all_sum_s'], 1) : 0; } $this->displayTDfor($num, $time, $dist, $percent); } else { echo HTML::emptyTD(); } echo '</tr>'; } if ($i == count($Data['foreach']) - 1) { echo '<tr class="top-spacer no-zebra"><td class="c b">' . __('Total') . '</td>'; for ($t = $this->timer_start; $t <= $this->timer_end; $t++) { if (isset($Data['array']['timer_sum_km'][$t])) { if ($this->Sport->usesDistance() && $this->dat != 's') { echo '<td>' . Distance::format($Data['array']['timer_sum_km'][$t], false, 0) . '</td>'; } else { echo '<td>' . Duration::format($Data['array']['timer_sum_s'][$t]) . '</td>'; } } else { echo HTML::emptyTD(); } } if ($this->Sport->usesDistance() && $this->dat != 's') { echo '<td>' . Distance::format($Data['array']['all_sum_km'], false, 0) . '</td></tr>'; } else { echo '<td>' . Duration::format($Data['array']['all_sum_s']) . '</td></tr>'; } } } $this->printTableEnd(); } }
/** * Add sport and year (if set) to header */ protected function setHeaderWithSportAndYear() { $HeaderParts = array(); if ($this->sportid > 0 && $this->ShowSportsNavigation) { $Sport = new Sport($this->sportid); $HeaderParts[] = $Sport->name(); } if ($this->ShowYearsNavigation) { $HeaderParts[] = $this->getYearString(); } if (!empty($HeaderParts)) { $this->setHeader($this->name() . ': ' . implode(', ', $HeaderParts)); } }
/** * Show the form for editing the specified gameevent. * * @param int $id * @return Response */ public function edit($id) { $event = GameEvent::find($id); $sports = Sport::all(); $locations = Location::all(); if (!$event) { App::abort(404); } if (!Auth::check()) { return Redirect::action('UsersController@doLogin'); } elseif (Auth::id() == $event->organizer_id || Auth::user()->role == 'admin') { $dropdownL = []; $dropdownL[-1] = 'Add new address'; foreach ($locations as $location) { $dropdownL[$location->{$id}] = $location->name_of_location; } $dropdownS = []; $dropdownS[-1] = 'Select Sport'; foreach ($sports as $sport) { $dropdownS[$sport->{$id}] = $sport->sport; } return View::make('game_events.edit')->with('dropdown', $dropdownL)->with('dropdownS', $dropdownS)->with('event', $event); } else { Session::flash('errorMessage', 'Access not authorized'); return Redirect::action('GameEventsController@index'); } }
/** * @param string $league * @param int $teamSportId */ function getTeams(string $league, int $teamSportId) { try { // grab the db connection $pdo = connectToEncryptedMySQL("/etc/apache2/capstone-mysql/sprots.ini"); $config = readConfig("/etc/apache2/capstone-mysql/sprots.ini"); $apiKeys = json_decode($config["fantasyData"]); $opts = array('http' => array('method' => "GET", 'header' => "Content-Type: application/json\r\nOcp-Apim-Subscription-key: " . $apiKeys->{$league}, 'content' => "{body}")); $context = stream_context_create($opts); // response from api $response = file_get_contents("https://api.fantasydata.net/{$league}/v2/JSON/teams", false, $context); $data = json_decode($response); // Places team in designated sport, and populates teams in team db with response from api $sport = Sport::getSportBySportLeague($pdo, $league); foreach ($data as $team) { $team = new Team(null, $sport->getSportId(), $team->TeamID, $team->City, $team->Name); $team->insert($pdo); // get team statistics by game $game = Game::getGameByGameFirstTeamId($pdo, $team->getTeamId()); if ($game === null) { $game = Game::getGameByGameSecondTeamId($pdo, $team->getTeamId()); if ($game === null) { continue; } } $gameDate = $game->getGameTime()->format("Y-m-d"); // response from api $response = file_get_contents("https://api.fantasydata.net/{$league}/v2/JSON/TeamGameStatsByDate/{$gameDate}"); $statisticData = json_decode($response); // adds statistics to database foreach ($GLOBALS['stats'] as $statisticName) { $statistic = Statistic::getStatisticByStatisticName($pdo, $statisticName); if ($statistic === null || $statistic->getSize() <= 0) { $statistic = new Statistic(null, $statisticName); $statistic->insert($pdo); } else { $statistic = $statistic[0]; } $statisticValue = null; if (empty($statisticData->{$statisticName}) === false) { $statisticValue = $statisticData->{$statisticName}; } if ($statisticValue !== null) { // $statisticValue = ""; $teamStatisticToInsert = new TeamStatistic($game->getGameId(), $team->getTeamId(), $statistic->getTeamStatisticStatisticId(), $statisticValue); $teamStatisticToInsert->insert($pdo); } else { echo "<p> team statistics isn't working </p>" . PHP_EOL; } } } } catch (Exception $exception) { echo "Something went wrong: " . $exception->getMessage() . PHP_EOL; } catch (TypeError $typeError) { echo "Something went wrong: " . $typeError->getMessage() . PHP_EOL; } }
public function getChartData() { $testId = Input::get('test'); $startDate = date('Y-m-d', strtotime(Input::get('startDate'))); $endDate = date('Y-m-d', strtotime(Input::get('endDate') . ' + 1 days')); $sportId = Input::get("sport"); $genderId = Input::get("gender"); $filteredTests = $this->getFilteredTests($testId, $startDate, $endDate, $sportId, $genderId); $test = $filteredTests['test']; $answeredTests = $filteredTests['answeredTests']; $ranges = $test->scales[0]->ranges; $scales = $test->scales; $responseData = array('cols' => array(), 'rows' => array()); // Inserción de columnas $responseData['cols'][] = $this->createColumn('Escalas', 'string'); $ranges = $test->scales[0]->ranges; foreach ($ranges as $range) { $label = 'Deportistas en: ' . $range->description . ' (' . $range->min . ', ' . $range->max . ')'; $responseData['cols'][] = $this->createColumn($label, 'number'); } // Preparación de datos de renglones $scalesResults = array(); foreach ($scales as $scale) { $rangesValues = array(); for ($i = 0; $i < $ranges->count(); $i++) { $rangesValues[] = 0; } $scalesResults[$scale->description] = $rangesValues; } // Cálculo de valores foreach ($answeredTests as $answeredTest) { $resultsByScale = $this->getResultsByScale($scales, $answeredTest->userAnswers); foreach ($resultsByScale as $resultByScale) { $scale = $resultByScale['scale']; $result = $resultByScale['result']; $rangeIndex = $this->getRangeIndex($ranges, $result); $scalesResults[$scale->description][$rangeIndex]++; } } // Inserción de renglones foreach ($scalesResults as $scaleName => $results) { $row = array(); $row[] = $scaleName; foreach ($results as $result) { $row[] = $result; } $responseData['rows'][] = $this->createRow($row); } // Preparar encabezado y subtítulos $title = $test->name; $date = 'De ' . Input::get('startDate') . ' a ' . Input::get('endDate'); $sport; $gender; if ($sportId != -1) { $sport = ' Deporte: ' . Sport::find($sportId)->description; } else { $sport = ' Deporte: Sin Especificar'; } if ($genderId != -1) { $gender = ' Género: ' . Gender::find($genderId)->description; } else { $gender = ' Género: Sin Especificar'; } return array('title' => $title, 'date' => $date, 'sport' => $sport, 'gender' => $gender, 'table' => $responseData); }
/** * @return bool */ protected function showsAverage() { return $this->Sport->isRunning() && $this->Analysis == self::ANALYSIS_DEFAULT; }
$title = safeText($_POST['title']); if ($title == "") { $err[] = "Není vyplněný nadpis!"; } elseif (strlen($title) > 255) { $err[] = "Příliš dlouhý nadpis!"; } else { $headline = $title; } $sportID = safeText($_POST['sport']); if ($sportID == "other") { $otherSport = safeText($_POST['otherSport']); if (strlen($title) > 255) { $err[] = "Příliš dlouhý název sportu!"; } else { $otherSport = trim(strtolower($otherSport)); $newSport = new Sport(); if ($newSport->checkSport($otherSport) == 0) { $sportID = $newSport->setNewSport($otherSport); } else { $sportID = $newSport->checkSport($otherSport); } } } if ($_POST['num_entry'] != 0) { $num_entry = safeText($_POST['num_entry']); } $entry = $_POST['entry']; if ($_POST['shared'] == 0) { $shared = safeText($_POST['submit']); } else { $shared = 1;
throw new InvalidArgumentException("id can not be empty or negative", 405); } //sanitize and trim other fields $sportId = filter_input(INPUT_GET, "sportId", FILTER_VALIDATE_INT); $sportLeague = filter_input(INPUT_GET, "sportLeague", FILTER_VALIDATE_INT); $sportName = filter_input(INPUT_GET, "sportName", FILTER_VALIDATE_INT); //get the Sport based on the given field if (empty($id) === false) { $sport = Sport::getSportBySportId($pdo, $id); $reply->data = $sport; } elseif (empty($teamId) === false) { $sport = Sport::getSportBySportLeague($pdo, $playerTeamId); $reply->date = $sport; } elseif (empty($sportId) === false) { $sport = Sport::getSportBySportName($pdo, $playerSportId); $reply->date = $sport; } else { $reply->data = Sport::getAllSportLeagues($pdo)->toArray(); } } catch (Exception $exception) { $reply->status = $exception->getCode(); $reply->message = $exception->getMessage(); } catch (TypeError $typeError) { $reply->status = $typeError->getCode(); $reply->message = $typeError->getMessage(); } header("Content-type: application/json"); if ($reply->data === null) { unset($reply->data); } echo json_encode($reply);