'.__('Ticket Rating').''); // Définition du menu $mySubMenu->addItem(__('Home'), 'tools.php?p=ticketrating', 'images/ico_goto.png', FALSE); $mySubMenu->addItem(__('Most rated'), 'tools.php?p=ticketrating&a=most_rated', 'images/ico_goto.png', FALSE); $mySubMenu->addItem(__('Best rated'), 'tools.php?p=ticketrating&a=best_rated', 'images/ico_goto.png', FALSE); /* INSTALLATION */ // Vérification de la présence de la table if(!$rs = $con->select('SHOW TABLES FROM `'.DB_DBASE.'` LIKE \''.DB_PREFIX.'rate\'')) { buffer::str('

' . $con->error() . '

'); }elseif ($rs->isEmpty()){ // La table n'existe pas, on la créé $sql = 'CREATE TABLE IF NOT EXISTS `'.DB_PREFIX.'rate` ('. '`rate_post_id` int(11) NOT NULL,'. '`rate_ip` varchar(15) NOT NULL,'. '`rate_value` tinyint(1) NOT NULL'. ')'; if($con->execute($sql)) buffer::str('

' . __('Ticket Rating has been successfully installed!') . '

'); else buffer::str('

' . $con->error() . '

'); } /* Vérifictation des mises à jour */ require_once dirname(__FILE__).'/functions.php'; $plugins_root = dirname(__FILE__).'/../'; $plugins = new plugins($plugins_root); $plugins->getPlugins(false); $plugins_list = $plugins->getPluginsList(); $p_info = $plugins_list['ticketrating']; unset($plugins_list, $plugins, $plugins_root); if($check = @file_get_contents("http://x1fr.free.fr/share/ticketrating/version")) { if(postRating::checkNewVersion($p_info['version'],$check)) { buffer::str('

' . __('A newer version of this plugin is available!') . '(v'.$check.')

'); } } if(isset($_GET['a'])) { if(($_GET['a']==='most_rated') || ($_GET['a']==='best_rated')) { $op = ($_GET['a']==='most_rated') ? 'count(rate_value)' : 'round(avg(rate_value),2)'; $rs = $con->select('SELECT '.$op.' as value, post_titre FROM '.DB_PREFIX.'rate,'.DB_PREFIX.'post WHERE post_id = rate_post_id GROUP BY rate_post_id ORDER BY value DESC LIMIT 0,5'); if($rs->isEmpty()) { buffer::str(__('No ticket has been rated for now')); }else{ buffer::str(''); buffer::str(''); $i = 1; while ($rs->fetch()) { $style = ($i%2 == 0) ? ' style="background:#eee;"' : ''; buffer::str(''); } buffer::str('

'); ($_GET['a']==='most_rated') ? buffer::str(__('Most rated')) : buffer::str(__('Best rated')); buffer::str('

'.__('Rank').''.__('Ticket').''.__('Count').'
'.$i++.''.$rs->f('post_titre').''.$rs->f('value').'
'); } } }else{ $rs = $con->select('SELECT count(rate_value) as cpt FROM '.DB_PREFIX.'rate LIMIT 0,1'); if($rs->f('cpt')!=0) { buffer::str('

' . __('Informations') . '

'); buffer::str(''); $rs = $con->select('SELECT round(avg(rate_value),2) as avg FROM '.DB_PREFIX.'rate LIMIT 0,1'); buffer::str(''); buffer::str('
'.__('Total submit').''.$rs->f('cpt').'
'.__('Global average').''.$rs->f('avg').'
'); }else{ buffer::str(__('No ticket has been rated for now')); } buffer::str('

' . __('Usage') . '

'); buffer::str('

' . __('The following templates file can be edited to use the plugin: post.php and list.php') . '

' . '

' . __('To show the rate of a ticket, paste this code in the template file:') . '

' . '
' . htmlspecialchars('') . '
'. '

' . __('To show the form allowing to rate a ticket, use this:') . '

'. '
' . htmlspecialchars('') . '
'); } ?>