예제 #1
0
 protected function do_search()
 {
     global $wpdb;
     if (isset($wpdb->base_prefix)) {
         $_prefix = $wpdb->base_prefix;
     } else {
         $_prefix = $wpdb->prefix;
     }
     $options = $this->options;
     $searchData = $this->searchData;
     $s = $this->s;
     $_s = $this->_s;
     $allcommentsresults = array();
     if ($options['set_incomments']) {
         $like = "";
         if ($not_exactonly) {
             $sr = implode("%' OR lower({$wpdb->comments}.comment_content) like '%", $_s);
             if ($like != "") {
                 $sr = " OR lower({$wpdb->comments}.comment_content) like '%" . $sr . "%'";
             } else {
                 $sr = " lower({$wpdb->comments}.comment_content) like '%" . $sr . "%'";
             }
         } else {
             if ($like != "") {
                 $sr = " OR lower({$wpdb->comments}.comment_content) like '%" . $s . "%'";
             } else {
                 $sr = " lower({$wpdb->comments}.comment_content) like '%" . $s . "%'";
             }
         }
         $like .= $sr;
         $querystr = "\n      \t\tSELECT \n            {$wpdb->comments}.comment_ID as id,\n            {$wpdb->comments}.comment_post_ID as post_id,\n            {$wpdb->comments}.user_id as user_id,\n            {$wpdb->comments}.comment_content as content,\n            {$wpdb->comments}.comment_date as date\n      \t\tFROM {$wpdb->comments}\n      \t\tWHERE\n          ({$wpdb->comments}.comment_approved=1)\n          AND\n          (" . $like . ")\n      \t\tORDER BY {$wpdb->comments}.comment_ID DESC\n      \t\tLIMIT " . $searchData['maxresults'];
         $commentsresults = $wpdb->get_results($querystr, OBJECT);
         if (is_array($commentsresults)) {
             foreach ($commentsresults as $k => $v) {
                 $commentsresults[$k]->link = get_comment_link($v->id);
                 $commentsresults[$k]->author = get_comment_author($v->id);
                 if ($searchData['settings-imagesettings']['show'] == 1) {
                     $imgs = $searchData['settings-imagesettings'];
                     ksort($imgs['from']);
                     foreach ($imgs['from'] as $kk => $source) {
                         $img = new wpdreamsImageCache($v->content, "comment" . $v->id, AJAXSEARCHPRO_PATH . DIRECTORY_SEPARATOR . "cache" . DIRECTORY_SEPARATOR, $imgs['width'], $imgs['height'], $imgs['imagenum'], $searchData['imagebg']);
                         $res = $img->get_image();
                         if ($res != '') {
                             $commentsresults[$k]->image = plugins_url('/ajax-search-pro/cache/' . $res);
                             break;
                         }
                     }
                 }
                 $commentsresults[$k]->title = substr($commentsresults[$k]->content, 0, 15) . "...";
             }
         }
         $allcommentsresults = array_merge($allcommentsresults, $commentsresults);
     }
     $this->results = $allcommentsresults;
     return $allcommentsresults;
 }
예제 #2
0
 /**
  * Fetches an image with the imageCache class
  */
 protected function getCachedImage($post)
 {
     if ($post->image == null) {
         $i = 1;
         $im = "";
         for ($i == 1; $i < 6; $i++) {
             switch ($this->imageSettings['image_source' . $i]) {
                 case "featured":
                     $__im = wp_get_attachment_url(get_post_thumbnail_id($post->id));
                     if ($__im != "") {
                         $img = new wpdreamsImageCache($__im, "post" . $post->id, ASP_PATH . DIRECTORY_SEPARATOR . "cache" . DIRECTORY_SEPARATOR, $this->imageSettings['image_width'], $this->imageSettings['image_height'], -1, $this->imageSettings['image_bg_color']);
                         $_im = $img->get_image();
                         if ($_im != '') {
                             $im = plugins_url('/ajax-search-pro/cache/' . $_im);
                         }
                     }
                     break;
                 case "content":
                     $img = new wpdreamsImageCache($post->content, "post" . $post->id, ASP_PATH . DIRECTORY_SEPARATOR . "cache" . DIRECTORY_SEPARATOR, $this->imageSettings['image_width'], $this->imageSettings['image_height'], 1, $this->imageSettings['image_bg_color']);
                     $_im = $img->get_image();
                     if ($_im != '') {
                         $im = plugins_url('/ajax-search-pro/cache/' . $_im);
                     }
                     break;
                 case "excerpt":
                     $img = new wpdreamsImageCache($post->excerpt, "post" . $post->id, ASP_PATH . DIRECTORY_SEPARATOR . "cache" . DIRECTORY_SEPARATOR, $this->imageSettings['image_width'], $this->imageSettings['image_height'], 1, $this->imageSettings['image_bg_color']);
                     $_im = $img->get_image();
                     if ($_im != '') {
                         $im = plugins_url('/ajax-search-pro/cache/' . $_im);
                     }
                     break;
                 case "screenshot":
                     $im = 'http://s.wordpress.com/mshots/v1/' . urlencode(get_permalink($post->id)) . '?w=' . $this->imageSettings['image_width'] . '&h=' . $this->imageSettings['image_height'];
                     break;
                 case "custom":
                     if ($this->imageSettings['image_custom_field'] != "") {
                         $val = get_post_meta($post->id, $this->imageSettings['image_custom_field'], true);
                         if ($val != null && $val != "") {
                             $im = $val;
                         }
                     }
                     break;
                 case "default":
                     if ($this->imageSettings['image_default'] != "") {
                         $im = $this->imageSettings['image_default'];
                     }
                     break;
                 default:
                     $im = "";
                     break;
             }
             if ($im != null && $im != '') {
                 break;
             }
         }
         return $im;
     } else {
         return $post->image;
     }
 }
예제 #3
0
 protected function do_search()
 {
     global $wpdb;
     if (isset($wpdb->base_prefix)) {
         $_prefix = $wpdb->base_prefix;
     } else {
         $_prefix = $wpdb->prefix;
     }
     $options = $this->options;
     $searchData = $this->searchData;
     $s = $this->s;
     $_s = $this->_s;
     $repliesresults = array();
     $userresults = array();
     $groupresults = array();
     if (function_exists('bp_core_get_user_domain')) {
         /* BP users */
         $like = "";
         if ($options['set_inbpusers']) {
             if ($not_exactonly) {
                 $sr = implode("%' OR lower({$wpdb->users}.display_name) like '%", $_s);
                 if ($like != "") {
                     $sr = " OR lower({$wpdb->users}.display_name) like '%" . $sr . "%'";
                 } else {
                     $sr = " lower({$wpdb->users}.display_name) like '%" . $sr . "%'";
                 }
             } else {
                 if ($like != "") {
                     $sr = " OR lower({$wpdb->users}.display_name) like '%" . $s . "%'";
                 } else {
                     $sr = " lower({$wpdb->users}.display_name) like '%" . $s . "%'";
                 }
             }
             $like .= $sr;
         }
         $querystr = "\n           SELECT\n             {$wpdb->users}.ID as id,\n             {$wpdb->users}.display_name as title,\n             '' as date,\n             '' as author\n           FROM\n             {$wpdb->users}\n           WHERE \n            (" . $like . ") \n        ";
         $userresults = $wpdb->get_results($querystr, OBJECT);
         foreach ($userresults as $k => $v) {
             $userresults[$k]->link = bp_core_get_user_domain($v->id);
             $imgs = $searchData['settings-imagesettings'];
             if ($searchData['settings-imagesettings']['show'] == 1) {
                 $im = bp_core_fetch_avatar('item_id=' . $userresults[$k]->id);
                 if ($searchData['resultstype'] == 'vertical') {
                     $_width = $imgs['width'];
                     $_height = $imgs['height'];
                 } else {
                     $_width = wpdreams_width_from_px($searchData['hreswidth']);
                     $_vimageratio = $_width / $searchData['selected-imagesettings']['width'];
                     $_height = $_vimageratio * $searchData['selected-imagesettings']['height'];
                 }
                 $img = new wpdreamsImageCache($im, "user" . $v->id, AJAXSEARCHPRO_PATH . DIRECTORY_SEPARATOR . "cache" . DIRECTORY_SEPARATOR, $_width, $_height, 1, $searchData['imagebg']);
                 $res = $img->get_image();
                 if ($res != '') {
                     $userresults[$k]->image = plugins_url('/ajax-search-pro/cache/' . $res);
                 }
             }
             $update = get_usermeta($v->id, 'bp_latest_update');
             if (is_array($update) && isset($update['content'])) {
                 $userresults[$k]->content = $update['content'];
             }
             if ($userresults[$k]->content != '') {
                 $userresults[$k]->content = substr(strip_tags($userresults[$k]->content), 0, $searchData['descriptionlength']) . "...";
             } else {
                 $userresults[$k]->content = "";
             }
         }
         /* BP groups */
         $like = "";
         if ($options['set_inbpgroups']) {
             if ($not_exactonly) {
                 $sr = implode("%' OR lower(" . $wpdb->prefix . "bp_groups.name) like '%", $_s);
                 if ($like != "") {
                     $sr = " OR lower(" . $wpdb->prefix . "bp_groups.name) like '%" . $sr . "%'";
                 } else {
                     $sr = " lower(" . $wpdb->prefix . "bp_groups.name) like '%" . $sr . "%'";
                 }
             } else {
                 if ($like != "") {
                     $sr = " OR lower(" . $wpdb->prefix . "bp_groups.name) like '%" . $s . "%'";
                 } else {
                     $sr = " lower(" . $wpdb->prefix . "bp_groups.name) like '%" . $s . "%'";
                 }
             }
             $like .= $sr;
             if ($not_exactonly) {
                 $sr = implode("%' OR lower(" . $wpdb->prefix . "bp_groups.description) like '%", $_s);
                 if ($like != "") {
                     $sr = " OR lower(" . $wpdb->prefix . "bp_groups.description) like '%" . $sr . "%'";
                 } else {
                     $sr = " lower(" . $wpdb->prefix . "bp_groups.description) like '%" . $sr . "%'";
                 }
             } else {
                 if ($like != "") {
                     $sr = " OR lower(" . $wpdb->prefix . "bp_groups.description) like '%" . $s . "%'";
                 } else {
                     $sr = " lower(" . $wpdb->prefix . "bp_groups.description) like '%" . $s . "%'";
                 }
             }
             $like .= $sr;
             if (isset($searchData['searchinbpprivategroups']) && $searchData['searchinbpprivategroups'] == 0) {
                 $_and = "AND " . $wpdb->prefix . "bp_groups.status = 'public'";
             } else {
                 $_and = "";
             }
             $querystr = "\n             SELECT\n               " . $wpdb->prefix . "bp_groups.id as id,\n               " . $wpdb->prefix . "bp_groups.name as title,\n               " . $wpdb->prefix . "bp_groups.description as content,\n               " . $wpdb->prefix . "bp_groups.date_created as date,\n               {$wpdb->users}.user_nicename as author             \n             FROM\n               " . $wpdb->prefix . "bp_groups\n             LEFT JOIN {$wpdb->users} ON {$wpdb->users}.ID = " . $wpdb->prefix . "bp_groups.creator_id\n             WHERE \n              (" . $like . ")\n              " . $_and;
             //AND ".$wpdb->prefix."bp_groups.status = 'public'
             $groupresults = $wpdb->get_results($querystr, OBJECT);
             foreach ($groupresults as $k => $v) {
                 $group = new BP_Groups_Group($v->id);
                 $groupresults[$k]->link = bp_get_group_permalink($group);
                 $imgs = $searchData['settings-imagesettings'];
                 if ($searchData['settings-imagesettings']['show'] == 1) {
                     $avatar_options = array('item_id' => $v->id, 'object' => 'group', 'type' => 'full', 'html' => true);
                     if ($searchData['resultstype'] == 'vertical') {
                         $_width = $imgs['width'];
                         $_height = $imgs['height'];
                     } else {
                         $_width = wpdreams_width_from_px($searchData['hreswidth']);
                         $_vimageratio = $_width / $searchData['selected-imagesettings']['width'];
                         $_height = $_vimageratio * $searchData['selected-imagesettings']['height'];
                     }
                     $im = bp_core_fetch_avatar($avatar_options);
                     $img = new wpdreamsImageCache($im, "bp" . $v->id, AJAXSEARCHPRO_PATH . DIRECTORY_SEPARATOR . "cache" . DIRECTORY_SEPARATOR, $_width, $_height, 1, $searchData['imagebg']);
                     $res = $img->get_image();
                     if ($res != '') {
                         $groupresults[$k]->image = plugins_url('/ajax-search-pro/cache/' . $res);
                     }
                 }
                 if ($groupresults[$k]->content != '') {
                     $groupresults[$k]->content = substr(strip_tags($groupresults[$k]->content), 0, $searchData['descriptionlength']) . "...";
                 }
             }
         }
         do_action('bbpress_init');
         /*
                 if ($searchinbpforums && class_exists('BB_Query_Form')) {
                   $like = "";
                   
                   if ($not_exactonly) {
                     $sr = implode("%' OR lower(".$wpdb->prefix."bb_forums.forum_name) like '%",$_s);
                     if ($like!="") {
                       $sr =  " OR lower(".$wpdb->prefix."bb_forums.forum_name) like '%".$sr."%'";
                     } else {
                       $sr =  " lower(".$wpdb->prefix."bb_forums.forum_name) like '%".$sr."%'";
                     }
                   } else {
                   if ($like!="") {
                       $sr =  " OR lower(".$wpdb->prefix."bb_forums.forum_name) like '%".$s."%'";
                     } else {
                       $sr =  " lower(".$wpdb->prefix."bb_forums.forum_name) like '%".$s."%'";
                     }
                   }
                   $like .= $sr; 
                   
                   if ($not_exactonly) {
                     $sr = implode("%' OR lower(".$wpdb->prefix."bb_topics.topic_title) like '%",$_s);
                     if ($like!="") {
                       $sr =  " OR lower(".$wpdb->prefix."bb_topics.topic_title) like '%".$sr."%'";
                     } else {
                       $sr =  " lower(".$wpdb->prefix."bb_topics.topic_title) like '%".$sr."%'";
                     }
                   } else {
                   if ($like!="") {
                       $sr =  " OR lower(".$wpdb->prefix."bb_topics.topic_title) like '%".$s."%'";
                     } else {
                       $sr =  " lower(".$wpdb->prefix."bb_topics.topic_title) like '%".$s."%'";
                     }
                   }
                   $like .= $sr; 
                   
                   if ($not_exactonly) {
                     $sr = implode("%' OR lower(".$wpdb->prefix."bb_posts.post_text) like '%",$_s);
                     if ($like!="") {
                       $sr =  " OR lower(".$wpdb->prefix."bb_posts.post_text) like '%".$sr."%'";
                     } else {
                       $sr =  " lower(".$wpdb->prefix."bb_posts.post_text) like '%".$sr."%'";
                     }
                   } else {
                   if ($like!="") {
                       $sr =  " OR lower(".$wpdb->prefix."bb_posts.post_text) like '%".$s."%'";
                     } else {
                       $sr =  " lower(".$wpdb->prefix."bb_posts.post_text) like '%".$s."%'";
                     }
                   }
                   $like .= $sr;
                   
                   $querystr = "
                      SELECT
                        ".$wpdb->prefix."bb_posts.post_id as id,
                        ".$wpdb->prefix.$searchData['bpgroupstitle'].",
                        ".$wpdb->prefix."bb_posts.post_text as content,
                        ".$wpdb->prefix."bb_posts.post_time as date,
                        ".$wpdb->prefix."bb_topics.topic_id as topic_id,
                        $wpdb->users.user_nicename as author             
                      FROM
                        ".$wpdb->prefix."bb_posts
                      LEFT JOIN $wpdb->users ON $wpdb->users.ID = ".$wpdb->prefix."bb_posts.poster_id
                      LEFT JOIN ".$wpdb->prefix."bb_topics ON ".$wpdb->prefix."bb_posts.topic_id = ".$wpdb->prefix."bb_topics.topic_id 
                      LEFT JOIN ".$wpdb->prefix."bb_forums ON ".$wpdb->prefix."bb_posts.forum_id = ".$wpdb->prefix."bb_forums.forum_id
                      WHERE 
                       (".$like.")
                   ";
                    
                   $repliesresults = $wpdb->get_results($querystr, OBJECT);
                   foreach ($repliesresults as $k=>$v) {
                     $topic_query_vars = array( 'topic_id'=> $v->topic_id, 'topic_status' => 'normal', 'open' => 'open');
                     $topic_query = new BB_Query_Form( 'topic', $topic_query_vars );
                     $topics = $topic_query->results;
                     if (is_array($topics)) {
                       foreach ( $topics as $topic ) : $first_post = bb_get_first_post( $topic );
                          
                         $_qs = "SELECT post_id as id FROM ".$wpdb->prefix."bb_posts WHERE topic_id=".$v->topic_id;
                         $_posts = $wpdb->get_results($_qs, OBJECT);
                         $_count = 0; 
                         foreach ($_posts as $_post) {
                           $_count++;
                           if ($_post->id==$v->id) break;
                         }
                         $_bbp_post_count = get_option("_bbp_replies_per_page", 15);
                         $_page = intval(($_count-1) / $_bbp_post_count);
                         if ($_page>0) {
                           $_page = "?topic_page=".($_page+1);
                         } else {
                           $_page = "";
                         }
                         $repliesresults[$k]->link = get_bloginfo('url')."/groups/".$topic->object_slug."/forum/topic/".$topic->topic_slug."/".$_page."#post-".$v->id;
                       endforeach;
                     }           
                     if ($searchData['settings-imagesettings']['show']==1) {
                       $im =   $repliesresults[$k]->content;
                       $img = new wpdreamsImageCache($im, AJAXSEARCHPRO_PATH.DIRECTORY_SEPARATOR."cache".DIRECTORY_SEPARATOR, $imgs['width'], $imgs['height'], 1, $searchData['imagebg']);
                       $res = $img->get_image();
                       if ($res!='') {
                         $repliesresults[$k]->image = plugins_url('/ajax-search-pro/cache/'.$res );
                       }
                     }
                    if ($repliesresults[$k]->content!='')
                     $repliesresults[$k]->content = substr(strip_tags($repliesresults[$k]->content), 0, $searchData['descriptionlength'])."...";
                    $repliesresults[$k]->title = substr(strip_tags($repliesresults[$k]->title), 0, 30)."...";
                   }
                 }
                 Forum search Deprecated */
     }
     $this->results = array('repliesresults' => $repliesresults, 'groupresults' => $groupresults, 'userresults' => $userresults);
     return $this->results;
 }
