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

Last change on this file since 7470 was 7470, checked in by ddtddt, 14 years ago

[extensions] - metasimple - news plugin for gestion metadata

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 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_metadesc' );
21function 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
80add_event_handler('loc_after_page_header', 'set_metadesc_back');
81function set_metadesc_back()
82{
83  global $template, $meta_infosdesc;
84 
85  $template->assign(array(
86    'INFO_FILE'    => $meta_infosdesc['info']
87    )
88  );
89}
90?>
Note: See TracBrowser for help on using the repository browser.