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