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