1 | <?php |
---|
2 | /* |
---|
3 | * ----------------------------------------------------------------------------- |
---|
4 | * Plugin Name: Advanced MetaData |
---|
5 | * ----------------------------------------------------------------------------- |
---|
6 | * Author : Grum |
---|
7 | * email : grum@piwigo.org |
---|
8 | * website : http://photos.grum.fr |
---|
9 | * PWG user : http://forum.piwigo.org/profile.php?id=3706 |
---|
10 | * |
---|
11 | * << May the Little SpaceFrog be with you ! >> |
---|
12 | * |
---|
13 | * ----------------------------------------------------------------------------- |
---|
14 | * |
---|
15 | * See main.inc.php for release information |
---|
16 | * |
---|
17 | * AIP classe => manage integration in administration interface |
---|
18 | * |
---|
19 | * ----------------------------------------------------------------------------- |
---|
20 | */ |
---|
21 | |
---|
22 | if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); } |
---|
23 | |
---|
24 | include_once('amd_root.class.inc.php'); |
---|
25 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTabSheet.class.inc.php'); |
---|
26 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCAjax.class.inc.php'); |
---|
27 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/genericjs.class.inc.php'); |
---|
28 | |
---|
29 | |
---|
30 | |
---|
31 | class AMD_AIP extends AMD_root |
---|
32 | { |
---|
33 | protected $tabsheet; |
---|
34 | |
---|
35 | /** |
---|
36 | * |
---|
37 | * constructor needs the prefix of piwigo's tables and the location of plugin |
---|
38 | * |
---|
39 | * @param String $prefixeTable |
---|
40 | * @param String $filelocation |
---|
41 | */ |
---|
42 | public function __construct($prefixeTable, $filelocation) |
---|
43 | { |
---|
44 | parent::__construct($prefixeTable, $filelocation); |
---|
45 | |
---|
46 | $this->loadConfig(); |
---|
47 | $this->configForTemplate(); |
---|
48 | $this->initEvents(); |
---|
49 | |
---|
50 | $this->tabsheet = new tabsheet(); |
---|
51 | $this->tabsheet->add('database', |
---|
52 | l10n('g003_database'), |
---|
53 | $this->getAdminLink().'&fAMD_tabsheet=database'); |
---|
54 | $this->tabsheet->add('metadata', |
---|
55 | l10n('g003_metadata'), |
---|
56 | $this->getAdminLink().'&fAMD_tabsheet=metadata'); |
---|
57 | $this->tabsheet->add('search', |
---|
58 | l10n('g003_search'), |
---|
59 | $this->getAdminLink().'&fAMD_tabsheet=search'); |
---|
60 | $this->tabsheet->add('help', |
---|
61 | l10n('g003_help'), |
---|
62 | $this->getAdminLink().'&fAMD_tabsheet=help'); |
---|
63 | } |
---|
64 | |
---|
65 | public function __destruct() |
---|
66 | { |
---|
67 | unset($this->tabsheet); |
---|
68 | unset($this->ajax); |
---|
69 | parent::__destruct(); |
---|
70 | } |
---|
71 | |
---|
72 | |
---|
73 | /* |
---|
74 | * --------------------------------------------------------------------------- |
---|
75 | * Public classe functions |
---|
76 | * --------------------------------------------------------------------------- |
---|
77 | */ |
---|
78 | |
---|
79 | |
---|
80 | /** |
---|
81 | * manage the plugin integration into piwigo's admin interface |
---|
82 | */ |
---|
83 | public function manage() |
---|
84 | { |
---|
85 | global $template, $page; |
---|
86 | |
---|
87 | $this->initRequest(); |
---|
88 | |
---|
89 | $template->set_filename('plugin_admin_content', dirname(__FILE__)."/admin/amd_admin.tpl"); |
---|
90 | |
---|
91 | $this->tabsheet->select($_REQUEST['fAMD_tabsheet']); |
---|
92 | $this->tabsheet->assign(); |
---|
93 | $selected_tab=$this->tabsheet->get_selected(); |
---|
94 | $template->assign($this->tabsheet->get_titlename(), "[".$selected_tab['caption']."]"); |
---|
95 | |
---|
96 | $pluginInfo=array( |
---|
97 | 'AMD_VERSION' => "<i>".$this->getPluginName()."</i> ".l10n('g003_version').AMD_VERSION, |
---|
98 | 'AMD_PAGE' => $_REQUEST['fAMD_tabsheet'], |
---|
99 | 'PATH' => AMD_PATH |
---|
100 | ); |
---|
101 | |
---|
102 | $template->assign('plugin', $pluginInfo); |
---|
103 | |
---|
104 | switch($_REQUEST['fAMD_tabsheet']) |
---|
105 | { |
---|
106 | case 'help': |
---|
107 | $this->displayHelp(); |
---|
108 | break; |
---|
109 | case 'database': |
---|
110 | $this->displayDatabase($_REQUEST['fAMD_page']); |
---|
111 | break; |
---|
112 | case 'metadata': |
---|
113 | $this->displayMetaData($_REQUEST['fAMD_page']); |
---|
114 | break; |
---|
115 | case 'search': |
---|
116 | //$this->displaySearch($_REQUEST['fAMD_page']); |
---|
117 | break; |
---|
118 | } |
---|
119 | |
---|
120 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
121 | } |
---|
122 | |
---|
123 | /** |
---|
124 | * initialize events call for the plugin |
---|
125 | * |
---|
126 | * don't inherits from its parent => it's normal |
---|
127 | */ |
---|
128 | public function initEvents() |
---|
129 | { |
---|
130 | add_event_handler('loc_end_page_header', array(&$this->css, 'applyCSS')); |
---|
131 | GPCCss::applyGpcCss(); |
---|
132 | } |
---|
133 | |
---|
134 | /** |
---|
135 | * --------------------------------------------------------------------------- |
---|
136 | * Private & protected functions |
---|
137 | * --------------------------------------------------------------------------- |
---|
138 | */ |
---|
139 | |
---|
140 | /** |
---|
141 | * if empty, initialize the $_REQUEST var |
---|
142 | * |
---|
143 | * if not empty, check validity for the request values |
---|
144 | * |
---|
145 | */ |
---|
146 | private function initRequest() |
---|
147 | { |
---|
148 | //initialise $REQUEST values if not defined |
---|
149 | |
---|
150 | if(!isset($_REQUEST['fAMD_tabsheet'])) |
---|
151 | { |
---|
152 | if($this->getNumOfPictures()==0) |
---|
153 | { |
---|
154 | $_REQUEST['fAMD_tabsheet']="database"; |
---|
155 | $_REQUEST['fAMD_page']="state"; |
---|
156 | } |
---|
157 | else |
---|
158 | { |
---|
159 | $_REQUEST['fAMD_tabsheet']="metadata"; |
---|
160 | $_REQUEST['fAMD_page']="select"; |
---|
161 | } |
---|
162 | } |
---|
163 | |
---|
164 | if(!($_REQUEST['fAMD_tabsheet']=="metadata" or |
---|
165 | $_REQUEST['fAMD_tabsheet']!="help" or |
---|
166 | $_REQUEST['fAMD_tabsheet']!="database" or |
---|
167 | $_REQUEST['fAMD_tabsheet']!="search")) |
---|
168 | { |
---|
169 | $_REQUEST['fAMD_tabsheet']="metadata"; |
---|
170 | } |
---|
171 | |
---|
172 | /* |
---|
173 | * metadata tabsheet |
---|
174 | */ |
---|
175 | if($_REQUEST['fAMD_tabsheet']=="metadata") |
---|
176 | { |
---|
177 | if(!isset($_REQUEST['fAMD_page'])) $_REQUEST['fAMD_page']="select"; |
---|
178 | |
---|
179 | if(!($_REQUEST['fAMD_page']=="personnal" or |
---|
180 | $_REQUEST['fAMD_page']=="select" or |
---|
181 | $_REQUEST['fAMD_page']=="display")) $_REQUEST['fAMD_page']="select"; |
---|
182 | } |
---|
183 | |
---|
184 | /* |
---|
185 | * help tabsheet |
---|
186 | */ |
---|
187 | if($_REQUEST['fAMD_tabsheet']=="help") |
---|
188 | { |
---|
189 | if(!isset($_REQUEST['fAMD_page'])) $_REQUEST['fAMD_page']="exif"; |
---|
190 | |
---|
191 | if(!($_REQUEST['fAMD_page']=="exif" or |
---|
192 | $_REQUEST['fAMD_page']=="iptc" or |
---|
193 | $_REQUEST['fAMD_page']=="xmp" or |
---|
194 | $_REQUEST['fAMD_page']=="magic")) $_REQUEST['fAMD_page']="exif"; |
---|
195 | } |
---|
196 | |
---|
197 | /* |
---|
198 | * search tabsheet |
---|
199 | */ |
---|
200 | if($_REQUEST['fAMD_tabsheet']=="search") |
---|
201 | { |
---|
202 | if(!isset($_REQUEST['fAMD_page'])) $_REQUEST['fAMD_page']="search"; |
---|
203 | |
---|
204 | if(!($_REQUEST['fAMD_page']=="config" or |
---|
205 | $_REQUEST['fAMD_page']=="search")) $_REQUEST['fAMD_page']="search"; |
---|
206 | } |
---|
207 | |
---|
208 | /* |
---|
209 | * database tabsheet |
---|
210 | */ |
---|
211 | if($_REQUEST['fAMD_tabsheet']=="database") |
---|
212 | { |
---|
213 | if(!isset($_REQUEST['fAMD_page'])) $_REQUEST['fAMD_page']="state"; |
---|
214 | |
---|
215 | if(!($_REQUEST['fAMD_page']=="state" or |
---|
216 | $_REQUEST['fAMD_page']=="update")) $_REQUEST['fAMD_page']="state"; |
---|
217 | } |
---|
218 | |
---|
219 | } //init_request |
---|
220 | |
---|
221 | |
---|
222 | /** |
---|
223 | * manage adviser profile |
---|
224 | * |
---|
225 | * @return Boolean : true if user is adviser, otherwise false (and push a |
---|
226 | * message in the error list) |
---|
227 | */ |
---|
228 | protected function adviser_abort() |
---|
229 | { |
---|
230 | if(is_adviser()) |
---|
231 | { |
---|
232 | $this->display_result(l10n("g003_adviser_not_allowed"), false); |
---|
233 | return(true); |
---|
234 | } |
---|
235 | return(false); |
---|
236 | } |
---|
237 | |
---|
238 | |
---|
239 | /** |
---|
240 | * display and manage the metadata page |
---|
241 | * the page have three tabsheet : |
---|
242 | * - personnal tag management, to build personnal tags |
---|
243 | * - select tag management, to manage tags to be selected on the galerie |
---|
244 | * - display tag management, to choose how the tags are displayed |
---|
245 | * |
---|
246 | * @param String $tab : the selected tab on the stat page |
---|
247 | */ |
---|
248 | protected function displayMetaData($tab) |
---|
249 | { |
---|
250 | global $template, $user; |
---|
251 | $template->set_filename('body_page', dirname(__FILE__).'/admin/amd_metadata.tpl'); |
---|
252 | |
---|
253 | $statTabsheet = new GPCTabSheet('statTabsheet', $this->tabsheet->get_titlename(), 'tabsheet2 gcBorder', 'itab2'); |
---|
254 | $statTabsheet->select($tab); |
---|
255 | $statTabsheet->add('personnal', |
---|
256 | l10n('g003_personnal'), |
---|
257 | $this->getAdminLink().'&fAMD_tabsheet=metadata&fAMD_page=personnal'); |
---|
258 | $statTabsheet->add('select', |
---|
259 | l10n('g003_select'), |
---|
260 | $this->getAdminLink().'&fAMD_tabsheet=metadata&fAMD_page=select'); |
---|
261 | $statTabsheet->add('display', |
---|
262 | l10n('g003_display'), |
---|
263 | $this->getAdminLink().'&fAMD_tabsheet=metadata&fAMD_page=display'); |
---|
264 | $statTabsheet->assign(); |
---|
265 | |
---|
266 | switch($tab) |
---|
267 | { |
---|
268 | case 'select': |
---|
269 | $template->assign('sheetContent', $this->displayMetaDataSelect()); |
---|
270 | break; |
---|
271 | case 'display': |
---|
272 | $template->assign('sheetContent', $this->displayMetaDataDisplay()); |
---|
273 | break; |
---|
274 | case 'personnal': |
---|
275 | $template->assign('sheetContent', $this->displayMetaDataPersonnal()); |
---|
276 | break; |
---|
277 | } |
---|
278 | |
---|
279 | $template->assign_var_from_handle('AMD_BODY_PAGE', 'body_page'); |
---|
280 | } |
---|
281 | |
---|
282 | |
---|
283 | /** |
---|
284 | * display and manage the metadata page allowing to build user defined tags |
---|
285 | * |
---|
286 | * @return String : the content of the page |
---|
287 | */ |
---|
288 | protected function displayMetaDataPersonnal() |
---|
289 | { |
---|
290 | global $template, $theme, $themes, $themeconf; |
---|
291 | |
---|
292 | $template->set_filename('sheet_page', |
---|
293 | dirname($this->getFileLocation()).'/admin/amd_metadata_personnal.tpl'); |
---|
294 | |
---|
295 | $datas=array( |
---|
296 | 'urlRequest' => $this->getAdminLink('ajax'), |
---|
297 | 'tagList' => array(), |
---|
298 | ); |
---|
299 | |
---|
300 | /* |
---|
301 | * build tagList |
---|
302 | */ |
---|
303 | $sql="SELECT ut.name, ut.numId, ut.tagId |
---|
304 | FROM ".$this->tables['used_tags']." ut |
---|
305 | JOIN ".$this->tables['selected_tags']." st ON st.tagId = ut.tagId |
---|
306 | ORDER BY tagId"; |
---|
307 | $result=pwg_query($sql); |
---|
308 | if($result) |
---|
309 | { |
---|
310 | while($row=pwg_db_fetch_assoc($result)) |
---|
311 | { |
---|
312 | $datas['tagList'][]=Array( |
---|
313 | 'tagId' => $row['tagId'], |
---|
314 | 'name' => L10n::get($row['name']), |
---|
315 | 'numId' => $row['numId'] |
---|
316 | ); |
---|
317 | } |
---|
318 | } |
---|
319 | |
---|
320 | $template->assign('datas', $datas); |
---|
321 | return($template->parse('sheet_page', true)); |
---|
322 | } |
---|
323 | |
---|
324 | |
---|
325 | /** |
---|
326 | * display and manage the metadata page allowing to make tags selection |
---|
327 | * |
---|
328 | * @return String : the content of the page |
---|
329 | */ |
---|
330 | protected function displayMetaDataSelect() |
---|
331 | { |
---|
332 | global $template, $theme, $themes, $themeconf; |
---|
333 | |
---|
334 | $template->set_filename('sheet_page', |
---|
335 | dirname($this->getFileLocation()).'/admin/amd_metadata_select.tpl'); |
---|
336 | |
---|
337 | $datas=array( |
---|
338 | 'urlRequest' => $this->getAdminLink('ajax'), |
---|
339 | 'config_GetListTags_OrderType' => $this->config['amd_GetListTags_OrderType'], |
---|
340 | 'config_GetListTags_FilterType' => $this->config['amd_GetListTags_FilterType'], |
---|
341 | 'config_GetListTags_ExcludeUnusedTag' => $this->config['amd_GetListTags_ExcludeUnusedTag'], |
---|
342 | 'config_GetListTags_SelectedTagOnly' => $this->config['amd_GetListTags_SelectedTagOnly'], |
---|
343 | 'config_GetListImages_OrderType' => $this->config['amd_GetListImages_OrderType'] |
---|
344 | ); |
---|
345 | |
---|
346 | $template->assign('datas', $datas); |
---|
347 | return($template->parse('sheet_page', true)); |
---|
348 | } |
---|
349 | |
---|
350 | |
---|
351 | /** |
---|
352 | * display and manage the metadata page allowing to choose tags order |
---|
353 | * |
---|
354 | * @return String : the content of the page |
---|
355 | */ |
---|
356 | protected function displayMetaDataDisplay() |
---|
357 | { |
---|
358 | global $user, $template; |
---|
359 | |
---|
360 | //$local_tpl = new Template(AMD_PATH."admin/", ""); |
---|
361 | $template->set_filename('sheet_page', |
---|
362 | dirname($this->getFileLocation()).'/admin/amd_metadata_display.tpl'); |
---|
363 | |
---|
364 | $datas=array( |
---|
365 | 'urlRequest' => $this->getAdminLink('ajax'), |
---|
366 | 'selectedTags' => Array(), |
---|
367 | 'groups' => Array(), |
---|
368 | 'tagByGroup' => Array(), |
---|
369 | ); |
---|
370 | |
---|
371 | $sql="SELECT st.tagId, st.order, st.groupId, ut.numId |
---|
372 | FROM ".$this->tables['selected_tags']." st |
---|
373 | LEFT JOIN ".$this->tables['used_tags']." ut |
---|
374 | ON ut.tagId = st.tagId |
---|
375 | ORDER BY st.groupId ASC, st.order ASC, st.tagId ASC"; |
---|
376 | $result=pwg_query($sql); |
---|
377 | if($result) |
---|
378 | { |
---|
379 | while($row=pwg_db_fetch_assoc($result)) |
---|
380 | { |
---|
381 | if($row['groupId']==-1) |
---|
382 | { |
---|
383 | $datas['selectedTags'][]=Array( |
---|
384 | 'numId' => $row['numId'], |
---|
385 | 'tagId' => $row['tagId'] |
---|
386 | ); |
---|
387 | } |
---|
388 | else |
---|
389 | { |
---|
390 | $datas['tagByGroup'][]=Array( |
---|
391 | 'numId' => $row['numId'], |
---|
392 | 'tagId' => $row['tagId'], |
---|
393 | 'group' => $row['groupId'], |
---|
394 | 'order' => $row['order'] |
---|
395 | ); |
---|
396 | } |
---|
397 | } |
---|
398 | } |
---|
399 | |
---|
400 | $sql="SELECT g.groupId, gn.name |
---|
401 | FROM ".$this->tables['groups']." g |
---|
402 | LEFT JOIN ".$this->tables['groups_names']." gn |
---|
403 | ON g.groupId = gn.groupId |
---|
404 | WHERE gn.lang = '".$user['language']."' |
---|
405 | ORDER BY g.order;"; |
---|
406 | $result=pwg_query($sql); |
---|
407 | if($result) |
---|
408 | { |
---|
409 | while($row=pwg_db_fetch_assoc($result)) |
---|
410 | { |
---|
411 | $datas['groups'][]=Array( |
---|
412 | 'id' => $row['groupId'], |
---|
413 | 'name' => $row['name'] |
---|
414 | ); |
---|
415 | } |
---|
416 | } |
---|
417 | |
---|
418 | $template->assign('datas', $datas); |
---|
419 | return($template->parse('sheet_page', true)); |
---|
420 | } |
---|
421 | |
---|
422 | |
---|
423 | /** |
---|
424 | * display and manage the database page |
---|
425 | * the page have two tabsheet : |
---|
426 | * - state, to have general information about the database |
---|
427 | * - update, to manage database fill-in |
---|
428 | * |
---|
429 | * @param String $tab : the selected tab on the stat page |
---|
430 | */ |
---|
431 | protected function displayDatabase($tab) |
---|
432 | { |
---|
433 | global $template, $user; |
---|
434 | $template->set_filename('body_page', dirname(__FILE__).'/admin/amd_metadata.tpl'); |
---|
435 | |
---|
436 | $statTabsheet = new GPCTabSheet('statTabsheet', $this->tabsheet->get_titlename(), 'tabsheet2 gcBorder', 'itab2'); |
---|
437 | $statTabsheet->select($tab); |
---|
438 | $statTabsheet->add('state', |
---|
439 | l10n('g003_state'), |
---|
440 | $this->getAdminLink().'&fAMD_tabsheet=database&fAMD_page=state'); |
---|
441 | $statTabsheet->add('update', |
---|
442 | l10n('g003_update'), |
---|
443 | $this->getAdminLink().'&fAMD_tabsheet=database&fAMD_page=update'); |
---|
444 | $statTabsheet->assign(); |
---|
445 | |
---|
446 | switch($tab) |
---|
447 | { |
---|
448 | case 'state': |
---|
449 | $template->assign('sheetContent', $this->displayDatabaseStatus()); |
---|
450 | break; |
---|
451 | case 'update': |
---|
452 | $template->assign('sheetContent', $this->displayDatabaseDatabase()); |
---|
453 | break; |
---|
454 | } |
---|
455 | |
---|
456 | $template->assign_var_from_handle('AMD_BODY_PAGE', 'body_page'); |
---|
457 | } |
---|
458 | |
---|
459 | |
---|
460 | |
---|
461 | /** |
---|
462 | * display the database status |
---|
463 | * |
---|
464 | * @return String : the content of the page |
---|
465 | */ |
---|
466 | private function displayDatabaseStatus() |
---|
467 | { |
---|
468 | global $template, $page; |
---|
469 | |
---|
470 | $template->set_filename('sheet_page', dirname(__FILE__).'/admin/amd_metadata_database_status.tpl'); |
---|
471 | |
---|
472 | $datas=array( |
---|
473 | 'urlRequest' => $this->getAdminLink('ajax'), |
---|
474 | 'warning1' => GPCCore::BBtoHTML(l10n('g003_databaseWarning1')), |
---|
475 | 'nfoMetadata' => Array( |
---|
476 | 'exif' => 0, |
---|
477 | 'iptc' => 0, |
---|
478 | 'magic' => 0, |
---|
479 | 'xmp' => 0, |
---|
480 | 'userDefined' => 0, |
---|
481 | 'numOfPictures' => 0, |
---|
482 | 'numOfNotAnalyzedPictures' => 0, |
---|
483 | 'numOfPicturesWithoutTag' => 0, |
---|
484 | 'nfoSize' => 0, |
---|
485 | 'nfoRows' => 0, |
---|
486 | 'nfoSizeAndRows' => '', |
---|
487 | ) |
---|
488 | ); |
---|
489 | |
---|
490 | $sql="SELECT SUM(numOfImg) AS nb, 'exif' AS `type` |
---|
491 | FROM ".$this->tables['used_tags']." |
---|
492 | WHERE tagId LIKE 'exif.%' |
---|
493 | UNION |
---|
494 | SELECT SUM(numOfImg), 'iptc' |
---|
495 | FROM ".$this->tables['used_tags']." |
---|
496 | WHERE tagId LIKE 'iptc.%' |
---|
497 | UNION |
---|
498 | SELECT SUM(numOfImg), 'magic' |
---|
499 | FROM ".$this->tables['used_tags']." |
---|
500 | WHERE tagId LIKE 'magic.%' |
---|
501 | UNION |
---|
502 | SELECT SUM(numOfImg), 'xmp' |
---|
503 | FROM ".$this->tables['used_tags']." |
---|
504 | WHERE tagId LIKE 'xmp.%' |
---|
505 | UNION |
---|
506 | SELECT SUM(numOfImg), 'userDefined' |
---|
507 | FROM ".$this->tables['used_tags']." |
---|
508 | WHERE tagId LIKE 'userDefined.%' |
---|
509 | UNION |
---|
510 | SELECT COUNT(imageId), 'numOfPictures' |
---|
511 | FROM ".$this->tables['images']." |
---|
512 | WHERE analyzed='y' |
---|
513 | UNION |
---|
514 | SELECT COUNT(imageId), 'numOfNotAnalyzedPictures' |
---|
515 | FROM ".$this->tables['images']." |
---|
516 | WHERE analyzed='n' |
---|
517 | UNION |
---|
518 | SELECT COUNT(imageId), 'numOfPicturesWithoutTag' |
---|
519 | FROM ".$this->tables['images']." |
---|
520 | WHERE nbTags=0"; |
---|
521 | $result=pwg_query($sql); |
---|
522 | if($result) |
---|
523 | { |
---|
524 | while($row=pwg_db_fetch_assoc($result)) |
---|
525 | { |
---|
526 | if(!is_null($row['nb'])) |
---|
527 | { |
---|
528 | $datas['nfoMetadata'][$row['type']]=$row['nb']; |
---|
529 | if($row['type']=='exif' or |
---|
530 | $row['type']=='iptc' or |
---|
531 | $row['type']=='magic' or |
---|
532 | $row['type']=='xmp' or |
---|
533 | $row['type']=='userDefined') $datas['nfoMetadata']['nfoRows']+=$row['nb']; |
---|
534 | } |
---|
535 | } |
---|
536 | } |
---|
537 | |
---|
538 | $sql="SHOW TABLE STATUS WHERE name LIKE '".$this->tables['images_tags']."'"; |
---|
539 | $result=pwg_query($sql); |
---|
540 | if($result) |
---|
541 | { |
---|
542 | while($row=pwg_db_fetch_assoc($result)) |
---|
543 | { |
---|
544 | $datas['nfoMetadata']['nfoSize']=$row['Data_length']+$row['Index_length']; |
---|
545 | } |
---|
546 | } |
---|
547 | |
---|
548 | if($datas['nfoMetadata']['nfoSize']<1048576) |
---|
549 | { |
---|
550 | $datas['nfoMetadata']['nfoSize']=sprintf('%.2fKio', $datas['nfoMetadata']['nfoSize']/1024); |
---|
551 | } |
---|
552 | else |
---|
553 | { |
---|
554 | $datas['nfoMetadata']['nfoSize']=sprintf('%.2fMio', $datas['nfoMetadata']['nfoSize']/1048576); |
---|
555 | } |
---|
556 | $datas['nfoMetadata']['nfoSizeAndRows']=sprintf(l10n('g003_sizeAndRows'), $datas['nfoMetadata']['nfoSize'], $datas['nfoMetadata']['nfoRows']); |
---|
557 | $datas['nfoMetadata']['numOfPictures']=sprintf(l10n('g003_numberOfAnalyzedPictures'), $datas['nfoMetadata']['numOfPictures']); |
---|
558 | $datas['nfoMetadata']['numOfNotAnalyzedPictures']=sprintf(l10n('g003_numberOfNotAnalyzedPictures'), $datas['nfoMetadata']['numOfNotAnalyzedPictures']); |
---|
559 | $datas['nfoMetadata']['numOfPicturesWithoutTag']=sprintf(l10n('g003_numberOfPicturesWithoutTags'), $datas['nfoMetadata']['numOfPicturesWithoutTag']); |
---|
560 | |
---|
561 | $template->assign("datas", $datas); |
---|
562 | |
---|
563 | return($template->parse('sheet_page', true)); |
---|
564 | } // displayDatabaseStatus |
---|
565 | |
---|
566 | |
---|
567 | |
---|
568 | |
---|
569 | /** |
---|
570 | * display and manage the database page |
---|
571 | * |
---|
572 | * the function automatically update the AMD tables : |
---|
573 | * - add new pictures in the AMD image table (assuming image is not analyzed |
---|
574 | * yet) |
---|
575 | * - remove deleted pictures in the AMD image & image_tags table |
---|
576 | * |
---|
577 | * @return String : the content of the page |
---|
578 | */ |
---|
579 | private function displayDatabaseDatabase() |
---|
580 | { |
---|
581 | global $template, $page; |
---|
582 | |
---|
583 | /* |
---|
584 | * insert new image (from piwigo images table) in the AMD images table, with |
---|
585 | * statut 'not analyzed' |
---|
586 | */ |
---|
587 | $sql="INSERT INTO ".$this->tables['images']." |
---|
588 | SELECT id, 'n', 0 |
---|
589 | FROM ".IMAGES_TABLE." |
---|
590 | WHERE id NOT IN (SELECT imageId FROM ".$this->tables['images'].")"; |
---|
591 | pwg_query($sql); |
---|
592 | |
---|
593 | |
---|
594 | /* |
---|
595 | * delete image who are in the AMD images table and not in the piwigo image |
---|
596 | * table |
---|
597 | */ |
---|
598 | $sql="DELETE FROM ".$this->tables['images']." |
---|
599 | WHERE imageId NOT IN (SELECT id FROM ".IMAGES_TABLE.")"; |
---|
600 | pwg_query($sql); |
---|
601 | |
---|
602 | |
---|
603 | /* |
---|
604 | * delete metadata for images that are not in the AMD image table |
---|
605 | */ |
---|
606 | $sql="DELETE ait |
---|
607 | FROM ".$this->tables['images_tags']." ait |
---|
608 | JOIN (SELECT DISTINCT imageId FROM ".$this->tables['images_tags']." ) aitd |
---|
609 | ON ait.imageId=aitd.imageId |
---|
610 | WHERE aitd.imageId NOT IN (SELECT id FROM ".IMAGES_TABLE.") "; |
---|
611 | pwg_query($sql); |
---|
612 | |
---|
613 | |
---|
614 | |
---|
615 | |
---|
616 | $template->set_filename('sheet_page', dirname(__FILE__).'/admin/amd_metadata_database_database.tpl'); |
---|
617 | |
---|
618 | $datas=array( |
---|
619 | 'urlRequest' => $this->getAdminLink('ajax'), |
---|
620 | 'NumberOfItemsPerRequest' => $this->config['amd_NumberOfItemsPerRequest'], |
---|
621 | ); |
---|
622 | |
---|
623 | $template->assign("datas", $datas); |
---|
624 | |
---|
625 | return($template->parse('sheet_page', true)); |
---|
626 | } // displayDatabase |
---|
627 | |
---|
628 | |
---|
629 | |
---|
630 | |
---|
631 | |
---|
632 | /** |
---|
633 | * display and manage the help page |
---|
634 | * |
---|
635 | * @param String $tab : the selected tab on the help page |
---|
636 | */ |
---|
637 | protected function displayHelp() |
---|
638 | { |
---|
639 | global $template, $user, $lang; |
---|
640 | $template->set_filename('body_page', dirname(__FILE__).'/admin/amd_help.tpl'); |
---|
641 | |
---|
642 | $statTabsheet = new GPCTabSheet('statTabsheet', $this->tabsheet->get_titlename(), 'tabsheet2 gcBorder', 'itab2'); |
---|
643 | $statTabsheet->add('exif', |
---|
644 | l10n('g003_help_tab_exif'), |
---|
645 | '', true, "displayHelp('exif');"); |
---|
646 | $statTabsheet->add('iptc', |
---|
647 | l10n('g003_help_tab_iptc'), |
---|
648 | '', false, "displayHelp('iptc');"); |
---|
649 | $statTabsheet->add('xmp', |
---|
650 | l10n('g003_help_tab_xmp'), |
---|
651 | '', false, "displayHelp('xmp');"); |
---|
652 | $statTabsheet->add('magic', |
---|
653 | l10n('g003_help_tab_magic'), |
---|
654 | '', false, "displayHelp('magic');"); |
---|
655 | $statTabsheet->assign(); |
---|
656 | |
---|
657 | $data=Array( |
---|
658 | 'sheetContent_exif' => GPCCore::BBtoHTML($lang['g003_help_exif']), |
---|
659 | 'sheetContent_xmp' => GPCCore::BBtoHTML($lang['g003_help_xmp']), |
---|
660 | 'sheetContent_iptc' => GPCCore::BBtoHTML($lang['g003_help_iptc']), |
---|
661 | 'sheetContent_magic' => GPCCore::BBtoHTML($lang['g003_help_magic']), |
---|
662 | 'title_exif' => l10n('g003_help_tab_exif'), |
---|
663 | 'title_xmp' => l10n('g003_help_tab_xmp'), |
---|
664 | 'title_iptc' => l10n('g003_help_tab_iptc'), |
---|
665 | 'title_magic' => l10n('g003_help_tab_magic') |
---|
666 | ); |
---|
667 | |
---|
668 | $template->assign('data', $data); |
---|
669 | |
---|
670 | $template->assign_var_from_handle('AMD_BODY_PAGE', 'body_page'); |
---|
671 | } |
---|
672 | |
---|
673 | } // AMD_AIP class |
---|
674 | |
---|
675 | |
---|
676 | ?> |
---|