Skip to content

Commit

Permalink
troppi cambiamenti per elencarli
Browse files Browse the repository at this point in the history
nuova struttura sito
  • Loading branch information
fiste788 committed Dec 28, 2015
1 parent 0e3d045 commit 48fda68
Show file tree
Hide file tree
Showing 108 changed files with 2,989 additions and 2,219 deletions.
67 changes: 42 additions & 25 deletions app/controllers/ApplicationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Fantamanajer\Lib\Notify;
use Fantamanajer\Lib\QuickLinks;
use Fantamanajer\Models\Championship;
use Fantamanajer\Models\League;
use Fantamanajer\Models\Lineup;
use Fantamanajer\Models\Matchday;
Expand All @@ -30,7 +31,7 @@ abstract class ApplicationController extends BaseController {
* @var Season
*/
protected $currentSeason;

/**
*
* @var Matchday
Expand All @@ -43,31 +44,38 @@ abstract class ApplicationController extends BaseController {
*/
protected $currentLeague;

/**
*
* @var League
*/
protected $currentChampionship;

/**
*
* @var Notify[]
*/
protected $notification = array();

public function __construct(Request $request, Response $response) {
parent::__construct($request,$response);
parent::__construct($request, $response);
FirePHP::getInstance()->setEnabled($_SESSION['roles'] == 2);
FirePHP::getInstance()->setEnabled(true);
$this->templates['operation'] = new Savant3(array('template_path' => OPERATIONSDIR));
$this->templates['tabs'] = new Savant3(array('template_path' => TABSDIR));
$response->setHeader("X-UA-Compatible", "IE=edge");
}

public function notAuthorized() {
$this->setFlash(self::FLASH_NOTICE,"Non hai l'autorizzazione necessaria");
$this->redirectTo('squadre');
$this->setFlash(self::FLASH_NOTICE, "Non hai l'autorizzazione necessaria");
$this->redirectTo('home');
}

public function initialize() {
parent::initialize();
$this->notification = array();
$leagues = League::getList();
if (!is_null(Request::getRequest()->getParam('league_view',NULL))) {

if (!is_null(Request::getRequest()->getParam('league_view', NULL))) {
$_SESSION['league_view'] = Request::getRequest()->getParam('league_view');
}
if (isset($_SESSION['league_id'])) {
Expand All @@ -76,35 +84,39 @@ public function initialize() {
$this->currentSeason = Season::getCurrent();
$this->currentMatchday = Matchday::getCurrent();
$this->currentLeague = $leagues[$_SESSION['league_view']];
$this->currentChampionship = Championship::getById(1);
//$this->currentLeague = $leagues[1];
$endDate = Matchday::getTargetCountdown();
foreach ($this->templates as $savant) {
$savant->assign('endDate', date_parse($endDate->format("Y-m-d H:i:s")));
$savant->assign('timestamp', $endDate->getTimestamp());
$savant->assign('currentMatchday',$this->currentMatchday->getId());
$savant->assign('isSeasonEnded',$this->currentMatchday->isSeasonEnded());
$savant->assign('currentMatchday', $this->currentMatchday);
$savant->assign('isSeasonEnded', $this->currentMatchday->isSeasonEnded());
$savant->assign('leagues', $leagues);
$savant->assign('route',$this->route);
$savant->assign('route', $this->route);
$savant->assign('page', $this->page);
$savant->assign('router', $this->router);
$savant->assign('request',$this->request);
$savant->assign('request', $this->request);
}
$this->quickLinks = new QuickLinks($this->request,$this->router,$this->route);
$this->templates['navbar']->assign('entries',$this->pages);
$this->quickLinks = new QuickLinks($this->request, $this->router, $this->route);
$this->templates['navbar']->assign('entries', $this->pages);
$this->templates['header']->assign('entries', $this->pages);
$this->initializeNotification();
$this->templates['navbar']->assign('notification',$this->notification);
$this->templates['navbar']->assign('notification', $this->notification);
$this->templates['header']->assign('notification', $this->notification);
}

private function initializeNotification() {
if(!$this->currentMatchday->isSeasonEnded()) {
$lineup = Lineup::getFormazioneBySquadraAndGiornata($_SESSION['user_id'],$this->currentMatchday->getId());
if(empty($lineup)) {
$this->notification[] = new Notify(Notify::LEVEL_MEDIUM,'Non hai ancora impostato la formazione per questa giornata',$this->router->generate('lineup'));
if ($_SESSION['logged']) {
if (!$this->currentMatchday->isSeasonEnded()) {
$lineup = Lineup::getFormazioneBySquadraAndGiornata($_SESSION['user_id'], $this->currentMatchday->getId());
if (empty($lineup)) {
$this->notification[] = new Notify(Notify::LEVEL_MEDIUM, 'Non hai ancora impostato la formazione per questa giornata', $this->router->generate('lineup'));
}
}
}
if($_SESSION['logged']) {
$inactivePlayers = Member::getInactiveByTeam(User::getById($_SESSION['user_id'])->getTeam());
if(!empty($inactivePlayers) && count(Transfert::getTrasferimentiByIdSquadra($_SESSION['user_id'])) < $_SESSION['league_data']->number_transfert) {
$this->notification[] = new Notify(Notify::LEVEL_HIGH,'Un tuo giocatore non è più nella lista!',$this->router->generate('transfert_index'));
if (!empty($inactivePlayers) && count(Transfert::getTrasferimentiByIdSquadra($_SESSION['user_id'])) < $_SESSION['league_data']->number_transfert) {
$this->notification[] = new Notify(Notify::LEVEL_HIGH, 'Un tuo giocatore non è più nella lista!', $this->router->generate('transfert_index'));
}
}
}
Expand All @@ -113,15 +125,20 @@ public function fetchOperationTpl() {
$tpl = $this->controller . DS . $this->action . '.php';
return file_exists(OPERATIONSDIR . $tpl) ? $this->templates['operation']->fetch($this->controller . DS . $this->action . '.php') : "";
}

public function fetchTabsTpl() {
$tpl = $this->controller . DS . $this->action . '.php';
return file_exists(TABSDIR . $tpl) ? $this->templates['tabs']->fetch($this->controller . DS . $this->action . '.php') : "";
}

public function render($content = NULL) {
if(is_null($content)) {
$this->templates['layout']->assign("quickLinks",$this->quickLinks);
if (is_null($content)) {
$this->templates['layout']->assign("quickLinks", $this->quickLinks);
$this->fetched['operation'] = $this->fetchOperationTpl();
$this->fetched['tabs'] = $this->fetchTabsTpl();
$this->templates['header']->assign('tabs',$this->fetched['tabs']);
}
return parent::render($content);
}

}


71 changes: 71 additions & 0 deletions app/controllers/ArticlesController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

namespace Fantamanajer\Controllers;

use Fantamanajer\Models\Article;
use FirePHP;
use Lib\FormException;

class ArticlesController extends ApplicationController {

public function index() {
$articles = Article::getByChampionship($this->currentChampionship->getId());
$this->templates['content']->assign('articles', $articles);
}

public function team_index() {
$articles = Article::getByTeam($this->request->getParam('team_id'));
$this->templates['content']->assign('articles', $articles);
$this->view = 'index';
$this->noLayout = true;
}

public function build() {
$this->templates['content']->assign('article', new Article());
}

public function create() {
try {
$article = new Article();
$article->setTeamId($_SESSION['team']->id);
$article->setMatchday($this->currentMatchday);
$article->setCreatedAt('now');
$article->save();
$this->redirectTo("articles");
} catch(FormException $e) {
die($e->getMessage());
$this->setFlash(self::FLASH_NOTICE, $e->getMessage());
$this->renderAction("articles_new");
}

}

public function edit() {
$article = Article::getById($this->route['params']['id']);
FirePHP::getInstance()->log($article);
if (($article) == FALSE) {
$this->send404();
}
$this->templates['content']->assign('article', $article);
}

public function update() {
try {
$article = Article::getById($this->route['params']['id']);
$article->save();
$this->setFlash(self::FLASH_SUCCESS, "Modificato con successo");
$this->redirectTo("articles");
} catch(FormException $e) {
$this->setFlash(self::FLASH_NOTICE, $e->getMessage());
$this->renderAction("articles");
}
}

public function delete() {
$article = Article::getById($this->route['params']['id']);
$article->delete();
$this->redirectTo("articles");
}
}


68 changes: 0 additions & 68 deletions app/controllers/ArticoloController.php

This file was deleted.

40 changes: 0 additions & 40 deletions app/controllers/ClubController.php

This file was deleted.

43 changes: 43 additions & 0 deletions app/controllers/ClubsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Fantamanajer\Controllers;
use \Fantamanajer\Models as Models;

class ClubsController extends ApplicationController {

public function index() {
$this->templates['content']->assign('clubs',Models\Club::getBySeason($this->currentSeason));
}

public function show() {
if (($club = Models\View\ClubStats::getById($this->route['params']['id'])) == FALSE) {
Request::send404();
}

$clubs = Models\Club::getList();

$this->templates['header']->assign('title',$club->getName());
$this->quickLinks->set('id',$clubs,"");
$members = Models\View\MemberStats::getByField('club_id',$club->id);
$this->templates['content']->assign('members',$members);
$this->templates['content']->assign('club',$club);
$this->templates['operation']->assign('clubs',$clubs);
}

public function probabiliFormazioni() {
$clubs = Models\Club::getList();
$newClub = array();
foreach ($clubs as $club) {
$newClub[strtolower($club->nome)] = $club->id;
}

$this->templates['content']->assign('elencoClub', $newClub);
}

public function probabiliFormazioni_html() {
$url = "http://www.gazzetta.it/Calcio/prob_form/";
echo utf8_encode(\Fantamanajer\Lib\FileSystem::contenutoCurl($url));
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
use Suin\RSSWriter\Feed;
use Suin\RSSWriter\Item;

class EventoController extends ApplicationController {
class EventsController extends ApplicationController {

public function index() {
$eventi = Evento::getEventi($_SESSION['legaView'], $this->request->getParam('evento'), 0, 25);
$eventi = Events::getEventi($_SESSION['legaView'], $this->request->getParam('evento'), 0, 25);
FirePHP::getInstance()->log($this->request->getParam('evento'));
$this->templates['content']->assign('eventi', $eventi);
}
Expand Down
Loading

0 comments on commit 48fda68

Please sign in to comment.