From: <var...@us...> - 2014-10-06 17:17:27
|
Revision: 9204 http://sourceforge.net/p/phpwiki/code/9204 Author: vargenau Date: 2014-10-06 17:17:24 +0000 (Mon, 06 Oct 2014) Log Message: ----------- Let us put some abstraction Modified Paths: -------------- trunk/lib/BlockParser.php trunk/lib/CachedMarkup.php trunk/lib/InlineParser.php trunk/lib/PageType.php trunk/lib/WikiCallback.php trunk/lib/WikiPlugin.php trunk/lib/WikiPluginCached.php trunk/lib/WysiwygEdit.php trunk/lib/difflib.php trunk/lib/plugin/CacheTest.php trunk/lib/plugin/GraphViz.php trunk/lib/plugin/LinkDatabase.php trunk/lib/plugin/Ploticus.php trunk/lib/plugin/RecentChangesCached.php trunk/lib/plugin/SystemInfo.php trunk/lib/plugin/TexToPng.php trunk/lib/plugin/VisualWiki.php Modified: trunk/lib/BlockParser.php =================================================================== --- trunk/lib/BlockParser.php 2014-10-06 17:15:30 UTC (rev 9203) +++ trunk/lib/BlockParser.php 2014-10-06 17:17:24 UTC (rev 9204) @@ -501,14 +501,11 @@ } } -class BlockMarkup +abstract class BlockMarkup { public $_re; - function _match(&$input, $match) - { - trigger_error('pure virtual', E_USER_ERROR); - } + abstract function _match(&$input, $match); function _setTightness($top, $bot) { Modified: trunk/lib/CachedMarkup.php =================================================================== --- trunk/lib/CachedMarkup.php 2014-10-06 17:15:30 UTC (rev 9203) +++ trunk/lib/CachedMarkup.php 2014-10-06 17:17:24 UTC (rev 9204) @@ -243,7 +243,7 @@ * Dynamic content is anything that can change even when the original * wiki-text from which it was parsed is unchanged. */ -class Cached_DynamicContent +abstract class Cached_DynamicContent { function cache(&$cache) @@ -251,10 +251,7 @@ $cache[] = $this; } - function expand($basepage, &$obj) - { - trigger_error("Pure virtual", E_USER_ERROR); - } + abstract protected function expand($basepage, &$obj); function getWikiPageLinks($basepage) { @@ -274,7 +271,7 @@ } } -class Cached_Link extends Cached_DynamicContent +abstract class Cached_Link extends Cached_DynamicContent { function isInlineElement() Modified: trunk/lib/InlineParser.php =================================================================== --- trunk/lib/InlineParser.php 2014-10-06 17:15:30 UTC (rev 9203) +++ trunk/lib/InlineParser.php 2014-10-06 17:17:24 UTC (rev 9204) @@ -234,7 +234,7 @@ * When a match is found for the regexp, the matching text is replaced. * The replacement content is obtained by calling the SimpleMarkup::markup method. */ -class SimpleMarkup +abstract class SimpleMarkup { public $_match_regexp; @@ -254,10 +254,7 @@ * * @return mixed The expansion of the matched text. */ - function markup($match /*, $body */) - { - trigger_error("pure virtual", E_USER_ERROR); - } + abstract function markup($match /*, $body */); } /** @@ -265,7 +262,7 @@ * * These are defined by a start regexp, and an end regexp. */ -class BalancedMarkup +abstract class BalancedMarkup { public $_start_regexp; @@ -298,10 +295,7 @@ * * @return mixed The expansion of the matched text. */ - function markup($match, $body) - { - trigger_error("pure virtual", E_USER_ERROR); - } + abstract function markup($match, $body); } class Markup_escape extends SimpleMarkup Modified: trunk/lib/PageType.php =================================================================== --- trunk/lib/PageType.php 2014-10-06 17:15:30 UTC (rev 9203) +++ trunk/lib/PageType.php 2014-10-06 17:17:24 UTC (rev 9204) @@ -359,7 +359,7 @@ /** How to transform text. */ -class PageFormatter +abstract class PageFormatter { /** * @param WikiDB_Page $page @@ -382,10 +382,7 @@ * @param string $text The raw page content (e.g. wiki-text). * @return XmlContent Transformed content. */ - function format($text) - { - trigger_error("pure virtual", E_USER_ERROR); - } + abstract function format($text); } class PageFormatter_wikitext extends PageFormatter Modified: trunk/lib/WikiCallback.php =================================================================== --- trunk/lib/WikiCallback.php 2014-10-06 17:15:30 UTC (rev 9203) +++ trunk/lib/WikiCallback.php 2014-10-06 17:17:24 UTC (rev 9204) @@ -10,7 +10,7 @@ * * @see WikiFunctionCb, WikiMethodCb. */ -class WikiCallback +abstract class WikiCallback { /** * Convert from Pear-style callback specification to a WikiCallback. @@ -55,10 +55,7 @@ * @return mixed The return value of the callback. * @see call_user_func_array. */ - public function call_array($args) - { - trigger_error('pure virtual', E_USER_ERROR); - } + abstract public function call_array($args); /** * Convert to Pear callback. @@ -67,10 +64,7 @@ * (This value is suitable for passing as the callback parameter * to a number of different Pear functions and methods.) */ - public function toPearCb() - { - trigger_error('pure virtual', E_USER_ERROR); - } + abstract public function toPearCb(); } /** Modified: trunk/lib/WikiPlugin.php =================================================================== --- trunk/lib/WikiPlugin.php 2014-10-06 17:15:30 UTC (rev 9203) +++ trunk/lib/WikiPlugin.php 2014-10-06 17:17:24 UTC (rev 9204) @@ -1,6 +1,6 @@ <?php -class WikiPlugin +abstract class WikiPlugin { public $_pi; @@ -39,11 +39,7 @@ * @param string $basepage * @return mixed */ - function run($dbi, $argstr, &$request, $basepage) - { - trigger_error("WikiPlugin::run: pure virtual function", E_USER_ERROR); - return false; - } + abstract public function run($dbi, $argstr, &$request, $basepage); /** Get wiki-pages linked to by plugin invocation. * @@ -102,10 +98,7 @@ * @return string plugin description */ - function getDescription() - { - return _('This plugin has no description.'); - } + abstract protected function getDescription(); /** * @param string $argstr Modified: trunk/lib/WikiPluginCached.php =================================================================== --- trunk/lib/WikiPluginCached.php 2014-10-06 17:15:30 UTC (rev 9203) +++ trunk/lib/WikiPluginCached.php 2014-10-06 17:17:24 UTC (rev 9204) @@ -55,7 +55,7 @@ * * @author Johannes Große, Reini Urban */ -class WikiPluginCached extends WikiPlugin +abstract class WikiPluginCached extends WikiPlugin { public $_static; @@ -251,7 +251,7 @@ return HTML(); } // run - /* --------------------- virtual or abstract functions ----------- */ + /* --------------------- abstract functions ----------- */ /** * Sets the type of the plugin to html, image or map @@ -267,10 +267,7 @@ * <li>PLUGIN_CACHED_MAP</li> * </ul> */ - protected function getPluginType() - { - return PLUGIN_CACHED_IMG_ONDEMAND; - } + abstract protected function getPluginType(); /** * Creates an image handle from the given user arguments. @@ -286,12 +283,7 @@ * @return mixed imagehandle image handle if successful * false if an error occured */ - protected function getImage($dbi, $argarray, $request) - { - trigger_error('WikiPluginCached::getImage: pure virtual function in file ' - . __FILE__ . ' line ' . __LINE__, E_USER_ERROR); - return false; - } + abstract protected function getImage($dbi, $argarray, $request); /** * Sets the life time of a cache entry in seconds. @@ -363,11 +355,7 @@ * @return string html to be printed in place of the plugin command * false if an error occured */ - protected function getHtml($dbi, $argarray, $request, $basepage) - { - trigger_error('WikiPluginCached::getHtml: pure virtual function in file ' - . __FILE__ . ' line ' . __LINE__, E_USER_ERROR); - } + abstract protected function getHtml($dbi, $argarray, $request, $basepage); /** * Creates HTML output to be cached. @@ -385,11 +373,7 @@ * image. * array(false,false) if an error occured */ - protected function getMap($dbi, $argarray, $request) - { - trigger_error('WikiPluginCached::getHtml: pure virtual function in file ' - . __FILE__ . ' line ' . __LINE__, E_USER_ERROR); - } + abstract protected function getMap($dbi, $argarray, $request); /* --------------------- produce Html ----------------------------- */ Modified: trunk/lib/WysiwygEdit.php =================================================================== --- trunk/lib/WysiwygEdit.php 2014-10-06 17:15:30 UTC (rev 9203) +++ trunk/lib/WysiwygEdit.php 2014-10-06 17:17:24 UTC (rev 9204) @@ -23,7 +23,7 @@ require_once 'lib/InlineParser.php'; -class WysiwygEdit +abstract class WysiwygEdit { function WysiwygEdit() @@ -31,16 +31,10 @@ $this->_transformer_tags = false; } - function Head($name = 'edit[content]') - { - trigger_error("virtual", E_USER_ERROR); - } + abstract function Head($name = 'edit[content]'); // to be called after </textarea> - function Textarea($textarea, $wikitext, $name = 'edit[content]') - { - trigger_error("virtual", E_USER_ERROR); - } + abstract function Textarea($textarea, $wikitext, $name = 'edit[content]'); /** * Handler to convert the Wiki Markup to HTML before editing. Modified: trunk/lib/difflib.php =================================================================== --- trunk/lib/difflib.php 2014-10-06 17:15:30 UTC (rev 9203) +++ trunk/lib/difflib.php 2014-10-06 17:17:24 UTC (rev 9204) @@ -8,16 +8,13 @@ // You may copy this code freely under the conditions of the GPL. // -class _DiffOp +abstract class _DiffOp { public $type; public $orig; public $final; - function reverse() - { - trigger_error("pure virtual", E_USER_ERROR); - } + abstract function reverse(); function norig() { Modified: trunk/lib/plugin/CacheTest.php =================================================================== --- trunk/lib/plugin/CacheTest.php 2014-10-06 17:15:30 UTC (rev 9203) +++ trunk/lib/plugin/CacheTest.php 2014-10-06 17:17:24 UTC (rev 9204) @@ -54,7 +54,7 @@ class WikiPlugin_CacheTest extends WikiPluginCached { - /* --------- overwrite virtual or abstract methods ---------------- */ + /* --------- overwrite abstract methods ---------------- */ function getPluginType() { @@ -80,7 +80,7 @@ // image handle to an error image if you do not, // WikiPluginImageCache will do so. - function getImage($dbi, $argarray, $request) + protected function getImage($dbi, $argarray, $request) { extract($argarray); return $this->produceGraphics($text, $font); Modified: trunk/lib/plugin/GraphViz.php =================================================================== --- trunk/lib/plugin/GraphViz.php 2014-10-06 17:15:30 UTC (rev 9203) +++ trunk/lib/plugin/GraphViz.php 2014-10-06 17:17:24 UTC (rev 9204) @@ -261,7 +261,7 @@ return $ok ? $tempfile : false; } - function getImage($dbi, $argarray, $request) + protected function getImage($dbi, $argarray, $request) { $dotbin = GRAPHVIZ_EXE; $tempfiles = $this->tempnam($this->getName()); @@ -331,7 +331,7 @@ return 'imgtype'; } - function getMap($dbi, $argarray, $request) + protected function getMap($dbi, $argarray, $request) { $result = $this->invokeDot($argarray); if (isa($result, 'HtmlElement')) Modified: trunk/lib/plugin/LinkDatabase.php =================================================================== --- trunk/lib/plugin/LinkDatabase.php 2014-10-06 17:15:30 UTC (rev 9203) +++ trunk/lib/plugin/LinkDatabase.php 2014-10-06 17:17:24 UTC (rev 9204) @@ -74,11 +74,21 @@ * @param string $basepage * @return mixed */ - function getHtml($dbi, $argarray, $request, $basepage) + protected function getHtml($dbi, $argarray, $request, $basepage) { $this->run($dbi, WikiPluginCached::glueArgs($argarray), $request, $basepage); } + protected function getImage($dbi, $argarray, $request) + { + trigger_error('pure virtual', E_USER_ERROR); + } + + protected function getMap($dbi, $argarray, $request) + { + trigger_error('pure virtual', E_USER_ERROR); + } + /** * @param WikiDB $dbi * @param string $argstr Modified: trunk/lib/plugin/Ploticus.php =================================================================== --- trunk/lib/plugin/Ploticus.php 2014-10-06 17:15:30 UTC (rev 9203) +++ trunk/lib/plugin/Ploticus.php 2014-10-06 17:17:24 UTC (rev 9204) @@ -202,7 +202,7 @@ return 1; } - function getImage($dbi, $argarray, $request) + protected function getImage($dbi, $argarray, $request) { $source =& $this->source; if (empty($source)) { @@ -289,7 +289,7 @@ return 'device'; } - function getMap($dbi, $argarray, $request) + protected function getMap($dbi, $argarray, $request) { $img = $this->getImage($dbi, $argarray, $request); return array($this->_mapfile, $img); Modified: trunk/lib/plugin/RecentChangesCached.php =================================================================== --- trunk/lib/plugin/RecentChangesCached.php 2014-10-06 17:15:30 UTC (rev 9203) +++ trunk/lib/plugin/RecentChangesCached.php 2014-10-06 17:17:24 UTC (rev 9204) @@ -63,7 +63,7 @@ * @param string $basepage * @return mixed */ - function getHtml($dbi, $args, $request, $basepage) + protected function getHtml($dbi, $args, $request, $basepage) { $plugin = new WikiPlugin_RecentChanges(); $changes = $plugin->getChanges($dbi, $args); @@ -76,6 +76,16 @@ */ } + protected function getImage($dbi, $argarray, $request) + { + trigger_error('pure virtual', E_USER_ERROR); + } + + protected function getMap($dbi, $argarray, $request) + { + trigger_error('pure virtual', E_USER_ERROR); + } + // ->box is used to display a fixed-width, narrow version with common header. // Just a limited list of pagenames, without date. // This does not use ->run, to avoid pi construction and deconstruction Modified: trunk/lib/plugin/SystemInfo.php =================================================================== --- trunk/lib/plugin/SystemInfo.php 2014-10-06 17:15:30 UTC (rev 9203) +++ trunk/lib/plugin/SystemInfo.php 2014-10-06 17:17:24 UTC (rev 9204) @@ -78,7 +78,7 @@ * @param string $basepage * @return mixed */ - function getHtml($dbi, $argarray, $request, $basepage) + protected function getHtml($dbi, $argarray, $request, $basepage) { $loader = new WikiPluginLoader(); return $loader->expandPI('<<SystemInfo ' @@ -86,6 +86,16 @@ . ' ?>', $request, $this, $basepage); } + protected function getImage($dbi, $argarray, $request) + { + trigger_error('pure virtual', E_USER_ERROR); + } + + protected function getMap($dbi, $argarray, $request) + { + trigger_error('pure virtual', E_USER_ERROR); + } + function getDefaultArguments() { return array( // 'seperator' => ' ', // on multiple args Modified: trunk/lib/plugin/TexToPng.php =================================================================== --- trunk/lib/plugin/TexToPng.php 2014-10-06 17:15:30 UTC (rev 9203) +++ trunk/lib/plugin/TexToPng.php 2014-10-06 17:17:24 UTC (rev 9204) @@ -115,13 +115,17 @@ 'center' => 'off'); } - function getImage($dbi, $argarray, $request) + protected function getImage($dbi, $argarray, $request) { extract($argarray); $this->checkParams($tex, $magstep, $subslash, $antialias, $transparent); return $this->TexToImg($tex, $magstep, $antialias, $transparent); - } // run + } + protected function getMap($dbi, $argarray, $request) + { + } + function getExpire($dbi, $argarray, $request) { return '0'; Modified: trunk/lib/plugin/VisualWiki.php =================================================================== --- trunk/lib/plugin/VisualWiki.php 2014-10-06 17:15:30 UTC (rev 9203) +++ trunk/lib/plugin/VisualWiki.php 2014-10-06 17:17:24 UTC (rev 9204) @@ -134,7 +134,7 @@ * @param Request $request * @return array($map,$html) */ - function getMap($dbi, $argarray, $request) + protected function getMap($dbi, $argarray, $request) { if (!VISUALWIKI_ALLOWOPTIONS) $argarray = $this->defaultarguments(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |