Amélioration de l'organisation du code : la classe principale "Module" est maintenant prête et les modules l'ont bien étendue.

This commit is contained in:
Chouchen 2010-10-05 15:30:04 +00:00
parent ac017b84e9
commit 759a5556cc
25 changed files with 236 additions and 706 deletions

View File

@ -3,7 +3,11 @@ $options = array();
$module =''; $module ='';
include '../class/AccueilModules.php'; include '../class/AccueilModules.php';
foreach($_POST as $module => $valeur){ foreach($_POST as $module => $valeur){
AccueilModules::updateModule($module, array('visibility'=>$valeur)); $moduleToUpdate = AccueilModules::getModule($module);
if($moduleToUpdate != null){
$moduleToUpdate->updateConfig(array('visibility'=>$valeur));
} }
echo "1"; //AccueilModules::updateModule($module, array('visibility'=>$valeur));
}
echo "1"
?> ?>

View File

@ -8,9 +8,12 @@ $options = array();
$module =''; $module ='';
foreach($_GET as $indice=>$valeur){ foreach($_GET as $indice=>$valeur){
if($indice == 'id') if($indice == 'id')
$module .= $valeur; $module = $valeur;
else else
$options[$indice] = $valeur; $options[$indice] = $valeur;
} }
include '../class/AccueilModules.php'; include '../class/AccueilModules.php';
echo AccueilModules::updateModule($module, $options); $moduleToUpdate = AccueilModules::getModule($module);
if($moduleToUpdate != null){
echo $moduleToUpdate->updateConfig($options);
}

View File

