Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit 4e423be0d46f8c6749f1426ebcc771f443f80b7f @juzna committed Dec 7, 2010
1 .gitignore
@@ -0,0 +1 @@
+temp/cache
58 app/bootstrap.php
@@ -0,0 +1,58 @@
+<?php
+
+use Nette\Debug,
+ Nette\Environment,
+ Nette\Application\Route,
+ Nette\Application\SimpleRouter;
+
+
+
+// Step 1: Load Nette Framework
+// this allows load Nette Framework classes automatically so that
+// you don't have to litter your code with 'require' statements
+require LIBS_DIR . '/Nette/loader.php';
+
+
+
+// Step 2: Configure environment
+// 2a) enable Nette\Debug for better exception and error visualisation
+Debug::enable();
+
+// 2b) load configuration from config.ini file
+Environment::loadConfig();
+
+
+
+// Step 3: Configure application
+// 3a) get and setup a front controller
+$application = Environment::getApplication();
+
+// 3b) establish database connection
+dibi::connect(Environment::getConfig('database'));
+
+
+
+// Step 4: Setup application router
+$router = $application->getRouter();
+
+// mod_rewrite detection
+if (false && function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules())) {
+ $router[] = new Route('index.php', array(
+ 'presenter' => 'Dashboard',
+ 'action' => 'default',
+ ), Route::ONE_WAY);
+
+ $router[] = new Route('<presenter>/<action>/<id>', array(
+ 'presenter' => 'Dashboard',
+ 'action' => 'default',
+ 'id' => NULL,
+ ));
+
+} else {
+ $router[] = new SimpleRouter('Web:default');
+}
+
+
+
+// Step 5: Run the application!
+$application->run();
25 app/config.ini
@@ -0,0 +1,25 @@
+;
+; SECURITY WARNING: it is CRITICAL that this file & directory are NOT accessible directly via a web browser!
+; http://nette.org/security-warning
+;
+[common]
+; PHP configuration
+php.date.timezone = "Europe/London"
+
+; services
+service.Nette-Loaders-RobotLoader.option.directory[] = %appDir%
+service.Nette-Loaders-RobotLoader.option.directory[] = %libsDir%
+service.Nette-Loaders-RobotLoader.run = TRUE
+
+[production < common]
+; common database connection
+database.driver = mysql
+database.host = localhost
+database.user = fifa
+database.password = fifa
+database.database = fifa
+database.lazy = TRUE
+
+[development < production]
+; database options in development mode
+database.profiler = TRUE
8 app/presenters/BasePresenter.php
@@ -0,0 +1,8 @@
+<?php
+
+use Nette\Application\Presenter;
+
+
+abstract class BasePresenter extends Presenter
+{
+}
43 app/presenters/WebPresenter.php
@@ -0,0 +1,43 @@
+<?php
+
+use Nette\Application\AppForm,
+ Nette\Forms\Form;
+
+
+
+class WebPresenter extends BasePresenter {
+
+ /********************* view default *********************/
+
+
+ public function renderDefault() {
+ $this->template->match = dibi::query('select * from [matches] where [datetime] > now() limit 1')->fetch();
+ }
+
+
+ public function renderMatch($id) {
+ // Load match
+ $this->template->match = $match = dibi::query('select * from [matches] where [mid] = %i', $id)->fetch();
+
+ // Load teams
+ $this->template->team1 = dibi::query('select * from [teams] where tid = %i', $match->team1)->fetch();
+ $this->template->team2 = dibi::query('select * from [teams] where tid = %i', $match->team2)->fetch();
+ }
+
+ public function renderMatches() {
+ $this->template->matches = dibi::query('select matches.*, team1.tname as team1name, team2.tname as team2name from [matches]
+ left join teams team1 on team1.tid=matches.team1
+ left join teams team2 on team2.tid=matches.team2')->fetchAll();
+ }
+
+ public function renderTeam($id) {
+ $this->template->team = dibi::query('select * from [teams] where tid = %i', $id)->fetch();
+ $this->template->players = dibi::query('select * from [players] where tid = %i', $id)->fetchAll();
+ }
+
+ public function renderPlayer($id) {
+ $this->template->player = $player = dibi::query('select * from [players] where pid = %i', $id)->fetch();
+ $this->template->team = dibi::query('select * from [teams] where tid = %i', $player->tid)->fetch();
+ }
+
+}
41 app/templates/Web/@layout.phtml
@@ -0,0 +1,41 @@
+{**
+ * Layout of Nette Framework example CD collection (Akrabat)
+ *
+ * @package MyApplication
+ *
+ * @param string $robots tell robots how to index the content of a page (optinal)
+ * @param string $basePath web base path
+ * @param array $flashes flash messages
+ * @param Nette\Web\User $user current user
+ *}
+
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="Content-Language" content="en" />
+
+ <meta name="description" content="Nette Framework example" />
+ <meta n:ifset="$robots" name="robots" content="{$robots}">
+
+ <title>{block #title|striptags|trim}{/block} | Nette example</title>
+
+ <link rel="stylesheet" type="text/css" media="screen" href="{$basePath}/css/site.css" />
+</head>
+
+<body>
+ <div n:foreach="$flashes as $flash" class="flash {$flash->type}">{$flash->message}</div>
+
+ <div id="menu" style="border: 1px solid black;">
+ {block #menu}
+ Here is the basic menu
+ {/block}
+ </div>
+
+ <div id="content">
+ {include #content}
+ </div>
+
+ <p id="logged-in" n:if="$user->loggedIn">Signed in as {$user->identity->username} ({$user->identity->real_name}). <a href="{link Sign:out}">Sign out</a></p>
+</body>
+</html>
15 app/templates/Web/default.phtml
@@ -0,0 +1,15 @@
+{block #content}
+
+{block #title}<h1>Fifa welcome</h1>{/block}
+
+<p>
+{if $match}
+ <strong>Next match:</strong> <a href="{link match, $match->mid}">{$match->datetime|date}</a>
+{else}
+ <strong>No oncoming matches</strong>
+{/if}
+</p>
+
+
+<a href="{link matches}">All matches</a>
+
16 app/templates/Web/match.phtml
@@ -0,0 +1,16 @@
+{block #content}
+<h1>Match detail</h1>
+
+
+
+<p><b>Stadium: </b> {$match->stadium}</p>
+<p><b>Scheduled at: </b> {$match->datetime|date: 'j.n.Y H:i:s'}</p>
+<p><b>Teams:</b> <a href="{link team, $team1->tid}">{$team1->tname}</a> vs. <a href="{link team, $team2->tid}">{$team2->tname}</a></p>
+
+{/block}
+
+
+
+{block #menu}
+Menu of match
+{/block}
14 app/templates/Web/matches.latte
@@ -0,0 +1,14 @@
+{block #content}
+
+<h1>List of all matches</h1>
+
+<table>
+{foreach $matches as $match}
+ <tr>
+ <td>{$match->stadium}</td>
+ <td>{$match->datetime|date}</td>
+ <td>{$match->team1name}</td>
+ <td>{$match->team2name}</td>
+ </tr>
+{/foreach}
+</table>
6 app/templates/Web/player.latte
@@ -0,0 +1,6 @@
+{block #content}
+
+<h1>Player details</h1>
+<div>Name: {$player->pname}</div>
+<div>Date of birth: {$player->dob|date}</div>
+<div>Team: <a href="{link team, $team->tid}">{$team->tname}</a></div>
24 app/templates/Web/team.latte
@@ -0,0 +1,24 @@
+{block #content}
+<h1>Team {$team->tname}</h1>
+
+<p><b>City: </b>{$team->city}</p>
+
+<h2>Players</h2>
+
+<ul>
+ {foreach $players as $player}
+ <li><a href="{link player, $player->pid}">{$player->pname}</a></li>
+ {/foreach}
+</ul>
+
+
+{/block}
+
+
+
+
+
+
+{block #title}
+Team:{$team->tname}
+
13 document_root/.htaccess
@@ -0,0 +1,13 @@
+# disable directory listing
+Options -Indexes
+
+# mod_rewrite
+<IfModule mod_rewrite.c>
+ RewriteEngine On
+ # RewriteBase /
+
+ # front controller
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteRule !\.(pdf|js|ico|gif|jpg|png|css|rar|zip|tar\.gz)$ index.php [L]
+</IfModule>
108 document_root/css/site.css
@@ -0,0 +1,108 @@
+body {
+ font: 16px/1.5 "Trebuchet MS", "Geneva CE", lucida, sans-serif;
+ color: #333;
+ background-color: #fff;
+ margin: 2em;
+}
+
+h1 {
+ font-size: 1.9em;
+ color: #3484D2;
+}
+
+h2 {
+ font-size: 1.2em;
+ color: #3484D2;
+}
+
+#content {
+ width: 770px;
+ margin: 0 5px;
+}
+
+a {
+ color: #000080;
+}
+
+#logged-in {
+ margin-top: 3em;
+ font-size: 90%;
+}
+
+div.flash {
+ color: black;
+ background: #FFFFDD;
+ border: 1px solid #FFD700;
+ padding: 1em;
+ margin: 1em 0;
+}
+
+
+
+/*------------------------------------------------------------------*/
+
+
+table.grid {
+ padding: 0;
+ margin: 0;
+ border-collapse:collapse;
+}
+
+table.grid td, table.grid th {
+ background: #fff;
+ border: 1px solid #add4fb;
+ padding: 6px 6px 6px 12px;
+}
+
+table.grid th {
+ color: #7a7772;
+ background: #E4F1FC;
+ text-align: left;
+ font-weight: normal;
+ font-size: 80%;
+}
+
+table.grid .alt td {
+ background: #f8f8f0;
+}
+
+
+
+/*------------------------------------------------------------------*/
+
+
+
+form {
+ max-width: 500px;
+ padding: .8em 1.6em;
+ background: #E4F1FC;
+ border: solid 2px #add4fb;
+}
+
+form input {
+ margin: 2px 0;
+ font-size: 100%;
+}
+
+form input.default {
+ font-weight: bold;
+ font-size: 105%;
+}
+
+form input.text {
+ padding: 4px 2px;
+ border: solid 1px #add4fb;
+ min-width: 200px;
+}
+
+form label {
+ width: 100px;
+ display: block;
+ text-align: right;
+ margin-right: 5px;
+ font-weight: normal;
+}
+
+form .required label {
+ font-weight: bold;
+}
16 document_root/index.php
@@ -0,0 +1,16 @@
+<?php
+
+// absolute filesystem path to the web root
+define('WWW_DIR', __DIR__);
+
+// absolute filesystem path to the application root
+define('APP_DIR', WWW_DIR . '/../app');
+
+// absolute filesystem path to the libraries
+define('LIBS_DIR', WWW_DIR . '/../libs');
+
+// absolute filesystem path to the temporary files
+define('TEMP_DIR', WWW_DIR . '/../temp');
+
+// load bootstrap file
+require APP_DIR . '/bootstrap.php';
1 libs/Nette
1 libs/dibi
2 log/.htaccess
@@ -0,0 +1,2 @@
+Order Allow,Deny
+Deny from all
2 temp/.htaccess
@@ -0,0 +1,2 @@
+Order Allow,Deny
+Deny from all

0 comments on commit 4e423be

Please sign in to comment.