source: extensions/ColorStat/cstat_pip.class.inc.php @ 15907

Revision 6176, 2.4 KB checked in by grum, 10 years ago (diff)

Improve algorythm for colors analysis + use GPCRequestBuilder interface instead of a local interface

  • Property svn:executable set to *
Line 
1<?php
2/* -----------------------------------------------------------------------------
3  Plugin     : ColorStat
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  CStat_PIP : classe to manage plugin public pages
13
14  --------------------------------------------------------------------------- */
15
16include_once('cstat_root.class.inc.php');
17//include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCPublicIntegration.class.inc.php');
18
19class CStat_PIP extends CStat_root
20{
21  protected $section_page;
22
23  public function __construct($prefixeTable, $filelocation)
24  {
25    parent::__construct($prefixeTable, $filelocation);
26    $this->loadConfig();
27
28    $this->initEvents();
29    $this->load_lang();
30  }
31
32  public function __destruct()
33  {
34    unset($section_page);
35    parent::__destruct();
36  }
37
38  /**
39   * load language file
40   */
41  public function load_lang()
42  {
43    global $lang;
44
45    load_language('plugin.lang', CSTAT_PATH);
46  }
47
48  /**
49   * initialize events call for the plugin
50   */
51  public function initEvents()
52  {
53    parent::initEvents();
54
55    if($this->config['display_gallery_showColors']=='y')
56    {
57      add_event_handler('loc_begin_picture', array(&$this, 'addColors'));
58    }
59  }
60
61
62
63  /* -------------------------------------------------------------------------
64    FUNCTIONS TO MANAGE COLORS DISPLAY
65  ------------------------------------------------------------------------- */
66  public function addColors()
67  {
68    global $page, $template;
69
70    $colors=CStat_functions::getImageColors($page['image_id']);
71
72
73    if(count($colors['colors'])>0)
74    {
75      $metadata=$template->get_template_vars('metadata');
76
77      $tmp=Array();
78
79      for($i=0;$i<count($colors['colors']);$i++)
80      {
81        $tmp[$colors['colors'][$i]]['pct']=$colors['colors_pct'][$i];
82      }
83
84      $colorsNfo=Array(
85        'TITLE' => l10n('cstat_colors'),
86        'lines' => Array(
87          l10n('cstat_colors_on_image') => CStat_functions::htmlColorList($tmp, 8, 25, "", "color1px", "/"),
88        )
89      );
90
91      $metadata[]=$colorsNfo;
92
93      $template->assign('metadata', $metadata);
94    }
95  }
96
97
98
99  /* ---------------------------------------------------------------------------
100    ajax functions
101  --------------------------------------------------------------------------- */
102
103} //class
104
105?>
Note: See TracBrowser for help on using the repository browser.