Exemplo n.º 1
0
<?php

session_start();
use src\ProjectWhisky\business\DistilleryBusiness;
use src\ProjectWhisky\business\WhiskyBusiness;
use Doctrine\Common\ClassLoader;
/**
 * Connecting doctrine autoloader
 */
require_once 'Doctrine/Common/ClassLoader.php';
$classLoader = new ClassLoader("src");
$classLoader->register();
/* Twig autoloader*/
require_once "lib/Twig/Autoloader.php";
Twig_Autoloader::register();
$distilleryBiz = new DistilleryBusiness();
$whiskyBiz = new WhiskyBusiness();
$distillery = $distilleryBiz->getDistillery($_GET["id"]);
$whiskies = $whiskyBiz->getWhiskyByDistillery($_GET["id"]);
/*
print("<pre>");
print_r($distillery);
print("</pre>");
*/
$loader = new Twig_Loader_Filesystem("src/ProjectWhisky/presentation");
$twig = new Twig_Environment($loader);
$view = $twig->render("distillery_page.twig", array("user" => $_SESSION['user'], "distillery" => $distillery, "whiskies" => $whiskies));
print $view;
Exemplo n.º 2
0
use src\ProjectWhisky\exceptions\EmptyDataException;
use src\ProjectWhisky\exceptions\NoImageException;
use src\ProjectWhisky\exceptions\FuckedUpException;
use Doctrine\Common\ClassLoader;
require_once "rolestarter.php";
require_once "adminRights.php";
// Redirects users ir guest from control panel to index.php if is not admin
require_once 'Doctrine/Common/ClassLoader.php';
$classLoader = new ClassLoader("src");
$classLoader->register();
require_once "lib/Twig/Autoloader.php";
Twig_Autoloader::register();
$distillery_id = isset($_GET["id"]) ? $_GET["id"] : "";
// Get Distillery Data
$distilleryBiz = new DistilleryBusiness();
$distillery_data = $distilleryBiz->getDistillery($distillery_id);
/**
 * Initiate $_SESSION['savedData'] and $_SESSION['distilleryMessage']
 */
if (!isset($_SESSION['savedData'])) {
    $_SESSION['savedData'] = array();
}
if (!isset($_SESSION['distilleryMessage'])) {
    $_SESSION['distilleryMessage'] = array();
}
// check for post
if (isset($_POST['distillerySaveBtn'])) {
    try {
        // set variables
        $_SESSION['savedData']['name'] = !empty($_POST["name"]) ? $_POST["name"] : "";
        $_SESSION['savedData']['address'] = !empty($_POST["address"]) ? $_POST["address"] : "";