Forum-webmaster
Technique - programmation => HTML / CSS / XHTML => Message commencé par: Cro_mag le le 11-10-2011 a 21:43:31

Titre: Editeur wysiwyg
Posté par: Cro_mag le le 11-10-2011 a 21:43:31

Bonjour,

J'ai pris un script de news "Admin News Tools", disponible a l'adresse
adminnewstools.free.fr
seulement mes news s'affichent vraiment trop simplement, j'aurais souhaité pouvoir mettre en forme tout ca avant de publié. Alors j'ai pensé a "un editeur wysiwyg" pour une fois ma news ecrite la modelé au mieux, mais je ne trouve pas avec quoi le faire..

A moins de pouvoir editer les fichiers de admin news tools, mais je ne vois pas ou

je voudrais qu'en plus mes news soient separées par une balise <hr>

merci d'avance pour votre aide

Titre: Re:Editeur wysiwyg
Posté par: Pad le le 11-10-2011 a 23:30:41

il te faudra modifier le code source. Mais il est assez simple d'intégrer une solution wysiwyg pour ton champs textarea de news (quelques lignes à ajouter seulement).

- http://ckeditor.com/
- http://www.tinymce.com/
- http://nicedit.com/

Sinon pour la balise <hr> c'est aussi directement dans ton code source, surement au niveau de la boucle (while ou for) qui est dans le fichier qui affiche les news.

Titre: Re:Editeur wysiwyg
Posté par: Cro_mag le le 13-10-2011 a 10:35:39

Bonjour Pad et merci de ta réponse

J'avais vu ces modules ou plutot scripts, le problème c'est que je ne vois pas comment l'installer.

Mon dossier admin news tool se decompose comme ceci

-Admin
/create.php
/edit.php
/edit_traitement.php
/index.php
/style.css
/images

- news.txt


create.php

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>Admin News Tools 3.0 - Panel</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="content-language" content="fr" />
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript">function showHide(thingId) {var element=document.getElementById(thingId);if (element.style.display=='') element.style.display='none';else element.style.display='';}</script>
</head>
<body>
<div style="text-align:center;">
<h2>Admin News Tools</h2>
<hr />

<?php
// Mettons le (future) fichier dans une variable.
$fichier="./../news.txt";

// Assignons nos 2 variables du formulaire et on en profite pour les protégers des balises HTML.
$titre=htmlspecialchars($_POST['titre']);
$news=($_POST['news']);

// Pensons au retour à la ligne et au stripslashes pour la variable $news.
$news=stripslashes(nl2br($news));

// On met en place quelques conditions pour les cellules (titre et news).
// On vérifie avant tout si le fichier existe si ce n'est pas le cas on le crée.
if(!is_file($fichier))
{
$verif=@fopen($fichier,"w+");
}

// On vérifie que le titre ou la news ne soient pas vide.
elseif (trim($news)=="" || trim($titre)=="")
{
echo "<p><strong><span style=\"color:red;\">Vous devez remplir tous les champs !</span></strong></p>
<p><a href=\"./create.html\"><img style=\"border:0;width:150px;height:30px\" src=\"./images/retour.png\" title=\"Retour\" alt=\"Retour\" /></a></p>";

// On sort du script.
exit;
}

// Après ces quelques vérification d'usage on passe à l'exécution de ce formulaire.


// Si ok on ouvre en écirture-enregistrement du fichier news.txt.
$verif=@fopen($fichier,"r+");

// On analyse les anciennes données et on les stocks.
$stock=@fread($verif,filesize($fichier));

// On met la date dans une varialbe.
$date=date ("d/m/Y à H:i");

// On paramère le tout ($contenue).
$contenue="<p><strong>".$titre."</strong> <small>( ".$date." )</small><br />\n".$news."</p>\n";

// On remet le curseur du fichier en début de ligne.
rewind($verif);

// On insère le nouveau commentaire.
fputs($verif,$contenue." \n".$stock);

// On clore le fichier.
fclose($verif);

// On affiche le tout.
echo '<p><strong><span style="color:green;">Votre news a bien été ajouté avec succès !</span></strong></p>
<p><a href="./index.php"><img style="border:0;width:150px;height:30px" src="./images/accueil.png" title="Accueil du panel" alt="Accueil du panel" /></a></p><hr />';
readfile($fichier);


?>

<hr /><small>&copy; 2009 - <a class="hypertexte" href="http://www.adminnewstools.fr.nf" onclick="window.open(this.href); return false;">Admin News Tools 3.0</a></small>
<p><a href="http://validator.w3.org/check?uri=referer"><img style="border:0;width:88px;height:31px" src="./images/vxhtml.png" alt="Valide XHTML 1.0 Strict" /></a> <a href="http://jigsaw.w3.org/css-validator/check/referer"><img style="border:0;width:88px;height:31px" src="./images/vcss.png" alt="Valide CSS !" /></a></p>
</div>
</body>
</html>



