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

Last change on this file since 21569 was 16010, checked in by grum, 12 years ago

feature:2639- compatibility with Piwigo 2.4

  • Property svn:executable set to *
File size: 2.4 KB
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    FUNCTIONS TO MANAGE COLORS DISPLAY
63  ------------------------------------------------------------------------- */
64  public function addColors()
65  {
66    global $page, $template;
67
68    $colors=CStat_functions::getImageColors($page['image_id']);
69
70
71    if(count($colors['colors'])>0)
72    {
73      $metadata=$template->get_template_vars('metadata');
74
75      $tmp=Array();
76
77      for($i=0;$i<count($colors['colors']);$i++)
78      {
79        $tmp[$colors['colors'][$i]]['pct']=$colors['colors_pct'][$i];
80      }
81
82      $colorsNfo=Array(
83        'TITLE' => l10n('cstat_colors'),
84        'lines' => Array(
85          l10n('cstat_colors_on_image') => CStat_functions::htmlColorList($tmp, 8, 25, "", "color1px", "/"),
86        )
87      );
88
89      $metadata[]=$colorsNfo;
90
91      $template->assign('metadata', $metadata);
92    }
93  }
94
95
96
97  /* ---------------------------------------------------------------------------
98    ajax functions
99  --------------------------------------------------------------------------- */
100
101} //class
102
103?>
Note: See TracBrowser for help on using the repository browser.