source: extensions/meta/initadmin.php

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

[meta] check php8.3 and update for Piwigo14

File size: 6.4 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | meta plugin for Piwigo by TEMMII                                      |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-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'))
23    die('Hacking attempt!');
24
25//Add link menu
26/*
27add_event_handler('get_admin_plugin_menu_links', 'meta_admin_menu');
28
29function meta_admin_menu($menu) {
30  $menu[] = array(
31    'NAME' => l10n('Manage tag Metadata'),
32    'URL' => META_ADMIN,
33  );
34  return $menu;
35}*/
36
37//add prefiltre photo
38add_event_handler('loc_begin_admin', 'metaPadminf', 55);
39add_event_handler('loc_begin_admin_page', 'metaPadminA', 55);
40
41function metaPadminf() {
42  global $template;
43  $template->set_prefilter('picture_modify', 'metaPadminfT');
44}
45
46function metaPadminfT($content){
47  $search = '#<input type="hidden" name="pwg_token"#';
48  $replacement = '
49        <p>
50      <strong>{\'Metadata - Plugin meta\'|@translate}</strong>
51      <br>
52          <span style="margin: 0 0 0 20px">{\'meta_compimg\'|@translate}</span>
53          <br>
54      <span style="margin: 0 0 0 20px"><textarea rows="2" cols="60" {if $useED==1}placeholder="{\'Use Extended Description tags...\'|@translate}"{/if} name="insermetaKP" id="insermetaKP" class="insermetaKP">{$metaCONTENT}</textarea></span>
55          <br>
56          <span style="margin: 0 0 0 20px">{\'meta_compimgdes\'|@translate}</span>
57          <br>
58          <span style="margin: 0 0 0 20px"><textarea rows="2" cols="60" {if $useED==1}placeholder="{\'Use Extended Description tags...\'|@translate}"{/if} name="insermetaDP" id="insermetaDP" class="insermetaDP">{$metaCONTENT2}</textarea>
59          ({\'meta_compcatdeshelp\'|@translate})</span>
60        </p> 
61<input type="hidden" name="pwg_token"';
62
63  return preg_replace($search, $replacement, $content);
64}
65
66function metaPadminA() {
67  if (isset($_GET['image_id'])){
68        global $template, $prefixeTable, $pwg_loaded_plugins;
69        if (isset($pwg_loaded_plugins['ExtendedDescription'])){
70          $template->assign('useED',1);
71    }else{
72      $template->assign('useED',0);
73    }
74        $query = 'SELECT id,metaKeyimg,metadesimg FROM ' . meta_img_TABLE . ' WHERE id = ' . $_GET['image_id'] . ';';
75        $result = pwg_query($query);
76        $row = pwg_db_fetch_assoc($result);
77        if(!isset($row['metaKeyimg'])){$row['metaKeyimg']="";};
78        if(!isset($row['metadesimg'])){$row['metadesimg']="";};
79        $template->assign(
80        array(
81          'metaCONTENT' => $row['metaKeyimg'],
82          'metaCONTENT2' => $row['metadesimg'],
83        ));
84  }
85  if (isset($_POST['insermetaKP']) or isset($_POST['insermetaDP'])){
86    $query = 'DELETE FROM ' . meta_img_TABLE . ' WHERE id = ' . $_GET['image_id'] . ';';
87    $result = pwg_query($query);
88    $q = 'INSERT INTO ' . $prefixeTable . 'meta_img(id,metaKeyimg,metadesimg)VALUES (' . $_GET['image_id'] . ',"' . $_POST['insermetaKP'] . '","' . $_POST['insermetaDP'] . '");';
89    pwg_query($q);
90        $template->assign(
91          array(
92                'metaCONTENT' => $_POST['insermetaKP'],
93                'metaCONTENT2' => $_POST['insermetaDP'],
94        ));
95  }
96}
97
98/*//add prefiltre album
99add_event_handler('loc_begin_admin', 'metaAadminf');
100add_event_handler('loc_begin_admin_page', 'metaAadminA');
101
102function metaAadminf() {
103  global $template;
104  $template->set_prefilter('album_properties', 'metaAadminfT');
105}
106
107function metaAadminfT($content){
108  $search = '#<p style="margin:0">#';
109  $replacement = '
110        <p>
111      <strong>{\'Metadata - Plugin meta\'|@translate}</strong>
112      <br>
113          <span style="margin: 0 0 0 20px">{\'meta_compcat\'|@translate}</span>
114          <br>
115      <span style="margin: 0 0 0 20px"><textarea rows="2" cols="60" {if $useED==1}placeholder="{\'Use Extended Description tags...\'|@translate}"{/if} name="insermetaKA" id="insermetaKA" class="insermetaKA">{$metaCONTENTA}</textarea></span>
116          <br>
117          <span style="margin: 0 0 0 20px">{\'meta_compcatdes\'|@translate}</span>
118          <br>
119          <span style="margin: 0 0 0 20px"><textarea rows="2" cols="60" {if $useED==1}placeholder="{\'Use Extended Description tags...\'|@translate}"{/if} name="insermetaDA" id="insermetaDA" class="insermetaDA">{$metaCONTENTA2}</textarea>
120          ({\'meta_compcatdeshelp\'|@translate})</span>
121        </p> 
122<p style="margin:0">
123  ';
124  return preg_replace($search, $replacement, $content);
125}
126
127function metaAadminA(){
128  if (isset($_GET['cat_id'])) {
129        global $template, $prefixeTable, $pwg_loaded_plugins;
130        if (isset($pwg_loaded_plugins['ExtendedDescription'])){
131          $template->assign('useED',1);
132        }else{
133          $template->assign('useED',0);
134        }
135        $query = 'SELECT id,metaKeycat,metadescat FROM ' . meta_cat_TABLE . ' WHERE id = ' . $_GET['cat_id'] . ';';
136        $result = pwg_query($query);
137        $row = pwg_db_fetch_assoc($result);
138        if(!isset($row['metaKeycat'])){$row['metaKeycat']="";};
139        if(!isset($row['metadescat'])){$row['metadescat']="";};
140        $template->assign(
141          array(
142                'metaCONTENTA' => $row['metaKeycat'],
143                'metaCONTENTA2' => $row['metadescat'],
144        ));
145  }
146
147  if (isset($_POST['insermetaKA']) or isset($_POST['insermetaDA']) ) {
148    $query = 'DELETE FROM ' . meta_cat_TABLE . ' WHERE id = ' . $_GET['cat_id'] . ';';
149        $result = pwg_query($query);
150        $q = 'INSERT INTO ' . $prefixeTable . 'meta_cat(id,metaKeycat,metadescat)VALUES (' . $_GET['cat_id'] . ',"' . $_POST['insermetaKA'] . '","' . $_POST['insermetaDA'] . '");';
151        pwg_query($q);
152        $template->assign(
153          array(
154                'metaCONTENTA' => $_POST['insermetaKA'],
155                'metaCONTENTA2' => $_POST['insermetaDA'],
156        ));
157  }
158}*/
159
160?>
Note: See TracBrowser for help on using the repository browser.