Dotclear


Ignore:
Timestamp:
10/02/13 17:00:38 (12 years ago)
Author:
Denis Jean-Chirstian <contact@…>
Branch:
dcRepo
Message:

Calls to dcModules and dcRepository from plugins and themes page are now through adminModulesList, cleaner and healthy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin/blog_theme.php

    r2196 r2215  
    1515dcPage::check('admin'); 
    1616 
    17 # -------------------------------------------------- 
    18 # @todo Add settings to Dotclear update features 
     17# -- "First time" settings setup -- 
    1918if ($core->blog->settings->system->repository_theme_url === null) { 
    2019     $core->blog->settings->system->put( 
     
    2221     ); 
    2322} 
    24 # -------------------------------------------------- 
    2523 
    2624# -- Loading themes -- 
     
    2826$core->themes->loadModules($core->blog->themes_path, null); 
    2927 
    30 # -- Repository helper -- 
    31 $repository = new dcRepository( 
     28# -- Page helper -- 
     29$list = new adminThemesList( 
    3230     $core->themes,  
     31     $core->blog->themes_path, 
    3332     $core->blog->settings->system->repository_theme_url 
    3433); 
    35 $repository->check(); 
    36  
    37 # -- Page helper -- 
    38 $list = new adminThemesList( 
    39      $core,  
    40      $core->blog->themes_path, 
    41      false 
     34$list::$distributed_modules = array( 
     35     'blueSilence', 
     36     'blowupConfig', 
     37     'customCSS', 
     38     'default', 
     39     'ductile' 
    4240); 
    4341 
    4442# -- Theme screenshot -- 
    45 if (!empty($_GET['shot']) && $core->themes->moduleExists($_GET['shot'])) 
    46 { 
    47      if (empty($_GET['src'])) { 
    48           $f = $core->blog->themes_path.'/'.$_GET['shot'].'/screenshot.jpg'; 
    49      } else { 
    50           $f = $core->blog->themes_path.'/'.$_GET['shot'].'/'.path::clean($_GET['src']); 
    51      } 
    52       
    53      $f = path::real($f); 
    54       
     43if (!empty($_GET['shot']) && $list->modules->moduleExists($_GET['shot'])) { 
     44 
     45     $f= path::real(empty($_GET['src']) ? 
     46          $core->blog->themes_path.'/'.$_GET['shot'].'/screenshot.jpg' : 
     47          $core->blog->themes_path.'/'.$_GET['shot'].'/'.path::clean($_GET['src']) 
     48     ); 
     49 
    5550     if (!file_exists($f)) { 
    5651          $f = dirname(__FILE__).'/images/noscreenshot.png'; 
    5752     } 
    58       
    59      http::cache(array_merge(array($f),get_included_files())); 
    60       
     53 
     54     http::cache(array_merge(array($f), get_included_files())); 
     55 
    6156     header('Content-Type: '.files::getMimeType($f)); 
    6257     header('Content-Length: '.filesize($f)); 
    6358     readfile($f); 
    64       
     59 
    6560     exit; 
    6661} 
    6762 
    6863# -- Display module configuration page -- 
    69 if ($list->setConfigurationFile($core->themes, $core->blog->settings->system->theme)) { 
     64if ($list->setConfigurationFile($core->blog->settings->system->theme)) { 
    7065 
    7166     # Get content before page headers 
     
    105100 
    106101# -- Execute actions -- 
    107 if (!empty($_POST) && empty($_REQUEST['conf']) && $core->auth->isSuperAdmin() && $list->isPathWritable()) { 
    108      try { 
    109           $list->executeAction('themes', $core->themes, $repository); 
    110      } 
    111      catch (Exception $e) { 
    112           $core->error->add($e->getMessage()); 
    113      } 
     102try { 
     103     $list->doActions('themes'); 
     104} 
     105catch (Exception $e) { 
     106     $core->error->add($e->getMessage()); 
    114107} 
    115108 
     
    139132 
    140133     # Updated modules from repo 
    141      $modules = $repository->get(true); 
     134     $modules = $list->repository->get(true); 
    142135     if (!empty($modules)) { 
    143136          echo  
     
    168161'<div class="multi-part" id="themes" title="'.__('Installed themes').'">'; 
    169162 
    170 $modules = $core->themes->getModules(); 
     163$modules = $list->modules->getModules(); 
    171164if (!empty($modules)) { 
    172165 
     
    180173          ->setPageTab('themes') 
    181174          ->displayModulesList( 
    182                /* cols */          array('sshot', 'name', 'config', 'desc', 'author', 'version', 'parent'), 
     175               /* cols */          array('sshot', 'distrib', 'name', 'config', 'desc', 'author', 'version', 'parent'), 
    183176               /* actions */  array('select', 'deactivate', 'delete') 
    184177          ); 
    185178} 
    186179 
    187 $modules = $core->themes->getDisabledModules(); 
     180$modules = $list->modules->getDisabledModules(); 
    188181if (!empty($modules)) { 
    189182 
     
    209202     # New modules from repo 
    210203     $search = $list->getSearchQuery(); 
    211      $modules = $search ? $repository->search($search) : $repository->get(); 
    212  
    213      echo 
    214      '<div class="multi-part" id="new" title="'.__('Add themes from Dotaddict').'">'. 
    215      '<h3>'.__('Add themes from Dotaddict repository').'</h3>'; 
    216  
    217      $list 
    218           ->newList('theme-new') 
    219           ->setModules($modules) 
    220           ->setPageTab('new') 
    221           ->displaySearchForm() 
    222           ->displayNavMenu() 
    223           ->displayModulesList( 
    224                /* cols */          array('expander', 'sshot', 'name', 'config', 'desc', 'author', 'version', 'parent', 'distrib'), 
    225                /* actions */  array('install'), 
    226                /* nav limit */     true 
    227           ); 
    228  
    229      echo 
    230      '<p class="info vertical-separator">'.sprintf( 
    231           __("Visit %s repository, the resources center for Dotclear."), 
    232           '<a href="http://dotaddict.org/dc2/themes">Dotaddict</a>' 
    233           ). 
    234      '</p>'. 
    235  
     204     $modules = $search ? $list->repository->search($search) : $list->repository->get(); 
     205 
     206     if (!empty($search) || !empty($modules)) { 
     207          echo 
     208          '<div class="multi-part" id="new" title="'.__('Add themes from Dotaddict').'">'. 
     209          '<h3>'.__('Add themes from Dotaddict repository').'</h3>'; 
     210 
     211          $list 
     212               ->newList('theme-new') 
     213               ->setModules($modules) 
     214               ->setPageTab('new') 
     215               ->displaySearchForm() 
     216               ->displayNavMenu() 
     217               ->displayModulesList( 
     218                    /* cols */          array('expander', 'sshot', 'name', 'config', 'desc', 'author', 'version', 'parent', 'details', 'support'), 
     219                    /* actions */  array('install'), 
     220                    /* nav limit */     true 
     221               ); 
     222 
     223          echo 
     224          '<p class="info vertical-separator">'.sprintf( 
     225               __("Visit %s repository, the resources center for Dotclear."), 
     226               '<a href="http://dotaddict.org/dc2/themes">Dotaddict</a>' 
     227               ). 
     228          '</p>'. 
     229 
     230          '</div>'; 
     231     } 
     232 
     233     # Add a new plugin 
     234     echo 
     235     '<div class="multi-part" id="addtheme" title="'.__('Install or upgrade manually').'">'. 
     236     '<p>'.__('You can install themes by uploading or downloading zip files.').'</p>'; 
     237 
     238     $list->displayManualForm(); 
     239 
     240     echo 
    236241     '</div>'; 
    237  
    238      # Add a new plugin 
    239      echo 
    240      '<div class="multi-part" id="addtheme" title="'.__('Install or upgrade manually').'">'; 
    241  
    242      echo '<p>'.__('You can install themes by uploading or downloading zip files.').'</p>'; 
    243       
    244      $list->displayManualForm(); 
    245  
    246      echo 
    247      '</div>'; 
    248242} 
    249243 
    250244dcPage::close(); 
    251 ?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map