Changeset 20251 for extensions/user_tags/include/t4u_content.class.php
- Timestamp:
- Jan 18, 2013, 8:21:30 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/user_tags/include/t4u_content.class.php
r20139 r20251 6 6 // +-----------------------------------------------------------------------+ 7 7 // | This program is free software; you can redistribute it and/or modify | 8 // | it under the terms of the GNU General Public License version 2 as|8 // | it under the terms of the GNU General Public License version 2 as | 9 9 // | published by the Free Software Foundation | 10 10 // | | … … 29 29 global $template; 30 30 31 if (!$this->plugin_config->hasPermission('add')) { 32 return $content; 31 $template->set_prefilter('picture', array(__CLASS__, 'picture_prefilter')); 32 33 if ($this->plugin_config->hasPermission('add')) { 34 load_language('plugin.lang', T4U_PLUGIN_LANG); 35 36 $template->assign('T4U_JS', T4U_JS); 37 $template->assign('T4U_CSS', T4U_CSS); 38 $template->assign('T4U_IMGS', T4U_IMGS); 39 $template->assign('T4U_PERMISSION_DELETE', $this->plugin_config->hasPermission('delete')); 40 $template->assign('T4U_UPDATE_SCRIPT', get_root_url().'ws.php?format=json&method='.T4U_WS.'update'); 41 $template->assign('T4U_UPDATE_METHOD', T4U_WS.'update'); 42 $template->assign('T4U_LIST_SCRIPT', get_root_url().'ws.php?format=json&method='.T4U_WS.'list'); 43 $template->assign('T4U_IMAGE_ID', $picture['id']); 44 $template->assign('T4U_REFERER', urlencode($picture['url'])); 45 $template->assign('T4U_PERMISSION_DELETE', $this->plugin_config->hasPermission('delete')); 46 47 $related_tags = array(); 48 if (!empty($template->smarty->_tpl_vars['related_tags'])) { 49 foreach ($template->smarty->_tpl_vars['related_tags'] as $id => $tag_infos) { 50 $related_tags['~~'.$tag_infos['id'].'~~'] = $tag_infos['name']; 51 } 52 $template->assign('T4U_RELATED_TAGS', $related_tags); 53 } 54 55 $template->set_filename('add_tags', T4U_TEMPLATE.'/add_tags.tpl'); 56 $template->assign_var_from_handle('PLUGIN_PICTURE_AFTER', 'add_tags'); 33 57 } 58 } 34 59 35 load_language('plugin.lang', T4U_PLUGIN_LANG); 36 37 $template->assign('T4U_JS', T4U_JS); 38 $template->assign('T4U_CSS', T4U_CSS); 39 $template->assign('T4U_IMGS', T4U_IMGS); 40 $template->assign('T4U_PERMISSION_DELETE', $this->plugin_config->hasPermission('delete')); 41 $template->assign('T4U_UPDATE_SCRIPT', get_root_url().'ws.php?format=json&method='.T4U_WS.'update'); 42 $template->assign('T4U_UPDATE_METHOD', T4U_WS.'update'); 43 $template->assign('T4U_GET_SCRIPT', get_root_url().'ws.php?format=json&method='.T4U_WS.'list'); 44 $template->assign('T4U_IMAGE_ID', $picture['id']); 45 $template->assign('T4U_REFERER', urlencode($picture['url'])); 46 $template->assign('T4U_PERMISSION_DELETE', $this->plugin_config->hasPermission('delete')); 47 48 $related_tags = array(); 49 if (!empty($template->smarty->_tpl_vars['related_tags'])) { 50 foreach ($template->smarty->_tpl_vars['related_tags'] as $id => $tag_infos) { 51 $related_tags['~~'.$tag_infos['id'].'~~'] = $tag_infos['name']; 52 } 53 } 54 $template->assign('T4U_RELATED_TAGS', $related_tags); 55 56 $template->set_filename('add_tags', T4U_TEMPLATE.'/add_tags.tpl'); 57 58 $plugin_picture_before = $template->get_template_vars('PLUGIN_PICTURE_BEFORE'); 59 $plugin_picture_before .= $template->parse('add_tags', true); 60 $template->append('PLUGIN_PICTURE_BEFORE', $plugin_picture_before); 61 62 return $content; 60 public static function picture_prefilter($source, &$smarty) { 61 $pattern = '{if $display_info.tags and isset($related_tags)}'; 62 $replace = '{if $display_info.tags}'; 63 64 return str_replace($pattern, $replace, $source); 63 65 } 64 66 }
Note: See TracChangeset
for help on using the changeset viewer.