Subversion Repositories svnkaklik

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
<?php
2
/*************************
3
  Coppermine Photo Gallery
4
  ************************
5
  Copyright (c) 2003-2005 Coppermine Dev Team
6
  v1.1 originaly written by Gregory DEMAR
7
 
8
  This program is free software; you can redistribute it and/or modify
9
  it under the terms of the GNU General Public License as published by
10
  the Free Software Foundation; either version 2 of the License, or
11
  (at your option) any later version.
12
  ********************************************
13
  Coppermine version: 1.3.3
14
  $Source: /cvsroot/coppermine/stable/albmgr.php,v $
15
  $Revision: 1.6 $
16
  $Author: gaugau $
17
  $Date: 2005/04/19 03:17:10 $
18
**********************************************/
19
 
20
define('IN_COPPERMINE', true);
21
define('ALBMGR_PHP', true);
22
 
23
require('include/init.inc.php');
24
 
25
if (!(GALLERY_ADMIN_MODE || USER_ADMIN_MODE)) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
26
 
27
function get_subcat_data($parent, $ident = '')
28
{
29
    global $CONFIG, $CAT_LIST;
30
 
31
    $result = db_query("SELECT cid, name, description FROM {$CONFIG['TABLE_CATEGORIES']} WHERE parent = '$parent' AND cid != 1 ORDER BY pos");
32
    if (mysql_num_rows($result) > 0) {
33
        $rowset = db_fetch_rowset($result);
34
        foreach ($rowset as $subcat) {
35
            $CAT_LIST[] = array($subcat['cid'], $ident . $subcat['name']);
36
            get_subcat_data($subcat['cid'], $ident . '&nbsp;&nbsp;&nbsp;');
37
        }
38
    }
39
}
40
 
41
pageheader($lang_albmgr_php['alb_mrg']);
42
 
43
?>
44
 
45
<script language="javascript">
46
<!--
47
    function CheckAlbumForm(frm)
48
    {
49
        var select_len = frm.to.length;
50
        var album = new Object();
51
        var changed = false;
52
 
53
        for (i=0; i<select_len; i++) {
54
            album = new parseSelectValue(frm.to, i);
55
 
56
            if (album.action != '0') {
57
                if (album.album_nm == '') {
58
                    alert('<?php echo $lang_albmgr_php['alb_need_name'] ?>');
59
                    frm.to.options[i].selected = true;
60
                    return false;
61
                }
62
                changed = true;
63
            }
64
        }
65
 
66
        if (frm.delete_album.value.len !=0)
67
            changed = true;
68
 
69
        if (changed) {
70
            if (confirm('<?php echo $lang_albmgr_php['confirm_modifs'] ?>')) {
71
                for (i=0; i<select_len; i++) {
72
                    album = new parseSelectValue(frm.to, i);
73
                    if (album.action != '0') {
74
                        frm.to.options[i].selected = true;
75
                    }
76
                }
77
                return true;
78
            }
79
            else
80
                return false;
81
        }
82
        else {
83
            alert('<?php echo $lang_albmgr_php['no_change'] ?>');
84
            return false;
85
        }
86
    }
87
 
88
    function page_init()
89
    {
90
        document.album_menu.delete_album.value = "";
91
    }
92
-->
93
</script>
94
 
95
<script language="javascript">
96
<!--
97
    var selectedOptIndex;
98
 
99
    function Album_Select(selectedIndex)
100
    {
101
        selectedOptIndex = selectedIndex;
102
 
103
        for (i=0; i<document.album_menu.to.length; i++) {
104
            document.album_menu.to.options[i].selected = false;
105
        }
106
        document.album_menu.to.options[selectedIndex].selected = true;
107
 
108
        var album = new Object();
109
        album = new parseSelectValue(document.album_menu.to, selectedIndex);
110
 
111
        album.deleteFrm();
112
        album.changeFrm();
113
    }
114
 
115
    function Moveup_Option()