@ -1,14 +1,23 @@
<?php <?php
require 'Module.php'; function __autoload($class)
{
$BASE_DIR = '/homez.9/shikiryu/www/test/trunk3/';
set_include_path($BASE_DIR);
$path = 'modules/'.$class;
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');
}else{
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();
/** /**
* Constructeur * Constructeur
* Initialise le XML de conf générale * Initialise le XML de conf générale
* Active les modules
* Construit le menu
*/ */
function __construct(){ function __construct(){
if($config = simplexml_load_file(self::CONFIG_FILE)){ if($config = simplexml_load_file(self::CONFIG_FILE)){
@ -16,8 +25,6 @@ class AccueilModules {
foreach($config_xml as $item){ foreach($config_xml as $item){
$this->modules["$item[id]"] = $item; $this->modules["$item[id]"] = $item;
} }
$this->getModules();
$this->buildConfigMenu();
}else{ }else{
echo 'Impossible de trouver le fichier de configuration.'; echo 'Impossible de trouver le fichier de configuration.';
} }
@ -34,12 +41,41 @@ class AccueilModules {
foreach($moduleConf as $confParam){ foreach($moduleConf as $confParam){
$params[$confParam->getName()] = "$confParam"; $params[$confParam->getName()] = "$confParam";
} }
require 'modules/'.$module.'/'.ucfirst($module).'.php'; $module = new $module($params);
call_user_func(array($module, "start"), $params); if(is_subclass_of($module,'Module'))
$module->build();
// require 'modules/'.$module.'/'.ucfirst($module).'.php';
// call_user_func(array($module, "start"), $module, $params);
} }
} }
} }
/**
*
* @return le module donné avec ses paramètres actuellement présent en conf
*/
public static function getModule($module){
if($config = simplexml_load_file('../'.self::CONFIG_FILE)){
$config_xml = $config->item;
foreach($config_xml as $item){
if($item["id"] == $module){
$params = array();
foreach($item as $confParam){
$params[$confParam->getName()] = "$confParam";
}
//require '../modules/'.$module.'/'.ucfirst($module).'.php';
return new $module($params);
}
}
echo "object not found";
return;
}else{
echo "bad persistance";
return;
}
}
/** /**
* *
* Construit et insère le menu de changement de config * Construit et insère le menu de changement de config
@ -92,10 +128,12 @@ class AccueilModules {
* @param $things2change Array du ou des attributs à modifier avec sa ou ses nouvelles valeurs * @param $things2change Array du ou des attributs à modifier avec sa ou ses nouvelles valeurs
* @return "ok" String si c'est bon, ou le message d'erreur * @return "ok" String si c'est bon, ou le message d'erreur
*/ */
public static function updateModule($module, $things2change){ /*public static function updateModule($module, $things2change){
require '../modules/'.$module.'/'.ucfirst($module).'.php'; //require 'Module.php';
//require '../modules/'.$module.'/'.ucfirst($module).'.php';
$module = new $module();
return call_user_func(array($module, "updateConfig"), $things2change); return call_user_func(array($module, "updateConfig"), $things2change);
} }*/
/** /**
* *

View File

@ -94,8 +94,9 @@ class GoogleWeatherAPI {
} }
} else { } else {
trigger_error('Google results parse problem : http error '.$getContentCode,E_USER_WARNING); //trigger_error('Google results parse problem : http error '.$getContentCode,E_USER_WARNING);
return null; $this->is_found = false;
//return null;
} }
} }

View File

@ -1,5 +1,5 @@
<?php <?php
abstract class Module class Module
{ {
/** /**
* Liste des paramètres du module en concordance avec le "config.xml" * Liste des paramètres du module en concordance avec le "config.xml"
@ -22,18 +22,77 @@ abstract class Module
* *
* @var array * @var array
*/ */
public $params = array(); private $params = array();
private function setParams($params){ public function __construct($class, $params){
$this->setNames($class, $this->moduleTitle);
$this->setParams($params);
}
/**
* @param array correspondant aux paramètres du $paramsList
* Applique les paramètres du module depuis le conf
*/
public function setParams($params){
$this->params = $params; $this->params = $params;
} }
abstract static function start($params); /**
* @return Array les paramètres du module
*/
public function getParams(){
return $this->params;
}
public static function updateConfig($updated){ /**
* @param string le paramètre dont on veut la valeur
* @return string valeur du paramètre
*/
public function getParam($param){
if(isset($this->params[$param]))
return $this->params[$param];
else
return;
}
/**
* @return string le nom de la classe (du module)
*/
private function getModuleName(){
return $this->moduleName;
}
/**
* Donne les noms et chemins du module
*/
private function setNames($module, $libelle){
$this->moduleName = $module;
$this->pathToModule = 'modules/'.$this->moduleName.'/';
$this->moduleTitle = $libelle;
}
/**
* @param $class string nom du module
* @param $key string le nom du paramètre à changer
* @param $value string valeur du paramètre
* Enregistre le paramètre dans le conf
*/
public function setParam($class, $key, $value) {
echo 'setting :'.$key.' as '.$value.' in the '.$class.'\'s module';
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='".$class."']");
$path[0]->$key = $value;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
}
public function updateConfig($updated){
foreach ($updated as $what=>$withWhat){ foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){ if(array_key_exists($what, $this->getParams())){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat); $this->setParam($this->moduleName, $what, $withWhat);
}else{
echo $what.' isn\'t in ';
} }
} }
} }

View File

@ -31,7 +31,7 @@
<y>-2</y> <y>-2</y>
</item> </item>
<item id="clockAdvanced"> <item id="clockAdvanced">
<visibility>true</visibility> <visibility>false</visibility>
<x>80</x> <x>80</x>
<y>10</y> <y>10</y>
<fontFamily>Times New Roman, serif</fontFamily> <fontFamily>Times New Roman, serif</fontFamily>
@ -46,6 +46,8 @@
</item> </item>
<item id="news"> <item id="news">
<visibility>false</visibility> <visibility>false</visibility>
<x>0</x>
<y>600</y>
</item> </item>
<item id="ouifm"> <item id="ouifm">
<visibility>true</visibility> <visibility>true</visibility>

View File

@ -12,8 +12,10 @@
</head> </head>
<body> <body>
<? <?
require 'class/AccueilModules.php'; include "class/AccueilModules.php";
$index = new AccueilModules(); $index = new AccueilModules();
$index->getModules();
$index->buildConfigMenu();
?> ?>
</body> </body>
</html> </html>

View File

