Commit 336a9952 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Generic setup for a development startpoint. done by RO

parent 7dc542b3
/configUser.php
/.idea
/node_modules
/packages
......
......@@ -4,4 +4,5 @@
* User: ep
* Date: 12/23/15
* Time: 6:17 PM
*/
\ No newline at end of file
*/
<?php
/**
* Created by PhpStorm.
* User: Rafael Ostertag <rafael.ostertag@math.uzh.ch>
* Date: 2/9/15
* Time: 12:45 PM
*/
define('DBUSER', '<USERNAME>');
define('DBSERVER', '<HOST>');
define('DBPW', '<PASSWORD>');
define('DB', '<DEVELOPMENT_DATABASE>');
define('TESTDB', '<TEST_DATABASE>');
?>
<?php
/**
* Created by PhpStorm.
* User: Rafael Ostertag <rafael.ostertag@math.uzh.ch>
* Date: 2/9/15
* Time: 12:45 PM
*/
define('DBUSER', 'crose');
define('DBSERVER', 'localhost');
define('DBPW', 'GWtrLMx67S4wdFBV');
define('DB', 'crose_qfq_jqw');
define('TESTDB', 'crose_qfq_jqw_phpunit');
define('SESSIONNAME', 'qfq');
?>
<?php
/**
* Created by PhpStorm.
* @author: crose
* Date: 3/10/15
* Time: 9:48 AM
*
* $Id: efb1ee01c8487b213d49f2576b914cc0ec0dbc66 $
*/
namespace qfq;
/**
* Abstract class for retrieval of configuration options.
*
* @package qfq
*/
abstract class Config {
/**
* Get the PHP Session name
*
* @return string PHP Session name
*/
abstract public function getSessionName();
/**
* Get the database user name
*
* @return string database user name
*/
abstract public function getDatabaseUserName();
/**
* Get the database user password
*
* @return string database user password
*/
abstract public function getDatabaseUserPassword();
/**
* Get the MySQL DSN string.
*
* @return string MySQL DSN string.
*/
public function getMysqlDSNString() {
return 'mysql:host=' . $this->getDatabaseHost() . ';dbname=' . $this->getDatabaseName();
}
/**
* Get the database server host name
*
* @return string host name of the database server
*/
abstract public function getDatabaseHost();
/**
* Get the database name
*
* @return string database name
*/
abstract public function getDatabaseName();
/**
* Get the MySQL DSN string for the test database
*
* @return string MySQL DSN string.
*/
public function getMysqlDSNStringTestDB() {
return 'mysql:host=' . $this->getDatabaseHost() . ';dbname=' . $this->getTestDatabaseName();
}
/**
* Get the test database name
*
* @return string test database name
*/
abstract public function getTestDatabaseName();
}
<?php
/**
* @author Rafael Ostertag <rafael.ostertag@math.uzh.ch>
*/
namespace qfq;
require_once(__DIR__ . '/Config.php');
require_once(__DIR__ . '/../configUser.php');
/**
* Class ConfigFile
*
* Returns the configuration values based on values stored in configUser.php.
* @package qfq
*/
class ConfigFile extends Config {
/**
* Get the PHP Session name
*
* @return string PHP Session name
*/
public function getSessionName() {
return SESSIONNAME;
}
/**
* Get the database server host name
*
* @return string host name of the database server
*/
public function getDatabaseHost() {
return DBSERVER;
}
/**
* Get the database user name
*
* @return string database user name
*/
public function getDatabaseUserName() {
return DBUSER;
}
/**
* Get the database user password
*
* @return string database user password
*/
public function getDatabaseUserPassword() {
return DBPW;
}
/**
* Get the database name
*
* @return string database name
*/
public function getDatabaseName() {
return DB;
}
/**
* Get the test database name
*
* @return string test database name
*/
public function getTestDatabaseName() {
return TESTDB;
}
}
......@@ -9,9 +9,31 @@
namespace qfq;
class Form
{
class Form {
protected $config = null;
// protected $store = null;
// protected $formElements = null;
// protected $userLog = null;
/*
*
*/
public function __construct() {
/*
* TODO:
* Preparation: setup logging, database access, record locking
* fill stores
* Check permission_create / permission_update
* Multi: iterate over all records, Single: activate record
* Check mode: Load | Save
* doActions 'Before'
* Do all FormElements
* doActions 'After'
*/
}
public function toHTML() {
return "Hello World";
return "Hello World from Class Form";
}
}
\ No newline at end of file
......@@ -7,142 +7,26 @@
*/
require_once(__DIR__ . '/../qfq/Form.php');
use qfq\exceptions\UserException;
use qfq\exceptions\CodeException;
function loadForm() {
$form = new \qfq\Form();
//
// ...
//
// return $form->toHTML();
// or
// echo $form->toHTML();
//
echo <<<EOT
<div class="container-fluid">
<!-- Nav tabs -->
<ul id="myTabs" class="nav nav-pills" role="tablist">
<li role="presentation" class="active"><a href="#form-normal" data-toggle="tab">Form: normal</a>
</li>
<li role="presentation"><a href="#form-horizontal" data-toggle="tab">Form: horizontal</a>
</li>
<li role="presentation"><a href="#checkboxes" data-toggle="tab">Checkbox</a>
</li>
<li role="presentation"><a href="#radios" data-toggle="tab">Radios</a>
</li>
<li role="presentation"><a href="#inputfields" data-toggle="tab">Input</a>
</li>
<li role="presentation"><a href="#accordion" data-toggle="tab">Accordion</a>
</li>
<li role="presentation"><a href="#inline-container" data-toggle="tab">Horizontal Container</a>
</li>
<li role="presentation"><a href="#jqw-grid" data-toggle="tab">JQWdidget Grid</a></li>
</ul>
<!-- Tab panes -->
<!-- form normal -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="form-normal">
<form>
<div class="form-group">
<label for="personName">Name</label>
<input type="text" class="form-control" id="personName" placeholder="Name"
title="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
data-toggle="tooltip" data-placement="bottom">
<p class="help-block">Name of the person.</p>
</div>
<div class="form-group">
<label for="personFirstname">First name</label>
<input type="text" class="form-control" id="personFirstname" placeholder="First name"
title="Tooltip" data-toggle="tooltip" data-placement="left">
<p class="help-block">First name of the person.</p>
</div>
require_once(__DIR__ . '/../exceptions/UserException.php');
require_once(__DIR__ . '/../exceptions/CodeException.php');
<div class="form-group">
<label for="personEmail">Email</label>
<input type="email" class="form-control" id="personEmail" placeholder="Email" title="Tooltip"
data-toggle="tooltip" data-placement="right">
//TODO: unit tests fuer alle abgefangenen Exceptions
<p class="help-block">Email of the person.</p>
</div>
<!-- checkbox -->
<div class="form-group">
<fieldset>
<legend>Title Checkbox</legend>
<div class="checkbox">
<label>
<input type="checkbox">label 1
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox">label 2
</label>
</div>
</fieldset>
</div>
<!--radio -->
<div class="form-group">
<fieldset>
<legend>Title Radio</legend>
<div class="radio">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios4" value="option1" checked>
Option one is this and that&mdash;be sure to include why it's great
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios5" value="option2">
Option two can be something else and selecting it will deselect option one
</label>
</div>
<div class="radio disabled">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios6" value="option3" disabled>
Option three is disabled
</label>
</div>
</fieldset>
</div>
<!-- check for width adjustement: http://getbootstrap.com/css/#forms-->
<div class="form-group">
<label for="select1">Selectbox</label>
<select class="form-control" id="select1" title="Tooltip" data-toggle="tooltip"
data-placement="bottom">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
<!--textarea-->
<div class="form-group">
<label for="textarea">Textarea</label>
<textarea class="form-control" rows="3" title="Tooltip" data-toggle="tooltip"
data-placement="bottom" id="textarea1"></textarea>
</div>
<!--
<!--upload-->
<div class="form-group">
<label for="exampleInputFile1">File input</label>
<input type="file" id="exampleInputFile1">
function loadForm() {
<p class="help-block">Example block-level help text here.</p>
</div>
</form>
</div>
</div>
</div>
EOT;
try {
$form = new \qfq\Form();
echo $form->toHTML();
} catch (UserException $e) {
echo $e->formatMessage();
} catch (CodeException $e) {
echo $e->formatMessage();
} catch (Exception $e) {
echo "Generic Exception: " . $e->getMessage();
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: crose
* Date: 12/23/15
* Time: 7:11 PM
*/
require_once(__DIR__ . '/../../qfq/Form.php');
class FormTest extends PHPUnit_Framework_TestCase {
public function testToHTML() {
$form = new qfq\Form();
$this->assertEquals("Hello World", $form->toHTML());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment