1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: metasimple |
---|
4 | Version: 2.1.0 |
---|
5 | Description: Replaces the entire contents of the metadata "description" with the category description or pictures if any. Ability to customize the description of the home page |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=456 |
---|
7 | Author: ddtddt |
---|
8 | Author URI: http://piwigo.org/ |
---|
9 | */ |
---|
10 | |
---|
11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
12 | |
---|
13 | global $prefixeTable; |
---|
14 | |
---|
15 | define('metasimple_DIR' , basename(dirname(__FILE__))); |
---|
16 | define('metasimple_PATH' , PHPWG_PLUGINS_PATH . metasimple_DIR . '/'); |
---|
17 | |
---|
18 | |
---|
19 | |
---|
20 | add_event_handler('loc_begin_page_header', 'add_metadesc' ); |
---|
21 | function add_metadesc() |
---|
22 | { |
---|
23 | global $template, $page, $meta_infosdesc; |
---|
24 | |
---|
25 | $meta_infosdesc = array(); |
---|
26 | $meta_infosdesc['info'] = $template->get_template_vars('INFO_FILE'); |
---|
27 | $meta_infosdesc['page'] = $template->get_template_vars('PAGE_TITLE'); |
---|
28 | |
---|
29 | |
---|
30 | //meta categories |
---|
31 | if ( !empty($page['category']['id']) ) |
---|
32 | { |
---|
33 | |
---|
34 | $query = ' |
---|
35 | select id,comment |
---|
36 | FROM ' . CATEGORIES_TABLE . ' |
---|
37 | WHERE id = \''.$page['category']['id'].'\' |
---|
38 | ;'; |
---|
39 | $result = pwg_query($query); |
---|
40 | $row = mysql_fetch_array($result); |
---|
41 | if (!empty($row['comment'])) |
---|
42 | { |
---|
43 | $template->assign('COMMENT_IMG', $row['comment']); |
---|
44 | $template->clear_assign('INFO_FILE'); |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | //meta images |
---|
49 | if ( !empty($page['image_id']) ) |
---|
50 | { |
---|
51 | $query = ' |
---|
52 | select id,comment |
---|
53 | FROM ' . IMAGES_TABLE . ' |
---|
54 | WHERE id = \''.$page['image_id'].'\' |
---|
55 | ;'; |
---|
56 | $result = pwg_query($query); |
---|
57 | $row = mysql_fetch_array($result); |
---|
58 | if (!empty($row['comment'])) |
---|
59 | { |
---|
60 | $template->assign('COMMENT_IMG', $row['comment']); |
---|
61 | $template->clear_assign('INFO_FILE'); |
---|
62 | } |
---|
63 | |
---|
64 | } |
---|
65 | |
---|
66 | //meta homepage |
---|
67 | if (isset($page['section']) and $page['section'] == 'categories' and empty($page['category']['id'])) |
---|
68 | { |
---|
69 | $descindex=''; |
---|
70 | |
---|
71 | if (!empty($descindex)) |
---|
72 | { |
---|
73 | $template->assign('COMMENT_IMG', $descindex); |
---|
74 | $template->clear_assign('INFO_FILE'); |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | } |
---|
79 | |
---|
80 | add_event_handler('loc_after_page_header', 'set_metadesc_back'); |
---|
81 | function set_metadesc_back() |
---|
82 | { |
---|
83 | global $template, $meta_infosdesc; |
---|
84 | |
---|
85 | $template->assign(array( |
---|
86 | 'INFO_FILE' => $meta_infosdesc['info'] |
---|
87 | ) |
---|
88 | ); |
---|
89 | } |
---|
90 | ?> |
---|