HomeHelpTrac

source: tags/6.1/profilePhotos.php @ 10420

Revision 10420, 16.3 KB checked in by Andrey Prikaznov, 3 years ago (diff)
Line 
1<?php
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( BX_DIRECTORY_PATH_ROOT . 'uploadPhoto.php');   
22
23class ProfilePhotos extends UploadPhoto
24{
25    function ProfilePhotos( $iProfileID )
26    {
27        parent::UploadPhoto( $iProfileID );
28    }
29
30
31    function getMediaPage( $iMediaID = 0 )
32    {
33        global $votes_pic;
34
35        $ret = '';
36
37        //$ret .= $this -> getJSCode();
38
39        if( 0 < $this -> iMediaCount )
40        {
41            $iMediaID = ( 0 < $iMediaID ) ? $iMediaID : $this -> aMedia['0']['PrimPhoto'];
42
43            $aCurPhoto = $this -> getElementArrayByID($iMediaID);
44            if( empty( $aCurPhoto ) )
45            {
46                $sPhotoUrl = getTemplateIcon( $this -> sSexPic );
47            }
48            else
49            {
50                $ret .= '<div class="mediaTitle" id="sTitleDiv">';
51                    $ret .= stripcslashes( process_line_output( $aCurPhoto['med_title'] ) );
52                $ret .= '</div>';
53                $iPhotoID = $aCurPhoto['med_id'];
54                $sPhotoUrl = $this -> sMediaUrl . 'photo_' . $aCurPhoto['med_file'];
55                $iPhotoRating = $this -> getRating( $aCurPhoto['med_rating_sum'], $aCurPhoto['med_rating_count'] );
56            }
57        }
58        else
59        {
60            $sPhotoUrl = getTemplateIcon( $this -> sSexPic );
61        }
62       
63        $ret .= $this -> getJSCode( $aCurPhoto );
64
65        $ret .= '<div class="photoBlock" id="photoKeeper">';
66            $style = '
67                width:' . $this -> aMediaConfig['size']['photoWidth'] . 'px;' .
68                'height:' . $this -> aMediaConfig['size']['photoHeight'] . 'px;' .
69                'background-image:url(' . $sPhotoUrl . ');';
70            $ret .= '<img src="' . getTemplateIcon('spacer.gif') . '" style="' . $style . '" class="photo" alt="" id="temPhotoID" />';
71            //$ret .= '<img src="' . getTemplateIcon('spacer.gif') . '" style="' . $style . '"                                          class="photo" alt="" onload="return setImage();" id="temPhotoID" />';
72        $ret .= '</div>';
73
74        $sJsArray = '';
75        $iPhotosCount = 0;
76        $sIconsList = $this -> _getIconsList($sJsArray, $iPhotosCount);
77
78        $oVotingView = new BxTemplVotingView ('media', (int)$aCurPhoto['med_id']);
79        //if( $iPhotosCount && getParam('votes_pic') == 'on' && $oVotingView->isEnabled())
80        if( $iPhotosCount && $votes_pic && $oVotingView->isEnabled())
81            $ret .= '<div class="votingBlock">' . $oVotingView->getBigVoting () . '</div>';
82
83        $ret .= '<div class="iconBlock">';
84        $ret .= $sIconsList;
85        $ret .= '</div>';
86
87        $ret .= '
88            <script type="text/javascript">
89                ' . $sJsArray . '
90            </script>';
91
92        return $ret;
93    }
94
95    function getJSCode( $aCurPhoto, $bUseFeature = 'false' ) {
96        global $site;
97
98/*
99            function setImage()
100            {
101                var imgCode;
102                var oOldImg = document.getElementById("temPhotoID");
103                oOldImg.style.backgroundImage = "url({$this -> sMediaUrl}photo_{$aCurPhoto['med_file']})";
104                return false;
105            }
106
107            function setThumb()
108            {
109                if ('{$bUseFeature}' == 'true')
110                    return false;
111                var imgCode;
112                var oOldImg = document.getElementById("temThumbID");
113                var oLink = document.getElementById("temThumbLink");
114               
115                oOldImg.style.backgroundImage = "url({$this -> sMediaUrl}photo_{$aCurPhoto['med_file']})";
116                oLink.href = "{$site['url']}photos_gallery.php?ID={$this -> iProfileID}&photoID={$aCurPhoto['med_id']}";
117                return false;
118            }
119*/
120
121        $ret = <<<EOF
122        <script type="text/javascript">
123           
124            if (window.attachEvent)
125                window.attachEvent( "onload", onloadPhotos );
126            else
127                window.addEventListener( "load", onloadPhotos, false);
128           
129            function onloadPhotos()
130            {
131                hideScroll();
132                if (window.oVotingmediasmall)
133                {
134                    oVotingmediasmall.onvote = function (fRate, iCount)
135                    {
136                        oIcons[this._iObjId]["rate"] = fRate;
137                        oIcons[this._iObjId]["count"] = iCount;
138                    }                   
139                }
140                if (window.oVotingmediabig)
141                {
142                    oVotingmediabig.onvote = function (fRate, iCount)
143                    {
144                        oPhotos[this._iObjId]["rate"] = fRate;
145                        oPhotos[this._iObjId]["count"] = iCount;
146                    }                   
147                }
148            }
149           
150            //hide scrollers if needed
151            function hideScroll()
152            {
153                b = document.getElementById( "iconBlock" );
154                s = document.getElementById( "scrollCont" );
155               
156                if( !b || !s )
157                    return false;
158               
159                if( b.parentNode.clientWidth >= b.clientWidth ) {
160                    s.style.display = "none";
161                    $( '#iconBlock' ).css( { float: 'none', position: 'static', marginRight: 'auto', marginLeft: 'auto' } );
162                }
163                else
164                    s.style.display = "block";
165            }
166           
167            function changePhoto(iMediaID)
168            {
169                var oOldImg = document.getElementById("temPhotoID");
170
171                oOldImg.style.backgroundImage = "url({$this -> sMediaUrl}photo_"+oPhotos[iMediaID]["file"]+")";
172                changeTitle( oPhotos[iMediaID]["title"] );
173
174                if (oVotingmediabig)
175                {
176                    oVotingmediabig._iObjId = iMediaID;
177                    oVotingmediabig.setCount(oPhotos[iMediaID]["count"]);
178                    oVotingmediabig.setRate(oPhotos[iMediaID]["rate"]);
179                }
180
181
182                return false;
183            }
184
185            function changeBigPhoto(iMediaID)
186            {
187                $('#iiPPhoto1').children('img').hide();
188                $('#iiPPhoto1 #child_' + iMediaID).show();
189                //alert(iMediaID);
190                return;
191
192                var oOldImg = document.getElementById("temPhotoID");
193                oOldImg.style.backgroundImage = "url({$this -> sMediaUrl}photo_"+oPhotos[iMediaID]["file"]+")";
194
195                return false;
196            }
197
198            function changeThumb( iMediaID ) {
199                if ('{$bUseFeature}' == 'true') {
200                    $( '#iiPPhoto1' ).stopFlashing();
201                    changeBigPhoto(iMediaID);
202                }
203
204                if ('{$bUseFeature}' == 'false') {
205                    var oOldImg = document.getElementById("temThumbID");
206                    var oLink = document.getElementById("temThumbLink");
207                    oOldImg.style.backgroundImage = "url({$this -> sMediaUrl}photo_"+oIcons[iMediaID]["file"]+")";
208                }
209                var oTitle = document.getElementById("temPhotoTitle");
210
211                oTitle.innerHTML = oIcons[iMediaID]["title"];
212
213                if (oVotingmediasmall)
214                {
215                    oVotingmediasmall._iObjId = iMediaID;
216                    oVotingmediasmall.setCount(oIcons[iMediaID]["count"]);
217                    oVotingmediasmall.setRate(oIcons[iMediaID]["rate"]);
218                }
219
220                if ('{$bUseFeature}' == 'false') {
221                    oLink.href = "{$site['url']}photos_gallery.php?ID={$this -> iProfileID}&photoID=" + iMediaID;
222                }
223
224                return false;
225            }
226                       
227            function changeTitle( sTitle )
228            {
229                var oTitlDiv = document.getElementById("sTitleDiv");
230                oTitlDiv.innerHTML = stripSlashes(sTitle);
231            }
232
233        </script>
234EOF;
235
236        return $ret;
237    }
238
239    function _getIconsList(&$sJsArray, &$iCountPhotos)
240    {
241        $ret = '';
242        $sJsArray = 'var oPhotos = {';
243        $iCountPhotos = 0;
244
245        for( $i = 0; $i < $this -> aMediaConfig['max']['photo']; $i++ )
246        {
247            $sIconSrc = $this -> sMediaDir . 'icon_' . $this -> aMedia[$i]['med_file'];
248            if( extFileExists( $sIconSrc ) )
249            {
250                $iPhotoRatingCount = $this -> aMedia[$i]['voting_count'] ? $this -> aMedia[$i]['voting_count'] : 0;
251                $iPhotoRating = $this -> aMedia[$i]['voting_rate'] ? $this -> aMedia[$i]['voting_rate'] : 0;
252               
253                $sIconUrl = $this -> sMediaUrl . 'icon_' . $this -> aMedia[$i]['med_file'];
254
255                $atrib = "'{$this -> aMedia[$i]['med_id']}'";
256
257                $ret .= '
258                    <img src="' . getTemplateIcon('spacer.gif') . '"
259                      style="width:' . $this -> aMediaConfig['size']['iconWidth'] . 'px; height:' . $this -> aMediaConfig['size']['iconHeight'] . 'px; background-image:url(' . $sIconUrl . '); cursor:pointer;"
260                      alt="" class="icons" onmouseover="this.className=\'iconsHover\'" onmouseout="this.className=\'icons\'"
261                      onclick="return changePhoto(' . $atrib . ');" />';
262
263                $sJsArray .= "
264                    '{$this -> aMedia[$i]['med_id']}' : {
265                        'title' : '" . addslashes( htmlspecialchars( $this -> aMedia[$i]['med_title'] ) ) . "',
266                        'file' : '{$this -> aMedia[$i]['med_file']}',
267                        'rate' : '{$iPhotoRating}',
268                        'count' : '{$iPhotoRatingCount}'
269                    },";
270
271                ++$iCountPhotos;
272            }
273            else
274            {
275                $sIconUrl = getTemplateIcon( $this -> sSexIcon );
276                $ret .= '<img src="' . getTemplateIcon('spacer.gif') . '" style="width:' . $this -> aMediaConfig['size']['iconWidth'] . 'px; height:' . $this -> aMediaConfig['size']['iconHeight'] . 'px; background-image:url(' . $sIconUrl . ');" alt="" class="icons" />';
277            }
278
279        }
280       
281        if( $iCountPhotos )
282            $sJsArray = substr($sJsArray,0,-1);
283       
284        $sJsArray .= '}';
285
286        return $ret;
287    }
288   
289    // for thumbs switching
290    function _getIconsList2(&$sJsArray, &$iCountPhotos)
291    {
292
293        $ret = '';
294        $sJsArray = 'var oIcons = {';
295        $iCountPhotos = 0;
296
297        for( $i = 0; $i < $this -> aMediaConfig['max']['photo']; $i++ )
298        {
299            $sIconSrc = $this -> sMediaDir . 'icon_' . $this -> aMedia[$i]['med_file'];
300            if( extFileExists( $sIconSrc ) )
301            {
302                $iPhotoRatingCount = $this -> aMedia[$i]['voting_count'] ? $this -> aMedia[$i]['voting_count'] : 0;
303                $iPhotoRating = $this -> aMedia[$i]['voting_rate'] ? $this -> aMedia[$i]['voting_rate'] : 0;
304
305                $sIconUrl = $this -> sMediaUrl . 'icon_' . $this -> aMedia[$i]['med_file'];
306               
307                $atrib = "'{$this -> aMedia[$i]['med_id']}'";
308
309                $ret .= '
310                    <img src="' . getTemplateIcon('spacer.gif') . '"
311                      style="width:' . $this -> aMediaConfig['size']['iconWidth'] . 'px; height:' . $this -> aMediaConfig['size']['iconHeight'] . 'px; background-image:url(' . $sIconUrl . ');"
312                      alt="" class="icons" onclick="return changeThumb(' . $atrib . ');" />';
313                $sJsArray .= "
314                    '{$this -> aMedia[$i]['med_id']}' : {
315                        'title' : '" . addslashes( htmlspecialchars( $this -> aMedia[$i]['med_title'] ) ) . "',
316                        'file' : '{$this -> aMedia[$i]['med_file']}',
317                        'rate' : '{$iPhotoRating}',
318                        'count' : '{$iPhotoRatingCount}'
319                    },";
320
321                ++$iCountPhotos;
322            }
323        }
324        if( $iCountPhotos )
325            $sJsArray = substr($sJsArray,0,-1);
326       
327        $sJsArray .= '}';
328
329        return $ret;
330    }
331
332
333
334    function getPrimaryPhotoArray($iCouplePID = 0)
335    {
336        $iDestID = ($iCouplePID>0) ? $iCouplePID : $this -> aMedia['0']['PrimPhoto'];
337        $aPrimPhoto = $this -> getElementArrayByID( $iDestID );
338        return $aPrimPhoto;
339    }
340   
341    function getMediaBlock( $iMediaID = 0, $bCouple = false )
342    {
343        global $site;
344        global $votes_pic;
345
346        $ret = '';
347
348        $bUseFeature = getParam("profile_gallery_feature") == "on" ? true : false;
349        $bUseFeature = ($this->iMediaCount == 1) ? false : $bUseFeature;
350        $bSUseFeature = ($bUseFeature) ? 'true' : 'false';
351
352        if( $this -> iMediaCount > 0 )
353        {
354            $iMediaID = ( $iMediaID > 0 ) ? $iMediaID : $this -> aMedia['0']['PrimPhoto'];
355
356            $aCurPhoto = $this -> getElementArrayByID($iMediaID);
357            if( empty( $aCurPhoto ) )
358                $sPhotoUrl = getTemplateIcon( $this -> sSexPic );
359            else
360            {
361                $iPhotoID = $aCurPhoto['med_id'];
362                $sPhotoUrl = $this -> sMediaUrl . 'photo_' . $aCurPhoto['med_file'];
363            }
364        }
365        else
366            $sPhotoUrl = getTemplateIcon( $this -> sSexPic );
367
368        $ret .= $this -> getJSCode( $aCurPhoto, $bSUseFeature );
369
370        $sFeature = '';
371        if ($bUseFeature) {
372            for( $i = 0; $i < $this -> aMediaConfig['max']['photo']; $i++ ) {
373                $sIconSrc = $this -> sMediaDir . 'photo_' . $this -> aMedia[$i]['med_file'];
374                if( extFileExists( $sIconSrc ) ) {
375                    $sIconUrl = $this -> sMediaUrl . 'photo_' . $this -> aMedia[$i]['med_file'];
376                    $iMediaID = (int)$this->aMedia[$i]['med_id'];
377                    $sFeatImgs .= '<img src="' . getTemplateIcon('spacer.gif') . '" style="width:' . $this -> aMediaConfig['size']['photoWidth'] . 'px; height:' . $this -> aMediaConfig['size']['photoHeight'] . 'px; background-image:url(' . $sIconUrl . ');position:absolute;"  alt="" class="icons" id="child_'.$iMediaID.'" onclick="return $( \'#iiPPhoto1\' ).ResumeFlashing();" />';
378                }
379            }
380            $sFeatTotalHeight = $this -> aMediaConfig['size']['photoHeight'] + 30;
381
382            $iNumber=($bCouple) ? '2' : '1';
383
384            $sFeature = <<<EOF
385<script type="text/javascript" src="{$site['url']}inc/js/jquery.dolPromoT.js"></script>
386<script type="text/javascript">
387    $(document).ready( function() {
388        $( '#iiPPhoto{$iNumber}' ).dolPromo( 3000, 1 );
389    } );
390</script>
391EOF;
392
393            if ($sFeatImgs == '') {
394                $style =
395                    'width:'  . $this -> aMediaConfig['size']['photoWidth'] . 'px;'.
396                    'height:' . $this -> aMediaConfig['size']['photoHeight'] . 'px;' .
397                    'background-image:url(' . $sPhotoUrl . ');
398                    ';
399               
400                $sFeatImgs = '<img src="' . getTemplateIcon('spacer.gif') . '" style="' . $style . '" class="photo" alt="" />';
401                $sFeature = '';
402            }
403            $sFeature .= <<<EOF
404<div style="position:relative;width:100%;height:{$sFeatTotalHeight}px;overflow:hidden;">
405    <div id="iiPPhoto{$iNumber}">
406        {$sFeatImgs}
407    </div>
408</div>
409EOF;
410            $ret .= $sFeature;
411        } else {
412            $ret .= '<div class="photoBlock" id="photoKeeper">';
413                $style =
414                    'width:'  . $this -> aMediaConfig['size']['photoWidth'] . 'px;'.
415                    'height:' . $this -> aMediaConfig['size']['photoHeight'] . 'px;' .
416                    'background-image:url(' . $sPhotoUrl . ');';
417               
418                $ret .= '<a href="' . $site['url'] . 'photos_gallery.php?ID=' .  $this -> iProfileID . '" id="temThumbLink">';
419                    $ret .= '<img src="' . getTemplateIcon('spacer.gif') . '" style="' . $style . '" class="photo" alt="" id="temThumbID" />';
420                    //$ret .= '<img src="' . getTemplateIcon('spacer.gif') . '" style="' . $style . '" class="photo" alt="" onload="return setThumb();" id="temThumbID" />';
421                $ret .= '</a>';
422               
423            $ret .= '</div>';
424        }
425
426        $ret .= '<div id="temPhotoTitle" class="photo_title">' . htmlspecialchars( $aCurPhoto['med_title'] ) . '</div>';
427
428        if ($bCouple)
429            return $ret . '<div class="clear_both"></div>';
430
431        $sJsIconsArray = '';
432        $iCountPhotos = 0;
433        $sIcons = $this -> _getIconsList2($sJsIconsArray, $iCountPhotos);
434
435        $oVotingView = new BxTemplVotingView ('media', (int)$aCurPhoto['med_id']);
436        if( $iCountPhotos && $votes_pic && $oVotingView->isEnabled() )
437            $ret .= $oVotingView->getSmallVoting ();
438        $ret .= '<div class="clear_both"></div>';           
439       
440        if( strlen( $sIcons ) )
441        {
442            $ret .= '<div class="scrollIconContainer">';
443                $ret .= '<div class="scrollCont" id="scrollCont">';
444                    $ret .= '<div class="scrollLeft"  onmouseover="moveScrollLeftAuto(  \'iconBlock\', 1 );" onmouseout="moveScrollLeftAuto(  \'iconBlock\', 0 );"><img src="' . getTemplateIcon('left_arrow.gif') . '"/></div>';
445                    $ret .= '<div class="scrollRight" onmouseover="moveScrollRightAuto( \'iconBlock\', 1 );" onmouseout="moveScrollRightAuto( \'iconBlock\', 0 );"><img src="' . getTemplateIcon('right_arrow.gif') . '"/></div>';
446                    $ret .= '<div class="clear_both"></div>';
447                $ret .= '</div>';
448                $ret .= '<div class="iconBlockCont">';
449                    $ret .= '<div id="iconBlock" class="iconBlock">';
450                        $ret .= $sIcons;
451                    $ret .= '</div>';
452                $ret .= '</div>';
453            $ret .= '</div>';
454        }
455
456        $ret .= '
457            <script type="text/javascript">
458                ' . $sJsIconsArray . '
459            </script>';
460
461        return $ret;
462    }
463
464}
465
466
467?>
Note: See TracBrowser for help on using the repository browser.