forked from dokufreaks/plugin-include
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add (r)sort and order flags for namespace includes dokufreaks#96 doku…
…freaks#61 This adds the following ordering criterias: - page ID (current behavior, default) - title - date created - date modified - indexmenu sort tag metadata - include plugin sort tag metadata (new syntax: {{include_n>[number]}}) When the rsort flag is set, the ordering will be reversed. Both flags are available as configuration option, too.
- Loading branch information
Showing
6 changed files
with
137 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,7 @@ function handle($match, $state, $pos, &$handler) { | |
|
||
// break the pattern up into its parts | ||
list($mode, $page, $sect) = preg_split('/>|#/u', $match, 3); | ||
$check = null; | ||
$check = false; | ||
if (isset($sect)) $sect = sectionID($sect, $check); | ||
return array($mode, $page, $sect, explode('&', $flags)); | ||
} | ||
|
@@ -87,7 +87,7 @@ function handle($match, $state, $pos, &$handler) { | |
* @author Michael Hamann <[email protected]> | ||
*/ | ||
function render($format, &$renderer, $data) { | ||
global $ID, $conf; | ||
global $ID; | ||
|
||
// static stack that records all ancestors of the child pages | ||
static $page_stack = array(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
if(!defined('DOKU_INC')) die(); | ||
|
||
/** | ||
* Include plugin sort order tag, idea and parts of the code copied from the indexmenu plugin. | ||
* | ||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html) | ||
* @author Samuele Tognini <[email protected]> | ||
* @author Michael Hamann <[email protected]> | ||
* | ||
*/ | ||
class syntax_plugin_include_sorttag extends DokuWiki_Syntax_Plugin { | ||
|
||
/** | ||
* What kind of syntax are we? | ||
*/ | ||
public function getType(){ | ||
return 'substition'; | ||
} | ||
|
||
/** | ||
* The paragraph type - block, we don't need paragraph tags | ||
* | ||
* @return string The paragraph type | ||
*/ | ||
public function getPType() { | ||
return 'block'; | ||
} | ||
|
||
/** | ||
* Where to sort in? | ||
*/ | ||
public function getSort(){ | ||
return 139; | ||
} | ||
|
||
/** | ||
* Connect pattern to lexer | ||
*/ | ||
public function connectTo($mode) { | ||
$this->Lexer->addSpecialPattern('{{include_n>.+?}}',$mode,'plugin_include_sorttag'); | ||
} | ||
|
||
/** | ||
* Handle the match | ||
*/ | ||
public function handle($match, $state, $pos, &$handler){ | ||
$match = substr($match,12,-2); | ||
return array($match); | ||
} | ||
|
||
/** | ||
* Render output | ||
*/ | ||
public function render($mode, &$renderer, $data) { | ||
if ($mode === 'metadata') { | ||
/** @var Doku_Renderer_metadata $renderer */ | ||
$renderer->meta['include_n'] = $data[0]; | ||
} | ||
} | ||
} |