Created Development (markdown)

master
El RIDO 9 years ago
parent cc47bcef58
commit 422853e02d

@ -0,0 +1,57 @@
This fork of the original ZeroBin of Sebsauvage was refactured into an object oriented MVC structure. The `index.php` only includes an autoloader and starts the application by instancing a `zerobin` object.
## Structure
The main code or **controller** is found in `lib/zerobin.php`.
The data storage **models** are in the `lib/zerobin/` folder.
The **view** is still implemented using the RainTPL library (`lib/RainTPL.php`) using a template file located in the `tpl/` folder.
Any option that not every server administrator might want to use or provide should be implemented with **configuration** options in the file `cfg/conf.ini`.
## Unit Tests
For unit tests of the php code the folder `tst/` should be used. Apart from helping to implement new features correctly it should help us to keep regressions at bay. By default a code coverage report is generated after phpunit is run, the one of the latest release is [publicly available](https://zerobin.dssr.ch/coverage-report/).
In order to run these tests, you will need the following packages and its dependencies:
* phpunit
* php5-gd
* php5-sqlite
* php5-xdebug
Example installation for Debian and Ubuntu:
$ sudo aptitude install phpunit php5-mysql php5-xdebug
To run the tests, just change into the `tst/` directory and run phpunit:
$ cd ZeroBin/tst
$ phpunit
## Data Model
If you want to create your own data models, you might want to know how the arrays, that you have to store, look like:
public function create($pasteid, $paste)
{
$pasteid = substr(hash('md5', $paste['data']), 0, 16);
$paste['data'] // text
$paste['meta']['postdate'] // int UNIX timestamp
$paste['meta']['expire_date'] // int UNIX timestamp
$paste['meta']['opendiscussion'] // true (if false it is unset)
$paste['meta']['burnafterreading'] // true (if false it is unset; if true, then opendiscussion is unset)
}
public function createComment($pasteid, $parentid, $commentid, $comment)
{
$pasteid // the id of the paste this comment belongs to
$parentid // the id of the parent of this comment, may be the paste id itself
$commentid = substr(hash('md5', $paste['data']), 0, 16);
$comment['data'] // text
$comment['meta']['nickname'] // text or null (if anonymous)
$comment['meta']['vizhash'] // text or null (if anonymous)
$comment['meta']['postdate'] // int UNIX timestamp
}
Loading…
Cancel
Save