116
    {
117
        var to = document.album_menu.to;
118
        var pos = selectedOptIndex;
119
        if (pos == 0) {
120
            return;
121
        }
122
 
123
        swap_option(to, pos, pos-1);
124
        selected_option(to, pos-1);
125
    }
126
 
127
    function Movedown_Option()
128
    {
129
        var to = document.album_menu.to;
130
        var pos = selectedOptIndex;
131
        if (pos == to.length-1) {
132
            return;
133
        }
134
 
135
        swap_option(to, pos, pos+1);
136
        selected_option(to, pos+1);
137
    }
138
 
139
    function Album_Create()
140
    {
141
        var prev_album;
142
        var to_pos, album_type, album_sort;
143
        var to = document.album_menu.to;
144
 
145
        if (to.selectedIndex == -1)
146
            to_pos = to.length;
147
        else
148
            to_pos = to.selectedIndex;
149
 
150
        if (to_pos > 0) {
151
            prev_album = new parseSelectValue(to, to_pos-1);
152
            album_sort = Number(prev_album.album_sort)+1;
153
        }
154
        else {
155
            album_sort = 1;
156
        }
157
        move_list (to, to_pos);
158
        make_option("<?php echo $lang_albmgr_php['new_album'] ?>", make_value('0', "<?php echo $lang_albmgr_php['new_album'] ?>", album_sort, '1'), to, to_pos);
159
 
160
        selected_option(to, to_pos);
161
    }
162
 
163
    function Album_Delete()
164
    {
165
        var album = new Object();
166
        var to = document.album_menu.to;
167
        album = new parseSelectValue(to, selectedOptIndex);
168
 
169
        var msg = '<?php echo $lang_albmgr_php['confirm_delete1'] ?>';
170
 
171
        if (album.action == '1') {
172
            if (confirm(msg)) {
173
                to.options[selectedOptIndex] = null;
174
                document.album_menu.album_nm.value='';
175
            }
176
            else {
177
                return;
178
            }
179
        }
180
        else {
181
            msg = msg + '<?php echo $lang_albmgr_php['confirm_delete2'] ?>';
182
 
183
            if (confirm(msg)) {
184
                var album = new Object();
185
                album =  new parseSelectValue(to, selectedOptIndex);
186
                to.options[selectedOptIndex] = null;
187
                document.album_menu.album_nm.value='';
188
 
189
                document.album_menu.delete_album.value = document.album_menu.delete_album.value + album.album_no + ',';
190
            }
191
            else {
192
                return;
193
            }
194
        }
195
    }
196
 
197
    function Album_NameChange(change_name)
198
    {
199
 
200
                try {
201
                    var album = new Object();
202
                    var to = document.album_menu.to;
203
                    var value;
204
                    var text;
205
 
206
                    album = new parseSelectValue(to, selectedOptIndex);
207
                    if (album.action == '1')
208
                        action = '1';
209
                    else
210
                        action = '2';
211
 
212
                    text = change_name.substring(0, 80);
213
                    value = make_value(album.album_no, change_name, album.album_sort, action);
214
                    make_option(text, value, to, selectedOptIndex);
215
                }
216
                catch(e) {
217
                        alert("<?php echo $lang_albmgr_php['select_first'] ?>");
218
                }
219
        }
220
 
221
    function make_option(text, value, target, index)
222
    {
223
        target[index] = new Option(text, value);
224
    }
225
 
226
    function move_list(target, pos)
227
    {
228
        var album = new Object();
229
        var listlen = target.length;
230
 
231
        for (j=listlen-1; j>pos-1; j--) {
232
            album = new parseSelectValue(target, j)
233
            if (album.action == '1') {
234
                value = make_value(album.album_no, album.album_nm, Number(album.album_sort)+1, '1');
235
            }
236
            else {
237
                value = make_value(album.album_no, album.album_nm, Number(album.album_sort)+1, '2');
238
            }
239
            text  = target.options[j].text;
240
 
241
            make_option(text, value, target, j+1);
242
        }
243
    }
244
 
