123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <?php
- // $event = new Event();
- // $event->setTime(time());
- // $event->setRepeat(2);
- // $event->setContent($sayHello);
- // $event->save();
-
- class Event extends SQLiteEntity{
- protected $id,$name,$content,$year,$month,$day,$hour,$minut,$repeat,$recipients,$state;
- protected $TABLE_NAME = 'event';
- protected $CLASS_NAME = 'Event';
- protected $object_fields =
- array(
- 'id'=>'key',
- 'name'=>'string',
- 'content'=>'longstring',
- 'year'=>'string',
- 'month'=>'string',
- 'day'=>'string',
- 'hour'=>'string',
- 'minut'=>'string',
- 'repeat'=>'string',
- 'state'=>'int',
- 'recipients'=>'longstring'
- );
-
- function __construct(){
- parent::__construct();
- // $this->time = time();
- // $this->repeat = '1';
- // $this->name = 'Evenement sans titre du '.date('d/m/Y H:i:s');
- // $this->setRecipients(array());
- }
-
- function setId($id){
- $this->id= $id;
- }
- function getId(){
- return $this->id;
- }
- function setState($state){
- $this->state= $state;
- }
- function getState(){
- return $this->state;
- }
- function setYear($year){
- $this->year= $year;
- }
- function getYear(){
- return $this->year;
- }
- function setMonth($month){
- $this->month= $month;
- }
- function getMonth(){
- return $this->month;
- }
- function setDay($day){
- $this->day= $day;
- }
- function getDay(){
- return $this->day;
- }
- function setHour($hour){
- $this->hour= $hour;
- }
- function getHour(){
- return $this->hour;
- }
- function setMinut($minut){
- $this->minut= $minut;
- }
- function getMinut(){
- return $this->minut;
- }
-
- function setName($name){
- $this->name= $name;
- }
- function getName(){
- return $this->name;
- }
- function setContent($content){
- $this->content= json_encode($content);
- }
- function getContent(){
- return json_decode($this->content,true);
- }
- function setRepeat($repeat){
- $this->repeat= $repeat;
- }
- function getRepeat(){
- return $this->repeat;
- }
- function addRecipient($recipient){
- $recipients = $this->getRecipients();
- $recipients[] = $recipient;
- $this->setRecipients($recipients);
- }
- function setRecipients($recipients){
- $this->recipients= json_encode($recipients);
- }
- function getRecipients(){
- $rec = json_decode($this->recipients,true);
- return is_array($rec)?$rec:array();
- }
- public static function emit($event, $data) {
- if(isset($GLOBALS['events'][$event])) {
- foreach($GLOBALS['events'][$event] as $functionName) {
- call_user_func_array($functionName, $data);
- }
- }
- }
- public static function on($event, $functionName) {
- $GLOBALS['events'][$event][] = $functionName;
- }
- public static function announce($event, $comment,$dataDescription) {
- $GLOBALS['eventsDictionnary'][$event]['comment'] = $comment;
- $GLOBALS['eventsDictionnary'][$event]['data'] = $dataDescription;
- }
- public static function availables($event, $comment) {
- return $GLOBALS['eventsDictionnary'];
- }
- }
- ?>
|