From: Carsten K. <car...@us...> - 2002-01-08 21:09:42
|
Update of /cvsroot/phpwiki/phpwiki/lib/plugin In directory usw-pr-cvs1:/tmp/cvs-serv4556 Modified Files: Toolbar.php Log Message: Improvements to simplify RecentEdits and RecentChanges toolbars. <?plugin Toolbar name=RecentEdits days=1,2,3,7,30,-1 label="Show edits for: %s" sep=| ?> Index: Toolbar.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/plugin/Toolbar.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** Toolbar.php 2002/01/07 09:04:41 1.3 --- Toolbar.php 2002/01/08 21:09:39 1.4 *************** *** 4,7 **** --- 4,9 ---- * Usage: * + * <?plugin Toolbar name=RecentEdits days=1,2,3,7,30,-1 label="Show edits for: %s" sep=| ?> + * * <?plugin Toolbar label="My favorites pages are %s." sep=, go="SandBox|SandBox,stuff|TestPage" ?> * *************** *** 39,43 **** 'go' => false, 'style' => 'text', ! 'name' => '' // TODO: new 'image' style for use with themes // which have graphic buttons --- 41,46 ---- 'go' => false, 'style' => 'text', ! 'name' => '', ! 'days' => '' // TODO: new 'image' style for use with themes // which have graphic buttons *************** *** 49,56 **** } function run($dbi, $argstr, $request) { $args = $this->getArgs($argstr, $request); extract($args); ! if (empty($go)) { $html=""; if (!empty($label)) { --- 52,63 ---- } + function mklinks($text, $action) { + return "[$text|$action]"; + } + function run($dbi, $argstr, $request) { $args = $this->getArgs($argstr, $request); extract($args); ! if (empty($go) && empty($days)) { $html=""; if (!empty($label)) { *************** *** 68,88 **** return $html; } global $theme; - //$name="RecentChanges"; if ($theme == "MacOSX" && $name=="RecentChanges") { global $ToolbarImages; - /* - $ToolbarImages = array( - 'RecentChanges' => array( - '1 day' => "themes/$theme/locale/en/toolbars/RecentChanges/1day.png", - '3 days' => "themes/$theme/locale/en/toolbars/RecentChanges/3days.png", - '7 days' => "themes/$theme/locale/en/toolbars/RecentChanges/7days.png", - '30 days' => "themes/$theme/locale/en/toolbars/RecentChanges/30days.png", - '90 days' => "themes/$theme/locale/en/toolbars/RecentChanges/90days.png", - '...' => "themes/$theme/locale/en/toolbars/RecentChanges/alltime.png") - ); - */ $ToolbarURLs = array( - //'RecentChanges' => array( '1 day' => "RecentChanges?days=1", '3 days' => "RecentChanges?days=3", --- 75,85 ---- return $html; } + + + global $theme; if ($theme == "MacOSX" && $name=="RecentChanges") { global $ToolbarImages; $ToolbarURLs = array( '1 day' => "RecentChanges?days=1", '3 days' => "RecentChanges?days=3", *************** *** 91,103 **** '90 days' => "RecentChanges?days=90", '...' => "RecentChanges?days=-1" - //) ); - //while(list($key, $val) = each($ToolbarImages)) { - // echo "$key => $val<br>"; - //} - // if (in_array ($name, $ToolbarImages)) { $rcimages = $ToolbarImages[$name]; --- 88,95 ---- *************** *** 122,126 **** switch ($sep) { case '|': ! $sep = " | "; break; case ',': --- 114,118 ---- switch ($sep) { case '|': ! $sep = " | "; break; case ',': *************** *** 130,136 **** //$sep = $sep ." "; } ! $links = "[" .str_replace(",", "]" .$sep ."[", $go) ."]"; $content = sprintf(_($label),$links); // TODO: (maybe) localise individual item labels (the --- 122,151 ---- //$sep = $sep ." "; } + + if (($name==_("RecentChanges")||_("RecentEdits")) && $days) { ! $days = explode(",", $days); + $day1 = _("1 day"); + $ndays = _("%s days"); + $alldays = "..."; + + $links = array(); + foreach ($days as $val) { + if ($val == 1) + $text = $day1; + elseif ($val == -1) + $text = $alldays; + else + $text = sprintf($ndays, $val); + $action = 'phpwiki:' .$name ."?days=" .$val; + + $links[] = $this->mklinks($text, $action); + } + $links = join($sep, $links); + + } else { + $links = "[" .str_replace(",", "]" .$sep ."[", $go) ."]"; + } $content = sprintf(_($label),$links); // TODO: (maybe) localise individual item labels (the |