From 549a0837397243f9208e2e78aa6597d7d762443d Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 17 Dec 2015 09:14:49 +0100 Subject: [PATCH] initial wizard generated structure --- .travis.yml | 13 ++++++++ README | 27 +++++++++++++++ _test/general.test.php | 33 ++++++++++++++++++ action/entry.php | 40 ++++++++++++++++++++++ admin.php | 42 +++++++++++++++++++++++ conf/default.php | 8 +++++ conf/metadata.php | 10 ++++++ helper/db.php | 38 +++++++++++++++++++++ lang/en/lang.php | 16 +++++++++ lang/en/settings.php | 13 ++++++++ plugin.info.txt | 7 ++++ syntax/list.php | 76 ++++++++++++++++++++++++++++++++++++++++++ syntax/table.php | 76 ++++++++++++++++++++++++++++++++++++++++++ 13 files changed, 399 insertions(+) create mode 100644 .travis.yml create mode 100644 README create mode 100644 _test/general.test.php create mode 100644 action/entry.php create mode 100644 admin.php create mode 100644 conf/default.php create mode 100644 conf/metadata.php create mode 100644 helper/db.php create mode 100644 lang/en/lang.php create mode 100644 lang/en/settings.php create mode 100644 plugin.info.txt create mode 100644 syntax/list.php create mode 100644 syntax/table.php diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..fa8243f --- /dev/null +++ b/.travis.yml @@ -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 \ No newline at end of file diff --git a/README b/README new file mode 100644 index 0000000..39e9777 --- /dev/null +++ b/README @@ -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 + +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 diff --git a/_test/general.test.php b/_test/general.test.php new file mode 100644 index 0000000..306f79f --- /dev/null +++ b/_test/general.test.php @@ -0,0 +1,33 @@ +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'])); + } +} diff --git a/action/entry.php b/action/entry.php new file mode 100644 index 0000000..f1ed11e --- /dev/null +++ b/action/entry.php @@ -0,0 +1,40 @@ + + */ + +// 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: diff --git a/admin.php b/admin.php new file mode 100644 index 0000000..f0220ca --- /dev/null +++ b/admin.php @@ -0,0 +1,42 @@ + + */ + +// 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('

'.$this->getLang('menu').'

'); + } +} + +// vim:ts=4:sw=4:et: \ No newline at end of file diff --git a/conf/default.php b/conf/default.php new file mode 100644 index 0000000..a02dbb0 --- /dev/null +++ b/conf/default.php @@ -0,0 +1,8 @@ + + */ + +//$conf['fixme'] = 'FIXME'; diff --git a/conf/metadata.php b/conf/metadata.php new file mode 100644 index 0000000..a49eef5 --- /dev/null +++ b/conf/metadata.php @@ -0,0 +1,10 @@ + + */ + + +//$meta['fixme'] = array('string'); + diff --git a/helper/db.php b/helper/db.php new file mode 100644 index 0000000..9c056ae --- /dev/null +++ b/helper/db.php @@ -0,0 +1,38 @@ + + */ + +// 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: diff --git a/lang/en/lang.php b/lang/en/lang.php new file mode 100644 index 0000000..ddea203 --- /dev/null +++ b/lang/en/lang.php @@ -0,0 +1,16 @@ + + */ + +// 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 : diff --git a/lang/en/settings.php b/lang/en/settings.php new file mode 100644 index 0000000..17ff478 --- /dev/null +++ b/lang/en/settings.php @@ -0,0 +1,13 @@ + + */ + +// keys need to match the config setting name +// $lang['fixme'] = 'FIXME'; + + + +//Setup VIM: ex: et ts=4 : diff --git a/plugin.info.txt b/plugin.info.txt new file mode 100644 index 0000000..bfd4a06 --- /dev/null +++ b/plugin.info.txt @@ -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 diff --git a/syntax/list.php b/syntax/list.php new file mode 100644 index 0000000..8122162 --- /dev/null +++ b/syntax/list.php @@ -0,0 +1,76 @@ + + */ + +// 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('',$mode,'plugin_struct_list'); +// $this->Lexer->addEntryPattern('',$mode,'plugin_struct_list'); + } + +// public function postConnect() { +// $this->Lexer->addExitPattern('','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: diff --git a/syntax/table.php b/syntax/table.php new file mode 100644 index 0000000..60d7e58 --- /dev/null +++ b/syntax/table.php @@ -0,0 +1,76 @@ + + */ + +// 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('',$mode,'plugin_struct_table'); +// $this->Lexer->addEntryPattern('',$mode,'plugin_struct_table'); + } + +// public function postConnect() { +// $this->Lexer->addExitPattern('','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: