function SetCond ($TypF,$ValF,$NegF,$NomChp,$typChpNum=false) {
 
 if ($ValF!=NULL && $ValF!="%") {
 	if (!is_array($ValF)) $ValF = $typChpNum ? ($ValF + 0) : db_escape_string($ValF);
    switch ($TypF) { // switch sur type de filtrage
      case "EGAL" : // special
        $ValF=trim($ValF);
        $cond=$typChpNum ? "$NomChp = $ValF" : "$NomChp = '".$ValF."'";
        break;

      case "INPLIKE" : // boite d'entr�
        $ValF=trim($ValF);
        if (substr($ValF,-1,1)!="%" && !$typChpNum) $ValF.="%";
        $cond=$typChpNum ? "$NomChp = $ValF" : "$NomChp LIKE '".$ValF."'";
        break;

      case "LDM" : // liste �choix multiples de valeurs ds ce cas la valeur est un tableau
                 // la condition r�ultante est omChp LIKE '%Val1%' or NomChp LIKE '%Val2%' etc ...
        if (is_array($ValF)) {  // teste Valf est un tabelau
           foreach ($ValF as $valf) {
             if ($valf=="%" || $valf=="000") {
                $cond="";
                break; // pas de condition s'il y a %
                }
             else
                $cond.=$typChpNum ? "$NomChp = $valf OR " : "$NomChp LIKE '%".db_escape_string($valf)."%' OR "; // on av vire les % puis les a remis
             }
           if ($cond!="") $cond="(".substr($cond,0,strlen($cond)-4).")"; // vire le dernier OR
                                                          // et rajoute () !!
        } else {  // si ValF pas tableau
        	if ($ValF=="%" || $ValF=="000") {
        		$cond="";
        	} else {
        		if (!$typChpNum) $gi="'";
        		$op = strstr($ValF,"%,") ? "LIKE" : "="; // dans le cas des LD valeurs fixes multiple, ça peut merder... une cond  = "%,toto,%" ne ramène rien
        		$cond="($NomChp $op $gi$ValF$gi)";
        	}
        }
        break;
        
      case "LDMEG" : // liste �choix multiples de valeurs ds ce cas la valeur est un tableau
       // la condition r�ultante est un NomChp ='Val1' or NomChp ='Val2' etc ...

        if (is_array($ValF)) {  // teste Valf est un tabelau
           foreach ($ValF as $valf) {
             if ($valf=="%" || $valf=="000") {
             	// ya un bug avec les enum qui contiennent '0'; arrive pas à le résoudre
       		//if ($NomChp == "ECR_POINTAGE") { echo "$NomChp , the val ($TypF) : " ; print_r($ValF);}
                $cond="";
                break; // pas de condition s'il y a %
                }
             else
                $cond.=$typChpNum ? "$NomChp = $valf OR " : "$NomChp='".db_escape_string($valf)."' OR ";
             }
           if ($cond!="") $cond="(".substr($cond,0,strlen($cond)-4).")"; // vire le dernier OR  
	   // et rajoute () !!          
	   } // si ValF pas tableau
        else {
        	if ($ValF=="%" || $ValF=="000") {
        		$cond="";
        	} else {
        		if (!$typChpNum) $gi="'";
        		$cond="($NomChp = $gi$ValF$gi)";
        	}
        }

        break;
// special pour liaison multiple: solutionne le pb qui fait que typo met pas les , au debut et a la fin
	case "LDM_SPL":
        if (is_array($ValF)) {  // teste Valf est un tabelau
           foreach ($ValF as $valf) {
             if ($valf=="%" || $valf=="000") {
                $cond="";
                break; // pas de condition s'il y a %
                }
             else
                $cond.="($NomChp LIKE '%,".db_escape_string($valf).",%' OR $NomChp LIKE '".db_escape_string($valf).",%' OR $NomChp LIKE '%,".db_escape_string($valf)."' OR $NomChp='".db_escape_string($valf)."') OR "; 
             }
           if ($cond!="") $cond="(".substr($cond,0,strlen($cond)-4).")"; // vire le dernier OR
                                                          // et rajoute () !!
           } // si ValF pas tableau
        else $cond="";

	break;
      case "DANT" : // date ant�ieure �      
      case "DPOST" : // date ant�ieure 
      if ($ValF=="%" || $ValF=="") break; // pas de condition
        $oprq=($TypF=="DANT" ? "<=" : ">="); // calcul de l'op�ateur
        if ($typChpNum) { // alors c un tstamp
        	$cond="$NomChp $oprq ".DateF2tstamp($ValF)."";
        } else
        	$cond="$NomChp $oprq '".DateA($ValF)."'";
        break;

      case "DATAP" : // date inf et sup
        if ($ValF[0]!="%" && $ValF[0]!="") {
        	 if ($typChpNum) { // alors c un tstamp
        	 	$cond="$NomChp >= ".DateF2tstamp($ValF[0])."";
        	 } else 
        		$cond="$NomChp >= '".DateA($ValF[0])."'";
        }

        if ($ValF[1]!="%" && $ValF[1]!="") {
           $cond=($cond=="" ? "" : $cond." AND ");
           if ($typChpNum) { // alors c un tstamp
        	 	$cond="$NomChp <= ".DateF2tstamp($ValF[1])."";
        	 } else 
        		$cond.="$NomChp <= '".DateA($ValF[1])."'";
           }
        break;
         
      case "VINF" : // inf
      case "VSUP" : // sup 
      if ($ValF=="%" || $ValF=="") break; // pas de condition
        $oprq=($TypF=="VINF" ? "<=" : ">="); // calcul de l'op�ateur
        if ($typChpNum) { //
        	$cond="$NomChp $oprq $ValF";
        } else // marche avec alpha
        	$cond="$NomChp $oprq '".$ValF."'";
        break;

      case "VIS" : // inf et sup
        if ($ValF[0]!="%" && $ValF[0]!="") {
        	 if ($typChpNum) { // alors c un tstamp
        	 	$cond="$NomChp >= ".$ValF[0]."";
        	 } else // marche avec alpha
        		$cond="$NomChp >= '".$ValF[0]."'";
        }

        if ($ValF[1]!="%" && $ValF[1]!="") {
           $cond=($cond=="" ? "" : $cond." AND ");
           if ($typChpNum) { //
        	 	$cond.="$NomChp <= ".$ValF[1]."";
        	 } else 
        		$cond.="$NomChp <= '".$ValF[1]."'";
           }
        break;

      case "NOTNUL" : // inf et sup
      	$cond = "(".$NomChp ." IS NOT NULL AND ".($typChpNum ? "$NomChp!=0" : "$NomChp!=''"). ") ";
        
      break;
      
      default :
        $cond="";
        break;
      } // fin switch
  } // fin ValF a une valeur coh�ente
  else $cond="";


  if ($cond!="" && $NegF!="") $cond="NOT(".$cond.")"; // negationne �entuellement
  return($cond);
} // fin fonction SteCond
    /**
    	/**
    * le plugin a ��modifi�de fa�n �permettre d'�re ins��plusieurs fois dans une m�e page et que le passage en singleview de l'un n'influence pas les autres
    */
    function main($content, $conf)
    {
        $this->uid = substr(strstr($GLOBALS[GLOBALS][TSFE]->currentRecord, ":"), 1);
        if (strstr($this->cObj->currentRecord, "tt_content")) {
            $conf["pidList"] = $this->cObj->data["pages"];
            $conf["recursive"] = $this->cObj->data["recursive"];
        }
        $this->conf = $conf;
        // Setting the TypoScript passed to this function in $this->conf
        $this->pi_setPiVarDefaults();
        $this->pi_loadLL();
        // Loading the LOCAL_LANG values
        //$this->pi_moreParams="&pointeruid[".$this->uid."]=".$this->uid;
        /* !-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-
        		  modif: on ne se met et en mode singleView que si showUid!=" ET SURTOUT que si l'uid tt_content pass�correspond
        		// au courant
        		// voir aussi utilisation du dernier argument optionel de la la fonction
        		pi_list_linkSingle qui permet de passer un tableau de hachage contenant autant d'arguments suppl�entaires que l'on veut
         		!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-
        		*/
        /*		if ($this->piVars["showUid"] && $this->piVars["ttc_uid"]==$this->uid)	{	// If a single element should be displayed:
        Maintenant la loupe se fait directement dans la liste */
        // Affichage Titre verrue Elodie : si nom du dossier syst�e contenant les actus contient "_noinfo", pas de Logo actu ni titre, ni auteur en mode normal
        if (!strstr(txRecupLib("pages", "uid", "title", $this->conf['pidList']), "_noinfo")) {
            $content .= '<H2>' . $this->pi_getLL("titre_fe", "[titre_fe]") . '</H2>';
            // <img src="'.$this->conf["extCurDir"].'picto_actu.gif" class="picto">&nbsp;&nbsp; cette bourrique de Diane veut plus du picto
        }
        // si changement de page, on efface le contexte
        if ($_SESSION['datafvmnews']['pidcour'] != $this->cObj->data['pid']) {
            unset($_SESSION['datafvmnews']);
        }
        // gestion mode archive
        if (isset($this->piVars['arch_mode'])) {
            $_SESSION['vmnews_arch_mode'] = $this->piVars['arch_mode'];
        }
        $this->arch_mode = $this->cObj->data['layout'] >= 1 || $_SESSION['vmnews_arch_mode'] == 1;
        /*		debug($this->cObj->data['layout'],"this->cObj->data['layout']");
        		debug($this->piVars,"this->piVars:");*/
        //debug ($_SESSION,"sessione");
        if ($this->arch_mode) {
            // mode archive
            //$GLOBALS["TSFE"]->set_no_cache(); // desactive la cache en mode archive sinon formulairee merde...
            $content .= '<a name="debform"></a>';
            $content .= "<H3>" . $this->pi_getLL("rech_arch", "Rech arhives") . "</H3>";
            $content .= $this->buttdisphiddarch();
            $content .= "<H4>" . $this->pi_getLL("crit_arch", "Crit arhives") . "</H4>";
            //debug($this->conf);
            //debug($_SESSION['datafvmnews'],"_SESSION['datafvmnews']");
            // si formulaire envoyé, on met en session sa valeur; sinon quand on suit un lien vers le détail d'une actu, comme il n'y a pas de submit, on perd les critères courant
            if (isset($this->piVars['DATA']['test_f_sent'])) {
                if ($this->piVars['DATA']['datedebp'] != "") {
                    $this->piVars['DATA']['datedebp'] = rmfDateF($this->piVars['DATA']['datedebp']);
                }
                if ($this->piVars['DATA']['datefinp'] != "") {
                    $this->piVars['DATA']['datefinp'] = rmfDateF($this->piVars['DATA']['datefinp']);
                }
                $tsdtdebp = DateF2tstamp($this->piVars['DATA']['datedebp']);
                $tsdtfinp = DateF2tstamp($this->piVars['DATA']['datefinp']);
                if ($tsdtdebp > 0 && $tsdtfinp > 0 && $tsdtdebp > $tsdtfinp) {
                    $errorcd = $this->pi_getLL("err_coher_dates", "erreur de cohérences sur les dates");
                    $this->piVars['DATA']['datefinp'] = "";
                    unset($_SESSION['datafvmnews']['datefinp']);
                }
                $_SESSION['datafvmnews'] = $this->piVars['DATA'];
            }
            if (!isset($_SESSION['datafvmnews']['emplact'])) {
                $this->piVars['DATA']['emplact'][0] = "'" . $this->cObj->data['pid'] . "'";
                // si pas de sélection precedente, prend l'uid de la page courante
                $_SESSION['datafvmnews']['emplact'][0] = "'" . $this->cObj->data['pid'] . "'";
            }
            $_SESSION['datafvmnews']['pidcour'] = $this->cObj->data['pid'];
            //debug(in_array($this->cObj->data['pid'],$_SESSION['datafvmnews']['emplact']));
            //debug($this->piVars['DATA'],"this->piVars['DATA']:");
            //debug($_SESSION['datafvmnews'],"_SESSION['datafvmnews']");
            $reqroot = "SELECT pid FROM sys_template WHERE hidden = 0 AND root = 1 AND deleted = 0";
            $resroot = mysql(TYPO3_db, $reqroot);
            if (mysql_num_rows($resroot) == 0) {
                die("This site seems to contain no root page");
            }
            while ($rep = mysql_fetch_row($resroot)) {
                $tbpidroot[] = $rep[0];
            }
            // debug root pid tables
            foreach ($tbpidroot as $pidroot) {
                $this->retTLDarbo($pidroot);
            }
            $this->tbemplact = array("%" => $this->pi_getLL("Indifferent", "Indifferent")) + $this->tbemplact;
            $LDEmplact = DispLD($this->tbemplact, $this->prefixId . '[DATA][emplact]', "yes", "", false);
            // liste d�oulante multi
            // avant DispLD n'etait pas compatible XHTML
            //$LDEmplact=str_replace("SELECTED",' selected="selected" ',$LDEmplact);
            $comment_fdate = " <small> ex. : 15/10/2005 </small>";
            $cHash = md5(serialize($this->piVars['DATA']));
            $content .= '<FORM action="' . $this->pi_getPageLink($GLOBALS["TSFE"]->id) . '?cHash=' . $cHash . '#debform" name="' . $this->prefixId . 'fname" method="POST">';
            $content .= '
				<INPUT TYPE="hidden" value="coucou" name="' . $this->prefixId . '[DATA][test_f_sent]" />
                                <TABLE><TR><TD width="120><label for="keywords">' . $this->pi_getLL("keywords", "Mots clés") . '</label></TD><TD><INPUT id="keywords" type="text" size="60" value="' . $_SESSION['datafvmnews']['keywords'] . '" name="' . $this->prefixId . '[DATA][keywords]" />
                               </TD></TR><TR><TD>
                                <label for="and_or">' . $this->pi_getLL("and_or", "Et/ou") . '</label></TD><TD><INPUT type="radio" id="and_or"  ' . ($_SESSION['datafvmnews']["and_or"] != "OR" ? ' checked="checked" ' : '') . ' name="' . $this->prefixId . '[DATA][and_or]" value="AND">' . $this->pi_getLL("AND", "ET") . '&nbsp;&nbsp;&nbsp;<INPUT type="radio" name="' . $this->prefixId . '[DATA][and_or]" value="OR" ' . ($_SESSION['datafvmnews']["and_or"] == "OR" ? ' checked="checked" ' : '') . '>' . $this->pi_getLL("OR", "OU") . '</TD></TR><TR>
                                <TD>
                                <label for="datedebp">' . $this->pi_getLL("datedebp", "Datedebp") . '</label></TD><TD><INPUT id="datedebp" type="text" size="12" value="' . $_SESSION['datafvmnews']['datedebp'] . '" name="' . $this->prefixId . '[DATA][datedebp]" />' . $comment_fdate . '
                                </TD</TR><TR><TD>
                                <label for="datefinp">' . $this->pi_getLL("datefinp", "Datefinp") . '</label></TD><TD><INPUT id="datefinp" type="text" size="12" value="' . $_SESSION['datafvmnews']['datefinp'] . '" name="' . $this->prefixId . '[DATA][datefinp]" /> ' . $comment_fdate . ($errorcd ? '<BR><span style="color:red">' . $errorcd . '<span>' : "") . '</TD></TR><TR><TD>
                                <label for="emplact">' . $this->pi_getLL("Emplact", "emplact") . '</label></TD><TD>' . $LDEmplact . '
                                </TD></TR><TR><TD>
                                <INPUT ' . $this->pi_classParam("submit-button") . ' type="button" name="' . $this->prefixId . '[reset_button]" value="' . $this->pi_getLL("Reset", "Annuler") . '" onclick="getElementById(\'keywords\').value=\'\'; getElementById(\'datedebp\').value=\'\'; getElementById(\'datefinp\').value=\'\';">
                                </TD><TD>
                                <INPUT ' . $this->pi_classParam("submit-button") . ' type="submit" name="' . $this->prefixId . '[submit_button]" value="' . $this->pi_getLL("rechercher", "Rechercher") . '">

                                </TD></TR></TABLE>
                                <HR/>';
            $content .= '</FORM>';
        }
        //debug($this->cObj->data['pid']); uidd e la page courante
        //debug($this->uid);
        //debug($this->piVars);
        if (!isset($this->piVars["pointer"])) {
            $this->piVars["pointer"] = 0;
        }
        if (!isset($this->piVars["mode"])) {
            $this->piVars["mode"] = 1;
        }
        // Initializing the query parameters:
        list($this->internal["orderBy"], $this->internal["descFlag"]) = explode(":", $this->piVars["sort"]);
        //debug($this->piVars);
        $this->internal["results_at_a_time"] = t3lib_div::intInRange($conf["results_at_a_time"], 0, 1000, 3);
        // Number of results to show in a listing.
        $this->internal["maxPages"] = t3lib_div::intInRange($conf["maxPages"], 0, 1000, 2);
        // The maximum number of "pages" in the browse-box: "Page 1", "Page 2", etc.
        $this->internal["searchFieldList"] = "title,abstract,bodytext";
        $this->internal["orderByList"] = "tstamp,uid,title";
        if ($this->arch_mode) {
            // envoie la requete spéciale
            if (isset($_SESSION['datafvmnews']['keywords'])) {
                $_SESSION['datafvmnews']['keywords'] = addslashes($_SESSION['datafvmnews']['keywords']);
                $tbkeyw = explode(" ", $_SESSION['datafvmnews']['keywords']);
                foreach ($tbkeyw as $keyw) {
                    $whk .= " __nom_chp__ LIKE '%{$keyw}%' __op__ ";
                }
                $whk = vdc($whk, 7);
                $whk = "(" . str_replace("__op__", $_SESSION['datafvmnews']["and_or"], $whk) . ")";
                $whk = "(" . str_replace("__nom_chp__", "title", $whk) . " OR " . str_replace("__nom_chp__", "abstract", $whk) . " OR " . str_replace("__nom_chp__", "bodytext", $whk) . ")";
            }
            if ($_SESSION['datafvmnews']['datedebp'] != "") {
                $whdp = "( (starttime> " . DateF2tstamp($_SESSION['datafvmnews']['datedebp']) . ") OR ( starttime=0 AND tstamp > " . DateF2tstamp($_SESSION['datafvmnews']['datedebp']) . ") )";
            }
            if ($_SESSION['datafvmnews']['datefinp'] != "") {
                $whfp = "( (endtime>0 AND endtime < " . DateF2tstamp($_SESSION['datafvmnews']['datefinp']) . ") OR ( endtime=0 AND tstamp < " . DateF2tstamp($_SESSION['datafvmnews']['datefinp']) . ") )";
            }
            $whg = "from tx_vm19news_news WHERE deleted=0 AND hidden=0 ";
            $whg .= ($whk ? " AND " : "") . $whk;
            $whg .= ($whdp ? " AND " : "") . $whdp;
            $whg .= ($whfp ? " AND " : "") . $whfp;
            if ($_SESSION['datafvmnews']['emplact'][0] != "%") {
                $whg .= " AND pid IN (" . implode(",", $_SESSION['datafvmnews']['emplact']) . ")";
            }
            //debug ($whg,"where avant :");
            $query = $this->pi_list_query("tx_vm19news_news", 1, '', '', '', '', $whg);
            // le 1 sert a compter seulement
            //debug ($query,"query apres :");
            //pi_list_query($table,$count=0,$addWhere='',$mm_cat='',$groupBy='',$orderBy='',$query='',$returnQueryArray=FALSE)
        } else {
            // anciennee methode "normale", ... mais on a rajouté l'affichage sur d'autres pages pr 1 meme actu...
            //$query = $this->pi_list_query("tx_vm19news_news",1);
            $whg = "from tx_vm19news_news WHERE deleted=0 AND hidden=0 ";
            $whg .= "AND ( starttime< " . time() . ' OR  starttime=0  )';
            $whg .= " AND ( endtime> " . time() . ' OR  endtime=0  )';
            $pidc = $this->cObj->data['pid'];
            $whg .= " AND (pid={$pidc} OR otherpages LIKE '{$pidc},%' OR otherpages LIKE '%,{$pidc},%' OR otherpages LIKE '%,{$pidc}')";
            $query = $this->pi_list_query("tx_vm19news_news", 1, '', '', '', '', $whg);
            // le 1 sert a compter seulement
            //debug($query);
        }
        $res = mysql(TYPO3_db, $query);
        //debug($query);
        if (mysql_error()) {
            debug(array(mysql_error(), $query));
        }
        list($this->internal["res_count"]) = mysql_fetch_row($res);
        #	$content.=t3lib_div::view_array($this->piVars);	// DEBUG: Output the content of $this->piVars for debug purposes. REMEMBER to comment out the IP-lock in the debug() function in t3lib/config_default.php if nothing happens when you un-comment this line!
        if ($this->internal["res_count"] > 0) {
            // Make listing query, pass query to MySQL:
            //pi_list_query($table, $count=0, $addWhere="", $mm_cat="", $groupBy="", $orderBy="", $query="")
            if ($this->arch_mode) {
                $content .= '<div class="nbrep_r">' . $this->pi_getLL("nb_news_r", "[nb_news]") . " : <b>" . $this->internal["res_count"] . "</b></div>";
                //$query="SELECT * ".$whg." ORDER BY sorting,tstamp DESC";
                // le fait de passer par pi_list_query permet d'utiliser la pagination native
                $query = $this->pi_list_query("tx_vm19news_news", 0, '', '', '', "ORDER BY sorting,tstamp DESC", $whg);
            } else {
                // anciennee methode "normale", ... mais on a rajouté l'affichage sur d'autres pages pr 1 meme actu...
                //$query = $this->pi_list_query("tx_vm19news_news",0,"","","","ORDER BY sorting,tstamp DESC");
                $query = $this->pi_list_query("tx_vm19news_news", 0, '', '', '', "ORDER BY sorting,tstamp DESC", $whg);
            }
            $res = mysql(TYPO3_db, $query);
            if (mysql_error()) {
                debug(array(mysql_error(), $query));
            }
            $this->internal["currentTable"] = "tx_vm19news_news";
            // Adds the mode selector.
            //$content.=$this->pi_list_modeSelector($items);
            // Adds the whole list table
            $content .= $this->makelist($res);
            // Adds the search box:
            //$content.=$this->pi_list_searchBox();
            // Adds the result browser:
            // Adds the result browser, seulement s'il y a assez de r�ultats
            if ($this->internal["res_count"] > $this->internal["results_at_a_time"]) {
                $content .= $this->pi_list_browseresults();
            }
        } else {
            $content .= $this->pi_getLL("no_news" . ($this->arch_mode ? "1" : ""), "[no_news]");
        }
        $content .= "<BR/>" . $this->buttdisphiddarch();
        //$content.=$this->pi_list_browseresults();
        // Returns the content from the plugin.
        return $this->pi_wrapInBaseClass($content);
    }