source: extensions/titlesimple/main.inc.php @ 14919

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

[extensions] - titlesimple - new plugin for gestion <title>

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1<?php
2/*
3Plugin Name: Title Simple
4Version: auto
5Description: Replace the contents of the title tag
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=459
7Author: ddtddt
8Author URI: http://piwigo.org/
9*/
10
11add_event_handler('loc_begin_page_header', 'Change_Title', 55 );
12add_event_handler('loc_begin_page_header', 'Title', 60 );
13add_event_handler('loc_begin_page_header', 'Titleacc', 65 );
14add_event_handler('loc_begin_page_header', 'Titlecat', 70 );
15add_event_handler('loc_begin_page_header', 'Titleimg', 75 );
16
17function Change_Title()
18 {
19        global $template;
20        $template->set_prefilter('header', 'titleb');
21 }
22
23function titleb($content, &$smarty)
24 {
25  $search = '#<title>.*?</title>#';
26 
27  $replacement = '<title>{$PERSO_TITLE}</title>';
28
29  return preg_replace($search, $replacement, $content);
30 }
31
32function Title()
33 {
34        global $template, $page, $conf;
35
36                $titleindex = & $conf['titlesimple'];           
37                 if (!empty($titleindex))
38                        {
39                                $template->assign('PERSO_TITLE', $titleindex);
40                        }
41                 else
42                        {
43                                $titleindex = & $conf['gallery_title'];         
44                                $template->assign('PERSO_TITLE', $titleindex);
45                        }
46
47 } 
48
49function Titleacc()
50 {
51        global $template, $page, $conf;
52          if (isset($page['section']) and $page['section'] == 'categories' and empty($page['category']['id']))
53                {
54                $titleindex = & $conf['titlesimple_accueil'];           
55                 if (!empty($titleindex))
56                        {
57                                $template->assign('PERSO_TITLE', $titleindex);
58                        }
59                }
60 }
61
62function Titlecat()
63 {
64        global $template, $page;
65                 if (!empty($page['category']['id']) )   
66                                {
67    $query = '
68    select id,comment
69      FROM ' . CATEGORIES_TABLE . '
70      WHERE id = \''.$page['category']['id'].'\'
71      ;';
72    $result = pwg_query($query);
73    $row = mysql_fetch_array($result);
74                if (!empty($row['comment']))
75                        {
76                                $template->assign('PERSO_TITLE', $row['comment']);
77                        }
78                                }
79 }
80
81function Titleimg()
82 {
83                global $template, $page;
84
85                          if ( !empty($page['image_id']) )   
86                                {
87    $query = '
88    select id,comment
89      FROM ' . IMAGES_TABLE . '
90      WHERE id = \''.$page['image_id'].'\'
91      ;';
92    $result = pwg_query($query);
93    $row = mysql_fetch_array($result);
94                if (!empty($row['comment']))
95                        {
96                                $template->assign('PERSO_TITLE', $row['comment']);
97                        }
98                                }
99 }
100
101?>
Note: See TracBrowser for help on using the repository browser.