HomeHelpTrac

source: tags/6.1/rate.php @ 10242

Revision 10242, 7.8 KB checked in by Alexander Trofimov, 3 years ago (diff)

dolphin 6.1.5, initial commit

Line 
1<?
2
3/***************************************************************************
4*                            Dolphin Smart Community Builder
5*                              -----------------
6*     begin                : Mon Mar 23 2006
7*     copyright            : (C) 2006 BoonEx Group
8*     website              : http://www.boonex.com/
9* This file is part of Dolphin - Smart Community Builder
10*
11* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
12* http://creativecommons.org/licenses/by/3.0/
13*
14* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15* without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16* See the Creative Commons Attribution 3.0 License for more details.
17* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
18* see license.txt file; if not, write to marketing@boonex.com
19***************************************************************************/
20
21require_once( 'inc/header.inc.php' );
22require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
23require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
24require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
25
26require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolMediaQuery.php' );
27
28// --------------- page variables and login
29
30$_page['name_index']    = 26;
31$_page['css_name']      = 'upload_media.css';
32$_ni = $_page['name_index'];
33
34check_logged();
35
36$max_thumb_width  = (int)getParam( 'max_thumb_width' );
37$max_thumb_height = (int)getParam( 'max_thumb_height' );
38
39$_page['header'] = _t( "_HOTORNOT_H" );
40$_page['header_text'] = _t( "_HOTORNOT_H1" );
41
42
43// --------------- GET/POST actions
44
45$_ni = $_page['name_index'];
46$_page_cont[$_ni]['page_main_code'] = PageCompPageMainCode();
47
48
49PageCode();
50
51
52function PageCompPageMainCode() {
53    global $site;
54    global $oTemplConfig;
55
56    $aPhoto = getVotingItem();
57
58    $check_res = checkAction( $_COOKIE['memberID'], ACTION_ID_RATE_PHOTOS );
59    if ( $check_res[CHECK_ACTION_RESULT] != CHECK_ACTION_RESULT_ALLOWED )
60    {
61        $ret = '
62            <table width="100%" cellpadding="4" cellspacing="4" border="0">
63                <tr>
64                    <td align="center">' . $check_res[CHECK_ACTION_MESSAGE] . '</td>
65                </tr>
66            </table>';
67        return $ret;
68    }
69   
70    $ret = '';
71
72    if ($_GET['prev_id'])
73        $ret .= showPreviousRated((int)$_GET['prev_id']);
74
75    if( $oTemplConfig -> customize['rate']['showSexSelector'] )
76    {
77        $ret .= '<div class="rate_sex_form">';
78        $ret .= '<form method="post" name="FormVote" action="' . $_SERVER['PHP_SELF'] . '">';
79            $ret .= '<span>';
80            $ret .= _t("_Show me");
81            $ret .= '</span>';
82            $ret .= '<span>';
83           
84            $ret .= '<select name="showme" onchange="document.forms[\'FormVote\'].submit()">' . "\n";
85                $selected_all = ( $_REQUEST['showme'] == 'all' || strlen(trim($_REQUEST['showme'])) == 0 ) ? ' selected="selected" ' : '';
86                $ret .= '<option value="all"'. $selected_all . '>' . _t("_all") . '</option>';
87                $ret .= SelectOptions( 'Sex', $_REQUEST['showme'] );
88            $ret .= '</select>';
89            $ret .= '</span>';
90            $ret .= '</form>';
91        $ret .= '</div>';
92    }
93
94    if( empty( $aPhoto ) )
95    {
96        $ret .= _t_action('_there_is_no_photo_that_you_can_rate');
97    }
98    else
99    {
100        if( $oTemplConfig -> customize['rate']['showProfileInfo'] )
101        {
102            $ret .= '<div class="clear_both"></div>';
103            $ret .= ProfileDetails( $aPhoto['med_prof_id'] );
104            $ret .= '<div class="clear_both"></div>';
105        }
106       
107        $ret .= getRatingPhoto( $aPhoto );
108
109        $oVotingView = new BxTemplVotingView ('media', (int)$aPhoto['med_id']);
110        if( $oVotingView->isEnabled())
111        {
112            $sUrlAdd = '';
113            if ($_REQUEST['showme'])
114                $sUrlAdd .= 'showme='.$_REQUEST['showme'].'&';
115
116            $ret .= "
117                <script>
118                    BxDolVoting.prototype.onvote = function (fRate, iCount)
119                    {
120                        document.location = '{$site['url']}rate.php?{$sUrlAdd}prev_id=' + this._iObjId;
121                    }
122                    BxDolVoting.prototype.onvotefail = function ()
123                    {
124                        document.location = '{$site['url']}rate.php?{$sUrlAdd}prev_id=' + this._iObjId;
125                    }
126                </script>";
127
128            $ret .= '<div style="margin-left:55px">' . $oVotingView->getBigVoting () . '</div>';
129        }
130    }
131
132    return $ret;
133}
134
135function getVotingItem() {
136    if ( strlen($_REQUEST['showme']) && $_REQUEST['showme'] != 'all' ) {
137        $sSexOnly = process_db_input($_REQUEST['showme']);
138    }
139    $sVoted = getVotedItems();
140    $oMediaQuery = new BxDolMediaQuery();
141    $oDolVoting = new BxDolVoting ('media', 0, 0);
142    return $oMediaQuery -> selectVotingItem( $oDolVoting, $sVoted, $sSexOnly );
143
144}
145
146function VotingTrack( $iMediaID )
147{
148    $oMediaQuery = new BxDolMediaQuery();
149    $iMediaID = (int)$iMediaID;
150    $ip = getVisitorIP();
151    $oMediaQuery -> insertVotingTrack( $iMediaID, $ip );
152}
153
154function getVotedItems()
155{
156    $ip = getVisitorIP();
157
158    $oDolVoting = new BxDolVoting ('media', 0, 0);
159    $_aVotedItems = $oDolVoting -> getVotedItems ($ip);
160    $aVotedItems = reviewArray( $_aVotedItems );   
161
162    return $aVotedItems;
163}
164
165function reviewArray( $arrays )
166{
167    $line = '';
168    foreach($arrays as $array)
169    {
170        $line .= '\'' . $array['med_id'] . '\',';
171    }
172    $line .= '\'\'';
173    return $line;
174}
175
176function getRatingPhoto( $aPhoto )
177{
178    global $max_photo_width, $max_photo_height, $dir, $site;
179
180    $sFileSrc = $dir['profileImage'] . $aPhoto['med_prof_id'] . '/photo_' . $aPhoto['med_file'];
181    if( extFileExists($sFileSrc) )
182    {
183        $sPhotoUrl = $site['profileImage'] . $aPhoto['med_prof_id'] . '/photo_' . $aPhoto['med_file'];
184    }
185    else
186    {
187        header('Location:' . $_SERVER['PHP_SELF']);
188    }
189
190
191    $ret = '';
192
193    $ret .= '<div class="mediaTitle">';
194        $ret .= process_line_output( $aPhoto['med_title'] );
195    $ret .= '</div>';
196    $ret .= '<div class="photoBlock" style="text-align:center;">';
197        $ret .= '<img alt="" src="' . getTemplateIcon('spacer.gif') . '" style="width:' . $max_photo_width . 'px; height:' . $max_photo_height . 'px; background-image:url(' . $sPhotoUrl . ');" class="photo" />';
198    $ret .= '</div>';
199
200
201    return $ret;
202}
203
204
205
206function showPreviousRated( $iPhotoID )
207{
208    global $site;
209    global $oTemplConfig;
210    global $max_thumb_width;
211    global $max_thumb_height;
212   
213    $iBarWidth = $oTemplConfig -> iRateSmallRatingBar;
214    $iBarNum   = $oTemplConfig -> iRateSmallRatingBarNum;
215   
216    $query = "
217        SELECT
218            `media`.`med_id`,
219            `med_prof_id`,
220            `med_file`,
221            `med_title`,
222            `med_rating_count`,
223            `med_rating_sum`,
224            `Profiles`.`NickName`
225        FROM `media`
226        LEFT JOIN `media_rating` USING (`med_id`)
227        LEFT JOIN `Profiles` ON
228            (`Profiles`.`ID`=`media`.`med_prof_id`)
229        WHERE
230            `med_status` = 'active'
231            AND `media`.`med_id` = $iPhotoID
232        ";
233   
234    $ph_arr = db_arr( $query );
235    if( !$ph_arr )
236        return '';
237   
238   
239    $urlImg = "{$site['profileImage']}{$ph_arr['med_prof_id']}/thumb_{$ph_arr['med_file']}";
240    $urlSpacer = getTemplateIcon( 'spacer.gif' );
241   
242    $sProfLink = getProfileLink($ph_arr['med_prof_id']);
243
244    $sRatingBar = '';
245    $oVotingView = new BxTemplVotingView ('media', (int)$iPhotoID);
246    if( $oVotingView->isEnabled())
247        $sRatingBar = $oVotingView->getSmallVoting (false);
248
249   
250
251    $ret .= <<<EOJ
252    <div class="rate_prev_photo_block">
253        <div class="thumbnail_block" style="float:none;">
254            <a href="{$site['url']}photos_gallery.php?ID={$ph_arr['med_prof_id']}&amp;photoID={$ph_arr['med_id']}" title="{$ph_arr['med_title']}">
255                <img style="width:{$max_thumb_width}px;height:{$max_thumb_height}px;background-image:url($urlImg);" src="$urlSpacer" />
256            </a>
257        </div>
258        <div class="rate_prev_photo_nickname">
259            <a href="{$sProfLink}">{$ph_arr['NickName']}</a>
260        </div>
261        <div style="position:relative; width:50%; height:30px; overflow:visible; margin-top:10px;">
262            <div style="position:absolute; right:-94px; width:400px; height:30px;">
263                $sRatingBar
264            </div>         
265        </div>
266
267    </div>
268EOJ;
269   
270    return DesignBoxContent( _t('_Previous rated'), $ret, 1 );
271}
272
273?>
Note: See TracBrowser for help on using the repository browser.