Update of /cvsroot/phpwiki/phpwiki/lib/plugin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7909
Modified Files:
RateIt.php
Log Message:
Make changes suitable so that wikilens theme (and wikilens.org) work properly.
+ Remove predictions (for now)
+ Use new RatingsDb singleton.
+ Change RatingWidgetHtml() to use parameters like a normal PHP function
so we can have PHP check that we're passing the right # of them.
+ Change RatingWidgetHtml() to be callable static-ally
(without a plugin object)
+ Remove the "RateIt" button for now, because we don't use it on wikilens.org.
Maybe if someone wants the button, there can be an arg or flag for it.
+ Always show the cancel button, because UI widgets should not hide.
+ Remove the "No opinion" button for now, because we don't yet store that.
This is a useful thing, tho, for the future.
Index: RateIt.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/plugin/RateIt.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -2 -b -p -d -r1.11 -r1.12
--- RateIt.php 19 Jun 2004 10:22:41 -0000 1.11
+++ RateIt.php 30 Jun 2004 19:59:07 -0000 1.12
@@ -108,12 +108,6 @@ function displayRating(imgPrefix, rating
var imgName = imgPrefix + i;
var imgSrc = '".$img."';
- if (pred)
- document[imgName].title = '"._("Predicted rating ")."'+ratingvalue;
- else
document[imgName].title = '"._("Your rating ")."'+ratingvalue;
if (i<=(ratingvalue*2)) {
- if (pred)
- document[imgName].src = imgSrc + ((i%2) ? 'Rk1' : 'Rk0') + '.png';
- else
document[imgName].src = imgSrc + ((i%2) ? 'Ok1' : 'Ok0') + '.png';
} else {
@@ -121,8 +115,7 @@ function displayRating(imgPrefix, rating
}
}
- if ((pred == 0) && (ratingvalue > 0))
- document[cancel].src = imgSrc + 'Cancel.png';
- else
- document[cancel].src = imgSrc + 'CancelN.png';
+
+ //document[cancel].src = imgSrc + 'Cancel.png';
+
}
function click(actionImg, pagename, version, imgPrefix, dimension, rating) {
@@ -160,4 +153,5 @@ function deleteRating(actionImg, page, d
* string between ''s
*/
+
function _javascript_quote_string($s) {
return str_replace("'", "\'", $s);
@@ -206,5 +200,5 @@ function deleteRating(actionImg, page, d
if (RATING_STORAGE == 'SQL') {
- $rdbi = new RatingsDb();
+ $rdbi = RatingsDb::getTheRatingsDb();
$this->_rdbi =& $rdbi;
}
@@ -215,5 +209,5 @@ function deleteRating(actionImg, page, d
global $WikiTheme;
$actionImg = $WikiTheme->_path . $this->actionImgPath();
- $rdbi->addRating($request->getArg('rating'));
+ $rdbi->addRating($request->getArg('rating'), $user->getId(),
$this->pagename, $this->dimension);
ob_end_clean(); // discard any previous output
// delete the cache
@@ -233,5 +227,5 @@ function deleteRating(actionImg, page, d
global $WikiTheme;
$actionImg = $WikiTheme->_path . $this->actionImgPath();
- $rdbi->deleteRating();
+ $rdbi->deleteRating($user->getId(), $this->pagename,
$this->dimension);
ob_end_clean(); // discard any previous output
// delete the cache
@@ -250,5 +244,4 @@ function deleteRating(actionImg, page, d
// $WikiTheme->addMoreHeaders($this->RatingWidgetJavascript());
// or we change the header in the ob_buffer.
-
//Todo: add a validator based on the users last rating mtime
$rating = $rdbi->getRating();
@@ -263,5 +256,5 @@ function deleteRating(actionImg, page, d
*/
$args['rating'] = $rating;
- return $this->RatingWidgetHtml($args);
+ return $this->RatingWidgetHtml($args['pagename'],
$args['version'], $args['imgPrefix'], $args['dimension'], $args['small']);
} else {
if (!$user->isSignedIn())
@@ -273,7 +266,8 @@ function deleteRating(actionImg, page, d
$rdbi->getAvg($this->pagename,
$this->dimension)),
HTML::br());
- if ($rating !== false)
+ if ($rating !== false) {
$html->pushContent(sprintf(_("Your rating was %.1f"),
$rating));
+ }
else {
$pred = $rdbi->getPrediction($this->userid, $this->pagename,
$this->dimension);
@@ -322,18 +316,21 @@ function deleteRating(actionImg, page, d
* And only the widget, but no value (for buddies) also.
*/
- function RatingWidgetHtml($args) {
+ function RatingWidgetHtml($pagename, $version, $imgPrefix, $dimension,
$small = false) {
global $WikiTheme, $request;
- extract($args);
- if (!$request->_user->isSignedIn()) return;
+
+
$imgPrefix = $pagename . $imgPrefix;
$actionImgName = $imgPrefix . 'RateItAction';
$dbi =& $GLOBALS['request']->getDbh();
$version = $dbi->_backend->get_latest_version($pagename);
- $rdbi =& $this->_rdbi;
+ //$rdbi =& $this->_rdbi;
+ $rdbi = RatingsDb::getTheRatingsDb();
+ $id = 'rateit';
// Protect against 's, though not \r or \n
- $reImgPrefix = $this->_javascript_quote_string($imgPrefix);
- $reActionImgName = $this->_javascript_quote_string($actionImgName);
- $rePagename = $this->_javascript_quote_string($pagename);
+
+ $reImgPrefix =
WikiPlugin_RateIt::_javascript_quote_string($imgPrefix);
+ $reActionImgName =
WikiPlugin_RateIt::_javascript_quote_string($actionImgName);
+ $rePagename =
WikiPlugin_RateIt::_javascript_quote_string($pagename);
//$dimension = $args['pagename'] . "rat";
@@ -343,8 +340,4 @@ function deleteRating(actionImg, page, d
$none[$i] = $WikiTheme->_findData("images/RateItRk$i.png");
}
- if (!$small) {
- $html->pushContent(Button(_("RateIt"),_("RateIt"), $pagename));
- $html->pushContent(HTML::raw(' '));
- }
@@ -360,6 +353,7 @@ function deleteRating(actionImg, page, d
$img_attr = array();
$img_attr['src'] = $nk[$i%2];
- if (!$rating and !$pred)
- $img_attr['src'] = $none[$i%2];
+ //if (!$rating and !$pred)
+ // $img_attr['src'] = $none[$i%2];
+
$img_attr['name'] = $imgPrefix . $i;
$img_attr['border'] = 0;
@@ -367,10 +361,12 @@ function deleteRating(actionImg, page, d
$a1->addToolTip(_("Rate the topic of this page"));
$html->pushContent($a1);
+
//This adds a space between the rating smilies:
// if (($i%2) == 0) $html->pushContent(' ');
}
$html->pushContent(HTML::Raw(' '));
+
$a0 = HTML::a(array('href' => 'javascript:click(\'' . $reActionImgName
. '\',\'' . $rePagename . '\',\'' . $version . '\',\'' . $reImgPrefix . '\',\''
. $dimension . '\',\'X\')'));
- if ($rating) {
+
$msg = _("Cancel rating");
$a0->pushContent(HTML::img(array('src' =>
$WikiTheme->getImageUrl("RateItCancel"),
@@ -379,5 +375,5 @@ function deleteRating(actionImg, page, d
$a0->addToolTip($msg);
$html->pushContent($a0);
- } elseif ($pred) {
+ /*} elseif ($pred) {
$msg = _("No opinion");
$html->pushContent(HTML::img(array('src' =>
$WikiTheme->getImageUrl("RateItCancelN"),
@@ -386,5 +382,5 @@ function deleteRating(actionImg, page, d
//$a0->addToolTip($msg);
//$html->pushContent($a0);
- }
+ }*/
$img_attr = array();
$img_attr['src'] = $WikiTheme->_findData("images/RateItAction.png");
@@ -407,4 +403,18 @@ function deleteRating(actionImg, page, d
// $Log$
+// Revision 1.12 2004/06/30 19:59:07 dfrankow
+// Make changes suitable so that wikilens theme (and wikilens.org) work
properly.
+// + Remove predictions (for now)
+// + Use new RatingsDb singleton.
+// + Change RatingWidgetHtml() to use parameters like a normal PHP function
+// so we can have PHP check that we're passing the right # of them.
+// + Change RatingWidgetHtml() to be callable static-ally
+// (without a plugin object)
+// + Remove the "RateIt" button for now, because we don't use it on
wikilens.org.
+// Maybe if someone wants the button, there can be an arg or flag for it.
+// + Always show the cancel button, because UI widgets should not hide.
+// + Remove the "No opinion" button for now, because we don't yet store that.
+// This is a useful thing, tho, for the future.
+//
// Revision 1.11 2004/06/19 10:22:41 rurban
// outcomment the pear specific methods to let all pages load
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com
|