Skip to content

Commit

Permalink
use getConf() to access configuration options / added en language files
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelet authored and lupo49 committed Aug 6, 2011
1 parent f9cac3c commit 92fe437
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 32 deletions.
11 changes: 11 additions & 0 deletions conf/default.php
@@ -0,0 +1,11 @@
<?php
$conf['numerical_index'] = '0-9';
$conf['articles_deletion'] = '';
$conf['articles_moving'] = 1;
$conf['empty_msg'] = 'No index for <b>{{ns}}</b>';
$conf['title_tpl'] = '===== Index =====';
$conf['begin_letter_tpl'] = '==== {{letter}} ====';
$conf['entry_tpl'] = ' * [[{{link}}|{{name}}]]';
$conf['end_letter_tpl'] = '';
$conf['hidepages'] = '';
$conf['metadata_title'] = 0;
11 changes: 11 additions & 0 deletions conf/metadata.php
@@ -0,0 +1,11 @@
<?php
$meta['numerical_index'] = array('string');
$meta['articles_deletion'] = array('string');
$meta['articles_moving'] = array('multichoice', '_choices' => array('0', '1' ,'2'));
$meta['empty_msg'] = array('string');
$meta['title_tpl'] = array('string');
$meta['begin_letter_tpl'] = array('string');
$meta['entry_tpl'] = array('string');
$meta['end_letter_tpl'] = array('string');
$meta['hidepages'] = array('string');
$meta['metadata_title'] = array('onoff');
11 changes: 11 additions & 0 deletions lang/en/settings.php
@@ -0,0 +1,11 @@
<?php
$lang['numerical_index'] = 'Text display in block letter title for the page title beginning with a numerical value.';
$lang['articles_deletion'] = "List of article treated by the plugin. Each article is separated with a '|'. Example: <strong>^the +|^a +|^an +</strong>";
$lang['articles_moving'] = 'Management of the articles when the article_deletion option is active:<ul><li>0 : No change</li><li>1 : The article is move to the end of the page name inside brackets</li><li>2 or more : The article is deleted</li></ul>';
$lang['empty_msg'] = 'Message shown in your page when the index is empty.<br>Note : {{ns}} is an alias for the requested namespace.';
$lang['title_tpl'] = 'Template (in dokuwiki syntax) for the index title.';
$lang['begin_letter_tpl'] = "Template (in dokuwiki syntax) at the beginning of each letter's blok.<br>Note : the {{letter}} pattern is mandatory. It's an alias for the current letter.";
$lang['entry_tpl'] = "Template (in dokuwiki syntax) for each letter's entry.<br>Note : the {{link}} and {{name}} patterns are mandatory.They are aliases for the page link and the page name.";
$lang['end_letter_tpl'] = "Template (in dokuwiki syntax) at the end of each letter's block.";
$lang['hidepages'] = "Name of pages not displayed in the index. Each page name is separated with a '|'.";
$lang['metadata_title'] = "Use first heading for pagenames";
51 changes: 19 additions & 32 deletions syntax.php
Expand Up @@ -7,22 +7,9 @@
* last modified: 2006-06-14 12:00:00 * last modified: 2006-06-14 12:00:00
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Hubert Molière <hubert.moliere@alternet.fr> * @author Hubert Molière <hubert.moliere@alternet.fr>
*/ * Modified by Nicolas H. <prog@a-et-n.com>

* Modified by Jonesy <jonesy@oryma.org>
/** * Modified by Samuele Tognini <samuele@netsons.org>
* Configuration additionnelle sp�cifique au plugin
*
* - $conf['plugin']['alphaindex']['numerical_index']
* - $conf['plugin']['alphaindex']['articles_deletion']
* - $conf['plugin']['alphaindex']['articles_moving']
* - $conf['plugin']['alphaindex']['empty_msg']
* - $conf['plugin']['alphaindex']['title_tpl']
* - $conf['plugin']['alphaindex']['begin_letter_tpl']
* - $conf['plugin']['alphaindex']['entry_tpl']
* - $conf['plugin']['alphaindex']['end_letter_tpl']
* - $conf['plugin']['alphaindex']['hidepages']
* - $conf['plugin']['alphaindex']['metadata_title'] (true/false)
*
*/ */


