Plugin Directory

Changeset 627949


Ignore:
Timestamp:
11/20/2012 10:44:27 PM (13 years ago)
Author:
ashrafweb
Message:

sql changes

Location:
related-posts-list-grid-and-slider-all-in-one
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • related-posts-list-grid-and-slider-all-in-one/tags/1.7/related.php

    r623759 r627949  
    1414$aio_related_posts_settings = aio_read_options();
    1515$rstyle = $aio_related_posts_settings['related_posts_type'];
     16//------------------------------------------------------------------------
     17function sortTwoDimensionArrayByKey($arr, $arrKey, $sortOrder=SORT_ASC){
     18foreach ($arr as $key => $row){
     19$key_arr[$key] = $row[$arrKey];
     20}
     21array_multisort($key_arr, $sortOrder, $arr);
     22return $arr;
     23}
    1624//------------------------------------------------------------------------
    1725function get_related_posts_aio($content)
     
    216224    //$stuff = '';
    217225    if ((is_int($post->ID))) {
    218         $sql = "SELECT DISTINCT ID,post_title,post_date,MATCH (post_title,post_content) AGAINST ('".$stuff."') AS score "
     226        $sql = "SELECT DISTINCT ID,post_title,post_date "
    219227        . "FROM ". "$wpdb->posts , $wpdb->term_taxonomy t_t, $wpdb->term_relationships t_r"
    220228        ." WHERE "
    221         ." (t_t.taxonomy ='post_tag' AND t_t.term_taxonomy_id = t_r.term_taxonomy_id AND t_r.object_id  = ID AND (t_t.term_id IN ($taglist)) "
    222         . "or MATCH (post_title,post_content) AGAINST ('".$stuff."')) "
     229        ." (t_t.taxonomy ='post_tag' AND t_t.term_taxonomy_id = t_r.term_taxonomy_id  AND  t_r.object_id  = ID AND (t_t.term_id IN ($taglist))) "
    223230        . "AND post_date <= '".$now."' "
    224231        . "AND post_status = 'publish' "
    225232        . "AND id != ".$post->ID." "
    226233        ."AND post_type = 'post' "
    227         ." order by score*id desc "
     234        ." order by id desc "
    228235        ."LIMIT ".$limit;
    229236        $search_counter = 0;
  • related-posts-list-grid-and-slider-all-in-one/tags/1.7/the_globals.php

    r613077 r627949  
    77global $post;
    88$tags = wp_get_post_tags($post->ID);
    9    
    10     $taglist = "'" . $tags[0]->term_id. "'";
    11    
    12     $tagcount = count($tags);
     9$tagcount = count($tags);
     10$result = $tags;
     11if ($tagcount > 1) {
     12for ($i = 0; $i < $tagcount; $i++)
     13   {
     14    $mytags[$i]['term_id'] = $tags[$i]->term_id;
     15    $mytags[$i]['count'] = $tags[$i]->count;
     16   }
     17$result = sortTwoDimensionArrayByKey($mytags,'count');
     18}
     19    $taglist = "'" . $result[0]->term_id. "'";
     20    $countlist = "'" . $result[0]->count. "'";
     21
    1322    if ($tagcount > 1) {
    1423        for ($i = 1; $i < $tagcount; $i++) {
    15             $taglist = $taglist . ", '" . $tags[$i]->term_id . "'";
     24            if ($result[$i]['count'] < 9) {
     25            $taglist = $taglist . ", '" . $result[$i]['term_id'] . "'";
     26            $countlist = $countlist . ", '" . $result[$i]['count'] . "'";}
    1627        }
    1728    }
  • related-posts-list-grid-and-slider-all-in-one/trunk/related.php

    r623759 r627949  
    1414$aio_related_posts_settings = aio_read_options();
    1515$rstyle = $aio_related_posts_settings['related_posts_type'];
     16//------------------------------------------------------------------------
     17function sortTwoDimensionArrayByKey($arr, $arrKey, $sortOrder=SORT_ASC){
     18foreach ($arr as $key => $row){
     19$key_arr[$key] = $row[$arrKey];
     20}
     21array_multisort($key_arr, $sortOrder, $arr);
     22return $arr;
     23}
    1624//------------------------------------------------------------------------
    1725function get_related_posts_aio($content)
     
    216224    //$stuff = '';
    217225    if ((is_int($post->ID))) {
    218         $sql = "SELECT DISTINCT ID,post_title,post_date,MATCH (post_title,post_content) AGAINST ('".$stuff."') AS score "
     226        $sql = "SELECT DISTINCT ID,post_title,post_date "
    219227        . "FROM ". "$wpdb->posts , $wpdb->term_taxonomy t_t, $wpdb->term_relationships t_r"
    220228        ." WHERE "
    221         ." (t_t.taxonomy ='post_tag' AND t_t.term_taxonomy_id = t_r.term_taxonomy_id AND t_r.object_id  = ID AND (t_t.term_id IN ($taglist)) "
    222         . "or MATCH (post_title,post_content) AGAINST ('".$stuff."')) "
     229        ." (t_t.taxonomy ='post_tag' AND t_t.term_taxonomy_id = t_r.term_taxonomy_id  AND  t_r.object_id  = ID AND (t_t.term_id IN ($taglist))) "
    223230        . "AND post_date <= '".$now."' "
    224231        . "AND post_status = 'publish' "
    225232        . "AND id != ".$post->ID." "
    226233        ."AND post_type = 'post' "
    227         ." order by score*id desc "
     234        ." order by id desc "
    228235        ."LIMIT ".$limit;
    229236        $search_counter = 0;
  • related-posts-list-grid-and-slider-all-in-one/trunk/the_globals.php

    r613077 r627949  
    77global $post;
    88$tags = wp_get_post_tags($post->ID);
    9    
    10     $taglist = "'" . $tags[0]->term_id. "'";
    11    
    12     $tagcount = count($tags);
     9$tagcount = count($tags);
     10$result = $tags;
     11if ($tagcount > 1) {
     12for ($i = 0; $i < $tagcount; $i++)
     13   {
     14    $mytags[$i]['term_id'] = $tags[$i]->term_id;
     15    $mytags[$i]['count'] = $tags[$i]->count;
     16   }
     17$result = sortTwoDimensionArrayByKey($mytags,'count');
     18}
     19    $taglist = "'" . $result[0]->term_id. "'";
     20    $countlist = "'" . $result[0]->count. "'";
     21
    1322    if ($tagcount > 1) {
    1423        for ($i = 1; $i < $tagcount; $i++) {
    15             $taglist = $taglist . ", '" . $tags[$i]->term_id . "'";
     24            if ($result[$i]['count'] < 9) {
     25            $taglist = $taglist . ", '" . $result[$i]['term_id'] . "'";
     26            $countlist = $countlist . ", '" . $result[$i]['count'] . "'";}
    1627        }
    1728    }
Note: See TracChangeset for help on using the changeset viewer.