# HG changeset patch # User Dan # Date 1193620776 14400 # Node ID 1316404e4ea84925e90a37f960d4466b09403bc5 # Parent 30b857a6b811aa64fda6c8db486b1584323ac653 Localized history page and static HTML comment interface diff -r 30b857a6b811 -r 1316404e4ea8 includes/clientside/static/ajax.js --- a/includes/clientside/static/ajax.js Sun Oct 28 19:57:29 2007 -0400 +++ b/includes/clientside/static/ajax.js Sun Oct 28 21:19:36 2007 -0400 @@ -71,7 +71,7 @@ if(ajax.readyState == 4) { unsetAjaxLoading(); if(edit_open) { - c=confirm('Do you really want to revert your changes?'); + c=confirm($lang.get('editor_msg_revert_confirm')); if(!c) return; } edit_open = true; @@ -82,18 +82,18 @@ // Allow the textarea grippifier to re-create the resizer control on the textarea grippied_textareas.pop(in_array('ajaxEditArea', grippied_textareas)); } - disableUnload('If you do, any changes that you have made to this page will be lost.'); + disableUnload($lang.get('editor_msg_unload')); var switcher = ( readCookie('enano_editor_mode') == 'tinymce' ) ? - 'wikitext editor | graphical editor' : - 'wikitext editor | graphical editor' ; + '' + $lang.get('editor_btn_wikitext') + ' | ' + $lang.get('editor_btn_graphical') : + $lang.get('editor_btn_wikitext') + ' | ' + $lang.get('editor_btn_graphical') + '' ; document.getElementById('ajaxEditContainer').innerHTML = '\
\ ' + switcher + '
\
\
\ - Edit summary:
\ -
\ - save changes | preview changes | revert changes | discard changes\ + ' + $lang.get('editor_lbl_edit_summary') + '
\ +
\ + ' + $lang.get('editor_btn_save') + ' | ' + $lang.get('editor_btn_preview') + ' | ' + $lang.get('editor_btn_revert') + ' | ' + $lang.get('editor_btn_cancel') + '\
\ '+editNotice+'\
'; @@ -110,14 +110,14 @@ { $('ajaxEditArea').switchToMCE(); createCookie('enano_editor_mode', 'tinymce', 365); - $('switcher').object.innerHTML = 'wikitext editor | graphical editor'; + $('switcher').object.innerHTML = '' + $lang.get('editor_btn_wikitext') + ' | ' + $lang.get('editor_btn_graphical'); } function setEditorText() { $('ajaxEditArea').destroyMCE(); createCookie('enano_editor_mode', 'text', 365); - $('switcher').object.innerHTML = 'wikitext editor | graphical editor'; + $('switcher').object.innerHTML = $lang.get('editor_btn_wikitext') + ' | ' + $lang.get('editor_btn_graphical') + ''; } function ajaxViewSource() @@ -144,7 +144,7 @@ document.getElementById('ajaxEditContainer').innerHTML = '\
\
\ - close viewer\ + ' + $lang.get('editor_btn_closeviewer') + '\
'; initTextareas(); } @@ -194,7 +194,7 @@ // IE <6 pseudo-compatibility if ( KILL_SWITCH ) return true; - c = confirm('Do you really want to discard your changes?'); + c = confirm($lang.get('editor_msg_discard_confirm')); if(!c) return; ajaxReset(); } diff -r 30b857a6b811 -r 1316404e4ea8 includes/pageutils.php --- a/includes/pageutils.php Sun Oct 28 19:57:29 2007 -0400 +++ b/includes/pageutils.php Sun Oct 28 21:19:36 2007 -0400 @@ -521,6 +521,7 @@ function histlist($page_id, $namespace) { global $db, $session, $paths, $template, $plugins; // Common objects + global $lang; if(!$session->get_permissions('history_view')) return 'Access denied'; @@ -533,14 +534,17 @@ $q = 'SELECT time_id,date_string,page_id,namespace,author,edit_summary,minor_edit FROM ' . table_prefix.'logs WHERE log_type=\'page\' AND action=\'edit\' AND page_id=\'' . $page_id . '\' AND namespace=\'' . $namespace . '\' ORDER BY time_id DESC;'; if(!$db->sql_query($q)) $db->_die('The history data for the page "' . $paths->cpage['name'] . '" could not be selected.'); - echo 'History of edits and actions

