env->out_file_exists("emplacements.xml")) { $emplacements_config = simplexml_load_file($this->env->out_file("emplacements.xml")); foreach($emplacements_config as $emplacement) { $emplacements[utf8_decode($emplacement->id)] = array(); foreach($emplacement as $emplacement_key => $emplacement_value) { $emplacements[utf8_decode($emplacement->id)][utf8_decode($emplacement_key)] = utf8_decode($emplacement_value); } } } else $emplacements = false; return $emplacements; } # ---------------------------------------------------------------------------------------- # blocs # function box_files() { $box_files = array(); $boxes_dir = $this->env->path("out")."boxes/"; if(is_dir($boxes_dir)) { if($dh = opendir($boxes_dir)) { while(($file = readdir($dh)) !== false) { if(substr($file, 0, 1) != "." && substr($file, -4) == ".php") { $box_files[] = $file; } } } closedir($dh); } return $box_files; } function boxes($start = 0, $emplacement = null, $public = null) { $boxes = array(); try { $boxes = array("list" => array(), "total" => 0); $query = "SELECT count(*) as n" ." FROM #--boxes" .(isset($emplacement) ? " WHERE #--boxes.emplacement".($emplacement ? "=".$this->eq($emplacement) : " IS NULL") : "") .(isset($public) ? (isset($emplacement) ? " AND" : " WHERE")." public=".($public ? "1" : "0") : ""); $rst = $this->sql->query($query); if($v_rst = $this->sql->fetch_assoc($rst)) $boxes["total"] = $v_rst["n"]; $this->sql->free_result($rst); if($boxes["total"] > 0) { $query = "SELECT #--boxes.*" .", #--pun_users.username as auteur" ." FROM #--pun_users, #--boxes" ." WHERE #--boxes.auteur_creation=#--pun_users.id" .(isset($emplacement) ? " AND #--boxes.emplacement".($emplacement ? "=".$this->eq($emplacement) : " IS NULL") : "") .(isset($public) ? " AND public=".($public ? "1" : "0") : "") ." ORDER BY #--boxes.ordre"; $rst = $this->sql->query($query); while($v_rst = $this->sql->fetch_assoc($rst)) $boxes["list"][$v_rst["id"]] = $v_rst; $this->sql->free_result($rst); } } catch(Exception $_e) { $boxes = false; } return $boxes; } function box($id) { $box = array(); try { $query = "SELECT #--boxes.*" .", #--pun_users.username as auteur" ." FROM #--pun_users, #--boxes" ." WHERE #--boxes.auteur_creation=#--pun_users.id" ." AND #--boxes.id=".$this->eq($id); $rst = $this->sql->query($query); if($v_rst = $this->sql->fetch_assoc($rst)) $box = $v_rst; } catch(Exception $_e) { $box = false; } return $box; } function add_box($titre, $public, $nom, $emplacement, $fichier, $contenu, $user) { try { $query = "INSERT INTO #--boxes" ."(nom, emplacement, titre, fichier, contenu, auteur_creation, date_creation, public) VALUES" ."( ".$this->eq($nom) .", ".$this->eq($emplacement) .", ".$this->eq($titre) .", ".$this->eq($fichier) .", ".$this->eq($contenu) .", ".$this->eq($user) .", NOW()" .", ".$this->eq($public) .")"; $this->sql->query($query); } catch(Exception $_e) { return false; } return true; } function set_box($id, $titre, $public, $nom, $emplacement, $fichier, $contenu, $user) { try { $query = "UPDATE #--boxes SET" ." nom=".$this->eq($nom) .", emplacement=".$this->eq($emplacement) .", titre=".$this->eq($titre) .", fichier=".$this->eq($fichier) .", contenu=".$this->eq($contenu) .", auteur_modification=".$this->eq($user) .", date_modification=NOW()" .", public=".$this->eq($public) ." WHERE id=".$this->eq($id); $this->sql->query($query); } catch(Exception $_e) { return false; } return true; } function set_box_ordre($id, $ordre) { try { $query = "UPDATE #--boxes SET" ." ordre=".$this->eq($ordre) ." WHERE id=".$this->eq($id); $this->sql->query($query); } catch(Exception $_e) { return false; } return true; } function del_box($id) { try { $query = "DELETE FROM #--boxes" ." WHERE id=".$this->eq($id); $this->sql->query($query); } catch(Exception $_e) { return false; } return true; } } ?>