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://temmii.com/piwigo/ |
---|
9 | Has Settings: webmaster |
---|
10 | */ |
---|
11 | |
---|
12 | // +-----------------------------------------------------------------------+ |
---|
13 | // | Personal Favicon plugin for Piwigo by TEMMII | |
---|
14 | // +-----------------------------------------------------------------------+ |
---|
15 | // | Copyright(C) 2010-2021 ddtddt http://temmii.com/piwigo/ | |
---|
16 | // +-----------------------------------------------------------------------+ |
---|
17 | // | This program is free software; you can redistribute it and/or modify | |
---|
18 | // | it under the terms of the GNU General Public License as published by | |
---|
19 | // | the Free Software Foundation | |
---|
20 | // | | |
---|
21 | // | This program is distributed in the hope that it will be useful, but | |
---|
22 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
23 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
24 | // | General Public License for more details. | |
---|
25 | // | | |
---|
26 | // | You should have received a copy of the GNU General Public License | |
---|
27 | // | along with this program; if not, write to the Free Software | |
---|
28 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
29 | // | USA. | |
---|
30 | // +-----------------------------------------------------------------------+ |
---|
31 | define('PFI_DIR' , basename(dirname(__FILE__))); |
---|
32 | define('PFI_PATH' , PHPWG_PLUGINS_PATH . PFI_DIR . '/'); |
---|
33 | define('PFI_ADMIN',get_root_url().'admin.php?page=plugin-'.PFI_DIR); |
---|
34 | |
---|
35 | add_event_handler('loading_lang', 'PersoFavicon_loading_lang'); |
---|
36 | function PersoFavicon_loading_lang(){ |
---|
37 | load_language('plugin.lang', PFI_PATH); |
---|
38 | } |
---|
39 | |
---|
40 | |
---|
41 | //Ajout du menu admin |
---|
42 | /*add_event_handler('get_admin_plugin_menu_links', 'PersoFavicon_admin_menu'); |
---|
43 | function PersoFavicon_admin_menu($menu){ |
---|
44 | $menu[] = array( |
---|
45 | 'NAME' => l10n('PersoFavicon'), |
---|
46 | 'URL' => PFI_ADMIN, |
---|
47 | ); |
---|
48 | return $menu; |
---|
49 | }*/ |
---|
50 | |
---|
51 | |
---|
52 | // Remplace le code dans le header |
---|
53 | add_event_handler('loc_begin_page_header', 'Change_Favicon', 55 ); |
---|
54 | function Change_Favicon(){ |
---|
55 | global $template; |
---|
56 | $template->set_prefilter('header', 'Favicon'); |
---|
57 | } |
---|
58 | |
---|
59 | function Favicon($content){ |
---|
60 | $search = '#<link rel="shortcut icon".*?favicon.ico">#'; |
---|
61 | global $conf; |
---|
62 | $favicon_name = & $conf['PersoFavicon']; |
---|
63 | |
---|
64 | if (!empty($favicon_name)){ |
---|
65 | $replacement = '<link rel="shortcut icon" type="image/x-icon" href="'.PHPWG_ROOT_PATH.PWG_LOCAL_DIR.$favicon_name.'.ico">'; |
---|
66 | }else{ |
---|
67 | $replacement = '<link rel="shortcut icon" type="image/x-icon" href="'.PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'favicon.ico">'; |
---|
68 | } |
---|
69 | return preg_replace($search, $replacement, $content); |
---|
70 | } |
---|
71 | |
---|
72 | ?> |
---|