0byt3m1n1-V2
Path:
/
home
/
nlpacade
/
www.OLD
/
classes
/
[
Home
]
File: Theme.class.php
<?php include_once("Baseobj.class.php"); include_once("Themedesc.class.php"); include_once("Actualite.class.php"); include_once("Image.class.php"); include_once("Document.class.php"); class Theme extends Baseobj{ var $id; var $parent; var $lien; var $ligne; var $classement; var $table="theme"; var $bddvars = array("id", "parent", "lien", "ligne", "classement"); function Theme(){ $this->Baseobj(); } function charger($id, $lang=1){ return $this->getVars("select * from $this->table where id=\"$id\""); } function changer_classement($id, $type){ $this->charger($id); $remplace = new Theme(); if($type == "M") $res = $remplace->getVars("select * from $this->table where parent=\"" . $this->parent. "\" and classement<" . $this->classement . " order by classement desc limit 0,1"); else if($type == "D") $res = $remplace->getVars("select * from $this->table where parent=\"" . $this->parent. "\" and classement>" . $this->classement . " order by classement limit 0,1"); if(! $res) return ""; $sauv = $remplace->classement; $remplace->classement = $this->classement; $this->classement = $sauv; $remplace->maj(); $this->maj(); } function delete($requete){ $resul = mysql_query($requete); } function supprimer(){ if ($this->id == 0 || $this->id == "") return; $theme = new Themedesc(); $actualite = new Actualite(); $query = "select * from $this->table where parent=\"$this->id\""; $resul = mysql_query($query, $this->link); $query = "select * from $actualite->table where theme=\"$this->id\""; $resul2 = mysql_query($query, $this->link); if( ! mysql_num_rows($resul) && ! mysql_num_rows($resul2)){ $image = new Image(); $query = "select * from $image->table where theme=\"" . $this->id . "\""; $resul = mysql_query($query, $image->link); while($row = mysql_fetch_object($resul)){ $tmp = new Image(); $tmp->charger($row->id); $tmp->supprimer(); } $document = new Document(); $query = "select * from $document->table where theme=\"" . $this->id . "\""; $resul = mysql_query($query, $document->link); while($row = mysql_fetch_object($resul)){ $tmp = new Document(); $tmp->charger($row->id); $tmp->supprimer(); } $this->delete("delete from $this->table where id=\"$this->id\""); $this->delete("delete from $themedesc->table where theme=\"$this->id\""); $queryclass = "select * from $this->table where parent=$this->parent order by classement"; $resclass = mysql_query($queryclass); if(mysql_num_rows($resclass) > 0){ $i=1; while($rowclass = mysql_fetch_object($resclass)){ $dos = new Theme(); $dos->charger($rowclass->id); $dos->classement = $i; $dos->maj(); $i++; } } } else { return 0; } return 1; } function nb_theme(){ $actualite = new Actualite(); $query = "select count(*) as nbtheme from $actualite->table where theme=\"" . $this->id . "\""; $res = mysql_query($query); return mysql_result($res,0,"nbtheme"); } function aenfant(){ $query = "select count(*) as nb from $this->table where parent=\"" . $this->id . "\""; $resul = mysql_query($query, $this->link); if(mysql_result($resul, 0, "nb")) return 1; else return 0; } } ?>
©
2018.