Plugin Directory

Changeset 1866794


Ignore:
Timestamp:
05/01/2018 07:28:01 AM (8 years ago)
Author:
easyadpicker
Message:

new version update

  • New way to ad products to posts
  • Bug fixes
  • delete products
Location:
easy-ad-picker/trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • easy-ad-picker/trunk/admin/class-admin-init.php

    r1851690 r1866794  
    77        add_action( 'admin_init', array($this, 'EAP_load_scripts') );
    88        add_action( 'admin_init', array($this, 'EAP_load_metaboxes') );
    9         //add_action( 'widgets_init', array($this, 'EAP_load_widgets') );
     9        add_action( 'widgets_init', array($this, 'EAP_load_widgets') );
    1010        add_action( 'admin_menu', array($this, 'EAP_load_menu') );
    1111
     
    1717
    1818    static function EAP_load_widgets(){
    19         register_widget( 'EAP_Admin_Widget_Ad' );
     19        register_widget( 'EAP_Admin_Widget_Products_filter' );
    2020    }
    2121
     
    3333        }
    3434
    35         add_meta_box( 'easyadpicker-meta-box', 'EasyAdPicker', array('EAP_Admin_Metaboxes', 'load_metabox_suggestion'), $aTypes , 'normal', 'high' );
     35        add_meta_box( 'easyadpicker-meta-box', 'EasyAdPicker', array('EAP_Admin_Metaboxes', 'EAP_load_metabox_easyadpicker_ads'), $aTypes , 'normal', 'high' );
    3636    }
    3737
  • easy-ad-picker/trunk/admin/class-advertisers.php

    r1849844 r1866794  
    123123        return $aAdvertisers;
    124124    }
     125
     126    public function delete_products_advertiser($advertiserID){
     127        global $wpdb;
     128
     129        $wpdb->query("DELETE FROM {$wpdb->prefix}easyadpicker_products WHERE advertiser_id = '".sanitize_key($advertiserID)."'");
     130        $wpdb->query("DELETE FROM {$wpdb->prefix}easyadpicker_product_words WHERE advertiser_id = '".sanitize_key($advertiserID)."'");
     131    }
    125132}
    126133?>
  • easy-ad-picker/trunk/admin/class-ajax.php

    r1851690 r1866794  
    9696            $aWhere[] = "AND ( word NOT LIKE '".sanitize_text_field($aWord->word)."')"; //AND column_id = '".$eColumn[0]."
    9797        }
     98
     99        if($_GET['column'] != '' && $_GET['column'] != 0){
     100            $dColumn = "AND column_id = '".$_GET['column']."'";
     101        }
    98102           
    99103
     
    106110            WHERE
    107111                (
    108                     word LIKE '%".sanitize_text_field($_GET['search'])."%' AND
    109                     category_id = '".sanitize_key($_GET['category'])."'
     112                    word LIKE '%".sanitize_text_field($_GET['search'])."%'
     113                    AND category_id = '".sanitize_key($_GET['category'])."'
     114                    ".$dColumn."
    110115                )
    111116        ";
     
    142147    }
    143148
     149    public function EAP_testSearchWords(){
     150
     151        global $wpdb;
     152
     153        $cAds = new EAP_Frontend_Ads;
     154
     155        $aWords = json_decode(stripslashes($_GET['words']));
     156        $aFilters = array();
     157        $sSql = $cAds->EAP_get_query($_GET['category'], $aWords, $aFilters);
     158
     159        $aResults = $wpdb->get_results($sSql);
     160        $rowcount = count($aResults);
     161
     162        $htmlHeader = "Er zijn ".$rowcount." resultaten gevonden";
     163        $htmlHeader = html_entity_decode($htmlHeader);
     164        $htmlHeader = preg_replace("/\r|\n|\t/", "", $htmlHeader); 
     165        $list = json_encode($htmlHeader);
     166        return esc_html($_GET['jsoncallback']) . '(' . $list . ')';
     167    }
     168
     169    public function EAP_getAdFormType(){
     170        $cMetaboxes = new EAP_Admin_Metaboxes;
     171       
     172        $htmlHeader = $cMetaboxes->EAP_adForm_type($_GET['post']);
     173       
     174        $htmlHeader = html_entity_decode($htmlHeader);
     175        $htmlHeader = preg_replace("/\r|\n|\t/", "", $htmlHeader); 
     176        $list = json_encode($htmlHeader);
     177        return esc_html($_GET['jsoncallback']) . '(' . $list . ')';
     178    }
     179
    144180    public function EAP_getAdForm(){
    145181        global $wpdb;
    146182
    147183        $cMetaboxes = new EAP_Admin_Metaboxes;
    148        
    149         $htmlHeader = $cMetaboxes->EAP_adForm($_GET['post'], $_GET['post_ad_id'], '');
     184
     185        if($_GET['type'] == "banners"){
     186            $htmlHeader = $cMetaboxes->EAP_adForm_banners($_GET['post'], $_GET['post_ad_id'], '');
     187        }else{
     188            $htmlHeader = $cMetaboxes->EAP_adForm($_GET['post'], $_GET['post_ad_id'], '');
     189        }
     190       
     191       
    150192       
    151193        $htmlHeader = html_entity_decode($htmlHeader);
     
    158200        global $wpdb;
    159201
    160         $aFilters = array('amount' => $_GET['amount'], 'price' => $_GET['price'], 'advertiser' => $_GET['advertiser']);
     202        $aFilters = array('unique' => $_GET['unique'], 'amount' => $_GET['amount'], 'price' => $_GET['price'], 'advertiser' => $_GET['advertiser'], 'subid' => $_GET['subid']);
    161203        $aFilters = serialize($aFilters);
    162204
     
    201243                <div style="clear:both;"></div>
    202244                <div class="EAP-lightbox-advertising-highlight" id="EAP-copy-shortcode">[EAP_show_ad id="'.$id.'"]</div>
    203                 <div style="clear:both; height:20px;"></div>
    204245                <div class="EAP-lightbox-advertising-place">Kopieer en plaats shortcode</div>
    205246            </div>
     
    308349    public function EAP_deleteAd(){
    309350        global $wpdb;
    310         $wpdb->delete( 'post_ads', array( 'post_id' => sanitize_key($_GET['post']), 'post_ad_id' => sanitize_key($_GET['post_ad_id']) ) );
    311 
    312         $html = '';
    313         $htmlHeader = html_entity_decode($html);
    314         $htmlHeader = preg_replace("/\r|\n|\t/", "", $htmlHeader); 
    315         $list = json_encode($htmlHeader);
    316         return esc_html($_GET['jsoncallback']) . '(' . $list . ')';
     351        $wpdb->delete( "{$wpdb->prefix}easyadpicker_post_ads", array( 'post_id' => sanitize_key($_GET['post']), 'post_ad_id' => sanitize_key($_GET['post_ad_id']) ) );
     352
     353        $html = '';
     354        $htmlHeader = html_entity_decode($html);
     355        $htmlHeader = preg_replace("/\r|\n|\t/", "", $htmlHeader); 
     356        $list = json_encode($htmlHeader);
     357        return esc_html($_GET['jsoncallback']) . '(' . $list . ')';
     358    }
     359
     360    public function EAP_deleteProductsAdvertiser(){
     361       
     362        $cAdvertisers = new EAP_Admin_Advertisers;
     363        $cAdvertisers->delete_products_advertiser($_GET['advertiser']);
     364
     365        $html = '';
     366        $htmlHeader = html_entity_decode($html);
     367        $htmlHeader = preg_replace("/\r|\n|\t/", "", $htmlHeader); 
     368        $list = json_encode($htmlHeader);
     369        return esc_html($_GET['jsoncallback']) . '(' . $list . ')';
     370
    317371    }
    318372
     
    344398    }
    345399
     400    public function EAP_getFiltersSearchword(){
     401        $cMetaboxes = new EAP_Admin_Metaboxes;
     402       
     403        $htmlHeader = $cMetaboxes->EAP_AddTagsAdvertisment($_GET['category']);
     404
     405        $htmlHeader = preg_replace("/\r|\n|\t/", "", $htmlHeader); 
     406        $list = json_encode($htmlHeader);
     407        return esc_html($_GET['jsoncallback']) . '(' . $list . ')';
     408
     409
     410    }
     411
     412    public function EAP_loadAdsMetabox(){
     413        $cMetaboxes = new EAP_Admin_Metaboxes;
     414       
     415        $htmlHeader = $cMetaboxes->EAP_load_ads($_GET['post']);
     416
     417        $htmlHeader = preg_replace("/\r|\n|\t/", "", $htmlHeader); 
     418        $list = json_encode($htmlHeader);
     419        return esc_html($_GET['jsoncallback']) . '(' . $list . ')';
     420    }
     421
    346422}
    347423
  • easy-ad-picker/trunk/admin/class-import-products.php

    r1853164 r1866794  
    123123       
    124124        $wpdb->query("DELETE FROM {$wpdb->prefix}easyadpicker_products WHERE advertiser_property_id = '".$advertiser_property_id."' AND date != '".mktime(0, 0, 0, date('m'), date('d'), date('Y'))."' ");
    125        
    126            
    127125    }
    128126
     
    192190                    '".$word."'
    193191                ) ON DUPLICATE KEY UPDATE
     192                    word = VALUES(word),
    194193                    product_id = LAST_INSERT_ID(product_id)
    195194        ");
  • easy-ad-picker/trunk/admin/class-install.php

    r1853164 r1866794  
    123123        "ALTER TABLE `{$wpdb->prefix}easyadpicker_product_words`
    124124          ADD PRIMARY KEY (`advertiser_product_id`),
    125           ADD UNIQUE KEY `product_id` (`product_id`,`column_id`,`word`);",
     125          ADD UNIQUE KEY `product_id` (`product_id`,`column_id`);",
    126126        "ALTER TABLE `{$wpdb->prefix}easyadpicker_stats_clicks`
    127127          ADD PRIMARY KEY (`stats_clicks_id`),
  • easy-ad-picker/trunk/admin/class-metaboxes.php

    r1851690 r1866794  
    33class EAP_Admin_Metaboxes{
    44
    5     static function load_metabox_suggestion(){
     5    static function EAP_load_metabox_easyadpicker_ads(){
     6
    67        global $post;
     8
     9        $html = '<div id="EAP-metabox-ads" data-id="'.$post->ID.'">';
     10        $html .= self::EAP_load_ads();
     11        $html .= '</div>';
     12       
     13        echo $html;
     14    }
     15
     16    static function EAP_load_ads($postID = 0){
    717        global $wpdb;
     18        global $post;
     19
     20        if($postID > 0){
     21            $post_id = $postID;
     22        }else{
     23            $post_id = $post->ID;
     24        }
    825
    926        $cGeneral = new EAP_Admin_General;
    1027
    11         /* SUGGESTIONS */
    12         $WPEAD_Admin_Secret = new EAP_Admin_Secret($post->post_title, $post->post_content);
    13         $aPop = $WPEAD_Admin_Secret->aPop;
    14 
    15         if(count($aPop) > 0){
    16 
    17        
    18             $dPop = "";
    19             foreach($aPop AS $value => $pop){
    20                 $dPop .= " concat(' ',  word , ' ') LIKE '%".$value."%' OR";
    21             }
    22             $dPop = substr($dPop,0,-3)."";
    23 
    24 
    25             $aSuggestions = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}easyadpicker_product_words WHERE 1 AND (".$dPop.") LIMIT 5");
    26 
    27 
    28             echo '<div class="EAP-suggestion-container">';
    29             foreach($aSuggestions AS $aSuggestion){
    30 
    31                 echo '<div class="EAP-suggestion"><span>'.$aSuggestion->word.'</span></div>';
    32            
    33             }
    34 
    35             echo '</div>';
    36         }
    37 
    38         /* START ADVERTISMENTS */
    39 
    40         echo '<div id="EAP-metabox-ads" data-id="'.$post->ID.'">';
    41 
    42         echo '<div class="EAP-metabox-add" data-id="">Advertentie toevoegen</div>';
    43 
    44         $aAds = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}easyadpicker_post_ads WHERE post_id = '".$post->ID."' ");
     28        $html = '<div class="EAP-metabox-properties"><span><a rel="nofollow" target="blank" href="https://www.easyadpicker.com/docs/starters/hoe-maak-je-een-advertentie-aan/">Hulp nodig?</a></span></div>';
     29
     30        $html .= '<div class="EAP-metabox-add" data-id="">Advertentie toevoegen</div>';
     31
     32        $aAds = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}easyadpicker_post_ads WHERE post_id = '".$post_id."' ");
    4533        foreach($aAds AS $aAd){
    4634            $eWords = explode(',', $aAd->words);
    47             echo '
    48             <div class="EAP-metabox-advertising EAP-metabox-advertising-'.$aAd->ad.'" data-id="'.$aAd->post_ad_id.'">
     35            $html .= '
     36            <div class="EAP-metabox-advertising EAP-metabox-advertising-'.$aAd->ad.'" data-id="'.$aAd->post_ad_id.'" data-type="'.$aAd->ad.'">
    4937                <div class="EAP-metabox-advertising-title">'.$aAd->title.'</div>
    5038            </div>
     
    5240        }
    5341
    54         echo '</div>';
    55 
    56         echo $cGeneral->EAP_lightbox('Advertentie toevoegen', 'Laden', '');
    57        
    58         //echo '<div id="EAP-lightbox-ads" style="display:none;">'.self::adForm($post->ID).'</div>';
    59 
    60     }
    61 
    62     static function EAP_AddTagsAdvertisment($aWords, $suggestions){
     42       
     43
     44        $html .= $cGeneral->EAP_lightbox('Advertentie toevoegen', 'Laden', '');
     45
     46        return $html;
     47       
     48    }
     49
     50    static function EAP_AddTagsAdvertisment($categoryID, $filter_column_id = '', $filter_type= '', $filter_word= ''){
    6351
    6452        global $wpdb;
    6553
    66         $aTempColumns = $wpdb->get_results("SELECT DISTINCT(column_id) AS column_id FROM {$wpdb->prefix}easyadpicker_product_words");
     54        $aTempColumns = $wpdb->get_results("SELECT DISTINCT(column_id) AS column_id FROM {$wpdb->prefix}easyadpicker_product_words WHERE category_id = '".$categoryID."'");
    6755
    6856        $aColumns = array();
     
    7058            $aColumns[ $aTempColumn->column_id ] = $aTempColumn->column_id;
    7159        }
     60
     61        $aTypes = array('breed' => 'Breed zoekwoord zoeken', 'breed_not' => 'Breed zoekwoord uitsluiten', 'exact' => 'Exact zoekwoord zoeken', 'exact_not' => 'Exact zoekwoord uitsluiten');
    7262   
    7363        $html = '';
    7464
    7565        $html .= '
    76         <div id="EAP-box-add-tag">
    77             <div id="EAP-metabox-searchwords-suggestions">
    78                 <input type="text" name="text-tag" id="EAP-own-searchword" class="text-tag form-input-tip ui-autocomplete-input"  autocomplete="off"/>
    79                 <div id="EAP-metabox-searchwords-suggestions-words-back"></div>
    80                 <ul id="EAP-metabox-searchwords-suggestions-words"></ul>
    81             </div>
    82             <div id="EAP-add-searchword">Zoekwoord toevoegen</div>
     66       
     67                <li class="EAP-searchwords-row" data-category="'.$categoryID.'">
     68                    <div class="EAP-searchwords-coll EAP-searchwords-coll-move"></div>
     69                    <div class="EAP-searchwords-coll">
     70                        <select class="EAP-searchwords-column">
     71                            <option value="">Selecteerd data</option>
     72                            <option value="0"'; if($filter_column_id == '0'){ $html .= ' selected '; } $html .= '>Alle data</option>
    8373        ';
    8474
    85         if(strlen($suggestions) > 0){
    86             $html .= '
    87             <div id="EAP-box-suggestions">
    88                 <div id="EAP-box-suggestions-title">Onze suggesties</div>
    89             ';
    90         }
    91 
    92         /*foreach($aPop AS $word => $score){
    93             echo '<div class="EAP-suggestion"><span>'.$word.'</span> ('.$score.')</div>';
    94         }*/
    95 
    96         if(strlen($suggestions) > 0){
    97             $html .= '
     75        foreach($aColumns AS $columnID){
     76
     77            $html .= '<option '; if($filter_column_id == $columnID){ $html .= ' selected '; } $html .= 'value="'.$columnID.'">'.__('Column '.$columnID, 'easyadpicker').'</option>';
     78        }
     79
     80        $html .= '
     81                        </select>
    9882                    </div>
    99                 </div>
    100             ';
     83                    <div class="EAP-searchwords-coll">
     84                        <select class="EAP-searchwords-type">
     85                            <option value="">Selecteer overeenkomst</option>
     86        ';
     87
     88        foreach($aTypes AS $type_value => $type){
     89            $html .= '<option'; if($filter_type == $type_value){ $html .= ' selected '; } $html .= ' value="'.$type_value.'">'.$type.'</option>';
    10190        }
    10291
    10392        $html .= '
    104             <div id="EAP-box-active-tags">
    105                 <ul id="EAP-words">
     93                        </select>
     94                    </div>
     95                    <div class="EAP-searchwords-coll">
     96                        <input type="text" class="EAP-searchwords-word" value="'.$filter_word.'" />
     97                        <ul class="EAP-metabox-searchwords-suggestions-words"></ul>
     98                    </div>
     99                    <div class="EAP-searchwords-coll">
     100                        <div class="EAP-searchwords-delete">-</div>
     101                    <div>
     102                </li>
    106103        ';
    107104
    108         foreach($aWords AS $aWord){
    109             $html .= '
    110                     <li data-column="'.$aWord->column.'" data-word="'.$aWord->word.'">
    111                         <span class="EAP-metabox-searchwords-suggestions-result-category">'.__('Column '.$aWord->column, 'easyadpicker').'</span> :
    112                         <span class="EAP-metabox-searchwords-suggestions-result-word">'.$aWord->word.'</span>
    113                     </li>
    114             ';
    115         }
    116 
    117 
     105        return $html;
     106
     107    }
     108
     109    public function EAP_adForm_type(){
    118110        $html .= '
    119                 </ul>
    120                 <input type="textfield" id="EAP-searchwords-value" name="WPEAD_searchwords" value=""  style=" width:100%; display:none" />
    121             </div>
    122         </div>
     111            <div class="EAP-lightbox-advertising-step" style="display:block;">
     112                <div class="EAP-lightbox-advertising-part">
     113                    <div class="EAP-lightbox-advertising-title">Selecteer advertentie type</div>
     114                    <div class="EAP-lightbox-advertising-text">Selecteer hieronder het type advertentie</div>
     115                   
     116                        <div class="EAP-lighbox-advertising-ad EAP-metabox-advertising-banners"'; if($aAd->ad == "banners"){ $html .= 'EAP-lighbox-advertising-ad-active"'; } $html .= ' data-value="banners">
     117                            <div class="EAP-lighbox-advertising-ad-text">
     118                                <div class="EAP-lighbox-advertising-ad-title">Banner advertentie weergeven</div>
     119                                Weergeef dynamisch banners aan de hand van zelfgekozen zoekwoorden.
     120                            </div>
     121                        </div>
     122
     123                        <div class="EAP-lighbox-advertising-ad EAP-metabox-advertising-products'; if($aAd->ad == "products"){ $html .= ' EAP-lighbox-advertising-ad-active"'; } $html .= '" data-value="products">
     124                            <div class="EAP-lighbox-advertising-ad-text">
     125                                <div class="EAP-lighbox-advertising-ad-title">Producten advertentie weergeven</div>
     126                                Automatisch productoverzichten maken aan de hand van zoekwoorden.
     127                            </div>
     128                        </div>
     129
     130                        <div class="EAP-lighbox-advertising-ad EAP-metabox-advertising-advertisers'; if($aAd->ad == "advertisers"){ $html .=' EAP-lighbox-advertising-ad-active"'; } $html .= '" data-value="advertisers">
     131                            <div class="EAP-lighbox-advertising-ad-text">
     132                                <div class="EAP-lighbox-advertising-ad-title">Adverteerders advertentie weergeven</div>
     133                                Automatisch weergeven van adverteerders aan de hand van zoekwoorden.
     134                            </div>
     135                        </div>
     136
     137                        <input type="text" id="EAP-lightbox-advertising-ad-value" value="'.$aAd->ad.'" name="WPEAD_ad" style="display:none;">
     138                   
     139                </div>
     140                <div class="EAP-lightbox-advertising-ad-add">Advertentie aammaken</div>
     141            </div>
     142   
    123143        ';
    124144
    125145        return $html;
    126 
     146   
    127147    }
    128148
     
    140160        }
    141161
    142        
     162        $aBoxes = array();
     163        foreach($aWords AS $aWord){
     164            if(!isset($aBoxes[ $aWord->box ])){
     165                $aBoxes[ $aWord->box ] = array();
     166            }
     167            $aBoxes[ $aWord->box ][]= $aWord;
     168        }
     169
     170        //echo '<pre>'; print_r($aBoxes);
    143171
    144172        if(isset($_GET['change']) || $post_ad_id == 0){
     
    152180                <div class="EAP-lightbox-advertising-part">
    153181                    <div class="EAP-lightbox-advertising-title">Titel advertentie</div>
    154                     <div class="EAP-lightbox-advertising-text">Deze word alleen weergeven in de admin</div>
     182                    <div class="EAP-lightbox-advertising-text">Titel wordt alleen weergegeven in de admin</div>
    155183                    <input type="text" id="EAP-metabox-advertising-lightbox-title" value="'.$aAd->title.'" name="WPEAD_title" />
    156184                </div>
     
    175203            ';
    176204
    177 
    178             /* SECOND STEP */
     205            /* THIRD STEP */
    179206            $html .= '
    180207            <div class="EAP-lightbox-advertising-step" id="EAP-lightbox-advertising-step-second" data-part="second">
    181208
    182209                <div class="EAP-lightbox-advertising-part">
    183                     <div class="EAP-lightbox-advertising-title">Selecteer type advertentie</div>
    184                     <div class="EAP-lightbox-advertising-text">Selecteer hieronder het type advertentie welke je wilt weergeven.</div>
    185                    
    186                         <div class="EAP-lighbox-advertising-ad EAP-metabox-advertising-banners"'; if($aAd->ad == "banners"){ $html .= 'EAP-lighbox-advertising-ad-active"'; } $html .= ' data-value="banners">
    187                             <div class="EAP-lighbox-advertising-ad-text">
    188                                 <div class="EAP-lighbox-advertising-ad-title">Banner advertentie weergeven</div>
    189                                 Laat je banner zien
     210                    <div class="EAP-lightbox-advertising-title">Selecteer zoekwoorden</div>
     211                    <div class="EAP-lightbox-advertising-text">Aan de hand van de zoekwoorden die jij invoert, worden de advertenties weergeven</div>
     212                    <div id="EAP-box-add-tag">
     213                        <div id="EAP-searchwords">
     214            ';
     215
     216            foreach($aBoxes AS $aWords){
     217
     218                $html .= '
     219                            <div class="EAP-searchwords-table-container">
     220                                <ul class="EAP-searchwords-table connectedSortable">
     221                ';
     222
     223                foreach($aWords AS $aWord){
     224                    $html .= self::EAP_AddTagsAdvertisment($aAd->category_id, $aWord->column, $aWord->type, $aWord->word);
     225                }
     226
     227                $html .= '
     228                                </ul>
     229                                <div class="EAP-searchword-add-filter">Filter toevoegen</div>
    190230                            </div>
     231                ';
     232
     233            }
     234
     235            $html .= '
     236                           
     237                           
     238                       
    191239                        </div>
    192240
    193                         <div class="EAP-lighbox-advertising-ad EAP-metabox-advertising-products'; if($aAd->ad == "products"){ $html .= ' EAP-lighbox-advertising-ad-active"'; } $html .= '" data-value="products">
    194                             <div class="EAP-lighbox-advertising-ad-text">
    195                                 <div class="EAP-lighbox-advertising-ad-title">Producten advertentie weergeven</div>
    196                                 Stel je eigen productoverzicht samen aan de hand van eigen zoekwoorden. Zo is het bijvoorbeeld mogelijk om een overzicht van schoenen, vakanties en boeken te laten zien.
    197                             </div>
    198                         </div>
    199 
    200                         <div class="EAP-lighbox-advertising-ad EAP-metabox-advertising-advertisers'; if($aAd->ad == "advertisers"){ $html .=' EAP-lighbox-advertising-ad-active"'; } $html .= '" data-value="advertisers">
    201                             <div class="EAP-lighbox-advertising-ad-text">
    202                                 <div class="EAP-lighbox-advertising-ad-title">Adverteerders advertentie weergeven</div>
    203                                 Laat een lijst met adverteerders zien aan de hand van zoekwoorden welke je opgeeft. Zo is het mogelijk om bijvoorbeeld vakantie aanbieders te laten zien van een betreffend hotel.
    204                             </div>
    205                         </div>
    206 
    207                         <input type="text" id="EAP-lightbox-advertising-ad-value" value="'.$aAd->ad.'" name="WPEAD_ad" style="display:none;">
    208                    
     241                        <div id="EAP-metabox-searchwords-suggestions-words-back"></div>
     242                       
     243                        <div id="EAP-searchword-add-box">"En voldoet aan" box toevoegen</div>
     244                        <div id="EAP-searchword-submit"><span>Test resultaten</span></div>
     245                        <div id="EAP-searchword-submit-text"></div>
     246                    </div>
    209247                </div>
    210248                <div class="EAP-lightbox-advertising-prev-step" data-prev="first">Vorige stap</div>
    211                 <div class="EAP-lightbox-advertising-next-step" data-next="third">Volgende stap</div>
    212             </div>
    213             ';
    214 
    215             /* THIRD STEP */
     249                <div class="EAP-lightbox-advertising-next-step" data-next="third" data-part="check_searchwords">Volgende stap</div>
     250            </div>
     251            ';
     252
     253            /* LAST STEP */
    216254            $html .= '
    217255            <div class="EAP-lightbox-advertising-step" id="EAP-lightbox-advertising-step-third" data-part="third">
    218256
    219257                <div class="EAP-lightbox-advertising-part">
    220                     <div class="EAP-lightbox-advertising-title">Selecteer zoekwoorden</div>
    221                     <div class="EAP-lightbox-advertising-text">Aan de hand van de zoekwoorden welke jij invoert, worden de advertenties weergeven</div>
    222                     '.self::EAP_AddTagsAdvertisment($aWords, $suggestions).'
    223                 </div>
    224                 <div class="EAP-lightbox-advertising-prev-step" data-prev="second">Vorige stap</div>
    225                 <div class="EAP-lightbox-advertising-next-step" data-next="fourth">Volgende stap</div>
    226             </div>
    227             ';
    228 
    229             /* LAST STEP */
    230             $html .= '
    231             <div class="EAP-lightbox-advertising-step" id="EAP-lightbox-advertising-step-fourth" data-part="fourth">
     258                    <div class="EAP-lightbox-advertising-title">Producten weergaven</div>
     259                    <div class="EAP-lightbox-advertising-text">Alle producten weergeven of producten uniek weergeven met aanbieders erbij</div>
     260                    <select id="EAP-metabox-advertising-lightbox-unique">
     261                        <option value="all"'; if($aFilters['unique'] == 'all'){ $html.= ' selected'; } $html.= '>Alle producten weergeven</option>
     262                        <option value="unique"'; if($aFilters['unique'] == 'unique'){ $html.= ' selected'; } $html.= '>Producten uniek weergeven</option>
     263                    </select>
     264                </div>
    232265
    233266                <div class="EAP-lightbox-advertising-part">
     
    258291                </div>
    259292
    260 
    261                 <div class="EAP-lightbox-advertising-prev-step" data-prev="third">Vorige stap</div>
    262                 <div class="EAP-lightbox-advertising-next-step" data-next="save">Volgende opslaan</div>
     293                <div class="EAP-lightbox-advertising-part">
     294                    <div class="EAP-lightbox-advertising-title">SUBID</div>
     295                    <div class="EAP-lightbox-advertising-text">Tag welke je met de klik/transactie kan meegeven aan het affiliate netwerk</div>
     296                    <input type="text" id="EAP-metabox-advertising-lightbox-subid" value="'.$aFilters['subid'].'" name="WPEAD_subid" />
     297                </div>
     298
     299
     300                <div class="EAP-lightbox-advertising-prev-step" data-prev="second">Vorige stap</div>
     301                <div class="EAP-lightbox-advertising-next-step" data-next="save">Opslaan</div>
    263302            </div>
    264303            ';
     
    271310                <div style="clear:both;"></div>
    272311                <div class="EAP-lightbox-advertising-highlight" id="EAP-copy-shortcode">[EAP_show_ad id="'.$post_ad_id.'"]</div>
    273                 <div style="clear:both; height:20px;"></div>
     312                <div class="EAP-lightbox-advertising-place">Kopieer en plaats shortcode</div>
     313                <div style="clear:both; height:40px;"></div>
     314               
    274315                <div class="EAP-lightbox-advertising-change">Advertentie wijzigen</div>
     316                <div class="EAP-lightbox-advertising-delete">Advertentie verwijderen</div>
     317               
     318            </div>
     319            ';
     320        }
     321       
     322        return $html;
     323    }
     324
     325    public function EAP_adForm_banners($post_id, $post_ad_id, $suggestions){
     326        global $wpdb;
     327
     328        if($post_ad_id != 0){
     329            $aAd = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}easyadpicker_post_ads WHERE post_ad_id = '".sanitize_key($post_ad_id)."'");
     330            $aFilters = unserialize($aAd->filters);
     331            $aWords = unserialize($aAd->words);
     332        }else{
     333            $aAd = (object) array('title' => '', 'category_id' => '', 'ad'=> '', 'amount' => '10', 'words' => '' );
     334            $aFilters = array('amount' => 10, 'price' => 'priceall', 'advertiser' => 'logoname');
     335            $aWords = array();
     336        }
     337
     338       
     339
     340        if(isset($_GET['change']) || $post_ad_id == 0){
     341
     342            $aCategories = $wpdb->get_results("SELECT DISTINCT(category_id) AS category_id FROM {$wpdb->prefix}easyadpicker_product_words");
     343
     344            /* FIRST STEP */
     345            $html = '
     346            <div class="EAP-lightbox-advertising-step" id="EAP-lightbox-advertising-step-first" data-part="first">
     347
     348                <div class="EAP-lightbox-advertising-part">
     349                    <div class="EAP-lightbox-advertising-title">Titel advertentie</div>
     350                    <div class="EAP-lightbox-advertising-text">Titel wordt alleen weergegeven in de admin</div>
     351                    <input type="text" id="EAP-metabox-advertising-lightbox-title" value="'.$aAd->title.'" name="WPEAD_title" />
     352                </div>
     353
     354                <div class="EAP-lightbox-advertising-next-step" data-next="second">Volgende stap</div>
     355            </div>
     356            ';
     357
     358            /* THIRD STEP */
     359            $html .= '
     360            <div class="EAP-lightbox-advertising-step" id="EAP-lightbox-advertising-step-second" data-part="second">
     361
     362                <div class="EAP-lightbox-advertising-part">
     363                    <div class="EAP-lightbox-advertising-title">Selecteer zoekwoorden</div>
     364                    <div class="EAP-lightbox-advertising-text">Aan de hand van de zoekwoorden die jij invoert, worden de advertenties weergeven</div>
     365                    <div id="EAP-box-add-tag">
     366                        <input type="text" name="text-tag" style="width:200px" id="EAP-own-searchword" class="text-tag form-input-tip ui-autocomplete-input" />
     367                        <input type="button" class="button" id="EAP-add-searchword" value="Toevoegen">
     368            ';
     369
     370            $html .= '<div id="EAP-box-active-tags" class="EAP-box-active-tags-new">
     371                        <ul id="EAP-words">';
     372           
     373            foreach($aWords AS $aWord){
     374                $html .= '<li data-column="" data-word="'.$aWord->word.'"><span class="EAP-metabox-searchwords-suggestions-result-category">Search</span> : <span class="EAP-metabox-searchwords-suggestions-result-word">'.$aWord->word.'</span><span class="EAP-metabox-searchwords-suggestions-result-value">Search|'.$aWord->word.'</span></li>';
     375           
     376            }
     377
     378            $html .= '
     379                        </ul>
     380                        <input type="textfield" id="EAP-searchwords-value" name="WPEAD_searchwords" value="" style="display:none" />';
     381           
     382
     383            $html .= '
     384                    </div>
     385                </div>
     386                <div class="EAP-lightbox-advertising-prev-step" data-prev="first">Vorige stap</div>
     387                <div class="EAP-lightbox-advertising-next-step" data-next="third" data-part="check_searchwords">Volgende stap</div>
     388            </div>
     389            ';
     390
     391            /* LAST STEP */
     392            $html .= '
     393            <div class="EAP-lightbox-advertising-step" id="EAP-lightbox-advertising-step-third" data-part="third">
     394
     395                <div class="EAP-lightbox-advertising-part">
     396                    <div class="EAP-lightbox-advertising-title">Aantal resultaten</div>
     397                    <div class="EAP-lightbox-advertising-text">Aantal resultaten welke weergeven worden</div>
     398                    <input type="text" id="EAP-metabox-advertising-lightbox-amount" value="'.$aFilters['amount'].'" name="WPEAD_title" />
     399                </div>
     400
     401                <div class="EAP-lightbox-advertising-prev-step" data-prev="second">Vorige stap</div>
     402                <div class="EAP-lightbox-advertising-next-step" data-next="save">Opslaan</div>
     403            </div>
     404            ';
     405
     406        }else{
     407            $html = '
     408            <div class="EAP-lightbox-advertising-part" style="text-align:center;">
     409                <div class="EAP-lightbox-advertising-title">Plaats je advertentie</div>
     410                Plaats de onderstaan code om de advertentie te weergeven
     411                <div style="clear:both;"></div>
     412                <div class="EAP-lightbox-advertising-highlight" id="EAP-copy-shortcode">[EAP_show_ad id="'.$post_ad_id.'"]</div>
    275413                <div class="EAP-lightbox-advertising-place">Kopieer en plaats shortcode</div>
     414
     415                <div class="EAP-lightbox-advertising-change">Advertentie wijzigen</div>
    276416            </div>
    277417            ';
  • easy-ad-picker/trunk/admin/class-networks.php

    r1851690 r1866794  
    6464            <div class="EAP-lightbox-advertising-part">
    6565                <div class="EAP-lightbox-advertising-title">Publisher ID<a target="_blank" class="EAP-login-question" href="https://faq-publisher.daisycon.com/hc/nl/articles/205765911-Waar-vind-ik-mijn-Media-ID-">?</a></div>
    66                 <div class="EAP-lightbox-advertising-text">Je publisher ID kan je ophalen onder de tab "account" en dan te kiezen voor "<a href="https://my.daisycon.com/publisher/account" target="_blank">Account</a>" in de interface van Daisycon </div>
     66                <div class="EAP-lightbox-advertising-text">Je publisher ID kan je ophalen in de Daisycon interface onder het tabblad "account". Hier kies je voor "<a href="https://my.daisycon.com/publisher/account" target="_blank">Account</a>"</div>
    6767                <input type="text" class="EAP-network-publisherid" value="'.$aData[1]['publisherID'].'"/>
    6868            </div>
     
    7070            <div class="EAP-lightbox-advertising-part">
    7171                <div class="EAP-lightbox-advertising-title">Media ID <a target="_blank" class="EAP-login-question" href="https://faq-publisher.daisycon.com/hc/nl/articles/205765911-Waar-vind-ik-mijn-Media-ID-">?</a></div>
    72                 <div class="EAP-lightbox-advertising-text">Je Media ID an je ophalen onder de tab "account" en dan te kiezen voor "<a href="https://my.daisycon.com/publisher/media" target="_blank">Media</a>" in de interface van Daisycon</div>
     72                <div class="EAP-lightbox-advertising-text">Je media ID kan je ophalen in de Daisycon interface onder het tabblad "account". Hier kies je voor "<a href="https://my.daisycon.com/publisher/media" target="_blank">Media</a>"</div>
    7373                <input type="text" class="EAP-network-mediaid" value="'.$aData[1]['mediaID'].'"/>
    7474            </div>
     
    173173            <div class="EAP-lightbox-advertising-part">
    174174                <div class="EAP-lightbox-advertising-title">Authentication token</div>
    175                 <div class="EAP-lightbox-advertising-text">Je authentication token kan je ophalen in de header onder je account en dan te kiezen voor "<a href="https://ui.awin.com/awin-api" target="_blank">API-inloggegevens</a>"</div>
     175                <div class="EAP-lightbox-advertising-text">Je authentication token kan je ophalen in de header onder je account en te kiezen voor "<a href="https://ui.awin.com/awin-api" target="_blank">API-inloggegevens</a>"</div>
    176176                <input type="text" class="EAP-network-auth" value="'.$aData[2]['authkey'].'" />
    177177            </div>
  • easy-ad-picker/trunk/admin/class-widgets.php

    r1849844 r1866794  
    11<?php
    22
    3 class EAP_Admin_Widget_Ad extends WP_Widget {
     3class EAP_Admin_Widget_Products_filter extends WP_Widget {
    44     
    55    function __construct() {
    66        $widget_ops = array(
    7             'classname' => 'EAP_Admin_Widget_Ad',
    8             'description' => 'Automatisch weergeven van advertenties op basis van keywords',
     7            'classname' => 'EAP_Admin_Widget_Products_filter',
     8            'description' => 'Toon filters op dezelfde pagina als een productadvertentie',
    99        );
    10         parent::__construct( 'EAP_Admin_Widget_Ad', 'Advertenties Easy Ad Picker', $widget_ops );
     10        parent::__construct( 'EAP_Admin_Widget_Products_filter', 'Easy Ad Picker producten filter', $widget_ops );
    1111    }
    1212     
    1313    function form( $instance ) {
     14
     15        $aFilters = array(
     16            'colors' => 'Kleuren',
     17            'brands' => 'Merken',
     18            'shops' => 'Winkels',
     19            'prices' => 'Prijzen',
     20            'countries' => 'Landen',
     21            'regions' => 'Regios',
     22            'cities' => 'Steden'
     23        );
     24
    1425        $instance = wp_parse_args( (array) $instance, array( 'display' => '', 'title' => '' ) );
    1526        echo '
     
    2031        </p>
    2132        <p>
    22         <label for="'.$this->get_field_id("text").'">Type advertentie:
    23         <select class="widefat" id="'.$this->get_field_id('display').'" name="'.$this->get_field_name('display').'" type="text">
    24             <option value="" '; if($instance['display'] == ""){ echo ' selected'; } echo'>Selecteer type</option>
    25             <option value="horizontal" '; if($instance['display'] == "horizontal"){ echo ' selected'; } echo'>Horitzontaal</option>
    26             <option value="vertical" '; if($instance['display'] == "vertical"){ echo ' selected'; } echo'>Verticaal</option>
    27             <option value="square" '; if($instance['display'] == "square"){ echo ' selected'; } echo'>Vierkant</option>
     33        <label for="'.$this->get_field_id("filter").'">Type filter:
     34        <select class="widefat" id="'.$this->get_field_id('filter').'" name="'.$this->get_field_name('filter').'" type="text">
     35            <option value="" '; if(isset($instance['filter'])){if($instance['filter'] == ""){ echo ' selected'; }} echo'>Selecteer type</option>
     36        ';
     37
     38        foreach($aFilters AS $value => $name){
     39            echo '<option value="'.$value.'" '; if(isset($instance['filter'])){if($instance['filter'] == $value){ echo ' selected'; }} echo'>'.$name.'</option>';
     40        }
     41
     42        echo '
    2843        </select>               
    2944        </label>
     
    3449    function update( $new_instance, $old_instance ) {
    3550        $instance = $old_instance;
    36         $instance['display'] = $new_instance['display'];
     51        $instance['filter'] = $new_instance['filter'];
    3752        $instance['title'] = $new_instance['title'];
    3853        return $instance;
     
    4459        global $wpdb;
    4560
    46         $aAd = $wpdb->get_row("SELECT * FROM post_ads WHERE post_id = '".$post->ID."' AND ad = 'general'");
    47         $searchwords = "'".str_replace(",","','", $aAd->words)."'";
    48 
    49         if(!isset($instance['amount'])){ $instance['amount'] = 1; }
    50         if(isset($instance['display'])){ $dDisplay = "AND display = '".$instance['display']."'"; }else{ $dDisplay = ""; }
    51 
    52         $aAds = $wpdb->get_results("
    53             SELECT
    54                 *
    55             FROM
    56                 advertiser_material_words
    57             LEFT JOIN
    58                 advertiser_materials
    59             ON
    60                 advertiser_material_words.material_id = advertiser_materials.material_id
    61             WHERE
    62                 word IN (".$searchwords.")
    63                 ".$dDisplay."
    64             GROUP BY
    65                 advertiser_materials.material_id
    66             ORDER BY
    67                 RAND()
    68             LIMIT
    69                 ".$instance['amount']."
    70         ");
    71 
    72         $html = '<h2 class="widget-title">'.$instance['title'].'</h2>';
    73 
    74         foreach($aAds AS $aAd){
    75             $html .= '<div class="ad"><img src="'.$aAd->material.'" /></div>';
    76         }
    77 
    78         echo $html;
     61        echo '
     62            <aside class="widget group EAP-products-filter-container" data-type="'.$instance['filter'].'">
     63                <h3 class="widget-title">'.$instance['title'].'</h3>
     64                <div class="EAP-products-filter"></div>
     65            </aside>
     66        ';
    7967
    8068    }
  • easy-ad-picker/trunk/admin/views/advertisers-importproducts.php

    r1849844 r1866794  
    77
    88<div class="wrap">
    9     <h1 class="wp-heading-inline">Importeer producten van de volgende adverteerders</h1>
    10     <div class="EAP-button" id="EAP-advertiser-import-all-start">Start met importeren producten</div>
     9    <h1 class="wp-heading-inline">Importeer producten van de volgende adverteerders</h1><div style="clear:both;"></div>
     10    Importeer producten van meerdere adveteerders in één keer. Wanneer je op "Start met importeren van producten" klikt start het process. Let op dat het importeren van producten enkele (tientallen) minuten kan duren. Sluit het venster daarom niet af tot alle laadbalken achter de actieve adverteerders zijn voltooid.
     11    <div style="clear:both;"></div>
     12
     13    <div class="EAP-button" id="EAP-advertiser-import-all-start">Start met importeren van producten</div>
    1114
    1215    <table id="table-advertisers-productsimport" class="wp-list-table widefat fixed striped posts">
  • easy-ad-picker/trunk/admin/views/dashboard.php

    r1849844 r1866794  
    126126                        <?php
    127127                            global $wpdb;
    128                             $aKey = $wpdb->get_row("SELECT * FROM wp_options WHERE option_name = 'WPEAP_key'");
     128                            $aKey = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}options WHERE option_name = 'WPEAP_key'");
    129129                            $sUrl = 'http://api.easyadpicker.com/?q=getNews&type=json&website='.$_SERVER['SERVER_NAME'].'&key='.$aKey->option_value;
    130130                            $json = file_get_contents($sUrl);
  • easy-ad-picker/trunk/config/autoload.php

    r1849844 r1866794  
    2828        'EAP_Frontend_Settings' => "/../frontend/class-settings.php",
    2929        'EAP_Frontend_Ajax' => "/../frontend/class-ajax.php",
     30        'EAP_Frontend_Filters' => "/../frontend/class-filters.php"
    3031    );
    3132
  • easy-ad-picker/trunk/css/admin.css

    r1851690 r1866794  
    117117    text-shadow: 0 -1px 1px #e61414, 1px 0 1px #e61414, 0 1px 1px #e61414, -1px 0 1px #e61414;
    118118    float:right;
     119}
     120
     121#EAP-advertiser-import-all-start{
     122    border-radius: 4px;
     123    background: #8ecc54;
     124    color: #FFF;
     125    padding: 10px 15px;
     126    display: inline-block;
     127    vertical-align: top;
     128    margin-top:10px;
     129    border:none;
     130    margin-bottom:20px;
     131}
     132
     133.EAP-advertiser-import-all-start-active{
     134    background:#CCC !important;
     135    color:#333333 !important;
    119136}
    120137
     
    256273
    257274/* EDIT POST */
     275.EAP-metabox-properties{
     276    padding:5px;
     277    border-bottom:1px solid #f4f4f4;
     278    text-align: right;
     279}
     280.EAP-metabox-properties span{
     281    background:#f4f4f4;
     282    padding:7px 15px;
     283}
    258284.EAP-metabox-add{
    259285    width:25%;
     
    265291    font-style:italic;
    266292    margin-right:-4px;
     293    cursor: pointer;
    267294}
    268295
     
    285312    font-style:italic;
    286313    margin-right:-4px;
     314    cursor: pointer;
    287315}
    288316
     
    371399}
    372400
    373 .EAP-lightbox-advertising-next-step, .EAP-lightbox-advertising-save, .EAP-lightbox-advertising-place{
     401.EAP-lightbox-advertising-next-step, .EAP-lightbox-advertising-save{
    374402    background: #2eb9b4;
    375403    padding: 8px 15px;
     
    379407    font-size: 12px;
    380408    font-weight: 500;
     409}
     410
     411.EAP-lightbox-advertising-place{
     412    -webkit-border-top-right-radius: 6px;
     413    -webkit-border-bottom-right-radius: 6px;
     414    -moz-border-radius-topright: 6px;
     415    -moz-border-radius-bottomright: 6px;
     416    border-top-right-radius: 6px;
     417    border-bottom-right-radius: 6px;
     418    background: #2eb9b4;
     419    padding: 8px 15px;
     420    color: #FFF !important;
     421    display: inline-block;
     422    font-size: 12px;
     423    font-weight: 500;
     424    cursor: pointer;
    381425}
    382426
     
    390434    font-weight: 500;
    391435    margin-right:10px;
     436    cursor: pointer;
     437}
     438
     439.EAP-lightbox-advertising-delete{
     440    background: #eb3324;
     441    padding: 8px 15px;
     442    color: #ffffff !important;
     443    display: inline-block;
     444    border-radius: 6px;
     445    font-size: 12px;
     446    font-weight: 500;
     447    margin-right:10px;
     448    cursor: pointer;
     449}
     450
     451.EAP-lightbox-advertising-ad-add{
     452    background: #2eb9b4;
     453    padding: 8px 15px;
     454    color: #ffffff !important;
     455    display: inline-block;
     456    border-radius: 6px;
     457    font-size: 12px;
     458    font-weight: 500;
     459    margin:0 auto;
     460    cursor: pointer;
    392461}
    393462
     
    459528.EAP-lightbox-advertising-highlight{
    460529    background:#e8f0f7;
    461     border-radius: 8px;
    462     padding:7px 10px;
     530    padding: 8px 15px;
    463531    display: inline-block;
    464532    margin-top:20px;
     533    -webkit-border-top-left-radius: 6px;
     534    -webkit-border-bottom-left-radius: 6px;
     535    -moz-border-radius-topleft: 6px;
     536    -moz-border-radius-bottomleft: 6px;
    465537}
    466538
     
    540612
    541613/* SUGGESTIONS SEACHTWORDS */
     614
    542615#EAP-metabox-searchwords-suggestions{
    543616    display: inline-block;
     
    563636}
    564637
    565 #EAP-metabox-searchwords-suggestions-words{
     638.EAP-metabox-searchwords-suggestions-words{
    566639    position: absolute;
    567640    z-index: 3;
     
    573646    overflow-y: scroll;
    574647    opacity: 0.9;
    575     top:28px;
     648    top:42px;
    576649    border:1px solid #eaeaea;
    577650    display:none;
    578651}
    579652
    580 #EAP-metabox-searchwords-suggestions-words li{
     653.EAP-metabox-searchwords-suggestions-words li{
    581654    border-bottom:1px solid #eaeaea;
    582655    padding:5px;
     
    584657}
    585658
    586 #EAP-metabox-searchwords-suggestions-words li img{
     659.EAP-metabox-searchwords-suggestions-words li img{
    587660    width:30px;
    588661    display: inline-block;
     
    591664}
    592665
    593 #EAP-metabox-searchwords-suggestions-words li:hover{
     666.EAP-metabox-searchwords-suggestions-words li:hover{
    594667    font-weight: bold;
    595668}
     
    609682    border:none;
    610683    padding:10px;
    611 }
    612 
     684    text-align: right;
     685}
     686
     687
     688
     689/* TALBE LIST SEARCHWORD */
     690.EAP-searchwords-table-container{
     691    padding:10px;
     692    border:1px solid #008bd2;
     693    border-radius: 6px;
     694    margin-bottom:10px;
     695    position: relative;
     696    min-height: 20px;
     697}
     698.EAP-searchwords-table-container:after{
     699    content: 'En voldoet aan';
     700    background: #008bd2;
     701    color: #FFF;
     702    padding:0px 5px;
     703    font-size: 10px;
     704    position: absolute;
     705    left: 42%;
     706    bottom: -18px;
     707    border-radius: 6px;
     708    line-height: 24px;
     709    text-align: center;
     710    z-index: 2;
     711}
     712.EAP-searchwords-table-container:last-child:after{
     713    display: none;
     714}
     715.EAP-searchwords-table{
     716    display: table;
     717    border-collapse: collapse;
     718    width:100%;
     719    margin:0px;
     720    padding:0px;
     721    min-height: 20px;
     722}
     723.EAP-searchwords-row{
     724    position: relative;
     725    margin-bottom:0px;
     726    /* display: table-row; */
     727}
     728.EAP-searchwords-row:after{
     729    content: 'Of voldoet aan';
     730    background: #008bd2;
     731    color: #FFF;
     732    font-size: 10px;
     733    padding:0px 5px;
     734    position: absolute;
     735    left: 42%;
     736    bottom:-8px;
     737    border-radius: 6px;
     738    line-height: 20px;
     739    z-index: 2;
     740    text-align: center;
     741}
     742.EAP-searchwords-row:last-child:after{
     743    display: none;
     744}
     745.EAP-searchwords-coll{
     746    display: table-cell;
     747    vertical-align: middle;
     748    background:#f3f3f3;
     749    padding:5px;
     750    border-bottom:6px solid #FFF;
     751    position: relative;
     752}
     753
     754.EAP-searchwords-coll-move{
     755    content:'';
     756    background:url('../images/crosshair.png');
     757    background-size:16px auto;
     758    background-repeat: no-repeat;
     759    background-position: center center;
     760    min-width: 24px;
     761}
     762
     763#EAP-searchwords-table tr:first-child .EAP-searchwords-delete{
     764    display: none;
     765}
     766
     767.EAP-searchword-add-filter{
     768    background:#f3f3f3;
     769    vertical-align: middle;
     770    width:100%;
     771    display: inline-block;
     772    vertical-align: middle;
     773    text-align: center;
     774    padding:5px;
     775}
     776.EAP-searchword-add-filter:before{
     777    content:'+';
     778    background:#FFF;
     779    width:16px;
     780    height: 16px;
     781    display: inline-block;
     782    text-align: center;
     783    line-height: 14px;
     784    border-radius: 100%;
     785    margin-right: 5px;
     786}
     787
     788#EAP-searchword-add-box{
     789    background:#008bd2;
     790    display: inline-block;
     791    text-align: center;
     792    line-height: 14px;
     793    border-radius: 6px;
     794    width:100%;
     795    color:#FFF;
     796    display: inline-block;
     797    vertical-align: middle;
     798    margin-right:-4px;
     799    padding:5px 7px;
     800}
     801#EAP-searchword-add-box:before{
     802    content:'+';
     803    background:#FFF;
     804    width:16px;
     805    height: 16px;
     806    color:#008bd2;
     807    display: inline-block;
     808    text-align: center;
     809    line-height: 14px;
     810    border-radius: 100%;
     811    margin-right: 5px;
     812}
     813
     814.EAP-searchwords-delete{
     815    background:#eb3324;
     816    width:14px;
     817    height: 14px;
     818    border-radius: 100%;
     819    color:#FFF;
     820    content:'-';
     821    font-weight: bold;
     822    line-height: 12px;
     823    margin-left:5px;
     824    text-align: center;
     825    display: inline-block;
     826}
     827
     828#EAP-searchword-submit{
     829    margin-top:10px;
     830}
     831
     832#EAP-searchword-submit{
     833    text-align: right;
     834}
     835
     836#EAP-searchword-submit span{
     837    display: inline-block;
     838    padding:5px 7px;
     839    cursor: pointer;
     840    color:#FFF;
     841    background:#fdc629;
     842    border-radius: 6px
     843}
     844
     845#EAP-searchword-submit-text{
     846    border-radius: 6px;
     847    display: block;
     848    margin-top:10px;
     849    background:#f3f3f3;
     850    border:1px solid #CCC;
     851    display: none;
     852    margin-top:20px;
     853    font-style: italic;
     854    text-align: center;
     855    padding:5px;
     856}
    613857/* COLLAGES PAGE */
    614858
     
    9051149
    9061150.EAP-advertiser-actions{
    907 
     1151    text-align: center;
    9081152    padding-top:10px;
    9091153    margin-top:10px;
  • easy-ad-picker/trunk/css/front.css

    r1851771 r1866794  
    3535    margin:1%!important;
    3636    border:1px solid #FFF!important;
    37     height: 290px!important;
     37   
    3838    font-size:14px!important;
    3939    margin-right:-4px!important;
     
    5050    width:100%!important;
    5151    margin: 0 auto!important;
    52     text-align: center!important;
     52    min-height: 150px !important;
     53    text-align: center!important;
     54    position: relative !important;
    5355}
    5456
    5557.EAP-product-imagecontainer img{
    56     width:90%!important;
    57     max-width: 200px!important;
     58    max-width: 180px !important;
     59    max-height: 180px !important;
    5860}
    5961
     
    8284    box-shadow:none !important;
    8385    border:none !important;
     86    color:#333333;
     87    text-decoration: none;
    8488}
    8589
     
    101105    color:#FFF!important;
    102106    left:20px!important;
    103     bottom:100px!important;
     107    top:100px!important;
    104108}
    105109.EAP-product-new{
    106110    background:#5dbda4!important;
    107111    padding:0px 10px!important;
    108     border-radius: 6px!important;
     112    border-radius: 4px!important;
    109113    position: absolute!important;
    110114    font-size:10px!important;
    111115    color:#FFF!important;
    112     left:20px!important;
     116    left:0px!important;
    113117    bottom:100px!important;
    114118}
     
    214218    color:#FFF !important
    215219}
     220
     221/* RESIZE */
     222
     223.EAP-advertisment-container-0 .EAP-product{
     224    width:98% !important;
     225}
     226
     227.EAP-advertisment-container-300 .EAP-product{
     228    width:48% !important;
     229}
     230
     231.EAP-advertisment-container-600 .EAP-product{
     232    width:31.33% !important;
     233}
     234
     235.EAP-advertisment-container-900 .EAP-product{
     236    width:23% !important;
     237}
     238
     239/* FITLERS */
     240.EAP-checboxes-list{
     241    padding:0px;
     242    margin:0px;
     243}
     244
     245.EAP-checboxes-list li{
     246    padding:10px;
     247    background:#f4f4f4;
     248    margin-top:4px;
     249    list-style: none
     250}
     251
     252.EAP-checboxes-list li input[type=checkbox]{
     253    margin-right:5px;
     254}
     255
     256.EAP-products-filter-container{
     257    margin-bottom:20px;
     258    padding:20px;
     259}
  • easy-ad-picker/trunk/easyadpicker.php

    r1849844 r1866794  
    66Description: Een Wordpress plugin welke ervoor zorgt dat jouw website gemakkelijk kan samenwerking met affiliate partners. Promoot producten en banners op unieuwe wijze
    77Author: Easyadpicker.com
    8 Version: 1.0
     8Version: 1.0.1
    99Author URI: http://www.easyadpicker.com
    1010Domain Path: /languages
  • easy-ad-picker/trunk/frontend/class-ads.php

    r1853164 r1866794  
    7878    }
    7979
    80     public function EAP_get_products($post_ad_id){
     80    public function EAP_get_products($post_ad_id, $aUserFilters){
    8181
    8282        global $wpdb;
     
    8585        if(isset($post_ad_id)){
    8686            $aAd = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}easyadpicker_post_ads WHERE post_ad_id = ".sanitize_key($post_ad_id)."");
    87             $aFilters = unserialize($aAd->filters);
    8887        }else{
    8988            $aAd = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}easyadpicker_post_ads WHERE ad = 'general'");
     
    9190
    9291        if(count($aAd) > 0){
    93 
    94             $sSql = self::EAP_get_query($aAd);
     92            $aWords = unserialize($aAd->words);
     93            $aFilters = unserialize($aAd->filters);
     94
     95            $sSql = self::EAP_get_query($aAd->category_id, $aWords, $aFilters, $aUserFilters);
     96           
     97            if($aFilters['unique'] == "unique"){
     98                $sSql .= "GROUP BY {$wpdb->prefix}easyadpicker_product_words_ean.word";
     99            }
    95100
    96101            $sSql .= "
    97102                ORDER BY
    98                     RAND()
     103                    {$wpdb->prefix}easyadpicker_products.new DESC, price_order DESC
    99104            ";
    100105
     
    108113                    ".($blz * $aFilters['amount']).", ".$aFilters['amount']."
    109114            ";
    110 
    111             //var_dump($sSql);
    112115
    113116            $aAds = $wpdb->get_results($sSql);
     
    137140        if(isset($post_ad_id)){
    138141            $aAd = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}easyadpicker_post_ads WHERE post_ad_id = ".$post_ad_id."");
     142        }
     143
     144        if(count($aAd) > 0){
     145            $aWords = unserialize($aAd->words);
    139146            $aFilters = unserialize($aAd->filters);
    140         }
    141 
    142         if(count($aAd) > 0){
    143            
    144             $sSql = self::EAP_get_query($aAd);
     147
     148            $sSql = self::EAP_get_query($aAd->category_id, $aWords, $aFilters);
    145149
    146150            $sSql .= "
     
    172176    }
    173177
    174     static function EAP_get_query($aAd){
    175         global $wpdb;
    176         //$eWords = explode(',', $aAd->words);
    177         $aWords = unserialize($aAd->words);
    178 
     178    static function EAP_get_query($categoryID, $aWords, $aFilters, $aUserFilters = array()){
     179        global $wpdb;
    179180       
    180 
    181         $aColumns = array();
    182         foreach($aWords AS $aWord){
    183             if(!isset($aColumns[ $aWord->column ])){ $aColumns[ $aWord->column ] = ''; }
    184             $aColumns[ $aWord->column ] .= "'".$aWord->word."',";
    185         }
    186 
    187         $aWhere = array();
    188         $aJoins = array();
    189         $dSearch = "";
    190 
    191         if(count($aWords) > 0){
    192             foreach($aColumns AS $column => $words){
    193                 if( $column != 0){
    194                     $aJoins[ $column ] = "
    195                     LEFT OUTER JOIN
    196                         {$wpdb->prefix}easyadpicker_product_words AS {$wpdb->prefix}easyadpicker_product_words_".sanitize_key($column)."
    197                     ON
    198                         {$wpdb->prefix}easyadpicker_products.product_id = {$wpdb->prefix}easyadpicker_product_words_".sanitize_key($column).".product_id
    199                     ";
    200                 }else{
    201                     $dSearch = "AND ({$wpdb->prefix}easyadpicker_products.title LIKE '%".$words."%' OR {$wpdb->prefix}easyadpicker_products.search LIKE '%".$words."%')";
    202                 }
    203             }
    204         }
    205 
    206         $dBestDeal = '';
    207         /*if($aAd->best_deals == 1){
    208             $dBestDeal = "AND wp_easyadpicker_products.best_deal = '1'";
    209         }*/
    210        
    211         $aSql = array();
    212         foreach($aColumns AS $column => $words){
    213             if( $aWord->column != 0){
    214                 $aSql[] = " AND ({$wpdb->prefix}easyadpicker_product_words_".sanitize_key($column).".word IN (".substr($words,0,-1).") AND {$wpdb->prefix}easyadpicker_product_words_".sanitize_key($column).".column_id = '".sanitize_key($column)."')";
    215             }
     181        $aSql = self::EAP_get_query_array($aWords, $aFilters);
     182
     183        if(count($aUserFilters) > 0){
     184            $aSqlUsers = self::EAP_set_user_filters($aUserFilters);
    216185        }
    217186
    218187        $sSql = "
    219188            SELECT
    220                 *
     189                {$wpdb->prefix}easyadpicker_products.advertiser_id,
     190                {$wpdb->prefix}easyadpicker_products.unique_id,
     191                {$wpdb->prefix}easyadpicker_products.material,
     192                {$wpdb->prefix}easyadpicker_products.title,
     193                {$wpdb->prefix}easyadpicker_products.price_old,
     194                {$wpdb->prefix}easyadpicker_products.price,
     195                {$wpdb->prefix}easyadpicker_products.link,
     196                {$wpdb->prefix}easyadpicker_products.new,
     197                {$wpdb->prefix}easyadpicker_advertisers.advertiser,
     198                {$wpdb->prefix}easyadpicker_advertisers.slug,
     199                CASE WHEN price_old > 0 THEN (price_old - price) ELSE 0 END AS price_order
     200        ";
     201
     202        if($aFilters['unique'] == "unique"){ $sSql .= ",COUNT(*) AS advertisers, {$wpdb->prefix}easyadpicker_product_words_ean.word AS ean"; }
     203
     204        $sSql .= "
    221205            FROM
    222206                {$wpdb->prefix}easyadpicker_products
     
    231215        ";
    232216
    233         foreach($aJoins AS $join){
     217        if($aFilters['unique'] == "unique"){
     218            $sSql .= "
     219                LEFT OUTER JOIN
     220                    {$wpdb->prefix}easyadpicker_product_words AS {$wpdb->prefix}easyadpicker_product_words_ean
     221                ON
     222                    {$wpdb->prefix}easyadpicker_products.product_id = {$wpdb->prefix}easyadpicker_product_words_ean.product_id
     223            ";
     224        }
     225
     226        foreach($aSql['joins'] AS $join){
    234227            $sSql .= $join;
     228        }
     229
     230        foreach($aSqlUsers['joins'] AS $column => $join){
     231            if( !isset( $aSql['joins'][$column] ) ){
     232                $sSql .= $join;
     233            }
    235234        }
    236235
    237236        $sSql .= "
    238237            WHERE
    239                 {$wpdb->prefix}easyadpicker_advertiser_properties.category_id = '".sanitize_key($aAd->category_id)."'
     238                {$wpdb->prefix}easyadpicker_advertiser_properties.category_id = '".sanitize_key($categoryID)."'
    240239                ".$dSearch."
    241                 ".$dBestDeal."
    242240        ";
    243241
    244         foreach($aSql AS $sql){
    245             $sSql .= $sql;
    246         }
    247 
     242        foreach($aSqlUsers['where'] AS $where){
     243            $sSql .= $where;
     244        }
     245
     246
     247        foreach($aSql['search'] AS $search){
     248            $sSql .= $search;
     249        }
     250
     251
     252        if($aFilters['unique'] == "unique"){
     253            $sSql .= "AND {$wpdb->prefix}easyadpicker_product_words_ean.column_id = '10'";
     254        }
     255
     256        $sSql .= "AND ( ";
     257
     258        foreach($aSql['where'] AS $aOr){
     259            $sSql .= "(";
     260            foreach($aOr AS $sql){
     261                $sSql .= $sql." OR ";
     262            }
     263            $sSql = substr($sSql,0,-4);
     264            $sSql .= ") AND ";
     265        }
     266
     267        $sSql = substr($sSql,0,-4);
     268        $sSql .= ")";
    248269
    249270        return $sSql;
    250271    }
    251272
     273    static function EAP_get_query_array($aWords, $aFilters){
     274
     275        global $wpdb;
     276
     277        $aColumns = array();
     278        foreach($aWords AS $aWord){
     279            $aColumns[ $aWord->box ][ $aWord->column ][ $aWord->type ][] = $aWord->word;
     280        }
     281
     282        $aWhere = array();
     283        $aJoins = array();
     284        $aSearch = array();
     285
     286        if(count($aWords) > 0){
     287            foreach($aColumns AS $aBox){
     288                foreach($aBox AS $columnID => $aColumn){
     289                    if( $columnID != 0){
     290                        $aJoins[ $columnID ] = "
     291                        LEFT OUTER JOIN
     292                            {$wpdb->prefix}easyadpicker_product_words AS {$wpdb->prefix}easyadpicker_product_words_".sanitize_key($columnID)."
     293                        ON
     294                            {$wpdb->prefix}easyadpicker_products.product_id = {$wpdb->prefix}easyadpicker_product_words_".sanitize_key($columnID).".product_id
     295                        ";
     296                    }
     297                }
     298            }
     299        }
     300       
     301        if(count($aWords) > 0){
     302            foreach($aColumns AS $boxID => $aBox){
     303
     304                $aWhere[ $boxID ] = array();
     305
     306                foreach($aBox AS $columnID => $aColumn){
     307                   
     308                    $aWhere[ $boxID ][ $columnID ] = "(";
     309
     310                    if( $columnID != 0){
     311                        $search = '';
     312                       
     313                        $aSearch[ $columnID ] = "AND {$wpdb->prefix}easyadpicker_product_words_".sanitize_key($columnID).".column_id = '".sanitize_key($columnID)."'";
     314
     315                        foreach($aColumn AS $type => $aWords){
     316
     317                            foreach($aWords AS $word){
     318                               
     319                                if($type == "exact"){
     320                                    $aWhere[ $boxID ][ $columnID ] .= "{$wpdb->prefix}easyadpicker_product_words_".sanitize_key($columnID).".word = '".$word."' OR ";   
     321                                }
     322                                elseif($type == "exact_not"){
     323                                    $aWhere[ $boxID ][ $columnID ] .= "{$wpdb->prefix}easyadpicker_product_words_".sanitize_key($columnID).".word != '".$word."' OR "; 
     324                                }
     325                                elseif($type == "breed"){
     326                                    $aWhere[ $boxID ][ $columnID ] .= "{$wpdb->prefix}easyadpicker_product_words_".sanitize_key($columnID).".word LIKE '%".$word."%' OR "; 
     327                                }
     328                                elseif($type == "breed_not"){
     329                                    $aWhere[ $boxID ][ $columnID ] .= "{$wpdb->prefix}easyadpicker_product_words_".sanitize_key($columnID).".word NOT LIKE '%".$word."%' OR "; 
     330                                }
     331                                elseif($type == ""){
     332                                    $aWhere[ $boxID ][ $columnID ] .= "{$wpdb->prefix}easyadpicker_product_words_".sanitize_key($columnID).".word = '".$word."' OR ";   
     333                                }
     334                            }
     335                        }
     336
     337                    }else{
     338                        foreach($aColumn AS $type => $aWords){
     339                            foreach($aWords AS $word){
     340
     341                                if($type == "breed_not"){
     342                                    $aWhere[ $boxID ][ $columnID ] .= "({$wpdb->prefix}easyadpicker_products.title NOT LIKE '%".$word."%' AND {$wpdb->prefix}easyadpicker_products.search NOT LIKE '%".$word."%') OR ";
     343                                }else{
     344                                    $aWhere[ $boxID ][ $columnID ] .= "({$wpdb->prefix}easyadpicker_products.title LIKE '%".$word."%' OR {$wpdb->prefix}easyadpicker_products.search LIKE '%".$word."%') OR ";
     345                                }
     346
     347                            }
     348                        }
     349
     350                       
     351                    }
     352
     353                    $aWhere[ $boxID ][ $columnID ] = substr($aWhere[ $boxID ][ $columnID ],0,-4);
     354                    $aWhere[ $boxID ][ $columnID ] .= ") OR ";
     355                    $aWhere[ $boxID ][ $columnID ] = substr($aWhere[ $boxID ][ $columnID ],0,-4);
     356                   
     357
     358                }
     359               
     360            }
     361        }
     362
     363
     364        return array('where' => $aWhere, 'joins' => $aJoins, 'search' => $aSearch);
     365    }
     366
     367    static function EAP_set_user_filters($aUserFilters){
     368
     369        global $wpdb;
     370
     371        $aFilters = array();
     372        foreach($aUserFilters AS $aUserFilter){
     373            $aFilters[ $aUserFilter->type ][] = $aUserFilter->value;
     374        }
     375
     376        $aWhere = array();
     377        $aJoins = array();
     378        foreach($aFilters AS $column => $aFilterValues){
     379
     380            if($column == "brands"){
     381               
     382                $values = "";
     383                foreach($aFilterValues AS $value){
     384                    $values .= "'".$value."',";
     385                }
     386
     387                $aWhere[] = "AND {$wpdb->prefix}easyadpicker_product_words_5.word IN (".substr($values, 0, -1).")";
     388
     389                $aJoins[ 5 ] = "
     390                    LEFT OUTER JOIN
     391                        {$wpdb->prefix}easyadpicker_product_words AS {$wpdb->prefix}easyadpicker_product_words_5
     392                    ON
     393                        {$wpdb->prefix}easyadpicker_products.product_id = {$wpdb->prefix}easyadpicker_product_words_5.product_id
     394                ";
     395                   
     396            }
     397
     398            elseif($column == "colors"){
     399               
     400                $aWhere['colors'] = "AND (";
     401                foreach($aFilterValues AS $value){
     402                    $eColors = explode('-', $value);
     403
     404                    foreach($eColors AS $color){
     405                        $aWhere['colors'] .= "{$wpdb->prefix}easyadpicker_product_words_7.word LIKE '%".$color."%' OR ";
     406                    }
     407                }
     408
     409                $aWhere['colors'] = substr($aWhere['colors'], 0, -3);
     410                $aWhere['colors'] .= ")";
     411
     412                $aJoins[ 7 ] = "
     413                    LEFT OUTER JOIN
     414                        {$wpdb->prefix}easyadpicker_product_words AS {$wpdb->prefix}easyadpicker_product_words_7
     415                    ON
     416                        {$wpdb->prefix}easyadpicker_products.product_id = {$wpdb->prefix}easyadpicker_product_words_7.product_id
     417                ";
     418            }
     419
     420            elseif($column == "shops"){
     421               
     422                $values = "";
     423                foreach($aFilterValues AS $value){
     424                    $values .= "'".$value."',";
     425                }
     426
     427                $aWhere[] = "AND {$wpdb->prefix}easyadpicker_products.advertiser_id IN (".substr($values, 0, -1).")";
     428               
     429            }
     430
     431            elseif($column == "prices"){
     432               
     433                $values = "";
     434
     435                $aWhere['prices'] = "AND (";
     436                foreach($aFilterValues AS $value){
     437                   
     438                    $ePrice = explode('-', $value);
     439
     440                    if( count($ePrice) > 1){
     441                        if(count($aWhere) > 0){
     442                            $aWhere['prices'] .= " {$wpdb->prefix}easyadpicker_products.price BETWEEN ".$ePrice[0]." AND ".$ePrice[1]." OR ";
     443                        }else{
     444
     445                        }
     446                    }
     447                    else{
     448
     449                    }
     450                }
     451
     452                $aWhere['prices'] = substr($aWhere['prices'], 0, -3);
     453                $aWhere['prices'] .= ")";
     454               
     455            }
     456        }
     457
     458        //var_dump($aWhere['colors']);
     459
     460        return array('where' => $aWhere, 'joins' => $aJoins);
     461
     462    }
     463
    252464
    253465}
    254 
  • easy-ad-picker/trunk/frontend/class-ajax.php

    r1853164 r1866794  
    2323        echo esc_html($_GET['jsoncallback']) . '(' . $list . ')';   
    2424    }
     25
     26    public function EAP_get_filters(){
     27
     28        $cFilters = new EAP_Frontend_Filters;
     29        $html = $cFilters->EAP_get_products_filter($_GET['id']);
     30
     31        $list = json_encode($html);
     32        echo esc_html($_GET['jsoncallback']) . '(' . $list . ')';   
     33    }
    2534}
    2635
  • easy-ad-picker/trunk/frontend/class-shortcodes.php

    r1853164 r1866794  
    1313
    1414            $aAd = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}easyadpicker_post_ads WHERE post_ad_id = '".sanitize_key($atts['id'])."'");
    15             $html .= '<div class="EAP-advertisment-container" data-id="'.$aAd->post_ad_id.'" data-post="'.$post->ID.'"></div>';
     15            if (count($aAd)> 0){
     16                $html .= '<div class="EAP-advertisment-container" data-id="'.$aAd->post_ad_id.'" data-post="'.$post->ID.'"></div>';
     17            }
    1618        }
    1719
     
    5254
    5355        $cAds = new EAP_Frontend_Ads;
    54         $aAds = $cAds->EAP_get_advertisments($post->ID, array());
     56        $aAds = $cAds->EAP_get_advertisments($advertisment_id, array());
    5557       
    5658        $html = '';
     
    7072        global $post;
    7173
     74        $aUserFilters = json_decode(stripslashes($_GET['aFilters']));
     75       
    7276        $starttime = microtime(true);
    7377
    7478        $cAds = new EAP_Frontend_Ads;
    75         $aAd = $cAds->EAP_get_products($advertisment_id);
     79        $aAd = $cAds->EAP_get_products($advertisment_id, $aUserFilters);
    7680        $aFilters = $aAd['aFilters'];
    7781
    7882        $cSettings = new EAP_Frontend_Settings;
    7983        $aStyle = $cSettings->EAP_get_style();
    80 
    81         $html = '';
    82        
    8384
    8485        if(isset($aAd['post_ad_id'])){
     
    104105                }
    105106
    106                 /*$ch = curl_init('http://www.easyadpicker.com/images/products/'.$aSingleAd->advertiser_id.'/'.$aSingleAd->unique_id.'.jpg');
    107                 curl_setopt($ch, CURLOPT_NOBODY, true);
    108                 curl_exec($ch);
    109                 $retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    110                
    111                 if($retcode == 400){
    112                     $img = 'http://www.easyadpicker.com/images/products/'.$aSingleAd->advertiser_id.'/'.$aSingleAd->unique_id.'.jpg';
    113                 }else{
    114                     $img = $aSingleAd->material;
    115                 }
    116 
    117                 curl_close($ch); */
    118 
    119                 //$imageArray = @get_headers('http://www.easyadpicker.com/images/products/'.$aSingleAd->advertiser_id.'/'.$aSingleAd->unique_id.'.jpg');
    120 
    121                 $img = $aSingleAd->material;
     107                if($aSingleAd->new == 2){
     108                    $spotlight_text = '<div class="EAP-product-new" style="background:#'.$aStyle['newColor'].'">Goede deal</div>';
     109                }
     110
     111           
     112                $img = 'https://www.easyadpicker.com/images/products/'.$aSingleAd->advertiser_id.'/'.$aSingleAd->unique_id.'.jpg';
    122113
    123114                $html .= '
    124                     <div class="EAP-product">
    125                         <a target="_blank" href="'.$aSingleAd->link.'">
     115                    <div class="EAP-product" data-type="'.$aSingleAd->new.'">
     116                        <a target="_blank" href="'.self::set_subid_link($aSingleAd->link, $aFilters['subid']).'">
    126117                        <div class="EAP-product-imagecontainer">
    127118                            <img src="'.$img.'" />
     
    131122               
    132123                /* ADVERTISER */
    133                 if($aFilters['advertiser'] == "logoname"){
    134                     $html .= '<div class="EAP-product-store">'.$aSingleAd->advertiser.'</div>';
    135                 }
    136                 elseif($aFilters['advertiser'] == "logo"){
    137                     $html .= '<div class="EAP-product-store">'.$aSingleAd->advertiser.'</div>';
    138                 }
    139                 elseif($aFilters['advertiser'] == "name"){
    140                     $html .= '<div class="EAP-product-store">'.$aSingleAd->advertiser.'</div>';
     124                if(isset($aSingleAd->advertisers)){
     125                    if($aSingleAd->advertisers == 1){
     126                        if($aFilters['advertiser'] == "logoname"){
     127                            $html .= '<div class="EAP-product-store">'.$aSingleAd->advertiser.'</div>';
     128                        }
     129                        elseif($aFilters['advertiser'] == "logo"){
     130                            $html .= '<div class="EAP-product-store">'.$aSingleAd->advertiser.'</div>';
     131                        }
     132                        elseif($aFilters['advertiser'] == "name"){
     133                            $html .= '<div class="EAP-product-store">'.$aSingleAd->advertiser.'</div>';
     134                        }
     135                    }else{
     136                        $html .= '<div class="EAP-product-store">'.$aSingleAd->advertisers.' aanbieders</div>';
     137                    }
     138                }else{
     139                    if($aFilters['advertiser'] == "logoname"){
     140                        $html .= '<div class="EAP-product-store">'.$aSingleAd->advertiser.'</div>';
     141                    }
     142                    elseif($aFilters['advertiser'] == "logo"){
     143                        $html .= '<div class="EAP-product-store">'.$aSingleAd->advertiser.'</div>';
     144                    }
     145                    elseif($aFilters['advertiser'] == "name"){
     146                        $html .= '<div class="EAP-product-store">'.$aSingleAd->advertiser.'</div>';
     147                    }
    141148                }
    142149
     
    170177            }
    171178
    172             $html .= '</div>';
     179           
    173180
    174181        }
    175182
    176183        $html .= self::EAP_blz($aAd['blz'], $aAd['max_products'], $aAd['max_products_page']);
     184
     185        $html .= '</div>';
    177186
    178187        $stoptime  = microtime(true);
     
    219228            }
    220229
    221             if(@file_get_contents('http://www.easyadpicker.com/images/products/'.$aSingleAd->advertiser_id.'/'.$aSingleAd->unique_id.'.jpg', 0, NULL, 0, 1)){
    222                 $img = 'http://www.easyadpicker.com/images/products/'.$aSingleAd->advertiser_id.'/'.$aSingleAd->unique_id.'.jpg';
     230            if(@file_get_contents('https://www.easyadpicker.com/images/products/'.$aSingleAd->advertiser_id.'/'.$aSingleAd->unique_id.'.jpg', 0, NULL, 0, 1)){
     231                $img = 'https://www.easyadpicker.com/images/products/'.$aSingleAd->advertiser_id.'/'.$aSingleAd->unique_id.'.jpg';
    223232            }else{
    224233                $img = $aSingleAd->material;
     
    235244            /* ADVERTISER */
    236245                if($aFilters['advertiser'] == "logoname"){
    237                     $html .= '<div class="EAP-product-store"><img src="http://www.easyadpicker.com/images/advertisers/'.$aSingleAd->slug.'.png" alt="'.$aSingleAd->advertiser.'" /> '.$aSingleAd->advertiser.'</div>';
     246                    $html .= '<div class="EAP-product-store"><img src="https://www.easyadpicker.com/images/advertisers/'.$aSingleAd->slug.'.png" alt="'.$aSingleAd->advertiser.'" /> '.$aSingleAd->advertiser.'</div>';
    238247                }
    239248                elseif($aFilters['advertiser'] == "logo"){
    240                     $html .= '<div class="EAP-product-store"><img src="http://www.easyadpicker.com/images/advertisers/'.$aSingleAd->slug.'.png" alt="'.$aSingleAd->advertiser.'" style="width:80px;" /></div>';
     249                    $html .= '<div class="EAP-product-store"><img src="https://www.easyadpicker.com/images/advertisers/'.$aSingleAd->slug.'.png" alt="'.$aSingleAd->advertiser.'" style="width:80px;" /></div>';
    241250                }
    242251                elseif($aFilters['advertiser'] == "name"){
     
    305314                    $html .= '
    306315                        <div class="EAP-advertiser-cell">
    307                             <img src="http://www.easyadpicker.com/images/advertisers/'.$aAd->slug.'.png" alt="'.$aAd->advertiser.'" />
     316                            <img src="https://www.easyadpicker.com/images/advertisers/'.$aAd->slug.'.png" alt="'.$aAd->advertiser.'" />
    308317                            <span>'.$aAd->advertiser.'</span>
    309318                        </div>
     
    313322                    $html .= '
    314323                        <div class="EAP-advertiser-cell">
    315                             <img src="http://www.easyadpicker.com/images/advertisers/'.$aAd->slug.'.png" alt="'.$aAd->advertiser.'" />
     324                            <img src="https://www.easyadpicker.com/images/advertisers/'.$aAd->slug.'.png" alt="'.$aAd->advertiser.'" />
    316325                        </div>
    317326                    ';
     
    423432    }
    424433
     434    static function set_subid_link($url, $subID){
     435        if (strpos($url, 'awin1.com') !== false) {
     436            $url = $url.'&pref='.$subID;
     437        }
     438        elseif (strpos($url, '/tradetracker/') !== false) {
     439            $url = str_replace('&r=', $subID.'&r=', $url);
     440        }
     441        elseif (strpos($url, 'tradetracker.net') !== false) {
     442            $url = str_replace('&r=', $subID.'&r=', $url);
     443        }
     444        elseif (strpos($url, '?tt=') !== false) {
     445            $url = str_replace('&r=', $subID.'&r=', $url);
     446        }
     447        elseif (strpos($url, 'ds1.nl') !== false) {
     448            $url = str_replace('&ws=', '&ws='.$subID, $url);
     449        }
     450       
     451        return $url;
     452    }
     453
     454   
     455
    425456}
  • easy-ad-picker/trunk/js/admin.js

    r1851690 r1866794  
    33jQuery(document).ready(function(){
    44
    5 
    6     /* ADVERTENTIE POST WIJZIGEN */
    7     jQuery(".EAP-metabox-advertising, .EAP-metabox-add").click(function(){
    8         EAP_saveAd(jQuery(this), 'new');
    9     });
    10 
    11     EAP_searchWordFunction();
     5    EAP_metaboxFunctions();
    126
    137    EAP_collageFunctions();
     
    2620
    2721});
     22
     23function EAP_metaboxFunctions(){
     24    /* NIEUWE ADVERTENTIE */
     25    jQuery(".EAP-metabox-add").unbind("click").click(function(){
     26        jQuery(".EAP-lightbox-container").css({'display': 'table'});
     27        jQuery(".EAP-lightbox-box-content").html("Laden..");
     28
     29        jQuery(".EAP-lightbox-bg").click(function(){
     30            jQuery(this).parent().hide();
     31        });
     32
     33        var ad = jQuery(this);
     34        var post_ad_id = jQuery(this).attr("data-id");
     35        var post_id = jQuery(this).attr("data-id");
     36        aSuggestions = [];
     37
     38        var change = '';
     39        if(action == 'change'){
     40            var change = '&change=1';
     41        }
     42
     43        jQuery.ajax({
     44            url: easyadpicker_ajax.ajaxurl+"?action=admin&method=EAP_getAdFormType&post_ad_id="+post_ad_id+"&post="+jQuery("#EAP-metabox-ads").attr("data-id")+change+"&jsoncallback=?",
     45            dataType: "jsonp",
     46            cache: false,
     47            success: function(html)
     48            {
     49                jQuery(".EAP-lightbox-box-content").html(html);
     50
     51                /* CLICK ADVERTISING TYPE */
     52                jQuery(".EAP-lighbox-advertising-ad").unbind("click").click(function(){
     53                    jQuery(this).parent().find(".EAP-lighbox-advertising-ad-active").removeClass("EAP-lighbox-advertising-ad-active");
     54                    jQuery(this).addClass("EAP-lighbox-advertising-ad-active");
     55
     56                    jQuery("#EAP-lightbox-advertising-ad-value").val( jQuery(this).attr("data-value") );
     57                });
     58
     59                jQuery(".EAP-lightbox-advertising-ad-add").unbind("click").click(function(){
     60                    if(jQuery("#EAP-lightbox-advertising-ad-value").val() != ""){
     61                        EAP_saveAd(ad, 'new', jQuery("#EAP-lightbox-advertising-ad-value").val());
     62                    }else{
     63                        jQuery(this).parent().find(".EAP-lightbox-advertising-title").addClass("EAP-error");
     64                    }
     65                });
     66            }
     67        });
     68    });
     69
     70    /* ADVERTENTIE POST WIJZIGEN */
     71    jQuery(".EAP-metabox-advertising").unbind("click").click(function(){
     72        EAP_saveAd(jQuery(this), 'new', jQuery(this).attr("data-type"));
     73    });
     74}
    2875
    2976function EAP_networkFunctions(){
     
    138185                    });
    139186                });
     187
     188                jQuery(".EAP-advertiser-delete").click(function(){
     189
     190                    var EAP_confirm = confirm("Weet je zeker dat je de producten wilt verwijderen?");
     191
     192                    if(EAP_confirm){
     193                        jQuery.ajax({
     194                            url: easyadpicker_ajax.ajaxurl+"?action=admin&method=EAP_deleteProductsAdvertiser&advertiser="+advertiser+"&jsoncallback=?",
     195                            dataType: "jsonp",
     196                            cache: false,
     197                            success: function(html)
     198                            {
     199                               
     200                            }
     201
     202                        });
     203                    }
     204                });
    140205            }
    141206
     
    144209
    145210    jQuery("#EAP-advertiser-import-all-start").click(function(){
    146         EAP_realtimeProductImportAdvertiserRow(1)
     211
     212        if( jQuery(this).hasClass('EAP-advertiser-import-all-start-active') ){
     213            alert("Vernieuw je pagina om opnieuw producten te importeren");
     214        }else{
     215            EAP_realtimeProductImportAdvertiserRow(1);
     216            jQuery(this).addClass('EAP-advertiser-import-all-start-active');
     217        }
    147218    });
    148219
     
    243314}
    244315
    245 function EAP_saveAd(ad, action){
     316function EAP_saveAd(ad, action, type){
    246317   
    247318
     
    249320    jQuery(".EAP-lightbox-box-content").html("Laden..");
    250321
    251     jQuery(".EAP-lightbox-bg").click(function(){
     322    jQuery(".EAP-lightbox-bg").unbind("click").click(function(){
    252323        jQuery(this).parent().hide();
    253324    });
     
    263334
    264335    jQuery.ajax({
    265         url: easyadpicker_ajax.ajaxurl+"?action=admin&method=EAP_getAdForm&post_ad_id="+post_ad_id+"&post="+jQuery("#EAP-metabox-ads").attr("data-id")+change+"&jsoncallback=?",
     336        url: easyadpicker_ajax.ajaxurl+"?action=admin&method=EAP_getAdForm&type="+type+"&post_ad_id="+post_ad_id+"&post="+jQuery("#EAP-metabox-ads").attr("data-id")+change+"&jsoncallback=?",
    266337        dataType: "jsonp",
    267338        cache: false,
     
    270341            var fields = [];
    271342            fields['first'] = {title: 'EAP-metabox-advertising-lightbox-title', category: 'EAP-metabox-advertising-lightbox-category'};
    272             fields['second'] = {advertisment: 'EAP-lightbox-advertising-ad-value'};
    273             fields['third'] = {keywords: 'EAP-searchwords-value'};
    274             fields['fourth'] = {amount: 'EAP-metabox-advertising-lightbox-amount', price: 'EAP-metabox-advertising-lightbox-price', advertiser: 'EAP-metabox-advertising-lightbox-advertiser'};
     343            fields['second'] = {keywords: 'EAP-searchwords-value'};
     344
     345            if(type == "banners"){
     346                fields['third'] = {amount: 'EAP-metabox-advertising-lightbox-amount'};
     347            }else{
     348                fields['third'] = {unique: 'EAP-metabox-advertising-lightbox-unique', amount: 'EAP-metabox-advertising-lightbox-amount', price: 'EAP-metabox-advertising-lightbox-price', advertiser: 'EAP-metabox-advertising-lightbox-advertiser'};
     349            }
    275350           
    276351            jQuery(".EAP-lightbox-box-content").html(html);
    277352
     353            jQuery("#EAP-searchword-add-box").unbind("click").click(function(){
     354                jQuery("#EAP-searchwords").append('<div class="EAP-searchwords-table-container"><ul class="EAP-searchwords-table connectedSortable ui-sortable"></ul><div class="EAP-searchword-add-filter">Filter toevoegen</div></div>');
     355                EAP_searchWordFunction();
     356            });
     357
     358            EAP_activeSearchWord();
     359
     360            EAP_searchWordFunction();
     361
     362            /* AD OR BOX */
     363            jQuery("#EAP-metabox-advertising-lightbox-category").change(function(){
     364                jQuery(".EAP-searchwords-table").each(function(){
     365                    jQuery(this).find("li").each( function(){
     366                        if( jQuery(this).attr("data-category") != jQuery("#EAP-metabox-advertising-lightbox-category").val() ){
     367                            jQuery(this).remove();
     368                        }
     369                    });
     370                });
     371            });
     372
     373            /* TEST RESULTS */
     374            jQuery("#EAP-searchword-submit").unbind( "click" ).click(function(){
     375
     376                jQuery("#EAP-searchword-submit-text").show();
     377                jQuery("#EAP-searchword-submit-text").html("Resultaten laden");
     378
     379                aSuggestions = [];
     380                var EAP_counter = 0;
     381                jQuery(".EAP-searchwords-table").each(function(){
     382
     383                    jQuery(this).find("li").each( function(){
     384                        jQuery(this).find(".EAP-searchwords-column").removeClass("EAP-error");
     385                        jQuery(this).find(".EAP-searchwords-type").removeClass("EAP-error");
     386
     387                        if(jQuery(this).find(".EAP-searchwords-word").val() != ""){
     388                            if(jQuery(this).find(".EAP-searchwords-type").val() == ""){
     389                                jQuery(this).find(".EAP-searchwords-type").addClass("EAP-error");
     390                                error = 1;
     391                            }
     392                            if(jQuery(this).find(".EAP-searchwords-column").val() == ""){
     393                                jQuery(this).find(".EAP-searchwords-column").addClass("EAP-error");
     394                                error = 1;
     395                            }
     396                        }
     397                        if( jQuery(this).find(".EAP-searchwords-type").val() != "" && jQuery(this).find(".EAP-searchwords-column").val() != "" && jQuery(this).find(".EAP-searchwords-word").val() != "" && jQuery(this).find(".EAP-searchwords-type").val() != undefined && jQuery(this).find(".EAP-searchwords-column").val() != undefined && jQuery(this).find(".EAP-searchwords-word").val() != undefined){
     398                            aSuggestions.push({
     399                                'box' : EAP_counter,
     400                                'column': jQuery(this).find(".EAP-searchwords-column").val(),
     401                                'type': jQuery(this).find(".EAP-searchwords-type").val(),
     402                                'word': jQuery(this).find(".EAP-searchwords-word").val()
     403                            });
     404                        }
     405                    });
     406
     407                    console.log(aSuggestions);
     408
     409                    EAP_counter ++;
     410                   
     411                });
     412
     413                jQuery.ajax({
     414                    url: easyadpicker_ajax.ajaxurl+"?action=admin&method=EAP_testSearchWords&category="+jQuery('#EAP-metabox-advertising-lightbox-category').val()+"&words="+encodeURIComponent( JSON.stringify(aSuggestions) )+"&exist=&jsoncallback=?",
     415                    dataType: "jsonp",
     416                    cache: false,
     417                    success: function(html)
     418                    {
     419                        jQuery("#EAP-searchword-submit-text").html(html);   
     420                    }
     421
     422                });
     423
     424                console.log(aSuggestions);
     425            });
     426
     427
    278428            /* NEXT STEP */
    279             jQuery(".EAP-lightbox-advertising-next-step").click(function(){
     429            jQuery(".EAP-lightbox-advertising-next-step").unbind("click").click(function(){
    280430
    281431                var error = 0;
     
    290440                });
    291441
     442                if(type != "banners"){
     443
     444                    /* SEARCHWORDS */
     445               
     446                    if(jQuery(this).attr("data-part") == "check_searchwords"){
     447                        aSuggestions = [];
     448                        var EAP_counter = 0;
     449                       
     450                        jQuery(".EAP-searchwords-table").each(function(){
     451                            jQuery(this).find("li").each( function(){
     452                                jQuery(this).find(".EAP-searchwords-column").removeClass("EAP-word");
     453                                jQuery(this).find(".EAP-searchwords-column").removeClass("EAP-error");
     454                                jQuery(this).find(".EAP-searchwords-type").removeClass("EAP-error");
     455
     456                                if(jQuery(this).find(".EAP-searchwords-word").val() != ""){
     457                                    if(jQuery(this).find(".EAP-searchwords-type").val() == ""){
     458                                        jQuery(this).find(".EAP-searchwords-type").addClass("EAP-error");
     459                                        error = 1;
     460                                    }
     461                                    if(jQuery(this).find(".EAP-searchwords-column").val() == ""){
     462                                        jQuery(this).find(".EAP-searchwords-column").addClass("EAP-error");
     463                                        error = 1;
     464                                    }
     465                                }
     466                                if( jQuery(this).find(".EAP-searchwords-type").val() != "" && jQuery(this).find(".EAP-searchwords-column").val() != "" && jQuery(this).find(".EAP-searchwords-word").val() != "" && jQuery(this).find(".EAP-searchwords-type").val() != undefined && jQuery(this).find(".EAP-searchwords-column").val() != undefined && jQuery(this).find(".EAP-searchwords-word").val() != undefined){
     467                                    aSuggestions.push({
     468                                        'box' : EAP_counter,
     469                                        'column': jQuery(this).find(".EAP-searchwords-column").val(),
     470                                        'type': jQuery(this).find(".EAP-searchwords-type").val(),
     471                                        'word': jQuery(this).find(".EAP-searchwords-word").val()
     472                                    });
     473                                }
     474                            });
     475                            EAP_counter++;
     476                        });
     477
     478                        if(jQuery(".EAP-searchwords-table").find('tr:first').find(".EAP-searchwords-word").val() == ""){
     479                            jQuery(".EAP-searchwords-table").find('tr:first').find(".EAP-searchwords-word").addClass("EAP-error");
     480                            error = 1;
     481                        }
     482
     483                        if(jQuery(".EAP-searchwords-table").find('tr:first').find(".EAP-searchwords-column").val() == ""){
     484                            jQuery(".EAP-searchwords-table").find('tr:first').find(".EAP-searchwords-column").addClass("EAP-error");
     485                            error = 1;
     486                        }
     487
     488                        if(jQuery(".EAP-searchwords-table").find('tr:first').find(".EAP-searchwords-type").val() == ""){
     489                            jQuery(".EAP-searchwords-table").find('tr:first').find(".EAP-searchwords-type").addClass("EAP-error");
     490                            error = 1;
     491                        }
     492
     493
     494
     495                        console.log(aSuggestions);
     496                    }
     497                }
     498
    292499                if(error == 0){
     500
    293501                    jQuery(this).parent().hide();
    294 
    295                     if( (jQuery("#EAP-lightbox-advertising-ad-value").val() == "banners" && jQuery(this).attr("data-next") == "fourth") || jQuery(this).attr("data-next") == 'save'){
    296 
     502                    console.log(jQuery(this).attr("data-next"));
     503                    if(jQuery(this).attr("data-next") == 'save'){
    297504                        var best_deals = 0;
    298505                        jQuery.ajax({
    299                             url: easyadpicker_ajax.ajaxurl+"?action=admin&method=EAP_saveAd&post_ad_id="+post_ad_id+"&ad="+jQuery('#EAP-lightbox-advertising-ad-value').val()+"&category="+jQuery('#EAP-metabox-advertising-lightbox-category').val()+"&title="+jQuery('#EAP-metabox-advertising-lightbox-title').val()+"&amount="+jQuery('#EAP-metabox-advertising-lightbox-amount').val()+"&price="+jQuery('#EAP-metabox-advertising-lightbox-price').val()+"&advertiser="+jQuery('#EAP-metabox-advertising-lightbox-advertiser').val()+"&words="+encodeURIComponent(jQuery('#EAP-searchwords-value').val())+"&post="+jQuery('#EAP-metabox-ads').attr("data-id")+"&jsoncallback=?",
     506                            url: easyadpicker_ajax.ajaxurl+"?action=admin&method=EAP_saveAd&post_ad_id="+post_ad_id+"&ad="+type+"&category="+jQuery('#EAP-metabox-advertising-lightbox-category').val()+"&title="+jQuery('#EAP-metabox-advertising-lightbox-title').val()+"&amount="+jQuery('#EAP-metabox-advertising-lightbox-amount').val()+"&price="+jQuery('#EAP-metabox-advertising-lightbox-price').val()+"&unique="+jQuery('#EAP-metabox-advertising-lightbox-unique').val()+"&subid="+jQuery('#EAP-metabox-advertising-lightbox-subid').val()+"&advertiser="+jQuery('#EAP-metabox-advertising-lightbox-advertiser').val()+"&words="+encodeURIComponent( JSON.stringify(aSuggestions) )+"&post="+jQuery('#EAP-metabox-ads').attr("data-id")+"&jsoncallback=?",
    300507                            dataType: "jsonp",
    301508                            cache: false,
     
    305512                                jQuery(".EAP-lightbox-box-content").html(html);
    306513
    307                                 jQuery(".EAP-lightbox-advertising-place").click(function(){
     514                                jQuery(".EAP-lightbox-advertising-place").unbind("click").click(function(){
    308515                                    EAP_copyToClipboard('#EAP-copy-shortcode');
    309516                                    jQuery(".EAP-lightbox-container").css({'display': 'none'});
    310517                                    if(post_ad_id == ""){
    311                                         location.reload();
     518                                        jQuery.ajax({
     519                                            url: easyadpicker_ajax.ajaxurl+"?action=admin&method=EAP_loadAdsMetabox&post="+jQuery('#EAP-metabox-ads').attr("data-id")+"&jsoncallback=?",
     520                                            dataType: "jsonp",
     521                                            cache: false,
     522                                            success: function(html)
     523                                            {
     524                                                jQuery("#EAP-metabox-ads").html(html);
     525                                                EAP_metaboxFunctions();
     526                                            }
     527                                        });
    312528                                    }
    313529                                });
     
    318534
    319535                    }
    320 
    321536                }
     537               
    322538            });
    323539
    324540            /* PREV STEP */
    325             jQuery(".EAP-lightbox-advertising-prev-step").click(function(){
     541            jQuery(".EAP-lightbox-advertising-prev-step").unbind("click").click(function(){
    326542                jQuery(this).parent().hide();
    327543                jQuery("#EAP-lightbox-advertising-step-"+jQuery(this).attr("data-prev")).show();
    328544            });
    329545
    330             /* CLICK ADVERTISING TYPE */
    331             jQuery(".EAP-lighbox-advertising-ad").click(function(){
    332                 jQuery(this).parent().find(".EAP-lighbox-advertising-ad-active").removeClass("EAP-lighbox-advertising-ad-active");
    333                 jQuery(this).addClass("EAP-lighbox-advertising-ad-active");
    334 
    335                 jQuery("#EAP-lightbox-advertising-ad-value").val( jQuery(this).attr("data-value") );
    336             });
    337 
     546           
     547
     548            /* EDIT AD */
     549            jQuery(".EAP-lightbox-advertising-change").unbind("click").click(function(){
     550                EAP_saveAd(ad, 'change', type);
     551            });
     552
     553            /* DELETE AD */
     554            jQuery(".EAP-lightbox-advertising-delete").unbind("click").click(function(){
     555                var EAP_confirm = confirm("Weet je zeker dat je de advertentie wilt verwijderen?");
     556
     557                if(EAP_confirm){
     558                    jQuery.ajax({
     559                        url: easyadpicker_ajax.ajaxurl+"?action=admin&method=EAP_deleteAd&post_ad_id="+post_ad_id+"&post="+jQuery('#EAP-metabox-ads').attr("data-id")+"&jsoncallback=?",
     560                        dataType: "jsonp",
     561                        cache: false,
     562                        success: function(html)
     563                        {
     564                            jQuery(".EAP-lightbox-container").css({'display': 'none'});
     565                            jQuery(ad).remove();
     566                        }
     567
     568                    });
     569                }
     570               
     571            });
     572
     573            /* BANNER TYPE ACTIONS */
     574            if(type == "banners"){
     575                aSuggestions = [];
     576                jQuery( "#EAP-words" ).find('li').each( function(){
     577                    aSuggestions.push({
     578                        'column': 0,
     579                        'word': jQuery(this).attr("data-word")
     580                    });
     581                });
     582
     583                /* BANNER SEARCHWORDS */
     584                jQuery("#EAP-add-searchword").unbind("click").click(function(){
     585                    if(jQuery.inArray(jQuery("#EAP-own-searchword").val(), aSuggestions) == -1) {
     586
     587                        jQuery("#EAP-words").append('<li><span class="EAP-metabox-searchwords-suggestions-result-category">Search</span> : <span class="EAP-metabox-searchwords-suggestions-result-word">'+jQuery("#EAP-own-searchword").val()+'</span><span class="EAP-metabox-searchwords-suggestions-result-value">Search|'+jQuery("#EAP-own-searchword").val()+'</span></li>');
     588                        EAP_activeSearchWord();
     589
     590                        aSuggestions.push({
     591                            'column': 0,
     592                            'word': jQuery("#EAP-own-searchword").val()
     593                        });
     594
     595                        //jQuery("#EAP-searchwords-value").val( JSON.stringify(aSuggestions) );
     596                    }
     597                });
     598
     599            }
     600
     601        }
     602    });
     603
     604}
     605
     606function EAP_get_searchword_filter(div){
     607
     608    jQuery(div).find("li").each( function(){
     609        if( jQuery(this).attr("data-category") != jQuery("#EAP-metabox-advertising-lightbox-category").val() ){
     610            jQuery(this).remove();
     611        }
     612    });
     613
     614    jQuery("#EAP-lightbox-advertising-step-second").find(".EAP-lightbox-advertising-next-step").hide();
     615    jQuery.ajax({
     616        url: easyadpicker_ajax.ajaxurl+"?action=admin&method=EAP_getFiltersSearchword&category="+jQuery("#EAP-metabox-advertising-lightbox-category").val()+"&jsoncallback=?",
     617        dataType: "jsonp",
     618        cache: false,
     619        success: function(html)
     620        {
     621            jQuery(div).find(".EAP-searchwords-table").append(html);
     622            jQuery("#EAP-lightbox-advertising-step-second").find(".EAP-lightbox-advertising-next-step").show();
    338623            /* SEARCHWORDS FUNCTIONS */
    339624            EAP_searchWordFunction();
    340625
    341 
    342             /* EDIT AD */
    343             jQuery(".EAP-lightbox-advertising-change").click(function(){
    344                 EAP_saveAd(ad, 'change');
    345             });
    346 
    347             jQuery("#EAP-delete-ad").click(function(){
    348                 jQuery.ajax({
    349                     url: easyadpicker_ajax.ajaxurl+"?action=admin&method=EAP_deleteAd&post_ad_id="+post_ad_id+"&post="+jQuery('#EAP-metabox-ads').attr("data-id")+"&jsoncallback=?",
    350                     dataType: "jsonp",
    351                     cache: false,
    352                     success: function(html)
    353                     {
    354                         tb_remove();
    355                         jQuery(ad).remove();
    356                     }
    357 
    358                 });
    359             });
    360         }
    361     });
    362 
    363 }
    364 
    365 
     626        }
     627
     628    });
     629}
    366630
    367631function EAP_searchWordFunction(){
    368632
    369     if(jQuery("#EAP-searchwords-value").length > 0){
    370         aSuggestions = [];
    371         jQuery( "#EAP-words" ).find('li').each( function(){
    372             aSuggestions.push({
    373                 'column': jQuery(this).attr("data-column"),
    374                 'word': jQuery(this).attr("data-word")
    375             });
    376         });
    377 
    378         jQuery("#EAP-searchwords-value").val( JSON.stringify(aSuggestions) );
    379     }
    380    
    381     jQuery("#EAP-add-searchword").click(function(){
     633
     634    jQuery(".EAP-searchwords-table").sortable({
     635        connectWith: ".connectedSortable"
     636    }).disableSelection();
     637
     638    jQuery(".EAP-searchword-add-filter").unbind( "click" ).click(function(){
     639        EAP_get_searchword_filter(jQuery(this).parent());
     640    });
     641
     642    jQuery(".EAP-searchwords-delete").unbind( "click" ).click(function(){
     643        jQuery(this).parent().parent().remove();
     644    });
     645
     646
     647    jQuery("#EAP-add-searchword").unbind( "click" ).click(function(){
    382648        if(jQuery.inArray(jQuery("#EAP-own-searchword").val(), aSuggestions) == -1) {
    383649
     
    393659        }
    394660    });
    395    
    396 
    397     /* SEARCHBOX KEYWORDS */
    398     jQuery('#EAP-own-searchword').keyup(function(event){
    399         if(jQuery('#EAP-own-searchword').val().length > 1){
     661
     662    /* GET SUGGESTIONS BY FILTER */
     663    jQuery('.EAP-searchwords-word').keyup(function(event){
     664        var textfield = jQuery(this);
     665        if(jQuery(textfield).val().length > 1){
    400666            delay(function(){
    401667
    402                 jQuery.ajax({
    403                     url: easyadpicker_ajax.ajaxurl+"?action=admin&method=EAP_getSearchWords&search="+jQuery('#EAP-own-searchword').val()+"&category="+jQuery('#EAP-metabox-advertising-lightbox-category').val()+"&exist="+encodeURIComponent(jQuery("#EAP-searchwords-value").val())+"&jsoncallback=?",
    404                     dataType: "jsonp",
    405                     cache: false,
    406                     success: function(html)
    407                     {
    408                         jQuery("#EAP-metabox-searchwords-suggestions-words").show();
    409                         jQuery("#EAP-metabox-searchwords-suggestions-words").html(html);
    410                         jQuery("#EAP-metabox-searchwords-suggestions-words-back").show();
    411 
    412                         jQuery("#EAP-metabox-searchwords-suggestions-words").find("li").click(function(){
    413 
    414                             jQuery(this).remove();
    415 
    416                             jQuery("#EAP-words").append('<li><span class="EAP-metabox-searchwords-suggestions-result-category">'+jQuery(this).find(".EAP-metabox-searchwords-suggestions-result-category").html()+'</span> : <span class="EAP-metabox-searchwords-suggestions-result-word">'+jQuery(this).find(".EAP-metabox-searchwords-suggestions-result-word").html()+'</span></li>');
    417                            
    418                             EAP_activeSearchWord();
    419 
    420                             aSuggestions.push({
    421                                 'column': jQuery(this).attr("data-column"),
    422                                 'word': jQuery(this).attr("data-word")
     668                if((jQuery(textfield).parent().parent().find(".EAP-searchwords-column").val() != "" && jQuery(textfield).parent().parent().find(".EAP-searchwords-type").val() != "")){
     669
     670                    jQuery.ajax({
     671                        url: easyadpicker_ajax.ajaxurl+"?action=admin&method=EAP_getSearchWords&search="+jQuery(textfield).val()+"&column="+jQuery(textfield).parent().parent().find(".EAP-searchwords-column").val()+"&category="+jQuery('#EAP-metabox-advertising-lightbox-category').val()+"&exist=&jsoncallback=?",
     672                        dataType: "jsonp",
     673                        cache: false,
     674                        success: function(html)
     675                        {
     676                            jQuery(textfield).parent().find(".EAP-metabox-searchwords-suggestions-words").show();
     677                            jQuery(textfield).parent().find(".EAP-metabox-searchwords-suggestions-words").html(html);
     678                            jQuery("#EAP-metabox-searchwords-suggestions-words-back").show();
     679
     680                            jQuery(textfield).parent().find(".EAP-metabox-searchwords-suggestions-words").find("li").click(function(){
     681                                jQuery(textfield).val( jQuery(this).find(".EAP-metabox-searchwords-suggestions-result-word").html() );
     682                                jQuery(".EAP-metabox-searchwords-suggestions-words").hide();
     683                                jQuery("#EAP-metabox-searchwords-suggestions-words-back").hide();
    423684                            });
    424685
    425                             jQuery("#EAP-searchwords-value").val( JSON.stringify(aSuggestions) );
    426 
    427                             //jQuery("#EAP-metabox-searchwords-suggestions-words").hide();
    428                         });
    429 
    430                         jQuery("#EAP-metabox-searchwords-suggestions-words-back").click(function(){
    431                             jQuery("#EAP-metabox-searchwords-suggestions-words").hide();
    432                             jQuery("#EAP-metabox-searchwords-suggestions-words-back").hide();
    433                         });
    434                     }
    435                 });
     686                            jQuery("#EAP-metabox-searchwords-suggestions-words-back").click(function(){
     687                                jQuery(".EAP-metabox-searchwords-suggestions-words").hide();
     688                                jQuery("#EAP-metabox-searchwords-suggestions-words-back").hide();
     689                            });
     690                        }
     691                    });
     692                }
    436693   
    437694            }, 1000 );
     
    439696        }
    440697    });
    441 
    442     EAP_activeSearchWord();
    443698}
    444699
     
    470725        EAP_getResultsCollage(1);
    471726
    472         jQuery.ajax({
    473             url: easyadpicker_ajax.ajaxurl+"?action=admin&method=EAP_getFiltersAdvertiser&advertiser="+jQuery("#EAP-collages-filter-advertiser").val()+"&jsoncallback=?",
    474             dataType: "jsonp",
    475             cache: false,
    476             success: function(html)
    477             {
    478                 jQuery("#EAP-collages-filters-advertiser").html(html);
    479 
    480                 jQuery(".EAP-collages-filter").change(function(){
    481                     EAP_getResultsCollage(1);
    482                 });
    483             }
    484 
    485         });
    486 
     727        if(jQuery(".EAP-advertisment-container").length == 1){
     728            jQuery.ajax({
     729                url: easyadpicker_ajax.ajaxurl+"?action=admin&method=EAP_getFiltersAdvertiser&advertiser="+jQuery("#EAP-collages-filter-advertiser").val()+"&jsoncallback=?",
     730                dataType: "jsonp",
     731                cache: false,
     732                success: function(html)
     733                {
     734                    jQuery("#EAP-collages-filters-advertiser").html(html);
     735
     736                    jQuery(".EAP-collages-filter").change(function(){
     737                        EAP_getResultsCollage(1);
     738                    });
     739                }
     740
     741            });
     742        }
    487743    });
    488744
  • easy-ad-picker/trunk/js/front.js

    r1853164 r1866794  
     1var aFilters = [];
     2
    13jQuery(document).ready(function(){
    24
     
    57        var div = jQuery(this);
    68
     9        if(jQuery(div).width() > 899){
     10            jQuery(div).addClass("EAP-advertisment-container-900");
     11        }
     12        else if(jQuery(div).width() > 599 && jQuery(div).width() < 900){
     13            jQuery(div).addClass("EAP-advertisment-container-600");
     14        }
     15        else if(jQuery(div).width() > 299 && jQuery(div).width() < 600){
     16            jQuery(div).addClass("EAP-advertisment-container-300");
     17        }
     18        else if(jQuery(div).width() < 300){
     19            jQuery(div).addClass("EAP-advertisment-container-0");
     20        }
     21
     22        get_filter_values();
    723        EAP_get_results(div,1);
    824    });
     
    1127
    1228function EAP_get_results(div, blz){
    13     jQuery(div).html("content wordt geladen");
    1429    jQuery.ajax({
    15         url: easyadpicker_ajax.ajaxurl+"?action=frontend&method=EAP_get_advertisment&id="+jQuery(div).attr("data-id")+"&cp="+blz+"&jsoncallback=?",
     30        url: easyadpicker_ajax.ajaxurl+"?action=frontend&method=EAP_get_advertisment&id="+jQuery(div).attr("data-id")+"&aFilters="+encodeURIComponent( JSON.stringify(aFilters) )+"&cp="+blz+"&jsoncallback=?",
    1631        dataType: "jsonp",
    1732        cache: false,
    1833        success: function(html)
    1934        {
     35            jQuery(".EAP-products-filter-container").each(function(){
     36                var filter = jQuery(this);
     37                jQuery.ajax({
     38                    url: easyadpicker_ajax.ajaxurl+"?action=frontend&method=EAP_get_filters&id="+jQuery(div).attr("data-id")+"&type="+jQuery(filter).attr("data-type")+"&aFilters="+encodeURIComponent( JSON.stringify(aFilters) )+"&jsoncallback=?",
     39                    dataType: "jsonp",
     40                    cache: false,
     41                    success: function(html)
     42                    {
     43                        jQuery(filter).find(".EAP-products-filter").html(html);
     44
     45                        EAP_filter_actions(div, filter);
     46                    }
     47                });
     48            });
     49
    2050            jQuery(div).attr("load", html['loadtime']);
    21             jQuery(div).html(html['html']);
     51
     52            if(jQuery(div).find(".EAP-product-container").length > 0){
     53                jQuery(div).find(".EAP-product-container").html(html['html']);
     54            }else{
     55                jQuery(div).html(html['html']);
     56            }
     57           
    2258
    2359            jQuery(div).find(".EAP-products-blz-container").find("li").click(function(){
     
    4076}
    4177
     78function EAP_filter_actions(div, filter){
     79    jQuery(filter).find("li").unbind("click").click(function(){
     80        if(jQuery(this).find("input[type=checkbox]").is(':checked')){
     81            jQuery(this).find("input[type=checkbox]").prop('checked', false);
     82        }else{
     83            jQuery(this).find("input[type=checkbox]").prop('checked', true);
     84        }
     85
     86        get_filter_values();
     87
     88        EAP_get_results(div, 1)
     89    });
     90}
     91
     92function get_filter_values(){
     93    aFilters = [];
     94    jQuery(".EAP-products-filter-container").each(function(){
     95        var container = jQuery(this);
     96        jQuery(this).find("li").each(function(){
     97            if(jQuery(this).find("input[type=checkbox]").is(':checked')){
     98                aFilters.push({
     99                    'type' : jQuery(container).attr("data-type"),
     100                    'value' : jQuery(this).attr("data-value")
     101                });
     102            }
     103        });
     104    });
     105}
     106
    42107   
Note: See TracChangeset for help on using the changeset viewer.