Changeset 16937 for extensions
- Timestamp:
- Jul 23, 2012, 4:41:12 PM (12 years ago)
- Location:
- extensions/header_manager
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/header_manager/admin.php
r15854 r16937 10 10 } 11 11 12 $page['tab'] = (isset($_GET['tab'])) ? $_GET['tab'] : 'config'; 12 13 13 // tabsheet 14 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 15 $page['tab'] = (isset($_GET['tab'])) ? $_GET['tab'] : $page['tab'] = 'config'; 16 17 $tabsheet = new tabsheet(); 18 $tabsheet->add('config', l10n('Configuration'), HEADER_MANAGER_ADMIN . '-config'); 19 $tabsheet->add('add', l10n('Add a banner'), HEADER_MANAGER_ADMIN . '-add'); 20 $tabsheet->select($page['tab']); 21 $tabsheet->assign(); 14 if ($page['tab'] == 'album') 15 { 16 include(HEADER_MANAGER_PATH . 'admin/album.php'); 17 } 18 else 19 { 20 // tabsheet 21 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 22 $tabsheet = new tabsheet(); 23 $tabsheet->add('config', l10n('Configuration'), HEADER_MANAGER_ADMIN . '-config'); 24 $tabsheet->add('add', l10n('Add a banner'), HEADER_MANAGER_ADMIN . '-add'); 25 $tabsheet->select($page['tab']); 26 $tabsheet->assign(); 22 27 23 // include page24 include(HEADER_MANAGER_PATH . 'admin/' . $page['tab'] . '.php');28 // include page 29 include(HEADER_MANAGER_PATH . 'admin/' . $page['tab'] . '.php'); 25 30 26 // template 27 $template->assign(array( 28 'HEADER_MANAGER_PATH'=> HEADER_MANAGER_PATH, 29 'CONFIG_URL' => HEADER_MANAGER_ADMIN . '-config', 30 'ADD_IMAGE_URL' => HEADER_MANAGER_ADMIN . '-add', 31 )); 31 // template 32 $template->assign(array( 33 'CONFIG_URL' => HEADER_MANAGER_ADMIN . '-config', 34 'ADD_IMAGE_URL' => HEADER_MANAGER_ADMIN . '-add', 35 )); 36 } 37 38 $template->assign('HEADER_MANAGER_PATH', HEADER_MANAGER_PATH); 39 32 40 $template->assign_var_from_handle('ADMIN_CONTENT', 'header_manager'); 33 41 -
extensions/header_manager/include/header_manager.inc.php
r15922 r16937 7 7 function header_manager_render($page_banner) 8 8 { 9 global $conf, $user, $template ;9 global $conf, $user, $template, $page; 10 10 11 if ($conf['header_manager']['image'] == 'random') 11 // search banner for a specific category 12 if (isset($page['category'])) 12 13 { 13 $banners = list_banners(); 14 if (!count($banners)) return $page_banner; 15 $banner = $banners[ mt_rand(0, count($banners)-1) ]; 14 // we use the banner configured for this category 15 // if no banner is configured we use the banner of the first parent category with a "deep" banner 16 // if nothing found we use the default banner 17 $query = ' 18 SELECT * 19 FROM '.HEADER_MANAGER_TABLE.' 20 WHERE 21 category_id IN ('.$page['category']['uppercats'].') 22 AND (category_id = '.$page['category']['id'].' OR deep = 1) 23 ;'; 24 $cat_banners = hash_from_query($query, 'category_id'); 25 26 if (count($cat_banners)) 27 { 28 function uppercats_sort($a, $b) 29 { 30 global $page; 31 $ids = explode(',', $page['category']['uppercats']); 32 return array_search($a['category_id'], $ids) < array_search($b['category_id'], $ids); 33 } 34 usort($cat_banners, 'uppercats_sort'); 35 36 foreach ($cat_banners as $cat_banner) 37 { 38 $cat_banner = get_banner($cat_banner['image']); 39 if ($cat_banner !== false) 40 { 41 $banner = $cat_banner; 42 break; 43 } 44 } 45 } 16 46 } 17 else 47 48 // use default banner 49 if (!isset($banner)) 18 50 { 19 $banner = get_banner($conf['header_manager']['image']); 20 if (!file_exists($banner['PATH'])) return $page_banner; 51 if ($conf['header_manager']['image'] == 'random') 52 { 53 $banners = list_banners(); 54 if (!count($banners)) return $page_banner; 55 $banner = $banners[ mt_rand(0, count($banners)-1) ]; 56 } 57 else 58 { 59 $banner = get_banner($conf['header_manager']['image']); 60 if ($banner === false) return $page_banner; 61 } 21 62 } 22 63 … … 75 116 } 76 117 118 /** 119 * tab on album edition page 120 */ 121 function header_manager_tab($sheets, $id) 122 { 123 if ($id == 'album') 124 { 125 load_language('plugin.lang', HEADER_MANAGER_PATH); 126 127 $sheets['headermanager'] = array( 128 'caption' => l10n('Banner'), 129 'url' => HEADER_MANAGER_ADMIN.'-album&cat_id='.$_GET['cat_id'], 130 ); 131 } 132 133 return $sheets; 134 } 135 77 136 ?> -
extensions/header_manager/language/en_UK/plugin.lang.php
r15854 r16937 31 31 $lang['Add a banner'] = 'Add a banner'; 32 32 33 $lang['Default banner'] = 'Default banner'; 34 33 35 ?> -
extensions/header_manager/language/fr_FR/plugin.lang.php
r15854 r16937 31 31 $lang['Add a banner'] = 'Ajouter une bannière'; 32 32 33 $lang['Default banner'] = 'Bannière par défaut'; 34 33 35 ?> -
extensions/header_manager/main.inc.php
r16088 r16937 11 11 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 12 12 13 global $prefixeTable; 13 14 define('HEADER_MANAGER_PATH', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); 14 15 define('HEADER_MANAGER_ADMIN', get_root_url() . 'admin.php?page=plugin-' . basename(dirname(__FILE__))); 15 16 define('HEADER_MANAGER_DIR', PWG_LOCAL_DIR . 'banners/'); 17 define('HEADER_MANAGER_TABLE', $prefixeTable . 'category_banner'); 16 18 17 19 add_event_handler('init', 'header_manager_init'); … … 31 33 if (defined('IN_ADMIN')) 32 34 { 35 add_event_handler('tabsheet_before_select', 'header_manager_tab', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); 33 36 add_event_handler('get_admin_plugin_menu_links', 'header_manager_admin_menu'); 34 37 } -
extensions/header_manager/maintain.inc.php
r15854 r16937 2 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 3 3 4 define(' HEADER_MANAGER_DIR', PWG_LOCAL_DIR . 'banners/');4 define('header_dir', PWG_LOCAL_DIR . 'banners/'); 5 5 6 6 define( … … 17 17 function plugin_install() 18 18 { 19 global $prefixeTable; 20 21 pwg_query( 22 'CREATE TABLE IF NOT EXISTS `' .$prefixeTable . 'category_banner` ( 23 `category_id` smallint(5) unsigned NOT NULL, 24 `image` varchar(255) NOT NULL, 25 `deep` tinyint(1) DEFAULT 1, 26 PRIMARY KEY (`category_id`) 27 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 28 ;'); 29 19 30 conf_update_param('header_manager', header_manager_default_config); 20 mkdir( HEADER_MANAGER_DIR, 0755);31 mkdir(header_dir, 0755); 21 32 } 22 33 23 34 function plugin_activate() 24 35 { 25 global $conf ;36 global $conf, $prefixeTable; 26 37 27 38 if (empty($conf['header_manager'])) … … 29 40 conf_update_param('header_manager', header_manager_default_config); 30 41 } 31 if (!file_exists( HEADER_MANAGER_DIR))42 if (!file_exists(header_dir)) 32 43 { 33 mkdir( HEADER_MANAGER_DIR, 0755);44 mkdir(header_dir, 0755); 34 45 } 46 47 pwg_query( 48 'CREATE TABLE IF NOT EXISTS `' .$prefixeTable . 'category_banner` ( 49 `category_id` smallint(5) unsigned NOT NULL, 50 `image` varchar(255) NOT NULL, 51 `deep` tinyint(1) DEFAULT 1, 52 PRIMARY KEY (`category_id`) 53 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 54 ;'); 35 55 } 36 56 37 57 function plugin_uninstall() 38 58 { 59 global $prefixeTable; 60 61 pwg_query('DROP TABLE `' .$prefixeTable . 'category_banner`;'); 39 62 pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "header_manager" LIMIT 1;'); 40 63 }
Note: See TracChangeset
for help on using the changeset viewer.