Changeset 867

Show
Ignore:
Timestamp:
08/31/08 14:31:19 (3 months ago)
Author:
ayunyan
Message:

plugin:rateit added dashboard module "Highest Rated Entries"

Location:
plugins/rateit/trunk
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • plugins/rateit/trunk/rateit.plugin.php

    r806 r867  
    3333            'license' => 'Apache License 2.0', 
    3434            'description' => 'adding Star Rating to your posts.', 
     35            'guid' => '5ffe55ac-2773-11dd-b5d6-001b210f913f' 
    3536            ); 
    3637    } 
     
    6263        } 
    6364 
    64         Options::set( 'rateit__post_pos', 'bottom' ); 
     65        Options::set('rateit__post_pos', 'bottom'); 
     66        Modules::add(_t('Highest Rated Entries', 'rateit')); 
    6567    } 
    6668 
     
    8688    public function action_update_check() 
    8789    { 
    88         Update::add( 'Rate It!', '5ffe55ac-2773-11dd-b5d6-001b210f913f', $this->info->version ); 
     90        Update::add('Rate It!', $this->info->guid, $this->info->version); 
    8991    } 
    9092 
     
    134136        } 
    135137        return $actions; 
     138    } 
     139 
     140    /** 
     141     * filter: dash_modules 
     142     * 
     143     * @access public 
     144     * @param array $modules 
     145     * @return array 
     146     */ 
     147    public function filter_dash_modules($modules) 
     148    { 
     149        $modules[] = _t('Highest Rated Entries', 'rateit'); 
     150        $this->add_template('dash_highest_rated_entries', dirname(__FILE__) . '/dash_highest_rated_entries.php'); 
     151        return $modules; 
     152    } 
     153 
     154    /** 
     155     * filter: dash_module_highest_rated_entries 
     156     * 
     157     * @access public 
     158     * @param array $module 
     159     * @param string $module_id 
     160     * @param object $theme 
     161     * @return array 
     162     */ 
     163    public function filter_dash_module_highest_rated_entries($module, $module_id, $theme) 
     164    { 
     165        $module['title'] = _t('Highest Rated Entries', 'rateit'); 
     166 
     167        $theme->highest_rated_posts = DB::get_results('SELECT * FROM {posts} LEFT JOIN {postinfo} ON {posts}.id = {postinfo}.post_id WHERE {postinfo}.name = \'rateit_rating\' ORDER BY {postinfo}.value DESC LIMIT 0,5;', array(), 'Post'); 
     168 
     169        $module['content'] = $theme->fetch('dash_highest_rated_entries'); 
     170        return $module; 
    136171    } 
    137172 
     
    288323        if ( !$log->insert() ) return false; 
    289324 
    290         $post->info->rateit_total+= $rating; 
    291         $post->info->rateit_count+= 1; 
     325        $post->info->rateit_total += $rating; 
     326        $post->info->rateit_count += 1; 
     327        $post->info->rateit_rating = $post->info->rateit_total / $post->info->rateit_count; 
    292328        $post->info->commit(); 
    293329 
     
    305341    } 
    306342 
     343    /** 
     344     * create table 
     345     * 
     346     * @access private 
     347     * @return boolean 
     348     */ 
    307349    private function install_db() 
    308350    {