Change <? to <?php and add some formatting

This commit is contained in:
Clement Desmidt 2016-11-17 22:16:26 +01:00
parent 2d5ba7fb8d
commit fb71f8c112
27 changed files with 270 additions and 296 deletions

View File

@ -1,4 +1,4 @@
<? <?php
$number = $_POST['number']; $number = $_POST['number'];
$url = $_POST['url']; $url = $_POST['url'];
$name = $_POST['name']; $name = $_POST['name'];
@ -22,4 +22,3 @@ $newnote->addChild('url', $url);
$xmla->asXML('../db/blog_links.xml'); $xmla->asXML('../db/blog_links.xml');
echo $nb; echo $nb;
?>

View File

@ -1,4 +1,4 @@
<? <?php
$options = array(); $options = array();
$module =''; $module ='';
include '../class/AccueilModules.php'; include '../class/AccueilModules.php';
@ -9,5 +9,4 @@ foreach($_POST as $module => $valeur){
} }
//AccueilModules::updateModule($module, array('visibility'=>$valeur)); //AccueilModules::updateModule($module, array('visibility'=>$valeur));
} }
echo "1" echo "1";
?>

View File

@ -1,4 +1,4 @@
<? <?php
// Error reporting // Error reporting
error_reporting(E_ALL^E_NOTICE); error_reporting(E_ALL^E_NOTICE);

View File

