Ajout du module de news

This commit is contained in:
Chouchen 2010-09-21 15:09:31 +00:00
parent 2394218c17
commit 8ece766934
8 changed files with 97 additions and 87 deletions

View File

@ -1,12 +1,15 @@
<?// Escaping the input data: <?// Escaping the input data:
//TODO automatisation ! Je veux plus de "$config_xml[x]" //TODO automatisation ! Je veux plus de "$config_xml[x]"
$clock = $_POST['clock']; $clock = $_POST['clock'];
$weather = $_POST['weather']; $weather = $_POST['weather'];
$notes = $_POST['notes']; $notes = $_POST['notes'];
$search = $_POST['search']; $search = $_POST['search'];
$links = $_POST['links']; $links = $_POST['links'];
$blogs = $_POST['blogs']; $blogs = $_POST['blogs'];
$todo = $_POST['todo']; $todo = $_POST['todo'];
$clockAdvanced = $_POST['clockAdvanced'];
$rssblogs = $_POST['rssblogs'];
$news = $_POST['news'];
$xmla = simplexml_load_file('../db/config.xml'); $xmla = simplexml_load_file('../db/config.xml');
$config_xml = $xmla->item; $config_xml = $xmla->item;
@ -17,6 +20,9 @@ $config_xml[3]->visibility = $search;
$config_xml[4]->visibility = $links; $config_xml[4]->visibility = $links;
$config_xml[5]->visibility = $blogs; $config_xml[5]->visibility = $blogs;
$config_xml[6]->visibility = $todo; $config_xml[6]->visibility = $todo;
$config_xml[7]->visibility = $clockAdvanced;
$config_xml[8]->visibility = $rssblogs;
$config_xml[9]->visibility = $news;
$xmla->asXML('../db/config.xml'); $xmla->asXML('../db/config.xml');
echo "1"; echo "1";

View File

@ -24,6 +24,8 @@ class links {
echo '</ul> echo '</ul>
<hr>'; <hr>';
} }
}else{
echo 'Can\'t find '.self::LINKS_FILE;
} }
echo '</div>'; echo '</div>';
} }

60
class/News.php Normal file
View File

@ -0,0 +1,60 @@
<?php
class news {
protected static $paramsList = array(
'visibility'
);
public $params = array();
public function __construct($params){
$this->setParams($params);
echo '<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<div id="news"></div>
<script type="text/javascript">
google.load("elements", "1", {packages : ["newsshow"]});
function onLoad() {
var options = {
"format" : "300x250",
"language" : "fr",
"linkTarget" : "_blank"
}
// Load it using all of the defaults.
var content = document.getElementById(\'news\');
var newsShow = new google.elements.NewsShow(content, options);
make_draggable($(\'#news\'));
}
google.setOnLoadCallback(onLoad);
</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

@ -52,5 +52,5 @@ $(document).ready(function(){ $('#todo').resizable(); $('#todo').draggable();
document.getElementsByTagName('head')[0].appendChild(script); document.getElementsByTagName('head')[0].appendChild(script);
$('#'+arrayId[1]).remove(); $('#'+arrayId[1]).remove();
}); });
/* A helper function for converting a set of elements to draggables: */ make_draggable($('#todo')); var zIndex = 0; function make_draggable(elements) { /* Elements is a jquery object: */ elements.draggable({ snap:true, containment:'parent', start:function(e,ui){ ui.helper.css('z-index',++zIndex); }, stop:function(e,ui){ /* Sending the z-index and positon of the note to update_position.php via AJAX GET: */ $.get('ajax/update_position_config.php',{ x : ui.position.left, y : ui.position.top, id : ui.helper.attr('id') }); } }); } /* A helper function for converting a set of elements to draggables: */ make_draggable($('#todo'));
}); });

View File

