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

Last change on this file since 32729 was 32648, checked in by ddtddt, 3 years ago

[PersoFavicon] compatibility piwigo12

File size: 2.9 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://temmii.com/piwigo/
9Has 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// +-----------------------------------------------------------------------+
31define('PFI_DIR' , basename(dirname(__FILE__)));
32define('PFI_PATH' , PHPWG_PLUGINS_PATH . PFI_DIR . '/');
33define('PFI_ADMIN',get_root_url().'admin.php?page=plugin-'.PFI_DIR);
34
35add_event_handler('loading_lang', 'PersoFavicon_loading_lang');   
36function 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');
43function 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
53add_event_handler('loc_begin_page_header', 'Change_Favicon', 55 );
54function Change_Favicon(){
55        global $template;
56        $template->set_prefilter('header', 'Favicon');
57}
58
59function 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?>
Note: See TracBrowser for help on using the repository browser.