Edits:

'; + echo $lang->get('history_page_subtitle') . ' +

' . $lang->get('history_heading_edits') . '

'; $numrows = $db->numrows(); - if($numrows < 1) echo 'No history entries in this category.'; + if ( $numrows < 1 ) + { + echo $lang->get('history_no_entries'); + } else { - echo '
- + ' . ( urlSeparator == '&' ? '' : '' ) . ' ' . ( $session->sid_super ? '' : '') . ' @@ -548,17 +552,18 @@
- - - - - - + + + + + + '."\n"."\n"; $cls = 'row2'; $ticker = 0; - while($r = $db->fetchrow()) { + while ( $r = $db->fetchrow() ) + { $ticker++; @@ -592,7 +597,7 @@ // User if ( $session->get_permissions('mod_misc') && is_valid_ip($r['author']) ) { - $rc = ' style="cursor: pointer;" title="Click cell background for reverse DNS info" onclick="ajaxReverseDNS(this, \'' . $r['author'] . '\');"'; + $rc = ' style="cursor: pointer;" title="' . $lang->get('history_tip_rdns') . '" onclick="ajaxReverseDNS(this, \'' . $r['author'] . '\');"'; } else { @@ -606,15 +611,19 @@ echo '>' . $r['author'] . ''."\n"; // Edit summary + if ( $r['edit_summary'] == 'Automatic backup created when logs were purged' ) + { + $r['edit_summary'] = $lang->get('history_summary_clearlogs'); + } echo ''."\n"; // Minor edit echo ''."\n"; // Actions! - echo ''."\n"; - echo ''."\n"; - echo ''."\n"; + echo ''."\n"; + echo ''."\n"; + echo ''."\n"; echo ''."\n"."\n"; @@ -623,18 +632,33 @@
- + '; } $db->free_result(); - echo '

Other changes:

'; + echo '

' . $lang->get('history_heading_other') . '

'; $q = 'SELECT time_id,action,date_string,page_id,namespace,author,edit_summary,minor_edit FROM ' . table_prefix.'logs WHERE log_type=\'page\' AND action!=\'edit\' AND page_id=\'' . $paths->cpage['urlname_nons'] . '\' AND namespace=\'' . $paths->namespace . '\' ORDER BY time_id DESC;'; - if(!$db->sql_query($q)) $db->_die('The history data for the page "' . $paths->cpage['name'] . '" could not be selected.'); - if($db->numrows() < 1) echo 'No history entries in this category.'; - else { + if ( !$db->sql_query($q) ) + { + $db->_die('The history data for the page "' . htmlspecialchars($paths->cpage['name']) . '" could not be selected.'); + } + if ( $db->numrows() < 1 ) + { + echo $lang->get('history_no_entries'); + } + else + { - echo '
DiffDate/timeUserEdit summaryMinorActions' . $lang->get('history_col_diff') . '' . $lang->get('history_col_datetime') . '' . $lang->get('history_col_user') . '' . $lang->get('history_col_summary') . '' . $lang->get('history_col_minor') . '' . $lang->get('history_col_actions') . '
' . $r['edit_summary'] . ''. (( $r['minor_edit'] ) ? 'M' : '' ) .'View revisionView user contribsRevert to this revision' . $lang->get('history_action_view') . '' . $lang->get('history_action_contrib') . '' . $lang->get('history_action_restore') . '
'; + echo '
+
Date/timeUserMinorAction takenExtra info
+ + + + + + + '; $cls = 'row2'; while($r = $db->fetchrow()) { @@ -658,23 +682,18 @@ // Action taken echo ''; // Actions! - echo ''; - echo ''; - - //echo '(rollback) ' . $r['date_string'] . ' ' . $r['author'] . ' (Userpage, Contrib): '; - - if($r['minor_edit']) echo ' - minor edit'; - echo '
'; + echo ''; + echo ''; echo ''; } @@ -897,6 +916,7 @@ function comments_raw($page_id, $namespace, $action = false, $flags = Array(), $_ob = '') { global $db, $session, $paths, $template, $plugins; // Common objects + global $lang; $pname = $paths->nslist[$namespace] . $page_id; @@ -937,8 +957,8 @@ $q = 'UPDATE ' . table_prefix.'comments SET approved=' . $a . ' WHERE page_id=\'' . $page_id . '\' AND namespace=\'' . $namespace . '\' AND ' . $where . ';'; $e=$db->sql_query($q); if(!$e) die('alert(unesape(\''.rawurlencode('Error during query: '.mysql_error().'\n\nQuery:\n' . $q) . '\'));'); - if($a=='1') $v = 'Unapprove'; - else $v = 'Approve'; + if($a=='1') $v = $lang->get('comment_btn_mod_unapprove'); + else $v = $lang->get('comment_btn_mod_approve'); echo 'document.getElementById("mdgApproveLink'.intval($_GET['id']).'").innerHTML="' . $v . '";'; break; } @@ -966,22 +986,32 @@ WHERE page_id=\'' . $page_id . '\' AND namespace=\'' . $namespace . '\' ORDER BY c.time ASC;'); if(!$lq) _die('The comment text data could not be selected. '.mysql_error()); - $_ob .= '

