[5201] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
| 3 | // | pwgCumulus - a plugin for Piwigo | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
[21469] | 5 | // | Copyright(C) 2009-2013 Nicolas Roudaire http://www.nikrou.net | |
---|
[5201] | 6 | // +-----------------------------------------------------------------------+ |
---|
| 7 | // | This program is free software; you can redistribute it and/or modify | |
---|
[6433] | 8 | // | it under the terms of the GNU General Public License version 2 as | |
---|
| 9 | // | published by the Free Software Foundation | |
---|
[5201] | 10 | // | | |
---|
| 11 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 12 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 13 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 14 | // | General Public License for more details. | |
---|
| 15 | // | | |
---|
| 16 | // | You should have received a copy of the GNU General Public License | |
---|
| 17 | // | along with this program; if not, write to the Free Software | |
---|
[6433] | 18 | // | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
---|
| 19 | // | MA 02110-1301 USA | |
---|
[5201] | 20 | // +-----------------------------------------------------------------------+ |
---|
| 21 | |
---|
| 22 | class pwgCumulusContent |
---|
| 23 | { |
---|
[26115] | 24 | public function __construct($config) { |
---|
| 25 | $this->plugin_config = $config; |
---|
| 26 | } |
---|
[5201] | 27 | |
---|
[26115] | 28 | public function loc_begin_page_header() { |
---|
| 29 | global $template; |
---|
[11344] | 30 | |
---|
[26115] | 31 | if (!empty($_GET['display_mode']) && $_GET['display_mode']=='cumulus') { |
---|
| 32 | $template->assign('display_mode', 'cumulus'); |
---|
| 33 | } |
---|
[5201] | 34 | |
---|
[26115] | 35 | $template->set_filenames(array('tags'=> PWG_CUMULUS_PLUGIN_TEMPLATE . '/tags.tpl')); |
---|
[11344] | 36 | |
---|
[26115] | 37 | $template->assign('PWG_CUMULUS_SWF', PWG_CUMULUS_PLUGIN_SWF); |
---|
| 38 | $template->assign('PWG_CUMULUS_IMGS', PWG_CUMULUS_PLUGIN_IMGS); |
---|
[5201] | 39 | |
---|
[26115] | 40 | $template->assign('PWG_CUMULUS_WIDTH', $this->plugin_config->pwg_cumulus_width); |
---|
| 41 | $template->assign('PWG_CUMULUS_HEIGHT', $this->plugin_config->pwg_cumulus_height); |
---|
| 42 | $template->assign('PWG_CUMULUS_HREF', get_root_url().'tags.php?display_mode=cumulus'); |
---|
[5201] | 43 | |
---|
[26115] | 44 | $template->assign('PWG_CUMULUS_MODE_TRANSPARENT', $this->plugin_config->pwg_cumulus_mode_transparent); |
---|
| 45 | $template->assign('PWG_CUMULUS_BGCOLOR', $this->plugin_config->pwg_cumulus_bgcolor); |
---|
| 46 | $template->assign('PWG_CUMULUS_COLOR1', '0x'.$this->plugin_config->pwg_cumulus_color1); |
---|
| 47 | $template->assign('PWG_CUMULUS_COLOR2', '0x'.$this->plugin_config->pwg_cumulus_color2); |
---|
| 48 | $template->assign('PWG_CUMULUS_HICOLOR', '0x'.$this->plugin_config->pwg_cumulus_hicolor); |
---|
[5201] | 49 | |
---|
[26115] | 50 | if (!empty($template->smarty->tpl_vars['tags'])) { |
---|
| 51 | foreach ($template->smarty->tpl_vars['tags']->value as $key => &$tag) { |
---|
| 52 | $tag['display_name'] = urlencode($tag['name']); |
---|
| 53 | $tag['size'] = $this->plugin_config->pwg_cumulus_coeff * $tag['level']; |
---|
| 54 | } |
---|
| 55 | } |
---|
[5201] | 56 | } |
---|
[11344] | 57 | |
---|
[26115] | 58 | public function blockmanager_register_blocks($menu_ref_arr) { |
---|
| 59 | if (!$this->plugin_config->pwg_cumulus_in_main_menu) { |
---|
| 60 | return; |
---|
| 61 | } |
---|
| 62 | $menu = &$menu_ref_arr[0]; |
---|
| 63 | if ($menu->get_id() != 'menubar') { |
---|
| 64 | return; |
---|
| 65 | } |
---|
| 66 | $menu->register_block(new RegisteredBlock('mbCumulus', 'Cumulus', 'piwigo')); |
---|
[11344] | 67 | } |
---|
| 68 | |
---|
| 69 | |
---|
[26115] | 70 | public function blockmanager_apply($menu_ref_arr) { |
---|
| 71 | global $template; |
---|
[11344] | 72 | |
---|
[26115] | 73 | if (!$this->plugin_config->pwg_cumulus_in_main_menu) { |
---|
| 74 | return; |
---|
| 75 | } |
---|
[11344] | 76 | |
---|
[26115] | 77 | load_language('plugin.lang', PWG_CUMULUS_PLUGIN_LANG); |
---|
[11344] | 78 | |
---|
[26115] | 79 | $menu = &$menu_ref_arr[0]; |
---|
| 80 | if ($menu->get_id() != 'menubar') { |
---|
| 81 | return; |
---|
| 82 | } |
---|
[11344] | 83 | |
---|
[26115] | 84 | include_once(PHPWG_ROOT_PATH.'include/block.class.php'); |
---|
[11344] | 85 | |
---|
[26115] | 86 | if (($mbCumulus = $menu->get_block('mbTags'))!==null) { |
---|
| 87 | if (empty($mbCumulus->data)) { |
---|
| 88 | return; |
---|
| 89 | } |
---|
| 90 | if ($this->plugin_config->position_order!=null |
---|
| 91 | && $this->plugin_config->position_block_id!=null) { |
---|
| 92 | $related_block = $menu->get_block($this->plugin_config->position_block_id); |
---|
| 93 | if ($this->plugin_config->position_order=='after') { |
---|
| 94 | $mbCumulus->set_position($related_block->get_position()+1); |
---|
| 95 | } else { |
---|
| 96 | $mbCumulus->set_position($related_block->get_position()-1); |
---|
| 97 | } |
---|
| 98 | } |
---|
[11344] | 99 | |
---|
[26115] | 100 | $template->assign('PWG_CUMULUS_SWF', PWG_CUMULUS_PLUGIN_SWF); |
---|
| 101 | $template->assign('PWG_CUMULUS_IMGS', PWG_CUMULUS_PLUGIN_IMGS); |
---|
[11344] | 102 | |
---|
[26115] | 103 | $template->assign('PWG_CUMULUS_WIDTH', $this->plugin_config->pwg_cumulus_width); |
---|
| 104 | $template->assign('PWG_CUMULUS_HEIGHT', $this->plugin_config->pwg_cumulus_height); |
---|
| 105 | $template->assign('PWG_CUMULUS_MODE_TRANSPARENT', $this->plugin_config->pwg_cumulus_mode_transparent); |
---|
| 106 | $template->assign('PWG_CUMULUS_BGCOLOR', $this->plugin_config->pwg_cumulus_bgcolor); |
---|
| 107 | $template->assign('PWG_CUMULUS_COLOR1', '0x'.$this->plugin_config->pwg_cumulus_color1); |
---|
| 108 | $template->assign('PWG_CUMULUS_COLOR2', '0x'.$this->plugin_config->pwg_cumulus_color2); |
---|
| 109 | $template->assign('PWG_CUMULUS_HICOLOR', '0x'.$this->plugin_config->pwg_cumulus_hicolor); |
---|
| 110 | foreach ($mbCumulus->data as &$tag) { |
---|
| 111 | $tag['size'] = $this->plugin_config->pwg_cumulus_coeff * $tag['level']; |
---|
| 112 | if (!empty($tag['U_ADD'])) { |
---|
| 113 | $tag['URL'] = $tag['U_ADD']; |
---|
| 114 | } |
---|
| 115 | } |
---|
| 116 | $template->assign('PWG_CUMULUS_TAGS', $mbCumulus->data); |
---|
| 117 | $mbCumulus->template = PWG_CUMULUS_PLUGIN_TEMPLATE . '/menubar_tags.tpl'; |
---|
| 118 | } |
---|
[11344] | 119 | } |
---|
[5201] | 120 | } |
---|