1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | |
---|
5 | //Add link menu |
---|
6 | add_event_handler('get_admin_plugin_menu_links', 'meta_admin_menu'); |
---|
7 | function meta_admin_menu($menu) |
---|
8 | { |
---|
9 | array_push($menu, array( |
---|
10 | 'NAME' => 'Meta', |
---|
11 | 'URL' => get_admin_plugin_menu_link(meta_PATH . 'admin/admin.php'))); |
---|
12 | return $menu; |
---|
13 | } |
---|
14 | |
---|
15 | |
---|
16 | //add prefiltre photo |
---|
17 | add_event_handler('loc_begin_admin', 'metaPadminf',55); |
---|
18 | add_event_handler('loc_begin_admin', 'metaPadminA',55); |
---|
19 | |
---|
20 | function metaPadminf() |
---|
21 | { |
---|
22 | global $template; |
---|
23 | $template->set_prefilter('picture_modify', 'metaPadminfT'); |
---|
24 | } |
---|
25 | |
---|
26 | function metaPadminfT($content, &$smarty) |
---|
27 | { |
---|
28 | $search = '#<form id="associations"#'; |
---|
29 | |
---|
30 | $replacement = ' |
---|
31 | <div> |
---|
32 | <form method="post" > |
---|
33 | <fieldset> |
---|
34 | <br> |
---|
35 | <legend>{\'Metadata - Plugin meta\'|@translate}</legend> |
---|
36 | {\'meta_compimg\'|@translate} : <input type="text" name="inser" value="{$metaCONTENT}" size="110" maxlenght="110"> |
---|
37 | <br> |
---|
38 | <br> |
---|
39 | {\'meta_compimgdes\'|@translate} : <input type="text" name="inser2" value="{$metaCONTENT2}" size="110" maxlenght="110"> |
---|
40 | ({\'meta_compcatdeshelp\'|@translate}) |
---|
41 | <br> |
---|
42 | <br> |
---|
43 | <div style="text-align:center;"> |
---|
44 | <input class="submit" name="submetaphoto" type="submit" value="{\'meta_inscat\'|@translate}" {$TAG_INPUT_ENABLED} /> |
---|
45 | </div> |
---|
46 | </fieldset> |
---|
47 | </form> |
---|
48 | </div> |
---|
49 | <form id="associations"'; |
---|
50 | |
---|
51 | return preg_replace($search, $replacement, $content); |
---|
52 | } |
---|
53 | |
---|
54 | function metaPadminA() |
---|
55 | { |
---|
56 | load_language('plugin.lang', meta_PATH); |
---|
57 | if (isset($_GET['image_id'])) |
---|
58 | { |
---|
59 | global $template, $prefixeTable; |
---|
60 | $query = ' |
---|
61 | select id,metaKeyimg,metadesimg |
---|
62 | FROM ' . meta_img_TABLE . ' |
---|
63 | WHERE id = '.$_GET['image_id'].' |
---|
64 | ;'; |
---|
65 | $result = pwg_query($query); |
---|
66 | $row = mysql_fetch_array($result); |
---|
67 | $chvalimg=$row['metaKeyimg']; |
---|
68 | $chvalimgdes=$row['metadesimg']; |
---|
69 | |
---|
70 | $template->assign( |
---|
71 | array( |
---|
72 | 'metaCONTENT' => $chvalimg, |
---|
73 | 'metaCONTENT2' => $chvalimgdes, |
---|
74 | )); |
---|
75 | } |
---|
76 | |
---|
77 | if (isset($_POST['submetaphoto'])) |
---|
78 | { |
---|
79 | $query = ' |
---|
80 | DELETE |
---|
81 | FROM ' . meta_img_TABLE . ' |
---|
82 | WHERE id = '.$_GET['image_id'].' |
---|
83 | ;'; |
---|
84 | $result = pwg_query($query); |
---|
85 | $q = ' |
---|
86 | INSERT INTO ' . $prefixeTable . 'meta_img(id,metaKeyimg,metadesimg)VALUES ('.$_GET['image_id'].',"'.$_POST['inser'].'","'.$_POST['inser2'].'");'; |
---|
87 | pwg_query($q); |
---|
88 | |
---|
89 | $template->assign( |
---|
90 | array( |
---|
91 | 'metaCONTENT' => $_POST['inser'], |
---|
92 | 'metaCONTENT2' => $_POST['inser2'], |
---|
93 | )); |
---|
94 | } |
---|
95 | } |
---|
96 | |
---|
97 | //add prefiltre album |
---|
98 | add_event_handler('loc_end_cat_modify', 'metaAadminf'); |
---|
99 | add_event_handler('loc_end_cat_modify', 'metaAadminA'); |
---|
100 | |
---|
101 | function metaAadminf() |
---|
102 | { |
---|
103 | global $template; |
---|
104 | $template->set_prefilter('categories', 'metaAadminfT'); |
---|
105 | } |
---|
106 | |
---|
107 | function metaAadminfT($content, &$smarty) |
---|
108 | { |
---|
109 | $search = '#<fieldset id="options">#'; |
---|
110 | |
---|
111 | $replacement = ' |
---|
112 | |
---|
113 | <div> |
---|
114 | <form method="post" > |
---|
115 | <fieldset> |
---|
116 | <legend>{\'Metadata - Plugin meta\'|@translate}</legend> |
---|
117 | {\'meta_compcat\'|@translate} : <input type="text" name="inser" value="{$metaCONTENT}" size="110" maxlenght="110"> |
---|
118 | <br> |
---|
119 | <br> |
---|
120 | {\'meta_compcatdes\'|@translate} : <input type="text" name="inser2" value="{$metaCONTENT2}" size="110" maxlenght="110"> : ({\'meta_compcatdeshelp\'|@translate}) |
---|
121 | <br> |
---|
122 | <br> |
---|
123 | <div style="text-align:center;"> |
---|
124 | <input class="submit" name="submetaalbum" type="submit" value="{\'meta_inscat\'|@translate}" {$TAG_INPUT_ENABLED} /> |
---|
125 | </div> |
---|
126 | </fieldset> |
---|
127 | </form> |
---|
128 | </div> |
---|
129 | <fieldset id="options"> |
---|
130 | '; |
---|
131 | |
---|
132 | return preg_replace($search, $replacement, $content); |
---|
133 | } |
---|
134 | |
---|
135 | function metaAadminA() |
---|
136 | { |
---|
137 | load_language('plugin.lang', meta_PATH); |
---|
138 | if (isset($_GET['cat_id'])) |
---|
139 | { |
---|
140 | global $template, $prefixeTable; |
---|
141 | $query = ' |
---|
142 | select id,metaKeycat,metadescat |
---|
143 | FROM ' . meta_cat_TABLE . ' |
---|
144 | WHERE id = '.$_GET['cat_id'].' |
---|
145 | ;'; |
---|
146 | $result = pwg_query($query); |
---|
147 | $row = mysql_fetch_array($result); |
---|
148 | $chvalcat=$row['metaKeycat']; |
---|
149 | $chvalcatdes=$row['metadescat']; |
---|
150 | |
---|
151 | $template->assign( |
---|
152 | array( |
---|
153 | 'metaCONTENT' => $chvalcat, |
---|
154 | 'metaCONTENT2' => $chvalcatdes, |
---|
155 | )); |
---|
156 | } |
---|
157 | |
---|
158 | if (isset($_POST['submetaalbum'])) |
---|
159 | { |
---|
160 | $query = ' |
---|
161 | DELETE |
---|
162 | FROM ' . meta_cat_TABLE . ' |
---|
163 | WHERE id = '.$_GET['cat_id'].' |
---|
164 | ;'; |
---|
165 | $result = pwg_query($query); |
---|
166 | $q = ' |
---|
167 | INSERT INTO ' . $prefixeTable . 'meta_cat(id,metaKeycat,metadescat)VALUES ('.$_GET['cat_id'].',"'.$_POST['inser'].'","'.$_POST['inser2'].'");'; |
---|
168 | pwg_query($q); |
---|
169 | |
---|
170 | $template->assign( |
---|
171 | array( |
---|
172 | 'metaCONTENT' => $_POST['inser'], |
---|
173 | 'metaCONTENT2' => $_POST['inser2'], |
---|
174 | )); |
---|
175 | } |
---|
176 | } |
---|
177 | |
---|
178 | ?> |
---|