logo       
Google Custom Search
    AddThis Social Bookmark Button

CreatePage and RateIt patches for spaces: msg#00155

Subject: CreatePage and RateIt patches for spaces
A patch for CreatePage to trim whitespace off the front and back of a page name. One of my users created a page that started with a space, and this was slightly bothersome.


diff -b -u -r1.5 -r1.6
--- CreatePage.php      22 Mar 2004 17:05:53 -0000      1.5
+++ CreatePage.php      21 Apr 2004 14:58:41 -0000      1.6

@@ -60,6 +60,9 @@

        if (empty($args['s']) or ($args['s'] == ""))
            return _("ERROR: Argument to CreatePage should not be empty!");
+
+        // Page names beginning or ending with space are annoying
+        $args['s'] = trim($args['s']);

        $parm['action'] = 'edit';
        if (!empty($args['initial_content_page'])) {


==============

A patch for the RateIt plugin (untested) to accept pagenames even with spaces at beginning or end: have Javascript explicitly encode, don't want for the browser to do it (Mozilla drops spaces!).

I say 'untested' because I still have not had time to switch to the RateIt plugin. I'm still using our original non-plugin code. It works there, but doesn't have the extra stuff in the URL (e.g., 'urlencode(_("RateIt"))). Anything that has potentially nasty chars needs to be escape()-ed, but I don't know if urlencode() already does that.

diff -b -u -r1.1.1.1 RateIt.php
--- RateIt.php  14 Apr 2004 21:22:41 -0000      1.1.1.1
+++ RateIt.php  20 Apr 2004 20:44:12 -0000
@@ -151,13 +151,13 @@
}
function submitRating(actionImg, page, version, dimension, rating) {
  var myRand = Math.round(Math.random()*(1000000));
- var imgSrc = page + '?version=' + version + '&action=".urlencode(_("RateIt"))."&mode=add&rating=' + rating + '&dimension=' + dimension + '&nopurge=cache&rand=' + myRand; + var imgSrc = escape(page) + '?version=' + version + '&action=".urlencode(_("RateIt"))."&mode=add&rating=' + rating + '&dimension=' + dimension + '&nopurge=cache&rand=' + myRand; //alert('submitRating(' + page + ', ' + version + ', ' + dimension + ', ' + rating + ') => '+imgSrc);
  document[actionImg].src= imgSrc;
}
function deleteRating(actionImg, page, dimension) {
  var myRand = Math.round(Math.random()*(1000000));
- var imgSrc = '".$urlprefix."' + page + '?action=".urlencode(_("RateIt"))."&mode=delete&dimension=' + dimension + '&nopurge=cache&rand=' + myRand; + var imgSrc = '".$urlprefix."' + escape(page) + '?action=".urlencode(_("RateIt"))."&mode=delete&dimension=' + dimension + '&nopurge=cache&rand=' + myRand; //alert('deleteRating(' + page + ', ' + version + ', ' + dimension + ')');
  document[actionImg].src= imgSrc;
}



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click



Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>