[3394] | 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 | |
---|
[5546] | 18 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'); |
---|
| 19 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCss.class.inc.php'); |
---|
[3394] | 20 | |
---|
[5546] | 21 | class AStat_AIM extends CommonPlugin |
---|
[3706] | 22 | { |
---|
[3394] | 23 | protected $css = null; |
---|
| 24 | |
---|
| 25 | function AStat_AIM($prefixeTable, $filelocation) |
---|
| 26 | { |
---|
[5546] | 27 | $this->setPluginName("AStat.2"); |
---|
| 28 | $this->setPluginNameFiles("astat"); |
---|
[3394] | 29 | parent::__construct($prefixeTable, $filelocation); |
---|
[5546] | 30 | $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().".css"); |
---|
[3394] | 31 | } |
---|
| 32 | |
---|
| 33 | /* |
---|
| 34 | initialize events call for the plugin |
---|
| 35 | */ |
---|
[5546] | 36 | function initEvents() |
---|
[3394] | 37 | { |
---|
[5546] | 38 | add_event_handler('get_admin_plugin_menu_links', array(&$this, 'pluginAdminMenu') ); |
---|
[3394] | 39 | } |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | /* |
---|
| 43 | initialization of config properties |
---|
| 44 | */ |
---|
[5546] | 45 | function initConfig() |
---|
[3394] | 46 | { |
---|
[5546] | 47 | $this->config=array( |
---|
[3394] | 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 |
---|
[3706] | 63 | 'AStat_SeeTimeRequests' => 'false', |
---|
[3707] | 64 | 'AStat_BlackListedIP' => '', // ip blacklisted (separator : ",") |
---|
| 65 | 'AStat_UseBlackList' => 'false' // if false, blacklist usage is disabled, if "invert" then result are inverted |
---|
[3394] | 66 | ); |
---|
| 67 | |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | /* |
---|
[5546] | 71 | surchage of CommonPlugin->saveConfig function |
---|
[3394] | 72 | */ |
---|
[5546] | 73 | function loadConfig() |
---|
[3394] | 74 | { |
---|
[5546] | 75 | parent::loadConfig(); |
---|
| 76 | if(!$this->css->fileExists()) |
---|
[3394] | 77 | { |
---|
[5546] | 78 | $this->css->makeCSS($this->generate_CSS()); |
---|
[3394] | 79 | } |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | /* |
---|
[5546] | 83 | surchage of CommonPlugin->saveConfig function |
---|
[3394] | 84 | */ |
---|
[5546] | 85 | function saveConfig() |
---|
[3394] | 86 | { |
---|
[5546] | 87 | if(parent::saveConfig()) |
---|
[3394] | 88 | { |
---|
[5546] | 89 | $this->css->makeCSS($this->generate_CSS()); |
---|
[3394] | 90 | return(true); |
---|
| 91 | } |
---|
| 92 | return(false); |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | /* |
---|
| 96 | generate the css code |
---|
| 97 | */ |
---|
| 98 | function generate_CSS() |
---|
| 99 | { |
---|
[3706] | 100 | $text = ".AStatBar1, .AStatBar2, .AStatBar3, .AStatBar4, .AStatBarX { |
---|
| 101 | border:0px; |
---|
[3394] | 102 | height:8px; |
---|
| 103 | display: block; |
---|
| 104 | margin:0px; |
---|
| 105 | padding:0px; |
---|
| 106 | left:0; |
---|
| 107 | position:relative; |
---|
| 108 | } |
---|
[3706] | 109 | .MiniSquare1, .MiniSquare2, .MiniSquare3, .MiniSquare4 { |
---|
| 110 | border:0px; |
---|
[3394] | 111 | height:8px; |
---|
| 112 | width:8px; |
---|
| 113 | margin:0px; |
---|
| 114 | padding:0px; |
---|
| 115 | } |
---|
[5546] | 116 | .AStatBar1 { background-color:#".$this->config['AStat_BarColor_Pages']."; top:5px; } |
---|
| 117 | .AStatBar2 { background-color:#".$this->config['AStat_BarColor_Img']."; top:-3px; } |
---|
| 118 | .AStatBar3 { background-color:#".$this->config['AStat_BarColor_IP']."; top:-3px;} |
---|
| 119 | .AStatBar4 { background-color:#".$this->config['AStat_BarColor_Cat']."; top:-3px;} |
---|
[3394] | 120 | .AStatBarX { background-color:transparent; top:-3px; height:1px; } |
---|
[5546] | 121 | .MiniSquare1 { color:#".$this->config['AStat_BarColor_Pages']."; } |
---|
| 122 | .MiniSquare2 { color:#".$this->config['AStat_BarColor_Img']."; } |
---|
| 123 | .MiniSquare3 { color:#".$this->config['AStat_BarColor_IP']."; } |
---|
| 124 | .MiniSquare4 { color:#".$this->config['AStat_BarColor_Cat']."; } |
---|
| 125 | .StatTableRow:hover { background-color:#".$this->config['AStat_MouseOverColor']."; } |
---|
[3706] | 126 | .formtable, .formtable P { text-align:left; display:block; } |
---|
| 127 | .formtable tr { vertical-align:top; } |
---|
[3394] | 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; |
---|
[3706] | 138 | visibility:hidden; } |
---|
[3394] | 139 | .img_thumb { |
---|
| 140 | border: solid 3px #ffffff; |
---|
| 141 | background: #000000; |
---|
| 142 | margin:0px; |
---|
[3706] | 143 | padding:0px; } |
---|
[3394] | 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; } |
---|
[3706] | 151 | #iplist { visibility:hidden; position:absolute; width:200px; z-index:1000; } |
---|
| 152 | .iipsellistitem { float:right; } |
---|
| 153 | #iipsellist { width:100%; font-family:monospace; } |
---|
[3394] | 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 | { |
---|
[5423] | 173 | $row = pwg_db_fetch_assoc($result); |
---|
[3394] | 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 | ?> |
---|