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