[7470] | 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 | |
---|
[7517] | 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); |
---|
[7470] | 24 | |
---|
[7517] | 25 | function add_metadescacc() |
---|
| 26 | //meta homepage |
---|
| 27 | { |
---|
[7524] | 28 | global $template, $page, $meta_infosdesc, $conf; |
---|
[7517] | 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 | |
---|
[7524] | 34 | if (isset($page['section']) and $page['section'] == 'categories' and empty($page['category']['id'])) |
---|
[7517] | 35 | { |
---|
[7524] | 36 | $descindex = & $conf['metasimple']; |
---|
| 37 | if (!empty($descindex)) |
---|
| 38 | { |
---|
| 39 | $template->assign('COMMENT_IMG', $descindex); |
---|
| 40 | $template->clear_assign('INFO_FILE'); |
---|
| 41 | } |
---|
[7517] | 42 | } |
---|
| 43 | } |
---|
[7470] | 44 | |
---|
[7517] | 45 | function add_metadesccat() |
---|
[7524] | 46 | //meta albums |
---|
[7517] | 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 | { |
---|
[7470] | 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); |
---|
[7517] | 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() |
---|
[7524] | 71 | //meta photos |
---|
[7517] | 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 | { |
---|
[7470] | 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); |
---|
[7517] | 87 | if (!empty($row['comment'])) |
---|
| 88 | { |
---|
| 89 | $template->assign('COMMENT_IMG', $row['comment']); |
---|
| 90 | $template->clear_assign('INFO_FILE'); |
---|
| 91 | } |
---|
| 92 | } |
---|
| 93 | } |
---|
[7470] | 94 | |
---|
| 95 | function set_metadesc_back() |
---|
[7517] | 96 | { |
---|
| 97 | global $template, $meta_infosdesc; |
---|
[7470] | 98 | |
---|
[7517] | 99 | $template->assign |
---|
| 100 | (array |
---|
| 101 | ( |
---|
| 102 | 'INFO_FILE' => $meta_infosdesc['info'], |
---|
| 103 | 'COMMENT_IMG' => $meta_infosdesc['comment'] |
---|
| 104 | ) |
---|
| 105 | ); |
---|
| 106 | } |
---|
[7470] | 107 | ?> |
---|