Dotclear

Changeset 2215:0775c8672865


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

Files:
7 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 ?> 
  • admin/index.php

    r2175 r2215  
    129129{ 
    130130     $repo = new dcRepository($mod, $url); 
    131      $repo->check(); 
    132131     $upd = $repo->get(true); 
    133132     if (!empty($upd)) { 
  • admin/plugins.php

    r2182 r2215  
    1515dcPage::check('admin'); 
    1616 
    17 # -------------------------------------------------- 
    18 # @todo Add settings to Dotclear update features 
     17# -- "First time" settings setup -- 
    1918if ($core->blog->settings->system->plugins_allow_multi_install === null) { 
    2019     $core->blog->settings->system->put( 
     
    2726     ); 
    2827} 
    29 # -------------------------------------------------- 
    30  
    31 # -- Repository helper -- 
    32 $repository = new dcRepository( 
     28 
     29# -- Page helper -- 
     30$list = new adminModulesList( 
    3331     $core->plugins,  
     32     DC_PLUGINS_ROOT,  
    3433     $core->blog->settings->system->repository_plugin_url 
    3534); 
    36 $repository->check(); 
    37  
    38 # -- Page helper -- 
    39 $list = new adminModulesList( 
    40      $core,  
    41      DC_PLUGINS_ROOT, 
    42      $core->blog->settings->system->plugins_allow_multi_install 
    43 ); 
    44  
    45 $list::setDistributedModules(array( 
     35 
     36$list::$allow_multi_install = $core->blog->settings->system->plugins_allow_multi_install; 
     37$list::$distributed_modules = array( 
    4638     'aboutConfig', 
    4739     'akismet', 
     
    6153     'userPref', 
    6254     'widgets' 
    63 )); 
     55); 
    6456 
    6557# -- Display module configuration page -- 
    66 if ($list->setConfigurationFile($core->plugins)) { 
     58if ($list->setConfigurationFile()) { 
    6759 
    6860     # Get content before page headers 
     
    10193 
    10294# -- Execute actions -- 
    103 if (!empty($_POST) && empty($_REQUEST['conf']) && $core->auth->isSuperAdmin() && $list->isPathWritable()) { 
    104      try { 
    105           $list->executeAction('plugins', $core->plugins, $repository); 
    106      } 
    107      catch (Exception $e) { 
    108           $core->error->add($e->getMessage()); 
    109      } 
     95try { 
     96     $list->doActions('plugins'); 
     97} 
     98catch (Exception $e) { 
     99     $core->error->add($e->getMessage()); 
    110100} 
    111101 
     
    140130     echo  
    141131     '<div class="static-msg">'.__('Following plugins have been installed:').'<ul>'; 
     132 
    142133     foreach ($plugins_install['success'] as $k => $v) { 
    143134          echo  
     
    145136     } 
    146137     echo  
     138 
    147139     '</ul></div>'; 
    148140} 
     
    150142     echo  
    151143     '<div class="error">'.__('Following plugins have not been installed:').'<ul>'; 
     144 
    152145     foreach ($plugins_install['failure'] as $k => $v) { 
    153146          echo  
    154147          '<li>'.$k.' ('.$v.')</li>'; 
    155148     } 
     149 
    156150     echo  
    157151     '</ul></div>'; 
     
    162156 
    163157     # Updated modules from repo 
    164      $modules = $repository->get(true); 
     158     $modules = $list->repository->get(true); 
    165159     if (!empty($modules)) { 
    166160          echo  
     
    191185'<div class="multi-part" id="plugins" title="'.__('Installed plugins').'">'; 
    192186 
    193 $modules = $core->plugins->getModules(); 
     187$modules = $list->modules->getModules(); 
    194188if (!empty($modules)) { 
    195  
    196189     echo 
    197190     '<h3>'.__('Activated plugins').'</h3>'. 
     
    209202 
    210203# Deactivated modules 
    211 $modules = $core->plugins->getDisabledModules(); 
     204$modules = $list->modules->getDisabledModules(); 
    212205if (!empty($modules)) { 
    213  
    214206     echo 
    215207     '<h3>'.__('Deactivated plugins').'</h3>'. 
     
    233225     # New modules from repo 
    234226     $search = $list->getSearchQuery(); 
    235      $modules = $search ? $repository->search($search) : $repository->get(); 
    236  
    237      echo 
    238      '<div class="multi-part" id="new" title="'.__('Add plugins from Dotaddict').'">'. 
    239      '<h3>'.__('Add plugins from Dotaddict repository').'</h3>'; 
    240  
    241      $list 
    242           ->newList('plugin-new') 
    243           ->setModules($modules) 
    244           ->setPageTab('new') 
    245           ->displaySearchForm() 
    246           ->displayNavMenu() 
    247           ->displayModulesList( 
    248                /* cols */          array('expander', 'name', 'version', 'desc'), 
    249                /* actions */  array('install'), 
    250                /* nav limit */     true 
    251           ); 
    252  
    253      echo 
    254      '<p class="info vertical-separator">'.sprintf( 
    255           __("Visit %s repository, the resources center for Dotclear."), 
    256           '<a href="http://dotaddict.org/dc2/plugins">Dotaddict</a>' 
    257           ). 
    258      '</p>'. 
    259  
    260      '</div>'; 
     227     $modules = $search ? $list->repository->search($search) : $list->repository->get(); 
     228 
     229     if (!empty($search) || !empty($modules)) { 
     230          echo 
     231          '<div class="multi-part" id="new" title="'.__('Add plugins from Dotaddict').'">'. 
     232          '<h3>'.__('Add plugins from Dotaddict repository').'</h3>'; 
     233 
     234          $list 
     235               ->newList('plugin-new') 
     236               ->setModules($modules) 
     237               ->setPageTab('new') 
     238               ->displaySearchForm() 
     239               ->displayNavMenu() 
     240               ->displayModulesList( 
     241                    /* cols */          array('expander', 'name', 'version', 'desc'), 
     242                    /* actions */  array('install'), 
     243                    /* nav limit */     true 
     244               ); 
     245 
     246          echo 
     247          '<p class="info vertical-separator">'.sprintf( 
     248               __("Visit %s repository, the resources center for Dotclear."), 
     249               '<a href="http://dotaddict.org/dc2/plugins">Dotaddict</a>' 
     250               ). 
     251          '</p>'. 
     252 
     253          '</div>'; 
     254     } 
    261255 
    262256     # Add a new plugin 
    263257     echo 
    264      '<div class="multi-part" id="addplugin" title="'.__('Install or upgrade manually').'">'; 
    265  
    266      echo '<p>'.__('You can install plugins by uploading or downloading zip files.').'</p>'; 
    267       
     258     '<div class="multi-part" id="addplugin" title="'.__('Install or upgrade manually').'">'. 
     259     '<p>'.__('You can install plugins by uploading or downloading zip files.').'</p>'; 
     260 
    268261     $list->displayManualForm(); 
    269262 
     
    282275 
    283276dcPage::close(); 
    284 ?> 
  • admin/services.php

    r2174 r2215  
    447447     { 
    448448          if (empty($get['id'])) { 
    449                     throw new Exception('No module ID'); 
     449               throw new Exception('No module ID'); 
    450450          } 
    451451          if (empty($get['list'])) { 
    452                     throw new Exception('No list ID'); 
     452               throw new Exception('No list ID'); 
    453453          } 
    454454 
     
    482482 
    483483          if (empty($module)) { 
    484                     throw new Exception('Unknow module ID'); 
     484               throw new Exception('Unknow module ID'); 
    485485          } 
    486486 
     
    489489          $rsp = new xmlTag('module'); 
    490490          $rsp->id = $id; 
    491            
     491 
    492492          foreach($module as $k => $v) { 
    493493               $rsp->{$k}((string) $v); 
  • inc/admin/lib.moduleslist.php

    r2195 r2215  
    11<?php 
     2# -- BEGIN LICENSE BLOCK --------------------------------------- 
     3# 
     4# This file is part of Dotclear 2. 
     5# 
     6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear 
     7# Licensed under the GPL version 2.0 license. 
     8# See LICENSE file or 
     9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 
     10# 
     11# -- END LICENSE BLOCK ----------------------------------------- 
     12if (!defined('DC_ADMIN_CONTEXT')) { return; } 
    213 
    314class adminModulesList 
     
    516     public $core; 
    617     public $modules; 
    7  
    8      public static  $allow_multi_install; 
     18     public $repository; 
     19 
     20     public static $allow_multi_install = false; 
    921     public static $distributed_modules = array(); 
    1022 
    1123     protected $list_id = 'unknow'; 
     24     protected $data = array(); 
    1225 
    1326     protected $config_module = ''; 
     
    3043     protected $sort_asc = true; 
    3144 
    32      public function __construct($core, $root, $allow_multi_install=false) 
    33      { 
    34           $this->core = $core; 
    35           self::$allow_multi_install = (boolean) $allow_multi_install; 
    36           $this->setPathInfo($root); 
     45     public function __construct(dcModules $modules, $modules_root, $xml_url) 
     46     { 
     47          $this->core = $modules->core; 
     48          $this->modules = $modules; 
     49          $this->repository = new dcRepository($modules, $xml_url); 
     50 
     51          $this->setPathInfo($modules_root); 
    3752          $this->setNavSpecial(__('other')); 
    38  
    39           $this->init(); 
    40      } 
    41  
    42      protected function init() 
    43      { 
    44           return null; 
    4553     } 
    4654 
    4755     public function newList($list_id) 
    4856     { 
    49           $this->modules = array(); 
     57          $this->data = array(); 
    5058          $this->page_tab = ''; 
    5159          $this->list_id = $list_id; 
     
    124132          $query = $this->getSearchQuery(); 
    125133 
    126           if (empty($this->modules) && $query === null) { 
     134          if (empty($this->data) && $query === null) { 
    127135               return $this; 
    128136          } 
     
    140148               echo  
    141149               '<p class="message">'.sprintf( 
    142                     __('Found %d result for search "%s":', 'Found %d results for search "%s":', count($this->modules)),  
    143                     count($this->modules), html::escapeHTML($query) 
     150                    __('Found %d result for search "%s":', 'Found %d results for search "%s":', count($this->data)),  
     151                    count($this->data), html::escapeHTML($query) 
    144152                    ). 
    145153               '</p>'; 
     
    163171     public function displayNavMenu() 
    164172     { 
    165           if (empty($this->modules) || $this->getSearchQuery() !== null) { 
     173          if (empty($this->data) || $this->getSearchQuery() !== null) { 
    166174               return $this; 
    167175          } 
     
    169177          # Fetch modules required field 
    170178          $indexes = array(); 
    171           foreach ($this->modules as $id => $module) { 
     179          foreach ($this->data as $id => $module) { 
    172180               if (!isset($module[$this->sort_field])) { 
    173181                    continue; 
     
    246254     public function setModules($modules) 
    247255     { 
    248           $this->modules = array(); 
     256          $this->data = array(); 
    249257          if (!empty($modules) && is_array($modules)) { 
    250258               foreach($modules as $id => $module) { 
    251                     $this->modules[$id] = self::parseModuleInfo($id, $module); 
     259                    $this->data[$id] = self::parseModuleInfo($id, $module); 
    252260               } 
    253261          } 
     
    257265     public function getModules() 
    258266     { 
    259           return $this->modules; 
     267          return $this->data; 
    260268     } 
    261269 
     
    297305     } 
    298306 
    299      public static function setDistributedModules($modules) 
    300      { 
    301           self::$distributed_modules = $modules; 
    302      } 
    303  
    304307     public static function isDistributedModule($module) 
    305308     { 
     
    361364          $sort_field = $this->getSortQuery(); 
    362365 
    363           # Sort modules by id 
     366          # Sort modules by $sort_field (default sname) 
    364367          $modules = $this->getSearchQuery() === null ? 
    365                self::sortModules($this->modules, $sort_field, $this->sort_asc) : 
    366                $this->modules; 
     368               self::sortModules($this->data, $sort_field, $this->sort_asc) : 
     369               $this->data; 
    367370 
    368371          $count = 0; 
     
    425428 
    426429               if (!empty($actions) && $this->core->auth->isSuperAdmin()) { 
     430                    $buttons = $this->getActions($id, $module, $actions); 
     431 
    427432                    echo  
    428                     '<td class="module-actions nowrap">'; 
    429  
    430                     $this->displayLineActions($id, $module, $actions); 
    431  
    432                     echo 
     433                    '<td class="module-actions nowrap">'. 
     434 
     435                    '<form action="'.$this->getPageURL().'" method="post">'. 
     436                    '<div>'. 
     437                    $this->core->formNonce(). 
     438                    form::hidden(array('module'), html::escapeHTML($id)). 
     439                    form::hidden(array('tab'), $this->page_tab). 
     440 
     441                    implode(' ', $buttons). 
     442 
     443                    '</div>'. 
     444                    '</form>'. 
     445 
    433446                    '</td>'; 
    434447               } 
     
    448461     } 
    449462 
    450      protected function displayLineActions($id, $module, $actions, $echo=true) 
     463     protected function getActions($id, $module, $actions) 
    451464     { 
    452465          $submits = array(); 
    453466 
    454           # Update (from repository) 
    455           if (in_array('update', $actions) && $this->path_writable) { 
    456                $submits[] = '<input type="submit" name="update" value="'.__('Update').'" />'; 
    457           } 
    458  
    459           # Install (form repository) 
    460           if (in_array('install', $actions) && $this->path_writable) { 
    461                $submits[] = '<input type="submit" name="install" value="'.__('Install').'" />'; 
    462           } 
    463            
    464           $tmp = $this->displayOtherLineAction($id, $module, $actions); 
    465           if (!empty($tmp) && is_array($tmp)) { 
    466                $submits = array_merge($submits, $tmp); 
    467           } 
    468  
    469           # Activate 
    470           if (in_array('deactivate', $actions) && $module['root_writable']) { 
    471                $submits[] = '<input type="submit" name="deactivate" value="'.__('Deactivate').'" class="reset" />'; 
    472           } 
    473  
    474           # Deactivate 
    475           if (in_array('activate', $actions) && $module['root_writable']) { 
    476                $submits[] = '<input type="submit" name="activate" value="'.__('Activate').'" />'; 
    477           } 
    478  
    479           # Delete 
    480           if (in_array('delete', $actions) && $this->isPathDeletable($module['root'])) { 
    481                $submits[] = '<input type="submit" class="delete" name="delete" value="'.__('Delete').'" />'; 
    482           } 
    483  
    484           # Parse form 
    485           if (!empty($submits)) { 
    486                $res =  
    487                '<form action="'.$this->getPageURL().'" method="post">'. 
    488                '<div>'. 
    489                $this->core->formNonce(). 
    490                form::hidden(array('module'), html::escapeHTML($id)). 
    491                form::hidden(array('tab'), $this->page_tab). 
    492                implode(' ', $submits). 
    493                '</div>'. 
    494                '</form>'; 
    495  
    496                if (!$echo) { 
    497                     return $res; 
    498                } 
    499                echo $res; 
    500           } 
    501      } 
    502  
    503      protected function displayOtherLineAction($id, $module, $actions) 
    504      { 
    505           return null; 
    506      } 
    507  
    508      public function executeAction($prefix, dcModules $modules, dcRepository $repository) 
    509      { 
    510           if (!$this->core->auth->isSuperAdmin() || !$this->isPathWritable()) { 
     467          # Use loop to keep requested order 
     468          foreach($actions as $action) { 
     469               switch($action) { 
     470 
     471                    # Deactivate 
     472                    case 'activate': if ($module['root_writable']) { 
     473                         $submits[] =  
     474                         '<input type="submit" name="activate" value="'.__('Activate').'" />'; 
     475                    } break; 
     476 
     477                    # Activate 
     478                    case 'deactivate': if ($module['root_writable']) { 
     479                         $submits[] =  
     480                         '<input type="submit" name="deactivate" value="'.__('Deactivate').'" class="reset" />'; 
     481                    } break; 
     482 
     483                    # Delete 
     484                    case 'delete': if ($this->isPathDeletable($module['root'])) { 
     485                         $submits[] =  
     486                         '<input type="submit" class="delete" name="delete" value="'.__('Delete').'" />'; 
     487                    } break; 
     488 
     489                    # Install (from repository) 
     490                    case 'install': if ($this->path_writable) { 
     491                         $submits[] =  
     492                         '<input type="submit" name="install" value="'.__('Install').'" />'; 
     493                    } break; 
     494 
     495                    # Update (from repository) 
     496                    case 'update': if ($this->path_writable) { 
     497                         $submits[] =  
     498                         '<input type="submit" name="update" value="'.__('Update').'" />'; 
     499                    } break; 
     500               } 
     501          } 
     502 
     503          return $submits; 
     504     } 
     505 
     506     public function doActions($prefix) 
     507     { 
     508          if (empty($_POST) || !empty($_REQUEST['conf'])  
     509          || !$this->core->auth->isSuperAdmin() || !$this->isPathWritable()) { 
    511510               return null; 
    512511          } 
     
    519518               if (!empty($_POST['activate'])) { 
    520519 
    521                     $enabled = $modules->getDisabledModules(); 
     520                    $enabled = $this->modules->getDisabledModules(); 
    522521                    if (!isset($enabled[$id])) { 
    523522                         throw new Exception(__('No such module.')); 
     
    527526                    $this->core->callBehavior($prefix.'BeforeActivate', $id); 
    528527 
    529                     $modules->activateModule($id); 
     528                    $this->modules->activateModule($id); 
    530529 
    531530                    # --BEHAVIOR-- moduleAfterActivate 
     
    537536               elseif (!empty($_POST['deactivate'])) { 
    538537 
    539                     if (!$modules->moduleExists($id)) { 
     538                    if (!$this->modules->moduleExists($id)) { 
    540539                         throw new Exception(__('No such module.')); 
    541540                    } 
    542541 
    543                     $module = $modules->getModules($id); 
     542                    $module = $this->modules->getModules($id); 
    544543                    $module['id'] = $id; 
    545544 
     
    551550                    $this->core->callBehavior($prefix.'BeforeDeactivate', $module); 
    552551 
    553                     $modules->deactivateModule($id); 
     552                    $this->modules->deactivateModule($id); 
    554553 
    555554                    # --BEHAVIOR-- moduleAfterDeactivate 
     
    561560               elseif (!empty($_POST['delete'])) { 
    562561 
    563                     $disabled = $modules->getDisabledModules(); 
     562                    $disabled = $this->modules->getDisabledModules(); 
    564563                    if (!isset($disabled[$id])) { 
    565564 
    566                          if (!$modules->moduleExists($id)) { 
     565                         if (!$this->modules->moduleExists($id)) { 
    567566                              throw new Exception(__('No such module.')); 
    568567                         } 
    569568 
    570                          $module = $modules->getModules($id); 
     569                         $module = $this->modules->getModules($id); 
    571570                         $module['id'] = $id; 
    572571 
     
    578577                         $this->core->callBehavior($prefix.'BeforeDelete', $module); 
    579578 
    580                          $modules->deleteModule($id); 
     579                         $this->modules->deleteModule($id); 
    581580 
    582581                         # --BEHAVIOR-- moduleAfterDelete 
     
    584583                    } 
    585584                    else { 
    586                          $modules->deleteModule($id, true); 
     585                         $this->modules->deleteModule($id, true); 
    587586                    } 
    588587 
    589588                    http::redirect($this->getPageURL('msg=delete')); 
     589               } 
     590 
     591               elseif (!empty($_POST['install'])) { 
     592 
     593                    $updated = $this->repository->get(); 
     594                    if (!isset($updated[$id])) { 
     595                         throw new Exception(__('No such module.')); 
     596                    } 
     597 
     598                    $module = $updated[$id]; 
     599                    $module['id'] = $id; 
     600 
     601                    $dest = $this->getPath().'/'.basename($module['file']); 
     602 
     603                    # --BEHAVIOR-- moduleBeforeAdd 
     604                    $this->core->callBehavior($prefix.'BeforeAdd', $module); 
     605 
     606                    $ret_code = $this->repository->process($module['file'], $dest); 
     607 
     608                    # --BEHAVIOR-- moduleAfterAdd 
     609                    $this->core->callBehavior($prefix.'AfterAdd', $module); 
     610 
     611                    http::redirect($this->getPageURL('msg='.($ret_code == 2 ? 'update' : 'install'))); 
    590612               } 
    591613 
     
    597619                    } 
    598620 
    599                     if (!$modules->moduleExists($id)) { 
     621                    if (!$this->modules->moduleExists($id)) { 
    600622                         throw new Exception(__('No such module.')); 
    601623                    } 
     
    617639                    $this->core->callBehavior($prefix.'BeforeUpdate', $module); 
    618640 
    619                     $repository->process($module['file'], $dest); 
     641                    $this->repository->process($module['file'], $dest); 
    620642 
    621643                    # --BEHAVIOR-- moduleAfterUpdate 
     
    623645 
    624646                    http::redirect($this->getPageURL('msg=upadte')); 
    625                } 
    626  
    627                elseif (!empty($_POST['install'])) { 
    628  
    629                     $updated = $repository->get(); 
    630                     if (!isset($updated[$id])) { 
    631                          throw new Exception(__('No such module.')); 
    632                     } 
    633  
    634                     $module = $updated[$id]; 
    635                     $module['id'] = $id; 
    636  
    637                     $dest = $this->getPath().'/'.basename($module['file']); 
    638  
    639                     # --BEHAVIOR-- moduleBeforeAdd 
    640                     $this->core->callBehavior($prefix.'BeforeAdd', $module); 
    641  
    642                     $ret_code = $repository->process($module['file'], $dest); 
    643  
    644                     # --BEHAVIOR-- moduleAfterAdd 
    645                     $this->core->callBehavior($prefix.'AfterAdd', $module); 
    646  
    647                     http::redirect($this->getPageURL('msg='.($ret_code == 2 ? 'update' : 'install'))); 
    648647               } 
    649648          } 
     
    667666                    $url = urldecode($_POST['pkg_url']); 
    668667                    $dest = $this->getPath().'/'.basename($url); 
    669                     $repository->download($url, $dest); 
     668                    $this->repository->download($url, $dest); 
    670669               } 
    671670 
     
    673672               $this->core->callBehavior($prefix.'BeforeAdd', null); 
    674673 
    675                $ret_code = $repository->install($dest); 
     674               $ret_code = $this->repository->install($dest); 
    676675 
    677676               # --BEHAVIOR-- moduleAfterAdd 
     
    681680          } 
    682681 
    683           return $this->executeOtherAction($prefix, $modules, $repository); 
    684      } 
    685  
    686      /** 
    687       *  
    688       * Way for child class to execute their own actions  
    689       * whitout rewriting all standard actions. 
    690       */ 
    691      protected function executeOtherAction($prefix, dcModules $modules, dcRepository $repository) 
    692      { 
    693682          return null; 
    694683     } 
     
    740729      * 
    741730      */ 
    742      public function setConfigurationFile(dcModules $modules, $id=null) 
     731     public function setConfigurationFile($id=null) 
    743732     { 
    744733          if (empty($_REQUEST['conf']) || empty($_REQUEST['module']) && !$id) { 
     
    750739          } 
    751740 
    752           if (!$modules->moduleExists($id)) { 
     741          if (!$this->modules->moduleExists($id)) { 
    753742               $core->error->add(__('Unknow module ID')); 
    754743               return false; 
    755744          } 
    756745 
    757           $module = $modules->getModules($id); 
     746          $module = $this->modules->getModules($id); 
    758747          $module = self::parseModuleInfo($id, $module); 
    759748          $file = path::real($module['root'].'/_config.php'); 
     
    842831          # Sort modules by id 
    843832          $modules = $this->getSearchQuery() === null ? 
    844                self::sortModules($this->modules, $sort_field, $this->sort_asc) : 
    845                $this->modules; 
     833               self::sortModules($this->data, $sort_field, $this->sort_asc) : 
     834               $this->data; 
    846835 
    847836          $res = ''; 
     
    861850 
    862851               $current = $this->core->blog->settings->system->theme == $id; 
    863  
    864                if (preg_match('#^http(s)?://#', $this->core->blog->settings->system->themes_url)) { 
    865                     $theme_url = http::concatURL($this->core->blog->settings->system->themes_url, '/'.$id); 
    866                } else { 
    867                     $theme_url = http::concatURL($this->core->blog->url, $this->core->blog->settings->system->themes_url.'/'.$id); 
    868                } 
     852               $distrib = self::isDistributedModule($id) ? ' dc-box' : ''; 
     853 
     854               $theme_url = preg_match('#^http(s)?://#', $this->core->blog->settings->system->themes_url) ? 
     855                    http::concatURL($this->core->blog->settings->system->themes_url, '/'.$id) : 
     856                    http::concatURL($this->core->blog->url, $this->core->blog->settings->system->themes_url.'/'.$id); 
    869857 
    870858               $has_conf = file_exists(path::real($this->core->blog->themes_path.'/'.$id).'/_config.php'); 
     
    877865 
    878866               $line =  
    879                '<div class="box '.($current ? 'medium current-theme' : 'small theme').'">'; 
     867               '<div class="box '.($current ? 'medium current-theme' : 'small theme').$distrib.'">'; 
    880868 
    881869               if (in_array('name', $cols)) { 
     
    899887 
    900888                    $line .=  
    901                     '<div class="module-sshot"><img src="'.$sshot.'" alt="'.__('screenshot.').'" /></div>'; 
     889                    '<div class="module-sshot"><img src="'.$sshot.'" alt="'. 
     890                    sprintf(__('%s screenshot.'), html::escapeHTML($module['name'])).'" /></div>'; 
    902891               } 
    903892 
     
    930919                         '<span class="module-parent-missing">'.sprintf(__('(requires "%s")'),html::escapeHTML($parent)).'</span> '; 
    931920                    } 
     921               } 
     922 
     923               if (in_array('version', $cols)) { 
     924                    $line .=  
     925                    '<span class="module-version">'.sprintf(__('version %s'),html::escapeHTML($module['version'])).'</span> '; 
     926               } 
     927 
     928               $has_details = in_array('details', $cols) && !empty($module['details']); 
     929               $has_support = in_array('support', $cols) && !empty($module['support']); 
     930               if ($has_details || $has_support) { 
     931                    $line .= 
     932                    '<span class="mod-more">'.__('Help:').' '; 
     933 
     934                    if ($has_details) { 
     935                         $line .=  
     936                         '<a class="module-details" href="'.$module['details'].'">'.__('Details').'</a>'; 
     937                    } 
     938 
     939                    if ($has_support) { 
     940                         $line .=  
     941                         ' - <a class="module-support" href="'.$module['support'].'">'.__('Support').'</a>'; 
     942                    } 
     943 
     944                    $line .= 
     945                    '</span>'; 
    932946               } 
    933947 
     
    958972 
    959973               # _POST actions 
    960                if (!empty($actions) && $this->core->auth->isSuperAdmin()) { 
     974               if (!empty($actions)) { 
    961975                    $line .= 
    962                     $this->displayLineActions($id, $module, $actions, false); 
     976                    '<form action="'.$this->getPageURL().'" method="post">'. 
     977                    '<div>'. 
     978                    $this->core->formNonce(). 
     979                    form::hidden(array('module'), html::escapeHTML($id)). 
     980                    form::hidden(array('tab'), $this->page_tab). 
     981 
     982                    implode(' ', $this->getActions($id, $module, $actions)). 
     983  
     984                    '</div>'. 
     985                    '</form>'; 
    963986               } 
    964987 
     
    9831006     } 
    9841007 
    985      protected function displayOtherLineAction($id, $module, $actions) 
     1008     protected function getActions($id, $module, $actions) 
    9861009     { 
    9871010          $submits = array(); 
    9881011 
    9891012          $this->core->blog->settings->addNamespace('system'); 
    990           if ($id == $this->core->blog->settings->system->theme) { 
    991                return null; 
    992           } 
    993  
    994           # Select theme to use on curent blog 
    995           if (in_array('select', $actions) && $this->path_writable) { 
    996                $submits[] = '<input type="submit" name="select" value="'.__('Choose').'" />'; 
    997           } 
    998  
    999           return $submits; 
    1000      } 
    1001       
    1002      protected function executeOtherAction($prefix, dcModules $modules, dcRepository $repository) 
    1003      { 
    1004           # Select theme to use on curent blog 
    1005           if (!empty($_POST['module']) && !empty($_POST['select'])) { 
    1006                $id = $_POST['module']; 
    1007  
    1008                if (!$modules->moduleExists($id)) { 
    1009                     throw new Exception(__('No such module.')); 
    1010                } 
    1011  
    1012                $this->core->blog->settings->addNamespace('system'); 
    1013                $this->core->blog->settings->system->put('theme',$id); 
    1014                $this->core->blog->triggerBlog(); 
    1015  
    1016                http::redirect($this->getPageURL('msg=select').'#themes'); 
    1017           } 
    1018  
    1019           return null; 
     1013          if ($id != $this->core->blog->settings->system->theme) { 
     1014 
     1015               # Select theme to use on curent blog 
     1016               if (in_array('select', $actions) && $this->path_writable) { 
     1017                    $submits[] = '<input type="submit" name="select" value="'.__('Choose').'" />'; 
     1018               } 
     1019          } 
     1020 
     1021          return array_merge( 
     1022               $submits, 
     1023               parent::getActions($id, $module, $actions) 
     1024          ); 
     1025     } 
     1026 
     1027     public function doActions($prefix) 
     1028     { 
     1029          if (!empty($_POST) && empty($_REQUEST['conf']) && $this->isPathWritable()) { 
     1030 
     1031               # Select theme to use on curent blog 
     1032               if (!empty($_POST['module']) && !empty($_POST['select'])) { 
     1033                    $id = $_POST['module']; 
     1034 
     1035                    if (!$this->modules->moduleExists($id)) { 
     1036                         throw new Exception(__('No such module.')); 
     1037                    } 
     1038 
     1039                    $this->core->blog->settings->addNamespace('system'); 
     1040                    $this->core->blog->settings->system->put('theme',$id); 
     1041                    $this->core->blog->triggerBlog(); 
     1042 
     1043                    http::redirect($this->getPageURL('msg=select').'#themes'); 
     1044               } 
     1045          } 
     1046 
     1047          return parent::doActions($prefix); 
    10201048     } 
    10211049} 
  • inc/core/class.dc.repository.php

    r2214 r2215  
    4444          $this->xml_url = $xml_url; 
    4545          $this->user_agent = sprintf('Dotclear/%s)', DC_VERSION); 
     46 
     47          $this->check(); 
    4648     } 
    4749 
  • plugins/maintenance/_config.php

    r2182 r2215  
    6161 
    6262     echo  
    63      '<p>'.__('Manage alert for maintenance task.').'</p>'. 
     63     '<p>'.__('Setup alert for maintenance task.').'</p>'. 
    6464 
    6565     '<h4 class="pretty-title">'.__('Activation').'</h4>'. 
Note: See TracChangeset for help on using the changeset viewer.

Sites map