Exemplo n.º 1
0
$link1 = new html_library\HTMLAElement();
$link1->add_attribute(new html_library\HTMLAttribute('href', 'index.php'));
$link1->add_child(new html_library\HTMLTextNode('Home page'));
$body->add_child($link1);
$body->add_child(new \html_library\HTMLBrElement());
$link2 = new html_library\HTMLAElement();
$link2->add_attribute(new html_library\HTMLAttribute('href', 'upload.php'));
$link2->add_child(new html_library\HTMLTextNode('Upload a new photo'));
$body->add_child($link2);
$body->add_child(new \html_library\HTMLBrElement());
$link1 = new html_library\HTMLAElement();
$link1->add_attribute(new html_library\HTMLAttribute('href', 'new_gallery.php'));
$link1->add_child(new html_library\HTMLTextNode('Create a new gallery'));
$body->add_child($link1);
$body->add_child(new \html_library\HTMLBrElement());
$gallery = new \models\Galerija();
$images = \db\DAO::getConnection()->getAllImagesInGallery($_GET['id']);
$gallery->load($_GET['id']);
$title = new \html_library\HTMLTitleElement();
$title->add_child(new \html_library\HTMLTextNode($gallery->__get('title') . ' (' . count($images) . ')'));
$body->add_child($title);
$body->add_child(new \html_library\HTMLBrElement());
$listElements = new \html_library\HTMLUlElement();
foreach ($images as $image) {
    $values = get_object_vars($image);
    $listElement = new \html_library\HTMLLiElement();
    $picLink = new \html_library\HTMLAElement();
    $picLink->add_attribute(new \html_library\HTMLAttribute('href', "aboutPicture.php?id=" . $values['ID']));
    $imgContent = new \html_library\HTMLImageElement();
    $imgContent->add_attribute(new \html_library\HTMLAttribute('src', "picture.php?id=" . $values['ID'] . "&size=small"));
    $picLink->add_child($imgContent);
Exemplo n.º 2
0
<?php

/**
 * Created by PhpStorm.
 * User: martinmatak
 * Date: 21/02/16
 * Time: 16:01
 */
require_once 'Autoloader.php';
session_start();
// not logged in or id of photo not set
if (!isset($_SESSION['user_id']) || !isset($_GET['id'])) {
    header('Location: index.php');
}
//not his gallery
$gallery = new \models\Galerija();
$gallery->load($_GET['id']);
if ($gallery->__get('user_id') !== $_SESSION['user_id']) {
    header('Location: index.php');
}
if (!empty($_POST['submitted'])) {
    if (isset($_POST['btnDelete'])) {
        $gallery->delete();
        //TODO: Obrisati i slike iz te galerije
        \db\DAO::getConnection()->removeImagesInGallery($_GET['id']);
        header('Location: mygalleries.php');
        exit;
    }
    $formValidation = new \validation_library\FormValidation();
    $rules = array();
    $rules['title'] = 'required|length[100]';