-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Fiste788/3.1
3.1
- Loading branch information
Showing
1,796 changed files
with
69,696 additions
and
124,757 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"directory" : "public/components" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,4 +39,3 @@ Thumbs.db | |
# Folder config file | ||
Desktop.ini | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
Oops, something went wrong.