Changeset 5258


Ignore:
Timestamp:
Mar 22, 2010, 3:11:10 PM (14 years ago)
Author:
plg
Message:

feature 1514: improvement, impossible to delete a theme that is required
by another installed theme.

Location:
trunk/admin
Files:
4 edited

Legend:

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

    r5196 r5258  
    141141          break;
    142142        }
     143
     144        $children = $this->get_children_themes($theme_id);
     145        if (count($children) > 0)
     146        {
     147          array_push(
     148            $errors,
     149            sprintf(
     150              l10n('Impossible to delete this theme. Other themes depends on it: %s'),
     151              implode(', ', $children)
     152              )
     153            );
     154          break;
     155        }
    143156       
    144157        if (!$this->deltree(PHPWG_THEMES_PATH.$theme_id))
     
    155168    return $errors;
    156169  }
     170
     171  function get_children_themes($theme_id)
     172  {
     173    $children = array();
     174   
     175    foreach ($this->fs_themes as $test_child)
     176    {
     177      if (isset($test_child['parent']) and $test_child['parent'] == $theme_id)
     178      {
     179        array_push($children, $test_child['name']);
     180      }
     181    }
     182
     183    return $children;
     184  }
    157185
    158186  function set_default_theme($theme_id)
     
    267295            list( , $extension) = explode('extension_view.php?eid=', $theme['uri']);
    268296            if (is_numeric($extension)) $theme['extension'] = $extension;
     297          }
     298          if (preg_match('/["\']parent["\'][^"\']+["\']([^"\']+)["\']/', $theme_data, $val))
     299          {
     300            $theme['parent'] = $val[1];
    269301          }
    270302
  • trunk/admin/themes/default/template/footer.tpl

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

    r5200 r5258  
    55<div id="themesContent">
    66
    7 <h3>Active Themes</h3>
     7<fieldset>
     8<legend>Active Themes</legend>
    89{if isset($active_themes)}
    910<div class="themeBoxes">
     
    2223</div> <!-- themeBoxes -->
    2324{/if}
     25</fieldset>
    2426
    2527{if isset($inactive_themes)}
    26 <h3>Inactive Themes</h3>
     28<fieldset>
     29<legend>Inactive Themes</legend>
    2730<div class="themeBoxes">
    2831{foreach from=$inactive_themes item=theme}
     
    3235    <div class="themeActions">
    3336      <a href="{$activate_baseurl}{$theme.id}" title="{'Make this theme available to users'|@translate}">{'Activate'|@translate}</a>
    34       | <a href="{$delete_baseurl}{$theme.id}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');" title="{'Delete this theme'|@translate}">{'Delete'|@translate}</a>
     37      |
     38  {if $theme.deletable}
     39      <a href="{$delete_baseurl}{$theme.id}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');" title="{'Delete this theme'|@translate}">{'Delete'|@translate}</a>
     40  {else}
     41      <span title="{$theme.delete_tooltip}">{'Delete'|@translate}</span>
     42  {/if}
    3543    </div>
    3644   
     
    3846{/foreach}
    3947</div> <!-- themeBoxes -->
     48</fieldset>
    4049{/if}
    4150
  • trunk/admin/themes_installed.php

    r5196 r5258  
    6969$inactive_themes = array();
    7070
    71 foreach($themes->fs_themes as $theme_id => $fs_theme)
     71foreach ($themes->fs_themes as $theme_id => $fs_theme)
    7272{
    7373  if ($theme_id == 'default')
     
    9090  else
    9191  {
     92    $children = $themes->get_children_themes($theme_id);
     93   
     94    if (count($children) > 0)
     95    {
     96      $fs_theme['deletable'] = false;
     97     
     98      $fs_theme['delete_tooltip'] = sprintf(
     99        l10n('Impossible to delete this theme. Other themes depends on it: %s'),
     100        implode(', ', $children)
     101        );
     102    }
     103    else
     104    {
     105      $fs_theme['deletable'] = true;
     106    }
     107   
    92108    array_push($inactive_themes, $fs_theme);
    93109  }
Note: See TracChangeset for help on using the changeset viewer.