2010-09-15 16:55:54 +02:00
< ? php
2010-09-20 11:40:27 +02:00
class todo extends Module {
2010-10-05 17:30:04 +02:00
protected $moduleTitle = 'Todo List' ;
2010-09-27 12:48:53 +02:00
2010-09-20 11:40:27 +02:00
protected static $paramsList = array (
'visibility' ,
'x' ,
'y'
);
2010-09-27 12:48:53 +02:00
const TODO_FILE = 'db/todoist.xml' ;
2010-10-05 17:30:04 +02:00
2010-09-15 16:55:54 +02:00
private $token ;
private $project_name ;
private $project_id ;
2010-10-05 17:30:04 +02:00
2010-09-15 16:55:54 +02:00
public function __construct ( $params ){
2010-10-05 17:30:04 +02:00
parent :: __construct ( __CLASS__ , $params );
}
public function build (){
2010-09-27 12:48:53 +02:00
echo '<script type="text/javascript" src="' . $this -> pathToModule . 'js/' . $this -> moduleName . ' . js " ></script>
< link rel = " stylesheet " href = " '. $this->pathToModule .'css/'. $this->moduleName .'.css " type = " text/css " /> ' ;
if ( $xmla = simplexml_load_file ( $this -> pathToModule . self :: TODO_FILE )){
2010-09-15 16:55:54 +02:00
$this -> setToken ( $xmla -> token );
$this -> setProjectName ( $xmla -> name );
$this -> setProjectId ( $xmla -> id );
2010-10-05 17:30:04 +02:00
echo '<div id="todo" style="top:' . $this -> getParam ( 'y' ) . '; left :' . $this -> getParam ( 'x' ) . ';">' ;
2010-09-15 16:55:54 +02:00
if ( $this -> token == null || $this -> project_id == null )
2010-09-27 12:48:53 +02:00
echo 'Impossible de trouver votre configuration. <a href="' . $this -> pathToModule . 'includes/install-todoist.php">Cliquez ici</a> pour la mettre en place.</div>' ;
2010-09-15 16:55:54 +02:00
else {
$token = $xmla -> token ;
$id = $xmla -> id ;
2010-09-27 12:48:53 +02:00
echo '</div><script type="text/javascript" src="' . $this -> pathToModule . 'js/getUncompletedTasks.php?token=' . $token . '&id=' . $id . '"></script>' ;
2010-09-15 16:55:54 +02:00
}
2010-09-17 15:38:57 +02:00
echo ' < script >
$ ( document ) . ready ( function (){
2010-09-27 12:48:53 +02:00
$ ( \ ' #todo\').resizable();
2010-09-17 15:38:57 +02:00
}); </ script > ' ;
2010-09-15 16:55:54 +02:00
} else {
echo 'baaaaad persistance...' ;
2010-10-05 17:30:04 +02:00
}
2010-09-15 16:55:54 +02:00
}
private function setToken ( $token ){
if ( $token == '' || $token == null )
$this -> token = null ;
else
$this -> token = $token ;
}
private function setProjectName ( $name ){
if ( $name == '' || $name == null )
$this -> project_name = null ;
else
$this -> project_name = $name ;
}
private function setProjectId ( $id ){
if ( $id == '' || $id == null )
$this -> project_id = null ;
else
$this -> project_id = $id ;
}
}