Dotclear


Ignore:
Timestamp:
03/08/18 17:58:39 (8 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Code formatting (PSR-2)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin/blog_theme.php

    r3398 r3730  
    1111# -- END LICENSE BLOCK ----------------------------------------- 
    1212 
    13 require dirname(__FILE__).'/../inc/admin/prepend.php'; 
     13require dirname(__FILE__) . '/../inc/admin/prepend.php'; 
    1414 
    1515dcPage::check('admin'); 
     
    2121# -- Page helper -- 
    2222$list = new adminThemesList( 
    23      $core->themes, 
    24      $core->blog->themes_path, 
    25      $core->blog->settings->system->store_theme_url 
     23    $core->themes, 
     24    $core->blog->themes_path, 
     25    $core->blog->settings->system->store_theme_url 
    2626); 
    2727adminThemesList::$distributed_modules = explode(',', DC_DISTRIB_THEMES); 
     
    3030if (!empty($_GET['shot']) && $list->modules->moduleExists($_GET['shot'])) { 
    3131 
    32      $f= path::real(empty($_GET['src']) ? 
    33           $core->blog->themes_path.'/'.$_GET['shot'].'/screenshot.jpg' : 
    34           $core->blog->themes_path.'/'.$_GET['shot'].'/'.path::clean($_GET['src']) 
    35      ); 
    36  
    37      if (!file_exists($f)) { 
    38           $f = dirname(__FILE__).'/images/noscreenshot.png'; 
    39      } 
    40  
    41      http::cache(array_merge(array($f), get_included_files())); 
    42  
    43      header('Content-Type: '.files::getMimeType($f)); 
    44      header('Content-Length: '.filesize($f)); 
    45      readfile($f); 
    46  
    47      exit; 
     32    $f = path::real(empty($_GET['src']) ? 
     33        $core->blog->themes_path . '/' . $_GET['shot'] . '/screenshot.jpg' : 
     34        $core->blog->themes_path . '/' . $_GET['shot'] . '/' . path::clean($_GET['src']) 
     35    ); 
     36 
     37    if (!file_exists($f)) { 
     38        $f = dirname(__FILE__) . '/images/noscreenshot.png'; 
     39    } 
     40 
     41    http::cache(array_merge(array($f), get_included_files())); 
     42 
     43    header('Content-Type: ' . files::getMimeType($f)); 
     44    header('Content-Length: ' . filesize($f)); 
     45    readfile($f); 
     46 
     47    exit; 
    4848} 
    4949 
     
    5151if ($list->setConfiguration($core->blog->settings->system->theme)) { 
    5252 
    53      # Get content before page headers 
    54      include $list->includeConfiguration(); 
    55  
    56      # Gather content 
    57      $list->getConfiguration(); 
    58  
    59      # Display page 
    60      dcPage::open(__('Blog appearance'), 
    61           dcPage::jsPageTabs(). 
    62           dcPage::jsColorPicker(). 
    63  
    64           # --BEHAVIOR-- themesToolsHeaders 
    65           $core->callBehavior('themesToolsHeaders', $core, true), 
    66  
    67           dcPage::breadcrumb( 
    68                array( 
    69                     html::escapeHTML($core->blog->name) => '', 
    70                     __('Blog appearance') => $list->getURL('',false), 
    71                     '<span class="page-title">'.__('Theme configuration').'</span>' => '' 
    72                )) 
    73      ); 
    74  
    75      # Display previously gathered content 
    76      $list->displayConfiguration(); 
    77  
    78      dcPage::helpBlock('core_blog_theme_conf'); 
    79      dcPage::close(); 
    80  
    81      # Stop reading code here 
    82      return; 
     53    # Get content before page headers 
     54    include $list->includeConfiguration(); 
     55 
     56    # Gather content 
     57    $list->getConfiguration(); 
     58 
     59    # Display page 
     60    dcPage::open(__('Blog appearance'), 
     61        dcPage::jsPageTabs() . 
     62        dcPage::jsColorPicker() . 
     63 
     64        # --BEHAVIOR-- themesToolsHeaders 
     65        $core->callBehavior('themesToolsHeaders', $core, true), 
     66 
     67        dcPage::breadcrumb( 
     68            array( 
     69                html::escapeHTML($core->blog->name)                                => '', 
     70                __('Blog appearance')                                               => $list->getURL('', false), 
     71                '<span class="page-title">' . __('Theme configuration') . '</span>' => '' 
     72            )) 
     73    ); 
     74 
     75    # Display previously gathered content 
     76    $list->displayConfiguration(); 
     77 
     78    dcPage::helpBlock('core_blog_theme_conf'); 
     79    dcPage::close(); 
     80 
     81    # Stop reading code here 
     82    return; 
    8383} 
    8484 
    8585# -- Execute actions -- 
    8686try { 
    87      $list->doActions(); 
    88 } 
    89 catch (Exception $e) { 
    90      $core->error->add($e->getMessage()); 
     87    $list->doActions(); 
     88} catch (Exception $e) { 
     89    $core->error->add($e->getMessage()); 
    9190} 
    9291 
    9392# -- Page header -- 
    9493dcPage::open(__('Themes management'), 
    95      dcPage::jsLoad('js/_blog_theme.js'). 
    96      dcPage::jsPageTabs(). 
    97      dcPage::jsColorPicker(). 
    98  
    99      # --BEHAVIOR-- themesToolsHeaders 
    100      $core->callBehavior('themesToolsHeaders', $core, false), 
    101  
    102      dcPage::breadcrumb( 
    103           array( 
    104                html::escapeHTML($core->blog->name) => '', 
    105                '<span class="page-title">'.__('Blog appearance').'</span>' => '' 
    106           )) 
     94    dcPage::jsLoad('js/_blog_theme.js') . 
     95    dcPage::jsPageTabs() . 
     96    dcPage::jsColorPicker() . 
     97 
     98    # --BEHAVIOR-- themesToolsHeaders 
     99    $core->callBehavior('themesToolsHeaders', $core, false), 
     100 
     101    dcPage::breadcrumb( 
     102        array( 
     103            html::escapeHTML($core->blog->name)                            => '', 
     104            '<span class="page-title">' . __('Blog appearance') . '</span>' => '' 
     105        )) 
    107106); 
    108107 
     
    110109if ($core->auth->isSuperAdmin()) { 
    111110 
    112      # Updated modules from repo 
    113      $modules = $list->store->get(true); 
    114      if (!empty($modules)) { 
    115           echo 
    116           '<div class="multi-part" id="update" title="'.html::escapeHTML(__('Update themes')).'">'. 
    117           '<h3>'.html::escapeHTML(__('Update themes')).'</h3>'. 
    118           '<p>'.sprintf( 
    119                __('There is one theme to update available from repository.', 'There are %s themes to update available from repository.', count($modules)), 
    120                count($modules) 
    121           ).'</p>'; 
    122  
    123           $list 
    124                ->setList('theme-update') 
    125                ->setTab('themes') 
    126                ->setModules($modules) 
    127                ->displayModules( 
    128                     /*cols */      array('checkbox', 'name', 'sshot', 'desc', 'author', 'version', 'current_version', 'parent'), 
    129                     /* actions */  array('update', 'delete') 
    130                ); 
    131  
    132           echo 
    133           '<p class="info vertical-separator">'.sprintf( 
    134                __("Visit %s repository, the resources center for Dotclear."), 
    135                '<a href="http://themes.dotaddict.org/galerie-dc2/">Dotaddict</a>' 
    136                ). 
    137           '</p>'. 
    138  
    139           '</div>'; 
    140      } 
     111    # Updated modules from repo 
     112    $modules = $list->store->get(true); 
     113    if (!empty($modules)) { 
     114        echo 
     115        '<div class="multi-part" id="update" title="' . html::escapeHTML(__('Update themes')) . '">' . 
     116        '<h3>' . html::escapeHTML(__('Update themes')) . '</h3>' . 
     117        '<p>' . sprintf( 
     118            __('There is one theme to update available from repository.', 'There are %s themes to update available from repository.', count($modules)), 
     119            count($modules) 
     120        ) . '</p>'; 
     121 
     122        $list 
     123            ->setList('theme-update') 
     124            ->setTab('themes') 
     125            ->setModules($modules) 
     126            ->displayModules( 
     127                /*cols */array('checkbox', 'name', 'sshot', 'desc', 'author', 'version', 'current_version', 'parent'), 
     128                /* actions */array('update', 'delete') 
     129            ); 
     130 
     131        echo 
     132        '<p class="info vertical-separator">' . sprintf( 
     133            __("Visit %s repository, the resources center for Dotclear."), 
     134            '<a href="http://themes.dotaddict.org/galerie-dc2/">Dotaddict</a>' 
     135        ) . 
     136            '</p>' . 
     137 
     138            '</div>'; 
     139    } 
    141140} 
    142141 
     
    145144if (!empty($modules)) { 
    146145 
    147      echo 
    148      '<div class="multi-part" id="themes" title="'.__('Installed themes').'">'. 
    149      '<h3>'.__('Installed themes').'</h3>'. 
    150      '<p class="more-info">'.__('You can configure and manage installed themes from this list.').'</p>'; 
    151  
    152      $list 
    153           ->setList('theme-activate') 
    154           ->setTab('themes') 
    155           ->setModules($modules) 
    156           ->displayModules( 
    157                /* cols */          array('sshot', 'distrib', 'name', 'config', 'desc', 'author', 'version', 'parent'), 
    158                /* actions */  array('select', 'behavior', 'deactivate', 'delete') 
    159           ); 
    160  
    161      echo 
    162      '</div>'; 
     146    echo 
     147    '<div class="multi-part" id="themes" title="' . __('Installed themes') . '">' . 
     148    '<h3>' . __('Installed themes') . '</h3>' . 
     149    '<p class="more-info">' . __('You can configure and manage installed themes from this list.') . '</p>'; 
     150 
     151    $list 
     152        ->setList('theme-activate') 
     153        ->setTab('themes') 
     154        ->setModules($modules) 
     155        ->displayModules( 
     156            /* cols */array('sshot', 'distrib', 'name', 'config', 'desc', 'author', 'version', 'parent'), 
     157            /* actions */array('select', 'behavior', 'deactivate', 'delete') 
     158        ); 
     159 
     160    echo 
     161        '</div>'; 
    163162} 
    164163 
     
    167166if (!empty($modules)) { 
    168167 
    169      echo 
    170      '<div class="multi-part" id="deactivate" title="'.__('Deactivated themes').'">'. 
    171      '<h3>'.__('Deactivated themes').'</h3>'. 
    172      '<p class="more-info">'.__('Deactivated themes are installed but not usable. You can activate them from here.').'</p>'; 
    173  
    174      $list 
    175           ->setList('theme-deactivate') 
    176           ->setTab('themes') 
    177           ->setModules($modules) 
    178           ->displayModules( 
    179                /* cols */          array('name', 'distrib'), 
    180                /* actions */  array('activate', 'delete') 
    181           ); 
    182  
    183      echo 
    184      '</div>'; 
     168    echo 
     169    '<div class="multi-part" id="deactivate" title="' . __('Deactivated themes') . '">' . 
     170    '<h3>' . __('Deactivated themes') . '</h3>' . 
     171    '<p class="more-info">' . __('Deactivated themes are installed but not usable. You can activate them from here.') . '</p>'; 
     172 
     173    $list 
     174        ->setList('theme-deactivate') 
     175        ->setTab('themes') 
     176        ->setModules($modules) 
     177        ->displayModules( 
     178            /* cols */array('name', 'distrib'), 
     179            /* actions */array('activate', 'delete') 
     180        ); 
     181 
     182    echo 
     183        '</div>'; 
    185184} 
    186185 
    187186if ($core->auth->isSuperAdmin() && $list->isWritablePath()) { 
    188187 
    189      # New modules from repo 
    190      $search = $list->getSearch(); 
    191      $modules = $search ? $list->store->search($search) : $list->store->get(); 
    192  
    193      if (!empty($search) || !empty($modules)) { 
    194           echo 
    195           '<div class="multi-part" id="new" title="'.__('Add themes').'">'. 
    196           '<h3>'.__('Add themes from repository').'</h3>'; 
    197 //        '<p>'.__('Search and install themes directly from repository.').'</p>'; 
    198  
    199           $list 
    200                ->setList('theme-new') 
    201                ->setTab('new') 
    202                ->setModules($modules) 
    203                ->displaySearch() 
    204                ->displayIndex() 
    205                ->displayModules( 
    206                     /* cols */          array('expander', 'sshot', 'name', 'score', 'config', 'desc', 'author', 'version', 'parent', 'details', 'support'), 
    207                     /* actions */  array('install'), 
    208                     /* nav limit */     true 
    209                ); 
    210  
    211           echo 
    212           '<p class="info vertical-separator">'.sprintf( 
    213                __("Visit %s repository, the resources center for Dotclear."), 
    214                '<a href="http://themes.dotaddict.org/galerie-dc2/">Dotaddict</a>' 
    215                ). 
    216           '</p>'. 
    217  
    218           '</div>'; 
    219      } 
    220  
    221      # Add a new plugin 
    222      echo 
    223      '<div class="multi-part" id="addtheme" title="'.__('Install or upgrade manually').'">'. 
    224      '<h3>'.__('Add themes from a package').'</h3>'. 
    225      '<p class="more-info">'.__('You can install themes by uploading or downloading zip files.').'</p>'; 
    226  
    227      $list->displayManualForm(); 
    228  
    229      echo 
    230      '</div>'; 
     188    # New modules from repo 
     189    $search = $list->getSearch(); 
     190    $modules = $search ? $list->store->search($search) : $list->store->get(); 
     191 
     192    if (!empty($search) || !empty($modules)) { 
     193        echo 
     194        '<div class="multi-part" id="new" title="' . __('Add themes') . '">' . 
     195        '<h3>' . __('Add themes from repository') . '</h3>'; 
     196//        '<p>'.__('Search and install themes directly from repository.').'</p>'; 
     197 
     198        $list 
     199            ->setList('theme-new') 
     200            ->setTab('new') 
     201            ->setModules($modules) 
     202            ->displaySearch() 
     203            ->displayIndex() 
     204            ->displayModules( 
     205                /* cols */array('expander', 'sshot', 'name', 'score', 'config', 'desc', 'author', 'version', 'parent', 'details', 'support'), 
     206                /* actions */array('install'), 
     207                /* nav limit */true 
     208            ); 
     209 
     210        echo 
     211        '<p class="info vertical-separator">' . sprintf( 
     212            __("Visit %s repository, the resources center for Dotclear."), 
     213            '<a href="http://themes.dotaddict.org/galerie-dc2/">Dotaddict</a>' 
     214        ) . 
     215            '</p>' . 
     216 
     217            '</div>'; 
     218    } 
     219 
     220    # Add a new plugin 
     221    echo 
     222    '<div class="multi-part" id="addtheme" title="' . __('Install or upgrade manually') . '">' . 
     223    '<h3>' . __('Add themes from a package') . '</h3>' . 
     224    '<p class="more-info">' . __('You can install themes by uploading or downloading zip files.') . '</p>'; 
     225 
     226    $list->displayManualForm(); 
     227 
     228    echo 
     229        '</div>'; 
    231230} 
    232231 
     
    236235# -- Notice for super admin -- 
    237236if ($core->auth->isSuperAdmin() && !$list->isWritablePath()) { 
    238      echo 
    239      '<p class="warning">'.__('Some functions are disabled, please give write access to your themes directory to enable them.').'</p>'; 
     237    echo 
     238    '<p class="warning">' . __('Some functions are disabled, please give write access to your themes directory to enable them.') . '</p>'; 
    240239} 
    241240 
Note: See TracChangeset for help on using the changeset viewer.

Sites map