From: <var...@us...> - 2009-02-23 17:53:25
|
Revision: 6539 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6539&view=rev Author: vargenau Date: 2009-02-23 17:53:22 +0000 (Mon, 23 Feb 2009) Log Message: ----------- Display error message if no argument provided Modified Paths: -------------- trunk/lib/plugin/FuzzyPages.php Modified: trunk/lib/plugin/FuzzyPages.php =================================================================== --- trunk/lib/plugin/FuzzyPages.php 2009-02-23 15:04:46 UTC (rev 6538) +++ trunk/lib/plugin/FuzzyPages.php 2009-02-23 17:53:22 UTC (rev 6539) @@ -2,6 +2,7 @@ rcs_id('$Id$'); /* Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam + Copyright 2009 Marc-Etienne Vargenau, Alcatel-Lucent This file is part of PhpWiki. @@ -20,8 +21,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -//require_once('lib/PageList.php'); - /** * FuzzyPages is plugin which searches for similar page titles. * @@ -149,8 +148,9 @@ function run($dbi, $argstr, &$request, $basepage) { $args = $this->getArgs($argstr, $request); extract($args); - if (empty($s)) - return ''; + if (empty($s)) { + return HTML::div(array('class' => "error"), "Please provide 's' argument to the plugin."); + } $this->debug = $debug; $this->_searchterm = $s; @@ -183,19 +183,6 @@ } }; -// $Log: not supported by cvs2svn $ -// Revision 1.11 2004/02/17 12:11:36 rurban -// added missing 4th basepage arg at plugin->run() to almost all plugins. This caused no harm so far, because it was silently dropped on normal usage. However on plugin internal ->run invocations it failed. (InterWikiSearch, IncludeSiteMap, ...) -// -// Revision 1.10 2003/02/22 20:49:55 dairiki -// Fixes for "Call-time pass by reference has been deprecated" errors. -// -// Revision 1.9 2003/01/18 21:41:02 carstenklapp -// Code cleanup: -// Reformatting & tabs to spaces; -// Added copyleft, getVersion, getDescription, rcs_id. -// - // Local Variables: // mode: php // tab-width: 8 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2009-10-09 16:52:59
|
Revision: 7197 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7197&view=rev Author: vargenau Date: 2009-10-09 16:52:50 +0000 (Fri, 09 Oct 2009) Log Message: ----------- Silence on empty s argument. s= is a common case. Modified Paths: -------------- trunk/lib/plugin/FuzzyPages.php Modified: trunk/lib/plugin/FuzzyPages.php =================================================================== --- trunk/lib/plugin/FuzzyPages.php 2009-10-09 16:50:13 UTC (rev 7196) +++ trunk/lib/plugin/FuzzyPages.php 2009-10-09 16:52:50 UTC (rev 7197) @@ -152,7 +152,7 @@ $args = $this->getArgs($argstr, $request); extract($args); if (empty($s)) { - return HTML::div(array('class' => "error"), "Please provide 's' argument to the plugin."); + return HTML(); } if (defined('DEBUG') && DEBUG) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2009-10-09 16:54:40
|
Revision: 7198 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7198&view=rev Author: vargenau Date: 2009-10-09 16:54:30 +0000 (Fri, 09 Oct 2009) Log Message: ----------- Do not display table when no matches Modified Paths: -------------- trunk/lib/plugin/FuzzyPages.php Modified: trunk/lib/plugin/FuzzyPages.php =================================================================== --- trunk/lib/plugin/FuzzyPages.php 2009-10-09 16:52:50 UTC (rev 7197) +++ trunk/lib/plugin/FuzzyPages.php 2009-10-09 16:54:30 UTC (rev 7198) @@ -137,6 +137,9 @@ function formatTable(&$list, &$dbi) { + if (empty($list)) { + return HTML::p(fmt("No fuzzy matches with '%s'", $this->_searchterm)); + } $table = HTML::table(array('cellpadding' => 2, 'cellspacing' => 1, 'border' => 0, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-10-01 13:55:19
|
Revision: 10611 http://sourceforge.net/p/phpwiki/code/10611 Author: vargenau Date: 2021-10-01 13:55:18 +0000 (Fri, 01 Oct 2021) Log Message: ----------- lib/plugin/FuzzyPages.php: use private Modified Paths: -------------- trunk/lib/plugin/FuzzyPages.php Modified: trunk/lib/plugin/FuzzyPages.php =================================================================== --- trunk/lib/plugin/FuzzyPages.php 2021-10-01 13:54:11 UTC (rev 10610) +++ trunk/lib/plugin/FuzzyPages.php 2021-10-01 13:55:18 UTC (rev 10611) @@ -37,10 +37,10 @@ class WikiPlugin_FuzzyPages extends WikiPlugin { - public $_searchterm; - public $_searchterm_metaphone; - public $debug; - public $_list; + private $searchterm; + private $searchterm_metaphone; + private $debug; + private $list; function getDescription() { @@ -50,14 +50,14 @@ function getDefaultArguments() { - return array('s' => false, - 'debug' => false); + return array('s' => '', + 'debug' => false); } private function spelling_similarity($subject) { $spelling_similarity_score = 0; - similar_text($subject, $this->_searchterm, + similar_text($subject, $this->searchterm, $spelling_similarity_score); return $spelling_similarity_score; } @@ -65,7 +65,7 @@ private function sound_similarity($subject) { $sound_similarity_score = 0; - similar_text(metaphone($subject), $this->_searchterm_metaphone, + similar_text(metaphone($subject), $this->searchterm_metaphone, $sound_similarity_score); return $sound_similarity_score; } @@ -76,12 +76,12 @@ + $this->sound_similarity($subject)) / 2; } - private function collectSimilarPages(&$list, &$dbi) + private function collectSimilarPages(&$list, $dbi) { if (!defined('MIN_SCORE_CUTOFF')) define('MIN_SCORE_CUTOFF', 33); - $this->_searchterm_metaphone = metaphone($this->_searchterm); + $this->searchterm_metaphone = metaphone($this->searchterm); $allPages = $dbi->getAllPages(); @@ -98,17 +98,17 @@ arsort($list, SORT_NUMERIC); } - private function addTableCaption(&$table, &$dbi) + private function addTableCaption($table, $dbi) { - if ($dbi->isWikiPage($this->_searchterm)) - $link = WikiLink($this->_searchterm, 'auto'); + if ($dbi->isWikiPage($this->searchterm)) + $link = WikiLink($this->searchterm, 'auto'); else - $link = $this->_searchterm; + $link = $this->searchterm; $caption = fmt("These page titles match fuzzy with “%s”", $link); $table->pushContent(HTML::caption($caption)); } - private function addTableHead(&$table) + private function addTableHead($table) { $row = HTML::tr(HTML::th(_("Name")), HTML::th(_("Score"))); @@ -119,7 +119,7 @@ $table->pushContent(HTML::thead($row)); } - private function addTableBody(&$list, &$table) + private function addTableBody($list, $table) { if (!defined('HIGHLIGHT_ROWS_CUTOFF_SCORE')) define('HIGHLIGHT_ROWS_CUTOFF_SCORE', 60); @@ -146,7 +146,7 @@ { if (empty($list)) { - return HTML::p(fmt("No fuzzy matches with “%s”", $this->_searchterm)); + return HTML::p(fmt("No fuzzy matches with “%s”", $this->searchterm)); } $table = HTML::table(array('class' => 'pagelist')); $this->addTableCaption($table, $dbi); @@ -155,6 +155,27 @@ return $table; } + private function pushDebugHeadingTDinto($row) + { + $row->pushContent(HTML::td(_("Spelling Score")), + HTML::td(_("Sound Score")), + HTML::td('Metaphones')); + } + + private function pushDebugTDinto($row, $pagename) + { + // This actually calculates everything a second time for each pagename + // so the individual scores can be displayed separately for debugging. + $debug_spelling = round($this->spelling_similarity($pagename), 1); + $debug_sound = round($this->sound_similarity($pagename), 1); + $debug_metaphone = sprintf("(%s, %s)", metaphone($pagename), + $this->searchterm_metaphone); + + $row->pushContent(HTML::td(array('class' => 'align-center'), $debug_spelling), + HTML::td(array('class' => 'align-center'), $debug_sound), + HTML::td($debug_metaphone)); + } + /** * @param WikiDB $dbi * @param string $argstr @@ -167,6 +188,16 @@ $args = $this->getArgs($argstr, $request); extract($args); + if (!is_bool($debug)) { + if (($debug == '0') || ($debug == 'false')) { + $debug = false; + } elseif (($debug == '1') || ($debug == 'true')) { + $debug = true; + } else { + return $this->error(sprintf(_("Argument '%s' must be a boolean"), "debug")); + } + } + if (empty($s)) { return HTML::p(array('class' => 'warning'), _("You must enter a search term.")); @@ -176,32 +207,11 @@ $this->debug = $debug; } - $this->_searchterm = $s; - $this->_list = array(); + $this->searchterm = $s; + $this->list = array(); - $this->collectSimilarPages($this->_list, $dbi); - $this->sortCollectedPages($this->_list); - return $this->formatTable($this->_list, $dbi); + $this->collectSimilarPages($this->list, $dbi); + $this->sortCollectedPages($this->list); + return $this->formatTable($this->list, $dbi); } - - private function pushDebugHeadingTDinto(&$row) - { - $row->pushContent(HTML::td(_("Spelling Score")), - HTML::td(_("Sound Score")), - HTML::td('Metaphones')); - } - - private function pushDebugTDinto(&$row, $pagename) - { - // This actually calculates everything a second time for each pagename - // so the individual scores can be displayed separately for debugging. - $debug_spelling = round($this->spelling_similarity($pagename), 1); - $debug_sound = round($this->sound_similarity($pagename), 1); - $debug_metaphone = sprintf("(%s, %s)", metaphone($pagename), - $this->_searchterm_metaphone); - - $row->pushContent(HTML::td(array('class' => 'align-center'), $debug_spelling), - HTML::td(array('class' => 'align-center'), $debug_sound), - HTML::td($debug_metaphone)); - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-10-01 13:58:28
|
Revision: 10612 http://sourceforge.net/p/phpwiki/code/10612 Author: vargenau Date: 2021-10-01 13:58:26 +0000 (Fri, 01 Oct 2021) Log Message: ----------- lib/plugin/FuzzyPages.php: pass by reference not needed Modified Paths: -------------- trunk/lib/plugin/FuzzyPages.php Modified: trunk/lib/plugin/FuzzyPages.php =================================================================== --- trunk/lib/plugin/FuzzyPages.php 2021-10-01 13:55:18 UTC (rev 10611) +++ trunk/lib/plugin/FuzzyPages.php 2021-10-01 13:58:26 UTC (rev 10612) @@ -142,7 +142,7 @@ $table->pushContent($tbody); } - private function formatTable(&$list, &$dbi) + private function formatTable($list, $dbi) { if (empty($list)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-10-06 08:28:48
|
Revision: 10613 http://sourceforge.net/p/phpwiki/code/10613 Author: vargenau Date: 2021-10-06 08:28:47 +0000 (Wed, 06 Oct 2021) Log Message: ----------- Use local variable instead of private member Modified Paths: -------------- trunk/lib/plugin/FuzzyPages.php Modified: trunk/lib/plugin/FuzzyPages.php =================================================================== --- trunk/lib/plugin/FuzzyPages.php 2021-10-01 13:58:26 UTC (rev 10612) +++ trunk/lib/plugin/FuzzyPages.php 2021-10-06 08:28:47 UTC (rev 10613) @@ -40,7 +40,6 @@ private $searchterm; private $searchterm_metaphone; private $debug; - private $list; function getDescription() { @@ -208,10 +207,10 @@ } $this->searchterm = $s; - $this->list = array(); + $list = array(); - $this->collectSimilarPages($this->list, $dbi); - $this->sortCollectedPages($this->list); - return $this->formatTable($this->list, $dbi); + $this->collectSimilarPages($list, $dbi); + $this->sortCollectedPages($list); + return $this->formatTable($list, $dbi); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2012-11-29 17:41:39
|
Revision: 8575 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=8575&view=rev Author: vargenau Date: 2012-11-29 17:41:30 +0000 (Thu, 29 Nov 2012) Log Message: ----------- Use CSS Modified Paths: -------------- trunk/lib/plugin/FuzzyPages.php Modified: trunk/lib/plugin/FuzzyPages.php =================================================================== --- trunk/lib/plugin/FuzzyPages.php 2012-11-29 17:40:59 UTC (rev 8574) +++ trunk/lib/plugin/FuzzyPages.php 2012-11-29 17:41:30 UTC (rev 8575) @@ -103,13 +103,12 @@ else $link = $this->_searchterm; $caption = fmt("These page titles match fuzzy with '%s'", $link); - $table->pushContent(HTML::caption(array('align' => 'top'), $caption)); + $table->pushContent(HTML::caption($caption)); } function addTableHead(&$table) { - $row = HTML::tr(HTML::th(_("Name")), - HTML::th(array('align' => 'right'), _("Score"))); + $row = HTML::tr(HTML::th(_("Name")), HTML::th(_("Score"))); if (defined('DEBUG') && DEBUG && $this->debug) { $this->_pushDebugHeadingTDinto($row); @@ -129,7 +128,7 @@ $score > HIGHLIGHT_ROWS_CUTOFF_SCORE ? 'evenrow' : 'oddrow'), HTML::td(WikiLink($found_pagename)), - HTML::td(array('align' => 'right'), + HTML::td(array('class' => 'align-right'), round($score))); if (defined('DEBUG') && DEBUG && $this->debug) { @@ -147,10 +146,7 @@ if (empty($list)) { return HTML::p(fmt("No fuzzy matches with '%s'", $this->_searchterm)); } - $table = HTML::table(array('cellpadding' => 2, - 'cellspacing' => 1, - 'border' => 0, - 'class' => 'pagelist')); + $table = HTML::table(array('class' => 'pagelist')); $this->addTableCaption($table, $dbi); $this->addTableHead($table); $this->addTableBody($list, $table); @@ -193,8 +189,8 @@ $debug_metaphone = sprintf("(%s, %s)", metaphone($pagename), $this->_searchterm_metaphone); - $row->pushcontent(HTML::td(array('align' => 'center'), $debug_spelling), - HTML::td(array('align' => 'center'), $debug_sound), + $row->pushcontent(HTML::td(array('class' => 'align-center'), $debug_spelling), + HTML::td(array('class' => 'align-center'), $debug_sound), HTML::td($debug_metaphone)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-09-30 16:00:02
|
Revision: 10608 http://sourceforge.net/p/phpwiki/code/10608 Author: vargenau Date: 2021-09-30 16:00:00 +0000 (Thu, 30 Sep 2021) Log Message: ----------- lib/plugin/FuzzyPages.php: make functions private Modified Paths: -------------- trunk/lib/plugin/FuzzyPages.php Modified: trunk/lib/plugin/FuzzyPages.php =================================================================== --- trunk/lib/plugin/FuzzyPages.php 2021-09-30 14:27:23 UTC (rev 10607) +++ trunk/lib/plugin/FuzzyPages.php 2021-09-30 16:00:00 UTC (rev 10608) @@ -54,7 +54,7 @@ 'debug' => false); } - function spelling_similarity($subject) + private function spelling_similarity($subject) { $spelling_similarity_score = 0; similar_text($subject, $this->_searchterm, @@ -62,7 +62,7 @@ return $spelling_similarity_score; } - function sound_similarity($subject) + private function sound_similarity($subject) { $sound_similarity_score = 0; similar_text(metaphone($subject), $this->_searchterm_metaphone, @@ -70,13 +70,13 @@ return $sound_similarity_score; } - function averageSimilarities($subject) + private function averageSimilarities($subject) { return ($this->spelling_similarity($subject) + $this->sound_similarity($subject)) / 2; } - function collectSimilarPages(&$list, &$dbi) + private function collectSimilarPages(&$list, &$dbi) { if (!defined('MIN_SCORE_CUTOFF')) define('MIN_SCORE_CUTOFF', 33); @@ -93,12 +93,12 @@ } } - function sortCollectedPages(&$list) + private function sortCollectedPages(&$list) { arsort($list, SORT_NUMERIC); } - function addTableCaption(&$table, &$dbi) + private function addTableCaption(&$table, &$dbi) { if ($dbi->isWikiPage($this->_searchterm)) $link = WikiLink($this->_searchterm, 'auto'); @@ -108,7 +108,7 @@ $table->pushContent(HTML::caption($caption)); } - function addTableHead(&$table) + private function addTableHead(&$table) { $row = HTML::tr(HTML::th(_("Name")), HTML::th(_("Score"))); @@ -119,7 +119,7 @@ $table->pushContent(HTML::thead($row)); } - function addTableBody(&$list, &$table) + private function addTableBody(&$list, &$table) { if (!defined('HIGHLIGHT_ROWS_CUTOFF_SCORE')) define('HIGHLIGHT_ROWS_CUTOFF_SCORE', 60); @@ -142,7 +142,7 @@ $table->pushContent($tbody); } - function formatTable(&$list, &$dbi) + private function formatTable(&$list, &$dbi) { if (empty($list)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |