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 | |
---|
22 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
23 | |
---|
24 | //add prefiltre photo |
---|
25 | add_event_handler('loc_begin_admin', 'titlePadminf',60); |
---|
26 | add_event_handler('loc_begin_admin_page', 'titlePadminA',60); |
---|
27 | |
---|
28 | function titlePadminf(){ |
---|
29 | global $template; |
---|
30 | $template->set_prefilter('picture_modify', 'titlePadminfT'); |
---|
31 | } |
---|
32 | |
---|
33 | function titlePadminfT($content){ |
---|
34 | $search = '#<input type="hidden" name="pwg_token"#'; |
---|
35 | $replacement = ' |
---|
36 | <p> |
---|
37 | <strong>{\'title_photo\'|@translate}</strong> |
---|
38 | <br> |
---|
39 | <textarea rows="4" cols="80" {if $useED==1}placeholder="{\'Use Extended Description tags...\'|@translate}"{/if} name="insertitleP" id="insertitleP" class="insertitleP">{$titleICONTENT}</textarea> |
---|
40 | </p> |
---|
41 | |
---|
42 | <input type="hidden" name="pwg_token"'; |
---|
43 | |
---|
44 | return preg_replace($search, $replacement, $content); |
---|
45 | } |
---|
46 | |
---|
47 | function titlePadminA(){ |
---|
48 | if (isset($_GET['image_id'])){ |
---|
49 | global $template, $prefixeTable, $pwg_loaded_plugins; |
---|
50 | $query = 'select id,title FROM ' . TITLE_PHOTO_TABLE . ' WHERE id = '.$_GET['image_id'].';'; |
---|
51 | $result = pwg_query($query); |
---|
52 | $row = pwg_db_fetch_assoc($result); |
---|
53 | if (isset($row['title'])){ |
---|
54 | $titleP=$row['title']; |
---|
55 | $template->assign( |
---|
56 | array( |
---|
57 | 'titleICONTENT' => $titleP, |
---|
58 | )); |
---|
59 | }else{ |
---|
60 | $template->assign( |
---|
61 | array( |
---|
62 | 'titleICONTENT' => "", |
---|
63 | )); |
---|
64 | } |
---|
65 | if (isset($pwg_loaded_plugins['ExtendedDescription'])){ |
---|
66 | $template->assign('useED',1); |
---|
67 | }else{ |
---|
68 | $template->assign('useED',0); |
---|
69 | } |
---|
70 | |
---|
71 | } |
---|
72 | if (isset($_POST['insertitleP'])){ |
---|
73 | $query = 'DELETE FROM ' . TITLE_PHOTO_TABLE . ' WHERE id = '.$_GET['image_id'].';'; |
---|
74 | $result = pwg_query($query); |
---|
75 | $q = 'INSERT INTO ' . $prefixeTable . 'title_photo(id,title)VALUES ('.$_GET['image_id'].',"'.$_POST['insertitleP'].'");'; |
---|
76 | pwg_query($q); |
---|
77 | $template->assign( |
---|
78 | array( |
---|
79 | 'titleICONTENT' => $_POST['insertitleP'], |
---|
80 | )); |
---|
81 | } |
---|
82 | } |
---|
83 | /* |
---|
84 | //add prefiltre album |
---|
85 | add_event_handler('loc_begin_admin', 'titleAadminf', 60); |
---|
86 | add_event_handler('loc_begin_admin_page', 'titleAadminA', 60); |
---|
87 | |
---|
88 | function titleAadminf() |
---|
89 | { |
---|
90 | global $template; |
---|
91 | $template->set_prefilter('album_properties', 'titleAadminfT'); |
---|
92 | } |
---|
93 | |
---|
94 | function titleAadminfT($content) |
---|
95 | { |
---|
96 | $search = '#<p style="margin:0">#'; |
---|
97 | |
---|
98 | $replacement = ' |
---|
99 | <p> |
---|
100 | <strong>{\'title_album\'|@translate}</strong> |
---|
101 | <br> |
---|
102 | <textarea rows="4" cols="80" {if $useED==1}placeholder="{\'Use Extended Description tags...\'|@translate}"{/if} name="insertitleA" id="insertitleA" class="insertitleA">{$titleCONTENT}</textarea> |
---|
103 | </p> |
---|
104 | |
---|
105 | |
---|
106 | <p style="margin:0">'; |
---|
107 | |
---|
108 | return preg_replace($search, $replacement, $content); |
---|
109 | } |
---|
110 | |
---|
111 | function titleAadminA(){ |
---|
112 | if (isset($_GET['cat_id'])){ |
---|
113 | global $template, $prefixeTable, $pwg_loaded_plugins; |
---|
114 | $query = 'select id,title FROM ' . TITLE_ALBUM_TABLE . ' WHERE id = '.$_GET['cat_id'].';'; |
---|
115 | $result = pwg_query($query); |
---|
116 | $row = pwg_db_fetch_assoc($result); |
---|
117 | if (isset($row['title'])){ |
---|
118 | $titleA=$row['title']; |
---|
119 | $template->assign( |
---|
120 | array( |
---|
121 | 'titleCONTENT' => $titleA, |
---|
122 | )); |
---|
123 | }else{ |
---|
124 | $template->assign( |
---|
125 | array( |
---|
126 | 'titleCONTENT' => "", |
---|
127 | )); |
---|
128 | } |
---|
129 | if (isset($pwg_loaded_plugins['ExtendedDescription'])){ |
---|
130 | $template->assign('useED',1); |
---|
131 | }else{ |
---|
132 | $template->assign('useED',0); |
---|
133 | } |
---|
134 | |
---|
135 | } |
---|
136 | if (isset($_POST['insertitleA'])){ |
---|
137 | $query = 'DELETE FROM ' . TITLE_ALBUM_TABLE . ' WHERE id = '.$_GET['cat_id'].';'; |
---|
138 | $result = pwg_query($query); |
---|
139 | $q = 'INSERT INTO ' . $prefixeTable . 'title_album(id,title)VALUES ('.$_GET['cat_id'].',"'.$_POST['insertitleA'].'");'; |
---|
140 | pwg_query($q); |
---|
141 | $template->assign( |
---|
142 | array( |
---|
143 | 'titleCONTENT' => $_POST['insertitleA'], |
---|
144 | )); |
---|
145 | } |
---|
146 | } |
---|
147 | */ |
---|
148 | ?> |
---|