HomeHelpTrac

source: tags/6.1/upload_media.php @ 10242

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

dolphin 6.1.5, initial commit

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
21
22require_once('inc/header.inc.php');
23require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
24require_once( BX_DIRECTORY_PATH_INC . 'admin.inc.php' );
25require_once( BX_DIRECTORY_PATH_INC . 'images.inc.php' );
26
27
28$_page['name_index']    = 62;
29$_page['css_name']      = 'upload_media.css';
30
31$_page['extra_js'] = '
32    <script type="text/javascript">
33        active= new Image();
34        active.src="' . $site['url'] . 'templates/base/images/media_tab_active.png;";
35        passive= new Image();
36        passive.src="' . $site['url'] . 'templates/base/images/media_tab_passive.png;";
37        hover= new Image();
38        hover.src="' . $site['url'] . 'templates/base/images/media_tab_hover.png;";
39    </script>
40';
41
42$logged['member'] = member_auth( 0 );
43
44$_page['header'] = _t( "_Profile Photos" );
45//$_page['header_text'] = _t( "_UPLOAD_MEDIA", $site['title'] );
46
47
48$_ni = $_page['name_index'];
49$_page_cont[$_ni]['page_main_code'] = PageCompMainCode();
50
51PageCode();
52
53
54
55function PageCompMainCode()
56{
57    global $tmpl, $_page, $oTemplConfig;
58
59    $iProfileID = (int)$_COOKIE['memberID'];
60
61    $show = $_REQUEST['show'];
62    switch( $show )
63    {
64        case 'photo':
65        default:
66                require_once( BX_DIRECTORY_PATH_ROOT . 'uploadPhoto.php' );
67                $oMedia = new UploadPhoto( $iProfileID );
68                $oMedia -> getMediaArray();
69                $_page['header_text'] = _t( "_My Photos" );
70        break;
71    }
72
73    $ret = '';
74
75            $ret .= '
76            <script type="text/javascript">
77
78                function checkForm()
79                {
80
81
82                    var el;
83                    var hasErr = false;
84                    var fild = "";
85
86                    el = document.getElementById("mediaTitle");
87                    if( el.value.length < ' . $oMedia -> aMediaConfig['min']['mediaTitle'] . ' )
88                    {
89                        el.style.backgroundColor = "pink";
90                        el.style.border = "1px solid silver";
91                        hasErr = true;
92                        fild += "\n ' . _t( '_title_min_lenght', $oMedia -> aMediaConfig['min']['mediaTitle'] ) . '";
93                    }
94                    else
95                    {
96                        el.style.backgroundColor = "#fff";
97                    }
98
99                    if (hasErr)
100                    {
101                        alert( fild )
102                        return false;
103
104                    }
105                    else
106                    {
107                        return true;
108                    }
109
110
111                    return false;
112                }
113            </script>
114';
115   
116    if( $oTemplConfig -> customize['upload_media']['showMediaTabs'] )
117    {
118        $ret .= '<div class="choiseBlock">';
119            $ret .= getMediaTabs( $oMedia -> sMediaType, $oMedia -> aMediaConfig['enable'] );
120        $ret .= '</div>' . "\n";
121        $ret .= '<div class="clear_both"></div>';
122    }
123   
124   
125    if( $oTemplConfig -> customize['upload_media']['showAddButton'] )
126    {
127        $ret .= '<div class="addNew">';
128            $ret .= '<a href="javascript:void(0);" onclick="return BxShowBlock(\'addNewBlock\');">' . _t('_add_new', _t('_' . $oMedia -> sMediaType . '')) . '</a>';
129        $ret .= '</div>' . "\n";
130    }
131   
132    $ret .= '<div id="addNewBlock" style="display:' . $oTemplConfig -> customize['upload_media']['addNewBlock_display'] . ';">';
133
134    if( $oMedia -> iMediaCount >= $oMedia -> aMediaConfig['max'][$oMedia -> sMediaType] )
135    {
136        $ret .= _t_action('_too_many_files');
137    }
138    else
139    {
140        $ret .= '<form enctype="multipart/form-data" action="' . $oMedia -> aMediaConfig['url']['media'] . '?show=' . $oMedia -> sMediaType . '" method="post" onsubmit="return checkForm();">';
141            $ret .= '<div>';
142                $ret .= _t('_Title');
143                $ret .= '&nbsp;(&nbsp;<span id="charCount" class="charCount">' . $oMedia -> aMediaConfig['max']['mediaTitle'] . '</span>';
144                $ret .= '<span class="charCount">' . _t('_characters_left') . '</span>&nbsp;)';
145            $ret .= '</div>' . "\n";
146            $ret .= '<div>';
147                $ret .= '<input type="text" name="title" class="title" id="mediaTitle" onkeydown="return charCounter(\'mediaTitle\', ' . $oMedia -> aMediaConfig['max']['mediaTitle'] . ', \'charCount\');" onkeyup="return charCounter(\'mediaTitle\', ' . $oMedia -> aMediaConfig['max']['mediaTitle'] . ', \'charCount\');"  />';
148            $ret .= '</div>' . "\n";
149            $ret .= '<div>';
150                $ret .= '<input type="file" size="34" name="' . $oMedia -> sMediaType . '" class="file" />';
151            $ret .= '</div>' . "\n";
152            $ret .= '<div>';
153                $ret .= '<input type="submit" value="' . _t('_Submit') . '">';
154                $ret .= '<input type="hidden" name="media_type" value="' . $oMedia -> sMediaType . '" />';
155                $ret .= '<input type="hidden" name="show" value="' . $oMedia -> sMediaType . '" />';
156                $ret .= '<input type="hidden" name="action" value="upload" />';
157            $ret .= '</div>' . "\n";
158        $ret .= '</form>';
159
160    }
161    $ret .= '</div>' . "\n";
162
163    $action = $_REQUEST['action'];
164    if( $_POST['makePrim'] || isset($_POST['makePrim_x'] ) )
165    {
166        $action = 'makePrim';
167    }
168    elseif( $_POST['makePrimCouple'] || isset($_POST['makePrimCouple_x'] ) )
169    {
170        $action = 'makePrimCouple';
171    }
172    elseif( $_POST['makeRable'] )
173    {
174        $action = 'makeRable';
175    }
176    elseif( $_POST['deletePhoto'] || isset($_POST['deletePhoto_x']) )
177    {
178        $action = 'deletePhoto';
179    }
180
181    $iPhotoID = (int)$_REQUEST['photoID'];
182    $iMediaID = (int)$_REQUEST['mediaID'];
183
184    switch($action)
185    {
186        case 'upload':
187            $ret .= $oMedia -> uploadMedia();
188            header('Location:' . $_SERVER['PHP_SELF'] . '?show=' . $oMedia -> sMediaType );
189        break;
190        case 'makePrim':
191            $ret .= $oMedia -> makePrimPhoto( $iPhotoID );
192            header('Location:' . $_SERVER['PHP_SELF'] . '?show=' . $oMedia -> sMediaType);
193        break;
194        case 'makeRable':
195            $ret .= $oMedia -> makeRablePhoto( $iPhotoID );
196            header('Location:' . $_SERVER['PHP_SELF'] . '?show=' . $oMedia -> sMediaType);
197        break;
198        case 'makePrimCouple':
199            $ret .= $oMedia -> makePrimPhoto( $iPhotoID, true );
200            header('Location:' . $_SERVER['PHP_SELF'] . '?show=' . $oMedia -> sMediaType);
201        break;
202        case 'deletePhoto':
203            $ret .= $oMedia -> deleteMedia( $iPhotoID );
204            header('Location:' . $_SERVER['PHP_SELF'] . '?show=' . $oMedia -> sMediaType);
205        break;
206        case 'delete':
207            $ret .= $oMedia -> deleteMedia( $iMediaID );
208            header('Location:' . $_SERVER['PHP_SELF'] . '?show=' . $oMedia -> sMediaType);
209        break;
210    }
211
212
213    switch( $show )
214    {
215        case 'photo':
216        default:
217            if( $_REQUEST['photoID'] )
218            {
219                $iPhotoId = (int)$_REQUEST['photoID'];
220                $ret .= $oMedia -> getMediaPage($iPhotoId);
221            }
222            else
223            {
224                $ret .= $oMedia -> getMediaPage();
225            }
226        break;
227    }
228
229    return $ret;
230}
231
232function getMediaTabs( $show = 'photo', $aMediaConf ) {
233    $aItems = array( 'photo' );
234
235    foreach( $aItems as $sItem )
236    {
237        if( $aMediaConf[$sItem] )
238        {
239            if( $sItem == $show )
240            {
241                $ret .= '<div class="item">';
242                    $ret .= '<div class="active">';
243                        $ret .= _t('_' . $sItem . '');
244                    $ret .= '</div>';
245                $ret .= '</div>';
246            }
247            else
248            {
249                $ret .= '<div class="item">';
250                    $ret .= '<div class="passive" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'passive\'">';
251                        $ret .= '<a href="' . $_SERVER['PHP_SELF'] . '?show=' . $sItem . '">' . _t('_' . $sItem . '') . '</a>';
252                    $ret .= '</div>';
253                $ret .= '</div>';
254            }
255        }
256        else
257        {
258            $ret .= '';
259        }
260    }
261
262    return $ret;
263}
264
265?>
Note: See TracBrowser for help on using the repository browser.