> ------------------------------------------------------------------------------ See main.inc.php for release information CStat_root : common classe for admin and public classes --------------------------------------------------------------------------- */ include_once('cstat_colorstat.class.inc.php'); include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'); include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCss.class.inc.php'); include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCAjax.class.inc.php'); class CStat_root extends CommonPlugin { protected $css; //the css object protected $colorTableSize=Array('small' => Array(30,20), 'large' => Array(10,10)); public function __construct($prefixeTable, $filelocation) { $this->setPluginName('ColorStat'); $this->setPluginNameFiles("cstat"); parent::__construct($prefixeTable, $filelocation); $this->section_name=$this->getPluginNameFiles(); $this->setTablesList(array('images', 'color_table', 'images_colors')); $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().".css"); } public function __destruct() { unset($this->css); parent::__destruct(); } public function initEvents() { parent::initEvents(); add_event_handler('blockmanager_register_blocks', array(&$this, 'register_blocks') ); } /* menu block management */ public function register_blocks() { } /* intialize default values */ public function initConfig() { //global $user; $this->config=array( 'newInstall' => 'n', 'analyze.maxTime' => 0.1, 'analyze.colorTable' => 'small', 'analyze.pps' => 0, 'analyze.itemPerRequest' => 10, 'display.stat.orderType' => 'img', ); } /** * return HTML code for a given colorTable * * @param Array $colorTable : a color table, typically made with the * ColorStat::getColorTable() function * @param Int $size : size for colorbox in the HTML table * @return String : HTML code */ public function htmlColorTable($colorTable, $size=5, $id="", $class="") { global $template; $template->set_filename('color_table_page', dirname($this->getFileLocation()).'/templates/cstat_color_table.tpl'); $nbHue=count($colorTable); $nbStep=count($colorTable[0]); $colors=Array(); for($step=0;$step<$nbStep;$step++) { $row=Array(); for($hue=0;$hue<$nbHue;$hue++) { if($colorTable[$hue][$step] instanceof HSV) { $row[]=Array('color' => $colorTable[$hue][$step]->getRGB()->getHexString(), 'pct' => "", 'num' => ""); } elseif(is_array($colorTable[$hue][$step])) { $row[]=Array( 'color' => (array_key_exists('color', $colorTable[$hue][$step]))?$colorTable[$hue][$step]['color']:"", 'pct' => (array_key_exists('pct', $colorTable[$hue][$step]))?$colorTable[$hue][$step]['pct']:"", 'num' => (array_key_exists('num', $colorTable[$hue][$step]))?$colorTable[$hue][$step]['num']:"", ); } else { $row[]=Array('color' => $colorTable[$hue][$step], 'pct' => "", 'num' => ""); } } $colors[]=$row; unset($row); } $data=array( 'colorTable' => $colors, 'size' => $size, 'id' => $id, 'class' => $class ); $template->assign('data', $data); unset($data); return($template->parse('color_table_page', true)); } /** * return HTML code for a given colors list * * @param Array $colors : list of colors * @param Int $size : size for colorbox in the HTML table * @return String : HTML code */ public function htmlColorList($colorList, $split=8, $size=5, $id="", $class="") { global $template; $template->set_filename('color_table_page', dirname($this->getFileLocation()).'/templates/cstat_color_table.tpl'); $colors=Array(); $row=0; $num=0; foreach($colorList as $key => $val) { $colors[$row][]=Array('color' => $key, 'pct' => $val['pct'], 'num' => ""); $num++; if($num==$split) { $num=0; $row++; } } $data=array( 'colorTable' => $colors, 'size' => $size, 'id' => $id, 'class' => $class ); $template->assign('data', $data); unset($data); return($template->parse('color_table_page', true)); } protected function displayResult($action_msg, $result) { global $page; if($result) { array_push($page['infos'], $action_msg); } else { array_push($page['errors'], $action_msg); } } /* --------------------------------------------------------------------------- ajax functions --------------------------------------------------------------------------- */ } //class ?>