@ -1,27 +1,7 @@
$(document).ready(function(){ $(document).ready(function(){
var zIndex = 0;
$('#menu-bar').prepend($('#blog-links-manager')); $('#menu-bar').prepend($('#blog-links-manager'));
function make_draggable(elements)
{
/* Elements is a jquery object: */
elements.draggable({
snap:true,
containment:'parent',
start:function(e,ui){ ui.helper.css('z-index',++zIndex); },
stop:function(e,ui){
/* Sending the z-index and positon of the note to update_position.php via AJAX GET: */
$.get('ajax/update_position_config.php',{
x : ui.position.left,
y : ui.position.top,
id : ui.helper.attr('id')
});
}
});
}
//affichage des blogs //affichage des blogs
$("#blogs").html("<img src=\"images/interface/ajax_load.gif\"/> Loading Blogs..."); $("#blogs").html("<img src=\"images/interface/ajax_load.gif\"/> Loading Blogs...");
var tmp; var tmp;

View File

@ -216,23 +216,4 @@ $(document).ready(function(){
/* A helper function for converting a set of elements to draggables: */ /* A helper function for converting a set of elements to draggables: */
make_draggable($('.jclock')); make_draggable($('.jclock'));
var zIndex = 0;
function make_draggable(elements)
{
/* Elements is a jquery object: */
elements.draggable({
snap:true,
containment:'parent',
start:function(e,ui){ ui.helper.css('z-index',++zIndex); },
stop:function(e,ui){
/* Sending the z-index and positon of the note to update_position.php via AJAX GET: */
$.get('update_position_config.php',{
x : ui.position.left,
y : ui.position.top,
id : ui.helper.attr('id')
});
}
});}
}); });

View File

@ -26,24 +26,5 @@ $(document).ready(function(){
/* A helper function for converting a set of elements to draggables: */ /* A helper function for converting a set of elements to draggables: */
make_draggable($('#weather')); make_draggable($('#weather'));
var zIndex = 0;
function make_draggable(elements)
{
/* Elements is a jquery object: */
elements.draggable({
snap:true,
containment:'parent',
start:function(e,ui){ ui.helper.css('z-index',++zIndex); },
stop:function(e,ui){
/* Sending the z-index and positon of the note to update_position.php via AJAX GET: */
$.get('ajax/update.php',{
x : ui.position.left,
y : ui.position.top,
id : ui.helper.attr('id')
});
}
});
}
}); });

View File

@ -35,6 +35,27 @@
{ {
window.open("calculator.html", "Calc", "menubar=0,resizable=0,width=320,height=360") window.open("calculator.html", "Calc", "menubar=0,resizable=0,width=320,height=360")
} }
var zIndex = 0;
function make_draggable(elements)
{
/* Elements is a jquery object: */
elements.draggable({
snap:true,
containment:'parent',
start:function(e,ui){ ui.helper.css('z-index',++zIndex); },
stop:function(e,ui){
/* Sending the z-index and positon of the note to update_position.php via AJAX GET: */
$.get('ajax/update.php',{
x : ui.position.left,
y : ui.position.top,
id : ui.helper.attr('id')
});
}
});
}
$(document).ready(function(){ $(document).ready(function(){
$('body').prepend('<div id="menu-bar"></div>'); $('body').prepend('<div id="menu-bar"></div>');
$('#menu-bar').prepend($('#config-menu')); $('#menu-bar').prepend($('#config-menu'));
@ -57,26 +78,5 @@ $(document).ready(function(){
'hideOnContentClick': false, 'hideOnContentClick': false,
'padding' : 15 'padding' : 15
}); });
/*$('#config-submit').live('click',function(e){
$(this).replaceWith('<img src="images/interface/ajax_load.gif" style="margin:30px auto;display:block" />');
var data3 = {
'clock' : $('input[type=radio][name=clock_group]:checked').attr('value'),
'weather' : $('input[type=radio][name=weather_group]:checked').attr('value'),
'notes' : $('input[type=radio][name=notes_group]:checked').attr('value'),
'search' : $('input[type=radio][name=search_group]:checked').attr('value'),
'links' : $('input[type=radio][name=links_group]:checked').attr('value'),
'blogs' : $('input[type=radio][name=blogs_group]:checked').attr('value'),
'todo' : $('input[type=radio][name=todo_group]:checked').attr('value')
};
$.post('ajax/post-config.php',data3,function(msg3){
if(msg3=="1"){
location.reload();
}
});
e.preventDefault();
});*/
}); });