Changeset 6107 for extensions/ColorStat/cstat_aip.class.inc.php
- Timestamp:
- May 7, 2010, 10:23:47 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/ColorStat/cstat_aip.class.inc.php
r5961 r6107 1 1 <?php 2 2 /* ----------------------------------------------------------------------------- 3 Plugin : LMT3 Plugin : ColorStat 4 4 Author : Grum 5 5 email : grum@piwigo.org … … 10 10 See main.inc.php for release information 11 11 12 LMT_AIP : classe to manage plugin admin pages12 CStat_AIP : classe to manage plugin admin pages 13 13 14 14 --------------------------------------------------------------------------- */ 15 16 if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 15 17 16 18 include_once('cstat_root.class.inc.php'); 17 19 include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php'); 20 include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTabSheet.class.inc.php'); 21 include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php'); 18 22 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 19 23 … … 25 29 { 26 30 parent::__construct($prefixeTable, $filelocation); 31 $this->checkRequest(); 32 27 33 $this->loadConfig(); 28 34 $this->initEvents(); … … 55 61 { 56 62 parent::initEvents(); 63 if($_REQUEST['f_tabsheet']=='search') 64 { 65 // load request builder JS only on the search page 66 GPCRequestBuilder::loadJSandCSS(); 67 } 57 68 add_event_handler('loc_end_page_header', array(&$this->css, 'applyCSS')); 58 69 GPCCss::applyGpcCss(); … … 65 76 { 66 77 global $template; 67 68 $this->checkRequest();69 78 70 79 $this->returnAjaxContent(); … … 154 163 { 155 164 if(!isset($_REQUEST['selectMode'])) $_REQUEST['selectMode']='caddieAdd'; 156 if(!isset($_REQUEST['numOfItems'])) $_REQUEST['numOfItems']=$this->config['analyze .itemPerRequest'];165 if(!isset($_REQUEST['numOfItems'])) $_REQUEST['numOfItems']=$this->config['analyze_itemPerRequest']; 157 166 158 167 if(!($_REQUEST['selectMode']=='notAnalyzed' or … … 181 190 } 182 191 192 183 193 } 184 194 … … 195 205 $datas=Array( 196 206 'urlRequest' => $this->getAdminLink(), 197 'numberOfItemsPerRequest' => $this->config['analyze .itemPerRequest']207 'numberOfItemsPerRequest' => $this->config['analyze_itemPerRequest'] 198 208 ); 199 209 $template->assign('datas', $datas); … … 211 221 dirname($this->getFileLocation()).'/admin/cstat_stat.tpl'); 212 222 213 $generalStats=$this->getGeneralStats(); 214 215 $colors=Array(); 216 $sql="SELECT color_id, num_images, num_pixels 217 FROM ".$this->tables['color_table']." 218 WHERE num_images > 0 219 ORDER BY color_id "; 220 $result=pwg_query($sql); 221 if($result) 222 { 223 while($row=pwg_db_fetch_assoc($result)) 224 { 225 $colors[$row['color_id']]=Array('num_images' => $row['num_images'], 'num_pixels' => $row['num_pixels']); 226 } 227 } 228 229 $colorTable=ColorStat::getColorTable( 230 $this->colorTableSize[$this->config['analyze.colorTable']][0], 231 $this->colorTableSize[$this->config['analyze.colorTable']][1] 232 ); 233 foreach($colorTable as $key=>$val) 234 { 235 foreach($val as $key2=>$val2) 236 { 237 $rgb=$val2->getRGB()->getHexString(); 238 $colorTable[$key][$key2]=Array( 239 'color' => $rgb, 240 'pct' => (array_key_exists($rgb, $colors))?sprintf("%.2f", round(100*$colors[$rgb]['num_pixels']/$generalStats['pixelsAnalyzedSum'],2)):"", 241 'num' => (array_key_exists($rgb, $colors))?$colors[$rgb]['num_images']:"", 242 ); 243 } 244 } 223 $colorTable=$this->getColorTableWithStat(); 224 245 225 246 226 $datas=Array( 227 //'themeconf' => Array('name' => $template->get_themeconf('name')), 247 228 'colorTable' => $this->htmlColorTable( 248 229 $colorTable, 249 ($this->config['analyze.colorTable']=='small')?19:10 230 ($this->config['analyze_colorTable']=='small')?19:10, 231 "", 232 "color0px" 250 233 ), 251 234 'urlRequest' => $this->getAdminLink(), 252 'config_GetListColors_OrderType' => $this->config['display .stat.orderType'],235 'config_GetListColors_OrderType' => $this->config['display_stat_orderType'], 253 236 ); 254 237 $template->assign('datas', $datas); … … 267 250 dirname($this->getFileLocation()).'/admin/cstat_search.tpl'); 268 251 252 $datas=Array( 253 'dialogBox' => $this->dialogBoxColor(), 254 'themeName' => $template->get_themeconf('name'), 255 ); 256 257 $template->assign('datas', $datas); 258 269 259 $template->assign_var_from_handle('CSTAT_BODY_PAGE', 'body_page'); 270 260 } //displaySearchPage … … 276 266 protected function displayConfigPage() 277 267 { 278 /* 268 $tmpPct=$this->config['stat_minPct']; 269 279 270 if(!$this->adviser_abort()) 280 271 { … … 283 274 foreach($this->config as $key => $val) 284 275 { 285 if(is _array($val))276 if(isset($_REQUEST['f_'.$key])) 286 277 { 287 foreach($languages as $key2 => $val2) 288 { 289 if(isset($_REQUEST[str2url('f_'.$key.'_'.$key2)])) 290 { 291 $this->config[$key][$key2] = htmlspecialchars(stripslashes($_REQUEST[str2url('f_'.$key.'_'.$key2)]), ENT_QUOTES); 292 } 293 } 278 $this->config[$key] = $_REQUEST['f_'.$key]; 294 279 } 295 else296 {297 if(isset($_REQUEST['f_'.$key]))298 {299 $this->config[$key] = $_REQUEST['f_'.$key];300 }301 }302 303 280 } 304 $this->displayResult(l10n('lmt_save_config'), $this->saveConfig()); 305 } 306 }*/ 281 $this->displayResult(l10n('cstat_save_config'), $this->saveConfig()); 282 } 283 } 284 285 if($tmpPct!=$this->config['stat_minPct']) 286 { 287 $this->updateDatabaseConsolidation(); 288 } 289 307 290 $this->displayConfig(); 308 291 } … … 317 300 $template->set_filename('body_page', 318 301 dirname($this->getFileLocation()).'/admin/cstat_config.tpl'); 302 303 $datas=Array( 304 'minPct' => $this->config['stat_minPct'], 305 'showColors' => $this->config['display_gallery_showColors'] 306 ); 307 308 $template->assign('datas', $datas); 319 309 320 310 $template->assign_var_from_handle('CSTAT_BODY_PAGE', 'body_page'); … … 353 343 'quality' => 8, 354 344 'numColors' => 16, 355 'maxTime' => $this->config['analyze .maxTime'],356 'pps' => $this->config['analyze .pps'],345 'maxTime' => $this->config['analyze_maxTime'], 346 'pps' => $this->config['analyze_pps'], 357 347 ) 358 348 ); … … 443 433 } 444 434 435 436 /** 437 * make consolidation for the color_table : 438 * - count number of images using a color 439 * - count number of pixels of a color 440 */ 441 protected function updateDatabaseConsolidation() 442 { 443 $sql="UPDATE ".$this->tables['color_table']." cct 444 SET cct.num_images=0, 445 cct.num_pixels=0;"; 446 pwg_query($sql); 447 448 $sql="UPDATE ".$this->tables['color_table']." cct, 449 (SELECT color_id, 450 count(image_id) AS num_images, 451 sum(num_pixels) AS num_pixels 452 FROM ".$this->tables['images_colors']." 453 WHERE pct >= ".$this->config['stat_minPct']." 454 GROUP BY color_id) cic 455 SET cct.num_images=cic.num_images, 456 cct.num_pixels=cic.num_pixels 457 WHERE cct.color_id=cic.color_id;"; 458 pwg_query($sql); 459 460 $sql="UPDATE ".$this->tables['images']." pci 461 SET pci.colors = '', 462 pci.colors_pct = ''"; 463 pwg_query($sql); 464 465 $sql="UPDATE ".$this->tables['images']." pci, 466 (SELECT image_id, 467 GROUP_CONCAT(color_id ORDER BY pct DESC SEPARATOR ',') AS colors, 468 GROUP_CONCAT(pct ORDER BY pct DESC SEPARATOR ',') AS colors_pct 469 FROM ".$this->tables['images_colors']." 470 WHERE pct >= ".$this->config['stat_minPct']." 471 GROUP BY image_id) pcic 472 SET pci.colors = pcic.colors, 473 pci.colors_pct = pcic.colors_pct 474 WHERE pci.image_id = pcic.image_id;"; 475 pwg_query($sql); 476 } 477 445 478 /* --------------------------------------------------------------------------- 446 479 ajax functions … … 593 626 { 594 627 $colorTable=ColorStat::getColorTable( 595 $this->colorTableSize[$this->config['analyze .colorTable']][0],596 $this->colorTableSize[$this->config['analyze .colorTable']][1]628 $this->colorTableSize[$this->config['analyze_colorTable']][0], 629 $this->colorTableSize[$this->config['analyze_colorTable']][1] 597 630 ); 598 631 … … 629 662 private function ajax_cstat_updateDatabaseConsolidation() 630 663 { 631 $sql="UPDATE ".$this->tables['color_table']." cct, 632 (SELECT color_id, 633 count(image_id) AS num_images, 634 sum(num_pixels) AS num_pixels 635 FROM ".$this->tables['images_colors']." 636 GROUP BY color_id) cic 637 SET cct.num_images=cic.num_images, 638 cct.num_pixels=cic.num_pixels 639 WHERE cct.color_id=cic.color_id;"; 640 pwg_query($sql); 664 $this->updateDatabaseConsolidation(); 641 665 return("ok"); 642 666 } … … 657 681 global $template; 658 682 659 $this->config['display .stat.orderType'] = $orderType;683 $this->config['display_stat_orderType'] = $orderType; 660 684 $this->saveConfig(); 661 685
Note: See TracChangeset
for help on using the changeset viewer.