Changeset 5153


Ignore:
Timestamp:
Mar 17, 2010, 1:48:38 AM (14 years ago)
Author:
plg
Message:

feature 1514: new screen to manage installed themes; activate, deactivate,
delete, set as default.

plugins.class.php was merged back to a state it doesn't manage themes at all.
themes.class.php was created instead, from a duplication of plugins.class.php
and strongly modified then.

feature 1507: the display of available themes is now much more "graphic".

Location:
trunk
Files:
9 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin.php

    r5143 r5153  
    124124    'U_CONFIG_EXTENTS'=> $link_start.'extend_for_templates',
    125125    'U_CONFIG_MENUBAR'=> $link_start.'menubar',
    126     'U_CONFIG_THEMES'=> $link_start.'themes_new',
     126    'U_CONFIG_THEMES'=> $link_start.'themes_installed',
    127127    'U_CATEGORIES'=> $link_start.'cat_list',
    128128    'U_MOVE'=> $link_start.'cat_move',
  • trunk/admin/include/plugins.class.php

    r5143 r5153  
    269269   * Retrieve PEM server datas to $server_plugins
    270270   */
    271   function get_server_plugins($new=false, $ext_type='plugin')
     271  function get_server_plugins($new=false)
    272272  {
    273273    global $user;
    274 
    275     $pem_category_id = 12;
    276     if ('theme' == $ext_type)
    277     {
    278       $pem_category_id = 10;
    279     }
    280274
    281275    // Retrieve PEM versions
    282276    $version = PHPWG_VERSION;
    283277    $versions_to_check = array();
    284     $url = PEM_URL . '/api/get_version_list.php?category_id='.$pem_category_id.'&format=php';
     278    $url = PEM_URL . '/api/get_version_list.php?category_id=12&format=php';
    285279    if (fetchRemote($url, $result) and $pem_versions = @unserialize($result))
    286280    {
     
    314308
    315309    // Retrieve PEM plugins infos
    316     $url = PEM_URL . '/api/get_revision_list.php?category_id='.$pem_category_id.'&format=php&last_revision_only=true';
     310    $url = PEM_URL . '/api/get_revision_list.php?category_id=12&format=php&last_revision_only=true';
    317311    $url .= '&version=' . implode(',', $versions_to_check);
    318312    $url .= '&lang=' . substr($user['language'], 0, 2);
     
    371365    * @param string - plugin id or extension id
    372366   */
    373   function extract_plugin_files($action, $revision, $dest, $ext_type = 'plugin')
    374   {
    375     if ('plugin' == $ext_type)
    376     {
    377       $install_basedir = PHPWG_PLUGINS_PATH;
    378       $main_filename = 'main.inc.php';
    379     }
    380     elseif ('theme' == $ext_type)
    381     {
    382       $install_basedir = PHPWG_ROOT_PATH.'themes/';
    383       $main_filename = 'themeconf.inc.php';
    384     }
    385     else
    386     {
    387       fatal_error('unknown extension type "'.$ext_type.'"');
    388     }
    389    
    390     if ($archive = tempnam( $install_basedir, 'zip'))
     367  function extract_plugin_files($action, $revision, $dest)
     368  {
     369    if ($archive = tempnam( PHPWG_PLUGINS_PATH, 'zip'))
    391370    {
    392371      $url = PEM_URL . '/download.php?rid=' . $revision;
     
    403382          {
    404383            // we search main.inc.php in archive
    405             if (basename($file['filename']) == $main_filename
     384            if (basename($file['filename']) == 'main.inc.php'
    406385              and (!isset($main_filepath)
    407386              or strlen($file['filename']) < strlen($main_filepath)))
     
    415394            if ($action == 'upgrade')
    416395            {
    417               $extract_path = $install_basedir . $dest;
     396              $extract_path = PHPWG_PLUGINS_PATH . $dest;
    418397            }
    419398            else
    420399            {
    421               $extract_path = $install_basedir
     400              $extract_path = PHPWG_PLUGINS_PATH
    422401                  . ($root == '.' ? 'extension_' . $dest : basename($root));
    423402            }
  • trunk/admin/themes/default/default-layout.css

    r5145 r5153  
    738738}
    739739
    740 .themeBox {float:left; text-align:center; height:170px; background-color:#eee; margin:5px; -moz-border-radius:5px;}
     740.themeBox {float:left; text-align:center; height:180px; background-color:#eee; margin:5px; -moz-border-radius:5px;}
    741741.themeBox IMG {border:1px solid white; margin:0 15px;}
    742742.themeName {font-size:1.1em; margin:5px 0;}
    743 .themeActions {margin:5px 0;}
    744 .themeActions A {display:block;}
     743.themeActions {margin:5px 0; font-size:12px;}
     744.themeActions A {}
     745
     746#themesContent .themeBox IMG {width:150px; height:120px;}
     747#themesContent H3 {font-size:16px; text-align:left; border-bottom:1px solid #444; letter-spacing:1px; margin:5px;}
     748
     749.themeBoxes {min-height:300px;}
  • trunk/admin/themes/default/template/footer.tpl

    r5123 r5153  
    4646<script type='text/javascript'>
    4747  $(function() {
    48     $('#pwgHead A, #footer A').tipTip({
     48    $('#pwgHead A, #footer A, .themeActions A').tipTip({
    4949        'delay' : 0,
    5050        'fadeIn' : 200,
  • trunk/admin/themes/default/template/themes_new.tpl

    r5145 r5153  
    11<div class="titrePage">
    2   <h2>{'Install New Theme'|@translate}</h2>
     2  <h2>{'Add New Theme'|@translate}</h2>
    33</div>
    44
    55{if isset($themes)}
    6 <div id="themesBox">
     6<div id="themeBoxes">
    77{foreach from=$new_themes item=theme name=themes_loop}
    88  <div class="themeBox">
    99    <div class="themeName">{$theme.name}</div>
    10     <div class="themeShot"><img src="{$theme.src}"></div>
    11     <div class="themeActions"><a href="{$theme.install_url}">Install</a></div>
     10    <div class="themeShot"><img src="{$theme.screenshot}"></div>
     11    <div class="themeActions"><a href="{$theme.install_url}">{'Install'|@translate}</a></div>
    1212  </div>
    1313{/foreach}
    14 </div> <!-- themesBox -->
     14</div> <!-- themeBoxes -->
    1515{/if}
  • trunk/admin/themes/roma/theme.css

    r5145 r5153  
    223223.themeName {color:white;}
    224224.themeActions A {border-bottom:none;}
     225
     226.themeDefault {background-color:#555;}
  • trunk/admin/themes_new.php

    r5143 r5153  
    33// | Piwigo - a PHP based picture gallery                                  |
    44// +-----------------------------------------------------------------------+
    5 // | Copyright(C) 2008-2009 Piwigo Team                  http://piwigo.org |
     5// | Copyright(C) 2008-2010 Piwigo Team                  http://piwigo.org |
    66// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
    77// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
     
    2727}
    2828
    29 include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php');
     29include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php');
    3030
    3131$base_url = get_root_url().'admin.php?page='.$page['page'];
    3232
    33 $themes = new plugins();
     33$themes = new themes();
     34$themes->set_tabsheet('themes_new');
    3435
    3536// +-----------------------------------------------------------------------+
     
    5556if (isset($_GET['revision']) and isset($_GET['extension']) and !is_adviser())
    5657{
    57   $install_status = $themes->extract_plugin_files(
     58  $install_status = $themes->extract_theme_files(
    5859    'install',
    5960    $_GET['revision'],
    60     $_GET['extension'],
    61     'theme'
     61    $_GET['extension']
    6262    );
    6363 
     
    106106$template->set_filenames(array('themes' => 'themes_new.tpl'));
    107107
    108 if ($themes->get_server_plugins(true, 'theme'))
     108if ($themes->get_server_themes(true)) // only new themes
    109109{
    110   foreach($themes->server_plugins as $theme)
     110  foreach($themes->server_themes as $theme)
    111111  {
    112112    $url_auto_install = htmlentities($base_url)
     
    119119      array(
    120120        'name' => $theme['extension_name'],
    121         'src' => PEM_URL.'/upload/extension-'.$theme['extension_id'].'/thumbnail.jpg',
     121        'screenshot' => PEM_URL.'/upload/extension-'.$theme['extension_id'].'/thumbnail.jpg',
    122122        'install_url' => $url_auto_install,
    123123        )
  • trunk/include/config_default.inc.php

    r5138 r5153  
    769769// where should the user be guided when there is no photo in his gallery yet?
    770770$conf['no_photo_yet_url'] = 'admin.php?page=photos_add';
     771
     772// directory with themes inside
     773$conf['themes_dir'] = PHPWG_ROOT_PATH.'themes';
    771774?>
  • trunk/include/constants.php

    r5014 r5153  
    2525define('PHPWG_VERSION', 'Colibri');
    2626define('PHPWG_DEFAULT_LANGUAGE', 'en_UK');
    27 define('PHPWG_DEFAULT_TEMPLATE', 'yoga/Sylvia');
     27define('PHPWG_DEFAULT_TEMPLATE', 'Sylvia');
     28
     29define('PHPWG_THEMES_PATH', $conf['themes_dir'].'/');
    2830
    2931// Required versions
     
    98100if (!defined('OLD_PERMALINKS_TABLE'))
    99101  define('OLD_PERMALINKS_TABLE', $prefixeTable.'old_permalinks');
     102if (!defined('THEMES_TABLE'))
     103  define('THEMES_TABLE', $prefixeTable.'themes');
    100104
    101105?>
  • trunk/include/functions.inc.php

    r5138 r5153  
    714714function get_pwg_themes()
    715715{
    716   global $conf;
    717716  $themes = array();
    718717
    719   $template_dir = PHPWG_ROOT_PATH.'themes';
    720 
    721   foreach (get_dirs($template_dir) as $theme)
    722   {
    723     if ( $theme != 'default' )
    724           {
    725       array_push($themes, $theme);
    726           }
     718  $query = '
     719SELECT
     720    id,
     721    name
     722  FROM '.THEMES_TABLE.'
     723  ORDER BY name ASC
     724;';
     725  $result = pwg_query($query);
     726  while ($row = pwg_db_fetch_assoc($result))
     727  {
     728    $themes[ $row['id'] ] = $row['name'];
    727729  }
    728730
    729731  // plugins want remove some themes based on user status maybe?
    730732  $themes = trigger_event('get_pwg_themes', $themes);
     733 
    731734  return $themes;
    732735}
  • trunk/install/piwigo_structure-mysql.sql

    r5123 r5153  
    294294
    295295--
     296-- Table structure for table `piwigo_themes`
     297--
     298
     299DROP TABLE IF EXISTS `piwigo_themes`;
     300CREATE TABLE `piwigo_themes` (
     301  `id` varchar(64) NOT NULL default '',
     302  `version` varchar(64) NOT NULL default '0',
     303  `name` varchar(64) default NULL,
     304  PRIMARY KEY  (`id`)
     305) TYPE=MyISAM;
     306
     307--
    296308-- Table structure for table `piwigo_upgrade`
    297309--
  • trunk/profile.php

    r5123 r5153  
    258258      ));
    259259
    260   foreach (get_pwg_themes() as $pwg_theme)
    261   {
    262     if (isset($_POST['submit']) or $userdata['theme'] == $pwg_theme)
    263     {
    264       $template->assign('template_selection', $pwg_theme);
    265     }
    266     $template_options[$pwg_theme] = $pwg_theme;
    267   }
    268   $template->assign('template_options', $template_options);
     260  $template->assign('template_selection', $userdata['theme']);
     261  $template->assign('template_options', get_pwg_themes());
    269262
    270263  foreach (get_languages() as $language_code => $language_name)
Note: See TracChangeset for help on using the changeset viewer.