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