1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: metasimple |
---|
4 | Version: auto |
---|
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_metadescacc',55); |
---|
21 | add_event_handler('loc_begin_page_header', 'add_metadesccat',60); |
---|
22 | add_event_handler('loc_begin_page_header', 'add_metadescimg',70); |
---|
23 | add_event_handler('loc_after_page_header', 'set_metadesc_back',80); |
---|
24 | |
---|
25 | function add_metadescacc() |
---|
26 | //meta homepage |
---|
27 | { |
---|
28 | global $template, $page, $meta_infosdesc, $conf; |
---|
29 | $meta_infosdesc = array(); |
---|
30 | $meta_infosdesc['info'] = $template->get_template_vars('INFO_FILE'); |
---|
31 | $meta_infosdesc['page'] = $template->get_template_vars('PAGE_TITLE'); |
---|
32 | $meta_infosdesc['comment'] = $template->get_template_vars('COMMENT_IMG'); |
---|
33 | |
---|
34 | if (isset($page['section']) and $page['section'] == 'categories' and empty($page['category']['id'])) |
---|
35 | { |
---|
36 | $descindex = & $conf['metasimple']; |
---|
37 | if (!empty($descindex)) |
---|
38 | { |
---|
39 | $template->assign('COMMENT_IMG', $descindex); |
---|
40 | $template->clear_assign('INFO_FILE'); |
---|
41 | } |
---|
42 | } |
---|
43 | } |
---|
44 | |
---|
45 | function add_metadesccat() |
---|
46 | //meta albums |
---|
47 | { |
---|
48 | global $template, $page, $meta_infosdesc; |
---|
49 | $meta_infosdesc = array(); |
---|
50 | $meta_infosdesc['info'] = $template->get_template_vars('INFO_FILE'); |
---|
51 | $meta_infosdesc['page'] = $template->get_template_vars('PAGE_TITLE'); |
---|
52 | $meta_infosdesc['comment'] = $template->get_template_vars('COMMENT_IMG'); |
---|
53 | if ( !empty($page['category']['id']) ) |
---|
54 | { |
---|
55 | $query = ' |
---|
56 | select id,comment |
---|
57 | FROM ' . CATEGORIES_TABLE . ' |
---|
58 | WHERE id = \''.$page['category']['id'].'\' |
---|
59 | ;'; |
---|
60 | $result = pwg_query($query); |
---|
61 | $row = mysql_fetch_array($result); |
---|
62 | if (!empty($row['comment'])) |
---|
63 | { |
---|
64 | $template->assign('COMMENT_IMG', $row['comment']); |
---|
65 | $template->clear_assign('INFO_FILE'); |
---|
66 | } |
---|
67 | } |
---|
68 | } |
---|
69 | |
---|
70 | function add_metadescimg() |
---|
71 | //meta photos |
---|
72 | { |
---|
73 | global $template, $page, $meta_infosdesc; |
---|
74 | $meta_infosdesc = array(); |
---|
75 | $meta_infosdesc['info'] = $template->get_template_vars('INFO_FILE'); |
---|
76 | $meta_infosdesc['page'] = $template->get_template_vars('PAGE_TITLE'); |
---|
77 | $meta_infosdesc['comment'] = $template->get_template_vars('COMMENT_IMG'); |
---|
78 | if ( !empty($page['image_id']) ) |
---|
79 | { |
---|
80 | $query = ' |
---|
81 | select id,comment |
---|
82 | FROM ' . IMAGES_TABLE . ' |
---|
83 | WHERE id = \''.$page['image_id'].'\' |
---|
84 | ;'; |
---|
85 | $result = pwg_query($query); |
---|
86 | $row = mysql_fetch_array($result); |
---|
87 | if (!empty($row['comment'])) |
---|
88 | { |
---|
89 | $template->assign('COMMENT_IMG', $row['comment']); |
---|
90 | $template->clear_assign('INFO_FILE'); |
---|
91 | } |
---|
92 | } |
---|
93 | } |
---|
94 | |
---|
95 | function set_metadesc_back() |
---|
96 | { |
---|
97 | global $template, $meta_infosdesc; |
---|
98 | |
---|
99 | $template->assign |
---|
100 | (array |
---|
101 | ( |
---|
102 | 'INFO_FILE' => $meta_infosdesc['info'], |
---|
103 | 'COMMENT_IMG' => $meta_infosdesc['comment'] |
---|
104 | ) |
---|
105 | ); |
---|
106 | } |
---|
107 | ?> |
---|