source: trunk/content/plugins/updown_voting/templates/updown_voting_button.php @ 1375

Revision 1375, 5.0 KB checked in by nick_ramsay, 3 years ago (diff)

[Trunk] Hotaru 1.1.3 [Run upgrade script]

Line 
1<?php
2/**
3 * Vote Button
4 *
5 * PHP version 5
6 *
7 * LICENSE: Hotaru CMS is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * Hotaru CMS is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with Hotaru CMS. If not, see http://www.gnu.org/licenses/.
18 *
19 * @category  Content Management System
20 * @package   HotaruCMS
21 * @author    Nick Ramsay <admin@hotarucms.org>
22 * @copyright Copyright (c) 2009, Hotaru CMS
23 * @license   http://www.gnu.org/copyleft/gpl.html GNU General Public License
24 * @link      http://www.hotarucms.org/
25
26The following code looks pretty ugly, but it's not quite as confusing as it first appears. Basically, it's in two blocks, one for "vote" and one for "un-vote". The reason it's so bulky is because we want users to be able to change their vote, so after voting, we need to enable the "un-vote" button and vice-versa. This is done by having two copies of the text blocks and switching the display to show or hide them.
27*/
28
29//$user_ip = $h->cage->server->testIp('REMOTE_ADDR');
30
31// Determine the status of the post so we can apply different css to top and new vote buttons:
32$status = $h->post->status;
33if ($status != 'top' && $status != 'new') { $status = 'new'; }  // used on next line to default to a blue button
34$vote_button_type = 'vote_color_' . $status;  // for css difference between top and new stories
35?>
36 
37<!-- Vote Button -->
38<div class='vote_button'>
39
40
41<!-- ********* VOTE UP LINK ************ -->
42<?php if ($h->currentUser->loggedIn && (!$h->vars['voted'] || $h->vars['voted'] < 0)) { ?>
43    <!-- Logged in and not voted yet or previously voted down-->
44   
45    <!-- Shown -->
46    <div id='text_vote_top_<?php echo $h->post->id; ?>' class='vote_button_top'>
47        <a href="#" onclick="vote( <?php echo $h->post->id; ?>, 10); return false;"><b><?php echo $h->lang["vote_button_vote_up"]; ?></b></a>
48    </div>   
49   
50    <!-- Hidden -->
51    <div id='text_voted_top_<?php echo $h->post->id; ?>' class='vote_button_top' style="display: none;">
52        <?php echo $h->lang["vote_button_voted"]; ?>
53    </div>       
54   
55<?php } elseif ($h->currentUser->loggedIn && ($h->vars['voted'] > 0)) { ?>
56    <!-- Logged in and already voted up -->
57   
58    <!-- Hidden -->
59    <div id='text_vote_top_<?php echo $h->post->id; ?>' class='vote_button_top' style="display: none;">
60        <a href="#" onclick="vote(<?php echo $h->post->id; ?>, 10); return false;"><b><?php echo $h->lang["vote_button_vote_up"]; ?></b></a>
61    </div>
62   
63    <!-- Shown -->
64    <div id='text_voted_top_<?php echo $h->post->id; ?>' class='vote_button_top'>
65        <?php echo $h->lang["vote_button_voted"]; ?>
66    </div>
67   
68<?php } else { ?>
69    <!-- Need to login -->
70   
71    <div id='text_login_<?php echo $h->post->id; ?>' class='vote_button_top'>
72        <a href="<?php echo $h->vars['vote_login_url']; ?>"><?php echo $h->lang["vote_button_vote_up"]; ?></a>
73    </div>
74<?php } ?>
75
76
77<!-- ********* VOTE COUNT ************ -->
78<div id='votes_<?php echo $h->post->id; ?>' class='vote_button_count  <?php echo $vote_button_type; ?>'><?php echo $h->vars['votesUp']; ?></div>
79
80
81<!-- ********* VOTE DOWN LINK ************ -->
82<?php if ($h->currentUser->loggedIn && (!$h->vars['voted'] || $h->vars['voted'] > 0)) { ?>
83    <!-- Logged in and not voted yet or previously voted up -->
84   
85    <!-- Shown -->
86    <div id='text_vote_down_<?php echo $h->post->id; ?>' class='vote_button_bottom'>
87        <a href="#" onclick="vote( <?php echo $h->post->id; ?>, -10); return false;"><b><?php echo $h->lang["vote_button_vote_down"]; ?></b></a>
88    </div>   
89   
90    <!-- Hidden -->
91    <div id='text_voted_down_<?php echo $h->post->id; ?>' class='vote_button_bottom' style="display: none;">
92        <?php echo $h->lang["vote_button_voted"]; ?>
93    </div>       
94   
95<?php } elseif ($h->currentUser->loggedIn && ($h->vars['voted'] < 0)) { ?>
96    <!-- Logged in and already voted down -->
97   
98    <!-- Hidden -->
99    <div id='text_vote_down_<?php echo $h->post->id; ?>' class='vote_button_bottom' style="display: none;">
100        <a href="#" onclick="vote(<?php echo $h->post->id; ?>, -10); return false;"><b><?php echo $h->lang["vote_button_vote_down"]; ?></b></a>
101    </div>
102   
103    <!-- Shown -->
104    <div id='text_voted_down_<?php echo $h->post->id; ?>' class='vote_button_bottom'>
105        <?php echo $h->lang["vote_button_voted"]; ?>
106    </div>
107   
108<?php } else { ?>
109    <!-- Need to login -->
110   
111    <div id='text_login_<?php echo $h->post->id; ?>' class='vote_button_bottom'>
112        <a href="<?php echo $h->vars['vote_login_url']; ?>"><?php echo $h->lang["vote_button_vote_down"]; ?></a>
113    </div>
114<?php } ?>
115
116
117</div>
Note: See TracBrowser for help on using the repository browser.