source: extensions/Statistics/main.inc.php

Last change on this file was 32414, checked in by ddtddt, 3 years ago

[Statistics] compatibility piwigo11

File size: 1.7 KB
Line 
1<?php
2/*
3Plugin Name: Statistics
4Version: auto
5Description: Add source code like Google Analytics on each page.
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=174
7Author: Ruben & Sakkhho
8Author URI: http://piwigo.org
9Has Settings: webmaster
10*/
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12define('STAT_DIR' , basename(dirname(__FILE__)));
13define('STAT_PATH' , PHPWG_PLUGINS_PATH . STAT_DIR . '/');
14
15/* add_event_handler('get_admin_plugin_menu_links', 'statistics_admin_menu');
16function statistics_admin_menu($menu)
17{
18  array_push(
19    $menu,
20    array(
21      'NAME' => 'Statistics',
22      'URL' => get_admin_plugin_menu_link(STAT_PATH . 'admin/stat_admin.php')
23      )
24    );
25  return $menu;
26}
27*/
28function stat_candoit($type)
29{
30  global $conf, $user;
31
32  $conf_statistics = unserialize($conf['statistics']);
33
34  if (is_admin() and $conf_statistics['exclude_admin'])
35  {
36    return false;
37  }
38
39  if (is_a_guest() and $conf_statistics['exclude_guest'])
40  {
41    return false;
42  }
43
44
45  $show_htmlcontent = false;
46  if ($conf_statistics['header'] and $type == 'header')
47  {
48    $show_htmlcontent = true;
49  }
50  if ($conf_statistics['tail'] and $type == 'tail')
51  {
52    $show_htmlcontent = true;
53  }
54
55  if (!$show_htmlcontent)
56  {
57    return false;
58  }
59
60  return '
61<!-- Plugin Statistics -->
62'.$conf_statistics['content'].'
63<!-- Plugin Statistics -->
64';
65}
66
67function stat_tail()
68{
69  global $template;
70
71  if ($code_stat = stat_candoit('tail'))
72  {
73    $template->append('footer_elements', $code_stat);
74  }
75}
76
77function stat_header()
78{
79  global $template;
80
81  if ($code_stat = stat_candoit('header'))
82  {
83    $template->append('head_elements', $code_stat);
84  }
85}
86
87
88add_event_handler('loc_end_page_tail', 'stat_tail');
89add_event_handler('loc_end_page_header', 'stat_header');
90?>
Note: See TracBrowser for help on using the repository browser.