| 1 | <?php |
|---|
| 2 | // +-----------------------------------------------------------------------+ |
|---|
| 3 | // | User Tags - a plugin for Piwigo | |
|---|
| 4 | // +-----------------------------------------------------------------------+ |
|---|
| 5 | // | Copyright(C) 2010 Nicolas Roudaire http://www.nikrou.net | |
|---|
| 6 | // +-----------------------------------------------------------------------+ |
|---|
| 7 | // | This program is free software; you can redistribute it and/or modify | |
|---|
| 8 | // | it under the terms of the GNU General Public License as published by | |
|---|
| 9 | // | the Free Software Foundation | |
|---|
| 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 | |
|---|
| 18 | // | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
|---|
| 19 | // | MA 02110-1301 USA. | |
|---|
| 20 | // +-----------------------------------------------------------------------+ |
|---|
| 21 | |
|---|
| 22 | class t4u_Content |
|---|
| 23 | { |
|---|
| 24 | public function __construct($config) { |
|---|
| 25 | $this->plugin_config = &$config; |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | public function render_element_content($content, $picture) { |
|---|
| 29 | global $template; |
|---|
| 30 | |
|---|
| 31 | if (!$this->plugin_config->hasPermission('add')) { |
|---|
| 32 | return false; |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | $template->func_known_script(array('id' => 'jquery', |
|---|
| 36 | 'src' => get_root_url().'themes/default/js/jquery.packed.js' |
|---|
| 37 | ), |
|---|
| 38 | $template->smarty |
|---|
| 39 | ); |
|---|
| 40 | |
|---|
| 41 | $template->assign('T4U_JS', T4U_JS); |
|---|
| 42 | $template->assign('T4U_CSS', T4U_CSS); |
|---|
| 43 | $template->assign('T4U_IMGS', T4U_IMGS); |
|---|
| 44 | $template->assign('T4U_ADD_SCRIPT', $this->plugin_config->getActionUrl('add', 'GET')); |
|---|
| 45 | $template->assign('T4U_GET_SCRIPT', $this->plugin_config->getActionUrl('get', 'GET')); |
|---|
| 46 | $template->assign('T4U_IMAGE_ID', $picture['id']); |
|---|
| 47 | $template->assign('T4U_REFERER', htmlentities($picture['url'])); |
|---|
| 48 | $template->assign('T4U_PERMISSION_DELETE', $this->plugin_config->hasPermission('delete')); |
|---|
| 49 | |
|---|
| 50 | $related_tags = array(); |
|---|
| 51 | if (!empty($template->smarty->_tpl_vars['related_tags'])) { |
|---|
| 52 | foreach ($template->smarty->_tpl_vars['related_tags'] as $id => $tag_infos) { |
|---|
| 53 | $related_tags['~~'.$tag_infos['id'].'~~'] = $tag_infos['name']; |
|---|
| 54 | } |
|---|
| 55 | } |
|---|
| 56 | $template->assign('T4U_RELATED_TAGS', $related_tags); |
|---|
| 57 | |
|---|
| 58 | $template->set_filename('add_tags', T4U_TEMPLATE.'/add_tags.tpl'); |
|---|
| 59 | $template->assign_var_from_handle('PLUGIN_PICTURE_BEFORE', 'add_tags'); |
|---|
| 60 | |
|---|
| 61 | return $content; |
|---|
| 62 | } |
|---|
| 63 | } |
|---|
| 64 | ?> |
|---|