edit.php

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>Admin News Tools 3.0 - Panel</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="content-language" content="fr" />
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div style="text-align:center;">
<h2>Admin News Tools</h2>
<hr />
<?php $content=file_get_contents('./../news.txt'); ?>
<form method="post" action="edit-traitement.php">
<p><strong>Les news déjà publier :</strong><br />
<textarea name="content" rows="6" cols="66"><?php echo htmlentities($content); ?></textarea></p>
<p><input type="submit" name="ok" value="Modifier et/ou supprimer les news" /></p>
</form>
<hr />
<p><a href="./index.php"><img style="border:0;width:150px;height:30px" src="./images/accueil.png" title="Accueil du panel" alt="Accueil du panel" /></a></p><hr />
<small>&copy; 2009 - <a class="hypertexte" href="http://www.adminnewstools.fr.nf" onclick="window.open(this.href); return false;">Admin News Tools 3.0</a></small>
<p><a href="http://validator.w3.org/check?uri=referer"><img style="border:0;width:88px;height:31px" src="./images/vxhtml.png" alt="Valide XHTML 1.0 Strict" /></a> <a href="http://jigsaw.w3.org/css-validator/check/referer"><img style="border:0;width:88px;height:31px" src="./images/vcss.png" alt="Valide CSS !" /></a></p>
</div>
</body>
</html>



edit-traitement.php

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>Admin News Tools 3.0 - Panel</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="content-language" content="fr" />
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div style="text-align:center;">
<h2>Admin News Tools</h2>
<hr />
<?php
   if(isset($_POST['ok'])) {
      $fp=fopen('./../news.txt','w+');
      fwrite($fp,$_POST['content']);
      fclose($fp);
   }
?>
<p><strong><span style="color:green">Modification(s) et/ou suppression(s) effectuée avec succès !</span></strong></p>
<p><a href="./index.php"><img style="border:0;width:150px;height:30px" src="./images/accueil.png" title="Accueil du panel" alt="Accueil du panel" /></a></p><hr />
<small>&copy; 2009 - <a class="hypertexte" href="http://www.adminnewstools.fr.nf" onclick="window.open(this.href); return false;">Admin News Tools 3.0</a></small>
<p><a href="http://validator.w3.org/check?uri=referer"><img style="border:0;width:88px;height:31px" src="./images/vxhtml.png" alt="Valide XHTML 1.0 Strict" /></a> <a href="http://jigsaw.w3.org/css-validator/check/referer"><img style="border:0;width:88px;height:31px" src="./images/vcss.png" alt="Valide CSS !" /></a></p>
</div>
</body>
</html>



index.php

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>Admin News Tools 3.0 - Panel</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="content-language" content="fr" />
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div style="text-align:center;">
<h2>Admin News Tools</h2>
<hr />
<!-- Vérification des mise à jours -->
<?php
$maj="http://adminnewstools.free.fr/maj/30.html";
@readfile($maj);
?>
<!-- Vérification des mise à jours -->
<p><a href="./create.html"><img style="border:0;width:128px;height:128px" src="./images/creer.png" title="Ajouter une news" alt="Ajouter une news" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="./edit.php"><img style="border:0;width:128px;height:128px" src="./images/modif.png" title="Modifier et/ou supprimer les news" alt="Modifier et/ou supprimer les news" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="./faq.html"><img style="border:0;width:128px;height:128px" src="./images/help.png" title="FAQ" alt="FAQ" /></a></p><hr />
<p><a href="./../index.php" onclick="window.open(this.href); return false;"><img style="border:0;width:150px;height:30px" src="./images/votresite.png" title="Votre site" alt="Votre site" /></a></p><hr />
<small>&copy; 2009 - <a class="hypertexte" href="http://www.adminnewstools.fr.nf" onclick="window.open(this.href); return false;">Admin News Tools 3.0</a></small>
<p><a href="http://validator.w3.org/check?uri=referer"><img style="border:0;width:88px;height:31px" src="./images/vxhtml.png" alt="Valide XHTML 1.0 Strict" /></a> <a href="http://jigsaw.w3.org/css-validator/check/referer"><img style="border:0;width:88px;height:31px" src="./images/vcss.png" alt="Valide CSS !" /></a></p>
</div>
</body>
</html>



style.css

Code:
body {
background-image:url(images/fond.png);
background-repeat: repeat-x;
}
a.hypertexte { color: blue; }
a.hypertexte:hover { color: black;}
a { text-decoration: none; }


news.txt
et bien ce que j'ai tapé comme news apparait dans ce fichier txt

et un autre index.php qui est a la racine du dossier, mais j ai juste pris le morceau de code php pour faire apparaitre ma news a l'endroit que je souhaite

Si tu peux m'aider

Merci d'avance

Cro_mag

Titre: Re:Editeur wysiwyg
Posté par: Pad le le 13-10-2011 a 15:37:54

il faut télécharger l'un de ces scripts, uploader les fichiers sur ton hébergement et ensuite il faut ajouter 2-3 lignes de code (précisés sur les tutoriels d'installation de ces scripts) entre la balise <head></head> de ton fichier edit.php (je pense que c'est celui-ci) Ensuite il faut aussi ajouter une partie de code sur cette ligne (présente dans ce même fichier edit.php) :


Code:
<textarea name="content" rows="6" cols="66"><?php echo htmlentities($content); ?></textarea>

Titre: Re:Editeur wysiwyg
Posté par: Cro_mag le le 13-10-2011 a 18:16:50

Merci de ta réponse,

Désolé de faire le boulet mais j'arrive a rien là :-[


Forum-webmaster | Actionné par YaBB SE
© 2001-2003, YaBB SE Dev Team. Tous droits réservés.