merge in WP 2.7 theme changes
[opensuse:lizards_o_o.git] / wp-content / plugins / postratings / postratings-admin-ajax.php
1 <?php\r
2 /*\r
3 +----------------------------------------------------------------+\r
4 |                                                                                                                                                                                       |\r
5 |       WordPress 2.1 Plugin: WP-PostRatings 1.20                                                               |\r
6 |       Copyright (c) 2007 Lester "GaMerZ" Chan                                                                 |\r
7 |                                                                                                                                                                                       |\r
8 |       File Written By:                                                                                                                                        |\r
9 |       - Lester "GaMerZ" Chan                                                                                                                  |\r
10 |       - http://lesterchan.net                                                                                                                 |\r
11 |                                                                                                                                                                                       |\r
12 |       File Information:                                                                                                                                       |\r
13 |       - Post Ratings AJAX For Admin Backend                                                                   |\r
14 |       - wp-content/plugins/postratings/postratings-admin-ajax.php             |\r
15 |                                                                                                                                                                                       |\r
16 +----------------------------------------------------------------+\r
17 */\r
18 \r
19 \r
20 ### Include wp-config.php\r
21 @require('../../../wp-config.php');\r
22 \r
23 \r
24 ### Check Whether User Can Manage Ratings\r
25 if(!current_user_can('manage_ratings')) {\r
26         die('Access Denied');\r
27 }\r
28 \r
29 \r
30 ### Variables\r
31 $postratings_url = get_option('siteurl').'/wp-content/plugins/postratings/images';\r
32 $postratings_path = ABSPATH.'/wp-content/plugins/postratings/images';\r
33 $postratings_ratingstext = get_option('postratings_ratingstext');\r
34 $postratings_ratingsvalue = get_option('postratings_ratingsvalue');\r
35 \r
36 \r
37 ### Form Processing\r
38 $postratings_customrating = intval($_GET['custom']);\r
39 $postratings_image = trim($_GET['image']);\r
40 $postratings_max = intval($_GET['max']);\r
41 \r
42 \r
43 ### If It Is A Up/Down Rating\r
44 if($postratings_customrating && $postratings_max == 2) {\r
45         $postratings_ratingsvalue[0] = -1;\r
46         $postratings_ratingsvalue[1] = 1;\r
47         $postratings_ratingstext[0] = __('Vote This Post Down', 'wp-postratings');\r
48         $postratings_ratingstext[1] = __('Vote This Post Up', 'wp-postratings');\r
49 } else {\r
50         for($i = 0; $i < $postratings_max; $i++) {\r
51                 if($i > 0) {\r
52                         $postratings_ratingstext[$i] = sprintf(__('%s Stars', 'wp-postratings'), $i+1);\r
53                 } else {\r
54                         $postratings_ratingstext[$i] = sprintf(__('%s Star', 'wp-postratings'), $i+1);\r
55                 }\r
56                 $postratings_ratingsvalue[$i] = $i+1;\r
57         }\r
58 }\r
59 ?>\r
60 <table width="80%"  border="0" cellspacing="3" cellpadding="3">                 \r
61         <tr>\r
62                 <td><strong>Rating Image</strong></td>\r
63                 <td><strong>Rating Text</strong></td>\r
64                 <td><strong>Rating Value</strong></td>\r
65         </tr>\r
66         <?php\r
67                 for($i = 1; $i <= $postratings_max; $i++) {\r
68                         $postratings_text = stripslashes($postratings_ratingstext[$i-1]);\r
69                         $postratings_value = $postratings_ratingsvalue[$i-1];\r
70                         if($postratings_value > 0) {\r
71                                 $postratings_value = '+'.$postratings_value;\r
72                         }\r
73                         echo '<tr>'."\n";\r
74                         echo '<td>'."\n";\r
75                         if(file_exists($postratings_path.'/'.$postratings_image.'/rating_start.gif')) {\r
76                                 echo '<img src="'.$postratings_url.'/'.$postratings_image.'/rating_start.gif" alt="rating_start.gif" class="post-ratings-image" />';\r
77                         }\r
78                         if($postratings_customrating) {\r
79                                 if($postratings_max == 2) {\r
80                                         echo '<img src="'.$postratings_url.'/'.$postratings_image.'/rating_'.$i.'_on.gif" alt="rating_'.$i.'_on.gif" class="post-ratings-image" />';\r
81                                 } else {\r
82                                         for($j = 1; $j < ($i+1); $j++) {\r
83                                                 echo '<img src="'.$postratings_url.'/'.$postratings_image.'/rating_'.$j.'_on.gif" alt="rating_on.gif" class="post-ratings-image" />';\r
84                                         }\r
85                                 }\r
86                         } else {\r
87                                 for($j = 1; $j < ($i+1); $j++) {\r
88                                         echo '<img src="'.$postratings_url.'/'.$postratings_image.'/rating_on.gif" alt="rating_on.gif" class="post-ratings-image" />';\r
89                                 }\r
90                         }\r
91                         if(file_exists($postratings_path.'/'.$postratings_image.'/rating_end.gif')) {\r
92                                 echo '<img src="'.$postratings_url.'/'.$postratings_image.'/rating_end.gif" alt="rating_end.gif" class="post-ratings-image" />';\r
93                         }\r
94                         echo '</td>'."\n";\r
95                         echo '<td>'."\n";\r
96                         echo '<input type="text" id="postratings_ratingstext_'.$i.'" name="postratings_ratingstext[]" value="'.$postratings_text.'" size="20" maxlength="50" />'."\n";\r
97                         echo '</td>'."\n";\r
98                         echo '<td>'."\n";\r
99                         echo '<input type="text" id="postratings_ratingsvalue_'.$i.'" name="postratings_ratingsvalue[]" value="'.$postratings_value.'" size="2" maxlength="2" />'."\n";\r
100                         echo '</td>'."\n";\r
101                         echo '</tr>'."\n";\r
102                 }                                                               \r
103         ?>\r
104 </table>\r
105 <?php exit(); ?>