source: extensions/title/admin.php

Last change on this file was 32994, checked in by ddtddt, 4 months ago

[meta] check php8.3 and update for Piwigo14

File size: 7.8 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Title plugin for piwigo by TEMMII                                     |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2011 - 2023 ddtddt             http://temmii.com/piwigo/ |
6// +-----------------------------------------------------------------------+
7// | This program is free software; you can redistribute it and/or modify  |
8// | it under the terms of the GNU General Public License as published by  |
9// | the Free Software Foundation                                          |
10// |                                                                       |
11// | This program is distributed in the hope that it will be useful, but   |
12// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
13// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
14// | General Public License for more details.                              |
15// |                                                                       |
16// | You should have received a copy of the GNU General Public License     |
17// | along with this program; if not, write to the Free Software           |
18// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
19// | USA.                                                                  |
20// +-----------------------------------------------------------------------+
21
22if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
23global $template, $conf, $user, $pwg_loaded_plugins;
24include_once(PHPWG_ROOT_PATH .'admin/include/tabsheet.class.php');
25$my_base_url = PHPWG_ROOT_PATH.'admin.php?page=plugin-';
26
27// +-----------------------------------------------------------------------+
28// | Check Access and exit when user status is not ok                      |
29// +-----------------------------------------------------------------------+
30check_status(ACCESS_ADMINISTRATOR);
31
32// Gestion des onglets
33$page['tab'] = (isset($_GET['tab'])) ? $_GET['tab'] : 'permissions';
34if ('album' == $page['tab']){
35        check_input_parameter('cat_id', $_GET, false, PATTERN_ID);
36        $cat_id = $_GET['cat_id'];
37        $page['tab'] = 'title-album';
38        $admin_album_base_url = get_root_url().'admin.php?page=album-'.$cat_id;
39        $query = '
40     SELECT *
41         FROM '.CATEGORIES_TABLE.'
42         WHERE id = '.$cat_id.'
43         ;';
44        $category = pwg_db_fetch_assoc(pwg_query($query));
45        if (!isset($category['id'])){
46         die("unknown album");
47        }
48
49        $tabsheet = new tabsheet();
50        $tabsheet->set_id('album');
51        $tabsheet->select('title-album');
52        $tabsheet->assign();
53    $template->assign(
54      'titlegestalbum', array(
55      'A' => 'A'
56    ));
57  if (isset($_GET['cat_id'])){
58        global $template, $prefixeTable, $pwg_loaded_plugins;
59        $query = 'select id,title FROM ' . TITLE_ALBUM_TABLE . ' WHERE id = '.$_GET['cat_id'].';';
60        $result = pwg_query($query);
61        $row = pwg_db_fetch_assoc($result);
62        if (isset($row['title'])){
63         $titleA=$row['title'];
64         $template->assign(
65      array(
66        'titleCONTENT' => $titleA,
67     ));
68        }else{
69                $template->assign(
70      array(
71        'titleCONTENT' => "",
72     ));
73        }
74        if (isset($pwg_loaded_plugins['ExtendedDescription'])){
75          $template->assign('useED',1);
76    }else{
77      $template->assign('useED',0);
78    }
79
80  }
81  if (isset($_POST['submittitlealbum'])){
82        $query = 'DELETE FROM ' . TITLE_ALBUM_TABLE . ' WHERE id = '.$_GET['cat_id'].';';
83        $result = pwg_query($query);
84        $q = 'INSERT INTO ' . $prefixeTable . 'title_album(id,title)VALUES ('.$_GET['cat_id'].',"'.$_POST['insertitleA'].'");';
85    pwg_query($q);
86        $template->assign(
87      array(
88        'titleCONTENT' => $_POST['insertitleA'],
89    ));
90        $page['infos'][] = l10n('Album updated successfully');
91  }
92   
93}else{
94if (!isset($_GET['tab']))
95  $page['tab'] = 'plugtitle';
96else
97  $page['tab'] = $_GET['tab'];
98
99$tabsheet = new tabsheet();
100  $tabsheet->add('plugtitle', l10n('title_tab_plgtitle'), TITLE_ADMIN . '-plugtitle');
101  if (isset($pwg_loaded_plugins['ContactForm'])){
102        $tabsheet->add('contacttitle', l10n('Contact Title'), TITLE_ADMIN . '-contacttitle');
103  }
104  if (isset($pwg_loaded_plugins['AdditionalPages'])){
105        $tabsheet->add('AdditionalPagestitle', l10n('Additional Pages Title'), TITLE_ADMIN . '-AdditionalPagestitle');
106  }                       
107$tabsheet->select($page['tab']);
108$tabsheet->assign();
109}
110// Tab Title on specials pages
111switch ($page['tab'])
112{
113  case 'plugtitle':
114
115$titlepagelistT = array(
116    l10n('title_select'),
117        '----------------------',
118    l10n('Home'),
119    l10n('Best rated'),
120    l10n('Most visited'),
121        l10n('Recent pictures'),
122        l10n('Recent categories'),
123        l10n('Favorites'),
124        l10n('Tags'),
125        l10n('Comments'),
126        l10n('About'),
127        l10n('search'),
128        l10n('Random pictures'),
129        l10n('Notification'),
130  );
131 
132$titlepagelist = array(
133    '',
134    '',
135    'home',
136    'best_rated',
137    'most_visited',
138        'recent_pics',
139        'recent_cats',
140        'favorites',
141        'tags',
142        'comments',
143        'about',
144        'search',
145        'random',
146        'notification',
147  );
148 
149    $template->assign(
150    'gestionA',
151    array(
152      ));
153
154$template->assign('titlepagelist', $titlepagelist);
155$template->assign('titlepagelistT', $titlepagelistT);
156
157if (isset($_POST['subtitlespecialET']) and (!$_POST['titlelist'])==0)
158        {
159$lire=$_POST['titlelist'];
160        $query = '
161select id,page,title
162  FROM ' . TITLE_TABLE . '
163  WHERE page = \''.$lire.'\'
164  ;';
165$result = pwg_query($query);
166
167$row = pwg_db_fetch_assoc($result);
168$titlepage=$row['page'];
169$titletitle=$row['title'];
170
171  $selected2 = "";
172 
173  $template->assign(
174    'title_edit',
175    array(
176      'VALUE' => $titlepage,
177      'CONTENT' => $titletitle,
178      'SELECTED' => $selected2
179      ));
180        }
181
182if (isset($_POST['subtitlespecial']))
183        {
184        $query = '
185UPDATE ' . TITLE_TABLE . '
186  SET title= \''.$_POST['inser'].'\'
187  WHERE page = \''.$_POST['invisible'].'\'
188    ;';
189$result = pwg_query($query);
190        }
191
192    break;
193       
194        case 'contacttitle':
195       
196        $template->assign('gestB',
197    array('CTBASE' => $conf['contacttitle'],));
198
199if (isset($_POST['submitct']))
200        {
201conf_update_param('contacttitle', $_POST['contacttitle']);
202$template->assign(
203    'gestB',
204    array('CTBASE' => stripslashes($_POST['contacttitle']),));
205        }
206       
207        break;
208
209        case 'AdditionalPagestitle':
210if (!defined('TITLE_AP_TABLE')) define('TITLE_AP_TABLE', $prefixeTable.'title_ap');
211$groups = array();
212$query = '
213select id,title
214  FROM ' . ADD_PAGES_TABLE . '
215  ORDER BY id ASC;';
216$result = pwg_query($query);
217       
218        while ($row = pwg_db_fetch_assoc($result))
219        {
220  $groups[$row['id']] = $row['id'].' : '.$row['title'];
221        }
222       
223        $selected = 0;
224        $options[] = l10n('Choose the page');
225        $options['a'] = '----------------------';
226       
227foreach($groups as $listid => $listid2)
228        {
229    $options[$listid] = $listid2;
230        }
231  $template->assign(
232    'gestionC',
233    array(
234          'OPTIONS' => $options,
235      'SELECTED' => $selected
236      ));
237       
238        if (isset($_POST['submitchoixAP'])and is_numeric($_POST['APchoix']) and (!$_POST['APchoix'])==0)
239        {
240$lire=$_POST['APchoix'];
241        $query = '
242select id,title
243  FROM ' . TITLE_AP_TABLE . '
244  WHERE id = \''.$lire.'\'
245  ;';
246$result = pwg_query($query);
247$row = pwg_db_fetch_assoc($result);
248$idap=$row['id'];
249$titleap=$row['title'];
250
251$query = '
252select id,title
253  FROM ' . ADD_PAGES_TABLE . '
254  WHERE id = \''.$lire.'\'
255    ;';
256$result = pwg_query($query);
257$row = pwg_db_fetch_assoc($result);
258$idap=$row['id'];
259$nameap=$row['title'];
260
261  $selected3 = 0;
262 
263  $template->assign(
264    'ap_edit',
265    array(
266      'VALUE' => $idap,
267          'VALUEN' => $nameap,
268      'CONTENT' => $titleap,
269      'SELECTED' => $selected3
270      ));
271        }
272
273if (isset($_POST['submitinsapt']))
274        {
275        $query = '
276DELETE
277  FROM ' . TITLE_AP_TABLE . '
278  WHERE id = \''.$_POST['invisible'].'\'
279  ;';
280$result = pwg_query($query);
281        $q = '
282INSERT INTO ' . $prefixeTable . 'title_ap(id,title)VALUES ('.$_POST['invisible'].',"'.$_POST['insertitle'].'");';
283    pwg_query($q);
284        }
285       
286        break;
287       
288} 
289
290$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); 
291$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
292?>
Note: See TracBrowser for help on using the repository browser.