source: extensions/AStat/astat_aim.class.inc.php @ 3706

Last change on this file since 3706 was 3706, checked in by grum, 15 years ago

Update AStat 2.1.0 - new features
See main.inc.php file for details

  • Property svn:executable set to *
File size: 6.0 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_AIM : classe to manage plugin integration into plugin menu
13
14  --------------------------------------------------------------------------- */
15
16if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
17
18include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/common_plugin.class.inc.php');
19include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/css.class.inc.php');
20
21class AStat_AIM extends common_plugin
22{
23  protected $css = null;
24
25  function AStat_AIM($prefixeTable, $filelocation)
26  {
27    $this->plugin_name="AStat.2";
28    $this->plugin_name_files="astat";
29    parent::__construct($prefixeTable, $filelocation);
30    $this->css = new css(dirname($this->filelocation).'/'.$this->plugin_name_files.".css");
31  }
32
33  /*
34    initialize events call for the plugin
35  */
36  function init_events()
37  {
38    add_event_handler('get_admin_plugin_menu_links', array(&$this, 'plugin_admin_menu') );
39  }
40
41
42  /*
43    initialization of config properties
44  */
45  function init_config()
46  {
47    $this->my_config=array(
48      'AStat_BarColor_Pages' => '6666ff',
49      'AStat_BarColor_Img' => '66ff66',
50      'AStat_BarColor_IP' => 'ff6666',
51      'AStat_MouseOverColor' => '303030',
52      'AStat_NpIPPerPages' => '25',
53      'AStat_NpCatPerPages' => '50',
54      'AStat_MaxBarWidth' => '400',
55      'AStat_default_period' => 'global', //global, all, year, month, day
56      'AStat_ShowThumbCat' => 'true',
57      'AStat_DefaultSortCat' => 'page', //page, picture, nbpicture
58      'AStat_ShowThumbImg' => 'true',
59      'AStat_DefaultSortImg' => 'picture',  //picture, catname
60      'AStat_NbImgPerPages' => '100',
61      'AStat_BarColor_Cat' => 'fff966',
62      'AStat_DefaultSortIP' => 'page',    //page, ip, picture
63      'AStat_SeeTimeRequests' => 'false',
64      'AStat_BlackListedIP' => ''    // ip blacklisted (separator : ",")
65      );
66
67  }
68
69  /*
70    surchage of common_plugin->save_config function
71  */
72  function load_config()
73  {
74    parent::load_config();
75    if(!$this->css->css_file_exists())
76    {
77      $this->css->make_CSS($this->generate_CSS());
78    }
79  }
80
81  /*
82    surchage of common_plugin->save_config function
83  */
84  function save_config()
85  {
86    if(parent::save_config())
87    {
88      $this->css->make_CSS($this->generate_CSS());
89      return(true);
90    }
91    return(false);
92  }
93
94  /*
95    generate the css code
96  */
97  function generate_CSS()
98  {
99    $text = ".AStatBar1, .AStatBar2, .AStatBar3, .AStatBar4, .AStatBarX {
100      border:0px;
101      height:8px;
102      display: block;
103      margin:0px;
104      padding:0px;
105      left:0;
106      position:relative;
107      }
108       .MiniSquare1, .MiniSquare2, .MiniSquare3, .MiniSquare4 {
109      border:0px;
110      height:8px;
111      width:8px;
112      margin:0px;
113      padding:0px;
114      }
115       .AStatBar1 { background-color:#".$this->my_config['AStat_BarColor_Pages']."; top:5px;  }
116       .AStatBar2 { background-color:#".$this->my_config['AStat_BarColor_Img']."; top:-3px; }
117       .AStatBar3 { background-color:#".$this->my_config['AStat_BarColor_IP']."; top:-3px;}
118       .AStatBar4 { background-color:#".$this->my_config['AStat_BarColor_Cat']."; top:-3px;}
119       .AStatBarX { background-color:transparent; top:-3px; height:1px; }
120       .MiniSquare1 { color:#".$this->my_config['AStat_BarColor_Pages'].";   }
121       .MiniSquare2 { color:#".$this->my_config['AStat_BarColor_Img'].";  }
122       .MiniSquare3 { color:#".$this->my_config['AStat_BarColor_IP']."; }
123       .MiniSquare4 { color:#".$this->my_config['AStat_BarColor_Cat']."; }
124       .StatTableRow:hover { background-color:#".$this->my_config['AStat_MouseOverColor']."; }
125       .formtable, .formtable P { text-align:left; display:block; }
126       .formtable tr { vertical-align:top; }
127       .window_thumb {
128      position:absolute;
129      border: none;
130      background: none;
131      left:0;
132      top:0;
133      margin:0px;
134      padding:0px;
135      z-index:100;
136      overflow:hidden;
137      visibility:hidden; }
138        .img_thumb {
139      border: solid 3px #ffffff;
140      background: #000000;
141      margin:0px;
142      padding:0px; }
143        .time_request {
144      font-size:83%;
145      text-align:right; }
146        .invisible { visibility:hidden; display:none; }
147      .littlefont { font-size:90%; }
148      table.littlefont th { padding:3px; }
149      table.littlefont td { padding:0px;padding-left:3px;padding-right:3px; }
150      #iplist { visibility:hidden; position:absolute; width:200px; z-index:1000; }
151      .iipsellistitem { float:right; }
152      #iipsellist { width:100%; font-family:monospace; }
153    ";
154
155    return($text);
156  }
157
158  /* ---------------------------------------------------------------------------
159  Function needed for plugin activation
160  --------------------------------------------------------------------------- */
161
162  /*
163    get 'section' enumeration from HISTORY_TABLE
164  */
165  function get_section_enum($add)
166  {
167    $returned=array('', false);
168    $sql = 'SHOW COLUMNS FROM '.HISTORY_TABLE.' LIKE "section"';
169    $result=pwg_query($sql);
170    if($result)
171    {
172      $row = mysql_fetch_array($result);
173      $list=substr($row['Type'], 5, strlen($row['Type'])-6);
174      $returned[0]=explode(',', $list);
175      if((strpos($list, "'$add'")===false)&&($add!=''))
176      { array_push($returned[0], "'$add'"); }
177      else
178      { $returned[1]=true; }
179      return($returned);
180    }
181  }
182
183  function alter_history_section_enum($section)
184  {
185    $sections=$this->get_section_enum('deleted_cat');
186    if(!$sections[1])
187    {
188      $enums=implode(',', $sections[0]);
189      $sql="ALTER TABLE ".HISTORY_TABLE."
190          CHANGE `section` `section`
191          ENUM (".$enums.") ;";
192      $result=pwg_query($sql);
193      if(!$result)
194      {
195        return(false);
196      }
197    }
198    return(true);
199  }
200
201} // AStat_Plugin class
202
203
204?>
Note: See TracBrowser for help on using the repository browser.