Dotclear

Changeset 2227:bfa7b3467627 for admin


Ignore:
Timestamp:
10/03/13 13:47:05 (12 years ago)
Author:
Denis Jean-Chirstian <contact@…>
Branch:
dcRepo
Message:

Continue clean and document code for plugins and themes admin pages

Location:
admin
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • admin/blog_theme.php

    r2222 r2227  
    6262 
    6363# -- Display module configuration page -- 
    64 if ($list->setConfigurationFile($core->blog->settings->system->theme)) { 
     64if ($list->setConfiguration($core->blog->settings->system->theme)) { 
    6565 
    6666     # Get content before page headers 
    67      include $list->getConfigurationFile(); 
     67     include $list->includeConfiguration(); 
    6868 
    6969     # Gather content 
    70      $list->setConfigurationContent(); 
     70     $list->getConfiguration(); 
    7171 
    7272     # Display page 
     
    8181               array( 
    8282                    html::escapeHTML($core->blog->name) => '', 
    83                     __('Blog appearance') => 'blog_theme.php', 
     83                    __('Blog appearance') => $list->getURL('',false), 
    8484                    '<span class="page-title">'.__('Theme configuration').'</span>' => '' 
    8585               )) 
     
    8787 
    8888     # Display previously gathered content 
    89      $list->getConfigurationContent(); 
     89     $list->displayConfiguration(); 
    9090 
    9191     dcPage::close(); 
     
    107107     dcPage::jsLoad('js/_blog_theme.js'). 
    108108     dcPage::jsPageTabs(). 
    109      dcPage::jsColorPicker(), 
     109     dcPage::jsColorPicker(). 
    110110 
    111111     # --BEHAVIOR-- themesToolsHeaders 
     
    120120 
    121121# -- Display modules lists -- 
    122 if ($core->auth->isSuperAdmin() && $list->isPathWritable()) { 
     122if ($core->auth->isSuperAdmin() && $list->isWritablePath()) { 
    123123 
    124124     # Updated modules from repo 
     
    129129          '<h3>'.html::escapeHTML(__('Update themes')).'</h3>'. 
    130130          '<p>'.sprintf( 
    131                __('There is one theme to update available from %2$s.', 'There are %s themes to update available from %s.', count($modules)), 
    132                count($modules), 
    133                '<a href="http://dotaddict.org/dc2/themes">Dotaddict</a>' 
     131               __('There is one theme to update available from repository.', 'There are %s themes to update available from repository.', count($modules)), 
     132               count($modules) 
    134133          ).'</p>'; 
    135134 
    136135          $list 
    137                ->newList('theme-update') 
     136               ->initList('theme-update') 
     137               ->setTab('themes') 
    138138               ->setModules($modules) 
    139                ->setPageTab('themes') 
    140                ->displayModulesList( 
     139               ->displayModules( 
    141140                    /*cols */      array('sshot', 'name', 'desc', 'author', 'version', 'current_version', 'parent'), 
    142141                    /* actions */  array('update', 'delete') 
    143                ); 
    144  
    145           echo 
    146           '</div>'; 
    147      } 
    148 } 
    149  
    150 # List all active plugins 
    151 echo 
    152 '<div class="multi-part" id="themes" title="'.__('Installed themes').'">'; 
    153  
    154 $modules = $list->modules->getModules(); 
    155 if (!empty($modules)) { 
    156  
    157      echo 
    158      '<h3>'.__('Activated themes').'</h3>'. 
    159      '<p>'.__('Manage installed themes from this list.').'</p>'; 
    160  
    161      $list 
    162           ->newList('theme-activate') 
    163           ->setModules($modules) 
    164           ->setPageTab('themes') 
    165           ->displayModulesList( 
    166                /* cols */          array('sshot', 'distrib', 'name', 'config', 'desc', 'author', 'version', 'parent'), 
    167                /* actions */  array('select', 'deactivate', 'delete') 
    168           ); 
    169 } 
    170  
    171 $modules = $list->modules->getDisabledModules(); 
    172 if (!empty($modules)) { 
    173  
    174      echo 
    175      '<h3>'.__('Deactivated themes').'</h3>'. 
    176      '<p>'.__('Deactivated themes are installed but not usable. You can activate them from here.').'</p>'; 
    177  
    178      $list 
    179           ->newList('theme-deactivate') 
    180           ->setModules($modules) 
    181           ->setPageTab('themes') 
    182           ->displayModulesList( 
    183                /* cols */          array('name', 'distrib'), 
    184                /* actions */  array('activate', 'delete') 
    185           ); 
    186 } 
    187  
    188 echo  
    189 '</div>'; 
    190  
    191 if ($core->auth->isSuperAdmin() && $list->isPathWritable()) { 
    192  
    193      # New modules from repo 
    194      $search = $list->getSearchQuery(); 
    195      $modules = $search ? $list->store->search($search) : $list->store->get(); 
    196  
    197      if (!empty($search) || !empty($modules)) { 
    198           echo 
    199           '<div class="multi-part" id="new" title="'.__('Add themes from Dotaddict').'">'. 
    200           '<h3>'.__('Add themes from Dotaddict repository').'</h3>'; 
    201  
    202           $list 
    203                ->newList('theme-new') 
    204                ->setModules($modules) 
    205                ->setPageTab('new') 
    206                ->displaySearchForm() 
    207                ->displayNavMenu() 
    208                ->displayModulesList( 
    209                     /* cols */          array('expander', 'sshot', 'name', 'score', 'config', 'desc', 'author', 'version', 'parent', 'details', 'support'), 
    210                     /* actions */  array('install'), 
    211                     /* nav limit */     true 
    212142               ); 
    213143 
     
    221151          '</div>'; 
    222152     } 
     153} 
     154 
     155# Activated modules 
     156$modules = $list->modules->getModules(); 
     157if (!empty($modules)) { 
     158 
     159     echo 
     160     '<div class="multi-part" id="themes" title="'.__('Installed themes').'">'. 
     161     '<h3>'.__('Installed themes').'</h3>'. 
     162     '<p>'.__('You can configure and manage installed themes from this list.').'</p>'; 
     163 
     164     $list 
     165          ->initList('theme-activate') 
     166          ->setTab('themes') 
     167          ->setModules($modules) 
     168          ->displayModules( 
     169               /* cols */          array('sshot', 'distrib', 'name', 'config', 'desc', 'author', 'version', 'parent'), 
     170               /* actions */  array('select', 'deactivate', 'delete') 
     171          ); 
     172 
     173     echo  
     174     '</div>'; 
     175} 
     176 
     177# Deactivated modules 
     178$modules = $list->modules->getDisabledModules(); 
     179if (!empty($modules)) { 
     180 
     181     echo 
     182     '<div class="multi-part" id="deactivate" title="'.__('Deactivated themes').'">'. 
     183     '<h3>'.__('Deactivated themes').'</h3>'. 
     184     '<p>'.__('Deactivated themes are installed but not usable. You can activate them from here.').'</p>'; 
     185 
     186     $list 
     187          ->initList('theme-deactivate') 
     188          ->setTab('themes') 
     189          ->setModules($modules) 
     190          ->displayModules( 
     191               /* cols */          array('name', 'distrib'), 
     192               /* actions */  array('activate', 'delete') 
     193          ); 
     194 
     195     echo  
     196     '</div>'; 
     197} 
     198 
     199if ($core->auth->isSuperAdmin() && $list->isWritablePath()) { 
     200 
     201     # New modules from repo 
     202     $search = $list->getSearch(); 
     203     $modules = $search ? $list->store->search($search) : $list->store->get(); 
     204 
     205     if (!empty($search) || !empty($modules)) { 
     206          echo 
     207          '<div class="multi-part" id="new" title="'.__('Add themes').'">'. 
     208          '<h3>'.__('Add themes from repository').'</h3>'. 
     209          '<p>'.__('You can search and install themes directly from repository.').'</p>'; 
     210 
     211          $list 
     212               ->initList('theme-new') 
     213               ->setTab('new') 
     214               ->setModules($modules) 
     215               ->displaySearch() 
     216               ->displayIndex() 
     217               ->displayModules( 
     218                    /* cols */          array('expander', 'sshot', 'name', 'score', '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     } 
    223232 
    224233     # Add a new plugin 
    225234     echo 
    226235     '<div class="multi-part" id="addtheme" title="'.__('Install or upgrade manually').'">'. 
     236     '<h3>'.__('Add themes from a package').'</h3>'. 
    227237     '<p>'.__('You can install themes by uploading or downloading zip files.').'</p>'; 
    228238 
  • admin/plugins.php

    r2222 r2227  
    5656 
    5757# -- Display module configuration page -- 
    58 if ($list->setConfigurationFile()) { 
     58if ($list->setConfiguration()) { 
    5959 
    6060     # Get content before page headers 
    61      include $list->getConfigurationFile(); 
     61     include $list->includeConfiguration(); 
    6262 
    6363     # Gather content 
    64      $list->setConfigurationContent(); 
     64     $list->getConfiguration(); 
    6565 
    6666     # Display page 
     
    7373               array( 
    7474                    html::escapeHTML($core->blog->name) => '', 
    75                     '<a href="'.$list->getPageURL().'">'.__('Plugins management').'</a>' => '', 
     75                    __('Plugins management') => $list->getURL('',false), 
    7676                    '<span class="page-title">'.__('Plugin configuration').'</span>' => '' 
    7777               )) 
     
    7979 
    8080     # Display previously gathered content 
    81      $list->getConfigurationContent(); 
     81     $list->displayConfiguration(); 
    8282 
    8383     dcPage::close(); 
     
    125125          '<li>'.$k.'</li>'; 
    126126     } 
    127      echo  
    128  
     127 
     128     echo  
    129129     '</ul></div>'; 
    130130} 
     
    143143 
    144144# -- Display modules lists -- 
    145 if ($core->auth->isSuperAdmin() && $list->isPathWritable()) { 
     145if ($core->auth->isSuperAdmin() && $list->isWritablePath()) { 
    146146 
    147147     # Updated modules from repo 
     
    152152          '<h3>'.html::escapeHTML(__('Update plugins')).'</h3>'. 
    153153          '<p>'.sprintf( 
    154                __('There is one plugin to update available from %2$s.', 'There are %s plugins to update available from %s.', count($modules)), 
    155                count($modules), 
    156                '<a href="http://dotaddict.org/dc2/plugins">Dotaddict</a>' 
     154               __('There is one plugin to update available from repository.', 'There are %s plugins to update available from repository.', count($modules)), 
     155               count($modules) 
    157156          ).'</p>'; 
    158157 
    159158          $list 
    160                ->newList('plugin-update') 
     159               ->initList('plugin-update') 
     160               ->setTab('update') 
    161161               ->setModules($modules) 
    162                ->setPageTab('update') 
    163                ->displayModulesList( 
     162               ->displayModules( 
    164163                    /*cols */      array('icon', 'name', 'version', 'current_version', 'desc'), 
    165164                    /* actions */  array('update') 
    166                ); 
    167  
    168           echo 
    169           '</div>'; 
    170      } 
    171 } 
    172  
    173 # List all active plugins 
    174 echo 
    175 '<div class="multi-part" id="plugins" title="'.__('Installed plugins').'">'; 
    176  
    177 $modules = $list->modules->getModules(); 
    178 if (!empty($modules)) { 
    179      echo 
    180      '<h3>'.__('Activated plugins').'</h3>'. 
    181      '<p>'.__('Manage installed plugins from this list.').'</p>'; 
    182  
    183      $list 
    184           ->newList('plugin-activate') 
    185           ->setModules($modules) 
    186           ->setPageTab('plugins') 
    187           ->displayModulesList( 
    188                /* cols */          array('expander', 'icon', 'name', 'config', 'version', 'desc', 'distrib'), 
    189                /* actions */  array('deactivate', 'delete') 
    190           ); 
    191 } 
    192  
    193 # Deactivated modules 
    194 $modules = $list->modules->getDisabledModules(); 
    195 if (!empty($modules)) { 
    196      echo 
    197      '<h3>'.__('Deactivated plugins').'</h3>'. 
    198      '<p>'.__('Deactivated plugins are installed but not usable. You can activate them from here.').'</p>'; 
    199  
    200      $list 
    201           ->newList('plugin-deactivate') 
    202           ->setModules($modules) 
    203           ->setPageTab('plugins') 
    204           ->displayModulesList( 
    205                /* cols */          array('icon', 'name', 'distrib'), 
    206                /* actions */  array('activate', 'delete') 
    207           ); 
    208 } 
    209  
    210 echo  
    211 '</div>'; 
    212  
    213 if ($core->auth->isSuperAdmin() && $list->isPathWritable()) { 
    214  
    215      # New modules from repo 
    216      $search = $list->getSearchQuery(); 
    217      $modules = $search ? $list->store->search($search) : $list->store->get(); 
    218  
    219      if (!empty($search) || !empty($modules)) { 
    220           echo 
    221           '<div class="multi-part" id="new" title="'.__('Add plugins from Dotaddict').'">'. 
    222           '<h3>'.__('Add plugins from Dotaddict repository').'</h3>'; 
    223  
    224           $list 
    225                ->newList('plugin-new') 
    226                ->setModules($modules) 
    227                ->setPageTab('new') 
    228                ->displaySearchForm() 
    229                ->displayNavMenu() 
    230                ->displayModulesList( 
    231                     /* cols */          array('expander', 'name', 'score', 'version', 'desc'), 
    232                     /* actions */  array('install'), 
    233                     /* nav limit */     true 
    234165               ); 
    235166 
     
    243174          '</div>'; 
    244175     } 
     176} 
     177 
     178echo 
     179'<div class="multi-part" id="plugins" title="'.__('Installed plugins').'">'; 
     180 
     181# Activated modules 
     182$modules = $list->modules->getModules(); 
     183if (!empty($modules)) { 
     184      
     185     echo  
     186     '<h3>'.($core->auth->isSuperAdmin() ?__('Activated plugins') : __('Installed plugins')).'</h3>'. 
     187     '<p>'.__('You can configure and manage installed plugins from this list.').'</p>'; 
     188 
     189     $list 
     190          ->initList('plugin-activate') 
     191          ->setTab('plugins') 
     192          ->setModules($modules) 
     193          ->displayModules( 
     194               /* cols */          array('expander', 'icon', 'name', 'config', 'version', 'desc', 'distrib'), 
     195               /* actions */  array('deactivate', 'delete') 
     196          ); 
     197} 
     198 
     199# Deactivated modules 
     200if ($core->auth->isSuperAdmin()) { 
     201     $modules = $list->modules->getDisabledModules(); 
     202     if (!empty($modules)) { 
     203          echo 
     204          '<h3>'.__('Deactivated plugins').'</h3>'. 
     205          '<p>'.__('Deactivated plugins are installed but not usable. You can activate them from here.').'</p>'; 
     206 
     207          $list 
     208               ->initList('plugin-deactivate') 
     209               ->setTab('plugins') 
     210               ->setModules($modules) 
     211               ->displayModules( 
     212                    /* cols */          array('icon', 'name', 'distrib'), 
     213                    /* actions */  array('activate', 'delete') 
     214               ); 
     215     } 
     216} 
     217 
     218echo  
     219'</div>'; 
     220 
     221if ($core->auth->isSuperAdmin() && $list->isWritablePath()) { 
     222 
     223     # New modules from repo 
     224     $search = $list->getSearch(); 
     225     $modules = $search ? $list->store->search($search) : $list->store->get(); 
     226 
     227     if (!empty($search) || !empty($modules)) { 
     228          echo 
     229          '<div class="multi-part" id="new" title="'.__('Add plugins').'">'. 
     230          '<h3>'.__('Add plugins from repository').'</h3>'. 
     231          '<p>'.__('You can search and install plugins directly from repository.').'</p>'; 
     232 
     233          $list 
     234               ->initList('plugin-new') 
     235               ->setTab('new') 
     236               ->setModules($modules) 
     237               ->displaySearch() 
     238               ->displayIndex() 
     239               ->displayModules( 
     240                    /* cols */          array('expander', 'name', 'score', 'version', 'desc'), 
     241                    /* actions */  array('install'), 
     242                    /* nav limit */     true 
     243               ); 
     244 
     245          echo 
     246          '<p class="info vertical-separator">'.sprintf( 
     247               __("Visit %s repository, the resources center for Dotclear."), 
     248               '<a href="http://dotaddict.org/dc2/plugins">Dotaddict</a>' 
     249               ). 
     250          '</p>'. 
     251 
     252          '</div>'; 
     253     } 
    245254 
    246255     # Add a new plugin 
    247256     echo 
    248257     '<div class="multi-part" id="addplugin" title="'.__('Install or upgrade manually').'">'. 
     258     '<h3>'.__('Add plugins from a package').'</h3>'. 
    249259     '<p>'.__('You can install plugins by uploading or downloading zip files.').'</p>'; 
    250260 
     
    259269 
    260270# -- Notice for super admin -- 
    261 if ($core->auth->isSuperAdmin() && !$list->isPathWritable()) { 
     271if ($core->auth->isSuperAdmin() && !$list->isWritablePath()) { 
    262272     echo  
    263273     '<p class="warning">'.__('Some functions are disabled, please give write access to your plugins directory to enable them.').'</p>'; 
  • admin/services.php

    r2216 r2227  
    485485          } 
    486486 
    487           $module = adminModulesList::parseModuleInfo($id, $module); 
     487          $module = adminModulesList::sanitizeModule($id, $module); 
    488488 
    489489          $rsp = new xmlTag('module'); 
  • admin/style/default.css

    r2221 r2227  
    23482348     display: block; 
    23492349     } 
     2350.debug { 
     2351     background: #ff6; 
     2352     padding: 3px 0.5em 2px; 
     2353     } 
    23502354/* ---------------------------------------------- Couleurs ajoutées via javascript    
    23512355/* color-picker.js */ 
Note: See TracChangeset for help on using the changeset viewer.

Sites map