-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matthias Schulte
committed
Aug 2, 2013
0 parents
commit 47d0693
Showing
10 changed files
with
221 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
hidepages Plugin for DokuWiki | ||
|
||
Hide pages from search results and/or sitemap | ||
|
||
All documentation for this plugin can be found at | ||
https://www.dokuwiki.org/plugin:hidepages | ||
|
||
If you install this plugin manually, make sure it is installed in | ||
lib/plugins/hidepages/ - if the folder is called different it | ||
will not work! | ||
|
||
Please refer to http://www.dokuwiki.org/plugins for additional info | ||
on how to install plugins in DokuWiki. | ||
|
||
---- | ||
Copyright (C) Matthias Schulte <dokuwiki@lupo49.de> | ||
|
||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; version 2 of the License | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
See the COPYING file in your DokuWiki folder for details |
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,58 @@ | ||
<?php | ||
/** | ||
* DokuWiki Plugin hidepages (Action Component) | ||
* | ||
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html | ||
* @author Matthias Schulte <dokuwiki@lupo49.de> | ||
*/ | ||
|
||
// must be run within Dokuwiki | ||
if (!defined('DOKU_INC')) die(); | ||
|
||
if (!defined('DOKU_LF')) define('DOKU_LF', "\n"); | ||
if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t"); | ||
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); | ||
|
||
require_once DOKU_PLUGIN.'action.php'; | ||
|
||
class action_plugin_hidepages extends DokuWiki_Action_Plugin { | ||
|
||
public function register(Doku_Event_Handler &$controller) { | ||
$controller->register_hook('PAGEUTILS_ID_HIDEPAGE', 'BEFORE', $this, 'handle_hidepages'); | ||
} | ||
|
||
public function handle_hidepages(Doku_Event &$event, $param) { | ||
global $ACT; | ||
global $conf; | ||
global $INPUT; | ||
|
||
// get page id from current result | ||
$pageID = $event->data['id']; | ||
$isHidden = $event->data['hidden']; | ||
|
||
// skip if page is already marked as hidden or when the admin wants to see all pages | ||
if($isHidden || $this->getConf('ignorepattern')) return true; | ||
|
||
$metaSearch = (p_get_metadata($pageID, 'hidepage_search') ? true : false); | ||
$metaSitemap = (p_get_metadata($pageID, 'hidepage_sitemap') ? true : false); | ||
|
||
// check if event is fired by quicksearch or sitemap ajax request | ||
$isQsearch = ($INPUT->post->str('call') == 'qsearch' ? true : false); | ||
$isAjaxIndex = ($INPUT->post->str('call') == 'index' ? true : false); | ||
|
||
// Hide pages from quicksearch and search result page | ||
if(($ACT == 'search' || $isQsearch) && $metaSearch == true) { | ||
if($conf['allowdebug']) dbg("hidepages plugin - suppressed page: " . $pageID); | ||
$event->data['hidden'] = true; | ||
} | ||
|
||
if(($ACT == 'index' || $isAjaxIndex) && $metaSitemap == true) { | ||
if($conf['allowdebug']) dbg("hidepages plugin - suppressed page: " . $pageID); | ||
$event->data['hidden'] = true; | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
|
||
// vim:ts=4:sw=4:et: |
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,10 @@ | ||
<?php | ||
/** | ||
* Default settings for the hidepages plugin | ||
* | ||
* @author Matthias Schulte <dokuwiki@lupo49.de> | ||
*/ | ||
|
||
$conf['ignorepattern'] = 0; | ||
$conf['hidefromsearch'] = 1; | ||
$conf['hidefromsitemap'] = 1; |
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,10 @@ | ||
<?php | ||
/** | ||
* Options for the hidepages plugin | ||
* | ||
* @author Matthias Schulte <dokuwiki@lupo49.de> | ||
*/ | ||
|
||
$meta['ignorepattern'] = array('onoff'); | ||
$meta['hidefromsearch'] = array('onoff');; | ||
$meta['hidefromsitemap'] = array('onoff');; |
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,8 @@ | ||
<?php | ||
/** | ||
* English language file for hidepages plugin | ||
* | ||
* @author Matthias Schulte <dokuwiki@lupo49.de> | ||
*/ | ||
|
||
//Setup VIM: ex: et ts=4 : |
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,12 @@ | ||
<?php | ||
/** | ||
* english language file for hidepages plugin | ||
* | ||
* @author Matthias Schulte <dokuwiki@lupo49.de> | ||
*/ | ||
|
||
$lang['ignorepattern'] = 'Pluginfunktion außer Kraft setzen und alle Seiten anzeigen.'; | ||
$lang['hidefromsearch'] = 'Seiten von der Suche ausblenden, wenn nur ~~HIDEPAGE~~ verwendet wird.'; | ||
$lang['hidefromsitemap'] = 'Seiten von der Übersichtsseite ausblenden, wenn nur ~~HIDEPAGE~~ verwendet wird.'; | ||
|
||
//Setup VIM: ex: et ts=4 : |
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,8 @@ | ||
<?php | ||
/** | ||
* English language file for hidepages plugin | ||
* | ||
* @author Matthias Schulte <dokuwiki@lupo49.de> | ||
*/ | ||
|
||
//Setup VIM: ex: et ts=4 : |
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,12 @@ | ||
<?php | ||
/** | ||
* english language file for hidepages plugin | ||
* | ||
* @author Matthias Schulte <dokuwiki@lupo49.de> | ||
*/ | ||
|
||
$lang['ignorepattern'] = 'Ignore syntax and unhide all pages'; | ||
$lang['hidefromsearch'] = 'Hide pages from search result when ~~HIDEPAGE~~ is used'; | ||
$lang['hidefromsitemap'] = 'Hide pages from sitemap when ~~HIDEPAGE~~ is used'; | ||
|
||
//Setup VIM: ex: et ts=4 : |
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,7 @@ | ||
base hidepages | ||
author Matthias Schulte | ||
email dokuwiki@lupo49.de | ||
date 2013-08-02 | ||
name hidepages plugin | ||
desc Hide pages from search results and/or sitemap | ||
url https://www.dokuwiki.org/plugin:hidepages |
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,69 @@ | ||
<?php | ||
/** | ||
* DokuWiki Plugin hidepages (Syntax Component) | ||
* | ||
* Syntax: ~~NOSIDEBAR~~ | ||
* | ||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html) | ||
* @author Matthias Schulte <dokuwiki@lupo49.de> | ||
* @version 2013-08-02 | ||
*/ | ||
|
||
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); | ||
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); | ||
require_once(DOKU_PLUGIN.'syntax.php'); | ||
|
||
class syntax_plugin_hidepages extends DokuWiki_Syntax_Plugin { | ||
|
||
function getType(){ return 'substition'; } | ||
function getPType(){ return 'normal'; } | ||
function getSort(){ return 990; } | ||
|
||
function connectTo($mode) { | ||
$this->Lexer->addSpecialPattern('~~HIDEPAGE.*~~', $mode, 'plugin_hidepages'); | ||
} | ||
|
||
function handle($match, $state, $pos, &$handler){ | ||
$data = array(); | ||
$match = hsc(trim($match)); | ||
|
||
if($match == '~~HIDEPAGE~~') { | ||
if($this->getConf('hidefromsearch')) array_push($data, 'search'); | ||
if($this->getConf('hidefromsitemap')) array_push($data, 'sitemap'); | ||
} else { | ||
// extract parameters search and sitemap if passed | ||
$param = utf8_substr($match, 11, -2); | ||
|
||
// $param could be "sitemap" or "sitemap;search" | ||
if(utf8_strpos($param, ';') !== false) { | ||
$param = explode(';', $param); | ||
} | ||
|
||
if($param == 'sitemap' || (is_array($param) && in_array('sitemap', $param))) { | ||
array_push($data, 'sitemap'); | ||
} | ||
|
||
if($param == 'search' || (is_array($param) && in_array('search', $param))) { | ||
array_push($data, 'search'); | ||
} | ||
} | ||
|
||
return $data; | ||
} | ||
|
||
function render($mode, &$renderer, $data) { | ||
if($mode == "metadata") { | ||
// set flag in metadata to hide page in action component | ||
if(!is_array($data)) { | ||
$renderer->meta['hidepage_sitemap'] = true; | ||
$renderer->meta['hidepage_search'] = true; | ||
} else { | ||
if(in_array('sitemap', $data)) $renderer->meta['hidepage_sitemap'] = true; | ||
if(in_array('search', $data)) $renderer->meta['hidepage_search'] = true; | ||
} | ||
} | ||
return true; | ||
} | ||
} | ||
|
||
//Setup VIM: ex: et ts=4 enc=utf-8 : |