Changeset 479087
- Timestamp:
- 12/22/2011 09:28:36 AM (13 years ago)
- Location:
- rate-this-page-plugin/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
rate-this-page-plugin/trunk/css/rtp-style-admin.css
r475733 r479087 234 234 font-size: 12px; 235 235 } 236 237 /*-- Insertion Style --*/ 238 #rtp-insertion td.rtp-ins-id { 239 width: 15%; 240 } 241 242 #rtp-insertion td.rtp-ins-name { 243 width: 45%; 244 } 245 246 #rtp-insertion td.rtp-ins-slug { 247 width: 35%; 248 } 249 250 /*-- Pagination Style --*/ 251 #rtp-insertion tfoot, #rtp-reporting tfoot { 252 text-align: center; 253 } 254 255 #rtp-insertion tfoot td, #rtp-reporting tfoot td { 256 background-color: #E5E5E5; 257 } 258 259 #rtp-insertion tfoot td img, #rtp-reporting tfoot td img { 260 vertical-align: middle; 261 } 262 263 #rtp-insertion tfoot .pagedisplay, #rtp-reporting tfoot .pagedisplay { 264 background-color: #E5E5E5; 265 border: 0; 266 text-align: center; 267 vertical-align: top; 268 width: 40px; 269 } 270 271 /*-- Reporting Style --*/ 272 #rtp-reporting thead th { 273 text-align: center; 274 word-wrap: break-word; 275 } 276 277 #rtp-reporting td.rtp-rpt-name { 278 width: 36%; 279 } 280 281 #rtp-reporting td.rtp-rpt-rate { 282 width: 12%; 283 } 284 285 #rtp-reporting td.rtp-rpt-average { 286 font-size: 11px; 287 width: 10%; 288 } 289 290 #rtp-reporting td.rtp-rpt-rate { 291 font-size: 11px; 292 text-align: left; 293 } 294 295 table.tablesorter tbody td { 296 font-size: 12px; 297 } -
rate-this-page-plugin/trunk/readme.txt
r476274 r479087 70 70 71 71 == Upgrade Notice == 72 = 1. 3=73 Fixed jQuery initialization on plugin admin page. It will now load only on its specific page.72 = 1.4 = 73 SOON. 74 74 75 75 == Changelog == 76 = 1.4 = 77 * Added new function rtp_count_rated_item() to be use to count # of user who rate. 78 * Updated aft_plgn_fetch_article_rate() function removed redundant sql select query string on querying list of rated posts/pages. 79 * Updated Ratings Report tab on displaying the average rating of the posts/pages rated to include displaying the count of users who rated. 80 * Admin settings now using cookies to store the last selected tab. 81 * Fixed table sorting not properly sorted from highest to lowest. 82 * Fixed table layout on admin settings for Insertion and Reports Tab. 83 * Fixed pagination on admin settings for Insertion and Reports Tab. 84 76 85 = 1.3 = 77 86 * Fixed jQuery initialization on plugin admin page. It will now load only on its specific page. -
rate-this-page-plugin/trunk/rtp-admin-scripts.php
r475733 r479087 2 2 jQuery(document).ready(function() { 3 3 /** Initialize jQuery Tabs **/ 4 jQuery(".tabs").tabs(); 4 jQuery(".tabs").tabs({ 5 cookie: { expires: 30 }, 6 fx: { opacity: 'toggle', duration: 'fast' } 7 }); 5 8 6 9 /** Initialize jQuery Table Sorter **/ 7 jQuery("#report-result").tablesorter({ 8 sortList: [[0,0]], 10 jQuery("#report-result") 11 .tablesorter({ 12 sortList: [[6,1]], 9 13 headers: { 10 14 2: { sorter: false }, … … 13 17 5: { sorter: false } 14 18 } 19 }) 20 .tablesorterPager({ 21 container: jQuery("#rpt-pager-report"), 22 positionFixed: false 15 23 }); 16 24 25 /** Pagination by Category **/ 17 26 jQuery("#insertion-by-category").tablesorter({ 18 27 sortList: [[1,0]], 19 28 headers: {0: { sorter: false } } 20 }); 29 }) 30 .tablesorterPager({ 31 container: jQuery("#rpt-pager-bycategory"), 32 positionFixed: false 33 }); 21 34 35 /** Pagination by Page **/ 22 36 jQuery("#insertion-by-page").tablesorter({ 23 37 sortList: [[1,0]], 24 38 headers: {0: { sorter: false } } 25 }); 39 }) 40 .tablesorterPager({ 41 container: jQuery("#rpt-pager-bypage"), 42 positionFixed: false 43 }); 26 44 27 jQuery("#insertion-category").tablesorter({ 45 /** Pagination Page and Category **/ 46 jQuery("#insertion-category") 47 .tablesorter({ 28 48 sortList: [[1,0]], 29 49 headers: {0: { sorter: false } } 30 }); 50 }) 51 .tablesorterPager({ 52 container: jQuery("#rpt-pager-category"), 53 positionFixed: false 54 }); 31 55 32 jQuery("#insertion-page").tablesorter({ 56 jQuery("#insertion-page") 57 .tablesorter({ 33 58 sortList: [[1,0]], 34 59 headers: {0: { sorter: false } } 60 }) 61 .tablesorterPager({ 62 container: jQuery("#rpt-pager-page"), 63 positionFixed: false 35 64 }); 36 65 -
rate-this-page-plugin/trunk/rtp-admin.php
r475764 r479087 142 142 <div id="message" class="updated" 143 143 <?php 144 if( (! isset( $_REQUEST['aft_plgn_submit_options'] ) || $error != "") && (! isset( $_REQUEST['rtp_submit_custom'] ) || $error != "" ) ) 144 if( ( !isset( $_REQUEST['aft_plgn_submit_options'] ) || $error != "") && 145 ( !isset( $_REQUEST['rtp_submit_custom'] ) || $error != "" ) && 146 ( !isset( $_REQUEST['submit-insertion'] ) || $error != "") && 147 ( !isset( $_REQUEST['rtp-install-table'] ) || $error != "") && 148 ( !isset( $_REQUEST['rtp-uninstall-table'] ) || $error != "") ) 145 149 echo "style=\"display:none\""; 146 150 ?>> … … 257 261 </div> 258 262 <div id="rtp-insertion"> 259 <form method="post" action="admin.php?page=<?php echo RTP_PLUGIN_SNAME; ?>#rtp-insertion" enctype="multipart/form-data" > 263 <form method="post" action="admin.php?page=<?php echo RTP_PLUGIN_SNAME; ?>" enctype="multipart/form-data" > 264 <input type="hidden" name="submit-insertion" value="submit" /> 260 265 <div class="rtp-label-top"> 261 <input class="button-secondary" name="submit-insertion"type="submit" value="<?php _e( 'Apply Insertion' ); ?>" />266 <input class="button-secondary" type="submit" value="<?php _e( 'Apply Insertion' ); ?>" /> 262 267 </div> 263 268 <?php if ( $options['aft_insertion'] == 'by-category' ) : ?> … … 269 274 <th><?php _e( 'ID', RTP_PLUGIN_SNAME ); ?></th> 270 275 <th><?php _e( 'Title', RTP_PLUGIN_SNAME ); ?></th> 271 <th><?php _e( 'Description', RTP_PLUGIN_SNAME ); ?></th>272 276 <th><?php _e( 'Slug', RTP_PLUGIN_SNAME ); ?></th> 273 277 </thead> … … 286 290 <input id="aft-category-check-<?php echo $i; ?>" type="checkbox" name="aft-category-check-<?php echo $i; ?>" value="<?php echo $cat_arr->term_id; ?>" <?php if ( $cat_arr->term_id == $cat_opt_id[$i] ) echo 'checked="checked"'; ?> /> 287 291 </th> 288 <td><?php echo $cat_arr->term_id; ?></td> 289 <td><?php echo $cat_arr->name; ?></td> 290 <td><?php echo $cat_arr->description; ?></td> 291 <td><?php echo $cat_arr->slug; ?></td> 292 <td class="rtp-ins-id"><?php echo $cat_arr->term_id; ?></td> 293 <td class="rtp-ins-name"><?php echo $cat_arr->name; ?></td> 294 <td class="rtp-ins-slug"><?php echo $cat_arr->slug; ?></td> 292 295 </tr> 293 296 <?php $i++; ?> 294 297 <?php endforeach; ?> 295 298 </tbody> 299 <tfoot> 300 <tr id="rpt-pager-bycategory" style="text-align: center;"> 301 <td colspan="4"> 302 <img class="first" src="<?php echo RTP_PLUGIN_DIR_IMG; ?>arrow-stop-180.png" /> 303 <img class="prev" src="<?php echo RTP_PLUGIN_DIR_IMG; ?>arrow-180.png" /> 304 <input class="pagedisplay" type="text" readonly="true" /> 305 <img class="next" src="<?php echo RTP_PLUGIN_DIR_IMG; ?>arrow.png" /> 306 <img class="last" src="<?php echo RTP_PLUGIN_DIR_IMG; ?>arrow-stop.png" /> 307 <input type="hidden" class="pagesize" value="10"> 308 </td> 309 </tr> 310 </tfoot> 296 311 </table> 297 <div id="category-navigation"></div>298 <script type="text/javascript">299 var cat_pager = new Pager('insertion-by-category', 10);300 cat_pager.init();301 cat_pager.showPageNav('cat_pager', 'category-navigation');302 cat_pager.showPage(1);303 </script>304 312 <?php elseif ( $options['aft_insertion'] == 'by-page' ) : ?> 305 313 <table id="insertion-by-page" class="tablesorter"> … … 326 334 <input id="aft-page-check-<?php echo $i; ?>" type="checkbox" name="aft-page-check-<?php echo $i; ?>" value="<?php echo $id; ?>" <?php if ( $id == $page_opt_id[$i] ) echo 'checked="checked"'; ?> /> 327 335 </th> 328 <td ><?php echo $page_data->ID; ?></td>329 <td ><?php echo $page_data->post_title; ?></td>330 <td ><?php echo $page_data->post_name; ?></td>336 <td class="rtp-ins-id"><?php echo $page_data->ID; ?></td> 337 <td class="rtp-ins-name"><?php echo $page_data->post_title; ?></td> 338 <td class="rtp-ins-slug"><?php echo $page_data->post_name; ?></td> 331 339 </tr> 332 340 <?php $i++; ?> 333 341 <?php endforeach; ?> 334 342 </tbody> 343 <tfoot> 344 <tr id="rpt-pager-bypage" style="text-align: center;"> 345 <td colspan="4"> 346 <img class="first" src="<?php echo RTP_PLUGIN_DIR_IMG; ?>arrow-stop-180.png" /> 347 <img class="prev" src="<?php echo RTP_PLUGIN_DIR_IMG; ?>arrow-180.png" /> 348 <input class="pagedisplay" type="text" readonly="true" /> 349 <img class="next" src="<?php echo RTP_PLUGIN_DIR_IMG; ?>arrow.png" /> 350 <img class="last" src="<?php echo RTP_PLUGIN_DIR_IMG; ?>arrow-stop.png" /> 351 <input type="hidden" class="pagesize" value="10"> 352 </td> 353 </tr> 354 </tfoot> 335 355 </table> 336 <div id="page-navigation"></div>337 <script type="text/javascript">338 var page_pager = new Pager('insertion-by-page', 10);339 page_pager.init();340 page_pager.showPageNav('page_pager', 'page-navigation');341 page_pager.showPage(1);342 </script>343 356 <?php else: ?> 344 357 <div style="clear: both;"></div> … … 353 366 <th><?php _e( 'ID', RTP_PLUGIN_SNAME ); ?></th> 354 367 <th><?php _e( 'Title', RTP_PLUGIN_SNAME ); ?></th> 355 <th><?php _e( 'Description', RTP_PLUGIN_SNAME ); ?></th>356 368 <th><?php _e( 'Slug', RTP_PLUGIN_SNAME ); ?></th> 357 369 </thead> … … 370 382 <input id="aft-category-check-<?php echo $i; ?>" type="checkbox" name="aft-category-check-<?php echo $i; ?>" value="<?php echo $cat_arr->term_id; ?>" <?php if ( $cat_arr->term_id == $cat_opt_id[$i] ) echo 'checked="checked"'; ?> /> 371 383 </th> 372 <td><?php echo $cat_arr->term_id; ?></td> 373 <td><?php echo $cat_arr->name; ?></td> 374 <td><?php echo $cat_arr->description; ?></td> 375 <td><?php echo $cat_arr->slug; ?></td> 384 <td class="rtp-ins-id"><?php echo $cat_arr->term_id; ?></td> 385 <td class="rtp-ins-name"><?php echo $cat_arr->name; ?></td> 386 <td class="rtp-ins-slug"><?php echo $cat_arr->slug; ?></td> 376 387 </tr> 377 388 <?php $i++; ?> 378 389 <?php endforeach; ?> 379 390 </tbody> 391 <tfoot> 392 <tr id="rpt-pager-category" style="text-align: center;"> 393 <td colspan="4"> 394 <img class="first" src="<?php echo RTP_PLUGIN_DIR_IMG; ?>arrow-stop-180.png" /> 395 <img class="prev" src="<?php echo RTP_PLUGIN_DIR_IMG; ?>arrow-180.png" /> 396 <input class="pagedisplay" type="text" readonly="true" /> 397 <img class="next" src="<?php echo RTP_PLUGIN_DIR_IMG; ?>arrow.png" /> 398 <img class="last" src="<?php echo RTP_PLUGIN_DIR_IMG; ?>arrow-stop.png" /> 399 <input type="hidden" class="pagesize" value="10"> 400 </td> 401 </tr> 402 </tfoot> 380 403 </table> 381 <div id="category-navigation"></div>382 404 </fieldset> 383 <script type="text/javascript">384 var cat_pager = new Pager('insertion-category', 10);385 cat_pager.init();386 cat_pager.showPageNav('cat_pager', 'category-navigation');387 cat_pager.showPage(1);388 </script>389 405 </div> 390 <br />391 406 <div> 392 407 <fieldset> … … 415 430 <input id="aft-page-check-<?php echo $i; ?>" type="checkbox" name="aft-page-check-<?php echo $i; ?>" value="<?php echo $page_data->ID; ?>" <?php if ( $page_data->ID == $page_opt_id[$i] ) echo 'checked="checked"'; ?> /> 416 431 </th> 417 <td ><?php echo $page_data->ID; ?></td>418 <td ><?php echo $page_data->post_title; ?></td>419 <td ><?php echo $page_data->post_name; ?></td>432 <td class="rtp-ins-id"><?php echo $page_data->ID; ?></td> 433 <td class="rtp-ins-name"><?php echo $page_data->post_title; ?></td> 434 <td class="rtp-ins-slug"><?php echo $page_data->post_name; ?></td> 420 435 </tr> 421 436 <?php $i++; ?> 422 437 <?php endforeach; ?> 423 438 </tbody> 439 <tfoot> 440 <tr id="rpt-pager-page" style="text-align: center;"> 441 <td colspan="4"> 442 <img class="first" src="<?php echo RTP_PLUGIN_DIR_IMG; ?>arrow-stop-180.png" /> 443 <img class="prev" src="<?php echo RTP_PLUGIN_DIR_IMG; ?>arrow-180.png" /> 444 <input class="pagedisplay" type="text" readonly="true" /> 445 <img class="next" src="<?php echo RTP_PLUGIN_DIR_IMG; ?>arrow.png" /> 446 <img class="last" src="<?php echo RTP_PLUGIN_DIR_IMG; ?>arrow-stop.png" /> 447 <input type="hidden" class="pagesize" value="10"> 448 </td> 449 </tr> 450 </tfoot> 424 451 </table> 425 <div id="page-navigation"></div>426 452 </fieldset> 427 <script type="text/javascript">428 var page_pager = new Pager('insertion-page', 10);429 page_pager.init();430 page_pager.showPageNav('page_pager', 'page-navigation');431 page_pager.showPage(1);432 </script>433 453 </div> 434 454 <?php endif; ?> 435 455 <div class="rtp-label-top"> 436 <input class="button-secondary" name="submit-insertion"type="submit" value="<?php _e( 'Apply Insertion' ); ?>" />456 <input class="button-secondary" type="submit" value="<?php _e( 'Apply Insertion' ); ?>" /> 437 457 </div> 438 458 </form> … … 447 467 } 448 468 ?> 449 <form method="post" action="admin.php?page=<?php echo RTP_PLUGIN_SNAME; ?> #rtp-reporting">469 <form method="post" action="admin.php?page=<?php echo RTP_PLUGIN_SNAME; ?>"> 450 470 <div class="rtp-label-top"> 451 471 <?php _e( 'Filter By', RTP_PLUGIN_SNAME ); ?>: … … 474 494 <th><?php _e( $lbl_wellwritten, RTP_PLUGIN_SNAME ); ?></th> 475 495 <?php if ( $_POST['aft-filter'] != 'last-update' ) : ?> 476 <th><?php _e( ' Ave. Rating', RTP_PLUGIN_SNAME ); ?></th>496 <th><?php _e( 'Ratings', RTP_PLUGIN_SNAME ); ?></th> 477 497 <?php else : ?> 478 498 <th><?php _e( 'Date Modified', RTP_PLUGIN_SNAME ); ?></th> … … 485 505 <tr valign="top"> 486 506 <td><?php echo $rows->post_id; ?></td> 487 <td >507 <td class="rtp-rpt-name"> 488 508 <div class="rtp-title"> 489 509 <a class="rtp-post-title" href="<?php echo admin_url(); ?>post.php?post=<?php echo $rows->post_id ?>&action=edit"><?php echo $rows->post_title; ?></a> 490 510 </div> 491 511 </td> 492 <td><?php echo $rows->trustworthy_rate; ?></td> 493 <td><?php echo $rows->objective_rate; ?></td> 494 <td><?php echo $rows->complete_rate; ?></td> 495 <td><?php echo $rows->wellwritten_rate; ?></td> 512 <td class="rtp-rpt-rate"> 513 [<strong><?php echo max('0.00', $rows->trustworthy_rate); ?></strong>] Rate / 514 <br />[<strong><?php echo rtp_count_rated_item($rows->post_id, 'trustworthy_rate' ); ?></strong>] Count 515 </td> 516 <td class="rtp-rpt-rate"> 517 [<strong><?php echo max('0.00', $rows->objective_rate); ?></strong>] Rate / 518 <br />[<strong><?php echo rtp_count_rated_item($rows->post_id, 'objective_rate' ); ?></strong>] Count 519 </td> 520 <td class="rtp-rpt-rate"> 521 [<strong><?php echo max('0.00', $rows->complete_rate); ?></strong>] Rate / 522 <br />[<strong><?php echo rtp_count_rated_item($rows->post_id, 'complete_rate' ); ?></strong>] Count 523 </td> 524 <td class="rtp-rpt-rate"> 525 [<strong><?php echo max('0.00', $rows->wellwritten_rate); ?></strong>] Rate / 526 <br />[<strong><?php echo rtp_count_rated_item($rows->post_id, 'wellwritten_rate' ); ?></strong>] Count 527 </td> 496 528 <?php if ( $_POST['aft-filter'] != 'last-update' ) : ?> 497 <td><?php echo $rows->rate_average; ?></td> 529 <td class="rtp-rpt-average"> 530 [<strong><?php echo $rows->rate_average; ?></strong>] Ave. / 531 <br />[<strong><?php echo rtp_count_rated_item($rows->post_id, array('trustworthy_rate', 'objective_rate', 'complete_rate', 'wellwritten_rate') ); ?></strong>] Count 532 </td> 498 533 <?php else : ?> 499 534 <td><?php echo $rows->rate_modified; ?></td> … … 503 538 <?php endif; ?> 504 539 </tbody> 540 <tfoot> 541 <tr id="rpt-pager-report" style="text-align: center;"> 542 <td colspan="7"> 543 <img class="first" src="<?php echo RTP_PLUGIN_DIR_IMG; ?>arrow-stop-180.png" /> 544 <img class="prev" src="<?php echo RTP_PLUGIN_DIR_IMG; ?>arrow-180.png" /> 545 <input class="pagedisplay" type="text" readonly="true" /> 546 <img class="next" src="<?php echo RTP_PLUGIN_DIR_IMG; ?>arrow.png" /> 547 <img class="last" src="<?php echo RTP_PLUGIN_DIR_IMG; ?>arrow-stop.png" /> 548 <input type="hidden" class="pagesize" value="10"> 549 </td> 550 </tr> 551 </tfoot> 505 552 </table> 506 <div id="pagenavigation"></div>507 553 </form> 508 <script type="text/javascript">509 var pager = new Pager('report-result', 10);510 pager.init();511 pager.showPageNav('pager', 'pagenavigation');512 pager.showPage(1);513 </script>514 554 </div> 515 555 <div style="clear: both;"></div> … … 524 564 <div id="rtp-db-configuration"> 525 565 <div> 526 <form method="post" action="admin.php?page=<?php echo RTP_PLUGIN_SNAME; ?> #rtp-db-configuration" enctype="multipart/form-data">566 <form method="post" action="admin.php?page=<?php echo RTP_PLUGIN_SNAME; ?>" enctype="multipart/form-data"> 527 567 <table class="rtp-form-table"> 528 568 <tr> … … 550 590 <?php if ( $wpdb->get_var("SHOW TABLES LIKE '$tbl_feedbacks'") != $tbl_feedbacks 551 591 && $wpdb->get_var("SHOW TABLES LIKE '$tbl_feedbacks_summary'") != $tbl_feedbacks_summary ) : ?> 552 <p class='rtp-p rtp-bg corners'>< b><?php _e( 'Warning', RTP_PLUGIN_SNAME ); ?>:<b><br />553 < i><?php _e( "No tables found inside the database.<br />592 <p class='rtp-p rtp-bg corners'><strong><?php _e( 'Warning', RTP_PLUGIN_SNAME ); ?>:</strong><br /> 593 <em><?php _e( "No tables found inside the database.<br /> 554 594 Please go to Database Configuration Tab then (Click Install) to install 555 the required database tables.", RTP_PLUGIN_SNAME ); ?></ i></p>595 the required database tables.", RTP_PLUGIN_SNAME ); ?></em></p> 556 596 <?php endif; ?> 557 597 </div> -
rate-this-page-plugin/trunk/rtp-hooks.php
r476197 r479087 54 54 wp_enqueue_script( 'jquery-tablesorter', RTP_PLUGIN_DIR_JS . 'jquery.tablesorter.min.js', array( 'jquery' ) ); 55 55 wp_enqueue_script( 'jquery-tablesorter-pager', RTP_PLUGIN_DIR_JS . 'jquery.tablesorter.pager.js', array('jquery' ) ); 56 wp_enqueue_script( 'jquery- paging', RTP_PLUGIN_DIR_JS . 'paging.js', array( 'jquery' ) );56 wp_enqueue_script( 'jquery-ui-cookie', RTP_PLUGIN_DIR_JS . 'external/jquery.cookie.js', array( 'jquery' ) ); 57 57 } else { 58 58 //Initialize jQuery Raty script -
rate-this-page-plugin/trunk/rtp-query.php
r439968 r479087 104 104 $is_page = $aft_data['is_page']; // Identify if the summary stored is a page rated summary. 105 105 106 $count_trustworthy = 1; 107 $count_objective = 1; 108 $count_complete = 1; 109 $count_wellwritten = 1; 106 // Counting the # of user who rated the posts/pages based on each items. 107 $count_trustworthy = rtp_count_rated_item( $post_id, 'trustworthy_rate' ); 108 $count_objective = rtp_count_rated_item( $post_id, 'objective_rate' ); 109 $count_complete = rtp_count_rated_item( $post_id, 'complete_rate' ); 110 $count_wellwritten = rtp_count_rated_item( $post_id, 'wellwritten_rate' ); 110 111 111 112 // Check if post_id already exist in wp_feedbacks_summary table. … … 147 148 $total_wellwritten = intval($aft_fetch_data->total_wellwritten + $temp_total); 148 149 } 149 150 $count_trustworthy = $aft_fetch_data->count_trustworthy;151 $count_objective = $aft_fetch_data->count_objective;152 $count_complete = $aft_fetch_data->count_complete;153 $count_wellwritten = $aft_fetch_data->count_wellwritten;154 150 } else { 155 151 $total_trustworthy = intval($aft_fetch_data->total_trustworthy + $aft_data['trustworthy_rate']); … … 157 153 $total_complete = intval($aft_fetch_data->total_complete + $aft_data['complete_rate']); 158 154 $total_wellwritten = intval($aft_fetch_data->total_wellwritten + $aft_data['wellwritten_rate']); 159 160 $count_trustworthy += $aft_fetch_data->count_trustworthy;161 $count_objective += $aft_fetch_data->count_objective;162 $count_complete += $aft_fetch_data->count_complete;163 $count_wellwritten += $aft_fetch_data->count_wellwritten;164 155 } 165 156 } … … 216 207 global $wpdb; 217 208 209 $_sql = "SELECT post_id, post_title, 210 CAST((total_trustworthy / count_trustworthy) AS decimal(3,2)) AS trustworthy_rate, 211 CAST((total_objective / count_objective) AS decimal(3,2)) AS objective_rate, 212 CAST((total_complete / count_complete) AS decimal(3,2)) AS complete_rate, 213 CAST((total_wellwritten / count_wellwritten) AS decimal(3,2)) AS wellwritten_rate, rate_average 214 FROM %sfeedbacks_summary "; 215 218 216 switch ( $filter ) { 219 217 case "highest": 220 $_sql = "SELECT post_id, post_title, 221 CAST((total_trustworthy / count_trustworthy) AS decimal(3,2)) AS trustworthy_rate , 222 CAST((total_objective / count_objective) AS decimal(3,2)) AS objective_rate, 223 CAST((total_complete / count_complete) AS decimal(3,2)) AS complete_rate, 224 CAST((total_wellwritten / count_wellwritten) AS decimal(3,2)) AS wellwritten_rate, rate_average 225 FROM %sfeedbacks_summary 226 INNER JOIN $wpdb->posts ON $wpdb->posts.id = %sfeedbacks_summary.post_id 218 $_sql .= "INNER JOIN $wpdb->posts ON $wpdb->posts.id = %sfeedbacks_summary.post_id 227 219 WHERE rate_average >= 3.5"; 228 220 if ( $insertion == 'page' ) { … … 235 227 break; 236 228 case "lowest": 237 $_sql = "SELECT post_id, post_title, 238 CAST((total_trustworthy / count_trustworthy) AS decimal(3,2)) AS trustworthy_rate , 239 CAST((total_objective / count_objective) AS decimal(3,2)) AS objective_rate, 240 CAST((total_complete / count_complete) AS decimal(3,2)) AS complete_rate, 241 CAST((total_wellwritten / count_wellwritten) AS decimal(3,2)) AS wellwritten_rate, rate_average 242 FROM %sfeedbacks_summary 243 INNER JOIN $wpdb->posts ON $wpdb->posts.id = %sfeedbacks_summary.post_id 244 WHERE rate_average <= 3.5"; 229 $_sql .= "INNER JOIN $wpdb->posts ON $wpdb->posts.id = %sfeedbacks_summary.post_id 230 WHERE rate_average <= 3.4"; 245 231 if ( $insertion == 'page' ) { 246 232 $_sql .= " AND is_page = 'true'"; … … 269 255 case "all": 270 256 default: 271 $_sql = "SELECT post_id, post_title, 272 CAST((total_trustworthy / count_trustworthy) AS decimal(3,2)) AS trustworthy_rate , 273 CAST((total_objective / count_objective) AS decimal(3,2)) AS objective_rate, 274 CAST((total_complete / count_complete) AS decimal(3,2)) AS complete_rate, 275 CAST((total_wellwritten / count_wellwritten) AS decimal(3,2)) AS wellwritten_rate, rate_average 276 FROM %sfeedbacks_summary 277 INNER JOIN $wpdb->posts ON $wpdb->posts.id = %sfeedbacks_summary.post_id"; 257 $_sql .= "INNER JOIN $wpdb->posts ON $wpdb->posts.id = %sfeedbacks_summary.post_id"; 278 258 if ( $insertion == 'page' ) { 279 259 $_sql .= " WHERE is_page = 'true'"; … … 334 314 } 335 315 } 316 317 if ( !function_exists( 'rtp_count_rated_item' ) ) { 318 function rtp_count_rated_item( $post_id, $field_name, $field_value = '' ) { 319 global $wpdb; 320 321 if ( !is_array( $field_name ) ) { 322 $sql = "SELECT COUNT(%s) AS count 323 FROM %sfeedbacks 324 WHERE post_id = %d"; 325 326 if ( empty( $field_value ) ) { 327 $sql .= " AND %s > 0"; 328 $data = $wpdb->get_row( sprintf( $sql, $field_name, $wpdb->prefix, $post_id, $field_name ) ); 329 } 330 331 return $data->count; 332 } else { 333 $sql = "SELECT COUNT(%s) AS count_trustworthy, 334 COUNT(%s) AS count_objective, 335 COUNT(%s) AS count_complete, 336 COUNT(%s) AS count_wellwritten 337 FROM %sfeedbacks 338 WHERE post_id = %d"; 339 340 $data = $wpdb->get_row( sprintf( 341 $sql, 342 $field_name[0], 343 $field_name[1], 344 $field_name[2], 345 $field_name[3], 346 $wpdb->prefix, 347 $post_id ) ); 348 349 $data_arr = array( $data->count_trustworthy, 350 $data->count_objective, 351 $data->count_complete, 352 $data->count_wellwritten ); 353 354 return array_sum( $data_arr ) / count( $data_arr ); 355 } 356 } 357 } 336 358 ?>
Note: See TracChangeset
for help on using the changeset viewer.