%PDF- %PDF-
Direktori : /home/alliance/domains/congress-intercultural.eu/public_html/inc/classes/ |
Current File : /home/alliance/domains/congress-intercultural.eu/public_html/inc/classes/Initiative.php |
<?php class Initiative extends Load { var $bd; var $lang; var $theme; var $nom_table='initiative'; var $clef_primaire='id_initiative'; var $table=array('id_theme','id_user','valide','id_pays','ville'); var $table_lang=array('titre','description','lien','libelle_lien'); function Initiative($connection) { //constructor parent::Load($connection); $this->bd = new BaseOps($connection); $this->lang = new Lang($connection); $this->trad = new Traduction($connection); $this->theme = new Theme($connection); } function liste_ini($lang = false,$theme=null,$actif=null,$country=null) { if(!$lang) { $lang = $this->lang->getlangid(); } $where=""; if($theme!=null){ $where.=" AND id_theme=".$theme; } if($actif!=null && $actif!=""){ $where.=" AND valide=".$actif; } if($country!=null){ $where.=" AND id_pays=".$country; } $liste=$this->getList($lang,false,$where); $html=""; foreach($liste as $initiative) { $html.='<li> <div '.(($initiative['valide']==0)?'style="background: #a45252"':'').' > <strong>'.$initiative['titre'].'</strong> <a href="admin/modifier_initiative.php?id='.$initiative['id_initiative'].'">'.$this->trad->t("Modifier l initiative",'admin',$this->lang->id()).'</a> <a href="admin/suppr_initiative.php?id='.$initiative['id_initiative'].'" class="confirm">'.$this->trad->t("Supprimer l initiative",'admin',$this->lang->id()).'</a>'; $html.='</div>'; $html.='</li>'; $prev = $initiative['id_initiative']; } return $html; return $liste; } function liste_initiatives_admin($lang = false) { if(!$lang) { $lang = $this->lang->getlangid(); } $html=""; $result = $this->getList($lang, true,"AND id_parent=0"); $i = 0; foreach($result as $initiative) { $html.='<li> <div> <strong>'.$initiative['libelle'].'</strong> <a href="admin/modifier_initiative.php?id='.$initiative['id_initiative'].'">'.$this->trad->t("Modifier l initiative",'admin',$this->lang->id()).'</a> <a href="admin/suppr_initiative.php?id='.$initiative['id_initiative'].'" class="confirm">'.$this->trad->t("Supprimer l initiative",'admin',$this->lang->id()).'</a>'; if($sous_cat['ordre'] != 1) { $html.='<a href="admin/monter.php?table=initiative&id='.$initiative['id_initiative'].'&avant='.$prev.'" style="color: #fff !important;">'.$this->trad->t("Monter","admin").'</a>'; } $html.='</div>'; $html.='</li>'; $sous_cats = $this->getList($lang, true,"AND id_parent=".$initiative["id_initiative"]); if($sous_cats!=null){ foreach($sous_cats as $sous_cat) { $html.='<li class="sous_cat"> <div> <strong>'.$sous_cat['libelle'].'</strong> <a href="admin/modifier_initiative.php?id='.$sous_cat['id_initiative'].'">'.$this->trad->t("Modifier l initiative",'admin',$this->lang->id()).'</a> <a href="admin/suppr_initiative.php?id='.$sous_cat['id_initiative'].'" class="confirm">'.$this->trad->t("Supprimer l initiative",'admin',$this->lang->id()).'</a>'; if($sous_cat['ordre'] != 1) { $html.='<a href="admin/monter.php?table=initiative&id='.$sous_cat['id_initiative'].'&avant='.$prevsous.'" style="color: #fff !important;">'.$this->trad->t("Monter","admin").'</a>'; } $html.='</div> </li>'; $prevsous=$sous_cat['id_initiative']; } } $i++; $prev = $initiative['id_initiative']; } return $html; } function getListSelect($lang=false,$ordre=false,$value="",$parent=""){ if(!$lang){ $lang = $this->lang->getlangid(); } if($parent!==""){ $entrees=$this->getList($lang,$ordre," AND id_parent=".$parent); } else{ $entrees=$this->getList($lang,$ordre); } $return=""; if($value=="" || $value==0){ $return.='<option selected="selected" value="0">'.$this->trad->t("Pas de parent","admin").'</option>'; } else{ $return.='<option value="0">'.$this->trad->t("Pas de parent","admin").'</option>'; } foreach($entrees as $entree){ if($value==$entree['id_initiative']){ $return.='<option selected="selected" value="'.$entree['id_initiative'].'">'.$entree['libelle'].'</option>'; } else{ $return.='<option value="'.$entree['id_initiative'].'">'.$entree['libelle'].'</option>'; } } return $return; } function getListInitiative($lang=false,$all=false){ if(!$lang) { $lang = $this->lang->getlangid(); } $html=""; $return=array(); $result = $this->getList($lang, true,"AND id_parent=0"); $i = 0; foreach($result as $initiative) { $return[]=$initiative; $html.='<option value="'.$initiative['id_initiative'].'">'.$initiative['libelle'].'</option>'; $sous_cats = $this->getList($lang, true,"AND id_parent=".$initiative["id_initiative"]); if($sous_cats!=null){ foreach($sous_cats as $sous_cat) { $return[]=$sous_cat; $html.='<option value="'.$sous_cat['id_initiative'].'"> '.$sous_cat['libelle'].'</option>'; } } } return $return; } function getLastInitiatives($lang=false,$theme=false){ if(!$lang) { $lang = $this->lang->getlangid(); } $html=""; $list_themes=$this->theme->getList($lang, false,"AND id_parent=".$theme); $str_theme=$theme.","; foreach($list_themes as $untheme){ $str_theme.=$untheme['id_theme'].","; } $str_theme.=trim($str_theme,','); $return=array(); $result = $this->getList($lang, false,"AND valide=1 AND id_theme IN (".$str_theme.")","id_theme DESC LIMIT 0,5"); $i = 0; return $result; } function getListInitiatives($lang=false,$theme){ if(!$lang) { $lang = $this->lang->getlangid(); } $return=array(); $result = $this->getList($lang, true,"AND valide=1 AND id_theme=".$theme); $i = 0; return $result; } function getSearch($cat=0,$sous_cat=0,$choix_pays=0,$keyword="",$lang=false){ if(!$lang){ $lang = $this->lang->getlangid(); } $query="SELECT * FROM initiative i LEFT JOIN initiative_lang l ON l.id_initiative=i.id_initiative WHERE l.id_lang=".$lang; if($sous_cat!=0){ $query.=" AND id_theme=".$sous_cat; } elseif($cat!=0){ $list_themes=$this->theme->getList($lang, false,"AND id_parent=".$cat); $str_theme=""; foreach($list_themes as $untheme){ $str_theme.=$untheme['id_theme'].","; } $str_theme.=trim($str_theme,','); $query.=" AND id_theme IN (".$str_theme.")"; } if($choix_pays!=0){ $query.=" AND id_pays=".$choix_pays; } if($keyword!=""){ $query.=" AND (titre LIKE ".$this->bd->qS("%".$keyword."%")." || description LIKE ".$this->bd->qS("%".$keyword."%")." )"; } return $this->bd->select_arrays($query); } } ?>