Changeset 16241


Ignore:
Timestamp:
Jul 1, 2012, 2:29:15 AM (12 years ago)
Author:
mistic100
Message:

choose between selectbox or thumbnails grid with a local config option, thumbnail grid use 2.4 drop-downs menus, only an icon appears on toolbar

Location:
extensions/theme_switch/trunk
Files:
9 added
20 deleted
18 edited

Legend:

Unmodified
Added
Removed
  • extensions/theme_switch/trunk/language/de_DE/description.txt

    r7112 r16241  
    1 Ermöglicht angemeldete oder nicht angemeldete Benutzer die Veränderung des Galerie-Layouts (durch die Umstellung auf ein anderes Thema) auf der Galerie-Startseite. Basierend auf "Language switch". Der Schalter kann Themanamen oder Themasymbole zeigen, dies hängt von der Konfiguration ab. Details finden Sie in der Datei main.inc.php.
     1Ermöglicht angemeldete oder nicht angemeldete Benutzer die Veränderung des Galerie-Layouts (durch die Umstellung auf ein anderes Thema) auf der Galerie-Startseite. Basierend auf "Language switch". Der Schalter kann Themanamen oder Themasymbole zeigen, dies hängt von der Konfiguration ab.
  • extensions/theme_switch/trunk/language/en_UK/description.txt

    r7093 r16241  
    1 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.
     1Lets users change the theme of the gallery via menu on home page. The switch can show theme names or theme icons, depends on configuration.
  • extensions/theme_switch/trunk/language/es_ES/description.txt

    r7161 r16241  
    1 Permite cambiar el aspecto visual de la galería en la
    2 página principal, tanto a usuarios identificados como anónimos, mediante la
    3 elección de otro ‘tema’. El cambio aplicará literales o iconos del tema,
    4 dependiendo de la configuración. Vea los detalles en main.inc.php
     1Permite cambiar el aspecto visual de la galería en la página principal, tanto a usuarios identificados como anónimos, mediante la elección de otro ‘tema’. El cambio aplicará literales o iconos del tema, dependiendo de la configuración.
  • extensions/theme_switch/trunk/language/fr_FR/description.txt

    r7101 r16241  
    1 Permet de Changer de thèmes sur la galerie facilement (invité et utilisateurs) à partir d'icônes ou d'une liste présente sur la page d'accueil.
    2 Voir les détails dans un fichier main.inc.php.
     1Permet de Changer de thèmes sur la galerie facilement à partir d'icônes ou d'une liste présente sur la page d'accueil.
  • extensions/theme_switch/trunk/language/hu_HU/description.txt

    r13388 r16241  
    1 Lehetővé teszi a felhasználóknak és vendégeknek, hogy megváltoztassák a galéria megjelenését. Mutathatja a témák ikonját és/vagy nevét, a beállítástól függően. A részletek a main.inc.php fájlban találhatók.
     1Lehetővé teszi a felhasználóknak és vendégeknek, hogy megváltoztassák a galéria megjelenését. Mutathatja a témák ikonját és/vagy nevét, a beállítástól függően.
  • extensions/theme_switch/trunk/language/it_IT/description.txt

    r7112 r16241  
    1 Consente agli utenti registrati o non registrati a modificare l'aspetto della galleria (attraverso lo scambio di diversi temi) sul sito della galleria. Il Plug-in è basato su "Language switch". Il switch può mostrare i nomi dei temi o le icone dei temi, a seconda dalla configurazione. Per ulteriori dettagli controllate il file main.inc.php.
     1Consente agli utenti registrati o non registrati a modificare l'aspetto della galleria (attraverso lo scambio di diversi temi) sul sito della galleria. Il Plug-in è basato su "Language switch". Il switch può mostrare i nomi dei temi o le icone dei temi, a seconda dalla configurazione.
  • extensions/theme_switch/trunk/language/lv_LV/description.txt

    r7938 r16241  
    1 Dod iespēju ielogotiem un neielogotiem lietotājiem mainīt galerijas izskatu (pārslēdzoties uz citu tēmu) galerijas mājas lapā. Bazēts uz Valodu pārslēgšdanu. Atkarībā no konfigurācijas, slēdzis rāda tēmu nosaukumus vai tēmu ikonas. Detaļas failā main.inc.php.
     1Dod iespēju ielogotiem un neielogotiem lietotājiem mainīt galerijas izskatu (pārslēdzoties uz citu tēmu) galerijas mājas lapā. Bazēts uz Valodu pārslēgšdanu. Atkarībā no konfigurācijas, slēdzis rāda tēmu nosaukumus vai tēmu ikonas.
  • extensions/theme_switch/trunk/language/nb_NO/description.txt

    r9184 r16241  
    1 Lar loggede eller uloggede brukere forandre utseende på galleriet (ved å bytte til en annet tema) på galleriets hjemmeside. Basert på språk bryteren. Bryteren kan vise temaets navn eller tema ikoner, avhengig av konfigurasjonen. Se detaljer i filen main.inc.php.
     1Lar loggede eller uloggede brukere forandre utseende på galleriet (ved å bytte til en annet tema) på galleriets hjemmeside. Basert på språk bryteren. Bryteren kan vise temaets navn eller tema ikoner, avhengig av konfigurasjonen.
  • extensions/theme_switch/trunk/language/nl_NL/description.txt

    r15162 r16241  
    1 Laat al dan niet ingelogde gebruiker, het uiterlijk van de gallery aanpassen(door te schakelen naar een ander theme) op de gallery home pagina. Gebaseerd op de taal switch. De keuze kan als thema namen of iconen worden weergegeven, afhankelijk van de configuratie. Zie de details in main.inc.php.
     1Laat al dan niet ingelogde gebruiker, het uiterlijk van de gallery aanpassen(door te schakelen naar een ander theme) op de gallery home pagina. Gebaseerd op de taal switch. De keuze kan als thema namen of iconen worden weergegeven, afhankelijk van de configuratie.
  • extensions/theme_switch/trunk/language/pl_PL/description.txt

    r10989 r16241  
    1 Umożliwia zalogowanym i niezalogowanym użytkownikom zmieniać wygląd strony głównej galerii (poprzez przełączanie różnych skórek). Bazuje na przełączniku języków. W zależności od konfiguracji przełącznik może mieć postać nazw skórek lub ikon skórek. Więcej szczegółów w pliku main.inc.php
     1Umożliwia zalogowanym i niezalogowanym użytkownikom zmieniać wygląd strony głównej galerii (poprzez przełączanie różnych skórek). Bazuje na przełączniku języków. W zależności od konfiguracji przełącznik może mieć postać nazw skórek lub ikon skórek.
  • extensions/theme_switch/trunk/language/pt_PT/description.txt

    r14410 r16241  
    1 Permite que um utilizador registado ou não altere a aparência da galeria (através de acionamento de um tema diferente) na página principal da galeria. Baseado na alteração de idioma. Este accionamento pode mostrar nomes das matrizes(templatess) ou ícones das matrizes, depende da configuração. Veja os detalhes no arquivo main.inc.php.
     1Permite que um utilizador registado ou não altere a aparência da galeria (através de acionamento de um tema diferente) na página principal da galeria. Baseado na alteração de idioma. Este accionamento pode mostrar nomes das matrizes(templatess) ou ícones das matrizes, depende da configuração.
  • extensions/theme_switch/trunk/language/ru_RU/description.txt

    r8098 r16241  
    1 Позволяет залогиненым и незалогиненым пользователям изменять внешний вид галереи (переключать темы) находясь на главной странице. Основан на переключении языка. Переключатель может показывать название темы или иконку темы в зависимости от конфигурации. Подробности смотрите в файле main.inc.php.
     1Позволяет залогиненым и незалогиненым пользователям изменять внешний вид галереи (переключать темы) находясь на главной странице. Основан на переключении языка. Переключатель может показывать название темы или иконку темы в зависимости от конфигурации.
  • extensions/theme_switch/trunk/language/sk_SK/description.txt

    r7143 r16241  
    1 Nechá zaznamenané alebo nezaznamenané používateľské zmeny vzhľadu galérie (cez prepínač na rôzne témy) na úvodnej stránke galérie. Na základe Prepínača jazyka. Prepínač môže zobraziť názvy tém alebo ikony tém, záleží na konfigurácii. Pozrite detaily v súbore main.inc.php.
     1Nechá zaznamenané alebo nezaznamenané používateľské zmeny vzhľadu galérie (cez prepínač na rôzne témy) na úvodnej stránke galérie. Na základe Prepínača jazyka. Prepínač môže zobraziť názvy tém alebo ikony tém, záleží na konfigurácii.
  • extensions/theme_switch/trunk/main.inc.php

    r7173 r16241  
    44// | Theme switch plugin                                                   |
    55// +-----------------------------------------------------------------------+
     6// | Copyright(C) 2012      Piwigo Team                  http://piwigo.org |
    67// | Copyright(C) 2010      Pavel Budka               http://budkovi.ic.cz |
    78// +-----------------------------------------------------------------------+
     
    2324/*
    2425Plugin Name: Theme Switch
    25 Version: 2.1.a
    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.
     26Version: auto
     27Description: Lets users change the theme of the gallery via menu on home page. The switch can show theme names or theme icons, depends on configuration.
    2728Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=257
    28 Author: Pavel Budka
     29Author: Pavel Budka & Mistic
    2930Author URI: http://budkovi.ic.cz
    3031*/
    3132
    32 include_once(PHPWG_PLUGINS_PATH.'theme_switch/theme_switch.inc.php');
    33 $theme_controler = new theme_controler();
    34 add_event_handler('loading_lang', array(&$theme_controler, '_switch'), 5 );
     33// in order to use select box instead of thumbnail view, add
     34// $conf['theme_switch_mode'] = 'select';
     35// in your local configuration
    3536
    36 // If you want user to choose from icons then use following handler.
    37 // Only themes which have screenshot.png icon provided will be provided to users.
     37if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    3838
    39 add_event_handler('loc_end_index', array(&$theme_controler, '_flags'), 85 );
     39define('THEME_SWITCH_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
    4040
    41 // If you want user to choose using select control then use following handler.
    42 // All available themes will be provided to users.
     41include_once(THEME_SWITCH_PATH.'theme_switch.inc.php');
    4342
    44 add_event_handler('loc_end_index', array(&$theme_controler, '_select'), 15 );
    45 
    46 // this is preparation for future version with configuration
    47 // add_event_handler('get_admin_plugin_menu_links', array(&$theme_controler,'_theme_admin'));
     43add_event_handler('user_init', 'theme_controler_switch');
     44add_event_handler('loc_end_index', 'theme_controler_init');
    4845
    4946?>
  • extensions/theme_switch/trunk/theme_switch.css

    r7171 r16241  
    1 @import "theme_switch-default.css";
    2 
    3 .theme_flag-pan { border:1px solid; background-color: #111; }
    4 .theme_menuf .theme_flags {border-color: #000 !important; }
    5 
    6 .theme_flag-pan {       border-radius: 8px; } /* round corners with CSS3 compliant browsers */
    7 .theme_flag-pan { -moz-border-radius:8px; }
    8 .theme_flag-pan { -webkit-border-radius: 8px; }
     1.theme-thumb {
     2  min-width:80px;
     3  max-width:120px;
     4  min-height:80px;
     5  max-height:120px;
     6  margin:2px;
     7}
  • extensions/theme_switch/trunk/theme_switch.inc.php

    r7171 r16241  
    44// | Theme switch plugin                                                   |
    55// +-----------------------------------------------------------------------+
     6// | Copyright(C) 2012      Piwigo Team                  http://piwigo.org |
    67// | Copyright(C) 2010      Pavel Budka               http://budkovi.ic.cz |
    78// +-----------------------------------------------------------------------+
     
    2021// | USA.                                                                  |
    2122// +-----------------------------------------------------------------------+
    22 if (!defined('THEME_SWITCH_PATH'))
    23 define('THEME_SWITCH_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
    2423
    25 include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php');
     24if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    2625
    27 class theme_controler {
    28 static public function _switch()
     26function theme_controler_switch()
    2927{
    3028  global $user, $template, $conf;
    31 
    32   load_language('plugin.lang', dirname(__FILE__).'/');
    33 
    34   if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
     29 
    3530  $same = $user['theme'];
    3631  if ( isset( $_GET['theme']) )
    3732  {
    38     if ( !empty($_GET['theme']) and
    39       file_exists( PHPWG_ROOT_PATH.'themes/'.$_GET['theme']) )
     33    if ( !empty($_GET['theme']) and file_exists(PHPWG_THEMES_PATH.$_GET['theme']) )
    4034    {
    41       if (is_a_guest() or is_generic())
    42         setcookie( 'pwg_theme_switch', $_GET['theme'],
    43           time()+60*60*24*30, cookie_path() );
     35      if ( is_a_guest() or is_generic() )
     36      {
     37        pwg_set_session_var('theme_switch', $_GET['theme']);
     38      }
    4439      else
    4540      {
    46         $query = 'UPDATE '.USER_INFOS_TABLE.'
    47         SET theme = \''.$_GET['theme'].'\'
    48         WHERE user_id = '.$user['id'].'
    49         ;';
     41        $query = '
     42UPDATE '.USER_INFOS_TABLE.'
     43  SET theme = "'.$_GET['theme'].'"
     44  WHERE user_id = '.$user['id'].'
     45;';
    5046        pwg_query($query);
    5147      }
     
    5349    }
    5450  }
    55   else
    56   // Users have $user['template']/$user['theme']
    57   // Guest or generic members will use their cookied $user['template']/$user['theme'] !
    58   if ((is_a_guest() or is_generic())
    59     and isset( $_COOKIE['pwg_theme_switch'] ) )
     51  else if ( (is_a_guest() or is_generic()) and pwg_get_session_var('theme_switch')!=null )
    6052  {
    61     $user['theme'] = $_COOKIE['pwg_theme_switch'];
     53    $user['theme'] = pwg_get_session_var('theme_switch');
    6254  }
    63 } // function _switch()
    64 
    65 static public function _installed_themes()
    66 // id, name, screenshot 
    67 {
    68 $themes = new themes();
    69 $themes->sort_fs_themes();
    70 $db_themes = $themes->get_db_themes();
    71 $db_theme_ids = array();
    72 foreach ($db_themes as $db_theme)
    73 {
    74   array_push($db_theme_ids, $db_theme['id']);
    7555}
    7656
    77 $active_themes = array();
    78 
    79 
    80 foreach ($themes->fs_themes as $theme_id => $fs_theme)
     57function theme_controler_init()
    8158{
    82   if (in_array($theme_id, $db_theme_ids))
    83       array_push($active_themes, $fs_theme);
     59  global $conf;
     60 
     61  if ( isset($conf['theme_switch_mode']) and $conf['theme_switch_mode'] == 'select' )
     62  {
     63    theme_controler_select();
     64  }
     65  else
     66  {
     67    theme_controler_thumb();
     68  }
    8469}
    8570
    86 return $active_themes;
    87 } // function  _installed_themes()
     71function theme_controler_thumb()
     72{
     73  global $user, $template, $conf;
     74 
     75  foreach (get_pwg_themes() as $id => $name)
     76  {
     77    $img =  PHPWG_THEMES_PATH.$id.'/screenshot.png';
     78         
     79    if (file_exists($img))
     80    {
     81      $theme = array(
     82        'id' => $id,
     83        'name' => $name,
     84        'url' => add_url_params( duplicate_index_url(), array('theme'=>$id) ),
     85        'img' => $img,
     86        );
     87       
     88      if ($id==$user['theme'])
     89      {
     90        $template->assign('theme_switch_active', $theme);
     91      }
     92     
     93      $template->append('theme_switch', $theme);
     94    }
     95  }
     96 
     97  $template->assign('THEME_SWITCH_PATH', THEME_SWITCH_PATH);
     98 
     99  $template->set_filename('theme_thumb', dirname(__FILE__) . '/thumb.tpl');
     100  $template->concat('PLUGIN_INDEX_ACTIONS', $template->parse('theme_thumb', true));
     101 
     102  $template->clear_assign('theme_thumb');
     103}
    88104
     105function theme_controler_select()
     106{
     107  global $user, $template;
    89108
    90 static public function _flags()
    91 // Lets user choose from icons
    92 // Only themes which have gif icon provided in icons plugin directory will be provided to users.
    93 // Gif file name must be the same as theme's name and must be stored in sub directory named according to template's name. 
    94 {
    95   global $user, $template, $conf, $lang;
     109  foreach (get_pwg_themes() as $id => $name)
     110  {     
     111    $template->append('theme_switch', array(
     112      'id' => $id,
     113      'name' => $name,
     114      'url' => add_url_params( duplicate_index_url(), array('theme'=>$id) ),
     115      'select' => ($id==$user['theme']) ? 'selected="selected"' :  null,
     116      ));
     117  }
    96118 
    97   $available_theme = get_pwg_themes();
    98 
    99   $url_starting = get_query_string_diff(array('theme'));
     119  $template->set_filename('theme_select', dirname(__FILE__) . '/select.tpl');
     120  $template->concat('PLUGIN_INDEX_ACTIONS', $template->parse('theme_select', true));
    100121 
    101   foreach ( theme_controler::_installed_themes() as $theme ) {
    102     $qlc_img =  $theme['screenshot']; // $conf['themes_dir'].'/'.$theme_id.'/'.'screenshot.png';
    103          
    104     if (file_exists($qlc_img)) {
    105      
    106       $qlc_url = str_replace(array('=&','?&'),array('&','?'),
    107                  add_url_params( $url_starting, array( 'theme' => $theme['id'] )));
    108       if (isset($lang['theme']))
    109         $qlc_alt = $lang['theme'].' '.ucwords( $theme['name'] );
    110       else
    111         $qlc_alt = ucwords( $theme['name'] );
    112       $qlc_title =  $qlc_alt;
    113       $qlc = array (
    114         'url' => $qlc_url,
    115         'alt' => $qlc_alt,
    116         'img' => $qlc_img,
    117         );
    118       if ( $theme['id'] !== $user['theme'])
    119         $lsw['flags'][$theme['id']] = $qlc ;
    120       else $lsw['Active'] = $qlc;
    121       }
    122   }
    123    
    124   $template->set_filename('theme_flags', dirname(__FILE__) . '/flags.tpl');
    125   $lsw['side'] = ceil(sqrt(count($available_theme)));
    126   $template->assign(array(
    127     'theme_switch'=> $lsw,
    128     'THEME_SWITCH_PATH' => THEME_SWITCH_PATH,
    129   ));
    130   $flags = $template->parse('theme_flags',true);
    131   $template->clear_assign('theme_switch');
    132   $template->concat( 'PLUGIN_INDEX_ACTIONS', $flags);
    133 } // function _flags()
    134 
    135 
    136 static public function _select()
    137 // Lets user choose using select control
    138 // All available themes will be provided to users.
    139 {
    140   global $user, $template, $lang;
    141  
    142   $available_theme = get_pwg_themes();
    143   $url_starting = get_query_string_diff(array('theme'));
    144   $options='<li class="selector">'
    145    .$lang['theme'].
    146     '&nbsp;<select onchange="javasript:window.location=this.value">';
    147   foreach ( theme_controler::_installed_themes() as $theme )
    148   {
    149     $qlc_url = str_replace(array('=&amp;','?&amp;'),array('&amp;','?'),
    150       add_url_params( $url_starting, array( 'theme' => $theme['id']  ) ));
    151    
    152     if ( $theme['id'] == $user['theme'] )
    153       $tmp='" selected="selected">';
    154     else
    155       $tmp='">';
    156     $options=$options.'
    157     <option label="'.$theme['name'].'" value="'.$qlc_url.$tmp.$theme['name'].'</option>';
    158   }
    159   $options=$options.'
    160   </select></li>';
    161   $template->concat( 'PLUGIN_INDEX_ACTIONS',$options);
    162 } //  function _select()
    163 
    164 static public function _theme_admin($menu)
    165 // adds menu options for future configuration
    166 {
    167 //  load_language('plugin.lang', dirname(__FILE__).'/');
    168   array_push($menu, array('NAME' => 'Theme Switch',
    169     'URL' => get_admin_plugin_menu_link(THEME_SWITCH_PATH.'admin/admin.php')));
    170   return $menu;
    171 } // function _theme_admin()
    172 
    173 } // class theme_controler
    174 
    175   /* {html_head} usage function */
    176   /* See flags.tpl for example (due no catenation available) */
    177 if (!function_exists('Componant_exists')) {
    178   function Componant_exists($path, $file)
    179     { return file_exists( $path . $file); }
     122  $template->clear_assign('theme_select');
    180123}
    181124
Note: See TracChangeset for help on using the changeset viewer.