Ajout de la fonctionnalité d'ajout de lien dans la reserve
This commit is contained in:
parent
3f3a219861
commit
2861556131
58
addLink.php
Normal file
58
addLink.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
$url = $_POST['urlField'];
|
||||||
|
$popup = $_POST['popupField'];
|
||||||
|
$img = $_FILES['imgField'];
|
||||||
|
$title = $_POST['titreField'];
|
||||||
|
|
||||||
|
// Préparation de l'image2
|
||||||
|
$content_dir = 'images/links/'; // dossier où sera déplacé le fichier
|
||||||
|
$tmp_file = $img['tmp_name']; // Fichier temporaire
|
||||||
|
|
||||||
|
// Vérification de l'upload
|
||||||
|
if( !is_uploaded_file($tmp_file) )
|
||||||
|
{
|
||||||
|
exit("Le fichier est introuvable");
|
||||||
|
}
|
||||||
|
|
||||||
|
// on vérifie maintenant l'extension
|
||||||
|
$type_file = $img['type'];
|
||||||
|
if( !strstr($type_file, 'jpg') && !strstr($type_file, 'jpeg') && !strstr($type_file, 'png') && !strstr($type_file, 'gif') )
|
||||||
|
{
|
||||||
|
exit("Le fichier n'est pas une image");
|
||||||
|
}
|
||||||
|
|
||||||
|
// on copie le fichier dans le dossier de destination
|
||||||
|
$name_file = $img['name'];
|
||||||
|
if( preg_match('#[\x00-\x1F\x7F-\x9F/\\\\]#', $name_file) )
|
||||||
|
{
|
||||||
|
exit("Nom de fichier non valide");
|
||||||
|
}
|
||||||
|
else if( !move_uploaded_file($tmp_file, $content_dir . $name_file) )
|
||||||
|
{
|
||||||
|
exit("Impossible de copier le fichier dans $content_dir");
|
||||||
|
}
|
||||||
|
|
||||||
|
$doc = new DOMDocument;
|
||||||
|
$doc->load('db/links.xml');
|
||||||
|
|
||||||
|
$xpath = new DOMXpath($doc);
|
||||||
|
|
||||||
|
// Creating new node
|
||||||
|
$newNode = $doc->createElement('link');
|
||||||
|
$newURL = $doc->createElement('url', $url);
|
||||||
|
if($popup == '1')
|
||||||
|
$newClick = $doc->createElement('onclick', 'popup');
|
||||||
|
else
|
||||||
|
$newClick = $doc->createElement('onclick', '');
|
||||||
|
$newImg = $doc->createElement('img', $name_file);
|
||||||
|
$newTitle = $doc->createElement('title', $title);
|
||||||
|
$newNode->appendChild($newURL);
|
||||||
|
$newNode->appendChild($newClick);
|
||||||
|
$newNode->appendChild($newImg);
|
||||||
|
$newNode->appendChild($newTitle);
|
||||||
|
|
||||||
|
|
||||||
|
$searchLabel = $xpath->query('reserve');
|
||||||
|
|
||||||
|
$searchLabel->item(0)->appendChild($newNode);
|
||||||
|
$doc->save('db/links.xml');
|
@ -13,6 +13,7 @@ class links {
|
|||||||
$this->setParams($params);
|
$this->setParams($params);
|
||||||
echo '<script type="text/javascript" src="js/jquery.links.js"></script>
|
echo '<script type="text/javascript" src="js/jquery.links.js"></script>
|
||||||
<link rel="stylesheet" href="css/links.css" type="text/css" />
|
<link rel="stylesheet" href="css/links.css" type="text/css" />
|
||||||
|
<div style="display:none;"><div id="links-add-fancy"></div></div>
|
||||||
<div class="appscontainer">';
|
<div class="appscontainer">';
|
||||||
if($links_xml = simplexml_load_file(self::LINKS_FILE)){
|
if($links_xml = simplexml_load_file(self::LINKS_FILE)){
|
||||||
$links = $links_xml->label;
|
$links = $links_xml->label;
|
||||||
|
@ -76,7 +76,7 @@
|
|||||||
#recherche{margin-top:70px;}
|
#recherche{margin-top:70px;}
|
||||||
|
|
||||||
#config {width:300px;}
|
#config {width:300px;}
|
||||||
#config-menu, #blog-links-manager, #city-menu , #jclockAdvanced-menu, #links-menu, #ouifm-menu{float:right; margin:12px 10px 0 0;}
|
#config-menu, #blog-links-manager, #city-menu , #jclockAdvanced-menu, #links-menu, #links-add-menu,#ouifm-menu{float:right; margin:12px 10px 0 0;}
|
||||||
#ouifm{position:absolute;width:144px;height:28px;}
|
#ouifm{position:absolute;width:144px;height:28px;}
|
||||||
|
|
||||||
/* Green button class: */
|
/* Green button class: */
|
||||||
|
BIN
images/interface/link_add.png
Normal file
BIN
images/interface/link_add.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 570 B |
@ -1,7 +1,17 @@
|
|||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
// Réglage des options
|
// Réglage des options
|
||||||
$('body').append('<img src="images/interface/link_edit.png" id="links-menu" />');
|
$('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-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
|
// Apparition de la reserve de liens
|
||||||
$('#links-menu').live('click', function(){
|
$('#links-menu').live('click', function(){
|
||||||
|
Loading…
Reference in New Issue
Block a user