1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Personal Favicon |
---|
4 | Version: auto |
---|
5 | Description: Replace Piwigo fivicon by the favicon in local directory |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=462 |
---|
7 | Author: ddtddt |
---|
8 | Author URI: http://piwigo.org/ |
---|
9 | */ |
---|
10 | |
---|
11 | define('PFI_DIR' , basename(dirname(__FILE__))); |
---|
12 | define('PFI_PATH' , PHPWG_PLUGINS_PATH . PFI_DIR . '/'); |
---|
13 | |
---|
14 | //Ajout du menu admin |
---|
15 | add_event_handler('get_admin_plugin_menu_links', 'PersoFavicon_admin_menu'); |
---|
16 | function 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 |
---|
26 | add_event_handler('loc_begin_page_header', 'Change_Favicon', 55 ); |
---|
27 | |
---|
28 | function Change_Favicon() |
---|
29 | { |
---|
30 | global $template; |
---|
31 | $template->set_prefilter('header', 'Favicon'); |
---|
32 | } |
---|
33 | |
---|
34 | function 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 | ?> |
---|