Dotclear

Changeset 2227:bfa7b3467627


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

Continue clean and document code for plugins and themes admin pages

Files:
6 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 */ 
  • inc/admin/lib.moduleslist.php

    r2222 r2227  
    1212if (!defined('DC_ADMIN_CONTEXT')) { return; } 
    1313 
     14/** 
     15 * @ingroup DC_CORE 
     16 * @brief Helper for admin list of modules. 
     17 * @since 2.6 
     18 
     19 * Provides an object to parse XML feed of modules from a repository. 
     20 */ 
    1421class adminModulesList 
    1522{ 
    16      public $core; 
    17      public $modules; 
    18      public $store; 
    19  
    20      public static $allow_multi_install = false; 
    21      public static $distributed_modules = array(); 
    22  
    23      protected $list_id = 'unknow'; 
    24      protected $data = array(); 
    25  
    26      protected $config_module = ''; 
    27      protected $config_file = ''; 
    28      protected $config_content = ''; 
    29  
    30      protected $path = false; 
    31      protected $path_writable = false; 
    32      protected $path_pattern = false; 
    33  
    34      protected $page_url = 'plugins.php'; 
    35      protected $page_qs = '?'; 
    36      protected $page_tab = ''; 
    37  
    38      public static $nav_indexes = 'abcdefghijklmnopqrstuvwxyz0123456789'; 
    39      protected $nav_list = array(); 
    40      protected $nav_special = 'other'; 
    41  
    42      protected $sort_field = 'sname'; 
    43      protected $sort_asc = true; 
    44  
     23     public $core;       /**< @var object    dcCore instance */ 
     24     public $modules;    /**< @var object    dcModules instance */ 
     25     public $store;      /**< @var object    dcStore instance */ 
     26 
     27     public static $allow_multi_install = false;       /**< @var boolean   Work with multiple root directories */ 
     28     public static $distributed_modules = array();     /**< @var array     List of modules distributed with Dotclear */ 
     29 
     30     protected $list_id = 'unknow';     /**< @var string    Current list ID */ 
     31     protected $data = array();         /**< @var array     Current modules */ 
     32 
     33     protected $config_module = '';     /**< @var string    Module ID to configure */ 
     34     protected $config_file = '';  /**< @var string    Module path to configure */ 
     35     protected $config_content = '';    /**< @var string    Module configuration page content */ 
     36 
     37     protected $path = false;           /**< @var string    Modules root directory */ 
     38     protected $path_writable = false;  /**< @var boolean   Indicate if modules root directory is writable */ 
     39     protected $path_pattern = false;   /**< @var string    Directory pattern to work on */ 
     40 
     41     protected $page_url = 'plugins.php';    /**< @var string    Page URL */ 
     42     protected $page_qs = '?';                    /**< @var string    Page query string */ 
     43     protected $page_tab = '';                    /**< @var string    Page tab */ 
     44 
     45     public static $nav_indexes = 'abcdefghijklmnopqrstuvwxyz0123456789'; /**< @var  string    Index list */ 
     46     protected $nav_list = array();          /**< @var array     Index list with special index */ 
     47     protected $nav_special = 'other';  /**< @var string    Text for other special index */ 
     48 
     49     protected $sort_field = 'sname';   /**< @var string    Field used to sort modules */ 
     50     protected $sort_asc = true;             /**< @var boolean   Sort order asc */ 
     51 
     52     /** 
     53      * Constructor. 
     54      * 
     55      * Note that this creates dcStore instance. 
     56      * 
     57      * @param object    $modules       dcModules instance 
     58      * @param string    $modules_root  Modules root directories 
     59      * @param string    $xml_url       URL of modules feed from repository 
     60      */ 
    4561     public function __construct(dcModules $modules, $modules_root, $xml_url) 
    4662     { 
     
    4965          $this->store = new dcStore($modules, $xml_url); 
    5066 
    51           $this->setPathInfo($modules_root); 
    52           $this->setNavSpecial(__('other')); 
    53      } 
    54  
    55      public function newList($list_id) 
     67          $this->setPath($modules_root); 
     68          $this->setIndex(__('other')); 
     69     } 
     70 
     71     /** 
     72      * Begin a new list. 
     73      * 
     74      * @param string    $id       New list ID 
     75      * @return     adminModulesList self instance 
     76      */ 
     77     public function initList($id) 
    5678     { 
    5779          $this->data = array(); 
    5880          $this->page_tab = ''; 
    59           $this->list_id = $list_id; 
     81          $this->list_id = $id; 
    6082 
    6183          return $this; 
    6284     } 
    6385 
    64      protected function setPathInfo($root) 
     86     /// @name Modules root directory methods 
     87     //@{ 
     88     /** 
     89      * Set path info. 
     90      * 
     91      * @param string    $root          Modules root directories 
     92      * @return     adminModulesList self instance 
     93      */ 
     94     protected function setPath($root) 
    6595     { 
    6696          $paths = explode(PATH_SEPARATOR, $root); 
     
    77107     } 
    78108 
     109     /** 
     110      * Get modules root directory. 
     111      * 
     112      * @return     Path to work on 
     113      */ 
    79114     public function getPath() 
    80115     { 
     
    82117     } 
    83118 
    84      public function isPathWritable() 
     119     /** 
     120      * Check if modules root directory is writable. 
     121      * 
     122      * @return     True if directory is writable 
     123      */ 
     124     public function isWritablePath() 
    85125     { 
    86126          return $this->path_writable; 
    87127     } 
    88128 
    89      public function isPathDeletable($root) 
     129     /** 
     130      * Check if root directory of a module is deletable. 
     131      * 
     132      * @param string    $root          Module root directory 
     133      * @return     True if directory is delatable 
     134      */ 
     135     public function isDeletablePath($root) 
    90136     { 
    91137          return $this->path_writable  
     
    93139               && $this->core->auth->isSuperAdmin(); 
    94140     } 
    95  
    96      public function setPageURL($url) 
     141     //@} 
     142 
     143     /// @name Page methods 
     144     //@{ 
     145     /** 
     146      * Set page base URL. 
     147      * 
     148      * @param string    $url      Page base URL 
     149      * @return     adminModulesList self instance 
     150      */ 
     151     public function setURL($url) 
    97152     { 
    98153          $this->page_qs = strpos('?', $url) ? '&' : '?'; 
     
    102157     } 
    103158 
    104      public function getPageURL($queries='', $with_tab=true) 
     159     /** 
     160      * Get page URL. 
     161      * 
     162      * @param string|array   $queries  Additionnal query string 
     163      * @param booleany  $with_tab      Add current tab to URL end 
     164      * @return     Clean page URL 
     165      */ 
     166     public function getURL($queries='', $with_tab=true) 
    105167     { 
    106168          return $this->page_url. 
     
    110172     } 
    111173 
    112      public function setPageTab($tab) 
     174     /** 
     175      * Set page tab. 
     176      * 
     177      * @param string    $tab      Page tab 
     178      * @return     adminModulesList self instance 
     179      */ 
     180     public function setTab($tab) 
    113181     { 
    114182          $this->page_tab = $tab; 
     
    117185     } 
    118186 
    119      public function getPageTab() 
     187     /** 
     188      * Get page tab. 
     189      * 
     190      * @return     Page tab 
     191      */ 
     192     public function getTab() 
    120193     { 
    121194          return $this->page_tab; 
    122195     } 
    123  
    124      public function getSearchQuery() 
     196     //@} 
     197 
     198     /// @name Search methods 
     199     //@{ 
     200     /** 
     201      * Get search query. 
     202      * 
     203      * @return     Search query 
     204      */ 
     205     public function getSearch() 
    125206     { 
    126207          $query = !empty($_REQUEST['m_search']) ? trim($_REQUEST['m_search']) : null; 
    127           return strlen($query) > 1 ? $query : null; 
    128      } 
    129  
    130      public function displaySearchForm() 
    131      { 
    132           $query = $this->getSearchQuery(); 
     208          return strlen($query) > 2 ? $query : null; 
     209     } 
     210 
     211     /** 
     212      * Display searh form. 
     213      * 
     214      * @return     adminModulesList self instance 
     215      */ 
     216     public function displaySearch() 
     217     { 
     218          $query = $this->getSearch(); 
    133219 
    134220          if (empty($this->data) && $query === null) { 
     
    137223 
    138224          echo  
    139           '<form action="'.$this->getPageURL().'" method="get" class="fieldset">'. 
     225          '<form action="'.$this->getURL().'" method="get" class="fieldset">'. 
    140226          '<p><label for="m_search" class="classic">'.__('Search in repository:').'&nbsp;</label><br />'. 
    141227          form::field(array('m_search','m_search'), 30, 255, html::escapeHTML($query)). 
    142228          '<input type="submit" value="'.__('Search').'" /> '; 
    143           if ($query) { echo ' <a href="'.$this->getPageURL().'" class="button">'.__('Reset search').'</a>'; } 
     229          if ($query) { echo ' <a href="'.$this->getURL().'" class="button">'.__('Reset search').'</a>'; } 
    144230          echo '</p>'. 
    145231          '</form>'; 
     
    155241          return $this; 
    156242     } 
    157  
    158      public function setNavSpecial($str) 
     243     //@} 
     244 
     245     /// @name Navigation menu methods 
     246     //@{ 
     247     /** 
     248      * Set navigation special index. 
     249      * 
     250      * @return     adminModulesList self instance 
     251      */ 
     252     public function setIndex($str) 
    159253     { 
    160254          $this->nav_special = (string) $str; 
     
    164258     } 
    165259 
    166      public function getNavQuery() 
     260     /** 
     261      * Get index from query. 
     262      * 
     263      * @return     Query index or default one 
     264      */ 
     265     public function getIndex() 
    167266     { 
    168267          return isset($_REQUEST['m_nav']) && in_array($_REQUEST['m_nav'], $this->nav_list) ? $_REQUEST['m_nav'] : $this->nav_list[0]; 
    169268     } 
    170269 
    171      public function displayNavMenu() 
    172      { 
    173           if (empty($this->data) || $this->getSearchQuery() !== null) { 
     270     /** 
     271      * Display navigation by index menu. 
     272      * 
     273      * @return     adminModulesList self instance 
     274      */ 
     275     public function displayIndex() 
     276     { 
     277          if (empty($this->data) || $this->getSearch() !== null) { 
    174278               return $this; 
    175279          } 
     
    194298          foreach($this->nav_list as $char) { 
    195299               # Selected letter 
    196                if ($this->getNavQuery() == $char) { 
     300               if ($this->getIndex() == $char) { 
    197301                    $buttons[] = '<li class="active" title="'.__('current selection').'"><strong> '.$char.' </strong></li>'; 
    198302               } 
     
    200304               elseif (!empty($indexes[$char])) { 
    201305                    $title = sprintf(__('%d module', '%d modules', $indexes[$char]), $indexes[$char]); 
    202                     $buttons[] = '<li class="btn" title="'.$title.'"><a href="'.$this->getPageURL('m_nav='.$char).'" title="'.$title.'"> '.$char.' </a></li>'; 
     306                    $buttons[] = '<li class="btn" title="'.$title.'"><a href="'.$this->getURL('m_nav='.$char).'" title="'.$title.'"> '.$char.' </a></li>'; 
    203307               } 
    204308               # Letter without modules 
     
    212316          return $this; 
    213317     } 
    214  
    215      public function setSortField($field, $asc=true) 
     318     //@} 
     319 
     320     /// @name Sort methods 
     321     //@{ 
     322     /** 
     323      * Set default sort field. 
     324      * 
     325      * @return     adminModulesList self instance 
     326      */ 
     327     public function setSort($field, $asc=true) 
    216328     { 
    217329          $this->sort_field = $field; 
     
    221333     } 
    222334 
    223      public function getSortQuery() 
     335     /** 
     336      * Get sort field from query. 
     337      * 
     338      * @return     Query sort field or default one 
     339      */ 
     340     public function getSort() 
    224341     { 
    225342          return !empty($_REQUEST['m_sort']) ? $_REQUEST['m_sort'] : $this->sort_field; 
    226343     } 
    227344 
    228      public function displaySortForm() 
    229      { 
    230           //not yet implemented 
    231      } 
    232  
     345     /** 
     346      * Display sort field form. 
     347      * 
     348      * @note  This method is not implemented yet 
     349      * @return     adminModulesList self instance 
     350      */ 
     351     public function displaySort() 
     352     { 
     353          // 
     354 
     355          return $this; 
     356     } 
     357     //@} 
     358 
     359     /// @name Modules methods 
     360     //@{ 
     361     /** 
     362      * Set modules and sanitize them. 
     363      * 
     364      * @return     adminModulesList self instance 
     365      */ 
    233366     public function setModules($modules) 
    234367     { 
     
    236369          if (!empty($modules) && is_array($modules)) { 
    237370               foreach($modules as $id => $module) { 
    238                     $this->data[$id] = self::parseModuleInfo($id, $module); 
     371                    $this->data[$id] = self::sanitizeModule($id, $module); 
    239372               } 
    240373          } 
     
    242375     } 
    243376 
     377     /** 
     378      * Get modules currently set. 
     379      * 
     380      * @return     Array of modules 
     381      */ 
    244382     public function getModules() 
    245383     { 
     
    247385     } 
    248386 
    249      public static function parseModuleInfo($id, $module) 
     387     /** 
     388      * Sanitize a module. 
     389      * 
     390      * This clean infos of a module by adding default keys  
     391      * and clean some of them, sanitize module can safely  
     392      * be used in lists. 
     393      * 
     394      * @return     Array of the module informations 
     395      */ 
     396     public static function sanitizeModule($id, $module) 
    250397     { 
    251398          $label = empty($module['label']) ? $id : $module['label']; 
     
    285432     } 
    286433 
    287      public static function isDistributedModule($module) 
     434     /** 
     435      * Check if a module is part of the distribution. 
     436      * 
     437      * @param string    $id       Module root directory 
     438      * @return     True if module is part of the distribution 
     439      */ 
     440     public static function isDistributedModule($id) 
    288441     { 
    289442          $distributed_modules = self::$distributed_modules; 
    290443 
    291           return is_array($distributed_modules) && in_array($module, $distributed_modules); 
    292      } 
    293  
     444          return is_array($distributed_modules) && in_array($id, $distributed_modules); 
     445     } 
     446 
     447     /** 
     448      * Sort modules list by specific field. 
     449      * 
     450      * @param string    $module        Array of modules 
     451      * @param string    $field         Field to sort from 
     452      * @param bollean   $asc      Sort asc if true, else decs 
     453      * @return     Array of sorted modules 
     454      */ 
    294455     public static function sortModules($modules, $field, $asc=true) 
    295456     { 
     
    303464     } 
    304465 
    305      public function displayModulesList($cols=array('name', 'config', 'version', 'desc'), $actions=array(), $nav_limit=false) 
     466     /** 
     467      * Display list of modules. 
     468      * 
     469      * @param array     $cols          List of colones (module field) to display 
     470      * @param array     $actions  List of predefined actions to show on form 
     471      * @param boolean   $nav_limit     Limit list to previously selected index 
     472      * @return     adminModulesList self instance 
     473      */ 
     474     public function displayModules($cols=array('name', 'version', 'desc'), $actions=array(), $nav_limit=false) 
    306475     { 
    307476          echo  
     
    315484          } 
    316485 
    317           if (in_array('score', $cols) && $this->getSearchQuery() !== null && defined('DC_DEBUG') && DC_DEBUG) { 
     486          if (in_array('score', $cols) && $this->getSearch() !== null && defined('DC_DEBUG') && DC_DEBUG) { 
    318487               echo  
    319488               '<th class="nowrap">'.__('Score').'</th>'; 
     
    347516          '</tr>'; 
    348517 
    349           $sort_field = $this->getSortQuery(); 
     518          $sort_field = $this->getSort(); 
    350519 
    351520          # Sort modules by $sort_field (default sname) 
    352           $modules = $this->getSearchQuery() === null ? 
     521          $modules = $this->getSearch() === null ? 
    353522               self::sortModules($this->data, $sort_field, $this->sort_asc) : 
    354523               $this->data; 
     
    358527          { 
    359528               # Show only requested modules 
    360                if ($nav_limit && $this->getSearchQuery() === null) { 
     529               if ($nav_limit && $this->getSearch() === null) { 
    361530                    $char = substr($module[$sort_field], 0, 1); 
    362531                    if (!in_array($char, $this->nav_list)) { 
    363532                         $char = $this->nav_special; 
    364533                    } 
    365                     if ($this->getNavQuery() != $char) { 
     534                    if ($this->getIndex() != $char) { 
    366535                         continue; 
    367536                    } 
     
    384553               echo  
    385554               '<td class="module-name nowrap" scope="row">'.($config ?  
    386                     '<a href="'.$this->getPageURL('module='.$id.'&conf=1').'" title"'.sprintf(__('Configure module "%s"'), html::escapeHTML($module['name'])).'">'.html::escapeHTML($module['name']).'</a>' :  
     555                    '<a href="'.$this->getURL('module='.$id.'&conf=1').'" title"'.sprintf(__('Configure module "%s"'), html::escapeHTML($module['name'])).'">'.html::escapeHTML($module['name']).'</a>' :  
    387556                    html::escapeHTML($module['name']) 
    388557               ).'</td>'; 
    389558 
    390559               # Display score only for debug purpose 
    391                if (in_array('score', $cols) && $this->getSearchQuery() !== null && defined('DC_DEBUG') && DC_DEBUG) { 
     560               if (in_array('score', $cols) && $this->getSearch() !== null && defined('DC_DEBUG') && DC_DEBUG) { 
    392561                    echo  
    393562                    '<td class="module-version nowrap count"><span class="debug">'.$module['score'].'</span></td>'; 
     
    424593                    '<td class="module-actions nowrap">'. 
    425594 
    426                     '<form action="'.$this->getPageURL().'" method="post">'. 
     595                    '<form action="'.$this->getURL().'" method="post">'. 
    427596                    '<div>'. 
    428597                    $this->core->formNonce(). 
    429598                    form::hidden(array('module'), html::escapeHTML($id)). 
    430                     form::hidden(array('tab'), $this->page_tab). 
    431599 
    432600                    implode(' ', $buttons). 
     
    446614          '</table></div>'; 
    447615 
    448           if(!$count && $this->getSearchQuery() === null) { 
     616          if(!$count && $this->getSearch() === null) { 
    449617               echo  
    450618               '<p class="message">'.__('No module matches your search.').'</p>'; 
    451619          } 
    452      } 
    453  
     620 
     621          return $this; 
     622     } 
     623 
     624     /** 
     625      * Get action buttons to add to modules list. 
     626      * 
     627      * @param string    $id            Module ID 
     628      * @param array     $module        Module info 
     629      * @param array     $actions  Actions keys 
     630      * @return     Array of actions buttons 
     631      */ 
    454632     protected function getActions($id, $module, $actions) 
    455633     { 
     
    473651 
    474652                    # Delete 
    475                     case 'delete': if ($this->isPathDeletable($module['root'])) { 
     653                    case 'delete': if ($this->isDeletablePath($module['root'])) { 
    476654                         $submits[] =  
    477655                         '<input type="submit" class="delete" name="delete" value="'.__('Delete').'" />'; 
     
    495673     } 
    496674 
     675     /** 
     676      * Execute POST action. 
     677      * 
     678      * @note  Set a notice on success through dcPage::addSuccessNotice 
     679      * @throw Exception Module not find or command failed 
     680      * @param string    $prefix        Prefix used on behaviors 
     681      * @return     Null 
     682      */ 
    497683     public function doActions($prefix) 
    498684     { 
    499685          if (empty($_POST) || !empty($_REQUEST['conf'])  
    500           || !$this->core->auth->isSuperAdmin() || !$this->isPathWritable()) { 
     686          || !$this->core->auth->isSuperAdmin() || !$this->isWritablePath()) { 
    501687               return null; 
    502688          } 
     
    523709 
    524710                    dcPage::addSuccessNotice(__('Module has been successfully activated.')); 
    525                     http::redirect($this->getPageURL()); 
     711                    http::redirect($this->getURL()); 
    526712               } 
    527713 
     
    548734 
    549735                    dcPage::addSuccessNotice(__('Module has been successfully deactivated.')); 
    550                     http::redirect($this->getPageURL()); 
     736                    http::redirect($this->getURL()); 
    551737               } 
    552738 
     
    563749                         $module['id'] = $id; 
    564750 
    565                          if (!$this->isPathDeletable($module['root'])) { 
     751                         if (!$this->isDeletablePath($module['root'])) { 
    566752                              throw new Exception(__("You don't have permissions to delete this module.")); 
    567753                         } 
     
    580766 
    581767                    dcPage::addSuccessNotice(__('Module has been successfully deleted.')); 
    582                     http::redirect($this->getPageURL()); 
     768                    http::redirect($this->getURL()); 
    583769               } 
    584770 
     
    607793                         __('Module has been successfully installed.') 
    608794                    ); 
    609                     http::redirect($this->getPageURL()); 
     795                    http::redirect($this->getURL()); 
    610796               } 
    611797 
     
    623809                    $module = $updated[$id]; 
    624810                    $module['id'] = $id; 
    625                 
     811 
    626812                    if (!self::$allow_multi_install) { 
    627813                         $dest = $module['root'].'/../'.basename($module['file']); 
     
    643829 
    644830                    dcPage::addSuccessNotice(__('Module has been successfully updated.')); 
    645                     http::redirect($this->getPageURL()); 
     831                    http::redirect($this->getURL()); 
    646832               } 
    647833          } 
     
    680866                    __('Module has been successfully installed.') 
    681867               ); 
    682                http::redirect($this->getPageURL().'#'.$prefix); 
     868               http::redirect($this->getURL().'#'.$prefix); 
    683869          } 
    684870 
     
    686872     } 
    687873 
     874     /** 
     875      * Display tab for manual installation. 
     876      * 
     877      * @return     adminModulesList self instance 
     878      */ 
    688879     public function displayManualForm() 
    689880     { 
    690           if (!$this->core->auth->isSuperAdmin() || !$this->isPathWritable()) { 
     881          if (!$this->core->auth->isSuperAdmin() || !$this->isWritablePath()) { 
    691882               return null; 
    692883          } 
     
    694885          # 'Upload module' form 
    695886          echo 
    696           '<form method="post" action="'.$this->getPageURL().'" id="uploadpkg" enctype="multipart/form-data" class="fieldset">'. 
     887          '<form method="post" action="'.$this->getURL().'" id="uploadpkg" enctype="multipart/form-data" class="fieldset">'. 
    697888          '<h4>'.__('Upload a zip file').'</h4>'. 
    698889          '<p class="field"><label for="pkg_file" class="classic required"><abbr title="'.__('Required field').'">*</abbr> '.__('Zip file path:').'</label> '. 
     
    701892          form::password(array('your_pwd','your_pwd1'),20,255).'</p>'. 
    702893          '<p><input type="submit" name="upload_pkg" value="'.__('Upload').'" />'. 
    703           form::hidden(array('tab'), $this->getPageTab()). 
    704894          $this->core->formNonce().'</p>'. 
    705895          '</form>'; 
    706            
     896 
    707897          # 'Fetch module' form 
    708898          echo 
    709           '<form method="post" action="'.$this->getPageURL().'" id="fetchpkg" class="fieldset">'. 
     899          '<form method="post" action="'.$this->getURL().'" id="fetchpkg" class="fieldset">'. 
    710900          '<h4>'.__('Download a zip file').'</h4>'. 
    711901          '<p class="field"><label for="pkg_url" class="classic required"><abbr title="'.__('Required field').'">*</abbr> '.__('Zip file URL:').'</label> '. 
     
    714904          form::password(array('your_pwd','your_pwd2'),20,255).'</p>'. 
    715905          '<p><input type="submit" name="fetch_pkg" value="'.__('Download').'" />'. 
    716           form::hidden(array('tab'), $this->getPageTab()). 
    717906          $this->core->formNonce().'</p>'. 
    718907          '</form>'; 
    719      } 
    720  
    721      /** 
     908 
     909          return $this; 
     910     } 
     911     //@} 
     912 
     913     /// @name Module configuration methods 
     914     //@{ 
     915     /** 
     916      * Prepare module configuration. 
    722917      * 
    723918      * We need to get configuration content in three steps 
    724919      * and out of this class to keep backward compatibility. 
    725920      * 
    726       * if ($xxx->setConfigurationFile()) { 
    727       *   include $xxx->getConfigurationFile(); 
     921      * if ($xxx->setConfiguration()) { 
     922      *   include $xxx->includeConfiguration(); 
    728923      * } 
    729       * $xxx->setConfigurationContent(); 
     924      * $xxx->getConfiguration(); 
    730925      * ... [put here page headers and other stuff] 
    731       * $xxx->getConfigurationContent(); 
    732       * 
    733       */ 
    734      public function setConfigurationFile($id=null) 
     926      * $xxx->displayConfiguration(); 
     927      * 
     928      * @param string    $id       Module to work on or it gather through REQUEST 
     929      * @return     True if config set 
     930      */ 
     931     public function setConfiguration($id=null) 
    735932     { 
    736933          if (empty($_REQUEST['conf']) || empty($_REQUEST['module']) && !$id) { 
     
    748945 
    749946          $module = $this->modules->getModules($id); 
    750           $module = self::parseModuleInfo($id, $module); 
     947          $module = self::sanitizeModule($id, $module); 
    751948          $file = path::real($module['root'].'/_config.php'); 
    752949 
     
    767964     } 
    768965 
    769      public function getConfigurationFile() 
     966     /** 
     967      * Get path of module configuration file. 
     968      * 
     969      * @note Required previously set file info 
     970      * @return Full path of config file or null 
     971      */ 
     972     public function includeConfiguration() 
    770973     { 
    771974          if (!$this->config_file) { 
     
    778981     } 
    779982 
    780      public function setConfigurationContent() 
     983     /** 
     984      * Gather module configuration file content. 
     985      * 
     986      * @note Required previously file inclusion 
     987      * @return True if content has been captured 
     988      */ 
     989     public function getConfiguration() 
    781990     { 
    782991          if ($this->config_file) { 
     
    789998     } 
    790999 
    791      public function getConfigurationContent() 
    792      { 
    793           if (!$this->config_file) { 
    794                return null; 
    795           } 
    796  
    797           if (!$this->config_module['standalone_config']) { 
    798                echo 
    799                '<form id="module_config" action="'.$this->getPageURL('conf=1').'" method="post" enctype="multipart/form-data">'. 
    800                '<h3>'.sprintf(__('Configure plugin "%s"'), html::escapeHTML($this->config_module['name'])).'</h3>'. 
    801                '<p><a class="back" href="'.$this->getPageURL().'#plugins">'.__('Back').'</a></p>'; 
    802           } 
    803  
    804           echo $this->config_content; 
    805  
    806           if (!$this->config_module['standalone_config']) { 
    807                echo 
    808                '<p class="clear"><input type="submit" name="save" value="'.__('Save').'" />'. 
    809                form::hidden('module', $this->config_module['id']). 
    810                $this->core->formNonce().'</p>'. 
    811                '</form>'; 
    812           } 
    813  
    814           return true; 
    815      } 
    816  
     1000     /** 
     1001      * Display module configuration form. 
     1002      * 
     1003      * @note Required previously gathered content 
     1004      * @return     adminModulesList self instance 
     1005      */ 
     1006     public function displayConfiguration() 
     1007     { 
     1008          if ($this->config_file) { 
     1009 
     1010               if (!$this->config_module['standalone_config']) { 
     1011                    echo 
     1012                    '<form id="module_config" action="'.$this->getURL('conf=1').'" method="post" enctype="multipart/form-data">'. 
     1013                    '<h3>'.sprintf(__('Configure plugin "%s"'), html::escapeHTML($this->config_module['name'])).'</h3>'. 
     1014                    '<p><a class="back" href="'.$this->getURL().'#plugins">'.__('Back').'</a></p>'; 
     1015               } 
     1016 
     1017               echo $this->config_content; 
     1018 
     1019               if (!$this->config_module['standalone_config']) { 
     1020                    echo 
     1021                    '<p class="clear"><input type="submit" name="save" value="'.__('Save').'" />'. 
     1022                    form::hidden('module', $this->config_module['id']). 
     1023                    $this->core->formNonce().'</p>'. 
     1024                    '</form>'; 
     1025               } 
     1026          } 
     1027 
     1028          return $this; 
     1029     } 
     1030     //@} 
     1031 
     1032     /** 
     1033      * Helper to sanitize a string. 
     1034      * 
     1035      * Used for search or id. 
     1036      * 
     1037      * @param string    $str      String to sanitize 
     1038      * @return     Sanitized string 
     1039      */ 
    8171040     public static function sanitizeString($str) 
    8181041     { 
     
    8211044} 
    8221045 
     1046/** 
     1047 * @ingroup DC_CORE 
     1048 * @brief Helper to manage list of themes. 
     1049 * @since 2.6 
     1050 */ 
    8231051class adminThemesList extends adminModulesList 
    8241052{ 
    8251053     protected $page_url = 'blog_theme.php'; 
    8261054 
    827      public function displayModulesList($cols=array('name', 'config', 'version', 'desc'), $actions=array(), $nav_limit=false) 
     1055     public function displayModules($cols=array('name', 'config', 'version', 'desc'), $actions=array(), $nav_limit=false) 
    8281056     { 
    8291057          echo  
    8301058          '<div id="'.html::escapeHTML($this->list_id).'" class="modules'.(in_array('expander', $cols) ? ' expandable' : '').' one-box">'; 
    8311059 
    832           $sort_field = $this->getSortQuery(); 
     1060          $sort_field = $this->getSort(); 
    8331061 
    8341062          # Sort modules by id 
    835           $modules = $this->getSearchQuery() === null ? 
     1063          $modules = $this->getSearch() === null ? 
    8361064               self::sortModules($this->data, $sort_field, $this->sort_asc) : 
    8371065               $this->data; 
     
    8421070          { 
    8431071               # Show only requested modules 
    844                if ($nav_limit && $this->getSearchQuery() === null) { 
     1072               if ($nav_limit && $this->getSearch() === null) { 
    8451073                    $char = substr($module[$sort_field], 0, 1); 
    8461074                    if (!in_array($char, $this->nav_list)) { 
    8471075                         $char = $this->nav_special; 
    8481076                    } 
    849                     if ($this->getNavQuery() != $char) { 
     1077                    if ($this->getIndex() != $char) { 
    8501078                         continue; 
    8511079                    } 
    8521080               } 
    8531081 
    854                $current = $this->core->blog->settings->system->theme == $id; 
     1082               $current = $this->core->blog->settings->system->theme == $id && $this->modules->moduleExists($id); 
    8551083               $distrib = self::isDistributedModule($id) ? ' dc-box' : ''; 
    856  
    857                $theme_url = preg_match('#^http(s)?://#', $this->core->blog->settings->system->themes_url) ? 
    858                     http::concatURL($this->core->blog->settings->system->themes_url, '/'.$id) : 
    859                     http::concatURL($this->core->blog->url, $this->core->blog->settings->system->themes_url.'/'.$id); 
    860  
    861                $has_conf = file_exists(path::real($this->core->blog->themes_path.'/'.$id).'/_config.php'); 
    862                $has_css = file_exists(path::real($this->core->blog->themes_path.'/'.$id).'/style.css'); 
    863                $parent = $module['parent']; 
    864                $has_parent = !empty($module['parent']); 
    865                if ($has_parent) { 
    866                     $is_parent_present = $this->modules->moduleExists($parent); 
    867                } 
    8681084 
    8691085               $line =  
     
    8761092 
    8771093               # Display score only for debug purpose 
    878                if (in_array('score', $cols) && $this->getSearchQuery() !== null && defined('DC_DEBUG') && DC_DEBUG) { 
     1094               if (in_array('score', $cols) && $this->getSearch() !== null && defined('DC_DEBUG') && DC_DEBUG) { 
    8791095                    $line .=  
    8801096                    '<p class="module-score debug">'.sprintf(__('Score: %s'), $module['score']).'</p>'; 
     
    8881104                    # Screenshot from installed module 
    8891105                    elseif (file_exists($this->core->blog->themes_path.'/'.$id.'/screenshot.jpg')) { 
    890                          $sshot = $this->getPageURL('shot='.rawurlencode($id)); 
     1106                         $sshot = $this->getURL('shot='.rawurlencode($id)); 
    8911107                    } 
    8921108                    # Default screenshot 
     
    9241140               } 
    9251141 
    926                if (in_array('parent', $cols) && $has_parent) { 
    927                     if ($is_parent_present) { 
     1142               if (in_array('parent', $cols) && !empty($module['parent'])) { 
     1143                    if ($this->modules->moduleExists($module['parent'])) { 
    9281144                         $line .=  
    929                          '<span class="module-parent-ok">'.sprintf(__('(built on "%s")'),html::escapeHTML($parent)).'</span> '; 
     1145                         '<span class="module-parent-ok">'.sprintf(__('(built on "%s")'),html::escapeHTML($module['parent'])).'</span> '; 
    9301146                    } 
    9311147                    else { 
    9321148                         $line .=  
    933                          '<span class="module-parent-missing">'.sprintf(__('(requires "%s")'),html::escapeHTML($parent)).'</span> '; 
     1149                         '<span class="module-parent-missing">'.sprintf(__('(requires "%s")'),html::escapeHTML($module['parent'])).'</span> '; 
    9341150                    } 
    9351151               } 
     
    9621178               '<div class="module-actions toggle-bloc">'; 
    9631179                
    964                # _GET actions 
    965  
    966                if ($current && $has_css) { 
    967                     $line .=  
    968                     '<p><a href="'.$theme_url.'/style.css">'.__('View stylesheet').'</a></p>'; 
    969                } 
    970                if ($current && $has_conf) { 
    971                     $line .=  
    972                     '<p><a href="'.$this->getPageURL('module='.$id.'&conf=1', false).'" class="button">'.__('Configure theme').'</a></p>'; 
    973                } 
    974  
    9751180               # Plugins actions 
    9761181               if ($current) { 
     1182 
     1183                    # _GET actions 
     1184                    if (file_exists(path::real($this->core->blog->themes_path.'/'.$id).'/style.css')) { 
     1185                         $theme_url = preg_match('#^http(s)?://#', $this->core->blog->settings->system->themes_url) ? 
     1186                              http::concatURL($this->core->blog->settings->system->themes_url, '/'.$id) : 
     1187                              http::concatURL($this->core->blog->url, $this->core->blog->settings->system->themes_url.'/'.$id); 
     1188                         $line .=  
     1189                         '<p><a href="'.$theme_url.'/style.css">'.__('View stylesheet').'</a></p>'; 
     1190                    } 
     1191 
     1192                    if (file_exists(path::real($this->core->blog->themes_path.'/'.$id).'/_config.php')) { 
     1193                         $line .=  
     1194                         '<p><a href="'.$this->getURL('module='.$id.'&conf=1', false).'" class="button">'.__('Configure theme').'</a></p>'; 
     1195                    } 
     1196 
    9771197                    # --BEHAVIOR-- adminCurrentThemeDetails 
    9781198                    $line .=  
     
    9831203               if (!empty($actions)) { 
    9841204                    $line .= 
    985                     '<form action="'.$this->getPageURL().'" method="post">'. 
     1205                    '<form action="'.$this->getURL().'" method="post">'. 
    9861206                    '<div>'. 
    9871207                    $this->core->formNonce(). 
    9881208                    form::hidden(array('module'), html::escapeHTML($id)). 
    989                     form::hidden(array('tab'), $this->page_tab). 
    9901209 
    9911210                    implode(' ', $this->getActions($id, $module, $actions)). 
     
    10091228          '</div>'; 
    10101229 
    1011           if(!$count && $this->getSearchQuery() === null) { 
     1230          if(!$count && $this->getSearch() === null) { 
    10121231               echo  
    10131232               '<p class="message">'.__('No module matches your search.').'</p>'; 
     
    10241243               # Select theme to use on curent blog 
    10251244               if (in_array('select', $actions) && $this->path_writable) { 
    1026                     $submits[] = '<input type="submit" name="select" value="'.__('Choose').'" />'; 
     1245                    $submits[] =  
     1246                    '<input type="submit" name="select" value="'.__('Use this one').'" />'; 
    10271247               } 
    10281248          } 
     
    10361256     public function doActions($prefix) 
    10371257     { 
    1038           if (!empty($_POST) && empty($_REQUEST['conf']) && $this->isPathWritable()) { 
     1258          if (!empty($_POST) && empty($_REQUEST['conf']) && $this->isWritablePath()) { 
    10391259 
    10401260               # Select theme to use on curent blog 
     
    10511271 
    10521272                    dcPage::addSuccessNotice(__('Module has been successfully selected.')); 
    1053                     http::redirect($this->getPageURL().'#themes'); 
     1273                    http::redirect($this->getURL().'#themes'); 
    10541274               } 
    10551275          } 
  • plugins/maintenance/_config.php

    r2215 r2227  
    5252               ); 
    5353          } 
    54            
    55           http::redirect($list->getPageURL('module=maintenance&conf=1&done=1')); 
     54 
     55          dcPage::addSuccessNotice(__('Maintenance plugin has been successfully configured.')); 
     56          http::redirect($list->getURL('module=maintenance&conf=1')); 
    5657     } 
    5758     catch(Exception $e) { 
     
    6061} 
    6162 
    62      echo  
    63      '<p>'.__('Setup alert for maintenance task.').'</p>'. 
     63echo  
     64'<p>'.__('Set up reminders for maintenance tasks.').'</p>'. 
    6465 
    65      '<h4 class="pretty-title">'.__('Activation').'</h4>'. 
    66      '<p><label for="settings_plugin_message" class="classic">'. 
    67      form::checkbox('settings_plugin_message', 1, $core->blog->settings->maintenance->plugin_message). 
    68      __('Display alert messages on late tasks').'</label></p>'. 
     66'<h4 class="pretty-title">'.__('Activation').'</h4>'. 
     67'<p><label for="settings_plugin_message" class="classic">'. 
     68form::checkbox('settings_plugin_message', 1, $core->blog->settings->maintenance->plugin_message). 
     69__('Display alert messages on late tasks').'</label></p>'. 
    6970 
    70      '<p class="info">'.sprintf( 
    71           __('You can place list of late tasks on your %s.'), 
    72           '<a href="preferences.php#user-favorites">'.__('Dashboard').'</a>' 
    73      ).'</p>'. 
     71'<p class="info">'.sprintf( 
     72     __('You can place list of late tasks on your %s.'), 
     73     '<a href="preferences.php#user-favorites">'.__('Dashboard').'</a>' 
     74).'</p>'. 
    7475 
    75      '<h4 class="pretty-title vertical-separator">'.__('Frequency').'</h4>'. 
     76'<h4 class="pretty-title vertical-separator">'.__('Frequency').'</h4>'. 
    7677 
    77      '<p class="vertical-separator">'.form::radio(array('settings_recall_type', 'settings_recall_all'), 'all').' '. 
    78      '<label class="classic" for="settings_recall_all">'. 
    79      '<strong>'.__('Use one recall time for all tasks').'</strong></label>'. 
     78'<p class="vertical-separator">'.form::radio(array('settings_recall_type', 'settings_recall_all'), 'all').' '. 
     79'<label class="classic" for="settings_recall_all">'. 
     80'<strong>'.__('Use one recall time for all tasks').'</strong></label>'. 
    8081 
    81      '<p class="field wide vertical-separator"><label for="settings_recall_time">'.__('Recall time for all tasks:').'</label>'. 
    82      form::combo('settings_recall_time', $combo_ts, 'seperate', 'recall-for-all'). 
     82'<p class="field wide vertical-separator"><label for="settings_recall_time">'.__('Recall time for all tasks:').'</label>'. 
     83form::combo('settings_recall_time', $combo_ts, 'seperate', 'recall-for-all'). 
     84'</p>'. 
     85 
     86'<p class="vertical-separator">'.form::radio(array('settings_recall_type', 'settings_recall_separate'), 'separate', 1).' '. 
     87'<label class="classic" for="settings_recall_separate">'. 
     88'<strong>'.__('Use one recall time per task').'</strong></label>'; 
     89 
     90foreach($tasks as $t) 
     91{ 
     92     echo 
     93     '<div class="two-boxes">'. 
     94 
     95     '<p class="field wide"><label for="settings_ts_'.$t->id().'">'.$t->task().'</label>'. 
     96     form::combo('settings_ts_'.$t->id(), $combo_ts, $t->ts(), 'recall-per-task'). 
    8397     '</p>'. 
    8498 
    85      '<p class="vertical-separator">'.form::radio(array('settings_recall_type', 'settings_recall_separate'), 'separate', 1).' '. 
    86      '<label class="classic" for="settings_recall_separate">'. 
    87      '<strong>'.__('Use one recall time per task').'</strong></label>'; 
    88  
    89      foreach($tasks as $t) 
    90      { 
    91           echo 
    92           '<div class="two-boxes">'. 
    93  
    94           '<p class="field wide"><label for="settings_ts_'.$t->id().'">'.$t->task().'</label>'. 
    95           form::combo('settings_ts_'.$t->id(), $combo_ts, $t->ts(), 'recall-per-task'). 
    96           '</p>'. 
    97  
    98           '</div>'; 
    99      } 
     99     '</div>'; 
     100} 
Note: See TracChangeset for help on using the changeset viewer.

Sites map