Article Comments

'; + $_ob .= '

' . $lang->get('comment_heading') . '

'; + $n = ( $session->get_permissions('mod_comments')) ? $db->numrows() : $num_app; - if($n==1) $s = 'is ' . $n . ' comment'; else $s = 'are ' . $n . ' comments'; - if($n < 1) + + $subst = array( + 'num_comments' => $n, + 'page_type' => '<FIXME> whatever' + ); + + $_ob .= '

'; + $_ob .= ( $n == 0 ) ? $lang->get('comment_msg_count_zero', $subst) : ( $n == 1 ? $lang->get('comment_msg_count_one', $subst) : $lang->get('comment_msg_count_plural', $subst) ); + + if ( $session->get_permissions('mod_comments') && $num_unapp > 0 ) { - $_ob .= '

There are currently no comments on this '.strtolower($namespace).''; - if($namespace != 'Article') $_ob .= ' page'; - $_ob .= '.

'; - } else $_ob .= '

There ' . $s . ' on this article.'; - if($session->get_permissions('mod_comments') && $num_unapp > 0) $_ob .= ' ' . $num_unapp . ' of those are unapproved.'; - elseif(!$session->get_permissions('mod_comments') && $num_unapp > 0) { $u = ($num_unapp == 1) ? "is $num_unapp comment" : "are $num_unapp comments"; $_ob .= ' However, there ' . $u . ' awating approval.'; } + $_ob .= ' ' . $lang->get('comment_msg_count_unapp_mod', array( 'num_unapp' => $num_unapp )) . ''; + } + else if ( !$session->get_permissions('mod_comments') && $num_unapp > 0 ) + { + $ls = ( $num_unapp == 1 ) ? 'comment_msg_count_unapp_one' : 'comment_msg_count_unapp_plural'; + $_ob .= ' ' . $lang->get($ls, array( 'num_unapp' => $num_unapp )) . ''; + } $_ob .= '

