Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
lightszentip committed Feb 23, 2014
1 parent 1bf0bbf commit 440645b
Show file tree
Hide file tree
Showing 271 changed files with 22,615 additions and 3 deletions.
89 changes: 86 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,87 @@
giftlist
========
# Presentlist / Geschenkeliste #

Eine Geschenkliste / a Presentlist / ein Wunschzettel
=> !! For English => english is under german !!

Presentlist ist eine Geschenkliste auf der man seine Wünsche zur Hochzeit, Geburtstag oder anderen Anlässen auflisten kann. Dabei kann man einen Titel, Beschreibung und auch ein Bild zum Geschnenk angeben, sowie Links zu Händlern oder dem Produkt angeben. Wenn sich dann jemand ein Geschenk von der Liste nimmt, ist es für die anderen nicht mehr sichtbar. Man kann gewählte Geschenke aber auch wieder freigeben und der Administrator sieht nicht wer sich welches Geschenk genommen hat.

![](https://raw2.github.com/lightszentip/giftlist/gh-pages/screenshot01.PNG)
![](https://raw2.github.com/lightszentip/giftlist/gh-pages/screenshot03.PNG)
![](https://raw2.github.com/lightszentip/giftlist/gh-pages/screenshot04.PNG)

## Funktionen ##
- Install Wizard
- Geschenkeliste
- Detail Ansicht von Geschenken
- Geschenk auswählen
- Geschenk freigeben
- Geschenk per Mail teilen
- Backend
- Geschenk anlegen / editieren / löschen
- Benutzer anlegen
- Profil editieren
- Passwort vergessen
- Login / Logout
- Wartungsmodus aktivieren
- Einstellungen ändern


## Requirements ##

- PHP 5.3.7 oder höher
- MySQL Datenbank (andere sind aktuell nur durch bearbeiten der Sources möglich)
- PHP PDO Support für MySQL aktiv (extension=php_pdo_mysql.dll)


## Anleitung ##

Die Zip Datei im gewüschten Ordner entpacken und die Url zum Ordner aufrufen. Danach wird man auf den Install Wizard weitergeleitet. Nach dem ausführen des Install Wizard den setup Ordner löschen. Danach sich anmelden und das Passwort und die Email Adresse des Admin Benutzers ändern. Durch das Ändern des Benutzernamens wird zudem die Sicherheit erhöht.

Bei Fragen/Problemen/Erweiterungen und Feedback stehe ich gerne zur Verfügung. Entweder per Email oder durch erstellen eines Issues.

## English ##

The app presentlist is show the wishes from wedding, birthday or from other occasions. You can create a present with a title, description, image and links. If a user take a present from the list, it is not visible for other user.



## Functions ##
- Install Wizard
- list with presents
- detail view of present
- use a present
- release a gift
- Backend
- create, edit, delete a present
- create user
- edit profile
- forgotten password
- Login / Logout
- maintenance mode
- change settings


## Requirements ##

- PHP 5.3.7 or higher
- MySQL Database (other database only support by you edit the source files)
- PHP PDO Support for MySQL active (extension=php_pdo_mysql.dll)


## Instructions ##

Unpack the zip file to the target dir and open the url in your browser. Follow the steps of install wizard. Delete the setup folder and change the password and email address of admin account.

If you have a question, problems or feedback then you can send a mail or create a new issue.

## Verwendete PHP Libraries / Used lbraries: ##

- Rain TPL => [https://github.com/rainphp/raintpl](https://github.com/rainphp/raintpl)
- php-i18n von Philipp Schröer=> [https://github.com/Philipp15b/php-i18n?files=1](https://github.com/Philipp15b/php-i18n?files=1)
- Medoo DB => [http://medoo.in/api/new](http://medoo.in/api/new)
- PHP Setup / Installer Script => [http://www.effiziente-webprogrammierung.info/php-scripts/setup-wizard-installer](http://www.effiziente-webprogrammierung.info/php-scripts/setup-wizard-installer)
- PHP Login von http://www.php-login.net/ => [https://github.com/panique/php-login](https://github.com/panique/php-login) -> Version Advanced

## Verwendete JS/HTML/CSS Komponeneten / Used JS/HTML/CSS components: ##

- TableSorter von Christian Bach => [http://mottie.github.io/tablesorter/](https://github.com/Mottie/tablesorter)
- Bootstrap 3.1 => [http://getbootstrap.com/](http://getbootstrap.com/)
73 changes: 73 additions & 0 deletions app/classes/controller/ControllerAdminStartpage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

class ControllerAdminStartpage implements InterfaceController {

private $request = null;
private $view = null;
private $messageResolver = null;
private $presentDao = null;

/**
*
* @param type $request
* @param type $jdbcTemplate
* @param SecurityModel $security
*/
public function __construct($request, $jdbcTemplate, InterfaceSecurity $login) {
$this -> view = new BackendView($login->getSecurityModel());
$this -> request = $request;
$this -> messageResolver = AppFactory::getMessageResolver();
$this -> presentDao = new PresentDao($jdbcTemplate);
}

/**
* Process data
*/
public function process() {
$presentlist = $this -> presentDao -> getAll();
$this -> view -> assign("presents", $presentlist -> getItems());
$success = null;
if(!empty($this -> request['get']['success'])) {
$success = EscapeHelper::escape($this -> request['get']['success'], EscapeHelper::TARGET_STRING);
}
$isErrorPresent = false;
$isChangePresent = false;
if (!empty($success) && ($success == "createPresent" || $success == "editPresent" || $success == "deletePresent")) {
$args = EscapeHelper::escape($this -> request['get']['args'], EscapeHelper::TARGET_STRING);
$parameter = base64_decode($args);
list($paramPresentId, $paramResult) = split("&", $parameter);
$presentId = EscapeHelper::escape(str_replace("presentId=", "", $paramPresentId), EscapeHelper::TARGET_NUMBER);
if ($success == "createPresent") {
$present = $this -> presentDao -> getById($presentId);
$isChangePresent = true;
$this -> view -> assign("infomessage", $this -> messageResolver -> getMessage("adminpresenttable_create_present", $present -> getTitle()));
} else if ($success == "editPresent") {
$present = $this -> presentDao -> getById($presentId);
$isChangePresent = true;
$this -> view -> assign("infomessage", $this -> messageResolver -> getMessage("adminpresenttable_edit_present", $present -> getTitle()));
} else if ($success == "deletePresent") {
$result = EscapeHelper::escape(str_replace("result=", "", $paramResult), EscapeHelper::TARGET_STRING);
if ($result == 1) {
$isChangePresent = true;
$this -> view -> assign("infomessage", $this -> messageResolver -> getMessage("adminpresenttable_delete_present", $presentId));
} else {
$isErrorPresent = true;
$this -> view -> assign("errormessage", $this -> messageResolver -> getMessage("adminpresenttable_delete_present_error", $presentId));
}
}
}
$this -> view -> assign("changePresent", $isChangePresent);
$this -> view -> assign("errorPresent", $isErrorPresent);
}
/**
* Display Content
* @return type
*/
public function display() {
$this -> view -> setTemplate("backend_presenttable");
$this -> view -> assign("view", "list");
$this -> view -> assign("messageResolver", $this -> messageResolver);
return $this -> view -> loadTemplate();
}

}
144 changes: 144 additions & 0 deletions app/classes/controller/ControllerCreateEditPresent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<?php

class ControllerCreateEditPresent implements InterfaceController {

private $request = null;
private $view = null;
private $messageResolver = null;
private $presentDao = null;

/**
*
* @param type $request
* @param type $jdbcTemplate
* @param InterfaceSecurity $login
*/
public function __construct($request, $jdbcTemplate, InterfaceSecurity $login) {
$this->view = new BackendView($login->getSecurityModel());
$this->request = $request;
$this->messageResolver = AppFactory::getMessageResolver();
$this->presentDao = new PresentDao($jdbcTemplate);
}

/**
*
*/
public function process() {
$isNew = null;
if (!empty($this->request['post']['checknew'])) {
$isNew = EscapeHelper::escape($this->request['post']['checknew'], EscapeHelper::TARGET_STRING);
}
$error = new ErrorModel();
$isError = false;
$isEdit = false;
if ($isNew == "true") {
$title = EscapeHelper::escape($this->request['post']['title'], EscapeHelper::TARGET_STRING);
$description = EscapeHelper::escape($this->request['post']['description'], EscapeHelper::TARGET_STRING);
$imagePath = EscapeHelper::escape($this->request['post']['imagePath'], EscapeHelper::TARGET_STRING);
$links = EscapeHelper::escape($this->request['post']['links'], EscapeHelper::TARGET_STRING);
if (HelperUtil::isNullOrEmptyString($title)) {
$error->addErrorField("title", "error_present_create_empty_title");
} else {
if (strlen($title) > 50) {
$error->addErrorField("title", "error_present_create_size_title");
}
}
if (!empty($imagePath)) {
if (!$this->str_starts_with($imagePath, "http")) {
$imagePath = "http://" . $imagePath;
}
if (!filter_var($imagePath, FILTER_VALIDATE_URL)) {
$error->addErrorField("title", "error_present_create_invalid_imagepath");
}
}
if (!empty($description) && strlen($description) > 1200) {
$error->addErrorField("description", "error_present_create_size_description");
}
if (!empty($links)) {

function notEmpty($var) {
// Gibt zurück, ob der Eingabewert gerade ist
return (!(!isset($var) || trim($var) === '' || empty($var)));
}

$links = array_filter($links, "notEmpty");
}
if (count($links) == 0) {
$links = null;
}
$present = new PresentModel();
$present->setTitle($title);
$present->setDescription($description);
$present->setImagePath($imagePath);
$present->setLinks($links);
if ($error->hasError()) {
$editId = EscapeHelper::escape($this->request['post']['editId'], EscapeHelper::TARGET_NUMBER);
if (!empty($editId)) {
$present->setId($editId);
}
$this->view->assign("present", $present);
} else {
$editId = EscapeHelper::escape($this->request['post']['editId'], EscapeHelper::TARGET_NUMBER);
if (!empty($editId)) {
$present->setId($editId);
$id = $this->presentDao->update($present);
if ($id != null) {
$targetLocation = APP_URL . "?mapping=admin&success=editPresent&args=" . base64_encode("presentId=$id");
header("Location: $targetLocation");
} else {
$error->addErrorField("present", $this->messageResolver->getMessage("error_present_create_db"));
$this->view->assign("present", $present);
}
} else {
$id = $this->presentDao->createPresent($present);
if ($id != null) {
$targetLocation = APP_URL . "?mapping=admin&success=createPresent&args=" . base64_encode("presentId=$id");
header("Location: $targetLocation");
} else {
$error->addErrorField("present", $this->messageResolver->getMessage("error_present_create_db"));
$this->view->assign("present", $present);
}
}
}
} else {
//edit ?
$presendId = EscapeHelper::escape($this->request['get']['id'], EscapeHelper::TARGET_NUMBER);
if (!empty($presendId)) {
$present = $this->presentDao->getById($presendId);
if ($present != null && $present->getStatus() != 1) {
$this->view->assign("present", $present);
$isEdit = true;
} else {
$this->view->assign("present", new PresentModel());
$isError = true;
}
} else {
$this->view->assign("present", new PresentModel());
}
}
$this->view->assign("isError", $isError);
$this->view->assign("isEdit", $isEdit);
$this->view->assign("error", $error);
}

/**
*
* @return type
*/
public function display() {
$this->view->setTemplate("backend_createeditpresent");
$this->view->assign("messageResolver", $this->messageResolver);
return $this->view->loadTemplate();
}

private function str_starts_with($haystack, $needle) {
return substr_compare($haystack, $needle, 0, strlen($needle)) === 0;
}

private function str_ends_with($haystack, $needle) {
return substr_compare($haystack, $needle, -strlen($needle)) === 0;
}

}

?>
35 changes: 35 additions & 0 deletions app/classes/controller/ControllerCreateUser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

class ControllerCreateUser implements InterfaceController {

private $request = null;
private $view = null;
private $messageResolver = null;
private $login;

/**
*
* @param type $request
* @param type $jdbcTemplate
* @param InterfaceSecurity $login
*/
public function __construct($request, $jdbcTemplate, InterfaceSecurity $login) {
$this->view = new BackendView($login->getSecurityModel());
$this->request = $request;
$this->messageResolver = AppFactory::getMessageResolver();
$this->login = $login;
}

public function process() {
$this->login->processRegister();
}

public function display() {
$this->view->setTemplate($this->login->getRegisterView());
$this->view->assign("messageResolver", $this->messageResolver);
$this->view->assign($this->login->getRegisterViewVars());
$this->view->assign("isRegisterConfirm", false);
return $this->view->loadTemplate();
}

}
41 changes: 41 additions & 0 deletions app/classes/controller/ControllerDeletePresent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

class ControllerDeletePresent implements InterfaceController {

private $request = null;
private $view = null;
private $messageResolver = null;
private $presentDao = null;

public function __construct($request, $jdbcTemplate, InterfaceSecurity $login) {
$this->view = new BackendView($login->getSecurityModel());
$this->request = $request;
$this->messageResolver = AppFactory::getMessageResolver();
$this->presentDao = new PresentDao($jdbcTemplate);
}

public function process() {
$present = null;
if (!empty($this->request['get']['presentId'])) {
$presentId = EscapeHelper::escape($this->request['get']['presentId'], EscapeHelper::TARGET_NUMBER);
$present = $this->presentDao->getById($presentId);
}
$targetLocation = null;
if ($present != null && $present->getStatus() != 1) {
$result = $this->presentDao->delete($presentId);
if ($result) {
$targetLocation = APP_URL . "?mapping=admin&success=deletePresent&args=" . base64_encode("presentId=$presentId&result=1");
} else {
$targetLocation = APP_URL . "?mapping=admin&success=deletePresent&args=" . base64_encode("presentId=$presentId&result=2");
}
} else {
$targetLocation = APP_URL . "?mapping=admin&success=deletePresent&args=" . base64_encode("presentId=$presentId&result=2");
}
header("Location: $targetLocation");
}

public function display() {
return $this->view->loadTemplate();
}

}
Loading

0 comments on commit 440645b

Please sign in to comment.