[7557] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: Title Simple |
---|
| 4 | Version: auto |
---|
| 5 | Description: Replace the contents of the title tag |
---|
| 6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=459 |
---|
| 7 | Author: ddtddt |
---|
| 8 | Author URI: http://piwigo.org/ |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | add_event_handler('loc_begin_page_header', 'Change_Title', 55 ); |
---|
| 12 | add_event_handler('loc_begin_page_header', 'Title', 60 ); |
---|
| 13 | add_event_handler('loc_begin_page_header', 'Titleacc', 65 ); |
---|
| 14 | add_event_handler('loc_begin_page_header', 'Titlecat', 70 ); |
---|
| 15 | add_event_handler('loc_begin_page_header', 'Titleimg', 75 ); |
---|
| 16 | |
---|
| 17 | function Change_Title() |
---|
| 18 | { |
---|
| 19 | global $template; |
---|
| 20 | $template->set_prefilter('header', 'titleb'); |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | function 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 | |
---|
| 32 | function 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 | |
---|
| 49 | function 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 | |
---|
| 62 | function 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 | |
---|
| 81 | function 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 | ?> |
---|