@ -67,7 +67,7 @@ $(document).ready(function(){
$('#menu-bar').prepend($('#config-menu')); $('#menu-bar').prepend($('#config-menu'));
$("#q").focus(); //focus sur la recherche $("#q").focus(); //focus sur la recherche
//$('.iconlist').sortable();
$('#config-menu').fancybox({ $('#config-menu').fancybox({
'zoomSpeedIn' : 600, 'zoomSpeedIn' : 600,
'zoomSpeedOut' : 500, 'zoomSpeedOut' : 500,

View File

@ -1,21 +1,21 @@
<?php <?php
class blogs extends Module { class blogs extends Module {
protected $moduleTitle = 'Blogs BD';
protected static $paramsList = array( protected static $paramsList = array(
'visibility', 'visibility',
'x', 'x',
'y' 'y'
); );
public $params = array();
public function __construct($params){ public function __construct($params){
$this->moduleName = get_class(); parent::__construct(__CLASS__, $params);
$this->pathToModule = 'modules/'.$this->moduleName.'/'; }
$this->setParams($params);
public function build(){
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" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />'; <link rel="stylesheet" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />';
require($this->pathToModule.'includes/blogs_last_post.php'); require($this->pathToModule.'includes/blogs_last_post.php');
echo '<div id="blogs" style="top:'.$params['y'].'; left :'.$params['x'].';"></div>'; echo '<div id="blogs" style="top:'.$this->getParam('y').'; left :'.$this->getParam('x').';"></div>';
echo '<a href="#blogLinksManager" id="blog-links-manager"><img src="images/interface/blogs_edit.png" /></a>'; echo '<a href="#blogLinksManager" id="blog-links-manager"><img src="images/interface/blogs_edit.png" /></a>';
echo '<div style="display:none;"> echo '<div style="display:none;">
<div id="blogLinksManager"> <div id="blogLinksManager">
@ -34,55 +34,4 @@ class blogs extends Module {
</div> </div>
</div>'; </div>';
} }
private function setParams($params){
$this->params = $params;
}
public static function start($params){
$blogs = new blogs($params);
}
public function setX($x){
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='blogs']");
$path[0]->x = $x;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setY($y){
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='blogs']");
$path[0]->y = $y;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setVisibility($visibility){
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='blogs']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
}
} }

View File

@ -1,48 +1,19 @@
<?php <?php
class clock extends Module { class clock extends Module {
protected $moduleTitle = 'Horloge Simple';
protected static $paramsList = array( protected static $paramsList = array(
'visibility', 'visibility',
'x', 'x',
'y' 'y'
); );
public $params = array();
public function __construct($params){ public function __construct($params){
$this->moduleName = get_class(); parent::__construct(__CLASS__, $params);
$this->pathToModule = 'modules/'.$this->moduleName.'/'; }
$this->setParams($params);
public function build(){
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" 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="jclock" id="clock" style="left:'.$params['x'].'; top:'.$params['y'].';"></div>'; echo '<div class="jclock" id="clock" style="left:'.$this->getParam('x').'; top:'.$this->getParam('y').';"></div>';
}
private function setParams($params){
$this->params = $params;
}
public static function start($params){
$clock = new clock($params);
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='clock']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
} }
} }

View File

@ -1,5 +1,6 @@
<?php <?php
class clockAdvanced extends Module { class clockAdvanced extends Module {
protected $moduleTitle = 'Horloge Avancée';
protected static $paramsList = array( protected static $paramsList = array(
'visibility', 'visibility',
'x', 'x',
@ -10,124 +11,26 @@ class clockAdvanced extends Module {
'color' 'color'
); );
public $params = array();
public function __construct($params){ public function __construct($params){
$this->moduleName = get_class(); parent::__construct(__CLASS__, $params);
$this->pathToModule = 'modules/'.$this->moduleName.'/'; }
$this->setParams($params);
public function build(){
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" 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:'.$params['x'].'; top:'.$params['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 (self::$paramsList as $paramName){
if(isset($this->params[$paramName])) if($this->getParam($paramName) != null)
$options .= $paramName.' : "'.$this->params[$paramName].'",'; $options .= $paramName.' : "'.$this->getParam($paramName).'",';
} }
echo '<script>$(document).ready(function(){ echo '<script>$(document).ready(function(){
$(\'#fontFamily\').val("'.$params['fontFamily'].'"); $(\'#fontFamily\').val("'.$this->getParam('fontFamily').'");
$(\'#fontSize\').val("'.$params['fontSize'].'"); $(\'#fontSize\').val("'.$this->getParam('fontSize').'");
$(\'#format\').val("'.$params['format'].'"); $(\'#format\').val("'.$this->getParam('format').'");
$(\'#color\').val("'.$params['color'].'"); $(\'#color\').val("'.$this->getParam('color').'");
$(\'.jclockAdvanced\').jclock({'.substr($options,0,-1).'}); $(\'.jclockAdvanced\').jclock({'.substr($options,0,-1).'});
}); });
</script>'; </script>';
} }
private function setParams($params){
$this->params = $params;
}
public static function start($params){
$clockAdvanced = new clockAdvanced($params);
}
public function setX($x){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='clockAdvanced']");
$path[0]->x = $x;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setY($y){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='clockAdvanced']");
$path[0]->y = $y;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='clockAdvanced']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setFontFamily($fontFamily){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='clockAdvanced']");
$path[0]->fontFamily = $fontFamily;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setFontSize($fontSize){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='clockAdvanced']");
$path[0]->fontSize = $fontSize;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setColor($color){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='clockAdvanced']");
$path[0]->color = $color;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setFormat($format){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='clockAdvanced']");
$path[0]->format = $format;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
}
} }

View File

@ -1,49 +1,19 @@
<?php <?php
class gmap extends Module { class gmap extends Module {
//TODO rajouter les params en détail protected $moduleTitle = 'Google Maps';
protected static $paramsList = array( protected static $paramsList = array(
'visibility' 'visibility'
); );
public $params = array();
public function __construct($params){ public function __construct($params){
$this->moduleName = get_class(); parent::__construct(__CLASS__, $params);
$this->pathToModule = 'modules/'.$this->moduleName.'/'; }
$this->setParams($params);
public function build(){
echo '<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=fr"></script> echo '<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=fr"></script>
<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script> <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" /> <link rel="stylesheet" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />
<div id="myAdress"><label for="myAdressField"><img src="images/interface/map.png" /> Adresse pour Google Maps :</label><input type="text" name="myAdressField" id="myAdressField" /></div><a href="#map" id="gmapLink"></a><div id="map"><div id="mymap" style="width:400px;height:400px"></div></div>'; <div id="myAdress"><label for="myAdressField"><img src="images/interface/map.png" /> Adresse pour Google Maps :</label><input type="text" name="myAdressField" id="myAdressField" /></div><a href="#map" id="gmapLink"></a><div id="map"><div id="mymap" style="width:400px;height:400px"></div></div>';
} }
private function setParams($params){
$this->params = $params;
}
public static function start($params){
$gmap = new gmap($params);
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='gmap']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
}
} }

View File

@ -1,22 +1,17 @@
<?php <?php
class links extends Module{ class links extends Module{
protected $moduleTitle = 'Liens';
protected $moduleName;
protected $moduleTitle;
protected $pathToModule;
protected static $paramsList = array( protected static $paramsList = array(
'visibility' 'visibility'
); );
const LINKS_FILE = 'db/links.xml'; const LINKS_FILE = 'db/links.xml';
public $params = array();
public function __construct($params){ public function __construct($params){
$this->moduleName = get_class(); parent::__construct(__CLASS__, $params);
$this->pathToModule = 'modules/'.$this->moduleName.'/'; }
$this->setParams($params);
public function build(){
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" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" /> <link rel="stylesheet" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />
<div style="display:none;"><div id="links-add-fancy"></div></div> <div style="display:none;"><div id="links-add-fancy"></div></div>
@ -38,32 +33,4 @@ class links extends Module{
echo '</div>'; echo '</div>';
} }
private function setParams($params){
$this->params = $params;
}
public static function start($params){
$links = new links($params);
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='links']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
}
} }

View File

@ -1,49 +1,19 @@
<?php <?php
class mappy extends Module { class mappy extends Module {
protected $moduleTitle = 'Mappy';
protected static $paramsList = array( protected static $paramsList = array(
'visibility' 'visibility'
); );
public $params = array();
public function __construct($params){ public function __construct($params){
$this->moduleName = get_class(); parent::__construct(__CLASS__, $params);
$this->pathToModule = 'modules/'.$this->moduleName.'/'; }
$this->setParams($params);
public function build(){
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 '<script src="http://axe.mappy.com/1v1/init/get.aspx?version=2.01&solution=ajax&auth=HbTTpMfC4//GWuldL2IsF+HJA4xVuTBsIQi0wcC7xRz+e17hobrJ+1947aq34rdjYAPy6nBYBQF8o56Qzdun9w=="></script> echo '<script src="http://axe.mappy.com/1v1/init/get.aspx?version=2.01&solution=ajax&auth=HbTTpMfC4//GWuldL2IsF+HJA4xVuTBsIQi0wcC7xRz+e17hobrJ+1947aq34rdjYAPy6nBYBQF8o56Qzdun9w=="></script>
<div id="mymap"></div> <div id="mymap"></div>
<div id="myAdress"><input type="text" name="myAdressField" id="myAdressField" /></div>'; <div id="myAdress"><input type="text" name="myAdressField" id="myAdressField" /></div>';
} }
private function setParams($params){
$this->params = $params;
}
public static function start($params){
$mappy = new mappy($params);
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='mappy']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
}
} }

View File

@ -1,16 +1,21 @@
<?php <?php
class news { class news extends Module{
protected $moduleTitle = 'Google News';
protected static $paramsList = array( protected static $paramsList = array(
'visibility' 'visibility',
'x',
'y'
); );
public $params = array();
public function __construct($params){ public function __construct($params){
$this->setParams($params); parent::__construct(__CLASS__, $params);
}
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="http://www.google.com/jsapi"></script> echo '<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<div id="news"></div> <div id="news" style="top:' . $this->getParam('y') . '; left: ' . $this->getParam('x') . ';"></div>
<script type="text/javascript"> <script type="text/javascript">
google.load("elements", "1", {packages : ["newsshow"]}); google.load("elements", "1", {packages : ["newsshow"]});
function onLoad() { function onLoad() {
@ -29,32 +34,4 @@ class news {
google.setOnLoadCallback(onLoad); google.setOnLoadCallback(onLoad);
</script>'; </script>';
} }
private function setParams($params){
$this->params = $params;
}
public static function start($params){
$news = new news($params);
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='news']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
}
} }

View File

@ -0,0 +1,2 @@
#news{position:absolute;}
#news div{display:inline !important;}

4
modules/news/js/news.js Normal file
View File

@ -0,0 +1,4 @@
$(document).ready(function(){
make_draggable($('#news'));
});

View File

@ -1,51 +1,19 @@
<?php <?php
class notes extends Module { class notes extends Module {
protected $moduleTitle = 'Post-It';
protected $moduleName;
protected $moduleTitle;
protected $pathToModule;
protected static $paramsList = array( protected static $paramsList = array(
'visibility' 'visibility'
); );
public $params = array();
public function __construct($params){ public function __construct($params){
$this->moduleName = get_class(); parent::__construct(__CLASS__, $params);
$this->pathToModule = 'modules/'.$this->moduleName.'/'; }
$this->setParams($params);
public function build(){
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">
<a id="addButton" class="green-button" href="'.$this->pathToModule.'includes/add_note.html">Add a note</a>'; <a id="addButton" class="green-button" href="'.$this->pathToModule.'includes/add_note.html">Add a note</a>';
include $this->pathToModule.'includes/notes_extract.php'; include $this->pathToModule.'includes/notes_extract.php';
} }
private function setParams($params){
$this->params = $params;
}
public static function start($params){
$notes = new notes($params);
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='notes']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
}
} }

View File

@ -1,48 +1,19 @@
<?php <?php
class ouifm extends Module { class ouifm extends Module {
protected $moduleTitle = 'Oui FM Radio';
protected static $paramsList = array( protected static $paramsList = array(
'visibility', 'visibility',
'x', 'x',
'y' 'y'
); );
public $params = array();
public function __construct($params){ public function __construct($params){
$this->moduleName = get_class(); parent::__construct(__CLASS__, $params);
$this->pathToModule = 'modules/'.$this->moduleName.'/'; }
$this->setParams($params);
public function build(){
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="ouifm" style="left:'.$params['x'].'; top:'.$params['y'].';"></div>'; echo '<div id="ouifm" style="left:'.$this->getParam('x').'; top:'.$this->getParam('y').';"></div>';
}
private function setParams($params){
$this->params = $params;
}
public static function start($params){
$ouifm = new ouifm($params);
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='ouifm']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
class rssblogs extends Module { class rssblogs extends Module {
//TODO rajouter les params en détail protected $moduleTitle = 'Lecteur de flux RSS';
protected static $paramsList = array( protected static $paramsList = array(
'visibility', 'visibility',
'x', 'x',
@ -10,9 +10,10 @@ class rssblogs extends Module {
public $params = array(); public $params = array();
public function __construct($params){ public function __construct($params){
$this->moduleName = get_class(); parent::__construct(__CLASS__, $params);
$this->pathToModule = 'modules/'.$this->moduleName.'/'; }
$this->setParams($params);
public function build(){
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" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />'; <link rel="stylesheet" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />';
require('class/lastRSS.php'); require('class/lastRSS.php');
@ -22,6 +23,7 @@ class rssblogs extends Module {
$rss->cache_time = 3600; // fréquence de mise à jour du cache (en secondes) $rss->cache_time = 3600; // fréquence de mise à jour du cache (en secondes)
$rss->date_format = 'd/m/y'; // format de la date (voir fonction date() pour syntaxe) $rss->date_format = 'd/m/y'; // format de la date (voir fonction date() pour syntaxe)
$rss->CDATA = 'content'; // on retire les tags CDATA en conservant leur contenu $rss->CDATA = 'content'; // on retire les tags CDATA en conservant leur contenu
echo '<div id="rssblogs" style="top:' . $this->getParam('y') . '; left: ' . $this->getParam('x') . ';">';
if($linksXML = simplexml_load_file($this->pathToModule.'db/rss.xml')){ if($linksXML = simplexml_load_file($this->pathToModule.'db/rss.xml')){
foreach($linksXML->link as $individualLink){ foreach($linksXML->link as $individualLink){
if ($rs = $rss->get($individualLink->url)) if ($rs = $rss->get($individualLink->url))
@ -32,56 +34,4 @@ class rssblogs extends Module {
} }
echo '</div>'; echo '</div>';
} }
private function setParams($params){
$this->params = $params;
}
public static function start($params){
$rssblogs = new rssblogs($params);
}
public function setX($x){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='rssblogs']");
$path[0]->x = $x;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setY($y){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='rssblogs']");
$path[0]->y = $y;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='rssblogs']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
}
} }

View File

@ -0,0 +1 @@
$(document).ready(function(){ make_draggable($('#rssblogs')); });

View File

@ -1,19 +1,15 @@
<?php <?php
class search extends Module { class search extends Module {
protected $moduleTitle = 'Recherche';
protected $moduleName;
protected $moduleTitle;
protected $pathToModule;
protected static $paramsList = array( protected static $paramsList = array(
'visibility' 'visibility'
); );
public $params = array();
public function __construct($params){ public function __construct($params){
$this->moduleName = get_class(); parent::__construct(__CLASS__, $params);
$this->pathToModule = 'modules/'.$this->moduleName.'/'; }
$this->setParams($params);
public function build(){
echo '<link rel="stylesheet" type="text/css" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css"> echo '<link rel="stylesheet" type="text/css" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css">
<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script> <script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
<form id="searchForm" method="post"> <form id="searchForm" method="post">
@ -31,32 +27,4 @@ class search extends Module {
</fieldset> </fieldset>
</form>'; </form>';
} }
private function setParams($params){
$this->params = $params;
}
public static function start($params){
$search = new search($params);
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='search']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
}
} }

View File

@ -1,6 +1,7 @@
<?php <?php
class todo extends Module { class todo extends Module {
protected $moduleTitle = 'Todo List';
protected static $paramsList = array( protected static $paramsList = array(
'visibility', 'visibility',
@ -8,23 +9,24 @@ class todo extends Module {
'y' 'y'
); );
public $params = array();
const TODO_FILE = 'db/todoist.xml'; const TODO_FILE = 'db/todoist.xml';
private $token; private $token;
private $project_name; private $project_name;
private $project_id; private $project_id;
public function __construct($params){ public function __construct($params){
$this->moduleName = get_class(); parent::__construct(__CLASS__, $params);
$this->pathToModule = 'modules/'.$this->moduleName.'/'; }
$this->setParams($params);
public function build(){
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" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />'; <link rel="stylesheet" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />';
if($xmla = simplexml_load_file($this->pathToModule.self::TODO_FILE)){ if($xmla = simplexml_load_file($this->pathToModule.self::TODO_FILE)){
$this->setToken($xmla->token); $this->setToken($xmla->token);
$this->setProjectName($xmla->name); $this->setProjectName($xmla->name);
$this->setProjectId($xmla->id); $this->setProjectId($xmla->id);
echo '<div id="todo" style="top:'.$params['y'].'; left :'.$params['x'].';">'; echo '<div id="todo" style="top:'.$this->getParam('y').'; left :'.$this->getParam('x').';">';
if($this->token == null || $this->project_id == null) if($this->token == null || $this->project_id == null)
echo 'Impossible de trouver votre configuration. <a href="'.$this->pathToModule.'includes/install-todoist.php">Cliquez ici</a> pour la mettre en place.</div>'; echo 'Impossible de trouver votre configuration. <a href="'.$this->pathToModule.'includes/install-todoist.php">Cliquez ici</a> pour la mettre en place.</div>';
else{ else{
@ -61,56 +63,4 @@ class todo extends Module {
else else
$this->project_id = $id; $this->project_id = $id;
} }
private function setParams($params){
$this->params = $params;
}
public static function start($params){
$todo = new todo($params);
}
public function setX($x){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='todo']");
$path[0]->x = $x;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setY($y){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='todo']");
$path[0]->y = $y;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='todo']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
}
} }

View File

@ -1,10 +1,7 @@
<?php <?php
class weather extends Module { class weather extends Module {
protected $moduleName; protected $moduleTitle = 'Météo';
protected $moduleTitle;
protected $pathToModule;
protected static $paramsList = array( protected static $paramsList = array(
'visibility', 'visibility',
@ -13,17 +10,16 @@ class weather extends Module {
'y' 'y'
); );
public $params = array();
public function __construct($params){ public function __construct($params){
$this->moduleName = get_class(); parent::__construct(__CLASS__, $params);
$this->pathToModule = 'modules/'.$this->moduleName.'/'; }
$this->setParams($params);
$ville = $params['city']; public function build(){
$ville = $this->getParam('city');
include $this->pathToModule.'includes/GoogleMeteo.php'; include $this->pathToModule.'includes/GoogleMeteo.php';
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:'.$params['x'].'; top:'.$params['y'].';"> echo '<div id="weather" style="left:'.$this->getParam("x").'; top:'.$this->getParam("y").';">
'.$city.'<br/> '.$city.'<br/>
<div class="weatherpic"></div> <div class="weatherpic"></div>
<strong>'.$present_weather.'</strong><br/> <strong>'.$present_weather.'</strong><br/>
@ -31,74 +27,4 @@ class weather extends Module {
'.$future_weather2.' '.$future_weather2.'
</div>'; </div>';
} }
private function setParams($params){
$this->params = $params;
}
public static function start($params){
$weather = new weather($params);
}
/**
*
* Modifie la ville
* @param String $city la ville.
* @return String "ok" ou message d'erreur (effectue aussi l'enregistrement en XML)
*/
public function setCity($city){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='weather']");
$path[0]->city = $city;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setX($x){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='weather']");
$path[0]->x = $x;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setY($y){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='weather']");
$path[0]->y = $y;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='weather']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
}
} }

View File

@ -1,26 +0,0 @@
<?php
if ($weather = simplexml_load_file('http://www.my-meteo.fr/meteo+rss+paris.html')){
$present_weather = $weather->channel->item[0]->title;
$future_weather1 = $weather->channel->item[1]->title;
$future_weather2 = $weather->channel->item[2]->title;
if(strpos(strtolower($present_weather),"soleil") !== false) {?>
<link rel="stylesheet" type="text/css" href="css/soleil.css">
<?}
if(strpos(strtolower($present_weather),"nuage") !== false) {?>
<link rel="stylesheet" type="text/css" href="css/nuage.css">
<?}
if(strpos(strtolower($present_weather),"peu nuageux") !== false) {?>
<link rel="stylesheet" type="text/css" href="css/peunuage.css">
<?}
if((strpos(strtolower($present_weather),"pluie") !== false) || (strpos(strtolower($present_weather),"averse") !== false)) {?>
<link rel="stylesheet" type="text/css" href="css/pluie.css">
<?}
if(strpos(strtolower($present_weather),"neige") !== false) {?>
<link rel="stylesheet" type="text/css" href="css/neige.css">
<?}
}
else
{
die ('Flux RSS non trouvé');
}
?>