245
    function _private_update_frm_element(name)
246
    {
247
        var frm = document.album_menu;
248
        frm.album_nm.value = name;
249
    }
250
 
251
    function _private_change()
252
    {
253
        _private_update_frm_element(this.album_nm);
254
    }
255
 
256
    function _private_delete()
257
    {
258
        _private_update_frm_element('');
259
    }
260
 
261
    function parseSelectValue(select, selectedIndex)
262
    {
263
        var temp_nm
264
        var option_value = select.options[selectedIndex].value;
265
 
266
        this.album_no = option_value.substring(option_value.indexOf('album_no=') + 9, option_value.indexOf(','));
267
        option_value = option_value.substring(option_value.indexOf(',') + 1);
268
 
269
        temp_nm = option_value.substring(option_value.indexOf('album_nm=') + 9, option_value.indexOf('album_sort=')-1);
270
        this.album_nm = temp_nm.substring(1, temp_nm.length-1);
271
        option_value = option_value.substring(option_value.indexOf('album_sort='));
272
 
273
        this.album_sort = option_value.substring(option_value.indexOf('album_sort=') + 11 ,option_value.indexOf(','));
274
        option_value = option_value.substring(option_value.indexOf(',') + 1);
275
 
276
        this.action = option_value.substring(option_value.indexOf('action=') + 7);
277
 
278
        this.changeFrm = _private_change;
279
        this.deleteFrm = _private_delete;
280
 
281
        return this;
282
    }
283
 
284
    function selected_option(target, pos)
285
    {
286
        target.options[pos].selected = true;
287
        Album_Select(pos);
288
    }
289
 
290
    function swap_option(target, swap_a, swap_b)
291
    {
292
        var album_a = new Object();
293
        var album_b = new Object();
294
 
295
        album_a = new parseSelectValue(target, swap_a);
296
        album_b = new parseSelectValue(target, swap_b);
297
 
298
        if (album_a.action == '0') album_a.action = '2';
299
        if (album_b.action == '0') album_b.action = '2';
300
 
301
        var temp_option = new Option(target.options[swap_a].text, make_value(album_a.album_no, album_a.album_nm,album_b.album_sort,album_a.action));
302
        target[swap_a] = new Option(target.options[swap_b].text, make_value(album_b.album_no, album_b.album_nm,album_a.album_sort,album_b.action));
303
        target[swap_b] = temp_option;
304
    }
305
 
306
    function make_value(album_no, album_nm, album_sort, action)
307
    {
308
        return "album_no=" + album_no + ",album_nm='" + album_nm + "',album_sort=" + album_sort + ",action=" + action;
309
    }
310
-->
311
</script>
312
 
313
<?php starttable("100%", $lang_albmgr_php['alb_mrg'], 1);
314
?>
315
<tr>
316
<?php
317
$cat = isset($HTTP_GET_VARS['cat']) ? ($HTTP_GET_VARS['cat']) : 0;
318
if ($cat == 1) $cat = 0;
319
 
320
if (GALLERY_ADMIN_MODE) {
321
    $result = db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = $cat ORDER BY pos ASC");
322
} elseif (USER_ADMIN_MODE) {
323
    $result = db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = " . (USER_ID + FIRST_USER_CAT) . " ORDER BY pos ASC");
324
} else cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
325
$rowset = db_fetch_rowset($result);
326
$i = 100;
327
$sort_order = '';
328
if (count ($rowset) > 0) foreach ($rowset as $album) {
329
    $sort_order .= $album['aid'] . '@' . ($i++) . ',';
330
}
331
 
332
?>
333
        <form name="album_menu" method="post" action="delete.php?what=albmgr" onSubmit="return CheckAlbumForm(this);">
334
        <input type="hidden" name="delete_album" value="">
335
        <input type="hidden" name="sort_order" value="<?php echo $sort_order ?>">
336
        <td class="tableb" valign="top" align="center">
337
                <br>
338
                <table width="300" border="0" cellspacing="0" cellpadding="0">
