to replace it with the plugin output content
*
* @param mixed $content The current page content
*
* @return mixed If the page contains the plugin shortcode, replace with the plugin content, else return the content
*/
function show($content) {
if(preg_match('<[Dd][Ii][Vv] [Rr][Ee][Ll]="[Aa][Nn][Nn][Oo][Nn][Cc][Ee][Ss]" [Ii][Dd]="[Aa][Nn][Nn][Oo][Nn][Cc][Ee][Ss]" >',$content)) {
return $this->generate($content);
}
else {
return $content;
}
}
/**
* Send an email when the user click on the "contact vendor"
*/
function sendMail()
{
/**
* Envoi des mails gr�ce au lien "Contacter le vendeur par email"
**/
if (isset ($_POST['submit']))
{
if (!empty($_POST['txtNom']) && preg_match('`[0-9]{10}`', $_POST['txtTel']) && preg_match('#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,6}$#', $_POST['txtEmail']) && !empty($_POST['txtMessage']))
{
/**
* Email de r�ception des demandes d'informations
**/
$mail = annonces_email_reception;
/**
* On filtre les serveurs qui rencontrent des bogues.
**/
if (!preg_match("#^[a-z0-9._-]+@(hotmail|live|msn).[a-z]{2,4}$#", $mail))
{
$passage_ligne = "\r\n";
}
else
{
$passage_ligne = "\n";
}
/**
* Remplacement des variables %xxxx% par leurs valeurs POST dans la personnalisation des emails HTML
**/
$html = annonces_html_reception;
$html = stripslashes(str_replace('%nom%',$_POST['txtNom'], $html));
$html = stripslashes(str_replace('%tel%',$_POST['txtTel'], $html));
$html = stripslashes(str_replace('%mail%',$_POST['txtEmail'], $html));
$html = stripslashes(str_replace('%message%',$_POST['txtMessage'], $html));
$html = stripslashes(str_replace('%id_annonce%',$_POST['id_annonce'], $html));
$html = stripslashes(str_replace('%titre%',$_POST['titre_annonce'], $html));
$html = stripslashes(str_replace('%url_annonce%', Eav::get_link($_POST['id_annonce']), $html));
/**
* Remplacement des variables %xxxx% par leurs valeurs POST dans la personnalisation des emails TXT
**/
$txt = annonces_txt_reception;
$txt = stripslashes(str_replace('%nom%',$_POST['txtNom'], $txt));
$txt = stripslashes(str_replace('%tel%',$_POST['txtTel'], $txt));
$txt = stripslashes(str_replace('%mail%',$_POST['txtEmail'], $txt));
$txt = stripslashes(str_replace('%message%',$_POST['txtMessage'], $txt));
$txt = stripslashes(str_replace('%id_annonce%',$_POST['id_annonce'], $txt));
$txt = stripslashes(str_replace('%titre%',$_POST['titre_annonce'], $txt));
$txt = stripslashes(str_replace('%url_annonce%', Eav::get_link($_POST['id_annonce']), $txt));
/**
* D�claration des messages au format texte et au format HTML.
**/
$message_txt = $txt."";
$message_html = "
' . __('Votre demande a correctement été envoyée, vous recevrez prochainement une réponse. Cordialement','annonce') . '
';
}
else
{
$message_error = __('L\'envoi de votre demande d\'information(s) n\'a pu aboutir :','annonces') . ' ';
if (empty($_POST['txtNom']))
{
$message_error .= '
' . __('Le nom est incomplet','annonces') . '
';
}
if (empty($_POST['txtMessage']))
{
$message_error .= '
' . __('Le message est incomplet','annonces') . '
';
}
if (!preg_match('`[0-9]{10}`', $_POST['txtTel']))
{
$message_error .= '
' . __('Le téléphone est incomplet ou incorrect','annonces') . '
';
}
if (!preg_match('#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,6}$#', $_POST['txtEmail']))
{
$message_error .= '
' . __('L\'adresse email est incomplète ou incorrecte','annonces') . '
';
}
$message_error .= __('Veuillez rectifier ces champs pour que l\'envoi de votre email se fasse','annonces');
$message_error .= '
';
echo $message_error;
}
}
}
/**
*
*/
function generate($content)
{
global $tools;
global $wpdb;
$query = isset($_REQUEST['query']) ? $tools->IsValid_Variable($_REQUEST['query']) : '' ;
$query1 = isset($_REQUEST['query1']) ? $tools->IsValid_Variable($_REQUEST['query1']) : '' ;
$query2 = isset($_REQUEST['query2']) ? $tools->IsValid_Variable($_REQUEST['query2']) : '' ;
$query3 = isset($_REQUEST['query3']) ? $tools->IsValid_Variable($_REQUEST['query3']) : '' ;
$query4 = isset($_REQUEST['query4']) ? $tools->IsValid_Variable($_REQUEST['query4']) : '' ;
$mode = isset($_REQUEST['mode']) ? $tools->IsValid_Variable($_REQUEST['mode']) : '' ;
$show_map = isset($_REQUEST['show_map']) ? $tools->IsValid_Variable($_REQUEST['show_map']) : '' ;
$show_annonce = isset($_REQUEST['show_annonce']) ? $tools->IsValid_Variable($_REQUEST['show_annonce']) : '' ;
if(!empty($query) OR !empty($query1) OR !empty($query2) OR !empty($query3) OR !empty($query4) OR !empty($mode)){
/**
Si le crit�re de recherche n'est que le type de bien, on rentre dans la fonction sinon on fait la recherche avec les autres crit�res
**/
if(empty($query) AND empty($query1) AND empty($query2) AND empty($query3) AND empty($query4) AND !empty($mode)){
$eav_mode = new Eav();
$annonces = $eav_mode->getAnnoncesEntete($morequery,DEFAULT_FLAG_AOS,annonce_frontend_listing_order,0,'nolimit');
if($mode != 'all'){
foreach($annonces as $i){
$eav_mode_value = $eav_mode->getTypeBien(null,'valid',null,$i->idpetiteannonce);
if($eav_mode_value[0]->valueattributchar == $mode){
$idarray .= $i->idpetiteannonce.',';
}
}
}else{
foreach($annonces as $i){
$idarray .= $i->idpetiteannonce.',';
}
}
//Supprime la derni�re virgule de la liste des IDs
$size = strlen($idarray);
$id = substr($idarray, 0, $size-1);
$result_search = ' AND ANN.idpetiteannonce IN ('.$id.') ';
if($show_map == 'true' and (annonces_maps_activation == 'oui')){
/*---- Show map ----*/
$this->concatAnnonceContent($this->generate_search_map());
if(!empty($id)){
$this->concatAnnonceContent('
');
$this->concatAnnonceContent($this->show_map($result_search));
}else{
$result_search = ' AND ANN.idpetiteannonce IN (0) ';
$this->concatAnnonceContent('
'.__('Aucune annonce ne répond à vos critères.','annonces').'
');
}
/*---- Show list annonces ----*/
$this->concatAnnonceContent($this->list_annonce());
/*---- Show annonce plugin ----*/
return $this->addAnnoncesToContent($content);
}
/**
*
*/
function addAnnoncesToContent($content)
{
$pattern = '/
<\/div>/';
$replacement = '
'.$this->getAnnonceContent().'
';
$content = preg_replace( $pattern, $replacement, $content );
return $content;
}
/**
*
*/
function filter_plugin_actions_links($links, $file)
{
if ($file == ANNONCES_PLUGIN_DIR. '/annonces.php')
{
$settings_link = $settings_link = '' . __('Réglages', 'annonces') . '';
array_unshift($links, $settings_link);
}
return $links;
}
/**
*
*/
function getActualPage()
{
global $tools;
$actual_page = isset($_REQUEST['page_nav_annonces']) ? $tools->IsValid_Variable($_REQUEST['page_nav_annonces']) : 0 ;
return $actual_page;
}
/**
* Cette m�thode est appel� lorsque que le formulaire de recherche fait une requ�te sur le prix et/ou la superficie
*/
function Filter($needle, $haystack)
{
if(is_null($needle)){
return $haystack;
}
if(is_null($haystack)){
return $needle;
}
if(is_null($needle) and is_null($haystack)){
return null;
}
$result = array();
foreach($needle as $tinyneedle){
if(in_array($tinyneedle,$haystack)){
$result[count($result)] = $tinyneedle;
}
}
return $result;
}
/**
*
*/
function getPagination($morequery = null)
{
global $tools;
$eav_value = new Eav();
$link = ' onclick="javascript:document.getElementById(\'page_nav_annonces\').value=\'#PAGE#\';document.forms.navigation_form.submit();" ';
$nb_total_items = 0;$nb_total_items = $eav_value->getAnnoncesEntete($morequery,DEFAULT_FLAG_AOS,annonce_frontend_listing_order,$this->getActualPage(),'nolimit','count');
$Pagination = '';
if(ceil($nb_total_items/NUMBER_OF_ITEM_PAR_PAGE_FRONTEND_AOS) > 1)
{
$Pagination = $tools->DoPagination($link,$nb_total_items,$this->getActualPage(),NUMBER_OF_ITEM_PAR_PAGE_FRONTEND_AOS,PAGINATION_OFFSET_FRONTEND_AOS,'','','#999999','#FFFFFF');
}
return $Pagination;
}
/**
* Add the google maps api callback into wordpress header
*/
function add_gmap()
{
if(annonces_maps_activation == 'oui')
{
echo '';
}
}
/**
* Add the different needed javascript into the header
*/
function add_js()
{
if(!wp_script_is('jquery', 'queue'))
{
wp_enqueue_script('jquery');
}
wp_enqueue_script('annonces_js_jq_swfobject', ANNONCES_JS_URL . 'swfobject.js', '', ANNONCE_PLUGIN_VERSION);
}
/**
* Add the different needed css into the header
*/
function add_css()
{
wp_register_style('annonces_css_main', ANNONCES_CSS_URL . 'annonce.css', '', ANNONCE_PLUGIN_VERSION);
wp_enqueue_style('annonces_css_main');
wp_register_style('annonces_css_fileuploader', ANNONCES_CSS_URL . 'fileuploader.css', '', ANNONCE_PLUGIN_VERSION);
wp_enqueue_style('annonces_css_fileuploader');
}
/**
* Cette m�thode g�n�re la petite carte que l'on peut voir dans le listing des annonces
*/
function generate_map($morequery = null)
{
$markers = '';
$eav_value = new Eav();
//Afficher que les marqueurs de la page courante
$annonces = $eav_value->getAnnoncesEntete($morequery,DEFAULT_FLAG_AOS,annonce_frontend_listing_order,$this->getActualPage());
//Afficher tout les marqueurs sans distinction de page
// $annonces = $eav_value->getAnnoncesEntete($morequery,DEFAULT_FLAG_AOS,annonce_frontend_listing_order,0,'nolimit');
$sizei = count($annonces);
for($i = 0; $i < $sizei; $i++)
{
$annonce_link_1 = $this->lienUrl($annonces[$i]->idpetiteannonce);
if(!is_null($annonces[$i]->latitude) AND !is_null($annonces[$i]->longitude)){
$surface = $eav_value->getSurface(null,'valid',null,$annonces[$i]->idpetiteannonce);
$prix = $eav_value->getPrix(null,'valid',null,$annonces[$i]->idpetiteannonce);
$description = $eav_value->getDescription(null,'valid',null,$annonces[$i]->idpetiteannonce);
$markers .= 'var marker'.$i.' = new GMarker(new GLatLng('.$annonces[$i]->latitude.','.$annonces[$i]->longitude.'),icon);';
$markers .='GEvent.addListener(marker'.$i.', "mouseover", function() {
annoncemap.openInfoWindowHtml(new GLatLng('.$annonces[$i]->latitude.','.$annonces[$i]->longitude.'), "
'.$annonces[$i]->titre.' '.number_format($surface[0]->valueattributdec,0,',',' ').' '.$surface[0]->measureunit.' à '.$annonces[$i]->ville.', prix '.number_format($prix[0]->valueattributdec,0,',',' ').' '.$prix[0]->measureunit.'
'.$annonces[$i]->titre.' '.number_format($surface[0]->valueattributdec,0,',',' ').' '.$surface[0]->measureunit.' à '.$annonces[$i]->ville.', prix '.number_format($prix[0]->valueattributdec,0,',',' ').' '.$prix[0]->measureunit.'