<?php
// +-----------------------------------------------------------------------+
// | pwgCumulus  - a plugin for Piwigo                                     |
// +-----------------------------------------------------------------------+
// | Copyright(C) 2009-2010 Nicolas Roudaire        http://www.nikrou.net  |
// +-----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify  |
// | it under the terms of the GNU General Public License version 2 as     |
// | published by  the Free Software Foundation                            |
// |                                                                       |
// | This program is distributed in the hope that it will be useful, but   |
// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
// | General Public License for more details.                              |
// |                                                                       |
// | You should have received a copy of the GNU General Public License     |
// | along with this program; if not, write to the Free Software           |
// | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,            |
// | MA 02110-1301 USA                                                     |
// +-----------------------------------------------------------------------+

class pwgCumulusContent
{
  public function __construct($config) {
    $this->plugin_config = $config;
  }

  public function loc_begin_page_header() {
    if (!empty($_GET['display_mode']) && $_GET['display_mode']=='cumulus') {
      $GLOBALS['template']->assign('display_mode', 'cumulus');
    }

    $GLOBALS['template']->set_filenames(array('tags'=> PWG_CUMULUS_PLUGIN_TEMPLATE . '/tags.tpl'));
    $GLOBALS['template']->func_known_script(array('id' => 'swfobject',
						  'src' => PWG_CUMULUS_PLUGIN_JS. '/swfobject.js'
						  ),
					    $GLOBALS['template']->smarty
					    );
    
    $GLOBALS['template']->assign('PWG_CUMULUS_SWF', PWG_CUMULUS_PLUGIN_SWF);
    $GLOBALS['template']->assign('PWG_CUMULUS_IMGS', PWG_CUMULUS_PLUGIN_IMGS);

    $GLOBALS['template']->assign('PWG_CUMULUS_WIDTH', $this->plugin_config->pwg_cumulus_width);
    $GLOBALS['template']->assign('PWG_CUMULUS_HEIGHT', $this->plugin_config->pwg_cumulus_height);
    $GLOBALS['template']->assign('PWG_CUMULUS_HREF', get_root_url().'tags.php?display_mode=cumulus');

    $GLOBALS['template']->assign('PWG_CUMULUS_COLOR1', '0x'.$this->plugin_config->pwg_cumulus_color1);
    $GLOBALS['template']->assign('PWG_CUMULUS_COLOR2', '0x'.$this->plugin_config->pwg_cumulus_color2);
    $GLOBALS['template']->assign('PWG_CUMULUS_HICOLOR', '0x'.$this->plugin_config->pwg_cumulus_hicolor);

    if (!empty($GLOBALS['template']->smarty->_tpl_vars['tags'])) {
      foreach ($GLOBALS['template']->smarty->_tpl_vars['tags'] as $key => &$tag) {
	$tag['display_name'] = urlencode($tag['name']);
	$tag['size'] = $this->plugin_config->pwg_cumulus_coeff*$tag['level'];
      }
    }
  }
}
?>
