source: extensions/Statistics/main.inc.php @ 31813

Last change on this file since 31813 was 8426, checked in by rub, 13 years ago

Add description.txt of my maintained extensions
Replace old link (http://phpwebgallery.net/ext/ by http://piwigo.org/ext/)

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
9*/
10if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
11define('STAT_DIR' , basename(dirname(__FILE__)));
12define('STAT_PATH' , PHPWG_PLUGINS_PATH . STAT_DIR . '/');
13
14function statistics_admin_menu($menu)
15{
16  array_push(
17    $menu,
18    array(
19      'NAME' => 'Statistics',
20      'URL' => get_admin_plugin_menu_link(STAT_PATH . 'admin/stat_admin.php')
21      )
22    );
23  return $menu;
24}
25
26function stat_candoit($type)
27{
28  global $conf, $user;
29
30  $conf_statistics = unserialize($conf['statistics']);
31
32  if (is_admin() and $conf_statistics['exclude_admin'])
33  {
34    return false;
35  }
36
37  if (is_a_guest() and $conf_statistics['exclude_guest'])
38  {
39    return false;
40  }
41
42
43  $show_htmlcontent = false;
44  if ($conf_statistics['header'] and $type == 'header')
45  {
46    $show_htmlcontent = true;
47  }
48  if ($conf_statistics['tail'] and $type == 'tail')
49  {
50    $show_htmlcontent = true;
51  }
52
53  if (!$show_htmlcontent)
54  {
55    return false;
56  }
57
58  return '
59<!-- Plugin Statistics -->
60'.$conf_statistics['content'].'
61<!-- Plugin Statistics -->
62';
63}
64
65function stat_tail()
66{
67  global $template;
68
69  if ($code_stat = stat_candoit('tail'))
70  {
71    $template->append('footer_elements', $code_stat);
72  }
73}
74
75function stat_header()
76{
77  global $template;
78
79  if ($code_stat = stat_candoit('header'))
80  {
81    $template->append('head_elements', $code_stat);
82  }
83}
84
85add_event_handler('get_admin_plugin_menu_links', 'statistics_admin_menu');
86add_event_handler('loc_end_page_tail', 'stat_tail');
87add_event_handler('loc_end_page_header', 'stat_header');
88?>
Note: See TracBrowser for help on using the repository browser.