mirror of
https://github.com/cosmocode/dokuwiki-plugin-struct.git
synced 2025-07-20 16:50:35 +00:00
initial wizard generated structure
This commit is contained in:
13
.travis.yml
Normal file
13
.travis.yml
Normal file
@ -0,0 +1,13 @@
|
||||
# Config file for travis-ci.org
|
||||
|
||||
language: php
|
||||
php:
|
||||
- "5.5"
|
||||
- "5.4"
|
||||
- "5.3"
|
||||
env:
|
||||
- DOKUWIKI=master
|
||||
- DOKUWIKI=stable
|
||||
before_install: wget https://raw.github.com/splitbrain/dokuwiki-travis/master/travis.sh
|
||||
install: sh travis.sh
|
||||
script: cd _test && phpunit --stderr --group plugin_struct
|
27
README
Normal file
27
README
Normal file
@ -0,0 +1,27 @@
|
||||
struct Plugin for DokuWiki
|
||||
|
||||
Add and query additional structured page data
|
||||
|
||||
All documentation for this plugin can be found at
|
||||
https://www.dokuwiki.org/plugin:struct
|
||||
|
||||
If you install this plugin manually, make sure it is installed in
|
||||
lib/plugins/struct/ - 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) Andreas Gohr, Michael Große <dokuwiki@cosmocode.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
|
33
_test/general.test.php
Normal file
33
_test/general.test.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* General tests for the struct plugin
|
||||
*
|
||||
* @group plugin_struct
|
||||
* @group plugins
|
||||
*/
|
||||
class general_plugin_struct_test extends DokuWikiTest {
|
||||
|
||||
/**
|
||||
* Simple test to make sure the plugin.info.txt is in correct format
|
||||
*/
|
||||
public function test_plugininfo() {
|
||||
$file = __DIR__.'/../plugin.info.txt';
|
||||
$this->assertFileExists($file);
|
||||
|
||||
$info = confToHash($file);
|
||||
|
||||
$this->assertArrayHasKey('base', $info);
|
||||
$this->assertArrayHasKey('author', $info);
|
||||
$this->assertArrayHasKey('email', $info);
|
||||
$this->assertArrayHasKey('date', $info);
|
||||
$this->assertArrayHasKey('name', $info);
|
||||
$this->assertArrayHasKey('desc', $info);
|
||||
$this->assertArrayHasKey('url', $info);
|
||||
|
||||
$this->assertEquals('struct', $info['base']);
|
||||
$this->assertRegExp('/^https?:\/\//', $info['url']);
|
||||
$this->assertTrue(mail_isvalid($info['email']));
|
||||
$this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']);
|
||||
$this->assertTrue(false !== strtotime($info['date']));
|
||||
}
|
||||
}
|
40
action/entry.php
Normal file
40
action/entry.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* DokuWiki Plugin struct (Action Component)
|
||||
*
|
||||
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Andreas Gohr, Michael Große <dokuwiki@cosmocode.de>
|
||||
*/
|
||||
|
||||
// must be run within Dokuwiki
|
||||
if(!defined('DOKU_INC')) die();
|
||||
|
||||
class action_plugin_struct_entry extends DokuWiki_Action_Plugin {
|
||||
|
||||
/**
|
||||
* Registers a callback function for a given event
|
||||
*
|
||||
* @param Doku_Event_Handler $controller DokuWiki's event controller object
|
||||
* @return void
|
||||
*/
|
||||
public function register(Doku_Event_Handler $controller) {
|
||||
|
||||
$controller->register_hook('FIXME', 'FIXME', $this, 'handle_fixme');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* [Custom event handler which performs action]
|
||||
*
|
||||
* @param Doku_Event $event event object by reference
|
||||
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
|
||||
* handler was registered]
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function handle_fixme(Doku_Event &$event, $param) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim:ts=4:sw=4:et:
|
42
admin.php
Normal file
42
admin.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* DokuWiki Plugin struct (Admin Component)
|
||||
*
|
||||
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Andreas Gohr, Michael Große <dokuwiki@cosmocode.de>
|
||||
*/
|
||||
|
||||
// must be run within Dokuwiki
|
||||
if(!defined('DOKU_INC')) die();
|
||||
|
||||
class admin_plugin_struct extends DokuWiki_Admin_Plugin {
|
||||
|
||||
/**
|
||||
* @return int sort number in admin menu
|
||||
*/
|
||||
public function getMenuSort() {
|
||||
return FIXME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool true if only access for superuser, false is for superusers and moderators
|
||||
*/
|
||||
public function forAdminOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should carry out any processing required by the plugin.
|
||||
*/
|
||||
public function handle() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Render HTML output, e.g. helpful text and a form
|
||||
*/
|
||||
public function html() {
|
||||
ptln('<h1>'.$this->getLang('menu').'</h1>');
|
||||
}
|
||||
}
|
||||
|
||||
// vim:ts=4:sw=4:et:
|
8
conf/default.php
Normal file
8
conf/default.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Default settings for the struct plugin
|
||||
*
|
||||
* @author Andreas Gohr, Michael Große <dokuwiki@cosmocode.de>
|
||||
*/
|
||||
|
||||
//$conf['fixme'] = 'FIXME';
|
10
conf/metadata.php
Normal file
10
conf/metadata.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* Options for the struct plugin
|
||||
*
|
||||
* @author Andreas Gohr, Michael Große <dokuwiki@cosmocode.de>
|
||||
*/
|
||||
|
||||
|
||||
//$meta['fixme'] = array('string');
|
||||
|
38
helper/db.php
Normal file
38
helper/db.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* DokuWiki Plugin struct (Helper Component)
|
||||
*
|
||||
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Andreas Gohr, Michael Große <dokuwiki@cosmocode.de>
|
||||
*/
|
||||
|
||||
// must be run within Dokuwiki
|
||||
if(!defined('DOKU_INC')) die();
|
||||
|
||||
class helper_plugin_struct_db extends DokuWiki_Plugin {
|
||||
|
||||
/**
|
||||
* Return info about supported methods in this Helper Plugin
|
||||
*
|
||||
* @return array of public methods
|
||||
*/
|
||||
public function getMethods() {
|
||||
return array(
|
||||
array(
|
||||
'name' => 'getThreads',
|
||||
'desc' => 'returns pages with discussion sections, sorted by recent comments',
|
||||
'params' => array(
|
||||
'namespace' => 'string',
|
||||
'number (optional)' => 'integer'
|
||||
),
|
||||
'return' => array('pages' => 'array')
|
||||
),
|
||||
array(
|
||||
// and more supported methods...
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim:ts=4:sw=4:et:
|
16
lang/en/lang.php
Normal file
16
lang/en/lang.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* English language file for struct plugin
|
||||
*
|
||||
* @author Andreas Gohr, Michael Große <dokuwiki@cosmocode.de>
|
||||
*/
|
||||
|
||||
// menu entry for admin plugins
|
||||
// $lang['menu'] = 'Your menu entry';
|
||||
|
||||
// custom language strings for the plugin
|
||||
// $lang['fixme'] = 'FIXME';
|
||||
|
||||
|
||||
|
||||
//Setup VIM: ex: et ts=4 :
|
13
lang/en/settings.php
Normal file
13
lang/en/settings.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* english language file for struct plugin
|
||||
*
|
||||
* @author Andreas Gohr, Michael Große <dokuwiki@cosmocode.de>
|
||||
*/
|
||||
|
||||
// keys need to match the config setting name
|
||||
// $lang['fixme'] = 'FIXME';
|
||||
|
||||
|
||||
|
||||
//Setup VIM: ex: et ts=4 :
|
7
plugin.info.txt
Normal file
7
plugin.info.txt
Normal file
@ -0,0 +1,7 @@
|
||||
base struct
|
||||
author Andreas Gohr, Michael Große
|
||||
email dokuwiki@cosmocode.de
|
||||
date 2015-12-17
|
||||
name struct plugin
|
||||
desc Add and query additional structured page data
|
||||
url https://www.dokuwiki.org/plugin:struct
|
76
syntax/list.php
Normal file
76
syntax/list.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* DokuWiki Plugin struct (Syntax Component)
|
||||
*
|
||||
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Andreas Gohr, Michael Große <dokuwiki@cosmocode.de>
|
||||
*/
|
||||
|
||||
// must be run within Dokuwiki
|
||||
if (!defined('DOKU_INC')) die();
|
||||
|
||||
class syntax_plugin_struct_list extends DokuWiki_Syntax_Plugin {
|
||||
/**
|
||||
* @return string Syntax mode type
|
||||
*/
|
||||
public function getType() {
|
||||
return 'FIXME: container|baseonly|formatting|substition|protected|disabled|paragraphs';
|
||||
}
|
||||
/**
|
||||
* @return string Paragraph type
|
||||
*/
|
||||
public function getPType() {
|
||||
return 'FIXME: normal|block|stack';
|
||||
}
|
||||
/**
|
||||
* @return int Sort order - Low numbers go before high numbers
|
||||
*/
|
||||
public function getSort() {
|
||||
return FIXME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect lookup pattern to lexer.
|
||||
*
|
||||
* @param string $mode Parser mode
|
||||
*/
|
||||
public function connectTo($mode) {
|
||||
$this->Lexer->addSpecialPattern('<FIXME>',$mode,'plugin_struct_list');
|
||||
// $this->Lexer->addEntryPattern('<FIXME>',$mode,'plugin_struct_list');
|
||||
}
|
||||
|
||||
// public function postConnect() {
|
||||
// $this->Lexer->addExitPattern('</FIXME>','plugin_struct_list');
|
||||
// }
|
||||
|
||||
/**
|
||||
* Handle matches of the struct syntax
|
||||
*
|
||||
* @param string $match The match of the syntax
|
||||
* @param int $state The state of the handler
|
||||
* @param int $pos The position in the document
|
||||
* @param Doku_Handler $handler The handler
|
||||
* @return array Data for the renderer
|
||||
*/
|
||||
public function handle($match, $state, $pos, Doku_Handler &$handler){
|
||||
$data = array();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render xhtml output or metadata
|
||||
*
|
||||
* @param string $mode Renderer mode (supported modes: xhtml)
|
||||
* @param Doku_Renderer $renderer The renderer
|
||||
* @param array $data The data from the handler() function
|
||||
* @return bool If rendering was successful.
|
||||
*/
|
||||
public function render($mode, Doku_Renderer &$renderer, $data) {
|
||||
if($mode != 'xhtml') return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// vim:ts=4:sw=4:et:
|
76
syntax/table.php
Normal file
76
syntax/table.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* DokuWiki Plugin struct (Syntax Component)
|
||||
*
|
||||
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Andreas Gohr, Michael Große <dokuwiki@cosmocode.de>
|
||||
*/
|
||||
|
||||
// must be run within Dokuwiki
|
||||
if (!defined('DOKU_INC')) die();
|
||||
|
||||
class syntax_plugin_struct_table extends DokuWiki_Syntax_Plugin {
|
||||
/**
|
||||
* @return string Syntax mode type
|
||||
*/
|
||||
public function getType() {
|
||||
return 'FIXME: container|baseonly|formatting|substition|protected|disabled|paragraphs';
|
||||
}
|
||||
/**
|
||||
* @return string Paragraph type
|
||||
*/
|
||||
public function getPType() {
|
||||
return 'FIXME: normal|block|stack';
|
||||
}
|
||||
/**
|
||||
* @return int Sort order - Low numbers go before high numbers
|
||||
*/
|
||||
public function getSort() {
|
||||
return FIXME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect lookup pattern to lexer.
|
||||
*
|
||||
* @param string $mode Parser mode
|
||||
*/
|
||||
public function connectTo($mode) {
|
||||
$this->Lexer->addSpecialPattern('<FIXME>',$mode,'plugin_struct_table');
|
||||
// $this->Lexer->addEntryPattern('<FIXME>',$mode,'plugin_struct_table');
|
||||
}
|
||||
|
||||
// public function postConnect() {
|
||||
// $this->Lexer->addExitPattern('</FIXME>','plugin_struct_table');
|
||||
// }
|
||||
|
||||
/**
|
||||
* Handle matches of the struct syntax
|
||||
*
|
||||
* @param string $match The match of the syntax
|
||||
* @param int $state The state of the handler
|
||||
* @param int $pos The position in the document
|
||||
* @param Doku_Handler $handler The handler
|
||||
* @return array Data for the renderer
|
||||
*/
|
||||
public function handle($match, $state, $pos, Doku_Handler &$handler){
|
||||
$data = array();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render xhtml output or metadata
|
||||
*
|
||||
* @param string $mode Renderer mode (supported modes: xhtml)
|
||||
* @param Doku_Renderer $renderer The renderer
|
||||
* @param array $data The data from the handler() function
|
||||
* @return bool If rendering was successful.
|
||||
*/
|
||||
public function render($mode, Doku_Renderer &$renderer, $data) {
|
||||
if($mode != 'xhtml') return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// vim:ts=4:sw=4:et:
|
Reference in New Issue
Block a user