Changeset 7093
- Timestamp:
- Oct 4, 2010, 8:58:57 PM (14 years ago)
- Location:
- extensions/theme_switch/trunk
- Files:
-
- 10 added
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/theme_switch/trunk/flags.tpl
r7072 r7093 35 35 </li> 36 36 {html_head} 37 {if $themeconf. template=='yoga' and $themeconf.theme=='Sylvia'}37 {if $themeconf.name =='Sylvia'} 38 38 <link rel="stylesheet" type="text/css" href="{$ROOT_URL}{$THEME_SWITCH_PATH|@cat:'theme_switch.css'}"> 39 39 {else} -
extensions/theme_switch/trunk/main.inc.php
r7072 r7093 4 4 // | Theme switch plugin | 5 5 // +-----------------------------------------------------------------------+ 6 // | Copyright(C) 20 08 Pavel Budka http://pbudka.co.cc|6 // | Copyright(C) 2010 Pavel Budka http://budkovi.ic.cz | 7 7 // +-----------------------------------------------------------------------+ 8 8 // | This program is free software; you can redistribute it and/or modify | … … 23 23 /* 24 24 Plugin Name: Theme Switch 25 Version: 2. 0.a26 Description: Switch to another template/theme from flags on your gallery home page. Edit file main.inc.php for configuration. Based on Language switch25 Version: 2.1. 26 Description: Lets logged or unlogged user change appearance of gallery (via switching to different theme) on gallery home page. Based on Language switch. The switch can show theme names or theme icons, depends on configuration. See details in a file main.inc.php. 27 27 Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=257 28 28 Author: Pavel Budka 29 Author URI: http:// pbudka.co.cc29 Author URI: http://budkovi.ic.cz 30 30 */ 31 31 … … 35 35 36 36 // If you want user to choose from icons then use following handler. 37 // Only themes which have gif icon provided in icons plugin directory will be provided to users. 38 // Gif file name must be the same as theme's name and must be stored in sub directory named according to template's name. 37 // Only themes which have screenshot.png icon provided will be provided to users. 39 38 40 add_event_handler('loc_end_index', array(&$theme_controler, '_flags'), 95 );39 // add_event_handler('loc_end_index', array(&$theme_controler, '_flags'), 95 ); 41 40 42 41 // If you want user to choose using select control then use following handler. 43 42 // All available themes will be provided to users. 44 43 45 // add_event_handler('loc_end_index', array(&$theme_controler, '_select'), 95 ); 44 add_event_handler('loc_end_index', array(&$theme_controler, '_select'), 95 ); 45 46 // this is preparation for future version with configuration 47 // add_event_handler('get_admin_plugin_menu_links', array(&$theme_controler,'_theme_admin')); 46 48 47 49 ?> -
extensions/theme_switch/trunk/theme_switch.inc.php
r7072 r7093 4 4 // | Theme switch plugin | 5 5 // +-----------------------------------------------------------------------+ 6 // | Copyright(C) 20 08 Pavel Budka http://pbudka.co.cc|6 // | Copyright(C) 2010 Pavel Budka http://budkovi.ic.cz | 7 7 // +-----------------------------------------------------------------------+ 8 8 // | This program is free software; you can redistribute it and/or modify | … … 22 22 if (!defined('THEME_SWITCH_PATH')) 23 23 define('THEME_SWITCH_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); 24 24 25 class theme_controler { 25 26 static public function _switch() 26 27 { 27 global $user, $template, $conf, $lang; 28 global $user, $template, $conf; 29 30 load_language('plugin.lang', dirname(__FILE__).'/'); 31 28 32 if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); } 29 $same = $user['t emplate'].'/'.$user['theme'];30 if ( isset( $_GET['theme']) and isset( $_GET['template']) )33 $same = $user['theme']; 34 if ( isset( $_GET['theme']) ) 31 35 { 32 if ( !empty($_GET['theme']) and !empty($_GET['template']) and33 file_exists( PHPWG_ROOT_PATH.'t emplate/'.$_GET['template'].'/theme/'.$_GET['theme']) )36 if ( !empty($_GET['theme']) and 37 file_exists( PHPWG_ROOT_PATH.'themes/'.$_GET['theme']) ) 34 38 { 35 39 if (is_a_guest() or is_generic()) 36 {37 40 setcookie( 'pwg_theme_switch', $_GET['theme'], 38 41 time()+60*60*24*30, cookie_path() ); 39 setcookie( 'pwg_template_switch', $_GET['template'],40 time()+60*60*24*30, cookie_path() );41 }42 42 else 43 43 { 44 44 $query = 'UPDATE '.USER_INFOS_TABLE.' 45 SET t emplate = \''.$_GET['template'].'/'.$_GET['theme'].'\'45 SET theme = \''.$_GET['theme'].'\' 46 46 WHERE user_id = '.$user['id'].' 47 47 ;'; … … 49 49 } 50 50 $user['theme'] = $_GET['theme']; 51 $user['template'] = $_GET['template'];52 51 } 53 52 } … … 56 55 // Guest or generic members will use their cookied $user['template']/$user['theme'] ! 57 56 if ((is_a_guest() or is_generic()) 58 and isset( $_COOKIE['pwg_theme_switch'] ) 59 and isset( $_COOKIE['pwg_template_switch'] ) ) 57 and isset( $_COOKIE['pwg_theme_switch'] ) ) 60 58 { 61 $user['template'] = $_COOKIE['pwg_template_switch'];62 59 $user['theme'] = $_COOKIE['pwg_theme_switch']; 63 60 } 64 } 61 } // function _switch() 65 62 66 63 static public function _flags() … … 69 66 // Gif file name must be the same as theme's name and must be stored in sub directory named according to template's name. 70 67 { 71 global $user, $template, $ lang;68 global $user, $template, $conf, $lang; 72 69 73 70 $available_theme = get_pwg_themes(); 74 71 75 $url_starting = get_query_string_diff(array('t emplate', 'theme'));72 $url_starting = get_query_string_diff(array('theme')); 76 73 77 foreach ( $available_theme as $ code ) {78 $qlc_img = 'plugins/theme_switch/icons/' . $code . '.gif';74 foreach ( $available_theme as $theme_id => $theme ) { 75 $qlc_img = $conf['themes_dir'].'/'.$theme_id.'/'.'screenshot.png'; 79 76 80 if (file_exists( PHPWG_ROOT_PATH.$qlc_img)) {81 list($temp, $theme) = split('/',$code);77 if (file_exists($qlc_img)) { 78 82 79 $qlc_url = str_replace(array('=&','?&'),array('&','?'), 83 add_url_params( $url_starting, array( 't emplate' => $temp, 'theme' => $theme )));80 add_url_params( $url_starting, array( 'theme' => $theme_id ))); 84 81 if (isset($lang['theme'])) 85 $qlc_alt = $lang['theme'].': '.ucwords( $ code );82 $qlc_alt = $lang['theme'].': '.ucwords( $theme ); 86 83 else 87 $qlc_alt = ucwords( $ code );84 $qlc_alt = ucwords( $theme ); 88 85 $qlc_title = $qlc_alt; 89 86 $qlc = array ( … … 92 89 'img' => $qlc_img, 93 90 ); 94 if ( $ code !== $user['template'].'/'.$user['theme'])95 $lsw['flags'][$ code] = $qlc ;91 if ( $theme_id !== $user['theme']) 92 $lsw['flags'][$theme_id] = $qlc ; 96 93 else $lsw['Active'] = $qlc; 97 94 } 98 } 95 } 99 96 100 97 $template->set_filename('theme_flags', dirname(__FILE__) . '/flags.tpl'); … … 107 104 $template->clear_assign('theme_switch'); 108 105 $template->concat( 'PLUGIN_INDEX_ACTIONS', $flags); 109 } 106 } // function _flags() 110 107 111 108 static public function _select() … … 116 113 117 114 $available_theme = get_pwg_themes(); 118 $url_starting = get_query_string_diff(array(' lang'));115 $url_starting = get_query_string_diff(array('theme')); 119 116 $options='<li><span class="property"> 120 117 <label for="template">'.$lang['theme'].'</label> 121 118 </span> 122 119 <select name="template" onchange="javasript:window.location=this.value">'; 123 foreach ( $available_theme as $ code )120 foreach ( $available_theme as $theme_id => $theme ) 124 121 { 125 list($temp, $theme) = split('/',$code);126 122 $qlc_url = str_replace(array('=&','?&'),array('&','?'), 127 add_url_params( $url_starting, array( 't emplate' => $temp, 'theme' => $theme) ));123 add_url_params( $url_starting, array( 'theme' => $theme_id ) )); 128 124 129 if ( $ code == $user['template'].'/'.$user['theme'] )125 if ( $theme_id == $user['theme'] ) 130 126 $tmp='" selected="selected">'; 131 127 else 132 128 $tmp='">'; 133 129 $options=$options.' 134 <option label="'.$ code.'" value="'.$qlc_url.$tmp.$code.'</option>';130 <option label="'.$theme.'" value="'.$qlc_url.$tmp.$theme.'</option>'; 135 131 } 136 132 $options=$options.' 137 133 </select></li>'; 138 134 $template->concat( 'PLUGIN_INDEX_ACTIONS',$options); 139 } 140 } 135 } // function _select() 136 137 static public function _theme_admin($menu) 138 // adds menu options for future configuration 139 { 140 // load_language('plugin.lang', dirname(__FILE__).'/'); 141 array_push($menu, array('NAME' => 'Theme Switch', 142 'URL' => get_admin_plugin_menu_link(THEME_SWITCH_PATH.'admin/admin.php'))); 143 return $menu; 144 } // function _theme_admin() 145 146 } // class theme_controler 147 141 148 /* {html_head} usage function */ 142 149 /* See flags.tpl for example (due no catenation available) */ … … 145 152 { return file_exists( $path . $file); } 146 153 } 154 147 155 ?>
Note: See TracChangeset
for help on using the changeset viewer.