source: extensions/meta_og/admin.php @ 32296

Last change on this file since 32296 was 32229, checked in by ddtddt, 4 years ago

[Meta_OG] add chose albums for list photos / options use other image for album and photo

File size: 10.2 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | meta_og plugin for Piwigo by TEMMII                                   |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2020 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
22
23if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
24global $template, $conf, $user;
25include_once(PHPWG_ROOT_PATH .'admin/include/tabsheet.class.php');
26include_once(metaog_PATH . 'include/function.mog.inc.php');
27// +-----------------------------------------------------------------------+
28// | Check Access and exit when user status is not ok                      |
29// +-----------------------------------------------------------------------+
30check_status(ACCESS_ADMINISTRATOR);
31
32// Gestion des onglets
33if (!isset($_GET['tab']))
34  $page['tab'] = 'gestion';
35else
36  $page['tab'] = $_GET['tab'];
37
38$tabsheet = new tabsheet();
39$tabsheet->add('gestion', l10n('Add Open Graph metadata'), METAOG_ADMIN . '-gestion');
40$tabsheet->add('config', l10n('Configuration'), METAOG_ADMIN . '-config');
41
42$tabsheet->select($page['tab']);
43$tabsheet->assign();
44
45// Tab Title on specials pages
46switch ($page['tab'])
47{
48 case 'gestion':
49                global $pwg_loaded_plugins;
50       
51$metaogpagelistT = array(
52    l10n('Select Page'),
53        '----------------------',
54    l10n('Home'),
55    l10n('Best rated'),
56    l10n('Most visited'),
57        l10n('Recent pictures'),
58        l10n('Recent categories'),
59        l10n('Favorites'),
60        l10n('Tags'),
61        l10n('Comments'),
62        l10n('About'),
63        l10n('search'),
64        l10n('Random pictures'),
65        l10n('Notification'),
66  );
67
68$metaogpagelist = array(
69    '',
70    '',
71    'categories',
72    'best_rated',
73    'most_visited',
74        'recent_pics',
75        'recent_cats',
76        'favorites',
77        'tags',
78        'comments',
79        'about',
80        'search',
81        'list',
82        'notification',
83  );
84  if (isset($pwg_loaded_plugins['ContactForm'])){
85        $metaogpagelistT[]=l10n('contact');
86        $metaogpagelist[]='contact';
87  }
88  if (isset($pwg_loaded_plugins['GuestBook'])){
89        $metaogpagelistT[]=l10n('GuestBook');
90        $metaogpagelist[]='GuestBook';
91  }
92  if (isset($pwg_loaded_plugins['GuestBook'])){
93    $result = pwg_query('SELECT id,title FROM ' . ADD_PAGES_TABLE . ' ORDER BY id ASC;');
94        while ($row = pwg_db_fetch_assoc($result)) {
95          $metaogpagelistT[]=l10n('Additional Page').' : '.$row['title'];
96          $metaogpagelist[]=$row['id'];
97        }
98 
99 
100  }
101    $template->assign(
102    'metagestion',
103    array(
104      'a' => 'a',
105      ));
106
107$template->assign('metaogpagelist', $metaogpagelist);
108$template->assign('metaogpagelistT', $metaogpagelistT);
109
110  if (isset($_POST['submetaogchp'])){
111        if(empty($_POST['metaoglist'])){
112        array_push($page['errors'], l10n('You must select a page'));
113        break;
114        }
115        $pageog=$_POST['metaoglist'];
116    if(is_numeric($pageog)){$type='4';}else{$type='1';}
117        $metaog = pwg_db_fetch_assoc(pwg_query("SELECT * FROM " . METAOG_TABLE . " WHERE type = ".$type." AND page = '".$_POST['metaoglist']."';"));
118        if(empty($metaog)){
119                $metaog['id']='';
120                $metaog['metaogtitle']='';
121                $metaog['metaogdescription']='';
122                $metaog['metaogimage']='';
123        }
124        $metaog['path']='';
125        $tab_picture = listphotosmog();
126        if (pwg_db_num_rows($tab_picture)) {
127        while ($info_photos = pwg_db_fetch_assoc($tab_picture)) {
128                        if($info_photos['id']==$metaog['metaogimage']){
129                                $select="SELECTED";
130                                $metaog['path']=$info_photos['path'];
131                        }else{
132                                $select="";
133                                $path="";
134                        }
135          if(empty($info_photos['name'])){$legend=$info_photos['file'];}else{$legend=$info_photos['name'];}
136                $items = array(
137                  'PHOTOID' => $info_photos['id'],
138                  'PHOTOINFO' => $info_photos['id'].' - '.$legend,
139                  'PHOTOSELECT' => $select,
140                  'PHOTOURL' => get_absolute_root_url().PWG_DERIVATIVE_DIR.substr($info_photos['path'], 2, -4)."-th".substr($info_photos['path'],-4),
141                );
142                        $template->append('info_photos', $items);
143        }
144    }
145        if (empty($metaog['metaogimage'])){unset($metaog['metaogimage']);}
146        if(isset($metaog['metaogimage'])){     
147          $metaogpath=get_absolute_root_url().PWG_DERIVATIVE_DIR.substr($metaog['path'], 2, -4)."-th".substr($metaog['path'],-4);
148        }else{
149          $metaogpath="";
150          $metaog['metaogimage']="";
151        }
152         $template->assign(
153     'metaog_edit',
154          array(
155                'id'  => $metaog['id'],
156                'VALUE'  => $pageog,
157        'metaogtitle' => $metaog['metaogtitle'],
158                'metaogdescription' => $metaog['metaogdescription'],
159                'metaogimage' => $metaog['metaogimage'],
160                'metaogpath' => $metaogpath,
161    ));
162  }
163
164  if (isset($_POST['submetaogsave'])){
165        if($_POST['metaogimagesave']=="-10" || $_POST['metaogimagesave']=="-20"){$_POST['metaogimagesave']='';}
166        if(!empty($_POST['metaogid'])){
167        $query = '
168                UPDATE ' . METAOG_TABLE . '
169                        SET metaogtitle= \''.$_POST['metaogtitlesave'].'\'
170                        ,metaogdescription= \''.$_POST['metaogdescriptionsave'].'\'
171                        ,metaogimage= \''.$_POST['metaogimagesave'].'\'
172                        WHERE id = \''.$_POST['metaogid'].'\'
173    ;';
174        pwg_query($query);
175        }else{
176if(is_numeric($_POST['metaogpage'])){$type='4';}else{$type='1';}               
177        $q = 'INSERT INTO ' . $prefixeTable . 'metaog(type,page,metaogtitle,metaogdescription,metaogimage)VALUES ('.$type.',"' . $_POST['metaogpage'] . '","' . $_POST['metaogtitlesave'] . '","' . $_POST['metaogdescriptionsave'] . '","' . $_POST['metaogimagesave'] .'");';
178    pwg_query($q);
179    }
180        array_push($page['infos'], l10n('Metadata Open Graph updated'));
181  }
182
183
184 break;
185 case 'config':
186 
187$mog1T = array(
188    '    '.l10n('no photos and albums pages'),
189    '    '.l10n('photos pages'),
190    '    '.l10n('albums pages'),
191        '    '.l10n('photos and albums pages'),
192  );
193
194$mog1 = array(
195    '1',
196    '2',
197    '3',
198        '4',
199  );   
200
201$template->assign('mog1T', $mog1T);
202$template->assign('mog1', $mog1); 
203 
204$metaogsizelistT = array(
205    '2s : '.l10n('size thumbnails modus'),
206    'cu : '.l10n('size thumbnails bootstrap'),
207    'th : '.l10n('size thumbnails default'),
208        'sq : '.l10n('size thumbnails square'),
209        'me : '.l10n('Size medium'),
210        'la : '.l10n('size thumbnails large'),
211        l10n('Original'),
212  );
213 
214$metaogsizelist = array(
215    '2s',
216    'cu',
217    'th',
218        'sq',
219        'me',
220        'la',
221        'original',
222  );
223 
224$template->assign('metaogsizelist', $metaogsizelist);
225$template->assign('metaogsizelistT', $metaogsizelistT);
226
227$tab_lang = pwg_query('SELECT id,name FROM ' . LANGUAGES_TABLE . ' order by id;');
228        if (pwg_db_num_rows($tab_lang)) {
229        while ($info_lang = pwg_db_fetch_assoc($tab_lang)) {
230                        if($info_lang['id']==$conf['moglocal']){
231                                $select="SELECTED";
232                        }else{
233                                $select="";
234                        }
235                        $items = array(
236                                        'OGLID' => $info_lang['id'],
237                                        'OGLNAME' => $info_lang['name'],
238                                        'LANGSELECT' => $select,
239                                );
240                        $template->append('info_lang', $items);
241        }
242    }
243 $template->assign(array(
244  'languages_other' => '',
245  'CACHE_KEYS' => get_admin_client_cache_keys(array('languages')),
246  'PWG_TOKEN' => get_pwg_token(),
247  ));
248 
249  $metaogtwcalistT = array(
250    l10n('empty'),
251    'summary : '.l10n('share your pages with a small squared thumbnail and informations'),
252    'summary_large_image : '.l10n('share your pages with a full width picture and informations'),
253        //'app : '.l10n('explain app'),
254        //'player : '.l10n('explain player'),
255  );
256 
257$metaogtwcalist = array(
258    'a',
259    'summary',
260    'summary_large_image',
261        //'app',
262        //'player',
263  );
264 
265$template->assign('metaogtwcalist', $metaogtwcalist);
266$template->assign('metaogtwcalistT', $metaogtwcalistT);
267
268$listchose=safe_unserialize($conf['moglista']);
269if(!isset($conf['mogshowpa'])){$conf['mogshowpa']=1;}
270 
271    $template->assign(
272     'metaogconfig',
273          array(
274        'MOGsize' => $conf['mogsize'],
275                'MOGFB' => $conf['fb:app_id'],
276                'MOGSN' => $conf['mogsitename'],
277                'MOGTCA' => $conf['mogtwcard'],
278                'MOGTS' => $conf['mogtwsite'],
279                'MOGTCR' => $conf['mogtwcreator'],
280                'MOGSPA' => $conf['mogshowpa'],
281                'choose_albums' => $listchose,
282    ));
283       
284  if (isset($_POST['submitogconfig'])){
285    conf_update_param('mogshowpa', $_POST['metaogconfishowpa']);
286        conf_update_param('moglista', $_POST['moglistea']);
287        conf_update_param('mogsize', $_POST['metaogconfigsize']);
288    conf_update_param('fb:app_id', $_POST['metaogconfigfb']);
289  if (isset($_POST['metaogconfiglo'])){ 
290        if($_POST['metaogconfiglo']=="a" || $_POST['metaogconfiglo']=="b"){$_POST['metaogconfiglo']='';}
291          if($_POST['metaogconfiglo']=='en_UK'){
292                $_POST['metaogconfiglo']='en_US';
293          }
294           if($_POST['metaogconfiglo']=='ar_SA'||$_POST['metaogconfiglo']=='ar_MA'||$_POST['metaogconfiglo']=='ar_EG'){
295                $_POST['metaogconfiglo']='ar_AR';
296          }
297           if($_POST['metaogconfiglo']=='es_ES'){
298                $_POST['metaogconfiglo']='en_LA';
299          }
300          conf_update_param('moglocal', $_POST['metaogconfiglo']);
301  }
302  if (isset($_POST['metaogconfigsname'])){
303          conf_update_param('mogsitename', $_POST['metaogconfigsname']);
304  }
305  if (isset($_POST['metaogconfigtwca'])){
306          if($_POST['metaogconfigtwca']=='a'){$_POST['metaogconfigtwca']='';}
307          conf_update_param('mogtwcard', $_POST['metaogconfigtwca']);
308  }
309  if (isset($_POST['metaogconfitws'])){
310          conf_update_param('mogtwsite', $_POST['metaogconfitws']);
311  }
312  if (isset($_POST['metaogconfitwcr'])){
313          conf_update_param('mogtwcreator', $_POST['metaogconfitwcr']);
314  }
315        header('Location:'.METAOG_ADMIN . '-config');
316}
317       
318 break;
319} 
320
321$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); 
322$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
323?>
Note: See TracBrowser for help on using the repository browser.