source: extensions/metasimple/main.inc.php @ 7517

Last change on this file since 7517 was 7517, checked in by ddtddt, 13 years ago

[extensions] - metasimple - update for priority / meta

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1<?php
2/*
3Plugin Name: metasimple
4Version: 2.1.0
5Description: 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
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=456
7Author: ddtddt
8Author URI: http://piwigo.org/
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13global $prefixeTable;
14
15define('metasimple_DIR' , basename(dirname(__FILE__)));
16define('metasimple_PATH' , PHPWG_PLUGINS_PATH . metasimple_DIR . '/');
17
18
19
20add_event_handler('loc_begin_page_header', 'add_metadescacc',55);
21add_event_handler('loc_begin_page_header', 'add_metadesccat',60);
22add_event_handler('loc_begin_page_header', 'add_metadescimg',70);
23add_event_handler('loc_after_page_header', 'set_metadesc_back',80);
24
25function add_metadescacc()
26  //meta homepage
27        {
28                global $template, $page, $meta_infosdesc;
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='ttz';
37                                if (!empty($descindex))
38                                        {
39                                                $template->assign('COMMENT_IMG', $descindex);
40                                                $template->clear_assign('INFO_FILE');
41                                        }
42                }
43        }
44
45function add_metadesccat()
46        {
47                global $template, $page, $meta_infosdesc;
48        $meta_infosdesc = array();
49        $meta_infosdesc['info'] = $template->get_template_vars('INFO_FILE');
50        $meta_infosdesc['page'] = $template->get_template_vars('PAGE_TITLE');
51        $meta_infosdesc['comment'] = $template->get_template_vars('COMMENT_IMG');
52                          if ( !empty($page['category']['id']) )   
53                                {
54    $query = '
55    select id,comment
56      FROM ' . CATEGORIES_TABLE . '
57      WHERE id = \''.$page['category']['id'].'\'
58      ;';
59    $result = pwg_query($query);
60    $row = mysql_fetch_array($result);
61                if (!empty($row['comment']))
62                        {
63                                $template->assign('COMMENT_IMG', $row['comment']);
64                                $template->clear_assign('INFO_FILE');
65                        }
66                                }
67        }
68
69function add_metadescimg()
70        {
71                global $template, $page, $meta_infosdesc;
72        $meta_infosdesc = array();
73        $meta_infosdesc['info'] = $template->get_template_vars('INFO_FILE');
74        $meta_infosdesc['page'] = $template->get_template_vars('PAGE_TITLE');
75        $meta_infosdesc['comment'] = $template->get_template_vars('COMMENT_IMG');
76                          if ( !empty($page['image_id']) )   
77                                {
78    $query = '
79    select id,comment
80      FROM ' . IMAGES_TABLE . '
81      WHERE id = \''.$page['image_id'].'\'
82      ;';
83    $result = pwg_query($query);
84    $row = mysql_fetch_array($result);
85                if (!empty($row['comment']))
86                        {
87                                $template->assign('COMMENT_IMG', $row['comment']);
88                                $template->clear_assign('INFO_FILE');
89                        }
90                                }
91        }
92
93function set_metadesc_back()
94        {
95                global $template, $meta_infosdesc;
96 
97                $template->assign
98                        (array
99                                (
100                'INFO_FILE'    => $meta_infosdesc['info'],
101                'COMMENT_IMG'    => $meta_infosdesc['comment']
102                                )
103                        );
104        }
105?>
Note: See TracBrowser for help on using the repository browser.