Skip to content

Commit

Permalink
Merge pull request #1 from Fiste788/3.1
Browse files Browse the repository at this point in the history
3.1
  • Loading branch information
fiste788 committed Aug 6, 2014
2 parents e7df63e + 48b8846 commit 5680ae6
Show file tree
Hide file tree
Showing 1,796 changed files with 69,696 additions and 124,757 deletions.
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory" : "public/components"
}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ Thumbs.db
# Folder config file
Desktop.ini


924 changes: 427 additions & 497 deletions .htaccess

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion error_docs/404.html → 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ <h1>Not found <span>:(</span></h1>
<script>
var GOOG_FIXURL_LANG = (navigator.language || '').slice(0,2),GOOG_FIXURL_SITE = location.host;
</script>
<script src="http://linkhelp.clients.google.com/tbproxy/lh/wm/fixurl.js"></script>
<script src="//linkhelp.clients.google.com/tbproxy/lh/wm/fixurl.js"></script>
</div>
</body>
</html>
17 changes: 0 additions & 17 deletions ajax/download.php

This file was deleted.

10 changes: 0 additions & 10 deletions ajax/giocatore.php

This file was deleted.

8 changes: 0 additions & 8 deletions ajax/probabiliFormazioni.php

This file was deleted.

10 changes: 0 additions & 10 deletions ajax/squadre.php

This file was deleted.

35 changes: 0 additions & 35 deletions ajax/upload.php

This file was deleted.

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

namespace Fantamanajer\Controllers;

use Fantamanajer\Lib\Notify;
use Fantamanajer\Lib\QuickLinks;
use Fantamanajer\Lib\Ruolo;
use Fantamanajer\Models\Formazione;
use Fantamanajer\Models\Giocatore;
use Fantamanajer\Models\Giornata;
use Fantamanajer\Models\Lega;
use Fantamanajer\Models\Trasferimento;
use FirePHP;
use Lib\BaseController;
use Lib\Request;
use Lib\Response;
use Savant3;

abstract class ApplicationController extends BaseController {

/**
*
* @var QuickLinks
*/
protected $quickLinks;

/**
*
* @var Giornata
*/
protected $currentGiornata;

/**
*
* @var Lega
*/
protected $currentLega;

/**
*
* @var Ruolo[]
*/
protected $ruoli = array();

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

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

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

public function initialize() {
parent::initialize();
$this->notifiche = array();
$this->ruoli['P'] = new Ruolo("Portiere", "Portieri", "POR");
$this->ruoli['D'] = new Ruolo("Difensore", "Difensori", "DIF");
$this->ruoli['C'] = new Ruolo("Centrocampista", "Centrocampisti", "CEN");
$this->ruoli['A'] = new Ruolo("Attaccante", "Attaccanti", "ATT");

$leghe = Lega::getList();

if (!is_null(Request::getRequest()->getParam('legaView',NULL))) {
$_SESSION['legaView'] = Request::getRequest()->getParam('legaView');
}
if (isset($_SESSION['idLega'])) {
$_SESSION['datiLega'] = $leghe[$_SESSION['idLega']];
}
$this->currentGiornata = Giornata::getCurrentGiornata();
$this->currentLega = $leghe[$_SESSION['legaView']];
foreach ($this->templates as $savant) {
$savant->assign('ruoli', $this->ruoli);
$savant->assign('dataFine', date_parse($this->currentGiornata->getData()->format("Y-m-d H:i:s")));
$savant->assign('timestamp', $this->currentGiornata->getData()->getTimestamp());
$savant->assign('currentGiornata',$this->currentGiornata->getId());
$savant->assign('stagioneFinita',$this->currentGiornata->getStagioneFinita());
$savant->assign('leghe', $leghe);
$savant->assign('route',$this->route);
$savant->assign('router', $this->router);
$savant->assign('request',$this->request);
}
$this->quickLinks = new QuickLinks($this->request,$this->router,$this->route);
$this->templates['navbar']->assign('entries',$this->pages);
$this->initializeNotifiche();
$this->templates['navbar']->assign('notifiche',$this->notifiche);
}

private function initializeNotifiche() {
if(!$this->currentGiornata->getStagioneFinita()) {
$formazione = Formazione::getFormazioneBySquadraAndGiornata($_SESSION['idUtente'],$this->currentGiornata->getId());
if(empty($formazione)) {
$this->notifiche[] = new Notify(Notify::LEVEL_MEDIUM,'Non hai ancora impostato la formazione per questa giornata',$this->router->generate('formazione'));
}
}

$giocatoriInattivi = Giocatore::getGiocatoriInattiviByIdUtente($_SESSION['idUtente']);
if(!empty($giocatoriInattivi) && count(Trasferimento::getTrasferimentiByIdSquadra($_SESSION['idUtente'])) < $_SESSION['datiLega']->numTrasferimenti ) {
$this->notifiche[] = new Notify(Notify::LEVEL_HIGH,'Un tuo giocatore non è più nella lista!',$this->router->generate('trasferimento_index'));
}
}

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 render($content = NULL) {
if(is_null($content)) {
$this->templates['layout']->assign("quickLinks",$this->quickLinks);
$this->fetched['operation'] = $this->fetchOperationTpl();
}
return parent::render($content);
}

}


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

namespace Fantamanajer\Controllers;

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

class ArticoloController extends ApplicationController {

public function index() {
$giornata = $this->request->getParam('giornata',$this->currentGiornata->id);
$articoli = $this->currentLega->getArticoliByGiornata($giornata);
$giornate = Articolo::getGiornateArticoliExist($this->currentLega->id);
array_push($giornate, $giornata);
$this->templates['content']->assign('articoli', $articoli);
$this->templates['operation']->assign('giornateWithArticoli', array_unique($giornate));
$this->templates['operation']->assign('giornata', $giornata);
}

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

public function create() {
try {
$articolo = new Articolo();
$articolo->setIdUtente($_SESSION['idUtente']);
$articolo->setIdGiornata($this->currentGiornata->id);
$articolo->setIdLega($this->currentLega->id);
$articolo->setDataCreazione('now');
$articolo->save();
$this->redirectTo("articoli");
} catch(FormException $e) {
$this->setFlash(self::FLASH_NOTICE, $e->getMessage());
$this->renderAction("articolo_new");
}

}

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

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

public function delete() {
$articolo = Articolo::getById($this->route['params']['id']);
$articolo->delete();
$this->redirectTo("articoli");
}
}


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

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

class ClubController extends ApplicationController {

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

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

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

$this->quickLinks->set('id',$elencoClub,"");
$giocatori = Models\View\GiocatoreStatistiche::getByField('idClub',$dettaglioClub->id);
$this->templates['content']->assign('giocatori',$giocatori);
$this->templates['content']->assign('clubDett',$dettaglioClub);
$this->templates['operation']->assign('elencoClub',$elencoClub);
}

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));
}
}


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

