Ignore:
Timestamp:
Jun 16, 2013, 6:23:45 PM (11 years ago)
Author:
mistic100
Message:

feature:2884 Display "i" tooltip on themes
+ simplify layout (like plugins_installed)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/themes_installed.php

    r19703 r23259  
    6666}
    6767
    68 $active_themes = array();
    69 $inactive_themes = array();
     68$tpl_themes = array();
    7069
    7170foreach ($themes->fs_themes as $theme_id => $fs_theme)
     
    7574    continue;
    7675  }
     76 
     77  $tpl_theme = array(
     78    'ID' => $theme_id,
     79    'NAME' => $fs_theme['name'],
     80    'VISIT_URL' => $fs_theme['uri'],
     81    'VERSION' => $fs_theme['version'],
     82    'DESC' => $fs_theme['description'],
     83    'AUTHOR' => $fs_theme['author'],
     84    'AUTHOR_URL' => @$fs_theme['author uri'],
     85    'PARENT' => @$fs_theme['parent'],
     86    'SCREENSHOT' => $fs_theme['screenshot'],
     87    'IS_MOBILE' => $fs_theme['mobile'],
     88    'ADMIN_URI' => @$fs_theme['admin_uri'],
     89    );
    7790
    7891  if (in_array($theme_id, $db_theme_ids))
    7992  {
    80     $fs_theme['deactivable'] = true;
     93    $tpl_theme['STATE'] = 'active';
     94    $tpl_theme['DEACTIVABLE'] = true;
    8195
    8296    if (count($db_theme_ids) <= 1)
    8397    {
    84       $fs_theme['deactivable'] = false;
    85       $fs_theme['deactivate_tooltip'] = l10n('Impossible to deactivate this theme, you need at least one theme.');
     98      $tpl_theme['DEACTIVABLE'] = false;
     99      $tpl_theme['DEACTIVATE_TOOLTIP'] = l10n('Impossible to deactivate this theme, you need at least one theme.');
    86100    }
    87 
    88     if ($theme_id == $default_theme)
     101   
     102    $tpl_theme['IS_DEFAULT'] = ($theme_id == $default_theme);
     103  }
     104  else
     105  {
     106    $tpl_theme['STATE'] = 'inactive';
     107   
     108    // is the theme "activable" ?
     109    if (isset($fs_theme['activable']) and !$fs_theme['activable'])
    89110    {
    90       $fs_theme['is_default'] = true;
    91       array_unshift($active_themes, $fs_theme);
     111      $tpl_theme['ACTIVABLE'] = false;
     112      $tpl_theme['ACTIVABLE_TOOLTIP'] = l10n('This theme was not designed to be directly activated');
    92113    }
    93114    else
    94115    {
    95       $fs_theme['is_default'] = false;
    96       array_push($active_themes, $fs_theme);
    97     }
    98   }
    99   else
    100   {
    101     // is the theme "activable" ?
    102     if (isset($fs_theme['activable']) and !$fs_theme['activable'])
    103     {
    104       $fs_theme['activate_tooltip'] = l10n('This theme was not designed to be directly activated');
    105     }
    106     else
    107     {
    108       $fs_theme['activable'] = true;
     116      $tpl_theme['ACTIVABLE'] = true;
    109117    }
    110118
     
    112120    if (isset($missing_parent))
    113121    {
    114       $fs_theme['activable'] = false;
     122      $tpl_theme['ACTIVABLE'] = false;
    115123
    116       $fs_theme['activate_tooltip'] = sprintf(
     124      $tpl_theme['ACTIVABLE_TOOLTIP'] = sprintf(
    117125        l10n('Impossible to activate this theme, the parent theme is missing: %s'),
    118126        $missing_parent
     
    123131    $children = $themes->get_children_themes($theme_id);
    124132
    125     $fs_theme['deletable'] = true;
     133    $tpl_theme['DELETABLE'] = true;
    126134
    127135    if (count($children) > 0)
    128136    {
    129       $fs_theme['deletable'] = false;
     137      $tpl_theme['DELETABLE'] = false;
    130138
    131       $fs_theme['delete_tooltip'] = sprintf(
     139      $tpl_theme['DELETE_TOOLTIP'] = sprintf(
    132140        l10n('Impossible to delete this theme. Other themes depends on it: %s'),
    133141        implode(', ', $children)
    134142        );
    135143    }
     144  }
     145 
     146  array_push($tpl_themes, $tpl_theme);
     147}
    136148
    137     array_push($inactive_themes, $fs_theme);
    138   }
     149// sort themes by state then by name
     150function cmp($a, $b)
     151{
     152  $s = array('active' => 0, 'inactive' => 1);
     153 
     154  if (@$a['IS_DEFAULT']) return -1;
     155  if (@$b['IS_DEFAULT']) return 1;
     156 
     157  if($a['STATE'] == $b['STATE'])
     158    return strcasecmp($a['NAME'], $b['NAME']);
     159  else
     160    return $s[$a['STATE']] >= $s[$b['STATE']];
    139161}
     162usort($tpl_themes, 'cmp');
    140163
    141164$template->assign(
     
    146169      'delete_baseurl' => $base_url.'&amp;action=delete&amp;theme=',
    147170
    148       'active_themes' => $active_themes,
    149       'inactive_themes' => $inactive_themes,
     171      'tpl_themes' => $tpl_themes,
    150172    )
    151173  );
Note: See TracChangeset for help on using the changeset viewer.