1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
| <html>
<head>
<title>Génération de tableau MediaWiki</title>
<style type="text/css">
body {
background-color:#22314E;
font-family:"trebuchet ms",sans-serif;
color:#E3E3E1;
}
form {
background-color:#505E7C;
padding:10px; width:320px;
color:#000000;
border-radius:10px;
}
fieldset {
padding:0 20px 20px 20px;
margin-bottom:10px;
border:1px solid #FEDF63;
border-radius:5px;
}
legend {
color:#F8AF22;
font-weight:bold
}
label {
font-weight:bold;
color:#101325;
}
input, textarea {
background-color:#E3E3E1;
padding:3px;
border:0px solid #F5C5C5;
border-radius:5px;
width:200px;
box-shadow:1px 1px 2px #C0C0C0 inset;
}
textarea{
resize:vertical;
width:260px;
}
input[type=radio] {
background-color:transparent;
border:none;
width:10px;
}
input[type=submit], input[type=reset], input[type=button] {
margin-top:10px;
/*width:100px;*/
box-shadow:1px 1px 1px #F5C5C5;
cursor:pointer;
}
pre{
background-color:#FFF3F3;
color:#101325;
}
</style>
<script>
function addLine(line_id) {
try {
var conteneur = document.getElementById(line_id);
var paragraphe = document.createElement('p');
var ligne = document.createElement('textarea');
ligne.setAttribute('name','line_content[]');
ligne.setAttribute('id','line_content[]');
paragraphe.appendChild(ligne);
conteneur.appendChild(paragraphe);
}
catch(e) {
alert(e);
}
}
</script>
</head>
<body>
<h1>Génération de tableau MediaWiki</h1>
<form method="post">
<fieldset>
<legend>Paramètres du tableau</legend>
<p><label for="page_name">Nom de la page : </label><input type="text" name="page_name" id="page_name" required/></p>
<p><label for="leftcol">Colonne de gauche : </label><input type="text" name="leftcol" id="leftcol" value="ECRAN"/></p>
<p><label for="rightcol">Colonne de droite : </label><input type="text" name="rightcol" id="rightcol" value="COMMENTAIRE"/></p>
<p>
Indiquer le format des images :<br />
<input type="radio" name="image_format" value="jpg" id="jpg" /> <label for="jpg">.jpg</label>
<input type="radio" name="image_format" value="png" id="png" checked /> <label for="png">.png</label>
</p>
</fieldset>
<fieldset>
<legend>Contenu des lignes</legend>
<textarea name="line_content[]" required></textarea>
<div id = "ligne_sup"></div>
<input type="button" onclick="addLine('ligne_sup')" value="Ajouter une ligne"/>
</fieldset>
<fieldset align="center">
<legend>Validation des données</legend>
<input type="submit" name="save" value="Générer" />
<input type="reset" value="Reinitialiser" />
</fieldset>
</form>
<div class="result">
<h2>Texte à recopier dans MediaWiki</h2>
<?php
if (isset($_REQUEST['save'])) {
$inputs = filter_input_array(INPUT_POST, array(
'page_name' => FILTER_SANITIZE_ENCODED,
'leftcol' => FILTER_SANITIZE_ENCODED,
'rightcol' => FILTER_SANITIZE_ENCODED,
'image_format' => FILTER_SANITIZE_ENCODED,
));
$page_name = $inputs['page_name'];
$leftcol = $inputs['leftcol'];
$rightcol = $inputs['rightcol'];
$image_format = $inputs['image_format'];
$output = '
{| align="center" width="90%" border="1" cellspacing="0" cellpadding="5"
!<center>' . $leftcol . '</center>
!width="95%"|<center>' . $rightcol . '</center>
|------------------------------------------------------------
';
// récupération des textarea
$line_contents = $_POST['line_content']; // array !
$image_number=1;
foreach( $line_contents as $line_content )
{
if( !empty($line_content) )
{
$output .= '|[[image:' . $page_name . '_' . $image_number .'.' . $image_format . ']]
|' . $line_content . '
|------------------------------------------------------------
';
$image_number++;
}
}
echo '<pre>'.$output.'|}</pre>';
}
?>
</div>
</body>
</html> |
Partager