if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
Expand Down Expand Up @@ -94,12 +81,12 @@ function handle($match, $state, $pos, &$handler){
*/ */
function render($mode, &$renderer, $data) { function render($mode, &$renderer, $data) {
global $conf; global $conf;

if($mode == 'xhtml'){ if($mode == 'xhtml'){
$alpha_data = $this->_alpha_index($data, $renderer); $alpha_data = $this->_alpha_index($data, $renderer);
if ((!@$n)) { if ((!@$n)) {
if (isset ($conf['plugin']['']['empty_msg'])) { if ($this->getConf('empty_msg')) {
$n = $conf['plugin_alphaindex']['empty_msg']; $n = $this->getConf('empty_msg');
} else { } else {
$n = 'No index for <b>{{ns}}</b>'; $n = 'No index for <b>{{ns}}</b>';
} }
Expand Down Expand Up @@ -145,40 +132,40 @@ function _alpha_index($myns, &$renderer) {


// Articles deletion configuration // Articles deletion configuration
$articlesDeletionPatterns = array(); $articlesDeletionPatterns = array();
if(isset($conf['plugin']['alphaindex']['articles_deletion'])) { if($this->getConf('articles_deletion')) {
$articlesDeletionPatterns = explode('|', $conf['plugin']['alphaindex']['articles_deletion']); $articlesDeletionPatterns = explode('|', $this->getConf('articles_deletion'));
$articlesDeletion = true; $articlesDeletion = true;
} else { } else {
$articlesDeletion = false; $articlesDeletion = false;
} }


// Hide pages configuration // Hide pages configuration
$hidepages = array(); $hidepages = array();
if(isset($conf['plugin']['alphaindex']['hidepages'])) { if($this->getConf('hidepages')) {
$hidepages = explode('|', $conf['plugin']['alphaindex']['hidepages']); $hidepages = explode('|', $this->getConf('hidepages'));
} }


// template configuration // template configuration
if(isset($conf['plugin']['alphaindex']['title_tpl'])) { if($this->getConf('title_tpl')) {
$titleTpl = $conf['plugin']['alphaindex']['title_tpl']; $titleTpl = $this->getConf('title_tpl');
} else { } else {
$titleTpl = '===== Index ====='; $titleTpl = '===== Index =====';
} }


if(isset($conf['plugin']['alphaindex']['begin_letter_tpl'])) { if($this->getConf('begin_letter_tpl')) {
$beginLetterTpl = $conf['plugin']['alphaindex']['begin_letter_tpl']; $beginLetterTpl = $this->getConf('begin_letter_tpl');
} else { } else {
$beginLetterTpl = '==== {{letter}} ===='; $beginLetterTpl = '==== {{letter}} ====';
} }


if(isset($conf['plugin']['alphaindex']['entry_tpl'])) { if($this->getConf('entry_tpl')) {
$entryTpl = $conf['plugin']['alphaindex']['entry_tpl']; $entryTpl = $this->getConf('entry_tpl');
} else { } else {
$entryTpl = ' * [[{{link}}|{{name}}]]'; $entryTpl = ' * [[{{link}}|{{name}}]]';
} }


if(isset($conf['plugin']['alphaindex']['end_letter_tpl'])) { if($this->getConf('end_letter_tpl')) {
$endLetterTpl = $conf['plugin']['alphaindex']['end_letter_tpl']; $endLetterTpl = $this->getConf('end_letter_tpl');
} else { } else {
$endLetterTpl = ''; $endLetterTpl = '';
} }
Expand Down Expand Up @@ -238,7 +225,7 @@ function _alpha_index($myns, &$renderer) {
} }


// Fix for useheading - Decide if the heading is used or the pagename // Fix for useheading - Decide if the heading is used or the pagename
if(isset($conf['plugin']['alphaindex']['metadata_title'])) { if($this->getConf('metadata_title')) {
$tmp = p_get_metadata($data[$cpt]['id']); $tmp = p_get_metadata($data[$cpt]['id']);
if(isset($tmp['title'])) $pageName = $tmp['title']; if(isset($tmp['title'])) $pageName = $tmp['title'];
} }
Expand Down

0 comments on commit 92fe437

Please sign in to comment.