Version avec modules séparés !
This commit is contained in:
81
modules/links/Links.php
Normal file
81
modules/links/Links.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
class links extends Module{
|
||||
|
||||
protected $moduleName;
|
||||
protected $moduleTitle;
|
||||
protected $pathToModule;
|
||||
|
||||
protected static $paramsList = array(
|
||||
'visibility'
|
||||
);
|
||||
|
||||
const LINKS_FILE = 'db/links.xml';
|
||||
|
||||
public $params = array();
|
||||
|
||||
public function __construct($params){
|
||||
$this->moduleName = get_class();
|
||||
$this->pathToModule = 'modules/'.$this->moduleName.'/';
|
||||
$this->setParams($params);
|
||||
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" />
|
||||
<div style="display:none;"><div id="links-add-fancy"></div></div>
|
||||
<div class="appscontainer">';
|
||||
if($links_xml = simplexml_load_file($this->pathToModule.self::LINKS_FILE)){
|
||||
$links = $links_xml->label;
|
||||
foreach($links as $label){
|
||||
//<span class="label">'.$label['id'].'</span>
|
||||
echo '<ul class="iconlist" id="'.$label['id'].'">';
|
||||
foreach($label->link as $link){
|
||||
echo '<li class="iconitem" id="'.$link->title.'"><img src="images/interface/delete.png" class="deleteLink" /><a href="'.$link->url.'" class="'.$link->onclick.'"><img src="images/links/'.$link->img.'" /><br>'.$link->title.'</a></li>';
|
||||
}
|
||||
echo '</ul>
|
||||
<hr>';
|
||||
}
|
||||
}else{
|
||||
echo 'Can\'t find '.$this->pathToModule.self::LINKS_FILE;
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
private function setParams($params){
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
public static function start($params){
|
||||
$links = new links($params);
|
||||
}
|
||||
|
||||
public function setLink($link){
|
||||
// Saving the position and z-index of the note:
|
||||
$xmla = simplexml_load_file('../'.self::LINKS_FILE);
|
||||
|
||||
$path = $xmla->xpath("//item[@id='weather']");
|
||||
$path[0]->x = $x;
|
||||
|
||||
$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='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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
18
modules/links/ajax/listToReserve.php
Normal file
18
modules/links/ajax/listToReserve.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?
|
||||
$reserve = $_POST['reserve'];
|
||||
|
||||
$doc = new DOMDocument;
|
||||
$doc->load('../db/links.xml');
|
||||
|
||||
$xpath = new DOMXpath($doc);
|
||||
|
||||
// Buffering and deleting moved element
|
||||
foreach($xpath->query('label/link[title = "'.$reserve.'"]') as $node) {
|
||||
$buffer = $node;
|
||||
$node->parentNode->removeChild($node);
|
||||
}
|
||||
|
||||
$searchLabel = $xpath->query('reserve');
|
||||
|
||||
$searchLabel->item(0)->appendChild($buffer);
|
||||
$doc->save('../db/links.xml');
|
11
modules/links/ajax/loadReserve.php
Normal file
11
modules/links/ajax/loadReserve.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?
|
||||
if($links_xml = simplexml_load_file("../db/links.xml")){
|
||||
$links = $links_xml->reserve;
|
||||
foreach($links as $label){
|
||||
echo '<ul id="reserveiconlist">';
|
||||
foreach($label->link as $link){
|
||||
echo '<li class="iconitem" id="'.$link->title.'"><img src="images/interface/delete.png" class="deleteLink" /><a href="'.$link->url.'" class="'.$link->onclick.'"><img src="images/links/'.$link->img.'" /><br>'.$link->title.'</a></li>';
|
||||
}
|
||||
echo '</ul> ';
|
||||
}
|
||||
}
|
19
modules/links/ajax/reserveToList.php
Normal file
19
modules/links/ajax/reserveToList.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?
|
||||
$reserve = $_POST['reserve'];
|
||||
|
||||
$doc = new DOMDocument;
|
||||
$doc->load('../db/links.xml');
|
||||
|
||||
$xpath = new DOMXpath($doc);
|
||||
|
||||
// Buffering and deleting moved element
|
||||
foreach($xpath->query('reserve/link[title = "'.$reserve.'"]') as $node) {
|
||||
$buffer = $node;
|
||||
$node->parentNode->removeChild($node);
|
||||
}
|
||||
|
||||
$searchLabel = $xpath->query('label');
|
||||
$lastLabel = $searchLabel->length -1;
|
||||
|
||||
$searchLabel->item($lastLabel)->appendChild($buffer);
|
||||
$doc->save('../db/links.xml');
|
36
modules/links/ajax/update-links-order.php
Normal file
36
modules/links/ajax/update-links-order.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?
|
||||
$label = $_POST['label'];
|
||||
$order = $_POST['order'];
|
||||
$itemMoved = $_POST['itemMoved'];
|
||||
|
||||
$orderArray = explode(',', $order);
|
||||
$itemIndex = 0;
|
||||
|
||||
foreach($orderArray as $index=>$value){
|
||||
if($value == $itemMoved)
|
||||
$itemIndex = (int)$index;
|
||||
}
|
||||
|
||||
$itemAfter = '';
|
||||
if(isset($orderArray[$itemIndex+1]))
|
||||
$itemAfter = $orderArray[$itemIndex+1];
|
||||
|
||||
$doc = new DOMDocument;
|
||||
$doc->load('../db/links.xml');
|
||||
|
||||
$xpath = new DOMXpath($doc);
|
||||
|
||||
// Buffering and deleting moved element
|
||||
foreach($xpath->query('label/link[title = "'.$itemMoved.'"]') as $node) {
|
||||
$buffer = $node;
|
||||
$node->parentNode->removeChild($node);
|
||||
}
|
||||
|
||||
if($itemAfter != ''){
|
||||
$searchLabel = $xpath->query('label[@id="'.$label.'"]/link[title = "'.$itemAfter.'"]')->item(0);
|
||||
$searchLabel->parentNode->insertBefore($buffer, $searchLabel);
|
||||
}else{
|
||||
$searchLabel = $xpath->query('label[@id="'.$label.'"]');
|
||||
$searchLabel->item(0)->appendChild($buffer);
|
||||
}
|
||||
$doc->save('../db/links.xml');
|
165
modules/links/css/links.css
Normal file
165
modules/links/css/links.css
Normal file
@@ -0,0 +1,165 @@
|
||||
#reserve{display:none;background:#000;}
|
||||
.deleteLink{display:none; position:absolute; top:-5px; right:-5px;width:16px !important; height:16px !important;}
|
||||
|
||||
.divider {
|
||||
display:block;
|
||||
font-size:1px;
|
||||
border-width:0px;
|
||||
border-style:solid;
|
||||
border-top-width:1px;
|
||||
margin:9px 0px 4px -2px;
|
||||
border-color:#BFBFBF;
|
||||
}
|
||||
|
||||
ul.iconlist li, ul#reserveiconlist li{
|
||||
/*display:inline-block;*/
|
||||
position:relative;
|
||||
float:left;
|
||||
margin:0 10px 10px 0;
|
||||
text-align:center;
|
||||
font-weight:bold;
|
||||
color:#2D406D;
|
||||
}
|
||||
|
||||
ul.iconlist li a, ul#reserveiconlist li a {
|
||||
display:block;
|
||||
padding:6px;
|
||||
margin:0px;
|
||||
text-align:center;
|
||||
font-weight:bold;
|
||||
|
||||
/*background-color:rgba(235,239,249,0.0);*/
|
||||
background-color:#FFFFFF;
|
||||
cursor:pointer;
|
||||
-webkit-border-radius: 10px;
|
||||
width:96px;
|
||||
/*height:86px;*/
|
||||
height:66px;
|
||||
-webkit-transition: background-color 0.3s ease-out ;
|
||||
|
||||
}
|
||||
|
||||
ul.iconlist li a:hover, ul#reserveiconlist li a:hover {
|
||||
background-color:#ebeff9;
|
||||
-webkit-transition: background-color 0s ease-out ;
|
||||
|
||||
}
|
||||
|
||||
ul.iconlist li.disabled a:hover {
|
||||
background-color:white;
|
||||
opacity:0.5;
|
||||
|
||||
}
|
||||
|
||||
ul.iconlist li.disabled a {
|
||||
background-color:white;
|
||||
opacity:0.5;
|
||||
cursor:default;
|
||||
|
||||
}
|
||||
|
||||
ul.iconlist li a img, ul#reserveiconlist li a img{
|
||||
x-webkit-transition: -webkit-transform 0.3s ease-out ;
|
||||
|
||||
}
|
||||
|
||||
ul.iconlist li a:hover img, ul#reserveiconlist li a:hover{
|
||||
x-webkit-transform: scale(1.1);
|
||||
x-webkit-transition: -webkit-transform 0.0s ease-out ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
ul.iconlist, ul#reserveiconlist {
|
||||
display:block;
|
||||
height:75px;
|
||||
padding:5px;
|
||||
list-style:none;
|
||||
}
|
||||
|
||||
ul.iconlist img, ul#reserveiconlist img{
|
||||
width:64px;
|
||||
height:64px;
|
||||
margin-bottom:1px;
|
||||
}
|
||||
|
||||
div.sidemenu{
|
||||
xbackground:rgba(255,255,255,0.8);
|
||||
x-webkit-border-radius: 5px;
|
||||
xborder: 1px solid rgba(0,0,0,0.3);
|
||||
x-webkit-box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.15);
|
||||
width:150px;
|
||||
margin-left: 0px;
|
||||
height:90%;
|
||||
display:none;
|
||||
float:left;
|
||||
border-right:1px solid red;
|
||||
}
|
||||
|
||||
div.appscontainer {
|
||||
width:730px;
|
||||
margin:20px auto;
|
||||
padding:0px;
|
||||
/*background:red;*/
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
xmargin-left:160px;
|
||||
background:rgba(255,255,255,0.8);
|
||||
overflow:auto;
|
||||
|
||||
border: 1px solid rgba(0,0,0,0.3);
|
||||
-webkit-box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.15);
|
||||
-moz-box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
hr {
|
||||
clear:left;
|
||||
border:none;
|
||||
height:0px;
|
||||
border-bottom:1px solid #eee;
|
||||
}
|
||||
|
||||
.label {
|
||||
display:none;
|
||||
float:Right;
|
||||
padding-top:6px;
|
||||
padding-right:6px;
|
||||
color:#fff;
|
||||
}
|
||||
|
||||
.fakelocation {
|
||||
background:white;
|
||||
height:38px;
|
||||
background:-webkit-gradient(linear, left top, left bottom, from(#fff), to(#ebeff9));
|
||||
border-bottom:1px solid #eee;
|
||||
padding:0;
|
||||
display:none;
|
||||
}
|
||||
|
||||
a.getmore {
|
||||
display:block;
|
||||
text-align:right;
|
||||
padding:10px;
|
||||
|
||||
}
|
||||
|
||||
div.url {
|
||||
font-weight:normal;
|
||||
opacity:0;
|
||||
position:absolute;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
ul.iconlist li:hover div.url, ul#reserveiconlist li:hover div.url{
|
||||
opacity:.5;
|
||||
}
|
||||
li.selected {
|
||||
background-color:#D6DEF7 !important;
|
||||
}
|
||||
|
||||
li.vseparator {
|
||||
width:1px;
|
||||
height:86px;
|
||||
background-color:red;
|
||||
}
|
168
modules/links/db/links.xml
Normal file
168
modules/links/db/links.xml
Normal file
@@ -0,0 +1,168 @@
|
||||
<links>
|
||||
<label id="Google Apps">
|
||||
<link>
|
||||
<url>http://mail.google.com</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>gmail_128.png</img>
|
||||
<title>Gmail</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>http://mail.live.com</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>mail-msn.png</img>
|
||||
<title>Hotmail</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>http://mail1.voila.fr/webmail/fr_FR/login.html</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>voila.png</img>
|
||||
<title>Voila.fr mail</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>http://calendar.google.com</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>calendar_128.png</img>
|
||||
<title>GoogleCalendar</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>http://reader.google.com</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>reader_128.png</img>
|
||||
<title>Google Reader</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>http://docs.google.com</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>docs_128.png</img>
|
||||
<title>Google Docs</title>
|
||||
</link>
|
||||
</label>
|
||||
<label id="Media">
|
||||
<link>
|
||||
<url>http://youtube.com</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>youtube_128.png</img>
|
||||
<title>YouTube</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>http://picasaweb.com</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>picasaweb_128.png</img>
|
||||
<title>PicasaWeb</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>http://www.netvibes.com</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>netvibes.png</img>
|
||||
<title>Netvibes</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>http://www.deviantart.com</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>deviantART128.png</img>
|
||||
<title>DeviantArt</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>https://www.labanquepostale.fr/index.html</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>banquepostale.png</img>
|
||||
<title>Banque 1</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>http://www.societegenerale.fr/</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>societegenerale.png</img>
|
||||
<title>Banque 2</title>
|
||||
</link>
|
||||
</label>
|
||||
<label id="Desk Accessories">
|
||||
<link>
|
||||
<url>javascript: openContactList()</url>
|
||||
<onclick></onclick>
|
||||
<img>contacts.png</img>
|
||||
<title>Contacts</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>javascript: openCalculator();</url>
|
||||
<onclick></onclick>
|
||||
<img>calculator.png</img>
|
||||
<title>Calculator</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>javascript: openTodo();</url>
|
||||
<onclick></onclick>
|
||||
<img>tasks.png</img>
|
||||
<title>To-do list</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>javascript: openCalendar();</url>
|
||||
<onclick></onclick>
|
||||
<img>calendar_128.png</img>
|
||||
<title>Calendar Panel</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>javascript: openNotepad();</url>
|
||||
<onclick></onclick>
|
||||
<img>notepad.png</img>
|
||||
<title>NotePad</title>
|
||||
</link>
|
||||
</label>
|
||||
<label id="Entertainment">
|
||||
<link>
|
||||
<url>http://facebook.com</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>facebook.png</img>
|
||||
<title>Facebook</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>http://twitter.com</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>twitter.png</img>
|
||||
<title>Twitter</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>http://fr.vente-privee.com/</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>vp128.png</img>
|
||||
<title>Ventes Privées</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>http://www.google.fr/movies</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>Gmovie.png</img>
|
||||
<title>Horaires Ciné</title>
|
||||
</link>
|
||||
</label>
|
||||
<reserve>
|
||||
<link>
|
||||
<url>http://fr.mail.yahoo.com/</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>mail-yahoo.png</img>
|
||||
<title>Yahoo Mail</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>http://www.meebo.com/messenger/</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>meebo.png</img>
|
||||
<title>Meebo</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>http://www.mail.com</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>mailcom.png</img>
|
||||
<title>Mail.com</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>http://www.xp-dev.com</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>xp-dev.png</img>
|
||||
<title>XP-DEV</title>
|
||||
</link>
|
||||
<link>
|
||||
<url>http://www.leboncoin.fr</url>
|
||||
<onclick>popup</onclick>
|
||||
<img>leboncoin.gif</img>
|
||||
<title>LeBonCoin</title>
|
||||
</link>
|
||||
</reserve>
|
||||
</links>
|
80
modules/links/js/links.js
Normal file
80
modules/links/js/links.js
Normal file
@@ -0,0 +1,80 @@
|
||||
$(document).ready(function(){
|
||||
// Réglage des options
|
||||
$('body').append('<img src="images/interface/link_edit.png" id="links-menu" />');
|
||||
$('body').append('<img src="images/interface/link_add.png" id="links-add-menu" />');
|
||||
$('#menu-bar').prepend($('#links-menu'));
|
||||
$('#menu-bar').prepend($('#links-add-menu'));
|
||||
$('#links-add-fancy').append('<form action="addLink.php" enctype="multipart/form-data" method="POST"><label for="urlField">URL : </label><input type="text" name="urlField" id="urlField"/><br/><label for="popupField">popup ? </label><input type="checkbox" name="popupField" id="popupField" checked="checked" value="1" /><br/><label for="imgField">Icône : </label><input type="file" name="imgField" id="imgField"/><br/><label for="titreField">Titre : </label><input type="text" name="titreField" id="titreField"/><br/><input type="submit" class="green-button" id="links-add-submit" value="Envoyer"/></form>');
|
||||
|
||||
// Apparition du menu d'ajout de lien
|
||||
$('#links-add-menu').live('click', function(){
|
||||
$.fancybox(
|
||||
$('#links-add-fancy').html()
|
||||
);
|
||||
});
|
||||
|
||||
// Apparition de la reserve de liens
|
||||
$('#links-menu').live('click', function(){
|
||||
$.get('modules/links/ajax/loadReserve.php', function(html){
|
||||
$.fancybox(
|
||||
html,
|
||||
{
|
||||
'autoDimensions' : false,
|
||||
'width' : 400,
|
||||
'height' : 'auto',
|
||||
'showNavArrows' : false,
|
||||
'transitionIn' : 'elastic'
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
// Passage Reserve => Liste
|
||||
$('#reserveiconlist .iconitem').live('click', function(e){
|
||||
e.preventDefault();
|
||||
$.post("modules/links/ajax/reserveToList.php", {reserve: $(this).attr('id')});
|
||||
$('.iconlist').last().append('<li class="iconitem" id="'+$(this).attr('id')+'">'+$(this).html()+'</li>');
|
||||
$.fancybox.close();
|
||||
});
|
||||
|
||||
|
||||
//Passage Liste => Reserve
|
||||
$('.iconitem').mouseover(function(){
|
||||
$(this).children('.deleteLink').show();
|
||||
});
|
||||
$('.iconitem').mouseout(function(){
|
||||
$(this).children('.deleteLink').hide();
|
||||
});
|
||||
|
||||
$('.deleteLink').click(function(){
|
||||
$.post("modules/links/ajax/listToReserve.php", {reserve: $(this).parent().attr('id')});
|
||||
$(this).parent().fadeOut();
|
||||
});
|
||||
|
||||
// Mouvement des liens avec enregistrement
|
||||
$(".iconlist").sortable(
|
||||
{
|
||||
connectWith: '.iconlist',
|
||||
update: function(event,ui){
|
||||
var linkOrder = $(this).sortable('toArray').toString();
|
||||
var label = $(ui.item).parent()[0].id;
|
||||
var itemMoved = $(ui.item)[0].id;
|
||||
$.post("modules/links/ajax/update-links-order.php", {order: linkOrder, label : label, itemMoved: itemMoved});
|
||||
},
|
||||
start: function(e) {
|
||||
// have to remvoe click handler off item so drop doesn't click
|
||||
$("a.popup").unbind("click");
|
||||
}
|
||||
}
|
||||
).disableSelection().mouseout(function(){
|
||||
// reattach the item click handler
|
||||
$('a.popup').unbind("click").bind("click", function(e){
|
||||
e.preventDefault();
|
||||
var url = $(this).attr('href');
|
||||
spawnURL(url);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
Reference in New Issue
Block a user