HomeHelpTrac

source: tags/6.1/videos.php @ 10242

Revision 10242, 4.4 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
26// --------------- page variables and login
27
28$_page['name_index']    = 84;
29$_page['css_name']      = 'videos.css';
30
31if ( !( $logged['admin'] = member_auth( 1, false ) ) )
32    if ( !( $logged['member'] = member_auth( 0, false ) ) )
33        if ( !( $logged['aff'] = member_auth( 2, false )) )
34            $logged['moderator'] = member_auth( 3, false );
35
36$_page['header'] = _t( "_Videos" );
37$_page['header_text'] = _t( "_Videos" );
38
39$_ni = $_page['name_index'];
40
41$_page_cont[$_ni]['page_main_code'] = PageCompVideos();
42
43PageCode();
44
45
46function PageCompVideos()
47{
48    global $site;
49    global $tmpl;
50
51    // number of videos
52    $max_num    = 12;
53    $mode       = 'rand';
54       
55    $sqlSelect = "
56        SELECT
57            `media`.`med_id`,
58            `med_prof_id`,
59            `med_file`,
60            `med_title`";
61   
62    $sqlFrom = "
63        FROM `media`";
64   
65    $sqlWhere = "
66        WHERE
67            `med_type` = 'video'";
68
69   
70    if ( $_GET['mode'] == 'rand' or
71         $_GET['mode'] == 'last' or
72         $_GET['mode'] == 'top' )
73            $mode = $_GET['mode'];
74   
75    $menu = '';
76    switch ( $mode )
77    {
78        case 'last': $sqlOrder = " ORDER BY `med_date` DESC"; break;
79        case 'rand': $sqlOrder = " ORDER BY RAND()";          break;
80        case 'top':
81                $sqlSelect .= ",
82    (`med_rating_sum`/`med_rating_count`) AS `avg_mark`";
83                $sqlFrom .= "
84    INNER JOIN `media_rating` USING (`med_id`) ";
85                $sqlOrder = "
86    ORDER BY `avg_mark` DESC";
87        break;
88    }
89   
90    $aNum = db_arr( "SELECT COUNT(`media`.`med_id`) $sqlFrom $sqlWhere" );
91    $num = (int)$aNum[0];
92    if( $num )
93    {
94        $pages = ceil( $num / $max_num );
95        $page = (int)$_GET['page'];
96       
97        if( $page < 1 or $mode == 'rand' )
98            $page = 1;
99        if( $page > $pages )
100            $page = $pages;
101       
102        $sqlLimitFrom = ( $page - 1 ) * $max_num;
103        $sqlLimit = "
104        LIMIT $sqlLimitFrom, $max_num";
105       
106        //$max_thumb_width  = (int)getParam( 'max_thumb_width' );
107        //$max_thumb_height = (int)getParam( 'max_thumb_height' );
108       
109        $ret = '<div class="clear_both"></div>';
110        $tmplBlock = file_get_contents( BX_DIRECTORY_PATH_ROOT . "templates/tmpl_{$tmpl}/media_page_block.html" );
111       
112        $result = db_res( $sqlSelect.$sqlFrom.$sqlWhere.$sqlOrder.$sqlLimit );
113        while ( $ph_arr = mysql_fetch_assoc( $result ) )
114        {
115            $block = $tmplBlock;
116           
117            $memNickName = getNickName( $ph_arr['med_prof_id'] );
118           
119            $aReplace['media_title'] = process_line_output( $ph_arr['med_title'] );
120            $aReplace['media_icon']  = "<a href=\"{$site['url']}media/video/{$ph_arr['med_prof_id']}/{$ph_arr['med_file']}\" title=\""._t('_download')."\"><img src=\"".getTemplateIcon( 'video.jpg' )."\" alt=\"video\" /></a>";
121            $aReplace['nickname']    = "<a href=\"".getProfileLink($ph_arr['med_prof_id'])."\">$memNickName</a>";
122            $aReplace['download']    = '';
123            $aReplace['delete']      = '';
124           
125            foreach( $aReplace as $key => $val )
126                $block = str_replace( "__{$key}__", $val, $block );
127           
128            $ret .= $block;
129           
130           
131        }
132       
133        $ret .= '<div class="clear_both"></div>';
134       
135        if( $pages > 1 )
136        {
137            $pagination =
138                '<div class="video_pages">'.
139                    genPagination( $pages, $page, $_SERVER['PHP_SELF']."?mode=$mode&amp;page={page}" ).
140                '</div>';
141           
142            $ret = $pagination . $ret . $pagination;
143        }
144    }
145    else
146    {
147        $ret .= '<div class="no_result">';
148            $ret .= '<div>';
149                $ret .= _t("_No results found");
150            $ret .= '</div>';
151        $ret .= '</div>';
152    }
153   
154    return $ret;
155}
Note: See TracBrowser for help on using the repository browser.