DokuWiki

It's better when it's simple

用户工具

站点工具


zh:devel:configuration

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

后一修订版
前一修订版
zh:devel:configuration [2017-07-20 05:37] – 创建 223.74.133.140zh:devel:configuration [2017-07-20 07:41] (当前版本) – [表] 223.74.133.140
行 34: 行 34:
 ---- ----
 ===== 配置元数据 ===== ===== 配置元数据 =====
-For every setting in ''lib/plugins/<your plugin>/conf/default.php'' there should be a ''%%$meta[<setting>]%%'' value defined in ''lib/plugins/<your plugin>/conf/metadata.php''((For templates it's totally analogous: ''lib/tpl/<your template>/conf/default.php'' and ''lib/tpl/<your template>/conf/metadata.php''.)):+对于每一个在 ''lib/plugins/<your plugin>/conf/default.php''的设置它们都有一个 ''%%$meta[<setting>]%%'' 值定位于  ''lib/plugins/<your plugin>/conf/metadata.php''((模板是完全类似: ''lib/tpl/<your template>/conf/default.php'' 和 ''lib/tpl/<your template>/conf/metadata.php''.)):
  
 <code php> <code php>
 $meta[<setting>] = array(<setting class>, <param name> => <param value>); $meta[<setting>] = array(<setting class>, <param name> => <param value>);
 </code> </code>
-If no parameter is required for a setting class (see below), it's simply:+如果一个设置类不需要参数(参见下面),那么它就是简单的:
  
 <code php> <code php>
行 45: 行 45:
 </code> </code>
  
-Examples:+例子:
  
 <code php> <code php>
行 51: 行 51:
 $meta['title'     = array('string'); $meta['title'     = array('string');
 $meta['lang'      = array('dirchoice','_dir' => DOKU_INC.'inc/lang/'); $meta['lang'      = array('dirchoice','_dir' => DOKU_INC.'inc/lang/');
-$meta['dmode'     = array('numeric','_pattern' => '/0[0-7]{3,4}/'); // only accept octal representation+$meta['dmode'     = array('numeric','_pattern' => '/0[0-7]{3,4}/'); // 只接受八进制表示法
 $meta['allowdebug'] = array('onoff'); $meta['allowdebug'] = array('onoff');
 $meta['passcrypt' = array('multichoice','_choices' => array('smd5','md5','sha1','ssha','crypt','mysql','my411')); $meta['passcrypt' = array('multichoice','_choices' => array('smd5','md5','sha1','ssha','crypt','mysql','my411'));
行 58: 行 58:
 ==== 类 ==== ==== 类 ====
  
-^ ''%%''%%''               Default class ('setting'), textarea, minimal input validation, setting output in quotes.                                                                                                                                           +^ ''%%''%%''               默认的类('setting'),文本框 ,最小输入验证,在引号中设置输出。                                                                                         
-^ ''%%'string'%%''         Single line text input, minimal input validation, setting output in quotes.                                                                                                                                                        +^ ''%%'string'%%''         单行文本输入,最小输入验证,在引号中设置输出。                                                                                                       
-^ ''%%'numeric'%%''        | Text input, accepts numbers and arithmetic operators, setting output without quotes.\\ If given the ''_min'' and ''_max'' parameters are used for validation.                                                                           +^ ''%%'numeric'%%''        | 文本输入,接受数字和算术运算符,设置没有引号的输出。 \\ 如果给定''_min''''_max''参数,则用于验证。                                                                  
-^ ''%%'numericopt'%%''     Like above, but accepts empty values.                                                                                                                                                                                              +^ ''%%'numericopt'%%''     像上面一样,但是接受空值。                                                                                                                 
-^ ''%%'onoff'%%''          | Checkbox inputsetting output ''0'' or ''1'' (note that default values should be one of these integersand not boolean).                                                                                                                 +^ ''%%'onoff'%%''          | 复选框输入,设置输出“0”或“1(注意,默认值应该是一个整数,而不是布尔)。                                                                                       
-^ ''%%'multichoice'%%''    | Select input (single choice), setting output with quotes, required ''_choices'' parameter.                                                                                                                                             +^ ''%%'multichoice'%%''    | 选择输入(单个选择),用引号设置输出,需要 ''_choices''参数。                                                                                         
-^ ''%%'email'%%''          | Text input, input must conform to email address format, setting output in quotes.                                                                                                                                                  +^ ''%%'email'%%''          | 文本输入,输入必须符合电子邮件地址格式,在引号中设置输出。                                                                                                 
-^ ''%%'richemail'%%''      | Text input, input must conform to email address header format, may include a text part and replacement patterns, setting output in quotes.                                                                                         +^ ''%%'richemail'%%''      | 文本输入,输入必须符合电子邮件地址头格式,可能包括文本部分和替换模式,在引号中设置输出。                                                                                  
-^ ''%%'password'%%''       Password input, minimal input validation, setting output plain text in quotes. Once set the password is not shown in the config manager any more. Can be obfuscated in config through the ''_code'' parameter.                         +^ ''%%'password'%%''       密码输入,最小输入验证,在引号中设置输出纯文本。一旦设置了密码,就不再显示在配置管理器中了。可以通过 ''_code''参数对配置进行模糊处理。                                                      
-^ ''%%'dirchoice'%%''      | As ''multichoice'', selection choices based on folders found at location specified in ''_dir'' parameter (required).                                                                                                                       +^ ''%%'dirchoice'%%''      | 作为“多选”,根据 ''_dir''参数(必需)中指定的位置所找到的文件夹进行选择。                                                                                    
-^ ''%%'multicheckbox'%%'' A checkbox for each choice plus an "other" string input, config file setting is a comma separated list of checked choices.                                                                                                         +^ ''%%'multicheckbox'%%'' 每个选项的复选框和一个 "other" 字符串输入,配置文件设置是一个逗号分隔的检查选项列表。                                                                               
-^ ''%%'fieldset'%%''       Used to group configuration settings, but is not itself a setting. To make this clear in the language files the keys for this type should start with ''_''.                                                                          +^ ''%%'fieldset'%%''       用于组配置设置,但它本身不是一个设置。为了在语言文件中清楚地说明,这种类型的键应该以''_''为开始                                                                            
-^ ''%%'authtype'%%''       Creates a selection of available authentication methods, based on the class names in ''inc/auth'' that match the ''authtype.class.php'' pattern.                                                                                           +^ ''%%'authtype'%%''       创建了一组可用的身份验证方法,这些方法是根据''inc/auth''的类名来匹配 ''authtype.class.php'' 模式。                                                           
-^ ''%%'regex'%%''          | Regular expression string, normally without delimitersas for ''string'', in addition tested to see if will compile and run as a regex.  In addition to ''_pattern'', also accepts ''_delimiter'' (default ''/''and ''_pregflags'' (default ''ui'') | +^ ''%%'regex'%%''          | 正则表达式字符串,通常没有分隔符;至于 ''string'',还测试了是否将编译并作为正则表达式运行。除了 ''_pattern''外,还接受 ''_delimiter'' (默认''/''''_pregflags'' (默认''ui'')。  |
  
 ==== 参数 ==== ==== 参数 ====
  
-^ ''%%'_pattern'%%''    | Stringa regular expression. Input is tested against this pattern before being accepted.\\ Optional all classesexcept ''onoff'', ''multichoice'' and ''dirchoice'' which ignore it.                                                                                                                                                                                                                                      +^ ''%%'_pattern'%%''    | 字符串,一个正则表达式。在被接受之前,输入是被测试的。\\ 可选的所有类,除了''onoff'', ''multichoice'' 和 ''dirchoice'' 忽略它。                                                                                                                                        
-^ ''%%'_choices'%%''    | Array of choices. Used to populate a selection box. Choice will be replaced by a localised language string, indexed by ''<setting name>_o_<choice>'', if one exists.\\ Required by ''multichoice'' & ''multicheckbox'' classes, ignored by others.                                                                                                                                                                    +^ ''%%'_choices'%%''    | 数组选择。用于填充一个选择框。选择将被一个本地化语言字符串替换,如果存在的话,由''<setting name>_o_<choice>''索引。要求 ''multichoice'' & ''multicheckbox'' 类,忽略其它。                                                                                                        
-^ ''%%'_dir'%%''        | Location of directory to be used to populate choice list.\\ Required by ''dirchoice'' class, ignored by other classes.                                                                                                                                                                                                                                                                                           +^ ''%%'_dir'%%''        | 用于填充选择列表的目录的位置。\\ 要求''dirchoice''类,忽略其它类。                                                                                                                                                                                     
-^ ''%%'_code'%%''       Sets the obfuscation option for password fields. May be ''plain'', ''base64'' or ''uuencode''. When using the latter two, you need to use [[phpxref>conf_decodeString()]] to access the plain value.                                                                                                                                                                                                               +^ ''%%'_code'%%''       设置密码字段的混淆选项。可能是 ''plain'', ''base64'' 或 ''uuencode''。 当使用后两个时,您需要使用[[phpxref>conf_decodeString()]]访问 plain 值。                                                                                                                 
-^ ''%%'_combine'%%''    | Complimentary output setting values which can be combined into a single display ''checkbox''.\\ Optional for ''multicheckbox'', ignored by other classes.                                                                                                                                                                                                                                                            +^ ''%%'_combine'%%''    | 互补输出设置值,可以组合成一个单一的显示 ''复选框''\\ 可选 “多复选框”,忽略其它类。                                                                                                                                                                              
-^ ''%%'_code'%%''       Encoding method to use, accepted values: ''base64'', ''uuencode'', ''plain''.  Defaults to plain.                                                                                                                                                                                                                                                                                                                    +^ ''%%'_code'%%''       使用的编码方法,接受的值: ''base64'', ''uuencode'', ''plain''.  默认为 plain.                                                                                                                                                                
-^ ''%%'_min'%%''        | Minimum numeric value.\\ Optional for ''numeric'' and ''numericopt'', ignored by others.                                                                                                                                                                                                                                                                                                                            +^ ''%%'_min'%%''        | 最小的数值。\\ 可选 ''numeric'' 和 ''numericopt'',忽略其它                                                                                                                                                                                 
-^ ''%%'_max'%%''        | Maximum numeric value.\\ Optional for ''numeric'' and ''numericopt'', ignored by others.                                                                                                                                                                                                                                                                                                                            +^ ''%%'_max'%%''        | 最小的数值。\\ 可选 ''numeric'' 和 ''numericopt'', 忽略其它                                                                                                                                                                                
-^ ''%%'_delimiter'%%'' Stringdefault ''/'', a single character used as a delimiter for testing regex input values.                                                                                                                                                                                                                                                                                                                   +^ ''%%'_delimiter'%%'' 字符串默认 ''/'', 一个字符作为分隔符用于测试正则表达式的输入值。                                                                                                                                                                                        
-^ ''%%'_pregflags'%%'' Stringdefault ''ui'', valid preg pattern modifiers used when testing regex input values, for more information see [[http://uk1.php.net/manual/en/reference.pcre.pattern.modifiers.php]]                                                                                                                                                                                                                         +^ ''%%'_pregflags'%%'' 字符串默认 ''ui'', 测试正则表达式输入值时使用的有效的preg模式修饰符, 更多信息见 http://uk1.php.net/manual/en/reference.pcre.pattern.modifiers.php.                                                                                                          
-^ ''%%'_multiple'%%''   Bool, allow multiple comma separated email values.\\ Optional for ''email'', ignored by others.                                                                                                                                                                                                                                                                                                                   +^ ''%%'_multiple'%%''   布尔型,允许多个逗号分隔的电子邮件值。\\ 可选 ''email'', 忽略其它                                                                                                                                                                                      
-^ ''%%'_other'%%''      | How to handle other values (not listed in ''_choices''). Accepted values: ''always'', ''exists'', ''never''. Default value ''always''.\\ ''exists'' only shows 'other' input field when the setting contains value(s) not listed in choices (e.g. due to manual editing or update changing ''_choices'').  This is safer than ''never'' as it will not discard unknown/other values.\\ Optional for ''multicheckbox'', ignored by others.  |+^ ''%%'_other'%%''      | 如何处理其他值 (未列出在 ''_choices'')。 接受的值: ''always'', ''exists'', ''never''。默认值 ''always''.\\ ''exists''只显示 'other' 输入字段,当设置包含没有在选项中列出的值时 (如由于手工编辑或更新改变 ''_choices'')。这比 ''never''更安全,因为它不会丢弃不知道的/其他值。\\ 可选 ''multicheckbox'',忽略其它。  |
  
  
行 94: 行 93:
 === ''multicheckbox'' 用 ''_other'' === === ''multicheckbox'' 用 ''_other'' ===
  
-Let's say initially a plugin uses the syntax:+假设最初插件使用的语法:
  
 <code php>$meta['multi'] = array('multicheckbox', '_choices' => array('a','b','c','d'));</code> <code php>$meta['multi'] = array('multicheckbox', '_choices' => array('a','b','c','d'));</code>
  
-this means the multicheckbox will show four choices plus a string input.+这意味着多复选框将显示四个选项和一个字符串输入。
  
-Let's suppose also that the user inserts one or more extra values not in ''_choices''.+假设用户插入一个或多个额外的值,而不是在 ''_choices''.
  
-In the next release of the plugin the author's plugin decides to use the multicheckbox without the extra string, but, in order to be backwardly compatible, adopts:+在插件的下一个版本中,作者的插件决定在没有额外的字符串的情况下使用多复选框,但是为了向后兼容,采用:
  
-<code php>$meta['multi'] = array('multicheckbox', '_other' => 'exists', '_choices' => array('a','b','c','d'));</code>+<code php> 
 +$meta['multi'] = array('multicheckbox', '_other' => 'exists', '_choices' => array('a','b','c','d')); 
 +</code>
  
-which means+这意味着
-  * if the user has inserted comma separated values, they will be printed in the extra string+  * 如果用户插入逗号分隔值,则将在额外的字符串中打印
-  * otherwise the extra string won't show.+  * 否则不会显示额外的字符串。
  
-Note also that if the user inserts comma separated values which already exist (or some of themin ''_choices'' but+还请注意,如果用户插入逗号分隔值已经存在(或一些)在 ''_choices'' 
-  * they are already ticked, then the extra string will be removed and nothing else+  * 它们已经被勾选,然后额外的字符串将被删除,其他的都没有
-  * they are not already ticked, then the extra string will be removed and the relative value will be ticked.+  * 它们还没有被勾选,然后额外的字符串将被删除,相对的值将被勾选。
  
 \\ \\
行 118: 行 119:
 ===== 访问设置 ===== ===== 访问设置 =====
 ====核心设置==== ====核心设置====
-Inside [[xref>inc/init.php]] the configurations settings are read into a [[devel:environment|global array]] ''$conf[]''. When no settings were set, these are read from the default settings file. +[[xref>inc/init.php]]内部,配置设置被读取到一个[[zh:devel:environment|全局数组]] ''$conf[]''。当没有设置设置时,将从默认设置文件中读取这些设置。 
-You can access the core settings anywhere by using the ''$conf[]'' array.+你可以在任何地方访问核心设置通过使用 ''$conf[]'' 数组。
  
 <code php> <code php>
行 126: 行 127:
  
 ====插件设置==== ====插件设置====
-You can access settings in [[plugins]] by using the ''%%$this->%%[[xref>getConf|getConf('<setting>')]]'' method.  +你可以访问设置在 [[plugins|插件]] 通过 ''%%$this->%%[[xref>getConf|getConf('<setting>')]]'' 方法。 
-In your plugin class you use:+在你的插件类中,你使用:
 <code php> <code php>
 $keyvalue = $this->getConf('key'); $keyvalue = $this->getConf('key');
行 133: 行 134:
  
 ==== 模板设置==== ==== 模板设置====
-In [[templates]] you can use ''[[xref>tpl_getConf|tpl_getConf('<setting>')]]''.+在 [[templates|模板]] 你可以使用 ''[[xref>tpl_getConf|tpl_getConf('<setting>')]]''.
 <code php> <code php>
 $nicetoknow = tpl_getConf('special'); $nicetoknow = tpl_getConf('special');
行 141: 行 142:
 ---- ----
 ===== 标签在配置管理器 ===== ===== 标签在配置管理器 =====
-For every setting in ''lib/plugins/<your plugin>/conf/default.php'' there can be a ''%%$lang[<setting>]%%'' value defined in ''lib/plugins/<your plugin>/lang/en/settings.php''. This value will be displayed as the label of the setting in the configuration manager. If the label file is left out or doesn't contain a value for the setting, the configuration manager will display "''%%plugin <plugin name> <setting>%%''" as the label instead. +对于''lib/plugins/<your plugin>/conf/default.php''中的每一个设置,都可以在''lib/plugins/<your plugin>/lang/en/settings.php''中定义一个''%%$lang[<setting>]%%''值。 这个值将作为配置管理器中的设置的标签显示。如果标签文件被省略,或者不包含设置的值,配置管理器将显示X"''%%plugin <plugin name> <setting>%%''"作为标签。
  
-You can also create a ''settings.php'' file for other languages. +您还可以创建一个 ''settings.php''文件为其他语言。
  
-Againthis also applies to templates (see [[:localization]] for further details).+同样,这也适用于模板 (进一步的细节见[[zh:localization|定位]])
zh/devel/configuration.1500521855.txt.gz · 最后更改: 2017-07-20 05:37 由 223.74.133.140

除额外注明的地方外,本维基上的内容按下列许可协议发布: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki