Files
le-matelot/client/plugins/contsuivprec/Contsuivprec.class.php
2020-01-27 08:56:08 +01:00

132 lines
3.9 KiB
PHP

<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) Octolys Development */
/* email : thelia@octolys.fr */
/* web : http://www.octolys.fr */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License, or */
/* (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* */
/*************************************************************************************/
?>
<?php
include_once(realpath(dirname(__FILE__)) . "/../../../classes/PluginsClassiques.class.php");
class Contsuivprec extends PluginsClassiques{
function Prodsuivprec(){
$this->PluginsClassiques();
}
function init(){
$cnx = new Cnx();
}
function destroy(){
}
function boucle($texte, $args){
$i=0;
// récupération des arguments
$id = lireTag($args, "id");
$suivant = lireTag($args, "suivant");
$precedent = lireTag($args, "precedent");
$dossier = lireTag($args, "dossier");
$order = "";
$search = "";
$res = "";
if ($dossier!="") $search = "and dossier = \"$dossier\"";
//requete
$query_cont = "SELECT * FROM contenu where 1 $search $order";
$resul_cont = mysql_query($query_cont);
$nb_cont = mysql_num_rows($resul_cont);
while($row = mysql_fetch_assoc($resul_cont)){
if($row["id"] != $id) $i++;
else break;
}
//récupération de la position de l'élèment suivant et précédent
$posprec = $i-1;
$possuiv = $i+1;
//test si la boucle est pour le contenu précédent
if ($precedent=="1"){
if ($posprec >= 0){
$query_prec = "SELECT id FROM contenu where 1 $search $order limit $posprec,1";
$resul_prec = mysql_query($query_prec);
$cont_prec = mysql_fetch_row($resul_prec);
}
else {
return "";
}
}
//test si la boucle est pour le produit suivant
if ($suivant=="1"){
if ($possuiv < $nb_cont){
$query_suiv = "SELECT id FROM contenu where 1 $search $order limit $possuiv,1";
$resul_suiv = mysql_query($query_suiv);
$cont_suiv = mysql_fetch_row($resul_suiv);
}
else {
return "";
}
}
//renvoie des données
$temp = str_replace("#IDPREC", $cont_prec[0], $texte);
$temp = str_replace("#TEXTEPREC", $texte_prec[1], $texte);
$temp = str_replace("#IDSUIV", $cont_suiv[0], $temp);
$temp = str_replace("#TEXTESUIV", $texte_suiv[1], $temp);
$res .= $temp;
return $res;
}
function action($res){
}
}
?>