namespace Fantamanajer\Controllers;

use Fantamanajer\Models\Evento;
use Fantamanajer\Models\Lega;
use FirePHP;
use Suin\RSSWriter\Channel;
use Suin\RSSWriter\Feed;
use Suin\RSSWriter\Item;

class EventoController extends ApplicationController {

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

public function rss() {
$this->response->setContentType("text/xml;charset=\"utf-8\"");
$feed = new Feed();
$leghe = Lega::getList();
foreach($leghe as $key => $lega) {
$eventi = Evento::getEventi($key, NULL, 0, 50);
$channel = new Channel();
$channel->title("Fantamanajer - " . $lega->nome);
$channel->description("Feed per la lega " . $lega->nome);
$channel->url("http://fantamanajer.it");
$channel->copyright("Copiright 2013 fantamanajer.it");
$channel->language("IT-it");
$channel->lastBuildDate($eventi[0]->data->getTimestamp());
foreach ($eventi as $key2 => $evento) {
$item = new Item();
$item->title($evento->titolo);
$item->pubDate($evento->data->getTimestamp());
$item->description($evento->content);
if(!empty($evento->link)) {
$item->url($evento->link);
} else {
$item->url($this->router->generate("feed") . "#evento-" . $evento->id);
}
$channel->addItem($item);
}
$feed->addChannel($channel);
}
echo $feed;
}

}
Loading

0 comments on commit 5680ae6

Please sign in to comment.