$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); $imgTitle = new \html_library\HTMLTitleElement(3); $imgTitle->add_child(new \html_library\HTMLTextNode($values['title'])); $editLink = new \html_library\HTMLAElement(); $editLink->add_attribute(new \html_library\HTMLAttribute('href', "editphoto.php?id=" . $values['ID'])); $editLink->add_child(new \html_library\HTMLTextNode('Edit photo')); $listElement->add_child($imgTitle); $listElement->add_child(new \html_library\HTMLBrElement()); $listElement->add_child($picLink); $listElement->add_child(new \html_library\HTMLBrElement()); $listElement->add_child($editLink); $listElement->add_child(new \html_library\HTMLBrElement()); $listElements->add_child($listElement); } $body->add_child($listElements); echo $page;
$inputUsername = new \html_library\HTMLInputElement(); $inputUsername->add_attribute(new \html_library\HTMLAttribute('type', 'text')); $inputUsername->add_attribute(new \html_library\HTMLAttribute('name', 'username')); $inputUsername->add_attribute(new \html_library\HTMLAttribute('required', null)); $li1->add_child($labelUsername); $li1->add_child($inputUsername); //password $labelPassword = new \html_library\HTMLLabelElement(); $labelPassword->add_attribute(new \html_library\HTMLAttribute('for', 'password')); $labelPassword->add_child(new \html_library\HTMLTextNode('Password')); $inputPassword = new \html_library\HTMLInputElement(); $inputPassword->add_attribute(new \html_library\HTMLAttribute('type', 'password')); $inputPassword->add_attribute(new \html_library\HTMLAttribute('name', 'password')); $inputPassword->add_attribute(new \html_library\HTMLAttribute('placeholder', 'password')); $inputPassword->add_attribute(new \html_library\HTMLAttribute('required', null)); $li2->add_child($labelPassword); $li2->add_child($inputPassword); $inputSubmit = new \html_library\HTMLInputElement(); $inputSubmit->add_attribute(new \html_library\HTMLAttribute('type', 'submit')); $inputSubmit->add_attribute(new \html_library\HTMLAttribute('value', 'Login')); $li3->add_child($inputSubmit); $homePageLink = new \html_library\HTMLAElement(); $homePageLink->add_attribute(new \html_library\HTMLAttribute('href', 'index.php')); $homePageLink->add_child(new \html_library\HTMLTextNode('Home page')); $body->add_child($homePageLink); $body->add_child(new \html_library\HTMLBrElement()); $registrationLink = new \html_library\HTMLAElement(); $registrationLink->add_attribute(new \html_library\HTMLAttribute('href', 'registration.php')); $registrationLink->add_child(new \html_library\HTMLTextNode('Registration')); $body->add_child($registrationLink); echo $page;
$page = new html_library\HTMLHtmlElement(); $page->add_child(new html_library\HTMLHeadElement()); $body = new html_library\HTMLBodyElement(); $page->add_child($body); $link5 = new html_library\HTMLAElement(); $link5->add_attribute(new html_library\HTMLAttribute('href', 'registration.php')); $link5->add_child(new html_library\HTMLTextNode('Register')); $link6 = new html_library\HTMLAElement(); $link6->add_attribute(new html_library\HTMLAttribute('href', 'login.php')); $link6->add_child(new html_library\HTMLTextNode('Login')); $body->add_child($link5); $body->add_child($link6); $body->add_child(new \html_library\HTMLBrElement()); $image = new \models\Slika(); $counter = 0; $numOfPicToShow = 2; while ($counter < $numOfPicToShow) { try { $image->load(rand(1, 10)); $counter++; $picLink = new \html_library\HTMLAElement(); $picLink->add_attribute(new \html_library\HTMLAttribute('href', "aboutPicture.php?id=" . $image->__get('ID'))); $imgContent = new \html_library\HTMLImageElement(); $imgContent->add_attribute(new \html_library\HTMLAttribute('src', "picture.php?id=" . $image->__get('ID') . "&size=small")); $picLink->add_child($imgContent); $body->add_child($picLink); } catch (Exception $e) { $counter = $counter <= 0 ? 0 : $counter--; } } echo $page;
$inputTitle->add_attribute(new \html_library\HTMLAttribute('placeholder', 'Name of your gallery')); $inputTitle->add_attribute(new \html_library\HTMLAttribute('required', null)); $fieldset->add_child($inputTitle); $fieldset->add_child(new \html_library\HTMLBrElement()); //description $labelDescription = new \html_library\HTMLLabelElement(); $labelDescription->add_attribute(new \html_library\HTMLAttribute('for', 'description')); $labelDescription->add_child(new \html_library\HTMLTextNode('Description: ')); $fieldset->add_child($labelDescription); $textArea = new \html_library\HTMLTextAreaElement(); $textArea->add_attribute(new \html_library\HTMLAttribute('name', 'description')); $textArea->add_attribute(new \html_library\HTMLAttribute('form', 'new_gallery')); $textArea->add_attribute(new \html_library\HTMLAttribute('maxlength', 500)); $fieldset->add_child($textArea); $fieldset->add_child(new \html_library\HTMLBrElement()); //submit $inputSubmit = new \html_library\HTMLInputElement(); $inputSubmit->add_attribute(new \html_library\HTMLAttribute('type', 'submit')); $inputSubmit->add_attribute(new \html_library\HTMLAttribute('name', 'Submit')); $inputSubmit->add_attribute(new \html_library\HTMLAttribute('value', 'Submit')); $fieldset->add_child($inputSubmit); $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()); $link1 = new html_library\HTMLAElement(); $link1->add_attribute(new html_library\HTMLAttribute('href', 'mypictures.php')); $link1->add_child(new html_library\HTMLTextNode('My pictures')); $body->add_child($link1); echo $page;
$body->add_child($link1); $body->add_child(new \html_library\HTMLBrElement()); $title = new \html_library\HTMLTitleElement(); $title->add_child(new \html_library\HTMLTextNode('Your photos: ')); $body->add_child($title); $body->add_child(new \html_library\HTMLBrElement()); $listElements = new \html_library\HTMLUlElement(); $images = DAO::getConnection()->getImagesByUser($_SESSION['user_id']); foreach ($images as $imageId => $image) { $listElement = new \html_library\HTMLLiElement(); $imgContent = new \html_library\HTMLImageElement(); $imgContent->add_attribute(new \html_library\HTMLAttribute('src', "picture.php?id={$imageId}&size=small")); $imgTitle = new \html_library\HTMLTitleElement(3); $imgTitle->add_child(new \html_library\HTMLTextNode($image->getTitle())); $galleryTitle = new \html_library\HTMLTitleElement(5); $galleryTitle->add_child(new \html_library\HTMLTextNode(DAO::getConnection()->getGallery($image->getGalleryId())->getTitle())); $editLink = new \html_library\HTMLAElement(); $editLink->add_attribute(new \html_library\HTMLAttribute('href', "editphoto.php?id={$imageId}")); $editLink->add_child(new \html_library\HTMLTextNode('Edit photo')); $listElement->add_child($imgTitle); $listElement->add_child(new \html_library\HTMLBrElement()); $listElement->add_child($imgContent); $listElement->add_child(new \html_library\HTMLBrElement()); $listElement->add_child($galleryTitle); $listElement->add_child(new \html_library\HTMLBrElement()); $listElement->add_child($editLink); $listElement->add_child(new \html_library\HTMLBrElement()); $listElements->add_child($listElement); } $body->add_child($listElements); echo $page;
$linkMyGalleries->add_child(new html_library\HTMLTextNode('My galleries')); $link3 = new html_library\HTMLAElement(); $link3->add_attribute(new html_library\HTMLAttribute('href', 'upload.php')); $link3->add_child(new html_library\HTMLTextNode('Upload a picture')); $link4 = new html_library\HTMLAElement(); $link4->add_attribute(new html_library\HTMLAttribute('href', 'new_gallery.php')); $link4->add_child(new html_library\HTMLTextNode('Create new gallery')); $linkAdmin = new html_library\HTMLAElement(); $linkAdmin->add_attribute(new html_library\HTMLAttribute('href', 'admin.php')); $linkAdmin->add_child(new html_library\HTMLTextNode('Edit your account')); $linkSearch = new html_library\HTMLAElement(); $linkSearch->add_attribute(new html_library\HTMLAttribute('href', 'search.php')); $linkSearch->add_child(new html_library\HTMLTextNode('Search')); $body->add_child($linkAdmin); $body->add_child($linkMyGalleries); $body->add_child($link1); $body->add_child($link2); $body->add_child($link3); $body->add_child($link4); $body->add_child($linkSearch); if (!isset($_SESSION['user_id'])) { $link5 = new html_library\HTMLAElement(); $link5->add_attribute(new html_library\HTMLAttribute('href', 'registration.php')); $link5->add_child(new html_library\HTMLTextNode('Register')); $link6 = new html_library\HTMLAElement(); $link6->add_attribute(new html_library\HTMLAttribute('href', 'login.php')); $link6->add_child(new html_library\HTMLTextNode('Login')); $body->add_child($link5); $body->add_child($link6); } echo $page;