Changeset 5259


Ignore:
Timestamp:
03/22/10 16:03:43 (10 years ago)
Author:
plg
Message:

ture 1514: improvement, impossible to activate a theme is a parent is missing
(a parent includes grand father and his own father, and his own father, and so
on... until the root theme is "default" or has no parent declared)

Location:
trunk/admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/themes.class.php

    r5258 r5259  
    8181          break; 
    8282        } 
     83 
     84        $missing_parent = $this->missing_parent_theme($theme_id); 
     85        if (isset($missing_parent)) 
     86        { 
     87          array_push( 
     88            $errors,  
     89            sprintf( 
     90              l10n('Impossible to activate this theme, the parent theme is missing: %s'), 
     91              $missing_parent 
     92              ) 
     93            ); 
     94           
     95          break; 
     96        } 
    8397         
    8498        $query = " 
     
    167181    } 
    168182    return $errors; 
     183  } 
     184 
     185  function missing_parent_theme($theme_id) 
     186  { 
     187    if (!isset($this->fs_themes[$theme_id]['parent'])) 
     188    { 
     189      return null; 
     190    } 
     191     
     192    $parent = $this->fs_themes[$theme_id]['parent']; 
     193       
     194    if ('default' == $parent) 
     195    { 
     196      return null; 
     197    } 
     198       
     199    if (!isset($this->fs_themes[$parent])) 
     200    { 
     201      return $parent; 
     202    } 
     203 
     204    return $this->missing_parent_theme($parent); 
    169205  } 
    170206 
  • trunk/admin/themes/default/template/themes_installed.tpl

    r5258 r5259  
    3434    <div class="themeShot"><img src="{$theme.screenshot}"></div> 
    3535    <div class="themeActions"> 
     36 
     37  {if $theme.activable} 
    3638      <a href="{$activate_baseurl}{$theme.id}" title="{'Make this theme available to users'|@translate}">{'Activate'|@translate}</a> 
     39  {else} 
     40      <span title="{$theme.activate_tooltip}">{'Activate'|@translate}</span> 
     41  {/if} 
     42 
    3743      | 
     44 
    3845  {if $theme.deletable} 
    3946      <a href="{$delete_baseurl}{$theme.id}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');" title="{'Delete this theme'|@translate}">{'Delete'|@translate}</a> 
     
    4148      <span title="{$theme.delete_tooltip}">{'Delete'|@translate}</span> 
    4249  {/if} 
     50 
    4351    </div> 
    4452     
  • trunk/admin/themes_installed.php

    r5258 r5259  
    9090  else 
    9191  { 
     92    // is the theme "activable" ? 
     93    $fs_theme['activable'] = true; 
     94     
     95    $missing_parent = $themes->missing_parent_theme($theme_id); 
     96    if (isset($missing_parent)) 
     97    { 
     98      $fs_theme['activable'] = false; 
     99       
     100      $fs_theme['activate_tooltip'] = sprintf( 
     101        l10n('Impossible to activate this theme, the parent theme is missing: %s'), 
     102        $missing_parent 
     103        ); 
     104    } 
     105 
     106    // is the theme "deletable" ? 
    92107    $children = $themes->get_children_themes($theme_id); 
     108 
     109    $fs_theme['deletable'] = true; 
    93110     
    94111    if (count($children) > 0) 
     
    100117        implode(', ', $children) 
    101118        ); 
    102     } 
    103     else 
    104     { 
    105       $fs_theme['deletable'] = true; 
    106119    } 
    107120     
Note: See TracChangeset for help on using the changeset viewer.