Changeset 87:2aa5a27cb797

mearie.org/pub

← 85:1db531fb5aaf ← 86:57e47236724a 87:2aa5a27cb797 pub.mearie.org 88:aa5c13b0f192
Author:
Kang Seonghoon <public+hg@mearie.org>
Committed on

merged with additional csses for altindex.

Files

lib/tpl/mearie/layout.css

Diff

     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/lib/plugins/altindex/action.php	Wed Jun 23 02:16:43 2010 +0900
     1.3 @@ -0,0 +1,161 @@
     1.4 +<?php
     1.5 +if (!defined('DOKU_INC')) die('what the...?!');
     1.6 +if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/');
     1.7 +require_once(DOKU_PLUGIN.'action.php');
     1.8 +
     1.9 +define('ALTINDEX_SKIPPING', 0);
    1.10 +define('ALTINDEX_INPAGE', 1);
    1.11 +define('ALTINDEX_DONE', 2);
    1.12 +
    1.13 +class action_plugin_altindex extends DokuWiki_Action_Plugin {
    1.14 +	function getInfo() {
    1.15 +		return array(
    1.16 +			'author' => 'Kang Seonghoon',
    1.17 +			'email' => 'public+dokuwiki@mearie.org',
    1.18 +			'date' => '2010-06-22',
    1.19 +			'name' => 'Alternative Index',
    1.20 +			'desc' => 'Alternative index implementation with paging and support for redirections.',
    1.21 +			'url' => '');
    1.22 +	}
    1.23 +
    1.24 +	function register(&$controller) {
    1.25 +		$controller->register_hook('TPL_ACT_RENDER', 'BEFORE', $this, 'html_altindex');
    1.26 +	}
    1.27 +
    1.28 +	function html_altindex(&$event) {
    1.29 +		global $conf, $lang, $ID, $IDX;
    1.30 +		if ($event->data != 'index') return;
    1.31 +
    1.32 +		require_once(DOKU_INC.'inc/search.php');
    1.33 +
    1.34 +		// parse the request arguments
    1.35 +		$idx = cleanID($IDX);
    1.36 +		if (empty($idx)) {
    1.37 +			$ns = dirname(str_replace(':', '/', $ID));
    1.38 +			if ($ns == '.') $ns = '';
    1.39 +		} else {
    1.40 +			$ns = str_replace(':', '/', $idx);
    1.41 +		}
    1.42 +
    1.43 +		$ns = utf8_encodeFN($ns);
    1.44 +		if (is_array($_REQUEST['first'])) {
    1.45 +			$_REQUEST['first'] = array_keys($_REQUEST['first']);
    1.46 +			$_REQUEST['first'] = $_REQUEST['first'][0];
    1.47 +		}
    1.48 +		$first = is_numeric($_REQUEST['first']) ? intval($_REQUEST['first']) : 0;
    1.49 +
    1.50 +		$count = $this->getConf('altindex');
    1.51 +
    1.52 +		// print the index
    1.53 +		echo p_locale_xhtml('index');
    1.54 +
    1.55 +		$form = new Doku_Form(array('id' => 'altindex__tree', 'method' => 'GET'));
    1.56 +		$form->addHidden('sectok', null);
    1.57 +		$form->addHidden('do', 'index');
    1.58 +		if ($idx) $form->addHidden('idx', $idx);
    1.59 +		$form->addElement(form_makeOpenTag('ul', array('class' => 'idx')));
    1.60 +
    1.61 +		$data = array();
    1.62 +		$current = array('form' => &$form, 'state' => ALTINDEX_SKIPPING, 'index' => 0, 'hasnext' => false);
    1.63 +		search($current, $conf['datadir'], array(&$this, '_search_callback'),
    1.64 +			array('ns' => $ns, 'idx' => $idx, 'first' => $first, 'count' => $count), $ns);
    1.65 +
    1.66 +		$form->addElement(form_makeCloseTag('ul'));
    1.67 +		$form->addElement(form_makeOpenTag('div', array('class' => 'pagenav')));
    1.68 +		$last = $first + $count;
    1.69 +		if ($first > 0) {
    1.70 +			$first -= $count;
    1.71 +			if ($first < 0) $first = 0;
    1.72 +			$form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-prev')));
    1.73 +			$form->addElement(form_makeTag('input', array(
    1.74 +				'type'  => 'submit',
    1.75 +				'name'  => 'first['.$first.']',
    1.76 +				'value' => $this->getLang('btn_previous'),
    1.77 +				'accesskey' => 'p',
    1.78 +				'title' => $this->getLang('btn_previous').' [p]',
    1.79 +				'class' => 'button'
    1.80 +			)));
    1.81 +			$form->addElement(form_makeCloseTag('div'));
    1.82 +		}
    1.83 +		if ($current['hasnext']) {
    1.84 +			$form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-next')));
    1.85 +			$form->addElement(form_makeTag('input', array(
    1.86 +				'type'  => 'submit',
    1.87 +				'name'  => 'first['.$last.']',
    1.88 +				'value' => $this->getLang('btn_next'),
    1.89 +				'accesskey' => 'n',
    1.90 +				'title' => $this->getLang('btn_next').' [n]',
    1.91 +				'class' => 'button'
    1.92 +			)));
    1.93 +			$form->addElement(form_makeCloseTag('div'));
    1.94 +		}
    1.95 +		$form->addElement(form_makeCloseTag('div'));
    1.96 +		html_form('index', $form);
    1.97 +
    1.98 +		$event->preventDefault();
    1.99 +		$event->stopPropagation();
   1.100 +	}
   1.101 +
   1.102 +	function _search_callback(&$current, $base, $file, $type, $lvl, $opts) {
   1.103 +		switch ($current['state']) {
   1.104 +		case ALTINDEX_SKIPPING:
   1.105 +			if ($current['index'] < $opts['first']) {
   1.106 +				$data = array();
   1.107 +				$ret = search_index($data, $base, $file, $type, $lvl, $opts);
   1.108 +				if (count($data) > 0) ++$current['index'];
   1.109 +				return $ret;
   1.110 +			}
   1.111 +			$current['state'] = ALTINDEX_INPAGE;
   1.112 +			$current['index'] = 0;
   1.113 +
   1.114 +		case ALTINDEX_INPAGE:
   1.115 +			if ($current['index'] < $opts['count']) {
   1.116 +				$data = array();
   1.117 +				$ret = search_index($data, $base, $file, $type, $lvl, $opts);
   1.118 +				if (count($data) > 0) {
   1.119 +					$this->_search_item($current['form'], $data[0], $opts);
   1.120 +					++$current['index'];
   1.121 +				}
   1.122 +				return $ret;
   1.123 +			}
   1.124 +			$current['state'] = ALTINDEX_DONE;
   1.125 +
   1.126 +		case ALTINDEX_DONE:
   1.127 +			if (!$current['hasnext']) {
   1.128 +				$data = array();
   1.129 +				$ret = search_index($data, $base, $file, $type, $lvl, $opts);
   1.130 +				if (count($data) > 0) $current['hasnext'] = true;
   1.131 +				return $ret;
   1.132 +			}
   1.133 +		}
   1.134 +		return false;
   1.135 +	}
   1.136 +
   1.137 +	function _search_item(&$form, $item, $opts) {
   1.138 +		global $ID;
   1.139 +
   1.140 +		$class = 'level'.$item['level'];
   1.141 +		$target = null;
   1.142 +		$meta = p_get_metadata($item['id']);
   1.143 +		if (isset($meta['relation']['isreplacedby'])) {
   1.144 +			$class .= ' redirection';
   1.145 +			$target = $meta['relation']['isreplacedby'];
   1.146 +		}
   1.147 +
   1.148 +		$form->addElement(form_makeOpenTag('li', array('class' => $class)));
   1.149 +		$form->addElement(form_makeOpenTag('div', array('class' => 'li')));
   1.150 +		if ($item['type'] == 'f') {
   1.151 +			$form->addElement(html_wikilink($item['id']));
   1.152 +			if (!is_null($target)) $form->addElement('<span> → '.html_wikilink($target).'</span>');
   1.153 +		} else {
   1.154 +			$base = ':'.$item['id'];
   1.155 +			$base = substr($base,strrpos($base,':')+1);
   1.156 +			$form->addElement('<a href="'.
   1.157 +				wl($ID,'do=index&amp;idx='.rawurlencode($item['id'])).
   1.158 +				'" class="idx_dir"><strong>'.$base.'</strong></a>');
   1.159 +		}
   1.160 +		$form->addElement(form_makeCloseTag('div'));
   1.161 +		$form->addElement(form_makeCloseTag('li'));
   1.162 +	}
   1.163 +}
   1.164 +
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/lib/plugins/altindex/conf/default.php	Wed Jun 23 02:16:43 2010 +0900
     2.3 @@ -0,0 +1,3 @@
     2.4 +<?php
     2.5 +$conf['altindex'] = 50; // number of index items per page
     2.6 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/lib/plugins/altindex/conf/metadata.php	Wed Jun 23 02:16:43 2010 +0900
     3.3 @@ -0,0 +1,3 @@
     3.4 +<?php
     3.5 +$meta['altindex'] = array('numeric');
     3.6 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/lib/plugins/altindex/lang/en/lang.php	Wed Jun 23 02:16:43 2010 +0900
     4.3 @@ -0,0 +1,11 @@
     4.4 +<?php
     4.5 +/**
     4.6 + * English language for Altindex plugin
     4.7 + *
     4.8 + * @license:    GPL 2 (http://www.gnu.org/licenses/gpl.html)
     4.9 + * @author:     Kang Seonghoon <public+dokuwiki@mearie.org>
    4.10 + */
    4.11 +
    4.12 +$lang['btn_previous'] = '<< Previous';
    4.13 +$lang['btn_next'] = 'Next >>';
    4.14 +
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/lib/plugins/altindex/lang/en/settings.php	Wed Jun 23 02:16:43 2010 +0900
     5.3 @@ -0,0 +1,10 @@
     5.4 +<?php
     5.5 +/**
     5.6 + * English language for Altindex plugin
     5.7 + *
     5.8 + * @license:    GPL 2 (http://www.gnu.org/licenses/gpl.html)
     5.9 + * @author:     Kang Seonghoon <public+dokuwiki@mearie.org>
    5.10 + */
    5.11 +
    5.12 +$lang['altindex'] = 'Number of items per page in the index';
    5.13 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/lib/plugins/altindex/lang/ko/lang.php	Wed Jun 23 02:16:43 2010 +0900
     6.3 @@ -0,0 +1,11 @@
     6.4 +<?php
     6.5 +/**
     6.6 + * Korean language for Altindex plugin
     6.7 + *
     6.8 + * @license:    GPL 2 (http://www.gnu.org/licenses/gpl.html)
     6.9 + * @author:     Kang Seonghoon <public+dokuwiki@mearie.org>
    6.10 + */
    6.11 +
    6.12 +$lang['btn_previous'] = '<< 이전';
    6.13 +$lang['btn_next'] = '다음 >>';
    6.14 +
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/lib/plugins/altindex/lang/ko/settings.php	Wed Jun 23 02:16:43 2010 +0900
     7.3 @@ -0,0 +1,10 @@
     7.4 +<?php
     7.5 +/**
     7.6 + * Korean language for Altindex plugin
     7.7 + *
     7.8 + * @license:    GPL 2 (http://www.gnu.org/licenses/gpl.html)
     7.9 + * @author:     Kang Seonghoon <public+dokuwiki@mearie.org>
    7.10 + */
    7.11 +
    7.12 +$lang['altindex'] = '색인에서 페이지 당 표시할 문서 수';
    7.13 +
     8.1 --- a/lib/tpl/mearie/layout.css	Fri Jun 18 02:31:40 2010 +0900
     8.2 +++ b/lib/tpl/mearie/layout.css	Wed Jun 23 02:16:43 2010 +0900
     8.3 @@ -178,7 +178,19 @@
     8.4  	cursor: pointer;
     8.5  }
     8.6  
     8.7 -/* recent changes */
     8.8 +/* recent changes, revisions and index */
     8.9 +div.dokuwiki #index__tree ul,
    8.10 +div.dokuwiki #altindex__tree ul {
    8.11 +	list-style-position: inside; /* temporary change for webkit bug which fails to render bullets */
    8.12 +	padding: 0;
    8.13 +	column-count: 2;
    8.14 +	-moz-column-count: 2;
    8.15 +	-webkit-column-count: 2;
    8.16 +}
    8.17 +div.dokuwiki #index__tree li div,
    8.18 +div.dokuwiki #altindex__tree li div {
    8.19 +	display: inline; /* due to gecko behavior; still cannot get rid of some spaces before it */
    8.20 +}
    8.21  div.dokuwiki #dw__recent ul,
    8.22  div.dokuwiki #page__revisions ul {
    8.23  	list-style: none;
    8.24 @@ -221,15 +233,29 @@
    8.25  div.dokuwiki a.diff_link, div.dokuwiki a.revisions_link {
    8.26  	text-decoration: none;
    8.27  }
    8.28 -div.dokuwiki li.minor {
    8.29 +div.dokuwiki li.minor,
    8.30 +div.dokuwiki li.redirection {
    8.31  	font-style: italic;
    8.32  }
    8.33 -div.dokuwiki li.minor a.wikilink1 {
    8.34 +div.dokuwiki li.minor a.wikilink1,
    8.35 +div.dokuwiki li.redirection a.wikilink1 {
    8.36  	color: #8ab;
    8.37  }
    8.38 -div.dokuwiki li.minor a.wikilink2 {
    8.39 +div.dokuwiki li.minor a.wikilink2,
    8.40 +div.dokuwiki li.redirection a.wikilink2 {
    8.41  	color: #b8a;
    8.42  }
    8.43 +div.dokuwiki li.redirection span a.wikilink1 {
    8.44 +	color: #379;
    8.45 +}
    8.46 +div.dokuwiki li.redirection span a.wikilink2 {
    8.47 +	color: #937;
    8.48 +}
    8.49 +div.dokuwiki li.minor a:hover, div.dokuwiki li.minor a:active,
    8.50 +div.dokuwiki li.redirection a:hover, div.dokuwiki li.redirection a:active,
    8.51 +div.dokuwiki li.redirection span a:hover, div.dokuwiki li.redirection span a:active {
    8.52 +	color: #973;
    8.53 +}
    8.54  div.dokuwiki div.pagenav-prev {
    8.55  	float: left;
    8.56  	margin-top: 0.5em;

Powered by Mercurial