function contenuassoc_contenu() { if ($_GET['type'] == 1) { $objet = new Produit(); $objet->charger($_GET['objet']); } else { $objet = new Rubrique(); $objet->charger($_GET['objet']); } $contenu = new Contenu(); $query = "select * from {$contenu->table} where dossier=\"" . $_GET['id_dossier'] . "\""; $resul = $contenu->query($query); while ($resul && ($row = $contenu->fetch_object($resul))) { $contenuassoc = new Contenuassoc(); if ($contenuassoc->existe($objet->id, $_GET['type'], $row->id)) { continue; } $contenudesc = new Contenudesc(); $contenudesc->charger($row->id); ?> <option value="<?php echo $row->id; ?> "><?php echo $contenudesc->titre; ?> </option> <?php } }
function contenuassoc_contenu($request) { if ($request->query->get('type') == 1) { $objet = new Produit(); $objet->charger($request->query->get('objet')); } else { $objet = new Rubrique(); $objet->charger($request->query->get('objet')); } $contenu = new Contenu(); $query = "select * from {$contenu->table} where dossier=\"" . $request->query->get('id_dossier') . "\""; $resul = $contenu->query($query); while ($resul && ($row = $contenu->fetch_object($resul))) { $contenuassoc = new Contenuassoc(); if (!in_array($row->id, explode('-', $request->query->get('force_show_content'))) && $contenuassoc->existe($objet->id, $request->query->get('type'), $row->id) || in_array($row->id, explode('-', $request->query->get('force_hide_content')))) { continue; } $contenudesc = new Contenudesc(); $contenudesc->charger($row->id); ?> <option value="<?php echo $row->id; ?> "><?php echo $contenudesc->titre; ?> </option> <?php } }
function lister_contenuassoc($type, $objet) { if ($type == 1) { $obj = new Produit(); $obj->charger($objet); } else { $obj = new Rubrique(); $obj->charger($objet); } $contenuassoc = new Contenuassoc(); $contenua = new Contenu(); $contenuadesc = new Contenudesc(); $query = "select * from {$contenuassoc->table} where type='{$type}' and objet='{$obj->id}' order by classement"; $resul = $contenuassoc->query($query); $i = 0; while ($resul && ($row = $contenuassoc->fetch_object($resul))) { $fond = $i++ % 2 ? "fonce" : "claire"; $contenua->charger($row->contenu); $contenuadesc->charger($contenua->id); $dossierdesc = new Dossierdesc(); $dossierdesc->charger($contenua->dossier); ?> <li class="<?php echo $fond; ?> "> <div class="cellule" style="width:260px;"><?php echo $dossierdesc->titre; ?> </div> <div class="cellule" style="width:260px;"><?php echo $contenuadesc->titre; ?> </div> <div class="cellule_supp"><a href="javascript:contenuassoc_supprimer(<?php echo $row->id; ?> , <?php echo $type; ?> ,'<?php echo $objet; ?> ')"><img src="gfx/supprimer.gif" /></a></div> </li> <?php } }
function substitcontenu($texte) { global $motcle, $id_contenu; $tcontenu = new Contenu(); $tcontenudesc = new Contenudesc(); $url = ""; if ($id_contenu) { if ($tcontenu->charger($id_contenu)) { $tcontenudesc->charger($tcontenu->id); $url = $tcontenudesc->getUrl(); } } $texte = str_replace("#CONTENU_URL", $url, $texte); $texte = str_replace("#CONTENU_ID", "{$id_contenu}", $texte); $texte = str_replace("#CONTENU_MOTCLE", "{$motcle}", $texte); $texte = str_replace("#CONTENU_NOM", $tcontenudesc->titre, $texte); $texte = str_replace("#CONTENU_CHAPO", $tcontenudesc->chapo, $texte); $texte = str_replace("#CONTENU_DESCRIPTION", $tcontenudesc->description, $texte); $texte = str_replace("#CONTENU_POSTSCRIPTUM", $tcontenudesc->postscriptum, $texte); return $texte; }
public function getList($type, $objet) { $return = array(); if ($type == 1) { $objectInstance = new Produit(); $objectInstance->charger($objet); } else { $objectInstance = new Rubrique(); $objectInstance->charger($objet); } $qList = "SELECT * FROM " . self::TABLE . " WHERE type='{$type}' AND objet='{$objectInstance->id}' ORDER BY classement"; $rList = $this->query($qList); while ($rList && ($theAssociatedContent = $this->fetch_object($rList))) { $content = new Contenu($theAssociatedContent->contenu); $contentDescription = new Contenudesc(); $contentDescription->charger($content->id); $folderDescription = new Dossierdesc(); $folderDescription->charger($content->dossier); $return[] = array('id' => $theAssociatedContent->id, 'folder_id' => $folderDescription->dossier, 'folder_titre' => $folderDescription->titre, 'content_id' => $contentDescription->contenu, 'content_titre' => $contentDescription->titre); } return $return; }
function ajouter($lang, $dossier, $ligne, $titre, $chapo, $description, $postscriptum) { if (!isset($id)) { $id = ""; } $contenu = new Contenu(); $contenu->charger($id); if ($contenu->id) { return; } $contenu = new Contenu(); $contenu->datemodif = date("Y-m-d H:i:s"); $contenu->dossier = $dossier; if ($ligne == "on") { $contenu->ligne = 1; } else { $contenu->ligne = 0; } $lastid = $contenu->add(); $contenu->id = $lastid; $contenudesc = new Contenudesc(); $contenudesc->chapo = $chapo; $contenudesc->description = $description; $contenudesc->postscriptum = $postscriptum; $contenudesc->contenu = $lastid; $contenudesc->lang = $lang; $contenudesc->titre = $titre; $contenudesc->chapo = str_replace("\n", "<br/>", $contenudesc->chapo); $contenudesc->postscriptum = str_replace("\n", "<br/>", $contenudesc->postscriptum); $contenudesc->add(); $contenudesc->reecrire(); ActionsModules::instance()->appel_module("ajoutcont", $contenu); redirige($_SERVER['PHP_SELF'] . "?id=" . $lastid . "&dossier=" . $contenu->dossier); exit; }
function ancien_rewrite_cont($id, $lang = 1) { $cont = new Contenu(); $cont->charger($id); $dosfinal = $cont->dossier; $chem = chemin_dos($dosfinal); if (!empty($chem)) { $dossierdesc = new Dossierdesc(); $listdos = ""; $dossierdesc->charger($chem[count($chem) - 1]->dossier, $lang); $listdos .= $dossierdesc->titre . "__"; $dossierdesc->charger($chem[0]->dossier, $lang); $listdos .= $dossierdesc->dossier . "_"; for ($i = count($chem) - 2; $i >= 0; $i--) { $dossierdesc->charger($chem[$i]->dossier, $lang); $listdos .= $dossierdesc->titre . "_"; } $contenudesc = new Contenudesc(); if (!$contenudesc->charger($cont->id, $lang)) { return ""; } $listdos .= $contenudesc->titre . "_" . $cont->id . ".html"; return eregurl($listdos); } else { return ""; } }
exit; } header('Content-Type: text/html; charset=utf-8'); list($modif, $id) = explode("_", lireParam("id", "string")); if (strstr($modif, "dos") !== false) { $obj = new Dossier(); $obj->charger($id); $objdesc = new Dossierdesc(); $objdesc->charger($obj->id); $point_entree = "moddcont"; $champ_parent = "parent"; } else { if (strstr($modif, "cont") !== false) { $obj = new Contenu(); $obj->charger($id); $objdesc = new Contenudesc(); $objdesc->charger($obj->id); $point_entree = "moddos"; $champ_parent = "dossier"; } else { exit; } } switch ($modif) { case 'titrecont': case 'titredos': $objdesc->titre = lireParam("value", "string"); echo $objdesc->titre; break; case 'lignecont': case 'lignedos':
function boucleContenu($texte, $args, $type = 0) { global $page, $totbloc, $id_contenu; // récupération des arguments $dossier = lireTag($args, "dossier", "int"); $ligne = lireTag($args, "ligne", "int"); $deb = lireTag($args, "deb", "int"); $num = lireTag($args, "num", "int"); $bloc = lireTag($args, "bloc", "int"); $id = lireTag($args, "id", "int_list"); $motcle = lireTag($args, "motcle", "string+\\s\\'"); $classement = lireTag($args, "classement", "string"); $aleatoire = lireTag($args, "aleatoire", "int"); $produit = lireTag($args, "produit", "int"); $rubrique = lireTag($args, "rubrique", "int"); $profondeur = lireTag($args, "profondeur", "int"); $courant = lireTag($args, "courant", "int"); $exclusion = lireTag($args, "exclusion", "int_list"); $forcepage = lireTag($args, "forcepage", "int"); if ($bloc) { $totbloc = $bloc; } if (!$deb) { $deb = 0; } if ($page) { $_SESSION['navig']->page = $page; } if (!$page || $page == 1) { $page = 0; } if (!$totbloc) { $totbloc = 1; } if ($page) { $deb = ($page - 1) * $totbloc * $num + $deb; } if ($forcepage != "") { if ($forcepage == 1) { $forcepage = 0; $deb = 0; } if ($forcepage) { $deb = ($forcepage - 1) * $totbloc * $num + $deb; } } // initialisation de variables $search = ""; $order = ""; $comptbloc = 0; $virg = ""; $limit = ""; $res = ""; // preparation de la requete if ($dossier != "") { if ($profondeur == "") { $profondeur = 0; } $rec = arbreBoucle_dos($dossier, $profondeur); $rec = rtrim($rec, ","); if ($rec) { $virg = ","; } $search .= " and dossier in('{$dossier}'{$virg}{$rec})"; } if ($ligne == "") { $ligne = "1"; } $search .= " and ligne=\"{$ligne}\""; if ($id != "") { $search .= " and id in({$id})"; } if ($courant == "1") { $search .= " and id='{$id_contenu}'"; } else { if ($courant == "0") { $search .= " and id!='{$id_contenu}'"; } } if ($exclusion != "") { $search .= " and id not in({$exclusion})"; } if ($bloc == "-1") { $bloc = "999999999"; } if ($bloc != "" && $num != "") { $limit .= " limit {$deb},{$bloc}"; } else { if ($num != "") { $limit .= " limit {$deb},{$num}"; } } $liste = ""; if ($rubrique != "" || $produit != "") { if ($rubrique) { $type_obj = 0; $objet = $rubrique; } else { $type_obj = 1; $objet = $produit; } $contenuassoc = new Contenuassoc(); $query = "select * from {$contenuassoc->table} where objet=\"" . $objet . "\" and type=\"" . $type_obj . "\""; $resul = CacheBase::getCache()->query($query); if (empty($resul)) { return ""; } foreach ($resul as $row) { $liste .= "'" . $row->contenu . "',"; } $liste = rtrim($liste, ","); if ($liste != "") { $search .= " and id in ({$liste})"; } else { $search .= " and id in ('')"; } $type_obj = ""; } if ($aleatoire) { $order = "order by " . " RAND()"; } else { if ($classement == "manuel") { $order = "order by classement"; } else { if ($classement == "inverse") { $order = "order by classement desc"; } else { if ($classement == "date") { $order = "order by datemodif desc"; } } } } $contenu = new Contenu(); $contenudesc = new Contenudesc(); if ($motcle) { $motcle = $contenu->escape_string(strip_tags(trim($motcle))); $liste = ""; $query = "\n\t\t\t\tSELECT cd.contenu FROM\n\t\t\t\t\t{$contenudesc->table} cd\n\t\t\t\tWHERE\n cd.lang = " . ActionsLang::instance()->get_id_langue_courante() . "\n AND (\n\t\t\t\t\tmatch(cd.titre, cd.chapo, cd.description, cd.postscriptum) AGAINST ('{$motcle}' IN BOOLEAN MODE)\n\t\t\t\tOR\n\t\t\t\t\tcd.titre REGEXP '[[:<:]]{$motcle}[[:>:]]'\n\t\t\t\tOR\n\t\t\t\t \tcd.chapo REGEXP '[[:<:]]{$motcle}[[:>:]]'\n\t\t\t\tOR\n\t\t\t\t \tcd.description REGEXP '[[:<:]]{$motcle}[[:>:]]'\n\t\t\t\tOR\n\t\t\t\t \tcd.postscriptum REGEXP '[[:<:]]{$motcle}[[:>:]]'\n \t\t\t)\n\t\t\t"; $resul = CacheBase::getCache()->query($query); if (empty($resul)) { return ""; } foreach ($resul as $row) { $liste .= "'{$row->contenu}',"; } $liste = rtrim($liste, ','); $query = "select * from {$contenu->table} where id in ({$liste}) and ligne=\"{$ligne}\" {$limit}"; $saveReq = "select * from {$contenu->table} where id in ({$liste}) and ligne=\"{$ligne}\""; } else { $query = "select * from {$contenu->table} where 1 {$search} {$order} {$limit}"; } $saveReq = "select * from {$contenu->table} where 1 {$search}"; $resul = CacheBase::getCache()->query($query); if (empty($resul)) { return ""; } // substitutions if ($type) { return $query; } $saveReq = str_replace("*", "count(*) as totcount", $saveReq); $saveRes = CacheBase::getCache()->query($saveReq); $countRes = $saveRes[0]->totcount; $compt = 1; foreach ($resul as $row) { if ($num > 0) { if ($comptbloc >= ceil($countRes / $num) && $bloc != "") { continue; } } if ($comptbloc == 0) { $debcourant = 0; } else { $debcourant = $num * $comptbloc; } $comptbloc++; $dossierdesc = new Dossierdesc(); $dossierdesc->charger($row->dossier); $contenudesc = new Contenudesc(); $contenudesc->charger($row->id); $temp = $texte; $temp = str_replace("#DATE", substr($row->datemodif, 0, 10), $temp); $temp = str_replace("#HEURE", substr($row->datemodif, 11), $temp); $temp = str_replace("#DEBCOURANT", "{$debcourant}", $temp); $temp = str_replace("#ID", "{$row->id}", $temp); $temp = str_replace("#DOSSIER", "{$row->dossier}", $temp); $temp = str_replace("#TITRE", "{$contenudesc->titre}", $temp); $temp = str_replace("#STRIPTITRE", strip_tags($contenudesc->titre), $temp); $temp = str_replace("#CHAPO", "{$contenudesc->chapo}", $temp); $temp = str_replace("#STRIPCHAPO", strip_tags($contenudesc->chapo), $temp); $temp = str_replace("#DESCRIPTION", str_replace("../", "", $contenudesc->description), $temp); $temp = str_replace("#POSTSCRIPTUM", "{$contenudesc->postscriptum}", $temp); $temp = str_replace("#STRIPDESCRIPTION", strip_tags($contenudesc->description), $temp); $temp = str_replace("#URL", $contenudesc->getUrl(), $temp); $temp = str_replace("#REWRITEURL", $contenudesc->getUrl(), $temp); $temp = str_replace("#DOSTITRE", "{$dossierdesc->titre}", $temp); $temp = str_replace("#PRODUIT", "{$produit}", $temp); $temp = str_replace("#RUBRIQUE", "{$rubrique}", $temp); $temp = str_replace("#COMPT", "{$compt}", $temp); $res .= $temp; $compt++; } return $res; }
function rewrite_cont($id, $lang = false) { $desc = new Contenudesc($id, $lang); return $desc->charger_reecriture()->url; }
function lister_contenus($parent, $critere, $order, $alpha) { $contenu = new Contenu(); $contenudesc = new Contenudesc(); if ($alpha == "alpha") { $query = "select c.id, c.ligne, c.classement from {$contenu->table} c LEFT JOIN {$contenudesc->table} cd ON cd.contenu = c.id and lang=" . ActionsLang::instance()->get_id_langue_courante() . " where dossier=\"{$parent}\" order by cd.{$critere} {$order}"; } else { $query = "select id, ligne, classement from {$contenu->table} where dossier=\"{$parent}\" order by {$critere} {$order}"; } $resul = $contenu->query($query); $i = 0; while ($resul && ($row = $contenu->fetch_object($resul))) { $contenudesc = new Contenudesc(); $contenudesc->charger($row->id); if (!$contenudesc->affichage_back_office_permis()) { continue; } $fond = "ligne_" . ($i++ % 2 ? "claire" : "fonce") . "_rub"; ?> <ul class="<?php echo $fond; ?> "> <li style="width:627px;"> <span id="titrecont_<?php echo $row->id; ?> " <?php if ($contenudesc->est_langue_courante()) { echo 'class="texte_edit"'; } ?> ><?php echo substr($contenudesc->titre, 0, 90); if (strlen($contenudesc->titre) > 90) { echo " ..."; } ?> </span></li> <li style="width:54px;"> <input type="checkbox" id="cont_ligne_<?php echo $row->id; ?> " name="ligne[]" class="sytle_checkbox" onchange="checkvalues('lignecont','<?php echo $row->id; ?> ')" <?php if ($row->ligne) { ?> checked="checked" <?php } ?> /> </li> <li style="width:54px;"></li> <li style="width:34px;"><a href="contenu_modifier.php?id=<?php echo $row->id; ?> &dossier=<?php echo $parent; ?> " class="txt_vert_11"><?php echo trad('editer', 'admin'); ?> </a></li> <li style="width:71px;"> <div class="bloc_classement"> <div class="classement"><a href="contenu_modifier.php?id=<?php echo $row->id; ?> &action=modclassement&parent=<?php echo $parent; ?> &type=M"><img src="gfx/up.gif" border="0" /></a></div> <div class="classement"><span id="classementcontenu_<?php echo $row->id; ?> " class="contenudos_edit"><?php echo $row->classement; ?> </span></div> <div class="classement"><a href="contenu_modifier.php?id=<?php echo $row->id; ?> &action=modclassement&parent=<?php echo $parent; ?> &type=D"><img src="gfx/dn.gif" border="0" /></a></div> </div> </li> <li style="width:37px; text-align:center;"><a href="javascript:supprimer_contenu('<?php echo $row->id; ?> ', '<?php echo $parent; ?> ');"><img src="gfx/supprimer.gif" width="9" height="9" border="0" /></a></li> </ul> <?php } }
/** * * Return an array of content for the current folder * * @param string $dossier id of the current folder * @param string $critere order by clause * @param string $order ASC or DESC * @param string $alpha if order is alpha pu "alpha" * @return Array */ public function getList($dossier, $critere, $order, $alpha) { $return = array(); if ($alpha == "alpha") { $query = "select c.id, c.dossier, c.ligne, c.classement from " . Contenu::TABLE . " p LEFT JOIN " . Contenudesc::TABLE . " pd ON cd.contenu = c.id and lang=" . ActionsLang::instance()->get_id_langue_courante() . " where c.dossier=\"{$dossier}\" order by cd.{$critere} {$order}"; } else { $query = "select id, dossier, ligne, classement from " . Contenu::TABLE . " where dossier=\"{$dossier}\" order by {$critere} {$order}"; } $resul = $this->query($query); $i = 0; while ($resul && ($row = $this->fetch_object($resul))) { $contenudesc = new Contenudesc(); $contenudesc->charger($row->id); if (!$contenudesc->affichage_back_office_permis()) { continue; } $image = new Image(); $query_image = "select * from " . Image::TABLE . " where contenu=\"" . $row->id . "\" order by classement limit 0,1"; $resul_image = $image->query($query_image); $row_image = $image->fetch_object($resul_image, 'image'); $return[] = array("id" => $row->id, "dossier" => $row->dossier, "ligne" => $row->ligne, "classement" => $row->classement, "titre" => $contenudesc->titre, "langue_courante" => $contenudesc->est_langue_courante(), "image" => array("fichier" => $row_image->fichier)); } return $return; }