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

Last change on this file since 31466 was 31466, checked in by ddtddt, 9 years ago

[extensions] - PersoFavicon - 2.8

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