Browse Source

Ajout de la fonctionnalité d'ajout de lien dans la reserve

remotes/svn/ModulesALaMano
Chouchen 9 years ago
parent
commit
2861556131
5 changed files with 70 additions and 1 deletions
  1. +58
    -0
      addLink.php
  2. +1
    -0
      class/Links.php
  3. +1
    -1
      css/main.css
  4. BIN
      images/interface/link_add.png
  5. +10
    -0
      js/jquery.links.js

+ 58
- 0
addLink.php View 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');

+ 1
- 0
class/Links.php View File

@@ -13,6 +13,7 @@ class links {
$this->setParams($params);
echo '<script type="text/javascript" src="js/jquery.links.js"></script>
<link rel="stylesheet" href="css/links.css" type="text/css" />
<div style="display:none;"><div id="links-add-fancy"></div></div>
<div class="appscontainer">';
if($links_xml = simplexml_load_file(self::LINKS_FILE)){
$links = $links_xml->label;


+ 1
- 1
css/main.css View File

@@ -76,7 +76,7 @@
#recherche{margin-top:70px;}
#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;}
/* Green button class: */


BIN
images/interface/link_add.png View File

Before After
Width: 16  |  Height: 16  |  Size: 570 B

+ 10
- 0
js/jquery.links.js
File diff suppressed because it is too large
View File


Loading…
Cancel
Save