339
<?php
340
if (GALLERY_ADMIN_MODE) {
341
    $CAT_LIST = array();
342
    $CAT_LIST[] = array(FIRST_USER_CAT + USER_ID, $lang_albmgr_php['my_gallery']);
343
    $CAT_LIST[] = array(0, $lang_albmgr_php['no_category']);
344
    get_subcat_data(0, '');
345
 
346
    echo <<<EOT
347
                <tr>
348
                        <td>
349
                                <b>{$lang_albmgr_php['select_category']}</b>
350
                                <select onChange="if(this.options[this.selectedIndex].value) window.location.href='$PHP_SELF?cat='+this.options[this.selectedIndex].value;"  name="cat" class="listbox">
351
EOT;
352
    foreach($CAT_LIST as $category) {
353
        echo '                                <option value="' . $category[0] . '"' . ($cat == $category[0] ? ' selected': '') . ">" . $category[1] . "</option>\n";
354
    }
355
    echo <<<EOT
356
                                </select>
357
                                <br /><br />
358
                        </td>
359
                </tr>
360
 
361
EOT;
362
}
363
 
364
?>
365
                <tr>
366
                        <td>
367
                                <select id="to" name="to[]" size="<?php echo min(max(count ($rowset) + 3, 15), 40) ?>" multiple onChange="Album_Select(this.selectedIndex);" class="listbox" style="width: 300px">
368
<?php
369
$i = 100;
370
$lb = '';
371
if (count ($rowset) > 0) foreach ($rowset as $album) {
372
    $lb .= '                                        <option value="album_no=' . $album['aid'] . ',album_nm=\'' . $album['title'] . '\',album_sort=' . ($i++) . ',action=0">' . stripslashes($album['title']) . "</option>\n";
373
}
374
echo $lb;
375
 
376
?>
377
                                </select>
378
                        </td>
379
                </tr>
380
                <tr>
381
                        <td>
382
                                <table width="100%" border="0" cellspacing="0" cellpadding="0">
383
                <tr>
384
                                        <td><a href="javascript:Moveup_Option();"><img src="images/move_up.gif" width="26" height="21" border="0"></a><a href="javascript:Movedown_Option();"><img src="images/move_down.gif" width="26" height="21" border="0"></a>
385
                                        </td>
386
                                        <td align="center" style="background-color: #D4D0C8; width: 80px; height: 21px; border-top: 1px solid White; border-left: 1px solid White; border-right: 1px solid #808080; border-bottom: 1px solid #808080;"><a href="javascript:Album_Delete();" style="color: Black; font-weight: bold;"><?php echo $lang_albmgr_php['delete'] ?></a>
387
                                        </td>
388
                                        <td align="center" style="width: 1px;"><img src="images/spacer.gif" width="1" alt=""><br>
389
                                        </td>
390
                                        <td align="center" style="background-color: #D4D0C8; width: 80px; height: 21px; border-top: 1px solid White; border-left: 1px solid White; border-right: 1px solid #808080; border-bottom: 1px solid #808080;"><a href="javascript:Album_Create();" style="color: Black; font-weight: bold;"><?php echo $lang_albmgr_php['new'] ?></a>
391
                                        </td>
392
                                </tr>
393
                                </table>
394
                        </td>
395
                </tr>
396
                <tr>
397
                        <td><br>
398
                                <input type="text" name="album_nm" size="27" maxlength="80" class="textinput" style="width: 300px;" onChange="Album_NameChange(this.value);" onKeyUp="Album_NameChange(this.value);">
399
                                <br>
400
                                <br>
401
                        </td>
402
                </tr>
403
        </table>
404
        </td>
405
</tr>
406
<tr>
407
        <td colspan="2" align="center" class="tablef">
408
        <input type="submit" class="button" value="<?php echo $lang_albmgr_php['apply_modifs'] ?>">
409
        </td>
410
        </form>
411
</tr>
412
<?php
413
endtable();
414
pagefooter();
415
ob_end_flush();
416
 
417
?>