Dotclear

Changeset 3333:11107ba2fc59


Ignore:
Timestamp:
09/01/16 12:21:43 (9 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Cope with settings URLs for modules (defined in _define.php).
The settings URLs are displayed on the plugins maganement page, and at the bottom of each plugin main page if any (index.php).

The URLs are set in _define.php, as a new property using this schema:

'settings' => array( <list of URLs> )

With:

<list of URLs> = '<type>' => '<location>', …
<type> = 'self' (own plugin page), 'blog' (in blog parameters page) or 'pref' (in user preferences page)
<location> = (empty) or #<tab>[.<id>] with <tab> = id of the corresponding tab, and <id> = id of fieldset, h4, h5, field, … of first corresponding field

The list of URLs are displayed in the order defined in the array above.

Examples:

Antispam plugin:

'settings' => array(

'self' => ,
'blog' => '#params.antispam_params'

)

self → for main settings of the plugin on its own page (index.php)
blog → for secondary settings in the blog parameters

Tags plugin:

'settings' => array(

'pref' => '#user-options.tags_prefs'

)

pref → for tags list format in user preferences

Maintenance plugin:

'settings' => array(

'self' => '#settings'

)

self → "settings" tab of its own page (index.php)

Files:
19 edited

Legend:

Unmodified
Added
Removed
  • admin/js/jquery/jquery.pageTabs.js

    r2479 r3333  
    11(function($) { 
    22     'use strict'; 
    3      
     3 
    44     $.pageTabs = function(start_tab, opts) { 
    55          var defaults = { 
     
    1010               idTabPrefix: 'part-tabs-' 
    1111          }; 
    12            
     12 
    1313          $.pageTabs.options = $.extend({}, defaults, opts); 
    1414          var active_tab = start_tab || ''; 
    1515          var hash = $.pageTabs.getLocationHash(); 
     16          var subhash = $.pageTabs.getLocationSubhash(); 
    1617 
    1718          if (hash !== undefined && hash) { 
     
    2324 
    2425          createTabs(); 
    25            
     26 
    2627          $('ul li', '.'+$.pageTabs.options.containerClass).click(function(e) { 
    2728               if ($(this).hasClass($.pageTabs.options.activeClass)) { 
     
    4041                    part_to_activate.addClass('loaded'); 
    4142               } 
    42                 
     43 
    4344               part_to_activate.tabload(); 
    4445          }); 
     
    4950 
    5051          $.pageTabs.clickTab(active_tab); 
    51            
     52 
     53          if (subhash !== undefined) { 
     54               // Tab displayed, now scroll to the sub-part if defined in original document.location (#tab.sub-part) 
     55               document.getElementById(subhash).scrollIntoView(); 
     56          } 
     57 
    5258          return this; 
    5359     }; 
    54       
     60 
    5561     var createTabs = function createTabs() { 
    5662          var lis = [], li_class = ''; 
    57            
     63 
    5864          $('.'+$.pageTabs.options.contentClass).each(function() { 
    5965               $(this).hide(); 
     
    6268               $(this).attr('id', $.pageTabs.options.partPrefix + $(this).attr('id')).prop('title',''); 
    6369          }); 
    64            
     70 
    6571          $('<div class="'+$.pageTabs.options.containerClass+'"><ul>'+lis.join('')+'</ul></div>') 
    6672               .insertBefore($('.'+$.pageTabs.options.contentClass).get(0)); 
    6773     }; 
    68       
     74 
    6975     var getHash = function getHash(href) { 
    7076          var href = href || ''; 
     
    7278          return href.replace(/.*#/, ''); 
    7379     }; 
    74       
     80 
    7581     $.pageTabs.clickTab = function(tab) { 
    7682          if (tab=='') { 
     
    96102 
    97103     $.pageTabs.getLocationHash = function() { 
    98           return getHash(document.location.hash); 
     104          // Return the URL hash (without subhash — #hash[.subhash]) 
     105          var h = getHash(document.location.hash).split('.'); 
     106          return h[0]; 
     107     }; 
     108     $.pageTabs.getLocationSubhash = function() { 
     109          // Return the URL subhash if present (without hash — #hash[.subhash]) 
     110          var sh = getHash(document.location.hash).split('.'); 
     111          return sh[1]; 
    99112     }; 
    100113})(jQuery); 
  • admin/plugin.php

    r2708 r3333  
    7878     call_user_func($open_f,$p_title,$p_head); 
    7979     echo $p_content; 
     80     if (!$popup) { 
     81          // Add direct links to plugin settings if any 
     82          $settings = adminModulesList::getSettingsUrls($core,$p,true,false); 
     83          if (!empty($settings)) { 
     84               echo '<hr class="clear"/><p class="right modules">'.implode(' - ',$settings).'</p>'; 
     85          } 
     86     } 
    8087     call_user_func($close_f); 
    8188} 
  • admin/preferences.php

    r3330 r3333  
    490490echo 
    491491'<div class="fieldset">'. 
    492 '<h4>'.__('Interface').'</h4>'. 
     492'<h4 id="user_options_interface">'.__('Interface').'</h4>'. 
    493493 
    494494'<p><label for="user_ui_enhanceduploader" class="classic">'. 
     
    524524echo 
    525525'<div class="fieldset">'. 
    526 '<h4>'.__('Optional columns displayed in lists').'</h4>'; 
     526'<h4 id="user_options_columns">'.__('Optional columns displayed in lists').'</h4>'; 
    527527$odd = true; 
    528528foreach ($cols as $col_type => $col_list) { 
     
    541541echo 
    542542'<div class="fieldset">'. 
    543 '<h4>'.__('Edition').'</h4>'; 
     543'<h4 id="user_options_edition">'.__('Edition').'</h4>'; 
    544544 
    545545echo '<div class="two-boxes odd">'; 
  • inc/admin/lib.moduleslist.php

    r3327 r3333  
    466466                    'sshot'             => '', 
    467467                    'score'                  => 0, 
    468                     'type'                   => null 
     468                    'type'                   => null, 
     469                    'require'           => array(), 
     470                    'settings'               => array() 
    469471               ), 
    470472               # Module's values 
     
    744746                         if (!empty($more)) { 
    745747                              echo 
    746                               '<li>'.implode(' - ', $more).'</li>'; 
     748                              '<li>'.implode(' - ',$more).'</li>'; 
    747749                         } 
    748750 
     
    753755                    $config = !empty($module['root']) && file_exists(path::real($module['root'].'/_config.php')); 
    754756 
    755                     if ($config || !empty($module['section']) || !empty($module['tags'])) { 
     757                    if ($config || !empty($module['section']) || !empty($module['tags']) || !empty($module['settings'])) { 
    756758                         echo 
    757759                         '<div><ul class="mod-more">'; 
    758760 
    759                          if ($config) { 
    760                               echo 
    761                               '<li><a class="module-config" href="'.$this->getURL('module='.$id.'&amp;conf=1').'">'.__('Configure plugin').'</a></li>'; 
     761                         $settings = $this->getSettingsUrls($this->core,$id); 
     762                         if (!empty($settings)) { 
     763                              echo '<li>'.implode(' - ',$settings).'</li>'; 
    762764                         } 
    763765 
     
    806808 
    807809          return $this; 
     810     } 
     811 
     812     /** 
     813      * Get settings URLs if any 
     814      * 
     815      * @param object $core 
     816      * @param string $id module ID 
     817      * @param boolean $check check permission 
     818      * @param boolean $self include self URL (→ plugin index.php URL) 
     819      * @return Array of settings URLs 
     820      */ 
     821     public static function getSettingsUrls($core,$id,$check=false,$self=true) 
     822     { 
     823          $st = array(); 
     824 
     825          $config = !empty($core->plugins->moduleRoot($id)) && 
     826               file_exists(path::real($core->plugins->moduleRoot($id).'/_config.php')); 
     827          $settings = $core->plugins->moduleInfo($id,'settings'); 
     828          if ($config || !empty($settings)) { 
     829               if ($config) { 
     830                    $st[] = '<a class="module-config" href="'. 
     831                         $core->adminurl->get('admin.plugins',array('module' => $id,'conf' => '1')). 
     832                         '">'.__('Configure plugin').'</a>'; 
     833               } 
     834               if (is_array($settings)) { 
     835                    foreach ($settings as $sk => $sv) { 
     836                         switch ($sk) { 
     837                              case 'blog': 
     838                                   if ((!$check) || 
     839                                        ($check && $core->auth->check('admin',$core->blog->id))) { 
     840                                        $st[] = '<a class="module-config" href="'. 
     841                                             $core->adminurl->get('admin.blog.pref').$sv. 
     842                                             '">'.__('Plugin settings (in blog parameters)').'</a>'; 
     843                                   } 
     844                                   break; 
     845                              case 'pref': 
     846                                   if ((!$check) || 
     847                                        ($check && $core->auth->check('usage,contentadmin',$core->blog->id))) { 
     848                                        $st[] = '<a class="module-config" href="'. 
     849                                             $core->adminurl->get('admin.user.preferences').$sv. 
     850                                             '">'.__('Plugin settings (in user preferences)').'</a>'; 
     851                                   } 
     852                                   break; 
     853                              case 'self': 
     854                                   if ($self) { 
     855                                        if ((!$check) || 
     856                                             ($check && $core->auth->check($core->plugins->moduleInfo($id,'permissions'),$core->blog->id))) { 
     857                                             $st[] = '<a class="module-config" href="'. 
     858                                                  $core->adminurl->get('admin.plugin.'.$id).$sv. 
     859                                                  '">'.__('Plugin settings').'</a>'; 
     860                                        } 
     861                                   } 
     862                                   break; 
     863                         } 
     864                    } 
     865               } 
     866          } 
     867 
     868          return $st; 
    808869     } 
    809870 
  • inc/core/class.dc.modules.php

    r3135 r3333  
    283283     (currently available keys : permissions, priority, type) 
    284284     */ 
    285      public function registerModule($name,$desc,$author,$version, $properties = array()) 
     285     public function registerModule($name,$desc,$author,$version,$properties = array()) 
    286286     { 
    287287          if ($this->disabled_mode) { 
     
    320320                    'type' => null, 
    321321                    'enabled' => true, 
    322                     'requires' => array() 
     322                    'requires' => array(), 
     323                    'settings' => array() 
    323324               ), $properties 
    324325          ); 
  • locales/fr/main.po

    r3330 r3333  
    29792979msgstr "Configurer le plugin" 
    29802980 
     2981msgid "Plugin settings (in blog parameters)" 
     2982msgstr "Réglages du plugin (paramètres du blog)" 
     2983 
     2984msgid "Plugin settings (in user preferences)" 
     2985msgstr "Réglages du plugin (mes préférences)" 
     2986 
     2987msgid "Plugin settings" 
     2988msgstr "Réglages du plugin" 
     2989 
    29812990msgid "No plugins matched your search." 
    29822991msgstr "Aucun plugin ne correspond à votre recherche." 
  • plugins/antispam/_admin.php

    r2849 r3333  
    9191          $ttl = $settings->antispam->antispam_moderation_ttl; 
    9292          echo 
    93           '<div class="fieldset"><h4>Antispam</h4>'. 
     93          '<div class="fieldset"><h4 id="antispam_params">Antispam</h4>'. 
    9494          '<p><label for="antispam_moderation_ttl" class="classic">'.__('Delete junk comments older than').' '. 
    9595          form::field('antispam_moderation_ttl', 3, 3, $ttl). 
  • plugins/antispam/_define.php

    r2566 r3333  
    1919     array( 
    2020          'permissions' =>    'usage,contentadmin', 
    21           'priority' =>       10 
     21          'priority' =>       10, 
     22          'settings'     =>        array( 
     23                                        'self' => '', 
     24                                        'blog' => '#params.antispam_params' 
     25                                   ) 
    2226     ) 
    2327); 
  • plugins/breadcrumb/_admin.php

    r3009 r3333  
    2525          $settings->addNameSpace('breadcrumb'); 
    2626          echo 
    27           '<div class="fieldset"><h4>'.__('Breadcrumb').'</h4>'. 
     27          '<div class="fieldset"><h4 id="breadcrumb_params">'.__('Breadcrumb').'</h4>'. 
    2828          '<p><label class="classic">'. 
    2929          form::checkbox('breadcrumb_enabled','1',$settings->breadcrumb->breadcrumb_enabled). 
  • plugins/breadcrumb/_define.php

    r3085 r3333  
    2020     array( 
    2121          /* Permissions */   'permissions' =>    'usage,contentadmin', 
    22           /* Type */               'type' =>           'plugin' 
     22          /* Type */               'type' =>           'plugin', 
     23          'settings'     =>        array( 
     24                                        'blog' => '#params.breadcrumb_params' 
     25                                   ) 
    2326     ) 
    2427); 
  • plugins/dcCKEditor/_define.php

    r3090 r3333  
    1919     array( 
    2020          'permissions' =>    'usage,contentadmin', 
    21           'type'         =>        'plugin' 
     21          'type'         =>        'plugin', 
     22          'settings'     =>        array( 
     23                                        'self' => '', 
     24                                        'pref' => '#user-options.user_options_edition' 
     25                                   ) 
    2226     ) 
    2327); 
  • plugins/dcLegacyEditor/_define.php

    r3258 r3333  
    1919     array( 
    2020          'permissions' =>    'usage,contentadmin', 
    21           'type'         =>        'plugin' 
     21          'type'         =>        'plugin', 
     22          'settings'     =>        array( 
     23                                        'self' => '', 
     24                                        'pref' => '#user-options.user_options_edition' 
     25                                   ) 
    2226     ) 
    2327); 
  • plugins/maintenance/_define.php

    r2257 r3333  
    1919     array( 
    2020          'permissions' =>    'admin', 
    21           'type'         =>        'plugin' 
     21          'type'         =>        'plugin', 
     22          'settings'     =>        array( 
     23                                        'self' => '#settings' 
     24                                   ) 
    2225     ) 
    2326 
  • plugins/pings/_define.php

    r2566 r3333  
    1919     array( 
    2020          'permissions' =>    'usage,contentadmin', 
    21           'type'         =>        'plugin' 
     21          'type'         =>        'plugin', 
     22          'settings'     =>        array( 
     23                                        'self' => '' 
     24                                   ) 
    2225     ) 
    2326); 
  • plugins/simpleMenu/_define.php

    r2773 r3333  
    1919     array( 
    2020          'permissions' =>    'admin', 
    21           'type'         =>        'plugin' 
     21          'type'         =>        'plugin', 
     22          'settings'     =>        array( 
     23                                        'self' => '' 
     24                                   ) 
    2225     ) 
    2326); 
  • plugins/tags/_define.php

    r2924 r3333  
    2020          'permissions' =>    'usage,contentadmin', 
    2121          'priority' =>       1001,     // Must be higher than dcLegacyEditor/dcCKEditor priority (ie 1000) 
    22           'type'         =>        'plugin' 
     22          'type'         =>        'plugin', 
     23          'settings'     =>        array( 
     24                                        'pref' => '#user-options.tags_prefs' 
     25                                   ) 
    2326     ) 
    2427); 
  • plugins/tags/inc/tags.behaviors.php

    r3024 r3333  
    363363 
    364364          echo 
     365          '<div class="fieldset"><h5 id="tags_prefs">'.__('Tags').'</h5>'. 
    365366          '<p><label for="user_tag_list_format" class="classic">'.__('Tags list format:').'</label> '. 
    366367          form::combo('user_tag_list_format',$combo,$value). 
    367           '</p>'; 
     368          '</p></div>'; 
    368369     } 
    369370 
  • plugins/themeEditor/_admin.php

    r3257 r3333  
    6060          echo 
    6161               '<div class="fieldset two-cols clearfix">'. 
    62                '<h5>'.__('Syntax highlighting').'</h5>'; 
     62               '<h5 id="themeEditor_prefs">'.__('Syntax highlighting').'</h5>'; 
    6363          echo 
    6464               '<div class="col">'. 
  • plugins/themeEditor/_define.php

    r3251 r3333  
    1818     /* Version */            '1.3', 
    1919     array( 
    20           'type'         =>        'plugin' 
     20          'type'         =>        'plugin', 
     21          'settings'     =>        array( 
     22                                        'pref' => '#user-options.themeEditor_prefs' 
     23                                   ) 
    2124     ) 
    2225); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map