예제 #4
0
 /**
  * Fetches an image with the imageCache class
  */
 protected function getCachedImage($post, $get_content = false, $get_excerpt = false)
 {
     if ($post->image == null) {
         $i = 1;
         $im = "";
         for ($i == 1; $i < 6; $i++) {
             switch ($this->imageSettings['image_source' . $i]) {
                 case "featured":
                     $__im = wp_get_attachment_url(get_post_thumbnail_id($post->id));
                     if ($__im != "") {
                         $img = new wpdreamsImageCache($__im, "post" . $post->id, ASP_PATH . DIRECTORY_SEPARATOR . "cache" . DIRECTORY_SEPARATOR, $this->imageSettings['image_width'], $this->imageSettings['image_height'], -1, $this->imageSettings['image_bg_color']);
                         $_im = $img->get_image();
                         if ($_im != '') {
                             $im = plugins_url('/ajax-search-pro/cache/' . $_im);
                         }
                     }
                     break;
                 case "content":
                     $content = $get_content ? get_post_field('post_content', $post->id) : $post->content;
                     $content = apply_filters('the_content', $content);
                     $img = new wpdreamsImageCache($content, "post" . $post->id, ASP_PATH . DIRECTORY_SEPARATOR . "cache" . DIRECTORY_SEPARATOR, $this->imageSettings['image_width'], $this->imageSettings['image_height'], 1, $this->imageSettings['image_bg_color']);
                     $_im = $img->get_image();
                     if ($_im != '') {
                         $im = plugins_url('/ajax-search-pro/cache/' . $_im);
                     }
                     break;
                 case "excerpt":
                     $excerpt = $get_excerpt ? get_post_field('post_excerpt', $post->id) : $post->excerpt;
                     $img = new wpdreamsImageCache($excerpt, "post" . $post->id, ASP_PATH . DIRECTORY_SEPARATOR . "cache" . DIRECTORY_SEPARATOR, $this->imageSettings['image_width'], $this->imageSettings['image_height'], 1, $this->imageSettings['image_bg_color']);
                     $_im = $img->get_image();
                     if ($_im != '') {
                         $im = plugins_url('/ajax-search-pro/cache/' . $_im);
                     }
                     break;
                 case "screenshot":
                     $im = 'http://s.wordpress.com/mshots/v1/' . urlencode(get_permalink($post->id)) . '?w=' . $this->imageSettings['image_width'] . '&h=' . $this->imageSettings['image_height'];
                     break;
                 case "post_format":
                     $format = get_post_format($post->id);
                     switch ($format) {
                         case "audio":
                             $im = ASP_URL . "img/post_format/audio.png";
                             break;
                         case "video":
                             $im = ASP_URL . "img/post_format/video.png";
                             break;
                         case "quote":
                             $im = ASP_URL . "img/post_format/quote.png";
                             break;
                         case "image":
                             $im = ASP_URL . "img/post_format/image.png";
                             break;
                         case "gallery":
                             $im = ASP_URL . "img/post_format/gallery.png";
                             break;
                         case "link":
                             $im = ASP_URL . "img/post_format/link.png";
                             break;
                         default:
                             $im = ASP_URL . "img/post_format/default.png";
                             break;
                     }
                     break;
                 case "custom":
                     if ($this->imageSettings['image_custom_field'] != "") {
                         $val = get_post_meta($post->id, $this->imageSettings['image_custom_field'], true);
                         if ($val != null && $val != "") {
                             $im = $val;
                         }
                     }
                     break;
                 case "default":
                     if ($this->imageSettings['image_default'] != "") {
                         $im = $this->imageSettings['image_default'];
                     }
                     break;
                 default:
                     $im = "";
                     break;
             }
             if ($im != null && $im != '') {
                 break;
             }
         }
         return $im;
     } else {
         return $post->image;
     }
 }
