Ignore:
Timestamp:
10/04/10 20:58:57 (9 years ago)
Author:
pab
Message:

theme switch compatible with piwigo 2.1.* (with CZ, UK localization)

Location:
extensions/theme_switch/trunk
Files:
10 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/theme_switch/trunk/flags.tpl

    r7072 r7093  
    3535</li> 
    3636{html_head} 
    37 {if $themeconf.template=='yoga' and $themeconf.theme=='Sylvia'} 
     37{if $themeconf.name =='Sylvia'} 
    3838<link rel="stylesheet" type="text/css" href="{$ROOT_URL}{$THEME_SWITCH_PATH|@cat:'theme_switch.css'}">  
    3939{else} 
  • extensions/theme_switch/trunk/main.inc.php

    r7072 r7093  
    44// | Theme switch plugin                                                   | 
    55// +-----------------------------------------------------------------------+ 
    6 // | Copyright(C) 2008      Pavel Budka                http://pbudka.co.cc | 
     6// | Copyright(C) 2010      Pavel Budka               http://budkovi.ic.cz | 
    77// +-----------------------------------------------------------------------+ 
    88// | This program is free software; you can redistribute it and/or modify  | 
     
    2323/* 
    2424Plugin Name: Theme Switch 
    25 Version: 2.0.a 
    26 Description: Switch to another template/theme from flags on your gallery home page. Edit file main.inc.php for configuration. Based on Language switch 
     25Version: 2.1. 
     26Description: 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. 
    2727Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=257 
    2828Author: Pavel Budka 
    29 Author URI: http://pbudka.co.cc 
     29Author URI: http://budkovi.ic.cz 
    3030*/ 
    3131 
     
    3535 
    3636// 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. 
    3938 
    40 add_event_handler('loc_end_index', array(&$theme_controler, '_flags'), 95 ); 
     39// add_event_handler('loc_end_index', array(&$theme_controler, '_flags'), 95 ); 
    4140 
    4241// If you want user to choose using select control then use following handler. 
    4342// All available themes will be provided to users.  
    4443 
    45 // add_event_handler('loc_end_index', array(&$theme_controler, '_select'), 95 ); 
     44add_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')); 
    4648 
    4749?> 
  • extensions/theme_switch/trunk/theme_switch.inc.php

    r7072 r7093  
    44// | Theme switch plugin                                                   | 
    55// +-----------------------------------------------------------------------+ 
    6 // | Copyright(C) 2008      Pavel Budka                http://pbudka.co.cc | 
     6// | Copyright(C) 2010      Pavel Budka               http://budkovi.ic.cz | 
    77// +-----------------------------------------------------------------------+ 
    88// | This program is free software; you can redistribute it and/or modify  | 
     
    2222if (!defined('THEME_SWITCH_PATH')) 
    2323define('THEME_SWITCH_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); 
     24 
    2425class theme_controler { 
    2526static public function _switch() 
    2627{ 
    27   global $user, $template, $conf, $lang; 
     28  global $user, $template, $conf; 
     29 
     30  load_language('plugin.lang', dirname(__FILE__).'/'); 
     31 
    2832  if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); } 
    29   $same = $user['template'].'/'.$user['theme']; 
    30   if ( isset( $_GET['theme']) and isset( $_GET['template']) ) 
     33  $same = $user['theme']; 
     34  if ( isset( $_GET['theme']) )  
    3135  { 
    32     if ( !empty($_GET['theme']) and !empty($_GET['template']) and 
    33       file_exists( PHPWG_ROOT_PATH.'template/'.$_GET['template'].'/theme/'.$_GET['theme']) ) 
     36    if ( !empty($_GET['theme']) and 
     37      file_exists( PHPWG_ROOT_PATH.'themes/'.$_GET['theme']) ) 
    3438    { 
    3539      if (is_a_guest() or is_generic()) 
    36       { 
    3740        setcookie( 'pwg_theme_switch', $_GET['theme'], 
    3841          time()+60*60*24*30, cookie_path() ); 
    39         setcookie( 'pwg_template_switch', $_GET['template'], 
    40           time()+60*60*24*30, cookie_path() ); 
    41       } 
    4242      else 
    4343      { 
    4444        $query = 'UPDATE '.USER_INFOS_TABLE.' 
    45         SET template = \''.$_GET['template'].'/'.$_GET['theme'].'\' 
     45        SET theme = \''.$_GET['theme'].'\' 
    4646        WHERE user_id = '.$user['id'].' 
    4747        ;'; 
     
    4949      } 
    5050      $user['theme'] = $_GET['theme']; 
    51       $user['template'] = $_GET['template']; 
    5251    } 
    5352  } 
     
    5655  // Guest or generic members will use their cookied $user['template']/$user['theme'] ! 
    5756  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'] ) ) 
    6058  { 
    61     $user['template'] = $_COOKIE['pwg_template_switch']; 
    6259    $user['theme'] = $_COOKIE['pwg_theme_switch']; 
    6360  } 
    64 } 
     61} // function _switch() 
    6562 
    6663static public function _flags() 
     
    6966// Gif file name must be the same as theme's name and must be stored in sub directory named according to template's name.   
    7067{ 
    71   global $user, $template, $lang; 
     68  global $user, $template, $conf, $lang; 
    7269   
    7370  $available_theme = get_pwg_themes(); 
    7471 
    75   $url_starting = get_query_string_diff(array('template', 'theme')); 
     72  $url_starting = get_query_string_diff(array('theme')); 
    7673 
    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'; 
    7976          
    80     if (file_exists(PHPWG_ROOT_PATH.$qlc_img)) { 
    81       list($temp, $theme) = split('/',$code); 
     77    if (file_exists($qlc_img)) { 
     78       
    8279      $qlc_url = str_replace(array('=&amp;','?&amp;'),array('&amp;','?'), 
    83                  add_url_params( $url_starting, array( 'template' => $temp, 'theme' => $theme  ) )); 
     80                 add_url_params( $url_starting, array( 'theme' => $theme_id ))); 
    8481      if (isset($lang['theme'])) 
    85         $qlc_alt = $lang['theme'].': '.ucwords( $code ); 
     82        $qlc_alt = $lang['theme'].': '.ucwords( $theme ); 
    8683      else 
    87         $qlc_alt = ucwords( $code ); 
     84        $qlc_alt = ucwords( $theme ); 
    8885      $qlc_title =  $qlc_alt; 
    8986      $qlc = array (  
     
    9289        'img' => $qlc_img, 
    9390        ); 
    94       if ( $code !== $user['template'].'/'.$user['theme']) 
    95         $lsw['flags'][$code] = $qlc ; 
     91      if ( $theme_id !== $user['theme']) 
     92        $lsw['flags'][$theme_id] = $qlc ; 
    9693      else $lsw['Active'] = $qlc; 
    9794      } 
    98   } 
     95  }  
    9996     
    10097  $template->set_filename('theme_flags', dirname(__FILE__) . '/flags.tpl'); 
     
    107104  $template->clear_assign('theme_switch'); 
    108105  $template->concat( 'PLUGIN_INDEX_ACTIONS', $flags); 
    109 } 
     106} // function _flags() 
    110107 
    111108static public function _select() 
     
    116113   
    117114  $available_theme = get_pwg_themes(); 
    118   $url_starting = get_query_string_diff(array('lang')); 
     115  $url_starting = get_query_string_diff(array('theme')); 
    119116  $options='<li><span class="property"> 
    120117   <label for="template">'.$lang['theme'].'</label> 
    121118  </span> 
    122119  <select name="template" onchange="javasript:window.location=this.value">'; 
    123   foreach ( $available_theme as $code ) 
     120  foreach ( $available_theme as $theme_id => $theme ) 
    124121  { 
    125     list($temp, $theme) = split('/',$code); 
    126122    $qlc_url = str_replace(array('=&amp;','?&amp;'),array('&amp;','?'), 
    127       add_url_params( $url_starting, array( 'template' => $temp, 'theme' => $theme  ) )); 
     123      add_url_params( $url_starting, array( 'theme' => $theme_id  ) )); 
    128124     
    129     if ( $code == $user['template'].'/'.$user['theme'] ) 
     125    if ( $theme_id == $user['theme'] ) 
    130126      $tmp='" selected="selected">'; 
    131127    else 
    132128      $tmp='">'; 
    133129    $options=$options.' 
    134     <option label="'.$code.'" value="'.$qlc_url.$tmp.$code.'</option>'; 
     130    <option label="'.$theme.'" value="'.$qlc_url.$tmp.$theme.'</option>'; 
    135131  } 
    136132  $options=$options.' 
    137133  </select></li>'; 
    138134  $template->concat( 'PLUGIN_INDEX_ACTIONS',$options); 
    139 } 
    140 } 
     135} //  function _select()  
     136 
     137static 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 
    141148  /* {html_head} usage function */ 
    142149  /* See flags.tpl for example (due no catenation available) */ 
     
    145152    { return file_exists( $path . $file); } 
    146153} 
     154 
    147155?> 
Note: See TracChangeset for help on using the changeset viewer.