@ -1,16 +1,18 @@
<?php <?php
function __autoload($class) function __autoload($class)
{ {
$BASE_DIR = $_SERVER['DOCUMENT_ROOT'].'/test/trunk3/'; // à modifier selon la configuration souhaitée $BASE_DIR = $_SERVER['DOCUMENT_ROOT'] . '/accueil/'; // à modifier selon la configuration souhaitée
set_include_path($BASE_DIR); set_include_path($BASE_DIR);
$path = 'modules/'.$class; $path = 'modules/' . $class;
if(file_exists($path . DIRECTORY_SEPARATOR . ucfirst($class) . '.php') || file_exists($BASE_DIR . $path . DIRECTORY_SEPARATOR . ucfirst($class) . '.php')){ if (file_exists($path . DIRECTORY_SEPARATOR . ucfirst($class) . '.php') || file_exists($BASE_DIR . $path . DIRECTORY_SEPARATOR . ucfirst($class) . '.php')) {
require_once($path . DIRECTORY_SEPARATOR . ucfirst($class) . '.php'); require_once($path . DIRECTORY_SEPARATOR . ucfirst($class) . '.php');
}else{ } else {
require_once('class/' . $class . '.php'); require_once('class/' . $class . '.php');
} }
} }
class AccueilModules {
class AccueilModules
{
const CONFIG_FILE = 'db/config.xml'; const CONFIG_FILE = 'db/config.xml';
private $modules = array(); private $modules = array();
@ -19,13 +21,14 @@ class AccueilModules {
* Constructeur * Constructeur
* Initialise le XML de conf générale * Initialise le XML de conf générale
*/ */
function __construct(){ function __construct()
if($config = simplexml_load_file(self::CONFIG_FILE)){ {
if ($config = simplexml_load_file(self::CONFIG_FILE)) {
$config_xml = $config->item; $config_xml = $config->item;
foreach($config_xml as $item){ foreach ($config_xml as $item) {
$this->modules["$item[id]"] = $item; $this->modules["$item[id]"] = $item;
} }
}else{ } else {
echo 'Impossible de trouver le fichier de configuration.'; echo 'Impossible de trouver le fichier de configuration.';
} }
} }
@ -34,16 +37,18 @@ class AccueilModules {
* *
* Initialise les modules activés uniquement * Initialise les modules activés uniquement
*/ */
function getModules(){ function getModules()
foreach($this->modules as $module=>$moduleConf){ {
if(file_exists('modules/'.$module.'/'.ucfirst($module).'.php') && $moduleConf->visibility == "true"){ foreach ($this->modules as $module => $moduleConf) {
if (file_exists('modules/' . $module . '/' . ucfirst($module) . '.php') && $moduleConf->visibility == "true") {
$params = array(); $params = array();
foreach($moduleConf as $confParam){ foreach ($moduleConf as $confParam) {
$params[$confParam->getName()] = "$confParam"; $params[$confParam->getName()] = "$confParam";
} }
$module = new $module($params); $module = new $module($params);
if(is_subclass_of($module,'Module')) if (is_subclass_of($module, 'Module')) {
$module->build(); $module->build();
}
// require 'modules/'.$module.'/'.ucfirst($module).'.php'; // require 'modules/'.$module.'/'.ucfirst($module).'.php';
// call_user_func(array($module, "start"), $module, $params); // call_user_func(array($module, "start"), $module, $params);
} }
@ -54,13 +59,14 @@ class AccueilModules {
* *
* @return le module donné avec ses paramètres actuellement présent en conf * @return le module donné avec ses paramètres actuellement présent en conf
*/ */
public static function getModule($module){ public static function getModule($module)
if($config = simplexml_load_file('../'.self::CONFIG_FILE)){ {
if ($config = simplexml_load_file('../' . self::CONFIG_FILE)) {
$config_xml = $config->item; $config_xml = $config->item;
foreach($config_xml as $item){ foreach ($config_xml as $item) {
if($item["id"] == $module){ if ($item["id"] == $module) {
$params = array(); $params = array();
foreach($item as $confParam){ foreach ($item as $confParam) {
$params[$confParam->getName()] = "$confParam"; $params[$confParam->getName()] = "$confParam";
} }
//require '../modules/'.$module.'/'.ucfirst($module).'.php'; //require '../modules/'.$module.'/'.ucfirst($module).'.php';
@ -69,7 +75,7 @@ class AccueilModules {
} }
echo "object not found"; echo "object not found";
return; return;
}else{ } else {
echo "bad persistance"; echo "bad persistance";
return; return;
} }
@ -80,16 +86,17 @@ class AccueilModules {
* *
* Construit et insère le menu de changement de config * Construit et insère le menu de changement de config
*/ */
function buildConfigMenu(){ function buildConfigMenu()
{
echo '<a href="#config" id="config-menu"><img src="images/interface/config.png" /></a> echo '<a href="#config" id="config-menu"><img src="images/interface/config.png" /></a>
<div style="display:none;"> <div style="display:none;">
<div id="config"> <div id="config">
<form id="config_form" action="" method="post"> <form id="config_form" action="" method="post">
<h3>Modules configuration</h3><br/>'; <h3>Modules configuration</h3><br/>';
foreach($this->modules as $module=>$moduleConf){ foreach ($this->modules as $module => $moduleConf) {
echo $module.' module : <input type="radio" name="'.$module.'_group" value="true"'; echo $module . ' module : <input type="radio" name="' . $module . '_group" value="true"';
if ($moduleConf->visibility == "true") echo " checked"; if ($moduleConf->visibility == "true") echo " checked";
echo '/>activé&nbsp;&nbsp;<input type="radio" name="'.$module.'_group" value="false"'; echo '/>activé&nbsp;&nbsp;<input type="radio" name="' . $module . '_group" value="false"';
if ($moduleConf->visibility == "false") echo " checked"; if ($moduleConf->visibility == "false") echo " checked";
echo '/>desactivé<br/><br/>'; echo '/>desactivé<br/><br/>';
} }
@ -107,8 +114,8 @@ class AccueilModules {
$(this).replaceWith(\'<img src="images/interface/ajax_load.gif" style="margin:30px auto;display:block" />\'); $(this).replaceWith(\'<img src="images/interface/ajax_load.gif" style="margin:30px auto;display:block" />\');
var data3 = {'; var data3 = {';
$temp = ''; $temp = '';
foreach($this->modules as $module=>$moduleConf){ foreach ($this->modules as $module => $moduleConf) {
$temp .= '\''.$module.'\' : $(\'input[type=radio][name='.$module.'_group]:checked\').attr(\'value\'),'; $temp .= '\'' . $module . '\' : $(\'input[type=radio][name=' . $module . '_group]:checked\').attr(\'value\'),';
} }
echo substr($temp, 0, -1); echo substr($temp, 0, -1);
echo '}; echo '};
@ -121,7 +128,8 @@ class AccueilModules {
</script>'; </script>';
} }
public static function retrieveModuleParams($module){ public static function retrieveModuleParams($module)
{
$temp = new $module; $temp = new $module;
return $temp->getParamsList(); return $temp->getParamsList();
} }
@ -132,44 +140,44 @@ class AccueilModules {
*/ */
public static function addModule($file, $name) public static function addModule($file, $name)
{ {
if($config = simplexml_load_file('../'.self::CONFIG_FILE)){ if ($config = simplexml_load_file('../' . self::CONFIG_FILE)) {
foreach($config->item as $item){ foreach ($config->item as $item) {
if($item['id'] == $name) if ($item['id'] == $name)
exit ('module déjà présent !'); exit ('module déjà présent !');
} }
} }
if(class_exists('ZipArchive')){ if (class_exists('ZipArchive')) {
$zip = new ZipArchive; $zip = new ZipArchive;
$res = $zip->open($file); $res = $zip->open($file);
if ($res === TRUE) { if ($res === TRUE) {
$zip->extractTo('../modules/'); $zip->extractTo('../modules/');
$zip->close(); $zip->close();
if(!file_exists('../modules/'.$name.'/'.ucfirst($name).'.php')) if (!file_exists('../modules/' . $name . '/' . ucfirst($name) . '.php'))
exit ('L\'extraction n\'a pas fonctionné...'); exit ('L\'extraction n\'a pas fonctionné...');
else{ else {
unlink ($file); unlink($file);
require '../modules/'.$name.'/'.ucfirst($name).'.php'; require '../modules/' . $name . '/' . ucfirst($name) . '.php';
if($config = simplexml_load_file('../'.self::CONFIG_FILE)){ if ($config = simplexml_load_file('../' . self::CONFIG_FILE)) {
$newItem = $config->addChild('item'); $newItem = $config->addChild('item');
$newItem->addAttribute('id', $name); $newItem->addAttribute('id', $name);
//$params = call_user_func(array($name, 'getParamList')); //$params = call_user_func(array($name, 'getParamList'));
$params = self::retrieveModuleParams($name); $params = self::retrieveModuleParams($name);
foreach($params as $param){ foreach ($params as $param) {
if($param == 'visibility') if ($param == 'visibility')
$newItem->AddChild($param, 'true'); $newItem->AddChild($param, 'true');
else else
$newItem->AddChild($param, '0'); $newItem->AddChild($param, '0');
} }
$config->asXML('../'.self::CONFIG_FILE); $config->asXML('../' . self::CONFIG_FILE);
echo 'Module enregistré. Vous pouvez revenir à la page d\'accueil'; echo 'Module enregistré. Vous pouvez revenir à la page d\'accueil';
}else{ } else {
exit ('L\'enregistrement dans le menu a échoué...'); exit ('L\'enregistrement dans le menu a échoué...');
} }
} }
} else { } else {
exit ('failed, code:' . $res); exit ('failed, code:' . $res);
} }
}else{ } else {
exit ('Votre serveur ne peut installer les modules automatiquement. Merci de passer par votre client FTP habituel ou d\'ajouter la classe ZipArchive à votre serveur PHP'); exit ('Votre serveur ne peut installer les modules automatiquement. Merci de passer par votre client FTP habituel ou d\'ajouter la classe ZipArchive à votre serveur PHP');
} }
} }

View File

@ -11,7 +11,7 @@
<title>Ma Page d'accueil</title> <title>Ma Page d'accueil</title>
</head> </head>
<body> <body>
<? <?php
include "class/AccueilModules.php"; include "class/AccueilModules.php";
$index = new AccueilModules(); $index = new AccueilModules();
$index->getModules(); $index->getModules();

View File

@ -1,5 +1,6 @@
<?php <?php
class blogs extends Module { class blogs extends Module
{
protected $moduleTitle = 'Blogs BD'; protected $moduleTitle = 'Blogs BD';
protected $paramsList = array( protected $paramsList = array(
'visibility', 'visibility',

View File

@ -1,4 +1,4 @@
<? <?php
$url = $_POST['newLink']; $url = $_POST['newLink'];
if($url == '' || !isset($_POST['newLink'])) if($url == '' || !isset($_POST['newLink']))
header('Location: index.php'); header('Location: index.php');
@ -18,7 +18,7 @@ header('Location: index.php');
$(document).ready(function(){ $(document).ready(function(){
$('.choose').click(function(){ $('.choose').click(function(){
var id = $(this).attr('id'); var id = $(this).attr('id');
var url = "<?=$url?>"; var url = "<?php echo $url; ?>";
var name = 'test'; var name = 'test';
$.post('addSiteXML.php', {number: id, url: url, name: name}, function(data){ $.post('addSiteXML.php', {number: id, url: url, name: name}, function(data){
document.location.href="index.php" document.location.href="index.php"
@ -30,7 +30,7 @@ $('.choose').click(function(){
</head> </head>
<body> <body>
<? <?php
echo 'URL : '.$url.'<br/>'; echo 'URL : '.$url.'<br/>';
require('blogs_last_post.php'); require('blogs_last_post.php');
$opts = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_TIMEOUT => 10); $opts = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_TIMEOUT => 10);

View File

@ -1,4 +1,4 @@
<? <?php
require('blogs_last_post.php'); require('blogs_last_post.php');
$opts = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_TIMEOUT => 10, CURLOPT_CONNECTTIMEOUT => 10); $opts = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_TIMEOUT => 10, CURLOPT_CONNECTTIMEOUT => 10);
$blogs = new Blogs_last_post(); $blogs = new Blogs_last_post();

View File

@ -1,4 +1,4 @@
<? <?php
require('CURL.php'); require('CURL.php');
class Blogs_last_post extends CURL{ class Blogs_last_post extends CURL{
@ -30,14 +30,14 @@ function getResult()
} }
public function getLinks(){ public function getLinks(){
if($linksXML = simplexml_load_file('../db/blog_links.xml')){ if($linksXML = @simplexml_load_file('../db/blog_links.xml')){
foreach($linksXML->link as $individualLink){ foreach($linksXML->link as $individualLink){
$this->link[] = array('name'=>$individualLink->name, 'url'=>$individualLink->url, 'number'=>$individualLink->number); $this->link[] = array('name'=>$individualLink->name, 'url'=>$individualLink->url, 'number'=>$individualLink->number);
} }
return $this->link; return $this->link;
} }
else else
return; return [];
} }
function getTitles() function getTitles()
@ -70,7 +70,7 @@ function getTitle($result = null, $url = null)
if(isset($title[1])) if(isset($title[1]))
return $title[1]; return $title[1];
else else
return 'Erreur : pas de titre de blog trouvé.'; return 'Erreur : pas de titre de blog trouv<EFBFBD>.';
} }
} }

View File

@ -1,5 +1,6 @@
<?php <?php
class clockAdvanced extends Module { class clockAdvanced extends Module
{
protected $moduleTitle = 'Horloge Avancée'; protected $moduleTitle = 'Horloge Avancée';
protected $paramsList = array( protected $paramsList = array(
'visibility', 'visibility',
@ -20,7 +21,7 @@ class clockAdvanced extends Module {
<link rel="stylesheet" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />'; <link rel="stylesheet" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />';
echo '<div class="jclockAdvanced" id="clockAdvanced" style="left:'.$this->getParam('x').'; top:'.$this->getParam('y').';"></div>'; echo '<div class="jclockAdvanced" id="clockAdvanced" style="left:'.$this->getParam('x').'; top:'.$this->getParam('y').';"></div>';
$options = ''; $options = '';
foreach (self::$paramsList as $paramName){ foreach ($this->paramsList as $paramName){
if($this->getParam($paramName) != null) if($this->getParam($paramName) != null)
$options .= $paramName.' : "'.$this->getParam($paramName).'",'; $options .= $paramName.' : "'.$this->getParam($paramName).'",';
} }

View File

@ -1,4 +1,4 @@
<? <?php
$reserve = $_POST['reserve']; $reserve = $_POST['reserve'];
$doc = new DOMDocument; $doc = new DOMDocument;

View File

@ -1,4 +1,4 @@
<? <?php
if($links_xml = simplexml_load_file("../db/links.xml")){ if($links_xml = simplexml_load_file("../db/links.xml")){
$links = $links_xml->reserve; $links = $links_xml->reserve;
foreach($links as $label){ foreach($links as $label){

View File

@ -1,4 +1,4 @@
<? <?php
$reserve = $_POST['reserve']; $reserve = $_POST['reserve'];
$doc = new DOMDocument; $doc = new DOMDocument;

View File

@ -1,4 +1,4 @@
<? <?php
$label = $_POST['label']; $label = $_POST['label'];
$order = $_POST['order']; $order = $_POST['order'];
$itemMoved = $_POST['itemMoved']; $itemMoved = $_POST['itemMoved'];

View File

@ -1,5 +1,7 @@
<?php <?php
class news extends Module{
class news extends Module
{
protected $moduleTitle = 'Google News'; protected $moduleTitle = 'Google News';
protected $paramsList = array( protected $paramsList = array(
'visibility', 'visibility',
@ -7,13 +9,15 @@ class news extends Module{
'y' 'y'
); );
public function __construct($params){ public function __construct($params)
{
parent::__construct(__CLASS__, $params); parent::__construct(__CLASS__, $params);
} }
public function build(){ public function build()
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" />'; 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" />';
echo '<script type="text/javascript" src="http://www.google.com/jsapi"></script> echo '<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<div id="news" style="top:' . $this->getParam('y') . '; left: ' . $this->getParam('x') . ';"></div> <div id="news" style="top:' . $this->getParam('y') . '; left: ' . $this->getParam('x') . ';"></div>
<script type="text/javascript"> <script type="text/javascript">

View File

@ -1,4 +1,4 @@
<?// Escaping the input data: <?php // Escaping the input data:
$rid = $_POST['id']; $rid = $_POST['id'];
$explodeid = explode("-",$rid); $explodeid = explode("-",$rid);
@ -22,4 +22,3 @@ $xmla->asXML('../db/notes.xml');
$target++; $target++;
echo $target; echo $target;
?>

View File

@ -1,4 +1,5 @@
<?// Escaping the input data: <?php
// Escaping the input data:
$body = $_POST['body']; $body = $_POST['body'];
$color = $_POST['color']; $color = $_POST['color'];
@ -26,4 +27,3 @@ $newnote->addChild('left', '0');
$xmla->asXML('../db/notes.xml'); $xmla->asXML('../db/notes.xml');
echo $nb; echo $nb;
?>

View File

@ -3,4 +3,4 @@
<note id="2"><text>Test de post-it.</text><color>green</color><zindex>1</zindex><top>153</top><left>53</left></note><note id="7"><text>/!\ C'est bien fait ? :)</text><color>yellow</color><zindex>1</zindex><top>85</top><left>1038</left></note><note id="10"><text>Des améliorations ?</text><color>yellow</color><zindex>1</zindex><top>264</top><left>1038</left></note></Notes> <note id="2"><text>Test de post-it.</text><color>green</color><zindex>1</zindex><top>153</top><left>53</left></note><note id="7"><text>/!\ C'est bien fait ? :)</text><color>yellow</color><zindex>1</zindex><top>68</top><left>252</left></note><note id="10"><text>Des améliorations ?</text><color>yellow</color><zindex>2</zindex><top>264</top><left>247</left></note></Notes>

View File

@ -1,8 +1,6 @@
<?php $nb = 0; <?php $nb = 0;
$notes = simplexml_load_file('modules/notes/db/notes.xml'); $notes = simplexml_load_file('modules/notes/db/notes.xml');
foreach($notes as $test){$nb++;} foreach($notes as $test){$nb++;}
for($i=0; $i<$nb; $i++){?> for($i=0; $i<$nb; $i++){ ?>
<div class="note <?echo $notes->note[$i]->color;?>" style="position:absolute; left:<? echo $notes->note[$i]->left;?>; top:<? echo $notes->note[$i]->top;?>;z-index:<? echo $notes->note[$i]->zindex;?>;"><div class="delete" id="r-<?echo $notes->note[$i]['id'];?>"></div><? echo $notes->note[$i]->text;?><br/><span class="data"><?echo $notes->note[$i]['id'];?></span></div> <div class="note <?php echo $notes->note[$i]->color;?>" style="position:absolute; left:<?php echo $notes->note[$i]->left;?>; top:<?php echo $notes->note[$i]->top;?>;z-index:<?php echo $notes->note[$i]->zindex;?>;"><div class="delete" id="r-<?php echo $notes->note[$i]['id'];?>"></div><?php echo $notes->note[$i]->text;?><br/><span class="data"><?php echo $notes->note[$i]['id'];?></span></div>
<?}?> <?php }

View File

@ -1,21 +1 @@
<? <?php $xmla = simplexml_load_file('../db/todoist.xml'); if (isset($_POST['token'])) { $token = trim($_POST['token']); $xmla->addChild("token", $token); $xmla->asXML('../db/todoist.xml'); echo "ok"; } else if (isset($_POST['name']) && isset($_POST['id'])) { $name = trim($_POST['name']); $id = trim($_POST['id']); $xmla->addChild("name", $name); $xmla->addChild("id", $id); $xmla->asXML('../db/todoist.xml'); echo "ok"; }
$xmla = simplexml_load_file('../db/todoist.xml');
if(isset($_POST['token'])){
$token = trim($_POST['token']);
$xmla->addChild("token", $token);
$xmla->asXML('../db/todoist.xml');
echo "ok";
}else if(isset($_POST['name']) && isset($_POST['id'])){
$name = trim($_POST['name']);
$id = trim($_POST['id']);
$xmla->addChild("name", $name);
$xmla->addChild("id", $id);
$xmla->asXML('../db/todoist.xml');
echo "ok";
}

View File

@ -1,3 +1 @@
<? $xmla = simplexml_load_file('../db/todoist.xml'); if($xmla->token== '' || $xmla->token == null) header('Location: install-todoist.php'); if($xmla->name == '' || $xmla->name == null):?> <html> <head> <style> .selectableProject{text-decoration:underline; color:blue; cursor:pointer;} </style> <?php $xmla = simplexml_load_file('../db/todoist.xml'); if($xmla->token== '' || $xmla->token == null) header('Location: install-todoist.php'); if($xmla->name == '' || $xmla->name == null):?> <html> <head> <style> .selectableProject{text-decoration:underline; color:blue; cursor:pointer;} </style> <title>Todoist : getProjects</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="../js/getProjectsList.php?token=<?=$xmla->token?>"></script> </head> <body> </body> </html> <?php else: header('Location: ../../../'); endif;
<title>Todoist : getProjects</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="../js/getProjectsList.php?token=<?=$xmla->token?>"></script> </head> <body>
</body> </html> <? else: header('Location: ../../../'); endif;

View File

@ -1,12 +1 @@
<? <?php $xmla = simplexml_load_file('../db/todoist.xml'); if($xmla->token== '' || $xmla->token == null) header('Location: install-todoist.php'); if($xmla->id != '' || $xmla->id != null): $token = $xmla->token; $id = $xmla->id;?> <script type="text/javascript" src="../js/getUncompletedTasks.php?token=<?php echo $token; ?>&id=<?php echo $id; ?>"></script> <?php else: header('Location: getProjectsList.php'); endif;
$xmla = simplexml_load_file('../db/todoist.xml');
if($xmla->token== '' || $xmla->token == null)
header('Location: install-todoist.php');
if($xmla->id != '' || $xmla->id != null):
$token = $xmla->token;
$id = $xmla->id;?>
<script type="text/javascript" src="../js/getUncompletedTasks.php?token=<?=$token?>&id=<?=$id?>"></script>
<? else:
header('Location: getProjectsList.php');
endif;

View File

@ -1,4 +1,4 @@
<? <?php
$xmla = simplexml_load_file('../db/todoist.xml'); $xmla = simplexml_load_file('../db/todoist.xml');
if($xmla->token == '' || $xmla->token == null):?> if($xmla->token == '' || $xmla->token == null):?>
<html> <html>
@ -18,7 +18,7 @@ if($xmla->token == '' || $xmla->token == null):?>
</fieldset> </fieldset>
</body> </body>
</html> </html>
<? <?php
else: else:
header('Location: getProjectsList.php'); header('Location: getProjectsList.php');
endif; endif;

View File

@ -1,6 +1 @@
<?header('Content-type: application/javascript'); <?header('Content-type: application/javascript'); $token = $_GET['token']; ?> function cbfunc(o){ $('body').append('<div id="results"><h2>Select your project</h2></div>'); $('#results').append('<ul id="uncompletedList"><ul>'); for(var i in o) { $('#uncompletedList').append('<li id="'+o[i].id+'" class="selectableProject">'+o[i].name+'</li>'); } } $(document).ready(function(){ var token = "<?php echo $token; ?>"; var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'https://todoist.com/API/getProjects?token='+token+'&format=json&callback=cbfunc'; document.getElementsByTagName('head')[0].appendChild(script); $('.selectableProject').live('click', function(){ var name = $(this).text(); var id = $(this).attr('id'); $.post('../ajax/saveTodoist.php', {name: name, id: id}, function(msg){ $('body').append('<a href="index.php">Etape suivante</a>'); if(msg=="ok"){ location.reload(); }else{ alert(msg); } }); }); });
$token = $_GET['token'];
?>
function cbfunc(o){ $('body').append('<div id="results"><h2>Select your project</h2></div>'); $('#results').append('<ul id="uncompletedList"><ul>'); for(var i in o) { $('#uncompletedList').append('<li id="'+o[i].id+'" class="selectableProject">'+o[i].name+'</li>'); } }
$(document).ready(function(){ var token = "<?=$token?>"; var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'https://todoist.com/API/getProjects?token='+token+'&format=json&callback=cbfunc'; document.getElementsByTagName('head')[0].appendChild(script); $('.selectableProject').live('click', function(){ var name = $(this).text(); var id = $(this).attr('id'); $.post('../ajax/saveTodoist.php', {name: name, id: id}, function(msg){ $('body').append('<a href="index.php">Etape suivante</a>'); if(msg=="ok"){ location.reload(); }else{ alert(msg); } }); });
});

View File

@ -1,9 +1 @@
<?header('Content-type: application/javascript'); $token = $_GET['token']; $id = $_GET['id']; ?> <?header('Content-type: application/javascript'); $token = $_GET['token']; $id = $_GET['id']; ?> function cbfunc(o){ $('#results').append('<ul id="uncompletedList"><ul>'); for(var i in o) { $('#uncompletedList').append('<li id="'+o[i].id+'">'+o[i].content+' - '+o[i].date_string+' <img src="images/interface/delete.png" class="deleteTask" id="delete-'+o[i].id+'"/> <img src="images/interface/complete.png" class="completeTask" id="complete-'+o[i].id+'"/> </li>'); } $('#uncompletedList li').prepend('<div class="puce"></div>'); } function cbfunc2(o){ $('#uncompletedList').append('<li id="'+o.id+'">'+o.content+' - '+o.date_string+' <img src="images/interface/delete.png" id="delete-'+o.id+'"/> <img src="images/interface/complete.png" class="completeTask" id="complete-'+o.id+'"/> </li>'); } $(document).ready(function(){ $('#todo').resizable(); $('#todo').draggable(); $('#todo').append('<div id="results"></div><img src="images/interface/add.png" id="showNewTask"/><fieldset id="newTaskFieldset" style="display:none; width:200px;"><input type="text" name="newtask" id="newtask"/> <select id="priority"><option id="1" value="1">1</option><option id="2" value="2">2</option><option id="3" value="3">3</option><option id="4" value="4">4</option></select> <br/><input type="text" name="date_string" id="date_string"/> <img src="images/interface/add.png" id="addTask"/></fieldset>'); var token = "<?php echo $token; ?>"; var project_id = "<?php echo $id; ?>"; var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'https://todoist.com/API/getUncompletedItems?project_id='+project_id+'&token='+token+'&format=json&callback=cbfunc'; document.getElementsByTagName('head')[0].appendChild(script); $('#showNewTask').click(function(){ $('#newTaskFieldset').toggle(); }); $('#addTask').click(function(){ var content = $('#newtask').val(); var date_string = $('#date_string').val(); var priority = $('#priority').val(); var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'https://todoist.com/API/addItem?project_id='+project_id+'&token='+token+'&content='+content+'&date_string='+date_string+'&priority='+priority+'&format=json&callback=cbfunc2'; document.getElementsByTagName('head')[0].appendChild(script); }); $('.deleteTask').live('click', function(){ var id = $(this).attr('id'); arrayId = id.split('-'); var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'https://todoist.com/API/deleteItems?ids=["'+arrayId[1]+'"]&token='+token; document.getElementsByTagName('head')[0].appendChild(script); $('#'+arrayId[1]).remove(); }); $('.completeTask').live('click', function(){ var id = $(this).attr('id'); arrayId = id.split('-'); var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'https://todoist.com/API/completeItems?ids=["'+arrayId[1]+'"]&token='+token; document.getElementsByTagName('head')[0].appendChild(script); $('#'+arrayId[1]).remove(); }); /* A helper function for converting a set of elements to draggables: */ make_draggable($('#todo')); });
function cbfunc(o){ $('#results').append('<ul id="uncompletedList"><ul>'); for(var i in o) { $('#uncompletedList').append('<li id="'+o[i].id+'">'+o[i].content+' - '+o[i].date_string+' <img src="images/interface/delete.png" class="deleteTask" id="delete-'+o[i].id+'"/> <img src="images/interface/complete.png" class="completeTask" id="complete-'+o[i].id+'"/> </li>'); } $('#uncompletedList li').prepend('<div class="puce"></div>'); }
function cbfunc2(o){ $('#uncompletedList').append('<li id="'+o.id+'">'+o.content+' - '+o.date_string+' <img src="images/interface/delete.png" id="delete-'+o.id+'"/> <img src="images/interface/complete.png" class="completeTask" id="complete-'+o.id+'"/> </li>'); }
$(document).ready(function(){ $('#todo').resizable(); $('#todo').draggable(); $('#todo').append('<div id="results"></div><img src="images/interface/add.png" id="showNewTask"/><fieldset id="newTaskFieldset" style="display:none; width:200px;"><input type="text" name="newtask" id="newtask"/> <select id="priority"><option id="1" value="1">1</option><option id="2" value="2">2</option><option id="3" value="3">3</option><option id="4" value="4">4</option></select> <br/><input type="text" name="date_string" id="date_string"/> <img src="images/interface/add.png" id="addTask"/></fieldset>'); var token = "<?=$token?>"; var project_id = "<?=$id?>"; var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'https://todoist.com/API/getUncompletedItems?project_id='+project_id+'&token='+token+'&format=json&callback=cbfunc'; document.getElementsByTagName('head')[0].appendChild(script);
$('#showNewTask').click(function(){ $('#newTaskFieldset').toggle(); });
$('#addTask').click(function(){ var content = $('#newtask').val(); var date_string = $('#date_string').val(); var priority = $('#priority').val(); var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'https://todoist.com/API/addItem?project_id='+project_id+'&token='+token+'&content='+content+'&date_string='+date_string+'&priority='+priority+'&format=json&callback=cbfunc2'; document.getElementsByTagName('head')[0].appendChild(script); });
$('.deleteTask').live('click', function(){ var id = $(this).attr('id'); arrayId = id.split('-'); var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'https://todoist.com/API/deleteItems?ids=["'+arrayId[1]+'"]&token='+token; document.getElementsByTagName('head')[0].appendChild(script); $('#'+arrayId[1]).remove(); }); $('.completeTask').live('click', function(){ var id = $(this).attr('id'); arrayId = id.split('-'); var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'https://todoist.com/API/completeItems?ids=["'+arrayId[1]+'"]&token='+token; document.getElementsByTagName('head')[0].appendChild(script); $('#'+arrayId[1]).remove(); });
/* A helper function for converting a set of elements to draggables: */ make_draggable($('#todo'));
});

View File

@ -1,5 +1,7 @@
<?php <?php
class weather extends Module {
class weather extends Module
{
protected $moduleTitle = 'Météo'; protected $moduleTitle = 'Météo';
@ -16,15 +18,17 @@ class weather extends Module {
public function build(){ public function build(){
$ville = $this->getParam('city'); $ville = $this->getParam('city');
$future_weather = [];
include $this->pathToModule.'includes/GoogleMeteo.php'; include $this->pathToModule.'includes/GoogleMeteo.php';
if (!empty($present_weather)) {
echo '<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script> echo '<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
<link rel="stylesheet" type="text/css" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css">'; <link rel="stylesheet" type="text/css" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css">';
echo '<div id="weather" style="left:'.$this->getParam("x").'; top:'.$this->getParam("y").';"> echo '<div id="weather" style="left:'.$this->getParam("x").'; top:'.$this->getParam("y").';">
'.$city.'<br/> '.$ville.'<br/>
<div class="weatherpic"></div> <div class="weatherpic"></div>
<strong>'.$present_weather.'</strong><br/> <strong>'.$present_weather.'</strong><br/>
'.$future_weather1.'<br/> '.implode('<br/>', $future_weather).'
'.$future_weather2.'
</div>'; </div>';
} }
}
} }

View File

@ -1,38 +1,45 @@
<?php <?php
require('class/GoogleWeather.class.php');
//ça récupère un truc du style : http://www.google.com/ig/api?weather=paris&hl=fr require('class/GoogleWeather.class.php');
if($ville != '' || $ville != null){ $present_weather = null;
$gweather = new GoogleWeatherAPI($ville,'fr'); //ça récupère un truc du style : http://www.google.com/ig/api?weather=paris&hl=fr
if ( !empty($ville) ) {
$google_weather = new GoogleWeatherAPI($ville, 'fr');
if($gweather->isFound()) { if ($google_weather->isFound()) {
$city = $gweather->getCity(); $city = $google_weather->getCity();
$currentTemp = $gweather->getCurrent(); $currentTemp = $google_weather->getCurrent();
$forecastTemp = $gweather->getForecast(); $forecastTemp = $google_weather->getForecast();
$present_weather = 'Actuellement : '.$currentTemp['temp_c'].'°C - '.$currentTemp['condition']; $present_weather = 'Actuellement : ' . $currentTemp['temp_c'] . '°C - ' . $currentTemp['condition'];
$i=0; $future_weather = [];
foreach($forecastTemp as $temp) { foreach ($forecastTemp as $temp) {
${'future_weather'.$i} = $temp['day_of_week'].' : '.$temp['low'].'°C | '.$temp['high'].'°C - '.$temp['condition']; $future_weather[] = $temp['day_of_week'] . ' : ' . $temp['low'] . '°C | ' . $temp['high'] . '°C - ' . $temp['condition'];
$i++;
} }
if(strpos(strtolower($present_weather),"soleil") !== false) {?> if (strpos(strtolower($present_weather), "soleil") !== false) { ?>
<link rel="stylesheet" type="text/css" href="modules/weather/css/soleil.css"> <link rel="stylesheet" type="text/css" href="modules/weather/css/soleil.css">
<?} <?php
if(strpos(strtolower($present_weather),"nuage") !== false) {?> }
if (strpos(strtolower($present_weather), "nuage") !== false) { ?>
<link rel="stylesheet" type="text/css" href="modules/weather/css/nuage.css"> <link rel="stylesheet" type="text/css" href="modules/weather/css/nuage.css">
<?} <?php
if(strpos(strtolower($present_weather),"peu nuageux") !== false) {?> }
if (strpos(strtolower($present_weather), "peu nuageux") !== false) { ?>
<link rel="stylesheet" type="text/css" href="modules/weather/css/peunuage.css"> <link rel="stylesheet" type="text/css" href="modules/weather/css/peunuage.css">
<?} <?php
if((strpos(strtolower($present_weather),"pluie") !== false) || (strpos(strtolower($present_weather),"averse") !== false)) {?> }
if ((strpos(strtolower($present_weather), "pluie") !== false) || (strpos(strtolower($present_weather), "averse") !== false)) { ?>
<link rel="stylesheet" type="text/css" href="modules/weather/css/pluie.css"> <link rel="stylesheet" type="text/css" href="modules/weather/css/pluie.css">
<?} <?php
if(strpos(strtolower($present_weather),"neige") !== false) {?> }
if (strpos(strtolower($present_weather), "neige") !== false) { ?>
<link rel="stylesheet" type="text/css" href="modules/weather/css/neige.css"> <link rel="stylesheet" type="text/css" href="modules/weather/css/neige.css">
<?} <?php
}else{ $present_weather = 'Ville non trouvé : '.$city; } }
}else } else {
$present_weather = 'Ville non trouvé : ' . $ville;
}
} else {
$present_weather = 'Ville non renseignée'; $present_weather = 'Ville non renseignée';
}