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

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

Add plugin AStat 2.0.4

  • Property svn:executable set to *
File size: 5.7 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      );
65
66  }
67
68  /*
69    surchage of common_plugin->save_config function
70  */
71  function load_config()
72  {
73    parent::load_config();
74    if(!$this->css->css_file_exists())
75    {
76      $this->css->make_CSS($this->generate_CSS());
77    }
78  }
79
80  /*
81    surchage of common_plugin->save_config function
82  */
83  function save_config()
84  {
85    if(parent::save_config())
86    {
87      $this->css->make_CSS($this->generate_CSS());
88      return(true);
89    }
90    return(false);
91  }
92
93  /*
94    generate the css code
95  */
96  function generate_CSS()
97  {
98    $text = ".AStatBar1, .AStatBar2, .AStatBar3, .AStatBar4, .AStatBarX {
99      border:0px;
100      height:8px;
101      display: block;
102      margin:0px;
103      padding:0px;
104      left:0;
105      position:relative;
106      }
107       .MiniSquare1, .MiniSquare2, .MiniSquare3, .MiniSquare4 {
108      border:0px;
109      height:8px;
110      width:8px;
111      margin:0px;
112      padding:0px;
113      }
114       .AStatBar1 { background-color:#".$this->my_config['AStat_BarColor_Pages']."; top:5px;  }
115       .AStatBar2 { background-color:#".$this->my_config['AStat_BarColor_Img']."; top:-3px; }
116       .AStatBar3 { background-color:#".$this->my_config['AStat_BarColor_IP']."; top:-3px;}
117       .AStatBar4 { background-color:#".$this->my_config['AStat_BarColor_Cat']."; top:-3px;}
118       .AStatBarX { background-color:transparent; top:-3px; height:1px; }
119       .MiniSquare1 { color:#".$this->my_config['AStat_BarColor_Pages'].";   }
120       .MiniSquare2 { color:#".$this->my_config['AStat_BarColor_Img'].";  }
121       .MiniSquare3 { color:#".$this->my_config['AStat_BarColor_IP']."; }
122       .MiniSquare4 { color:#".$this->my_config['AStat_BarColor_Cat']."; }
123       .StatTableRow:hover { background-color:#".$this->my_config['AStat_MouseOverColor']."; }
124       .formtable, .formtable P { text-align:left; display:block; }
125       .window_thumb {
126      position:absolute;
127      border: none;
128      background: none;
129      left:0;
130      top:0;
131      margin:0px;
132      padding:0px;
133      z-index:100;
134      overflow:hidden;
135      visibility:hidden; } 
136        .img_thumb {
137      border: solid 3px #ffffff;
138      background: #000000;
139      margin:0px;
140      padding:0px; } 
141        .time_request {
142      font-size:83%;
143      text-align:right; }
144        .invisible { visibility:hidden; display:none; }
145      .littlefont { font-size:90%; }
146      table.littlefont th { padding:3px; }
147      table.littlefont td { padding:0px;padding-left:3px;padding-right:3px; }
148    ";
149
150    return($text);
151  }
152
153  /* ---------------------------------------------------------------------------
154  Function needed for plugin activation
155  --------------------------------------------------------------------------- */
156
157  /*
158    get 'section' enumeration from HISTORY_TABLE
159  */
160  function get_section_enum($add)
161  {
162    $returned=array('', false);
163    $sql = 'SHOW COLUMNS FROM '.HISTORY_TABLE.' LIKE "section"';
164    $result=pwg_query($sql);
165    if($result)
166    {
167      $row = mysql_fetch_array($result);
168      $list=substr($row['Type'], 5, strlen($row['Type'])-6);
169      $returned[0]=explode(',', $list);
170      if((strpos($list, "'$add'")===false)&&($add!=''))
171      { array_push($returned[0], "'$add'"); }
172      else
173      { $returned[1]=true; }
174      return($returned);
175    }
176  }
177
178  function alter_history_section_enum($section)
179  {
180    $sections=$this->get_section_enum('deleted_cat');
181    if(!$sections[1])
182    {
183      $enums=implode(',', $sections[0]);
184      $sql="ALTER TABLE ".HISTORY_TABLE."
185          CHANGE `section` `section`
186          ENUM (".$enums.") ;";
187      $result=pwg_query($sql);
188      if(!$result)
189      {
190        return(false);
191      }
192    }
193    return(true);
194  }
195
196} // AStat_Plugin class
197
198
199?>
Note: See TracBrowser for help on using the repository browser.