'; $list = 'list = { '; // _die(htmlspecialchars($ttext)); $i = -1; - while($row = $db->fetchrow($lq)) + while ( $row = $db->fetchrow($lq) ) { $i++; $strings = Array(); @@ -995,14 +1025,14 @@ // Determine the name, and whether to link to the user page or not $name = ''; - if($row['user_id'] > 0) $name .= ''; + if($row['user_id'] > 1) $name .= ''; $name .= $row['name']; - if($row['user_id'] > 0) $name .= ''; + if($row['user_id'] > 1) $name .= ''; $strings['NAME'] = $name; unset($name); // Subject $s = $row['subject']; - if(!$row['approved']) $s .= ' (Unapproved)'; + if(!$row['approved']) $s .= ' ' . $lang->get('comment_msg_note_unapp') . ''; $strings['SUBJECT'] = $s; // Date and time @@ -1013,16 +1043,17 @@ { default: case USER_LEVEL_GUEST: - $l = 'Guest'; + $l = $lang->get('user_type_guest'); break; case USER_LEVEL_MEMBER: - $l = 'Member'; + case USER_LEVEL_CHPREF: + $l = $lang->get('user_type_member'); break; case USER_LEVEL_MOD: - $l = 'Moderator'; + $l = $lang->get('user_type_mod'); break; case USER_LEVEL_ADMIN: - $l = 'Administrator'; + $l = $lang->get('user_type_admin'); break; } $strings['USER_LEVEL'] = $l; unset($l); @@ -1033,10 +1064,10 @@ if($session->get_permissions('edit_comments')) { // Edit link - $strings['EDIT_LINK'] = 'edit'; + $strings['EDIT_LINK'] = '' . $lang->get('comment_btn_edit') . ''; // Delete link - $strings['DELETE_LINK'] = 'delete'; + $strings['DELETE_LINK'] = '' . $lang->get('comment_btn_delete') . ''; } else { @@ -1048,19 +1079,19 @@ } // Send PM link - $strings['SEND_PM_LINK'] = ( $session->user_logged_in && $row['user_id'] > 0 ) ? 'Send private message
' : ''; + $strings['SEND_PM_LINK'] = ( $session->user_logged_in && $row['user_id'] > 1 ) ? '' . $lang->get('comment_btn_send_privmsg') . '
' : ''; // Add Buddy link - $strings['ADD_BUDDY_LINK'] = ( $session->user_logged_in && $row['user_id'] > 0 ) ? 'Add to buddy list' : ''; + $strings['ADD_BUDDY_LINK'] = ( $session->user_logged_in && $row['user_id'] > 1 ) ? '' . $lang->get('comment_btn_add_buddy') . '' : ''; // Mod links $applink = ''; $applink .= ''; - if($row['approved']) $applink .= 'Unapprove'; - else $applink .= 'Approve'; + if($row['approved']) $applink .= $lang->get('comment_btn_mod_unapprove'); + else $applink .= $lang->get('comment_btn_mod_approve'); $applink .= ''; $strings['MOD_APPROVE_LINK'] = $applink; unset($applink); - $strings['MOD_DELETE_LINK'] = 'Delete'; + $strings['MOD_DELETE_LINK'] = '' . $lang->get('comment_btn_mod_delete') . ''; // Signature $strings['SIGNATURE'] = ''; @@ -1078,32 +1109,31 @@ } if(getConfig('comments_need_login') != '2' || $session->user_logged_in) { - if(!$session->get_permissions('post_comments')) - { - $_ob .= '

Got something to say?

Access to post comments on this page is denied.

'; - } - else + if($session->get_permissions('post_comments')) { - $_ob .= '

Got something to say?

If you have comments or suggestions on this article, you can shout it out here.'; - if(getConfig('approve_comments')=='1') $_ob .= ' Before your comment will be visible to the public, a moderator will have to approve it.'; - if(getConfig('comments_need_login') == '1' && !$session->user_logged_in) $_ob .= ' Because you are not logged in, you will need to enter a visual confirmation before your comment will be posted.'; + $_ob .= '

' . $lang->get('comment_postform_title') . '

'; + $_ob .= $lang->get('comment_postform_blurb'); + if(getConfig('approve_comments')=='1') $_ob .= ' ' . $lang->get('comment_postform_blurb_unapp'); + if(getConfig('comments_need_login') == '1' && !$session->user_logged_in) + { + $_ob .= ' ' . $lang->get('comment_postform_blurb_captcha'); + } $sn = $session->user_logged_in ? $session->username . '' : ''; - $_ob .= ' + $_ob .= '
-

Comment form

' . $lang->get('history_col_datetime') . '' . $lang->get('history_col_user') . '' . $lang->get('history_col_minor') . '' . $lang->get('history_col_action_taken') . '' . $lang->get('history_col_extra') . '
'; // Some of these are sanitized at insert-time. Others follow the newer Enano policy of stripping HTML at runtime. - if ($r['action']=='prot') echo 'Protected pageReason: ' . $r['edit_summary']; - elseif($r['action']=='unprot') echo 'Unprotected pageReason: ' . $r['edit_summary']; - elseif($r['action']=='semiprot') echo 'Semi-protected pageReason: ' . $r['edit_summary']; - elseif($r['action']=='rename') echo 'Renamed pageOld title: '.htmlspecialchars($r['edit_summary']); - elseif($r['action']=='create') echo 'Created page'; - elseif($r['action']=='delete') echo 'Deleted pageReason: ' . $r['edit_summary']; - elseif($r['action']=='reupload') echo 'Uploaded new file versionReason: '.htmlspecialchars($r['edit_summary']); + if ($r['action']=='prot') echo $lang->get('history_log_protect') . '' . $lang->get('history_extra_reason') . ' ' . $r['edit_summary']; + elseif($r['action']=='unprot') echo $lang->get('history_log_unprotect') . '' . $lang->get('history_extra_reason') . ' ' . $r['edit_summary']; + elseif($r['action']=='semiprot') echo $lang->get('history_log_semiprotect') . '' . $lang->get('history_extra_reason') . ' ' . $r['edit_summary']; + elseif($r['action']=='rename') echo $lang->get('history_log_rename') . '' . $lang->get('history_extra_oldtitle') . ' '.htmlspecialchars($r['edit_summary']); + elseif($r['action']=='create') echo $lang->get('history_log_create') . ''; + elseif($r['action']=='delete') echo $lang->get('history_log_delete') . '' . $lang->get('history_extra_reason') . ' ' . $r['edit_summary']; + elseif($r['action']=='reupload') echo $lang->get('history_log_uploadnew') . '' . $lang->get('history_extra_reason') . ' '.htmlspecialchars($r['edit_summary']); echo 'View user contribsRevert action' . $lang->get('history_action_contrib') . '' . $lang->get('history_action_revert') . '
- - '; + + '; if(getConfig('comments_need_login') == '1' && !$session->user_logged_in) { $session->kill_captcha(); $captcha = $session->make_captcha(); - $_ob .= ''; + $_ob .= ''; } $_ob .= ' - - + +
Your name or screen name:' . $sn . '
Comment subject:
' . $lang->get('comment_postform_field_name') . '' . $sn . '
' . $lang->get('comment_postform_field_subject') . '
Visual confirmation:
Please enter the code you see on the right.
Visual confirmation
Code:
' . $lang->get('comment_postform_field_captcha_title') . '
' . $lang->get('comment_postform_field_captcha_blurb') . '
Visual confirmation
' . $lang->get('comment_postform_field_captcha_label') . '
Comment text:
(most HTML will be stripped)
' . $lang->get('comment_postform_field_comment') . '
'; @@ -1818,6 +1848,7 @@ function pagediff($page_id, $namespace, $id1, $id2) { global $db, $session, $paths, $template, $plugins; // Common objects + global $lang; if(!$session->get_permissions('history_view')) return 'Access denied'; if(!preg_match('#^([0-9]+)$#', (string)$id1) || @@ -1836,7 +1867,7 @@ $time1 = date('F d, Y h:i a', $id1); $time2 = date('F d, Y h:i a', $id2); $_ob = " -

Comparing revisions: {$time1} → {$time2}

+

" . $lang->get('history_lbl_comparingrevisions') . " {$time1} → {$time2}

"; // Free some memory unset($row1, $row2, $q1, $q2); diff -r 30b857a6b811 -r 1316404e4ea8 index.php --- a/index.php Sun Oct 28 19:57:29 2007 -0400 +++ b/index.php Sun Oct 28 21:19:36 2007 -0400 @@ -89,11 +89,12 @@ if(!$q) $db->_die('The comment data could not be selected.'); $row = $db->fetchrow(); $db->free_result(); + $row['subject'] = str_replace('\'', ''', $row['subject']); echo '
'; echo "
- - - + + +
Subject:
Comment:
" . $lang->get('comment_postform_field_subject') . "
" . $lang->get('comment_postform_field_comment') . "
"; echo '
'; break; diff -r 30b857a6b811 -r 1316404e4ea8 language/english/enano.json --- a/language/english/enano.json Sun Oct 28 19:57:29 2007 -0400 +++ b/language/english/enano.json Sun Oct 28 21:19:36 2007 -0400 @@ -17,15 +17,19 @@ var enano_lang = { categories: [ - 'adm', 'meta', 'user', 'page', 'comment', 'onpage', 'etc' + 'adm', 'meta', 'user', 'page', 'comment', 'onpage', 'etc', 'editor', 'history', ], strings: { meta: { + adm: 'Administration panel nav menu', meta: 'Language category strings', user: 'Login, logout, and authentication', page: 'Page creation and control', comment: 'Comment display', onpage: 'On-page controls', + etc: 'Miscellaneous strings', + editor: 'Page editor interface', + history: 'Page history and log viewer', plural: 's' }, user: { @@ -150,6 +154,7 @@ postform_title: 'Got something to say?', postform_blurb: 'If you have comments or suggestions on this article, you can shout it out here.', postform_blurb_unapp: 'Before your post will be visible to the public, a moderator will have to approve it.', + postform_blurb_captcha: 'Because you are not logged in, you will need to enter a visual confirmation before your comment will be posted.', postform_blurb_link: 'Leave a comment...', postform_field_name: 'Your name/screen name:', postform_field_subject: 'Comment subject:', @@ -157,6 +162,8 @@ postform_field_captcha_title: 'Visual confirmation:', postform_field_captcha_blurb: 'Please enter the confirmation code seen in the image on the right into the box. If you cannot read the code, please click on the image to generate a new one. This helps to prevent automated bot posting.', postform_field_captcha_label: 'Confirmation code:', + postform_field_captcha_cantread_js: 'If you can\'t read the code, click on the image to generate a new one.', + postform_field_captcha_cantread_nojs: 'If you can\'t read the code, please refresh this page to generate a new one.', postform_btn_submit: 'Submit comment', }, adm: { @@ -194,12 +201,57 @@ btn_keepalive_about: 'About keep-alive', btn_keepalive_loading: 'Loading keep-alive button...' }, - admhome: { + editor: { + msg_revert_confirm: 'Do you really want to revert your changes?', + msg_discard_confirm: 'Do you really want to discard your changes?', + msg_unload: 'If you do, any changes that you have made to this page will be lost.', + btn_graphical: 'graphical editor', + btn_wikitext: 'wikitext editor', + lbl_edit_summary: 'Edit summary:', + lbl_minor_edit: 'This is a minor edit', + btn_save: 'Save changes', + btn_preview: 'Show preview', + btn_revert: 'Revert changes', + btn_cancel: 'Cancel and return to page', + btn_closeviewer: 'Close viewer', + }, + history: { + summary_clearlogs: 'Automatic backup created when logs were purged', + page_subtitle: 'History of edits and actions', + heading_edits: 'Edits:', + heading_other: 'Other changes:', + no_entries: 'No history entries in this category.', + btn_compare: 'Compare selected revisions', + col_diff: 'Diff', + col_datetime: 'Date/time', + col_user: 'User', + col_summary: 'Edit summary', + col_minor: 'Minor', + col_actions: 'Actions', + col_action_taken: 'Action taken', + col_extra: 'Extra info', + extra_reason: 'Reason:', + extra_oldtitle: 'Old title:', + tip_rdns: 'Click cell background for reverse DNS info', + action_view: 'View', + action_contrib: 'User contribs', + action_restore: 'Restore', + action_revert: 'Revert action', + log_protect: 'Protected page', + log_unprotect: 'Unprotected page', + log_semiprotect: 'Semi-protected page', + log_rename: 'Renamed page', + log_create: 'Created page', + log_delete: 'Deleted page', + log_uploadnew: 'Uploaded new file version', + lbl_comparingrevisions: 'Comparing revisions:', }, etc: { redirect_title: 'Redirecting...', redirect_body: 'Please wait while you are redirected.', redirect_timeout: 'If you are not redirected within %timeout% seconds, please click here.', + // Generic "Save Changes" button + save_changes: 'Save changes', }, } };