source: extensions/Histogram/hgram_aip.class.inc.php @ 31999

Last change on this file since 31999 was 16013, checked in by grum, 12 years ago

feature:2640- compatibility with Piwigo 2.4

  • Property svn:executable set to *
File size: 5.1 KB
Line 
1<?php
2/* -----------------------------------------------------------------------------
3  Plugin     : Histogram
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  HGram_AIP : classe to manage plugin admin pages
13
14  --------------------------------------------------------------------------- */
15
16if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
17
18include_once('hgram_root.class.inc.php');
19include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php');
20include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTabSheet.class.inc.php');
21include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
22
23class HGram_AIP extends HGram_root
24{
25  protected $tabsheet;
26
27  public function __construct($prefixeTable, $filelocation)
28  {
29    parent::__construct($prefixeTable, $filelocation);
30    $this->checkRequest();
31
32    $this->loadConfig();
33    $this->initEvents();
34
35    $this->tabsheet = new tabsheet();
36/*    $this->tabsheet->add('database',
37                          l10n('hgram_database'),
38                          $this->getAdminLink()."&amp;f_tabsheet=database");*/
39    $this->tabsheet->add('config',
40                          l10n('hgram_config'),
41                          $this->getAdminLink()."-config");
42  }
43
44  public function __destruct()
45  {
46    unset($this->tabsheet);
47    parent::__destruct();
48  }
49
50  /*
51    initialize events call for the plugin
52  */
53  public function initEvents()
54  {
55    parent::initEvents();
56    if($_GET['tab']=='search')
57    {
58      // load request builder JS only on the search page
59      GPCRequestBuilder::loadJSandCSS();
60    }
61  }
62
63  public function loadCSS()
64  {
65    parent::loadCSS();
66    GPCCore::addUI('gpcCSS');
67  }
68
69  /*
70    display administration page
71  */
72  public function manage()
73  {
74    global $template;
75
76    $template->set_filename('plugin_admin_content', dirname(__FILE__)."/admin/hgram_admin.tpl");
77
78    switch($_GET['tab'])
79    {
80      case 'config':
81        $this->displayConfigPage();
82        break;
83    }
84
85    $this->tabsheet->select($_GET['tab']);
86    $this->tabsheet->assign();
87    $selected_tab=$this->tabsheet->get_selected();
88    $template->assign($this->tabsheet->get_titlename(), "[".$selected_tab['caption']."]");
89
90    $template_plugin["HGRAM_VERSION"] = "<i>".$this->getPluginName()."</i> ".l10n('hgram_release').HGRAM_VERSION;
91
92    $template->assign('plugin', $template_plugin);
93    $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
94  }
95
96
97  /**
98   * check the $_REQUEST values and set default values
99   *
100   */
101  protected function checkRequest()
102  {
103    if(!isset($_GET['tab'])) $_GET['tab']='config';
104
105    if(!($_GET['tab']=='config')) $_GET['tab']='config';
106  }
107
108  /**
109   * manage display of config page & save config
110   */
111  protected function displayConfigPage()
112  {
113    $cfg=$this->config;
114
115    if(isset($_POST['submit_save_config']))
116    {
117      foreach($cfg as $key => $val)
118      {
119        if(isset($_REQUEST['f_'.$key]))
120        {
121          $cfg[$key] = $_REQUEST['f_'.$key];
122        }
123      }
124
125      if($cfg['color_r']=='')
126      {
127        $cfg['mode_r']='none';
128      }
129      else
130      {
131        $cfg['mode_r']='line';
132      }
133
134      if($cfg['color_g']=='')
135      {
136        $cfg['mode_g']='none';
137      }
138      else
139      {
140        $cfg['mode_g']='line';
141      }
142
143      if($cfg['color_b']=='')
144      {
145        $cfg['mode_b']='none';
146      }
147      else
148      {
149        $cfg['mode_b']='line';
150      }
151
152      $cfg['color_bg'] = Histogram::RGBToInt(Histogram::StringToRGB($cfg['color_bg']));
153      $cfg['color_v'] = Histogram::RGBToInt(Histogram::StringToRGB($cfg['color_v']));
154      $cfg['color_r'] = Histogram::RGBToInt(Histogram::StringToRGB($cfg['color_r']));
155      $cfg['color_g'] = Histogram::RGBToInt(Histogram::StringToRGB($cfg['color_g']));
156      $cfg['color_b'] = Histogram::RGBToInt(Histogram::StringToRGB($cfg['color_b']));
157
158
159      $this->config=$cfg;
160      $this->purgeHistoCache();
161
162      $this->displayResult(l10n('hgram_save_config'), $this->saveConfig());
163    }
164
165    $this->displayConfig();
166  }
167
168  /**
169   * display config page
170   */
171  protected function displayConfig()
172  {
173    global $template, $lang;
174
175    $template->set_filename('body_page',
176                dirname($this->getFileLocation()).'/admin/hgram_config.tpl');
177
178
179    $cfg=$this->config;
180
181    $cfg['color_bg'] = Histogram::RGBToString(Histogram::IntToRGB($cfg['color_bg']));
182    $cfg['color_v'] = Histogram::RGBToString(Histogram::IntToRGB($cfg['color_v']));
183    $cfg['color_r'] = Histogram::RGBToString(Histogram::IntToRGB($cfg['color_r']));
184    $cfg['color_g'] = Histogram::RGBToString(Histogram::IntToRGB($cfg['color_g']));
185    $cfg['color_b'] = Histogram::RGBToString(Histogram::IntToRGB($cfg['color_b']));
186    if($cfg['mode_r']=='none') $cfg['color_r']='';
187    if($cfg['mode_g']=='none') $cfg['color_g']='';
188    if($cfg['mode_b']=='none') $cfg['color_b']='';
189
190
191    $template->assign('hgramConfig', $cfg);
192
193    $template->assign_var_from_handle('HGRAM_BODY_PAGE', 'body_page');
194
195  } //displayConfig
196
197
198
199} //class
200
201
202?>
Note: See TracBrowser for help on using the repository browser.