source: extensions/PersoFavicon/main.inc.php @ 30693

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

[extensions] - PersoFavicon - remove /local/

File size: 1.3 KB
Line 
1<?php
2/*
3Plugin Name: Personal Favicon
4Version: auto
5Description: Replace Piwigo fivicon by the favicon in local directory
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=462
7Author: ddtddt
8Author URI: http://piwigo.org/
9*/
10
11define('PFI_DIR' , basename(dirname(__FILE__)));
12define('PFI_PATH' , PHPWG_PLUGINS_PATH . PFI_DIR . '/');
13
14//Ajout du menu admin
15add_event_handler('get_admin_plugin_menu_links', 'PersoFavicon_admin_menu');
16function PersoFavicon_admin_menu($menu)
17{
18  array_push($menu, array(
19        'NAME' => 'PersoFavicon',
20    'URL' => get_admin_plugin_menu_link(PFI_PATH . 'admin/admin.php')));
21  return $menu;
22}
23
24
25// Remplace le code dans le header
26add_event_handler('loc_begin_page_header', 'Change_Favicon', 55 );
27
28function Change_Favicon()
29 {
30        global $template;
31        $template->set_prefilter('header', 'Favicon');
32 }
33
34function Favicon($content, &$smarty)
35 {
36  $search = '#<link rel="shortcut icon".*?favicon.ico">#';
37
38        global $conf;
39 
40$favicon_name = & $conf['PersoFavicon'];
41
42        if (!empty($favicon_name))
43                {
44  $replacement = '<link rel="shortcut icon" type="image/x-icon" href="'.PHPWG_ROOT_PATH.PWG_LOCAL_DIR.$favicon_name.'.ico">';
45                }
46        else
47                {
48  $replacement = '<link rel="shortcut icon" type="image/x-icon" href="'.PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'favicon.ico">';
49                }
50  return preg_replace($search, $replacement, $content);
51 }
52 
53?>
Note: See TracBrowser for help on using the repository browser.