예제 #5
0
 protected function post_process()
 {
     $pageposts = $this->results;
     $options = $this->options;
     $searchData = $this->searchData;
     $s = $this->s;
     $_s = $this->_s;
     /* Category filtering */
     $_selected_categories = array();
     if (isset($options['categoryset'])) {
         $_selected_categories = $options['categoryset'];
     }
     $_all_categories = get_all_category_ids();
     if (count($_selected_categories) > 0 && count($_all_categories) != count($_selected_categories)) {
         foreach ($pageposts as $k => $v) {
             if ($v->term_id == null) {
                 $v->term_id = "";
                 continue;
             }
             if ($v->post_type != 'post' && $searchData['pageswithcategories'] != 1) {
                 continue;
             }
             $_term_ids = explode(',', $v->term_id);
             if (count($_term_ids) <= 0) {
                 $_term_ids = array($v->term_id);
             }
             $match = false;
             $_new_terms = array();
             foreach ($_term_ids as $_term_id) {
                 if (in_array($_term_id, $_selected_categories)) {
                     $match = true;
                     $_new_terms[] = $_term_id;
                 }
             }
             if (!$match) {
                 unset($pageposts[$k]);
             } else {
                 $v->term_id = implode(",", $_new_terms);
             }
         }
     }
     /* !Category filtering */
     /* TERM filtering */
     if (isset($options['termset'])) {
         $terms = array();
         $o_terms = array();
         foreach ($options['termset'] as $term => $tax) {
             if ($tax != "0") {
                 $o_terms[$tax][] = $term;
             }
         }
         //var_dump($o_terms);
         foreach ($pageposts as $k => $v) {
             $terms = $o_terms;
             foreach ($terms as $ex_taxonomy => $ex_terms) {
                 $_post_terms = wp_get_post_terms($v->id, $ex_taxonomy);
                 $post_terms = array();
                 if (is_array($_post_terms) && isset($_post_terms[0])) {
                     foreach ($_post_terms as $_term) {
                         $post_terms[] = (int) $_term->term_id;
                     }
                     foreach ($ex_terms as $_term) {
                         /* Get all child terms of the current term */
                         $args = array('child_of' => $_term);
                         $termchildren = get_terms($ex_taxonomy, $args);
                         if (isset($termchildren) && count($termchildren) > 0) {
                             foreach ($termchildren as $child_term) {
                                 if (!in_array((int) $child_term->term_id, $ex_terms)) {
                                     $ex_terms[] = (int) $child_term->term_id;
                                 }
                             }
                         }
                         /* Get the parent term of the current term */
                         $parent = get_term_by('id', $_term, $ex_taxonomy);
                         if (isset($parent) && isset($parent->term_id) && $parent->term_id != 0) {
                             $ex_terms[] = $parent->term_id;
                         }
                     }
                     $diff = array_unique(array_diff($post_terms, $ex_terms));
                     //var_dump($post_terms);
                     //var_dump($ex_terms);
                     //var_dump($diff);
                     //exit;
                     if (!is_array($diff) || count($diff) < 1) {
                         unset($pageposts[$k]);
                         break;
                     }
                 }
             }
         }
     }
     /* !TERM  filtering */
     /* Images, title, desc */
     foreach ($pageposts as $k => $v) {
         // Let's simplify things
         $r =& $pageposts[$k];
         $r->title = apply_filters('asp_result_title_before_prostproc', $r->title, $r->id);
         $r->content = apply_filters('asp_result_content_before_prostproc', $r->content, $r->id);
         $r->image = apply_filters('asp_result_image_before_prostproc', $r->image, $r->id);
         $r->author = apply_filters('asp_result_author_before_prostproc', $r->author, $r->id);
         $r->date = apply_filters('asp_result_date_before_prostproc', $r->date, $r->id);
         $r->link = get_permalink($v->id);
         $use_timthumb = get_option('asp_usetimbthumb');
         if ($use_timthumb) {
             if ($searchData['settings-imagesettings']['show'] == 1) {
                 $imgs = $searchData['settings-imagesettings'];
                 ksort($imgs['from']);
                 if ($searchData['resultstype'] == 'vertical') {
                     $_width = $imgs['width'];
                     $_height = $imgs['height'];
                 } else {
                     $_width = wpdreams_width_from_px($searchData['hreswidth']);
                     $_vimageratio = $_width / $searchData['selected-imagesettings']['width'];
                     $_height = $_vimageratio * $searchData['selected-imagesettings']['height'];
                 }
                 foreach ($imgs['from'] as $kk => $source) {
                     if ($kk == -11) {
                         continue;
                     }
                     if (isset($r->image) || $r->image != '') {
                         continue;
                     }
                     if ($source == 'featured') {
                         $im = wp_get_attachment_url(get_post_thumbnail_id($v->id));
                     } else {
                         if ($source == 'content') {
                             $im = wpdreams_get_image_from_content($v->content, $imgs['imagenum']);
                         } else {
                             if ($source == 'excerpt') {
                                 $im = wpdreams_get_image_from_content($v->excerpt, $imgs['imagenum']);
                             } else {
                                 if ($source == 'usecustom') {
                                     if (isset($imgs['customname']) && $imgs['customname'] != '') {
                                         $im = get_post_meta($v->id, $imgs['customname'], true);
                                         if ($im != '' && $im != false) {
                                         } else {
                                             continue;
                                         }
                                     } else {
                                         continue;
                                     }
                                 }
                             }
                         }
                     }
                     if ($im !== false && $im != '') {
                         $r->image = plugins_url('/ajax-search-pro/includes/timthumb.php') . '?cc=' . str_replace('#', '', wpdreams_rgb2hex($searchData['imagebg'])) . '&ct=0&q=95&w=' . $_width . '&h=' . $_height . '&src=' . rawurlencode($im);
                         break;
                     }
                 }
             }
         } else {
             if ($searchData['settings-imagesettings']['show'] == 1) {
                 $imgs = $searchData['settings-imagesettings'];
                 ksort($imgs['from']);
                 if ($searchData['resultstype'] == 'vertical') {
                     $_width = $imgs['width'];
                     $_height = $imgs['height'];
                 } else {
                     if ($searchData['resultstype'] == 'horizontal') {
                         $_width = wpdreams_width_from_px($searchData['hreswidth']);
                         $_vimageratio = $_width / $searchData['selected-imagesettings']['width'];
                         $_height = $_vimageratio * $searchData['selected-imagesettings']['height'];
                     } else {
                         $_width = wpdreams_width_from_px($searchData['preswidth']) - 2 * wpdreams_width_from_px($searchData['prespadding']);
                         $_height = $_width;
                     }
                 }
                 foreach ($imgs['from'] as $kk => $source) {
                     if ($kk == -11) {
                         continue;
                     }
                     if (isset($r->image) || $r->image != '') {
                         continue;
                     }
                     // Calculate the image size
                     if ($source == 'featured') {
                         //$im = get_the_post_thumbnail($v->id);
                         $im = wp_get_attachment_url(get_post_thumbnail_id($v->id));
                         //var_dump($im);
                         $img = new wpdreamsImageCache($im, "post" . $v->id, AJAXSEARCHPRO_PATH . DIRECTORY_SEPARATOR . "cache" . DIRECTORY_SEPARATOR, $_width, $_height, -1, $searchData['imagebg']);
                     } else {
                         if ($source == 'content') {
                             $img = new wpdreamsImageCache($v->content, "post" . $v->id, AJAXSEARCHPRO_PATH . DIRECTORY_SEPARATOR . "cache" . DIRECTORY_SEPARATOR, $_width, $_height, $imgs['imagenum'], $searchData['imagebg']);
                         } else {
                             if ($source == 'excerpt') {
                                 $img = new wpdreamsImageCache($v->excerpt, "post" . $v->id, AJAXSEARCHPRO_PATH . DIRECTORY_SEPARATOR . "cache" . DIRECTORY_SEPARATOR, $_width, $_height, $imgs['imagenum'], $searchData['imagebg']);
                             } else {
                                 if ($source == 'usecustom') {
                                     if (isset($imgs['customname']) && $imgs['customname'] != '') {
                                         $im = get_post_meta($v->id, $imgs['customname'], true);
                                         if ($im != '' && $im != false) {
                                             $img = new wpdreamsImageCache($im, "post" . $v->id, AJAXSEARCHPRO_PATH . DIRECTORY_SEPARATOR . "cache" . DIRECTORY_SEPARATOR, $_width, $_height, -1, $searchData['imagebg']);
                                         } else {
                                             continue;
                                         }
                                     } else {
                                         continue;
                                     }
                                 }
                             }
                         }
                     }
                     $res = $img->get_image();
                     if ($res != '') {
                         $r->image = plugins_url('/ajax-search-pro/cache/' . $res);
                         break;
                     }
                 }
             }
         }
         if (!isset($searchData['titlefield']) || $searchData['titlefield'] == "0" || is_array($searchData['titlefield'])) {
             $r->title = get_the_title($r->id);
         } else {
             if ($searchData['titlefield'] == "1") {
                 if (strlen($r->excerpt) >= 200) {
                     $r->title = substr($r->excerpt, 0, 200);
                 } else {
                     $r->title = $r->excerpt;
                 }
             } else {
                 $mykey_values = get_post_custom_values($searchData['titlefield'], $r->id);
                 if (isset($mykey_values[0])) {
                     $r->title = $mykey_values[0];
                 } else {
                     $r->title = get_the_title($r->id);
                 }
             }
         }
         if (!isset($searchData['striptagsexclude'])) {
             $searchData['striptagsexclude'] = "<a><span>";
         }
         if (!isset($searchData['descriptionfield']) || $searchData['descriptionfield'] == "0" || is_array($searchData['descriptionfield'])) {
             if (function_exists('qtrans_getLanguage')) {
                 $r->content = apply_filters('the_content', $r->content);
             }
             $_content = strip_tags($r->content, $searchData['striptagsexclude']);
         } else {
             if ($searchData['descriptionfield'] == "1") {
                 $_content = strip_tags($r->excerpt, $searchData['striptagsexclude']);
             } else {
                 if ($searchData['descriptionfield'] == "2") {
                     $_content = strip_tags(get_the_title($r->id), $searchData['striptagsexclude']);
                 } else {
                     $mykey_values = get_post_custom_values($searchData['descriptionfield'], $r->id);
                     if (isset($mykey_values[0])) {
                         $_content = strip_tags($mykey_values[0], $searchData['striptagsexclude']);
                     } else {
                         $_content = strip_tags(get_content_w($r->content), $searchData['striptagsexclude']);
                     }
                 }
             }
         }
         if ($_content == "") {
             $_content = $r->content;
         }
         if (isset($searchData['runshortcode']) && $searchData['runshortcode'] == 1) {
             if ($_content != "") {
                 $_content = apply_filters('the_content', $_content);
             }
             if ($_content != "") {
                 $_content = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $_content);
             }
         }
         if (isset($searchData['stripshortcode']) && $searchData['stripshortcode'] == 1) {
             if ($_content != "") {
                 $_content = strip_shortcodes($_content);
             }
         }
         $_content = strip_tags($_content, $searchData['striptagsexclude']);
         if ($_content != '' && strlen($_content) > $searchData['descriptionlength']) {
             $r->content = substr($_content, 0, $searchData['descriptionlength']) . "...";
         } else {
             $r->content = $_content . "...";
         }
         $r->title = apply_filters('asp_result_title_after_prostproc', $r->title, $r->id);
         $r->content = apply_filters('asp_result_content_after_prostproc', $r->content, $r->id);
         $r->image = apply_filters('asp_result_image_after_prostproc', $r->image, $r->id);
         $r->author = apply_filters('asp_result_author_after_prostproc', $r->author, $r->id);
         $r->date = apply_filters('asp_result_date_after_prostproc', $r->date, $r->id);
     }
     /* !Images, title, desc */
     //var_dump($pageposts); die();
     $this->results = $pageposts;
     return $pageposts;
 }