r94057 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94056‎ | r94057 | r94058 >
Date:12:38, 8 August 2011
Author:zhenya
Status:resolved
Tags:
Comment:
Fixed bug with quotes
Modified paths:
  • /trunk/extensions/SocialProfile/UserStatus/UserStatus.js (modified) (history)
  • /trunk/extensions/SocialProfile/UserStatus/UserStatusClass.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStatus/UserStatus_AjaxFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserStatus/UserStatus_AjaxFunctions.php
@@ -9,7 +9,7 @@
1010 $us_class->setStatus( $u_id, $status );
1111 $user_status_array = $us_class->getStatus( $u_id );
1212 $buf = $user_status_array['us_status'];
13 - $us = $buf;
 13+ $us = str_replace("@q;","'",$buf);
1414 $us .= "<br> <a id=\"us-link\" href=\"javascript:UserStatus.toEditMode('$buf','$u_id');\">".wfMsg('userstatus-edit')."</a>";
1515 return $us;
1616 }
@@ -25,7 +25,7 @@
2626
2727 $output .= '<tr><td width="60" id="status-history-time">'.date_format($time, 'j M G:i').' </td>';
2828 $output .= '<td width="360"><a href="javascript:UserStatus.fromHistoryToStatus(\''.$row['ush_status'].'\');">'
29 - .$row['ush_status'].'</a></td>';
 29+ .str_replace("@q;","'",$row['ush_status']).'</a></td>';
3030 //$output .='<td width="20" id="like-status"> <a href="javascript:UserStatus.likeIt('.$row['ush_id'].')" title="I like it!" >&#9829;</a> '.$row['ush_likes'].'</td></tr>';
3131 }
3232 $output.='</table>';
Index: trunk/extensions/SocialProfile/UserStatus/UserStatus.js
@@ -2,8 +2,11 @@
33 maxStatusLength : 70,
44
55 toShowMode: function( status, id ) {
6 - document.getElementById( 'user-status-block' ).innerHTML = status;
7 - document.getElementById( 'user-status-block' ).innerHTML += '<br> <a id="us-link" href="javascript:UserStatus.toEditMode(\'' + status + '\',' + id + ');">'+_US_EDIT+'</a>';
 6+ var str = this.returnJS(status);
 7+ document.getElementById( 'user-status-block' ).innerHTML = str;
 8+ document.getElementById( 'user-status-block' ).innerHTML += '<br> \n\
 9+ <a id="us-link" href="javascript:UserStatus.toEditMode(\'' +
 10+ status + '\',' + id + ');">'+_US_EDIT+'</a>';
811 },
912
1013 usLettersLeft: function() {
@@ -22,7 +25,7 @@
2326
2427 toEditMode: function( status, id ) {
2528 var editbar = '<input id="user-status-input" type="text" size="50" value="' +
26 - status + '" onkeyup="javascript:UserStatus.usLettersLeft();">';
 29+ this.returnJS(status) + '" onkeyup="javascript:UserStatus.usLettersLeft();">';
2730 editbar += '<br> <div id="status-bar">';
2831 editbar += '<a id="us-link" href="javascript:UserStatus.saveStatus(' + id + ');">'+_US_SAVE+'</a>';
2932 editbar += ' <a id="us-link" href="javascript:UserStatus.useHistory(' + id + ');">'+_US_HISTORY+'</a>';
@@ -30,11 +33,25 @@
3134 editbar += '<span id="status-letter-count"></span></div>';
3235 document.getElementById( 'user-status-block' ).innerHTML = editbar;
3336 },
34 -
 37+
 38+ parseJS:function ( str ) {
 39+ var patt=/'/g;
 40+ var s = str.replace(patt, "@q;");
 41+ return s;
 42+ },
 43+
 44+ returnJS:function ( str ) {
 45+
 46+ var pt= /@q;/gi;
 47+ var s = str.replace(pt, "'");
 48+ return s;
 49+ },
 50+
3551 saveStatus: function( id ) {
3652 var div = document.getElementById( 'user-status-block' );
3753 var ustext = document.getElementById( 'user-status-input' ).value;
38 - sajax_do_call( 'wfSaveStatus', [id, ustext], div );
 54+ var ust = this.parseJS(ustext);
 55+ sajax_do_call( 'wfSaveStatus', [id, ust], div );
3956 },
4057
4158 useHistory: function( id ){
@@ -55,7 +72,7 @@
5673 },
5774
5875 fromHistoryToStatus: function( str ) {
59 - document.getElementById('user-status-input').value = str;
 76+ document.getElementById('user-status-input').value = this.returnJS(str);
6077 },
6178
6279 specialGetHistory: function() {
@@ -66,13 +83,13 @@
6784
6885 specialHistoryDelete: function(id) {
6986 var block = document.getElementById("us-special");
70 - sajax_do_call( 'SpecialHistoryDelete', [id], block );
71 - this.specialGetHistory();
 87+ sajax_do_call( 'SpecialHistoryDelete', [id], block );
 88+ this.specialGetHistory();
7289 },
7390
7491 specialStatusDelete: function(id) {
7592 var block = document.getElementById("us-special");
76 - sajax_do_call( 'SpecialStatusDelete', [id], block );
77 - this.specialGetHistory();
 93+ sajax_do_call( 'SpecialStatusDelete', [id], block );
 94+ this.specialGetHistory();
7895 }
7996 };
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserStatus/UserStatusClass.php
@@ -10,6 +10,7 @@
1111 global $wgOut, $wgScriptPath;
1212 $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/SocialProfile/UserStatus/UserStatus.css' );
1313 $wgOut->addScriptFile( $wgScriptPath . '/extensions/SocialProfile/UserStatus/UserStatus.js' );
 14+ $wgOut->addHTML("<span id=\"temp_var\" style=\"display: none\"></span>");
1415 }
1516
1617 public function getStatus( $u_id ) {
@@ -52,7 +53,8 @@
5354 */
5455 public function setStatus( $u_id, $message ) {
5556 $message = trim($message);
56 - if (( mb_strlen( $message ) > 70 ) || ( mb_strlen( $message ) < 1 )) {
 57+ if (( mb_strlen( $message ) > 90 ) || ( mb_strlen( $message ) < 1 )) {
 58+ // INFO. Letter limit is 70, but here is 90, for special characters.
5759 // ERROR. Message length is too long
5860 return;
5961 }
@@ -131,7 +133,7 @@
132134
133135 if ( $mode == 'insert' ) {
134136 $currentStatus = $this->getStatus( $u_id );
135 -
 137+
136138 if ( $i < 4 ) {
137139 $dbw->insert(
138140 'user_status_history',

Follow-up revisions

RevisionCommit summaryAuthorDate
r94139SocialProfile: lots of miscellaneous cleanup to UserStatus, but the main big ...ashley23:37, 9 August 2011

Status & tagging log