source: extensions/AStat/astat_root.class.inc.php @ 16009

Last change on this file since 16009 was 16009, checked in by grum, 8 years ago

feature:2636- compatibility with Piwigo 2.4

  • Property svn:executable set to *
File size: 3.9 KB
Line 
1<?php
2/* -----------------------------------------------------------------------------
3  Plugin     : AStat.2
4  Author     : Grum
5    email    : grum@piwigo.org
6    website  : http://photos.grum.fr
7
8    << May the Little SpaceFrog be with you ! >>
9  ------------------------------------------------------------------------------
10  See main.inc.php for release information
11
12  AStat_install classe => manage install process
13
14  --------------------------------------------------------------------------- */
15
16if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
17
18include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
19
20class AStat_root extends CommonPlugin
21{
22  public function __construct($prefixeTable, $filelocation)
23  {
24    global $conf;
25
26    $this->setPluginName("AStat.2");
27    $this->setPluginNameFiles("astat");
28    parent::__construct($prefixeTable, $filelocation);
29  }
30
31
32
33  /*
34    initialization of config properties
35  */
36  function initConfig()
37  {
38    $this->config=array(
39      'AStat_BarColor_Pages' => '6666ff',
40      'AStat_BarColor_Img' => '66ff66',
41      'AStat_BarColor_IP' => 'ff6666',
42      'AStat_MouseOverColor' => '303030',
43      'AStat_NpIPPerPages' => '25',
44      'AStat_NpCatPerPages' => '50',
45      'AStat_MaxBarWidth' => '400',
46      'AStat_default_period' => 'global', //global, all, year, month, day
47      'AStat_ShowThumbCat' => 'true',
48      'AStat_DefaultSortCat' => 'page', //page, picture, nbpicture
49      'AStat_ShowThumbImg' => 'true',
50      'AStat_DefaultSortImg' => 'picture',  //picture, catname
51      'AStat_NbImgPerPages' => '100',
52      'AStat_BarColor_Cat' => 'fff966',
53      'AStat_DefaultSortIP' => 'page',    //page, ip, picture
54      'AStat_SeeTimeRequests' => 'false',
55      'AStat_BlackListedIP' => '',    // ip blacklisted (separator : ",")
56      'AStat_UseBlackList' => 'false'    // if false, blacklist usage is disabled, if "invert" then result are inverted
57      );
58
59  }
60
61  public function loadCSS()
62  {
63    parent::loadCSS();
64    GPCCore::addHeaderCSS('astat.css', 'plugins/'.$this->getDirectory().'/'.$this->getPluginNameFiles().".css");
65    GPCCore::addHeaderContent('css',
66"
67.AStatBar1 { background-color:#".$this->config['AStat_BarColor_Pages']."; }
68.AStatBar2 { background-color:#".$this->config['AStat_BarColor_Img']."; }
69.AStatBar3 { background-color:#".$this->config['AStat_BarColor_IP']."; }
70.AStatBar4 { background-color:#".$this->config['AStat_BarColor_Cat']."; }
71
72.MiniSquare1 { color:#".$this->config['AStat_BarColor_Pages'].";   }
73.MiniSquare2 { color:#".$this->config['AStat_BarColor_Img'].";  }
74.MiniSquare3 { color:#".$this->config['AStat_BarColor_IP']."; }
75.MiniSquare4 { color:#".$this->config['AStat_BarColor_Cat']."; }
76
77.StatTableRow:hover { background-color:#".$this->config['AStat_MouseOverColor']."; }
78"
79    );
80  }
81
82  /* ---------------------------------------------------------------------------
83  Function needed for plugin activation
84  --------------------------------------------------------------------------- */
85
86  /*
87    get 'section' enumeration from HISTORY_TABLE
88  */
89  function get_section_enum($add)
90  {
91    $returned=array('', false);
92    $sql = 'SHOW COLUMNS FROM '.HISTORY_TABLE.' LIKE "section"';
93    $result=pwg_query($sql);
94    if($result)
95    {
96      $row = pwg_db_fetch_assoc($result);
97      $list=substr($row['Type'], 5, strlen($row['Type'])-6);
98      $returned[0]=explode(',', $list);
99      if((strpos($list, "'$add'")===false)&&($add!=''))
100      { array_push($returned[0], "'$add'"); }
101      else
102      { $returned[1]=true; }
103      return($returned);
104    }
105  }
106
107  function alter_history_section_enum($section)
108  {
109    $sections=$this->get_section_enum('deleted_cat');
110    if(!$sections[1])
111    {
112      $enums=implode(',', $sections[0]);
113      $sql="ALTER TABLE ".HISTORY_TABLE."
114          CHANGE `section` `section`
115          ENUM (".$enums.") ;";
116      $result=pwg_query($sql);
117      if(!$result)
118      {
119        return(false);
120      }
121    }
122    return(true);
123  }
124
125
126} // astat_root  class
127
128
129
130?>
Note: See TracBrowser for help on using the repository browser.