1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based photo gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | |
---|
6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | This program is free software; you can redistribute it and/or modify | |
---|
10 | // | it under the terms of the GNU General Public License as published by | |
---|
11 | // | the Free Software Foundation | |
---|
12 | // | | |
---|
13 | // | This program is distributed in the hope that it will be useful, but | |
---|
14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
16 | // | General Public License for more details. | |
---|
17 | // | | |
---|
18 | // | You should have received a copy of the GNU General Public License | |
---|
19 | // | along with this program; if not, write to the Free Software | |
---|
20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
21 | // | USA. | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | |
---|
24 | |
---|
25 | // The "No Photo Yet" feature: if you have no photo yet in your gallery, the |
---|
26 | // gallery displays only a big box to show you the way for adding your first |
---|
27 | // photos |
---|
28 | if ( |
---|
29 | !(defined('IN_ADMIN') and IN_ADMIN) // no message inside administration |
---|
30 | and script_basename() != 'identification' // keep the ability to login |
---|
31 | and script_basename() != 'ws' // keep the ability to discuss with web API |
---|
32 | and script_basename() != 'popuphelp' // keep the ability to display help popups |
---|
33 | and !isset($_SESSION['no_photo_yet']) // temporary hide |
---|
34 | ) |
---|
35 | { |
---|
36 | $query = ' |
---|
37 | SELECT |
---|
38 | COUNT(*) |
---|
39 | FROM '.IMAGES_TABLE.' |
---|
40 | ;'; |
---|
41 | list($nb_photos) = pwg_db_fetch_row(pwg_query($query)); |
---|
42 | if (0 == $nb_photos) |
---|
43 | { |
---|
44 | // make sure we don't use the mobile theme, which is not compatible with |
---|
45 | // the "no photo yet" feature |
---|
46 | $template = new Template(PHPWG_ROOT_PATH.'themes', $user['theme']); |
---|
47 | |
---|
48 | if (isset($_GET['no_photo_yet'])) |
---|
49 | { |
---|
50 | if ('browse' == $_GET['no_photo_yet']) |
---|
51 | { |
---|
52 | $_SESSION['no_photo_yet'] = 'browse'; |
---|
53 | redirect(make_index_url()); |
---|
54 | exit(); |
---|
55 | } |
---|
56 | |
---|
57 | if ('deactivate' == $_GET['no_photo_yet']) |
---|
58 | { |
---|
59 | conf_update_param('no_photo_yet', 'false'); |
---|
60 | redirect(make_index_url()); |
---|
61 | exit(); |
---|
62 | } |
---|
63 | } |
---|
64 | |
---|
65 | header('Content-Type: text/html; charset='.get_pwg_charset()); |
---|
66 | $template->set_filenames(array('no_photo_yet'=>'no_photo_yet.tpl')); |
---|
67 | |
---|
68 | if (is_admin()) |
---|
69 | { |
---|
70 | $url = $conf['no_photo_yet_url']; |
---|
71 | if (substr($url, 0, 4) != 'http') |
---|
72 | { |
---|
73 | $url = get_root_url().$url; |
---|
74 | } |
---|
75 | |
---|
76 | $template->assign( |
---|
77 | array( |
---|
78 | 'step' => 2, |
---|
79 | 'intro' => l10n( |
---|
80 | 'Hello %s, your Piwigo photo gallery is empty!', |
---|
81 | $user['username'] |
---|
82 | ), |
---|
83 | 'next_step_url' => $url, |
---|
84 | 'deactivate_url' => get_root_url().'?no_photo_yet=deactivate', |
---|
85 | ) |
---|
86 | ); |
---|
87 | } |
---|
88 | else |
---|
89 | { |
---|
90 | |
---|
91 | $template->assign( |
---|
92 | array( |
---|
93 | 'step' => 1, |
---|
94 | 'U_LOGIN' => 'identification.php', |
---|
95 | 'deactivate_url' => get_root_url().'?no_photo_yet=browse', |
---|
96 | ) |
---|
97 | ); |
---|
98 | } |
---|
99 | |
---|
100 | trigger_notify('loc_end_no_photo_yet'); |
---|
101 | |
---|
102 | $template->pparse('no_photo_yet'); |
---|
103 | exit(); |
---|
104 | } |
---|
105 | else |
---|
106 | { |
---|
107 | conf_update_param('no_photo_yet', 'false'); |
---|
108 | } |
---|
109 | } |
---|
110 | |
---|
111 | ?> |
---|