예제 #1
0
require_once "rolestarter.php";
// gives to user role = 0 on first visit of the website: role = 0 - guest
if (isset($_GET['id']) && is_int((int) $_GET['id']) && !empty($_GET['id'])) {
    /**
     * Connecting doctrine autoloader
     */
    require_once 'Doctrine/Common/ClassLoader.php';
    $classLoader = new ClassLoader("src");
    $classLoader->register();
    require_once "lib/Twig/Autoloader.php";
    Twig_Autoloader::register();
    $whiskyBiz = new WhiskyBusiness();
    $whisky = $whiskyBiz->getWhisky($_GET["id"]);
    $barrelBiz = new BarrelBusiness();
    $barrel = $barrelBiz->showBarrel($_GET["id"]);
    $distilleryBiz = new DistilleryBusiness();
    $distillery = $distilleryBiz->getByWhisky($_GET["id"]);
    $commentBiz = new CommentBusiness();
    $userBiz = new UserBusiness();
    /**
     * Put comments data with user info into an array $participatedUsers
     */
    if (!empty($commentBiz->showComments($_GET["id"]))) {
        foreach ($commentBiz->showComments($_GET["id"]) as $key => $comment) {
            $usersDataFromComments = $userBiz->getUserByComment($comment->getId());
            $participatedUsers[$key]['userId'] = $usersDataFromComments->getId();
            $participatedUsers[$key]['username'] = $usersDataFromComments->getUsername();
            $participatedUsers[$key]['imagePath'] = $usersDataFromComments->getImagePath();
            $participatedUsers[$key]['commentId'] = $comment->getId();
            $participatedUsers[$key]['comment'] = $comment->getComment();
            // Formatting time
예제 #2
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;
예제 #3
0
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();
$formData = array("name" => "", "address" => "", "city" => "", "country" => "", "region" => "");
// check for post
if (count($_POST)) {
    // set variables
    $name = $_POST["name"];
    $address = $_POST["address"];
    $city = $_POST["city"];
    $country = $_POST["country"];
    $region = !empty($_POST["region"]) ? $_POST["region"] : "no region";
    $formData = array("name" => $name, "address" => $address, "city" => $city, "country" => $country, "region" => $region);
}
if (!empty($name) && !empty($address) && !empty($city) && !empty($country) && !empty($region)) {
    $distilleryBiz = new DistilleryBusiness();
    $addDistillery = $distilleryBiz->addDistillery($name, $address, $city, $country, $region);
    header("location:cp_distillery.php");
}
// render TWIG
$loader = new Twig_Loader_Filesystem("src/ProjectWhisky/presentation");
$twig = new Twig_Environment($loader);
$view = $twig->render("cp_distillery_add.twig", array("formData" => $formData));
print $view;
ob_flush();
예제 #4
0
<?php

session_start();
ob_start();
error_reporting(E_ALL);
ini_set("display_errors", 1);
use src\ProjectWhisky\business\DistilleryBusiness;
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();
$distilleryBiz = new DistilleryBusiness();
if (isset($_GET['search_distilleryname']) && !empty($_GET['search_distilleryname'])) {
    $distilleryNameTrim = trim($_GET['search_distilleryname']);
    $distilleryList = $distilleryBiz->getDistilleriesByName($distilleryNameTrim);
    $loader = new Twig_Loader_Filesystem("src/ProjectWhisky/presentation");
    $twig = new Twig_Environment($loader);
    $view = $twig->render("CP_distillery.twig", array("user" => $_SESSION['user'], "distilleries" => $distilleryList, 'searchInput' => $distilleryNameTrim));
} else {
    $distilleryList = $distilleryBiz->getDistilleryList();
    $loader = new Twig_Loader_Filesystem("src/ProjectWhisky/presentation");
    $twig = new Twig_Environment($loader);
    $view = $twig->render("CP_distillery.twig", array("user" => $_SESSION['user'], "distilleries" => $distilleryList));
}
print $view;
ob_flush();
예제 #5
0
require_once "rolestarter.php";
// gives to user role = 0 on first visit of the website: role = 0 - guest
require_once 'Doctrine/Common/ClassLoader.php';
$classLoader = new ClassLoader("src");
$classLoader->register();
require_once "lib/Twig/Autoloader.php";
Twig_Autoloader::register();
if (isset($_GET['strength_rangeleft']) && isset($_GET['strength_rangeright']) && isset($_GET['score_rangeleft']) && isset($_GET['score_rangeright']) && isset($_GET['age_rangeright']) && isset($_GET['age_rangeright']) && isset($_GET['barrel_id']) && isset($_GET['region'])) {
    $whiskyBiz = new WhiskyBusiness();
    $whiskyList = $whiskyBiz->getWhiskyBySearch($_GET["barrel_id"], $_GET["strength_rangeleft"], $_GET["strength_rangeright"], $_GET["score_rangeleft"], $_GET["score_rangeright"], $_GET["region"], $_GET["age_rangeleft"], $_GET["age_rangeright"]);
    $BarrelBiz = new BarrelBusiness();
    $barrelList = $BarrelBiz->showAllBarrels();
    $distilleryBiz = new DistilleryBusiness();
    $regionList = $distilleryBiz->getRegionList();
    $loader = new Twig_Loader_Filesystem("src/ProjectWhisky/presentation");
    $twig = new Twig_Environment($loader);
    $view = $twig->render("whisky_search_results.twig", array("user" => $_SESSION['user'], "whiskies" => $whiskyList, "barrels" => $barrelList, "distilleries" => $regionList));
    print $view;
} else {
    $whiskyBiz = new WhiskyBusiness();
    $whiskyList = $whiskyBiz->getWhiskyList();
    $BarrelBiz = new BarrelBusiness();
    $barrelList = $BarrelBiz->showAllBarrels();
    $distilleryBiz = new DistilleryBusiness();
    $regionList = $distilleryBiz->getRegionList();
    $loader = new Twig_Loader_Filesystem("src/ProjectWhisky/presentation");
    $twig = new Twig_Environment($loader);
    $view = $twig->render("whisky_search.twig", array("user" => $_SESSION['user'], "whiskies" => $whiskyList, "barrels" => $barrelList, "distilleries" => $regionList));
    print $view;
}
ob_flush();
예제 #6
0
        $addWhisky = $whiskyBiz->addWhisky($_SESSION['savedData']['name'], $_SESSION['savedData']['distillery'], $_SESSION['savedData']['price'], $_SESSION['savedData']['age'], $_SESSION['savedData']['strength'], $_SESSION['savedData']['barrel_id'], $newImagePath, $hidden, $_SESSION['savedData']['rating_aroma'], $_SESSION['savedData']['rating_color'], $_SESSION['savedData']['rating_taste'], $_SESSION['savedData']['rating_aftertaste'], $_SESSION['savedData']['text_aroma'], $_SESSION['savedData']['text_color'], $_SESSION['savedData']['text_taste'], $_SESSION['savedData']['text_aftertaste'], $_SESSION['savedData']['review'], $_SESSION['savedData']['user_id']);
        if ($addWhisky == false) {
            throw new FuckedUpException();
        }
        $_SESSION['whiskyMessage'] = "success";
        header("Location: CP_whisky_add.php?updated=1");
    } catch (EmptyDataException $e) {
        $_SESSION['whiskyMessage'] = "missing";
    } catch (NoImageException $e) {
        $_SESSION['whiskyMessage'] = "image_missing";
    } catch (FuckedUpException $e) {
        $_SESSION['whiskyMessage'] = "error";
    }
}
// Get distillery data
$distilleryBiz = new DistilleryBusiness();
$distillery_data = $distilleryBiz->getDistilleryList();
// Get Barrel Data
$barrelBiz = new BarrelBusiness();
$barrel_data = $barrelBiz->showAllBarrels();
$loader = new Twig_Loader_Filesystem("src/ProjectWhisky/presentation");
$twig = new Twig_Environment($loader);
$view = $twig->render("CP_whisky_add.twig", array("user" => $_SESSION['user'], "distilleries" => $distillery_data, "barrels" => $barrel_data, "msg" => $_SESSION['whiskyMessage'], "savedData" => $_SESSION['savedData']));
print $view;
/**
 * Handling messages removal and appearance
 */
if (isset($_GET['updated']) && empty($_SESSION['whiskyMessage'])) {
    header('Location: CP_whisky_add.php');
}
if (isset($_GET['updated']) && $_GET['updated'] == 1) {
예제 #7
0
use src\ProjectWhisky\business\UserBusiness;
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"] : "";