Localized remainder of on-page tools and parts of PageProcess
authorDan
Fri, 07 Dec 2007 18:47:37 -0500
changeset 314 474f8be55943
parent 313 854eecfada20
child 326 ab66d6d1f1f4
Localized remainder of on-page tools and parts of PageProcess
includes/pageprocess.php
includes/template.php
language/english/enano.json
--- a/includes/pageprocess.php	Fri Dec 07 16:42:22 2007 -0500
+++ b/includes/pageprocess.php	Fri Dec 07 18:47:37 2007 -0500
@@ -152,6 +152,8 @@
   function send( $do_stats = false )
   {
     global $db, $session, $paths, $template, $plugins; // Common objects
+    global $lang;
+    
     if ( !$this->perms->get_permissions('read') )
     {
       $this->err_access_denied();
@@ -187,7 +189,7 @@
     {
       if ( !$this->page_exists )
       {
-        redirect( makeUrl(getConfig('main_page')), 'Can\'t find special page', 'The special or administration page you requested does not exist. You will now be transferred to the main page.', 2 );
+        die_semicritical('Exception in PageProcessor', '<p>Special page not existent but exception not previously caught by path manager.</p>');
       }
       $func_name = "page_{$this->namespace}_{$this->page_id}";
       if ( function_exists($func_name) )
@@ -196,9 +198,8 @@
       }
       else
       {
-        $title = 'Page backend not found';
-        $message = "The administration page you are looking for was properly registered using the page API, but the backend function
-                    (<tt>$fname</tt>) was not found. If this is a plugin page, then this is almost certainly a bug with the plugin.";
+        $title = $lang->get('page_err_custompage_function_missing_title');
+        $message = $lang->get('page_err_custompage_function_missing_body', array( 'function_name' => $fname ));
                     
         if ( $this->send_headers )
         {
@@ -291,7 +292,7 @@
           $page_id_data = RenderMan::strToPageID($page_to);
           if ( count($this->redirect_stack) >= 3 )
           {
-            $this->render( (!$strict_no_headers), '<div class="usermessage"><b>The maximum number of internal redirects has been exceeded.</b></div>' );
+            $this->render( (!$strict_no_headers), '<div class="usermessage"><b>' . $lang->get('page_err_redirects_exceeded') . '</b></div>' );
           }
           else
           {
@@ -381,6 +382,7 @@
   function render($incl_inner_headers = true, $_errormsg = false)
   {
     global $db, $session, $paths, $template, $plugins; // Common objects
+    global $lang;
     
     $text = $this->fetch_text();
     $text = preg_replace('/([\s]*)__NOBREADCRUMBS__([\s]*)/', '', $text);
@@ -414,11 +416,7 @@
                     <img alt="Cute wet-floor icon" src="'.scriptPath.'/images/redirector.png" />
                   </td>
                   <td valign="top" style="padding-left: 10px;">
-                    <b>This page is a <i>redirector</i>.</b><br />
-                    This means that this page will not show its own content by default. Instead it will display the contents of the page it redirects to.<br /><br />
-                    To create a redirect page, make the <i>first characters</i> in the page content <tt>#redirect [[Page_ID]]</tt>. For more information, see the
-                    Enano <a href="http://enanocms.org/Help:Wiki_formatting" onclick="window.open(this.href); return false;">Wiki formatting guide</a>.<br /><br />
-                    This page redirects to ' . $a . '.
+                    ' . $lang->get('page_msg_this_is_a_redirector', array( 'redirect_target' => $a )) . '
                   </td>
                 </tr>
               </table>
@@ -956,19 +954,29 @@
   function _handle_redirect($page_id, $namespace)
   {
     global $db, $session, $paths, $template, $plugins; // Common objects
+    global $lang;
     $arr_pid = array($this->page_id, $this->namespace);
     if ( $namespace == 'Special' || $namespace == 'Admin' )
     {
-      return 'This page redirects to a Special or Administration page, which is not allowed.';
+      return $lang->get('page_err_redirect_to_special');
     }
-    if ( in_array($this->redirect_stack, $arr_pid) )
+    $looped = false;
+    foreach ( $this->redirect_stack as $page )
     {
-      return 'This page infinitely redirects with another page (or another series of pages), and the infinite redirect was trapped.';
+      if ( $page[0] == $arr_pid[0] && $page[1] == $arr_pid[1] )
+      {
+        $looped = true;
+        break;
+      }
+    }
+    if ( $looped )
+    {
+      return $lang->get('page_err_redirect_infinite_loop');
     }
     $page_id_key = $paths->nslist[ $namespace ] . sanitize_page_id($page_id);
     if ( !isset($paths->pages[$page_id_key]) )
     {
-      return 'This page redirects to another page that doesn\'t exist.';
+      return $lang->get('page_err_redirect_to_nonexistent');
     }
     $this->redirect_stack[] = $arr_pid;
     
@@ -988,6 +996,8 @@
   function err_access_denied()
   {
     global $db, $session, $paths, $template, $plugins; // Common objects
+    global $lang;
+    global $email;
     
     // Log it for crying out loud
     $q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary,page_text) VALUES(\'security\', \'illegal_page\', '.time().', \''.date('d M Y h:i a').'\', \''.$db->escape($session->username).'\', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\', \'' . $db->escape(serialize(array($this->page_id, $this->namespace))) . '\')');
@@ -1022,7 +1032,10 @@
       }
     }
     
-    $ob .= '<div class="error-box"><b>Access to this page is denied.</b><br />This may be because you are not logged in or you have not met certain criteria for viewing this page.</div>';
+    $email_link = $email->encryptEmail(getConfig('contact_email'), '', '', $lang->get('page_err_access_denied_siteadmin'));
+    
+    $ob .= "<h3>" . $lang->get('page_err_access_denied_title') . "</h3>";
+    $ob .= "<p>" . $lang->get('page_err_access_denied_body', array('site_administration' => $email_link)) . "</p>";
     
     if ( $this->send_headers )
     {
--- a/includes/template.php	Fri Dec 07 16:42:22 2007 -0500
+++ b/includes/template.php	Fri Dec 07 18:47:37 2007 -0500
@@ -535,7 +535,7 @@
       }
       
       $menubtn->assign_vars(array(
-          'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxDeletePage()); return false; }" title="Delete this page. This is always reversible unless the logs are cleared. (alt-k)" accesskey="k"',
+          'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxDeletePage()); return false; }" title="' . $lang->get('onpage_tip_deletepage') . '" accesskey="k"',
           'HREF'  => makeUrl($paths->page, 'do=deletepage', true),
           'TEXT'  => $s,
         ));
@@ -591,7 +591,7 @@
     if ( $session->user_level >= USER_LEVEL_ADMIN && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' )
     {
       $menubtn->assign_vars(array(
-          'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxAdminPage()); return false; }" title="Administrative options for this page" accesskey="g"',
+          'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxAdminPage()); return false; }" title="' . $lang->get('onpage_tip_adminoptions') . '" accesskey="g"',
           'HREF'  => makeUrlNS('Special', 'Administration', 'module='.$paths->nslist['Admin'].'PageManager', true),
           'TEXT'  => $lang->get('onpage_btn_admin'),
         ));
@@ -601,7 +601,7 @@
     if ( strlen($this->toolbar_menu) > 0 )
     {
       $button->assign_vars(array(
-        'FLAGS'       => 'id="mdgToolbar_moreoptions" onclick="if ( !KILL_SWITCH ) { return false; }" title="Additional options for working with this page"',
+        'FLAGS'       => 'id="mdgToolbar_moreoptions" onclick="if ( !KILL_SWITCH ) { return false; }" title="' . $lang->get('onpage_tip_moreoptions') . '"',
         'PARENTFLAGS' => '',
         'HREF'        => makeUrl($paths->page, 'do=moreoptions', true),
         'TEXT'        => $lang->get('onpage_btn_moreoptions')
--- a/language/english/enano.json	Fri Dec 07 16:42:22 2007 -0500
+++ b/language/english/enano.json	Fri Dec 07 18:47:37 2007 -0500
@@ -204,6 +204,9 @@
       tip_protect_off: 'Allows everyone to edit this page. [alt-o]',
       tip_protect_semi: 'Allows only users who have been registered for 4 days to edit this page. [alt-p]',
       tip_flushlogs: 'Remove all edit and action logs for this page from the database. IRREVERSIBLE! (alt-l)',
+      tip_deletepage: 'Delete this page. This is always reversible unless the logs are cleared. (alt-k)',
+      tip_adminoptions: 'Administrative options for this page',
+      tip_moreoptions: 'Additional options for working with this page',
       tip_password: 'Require a password in order for this page to be viewed',
       tip_aclmanager: 'Manage who can do what with this page (alt-m)',
       
@@ -383,6 +386,26 @@
       detag_err_page_exists: 'The detag action is only valid for pages that have been deleted in the past.',
       detag_success_title: 'Page detagged',
       detag_success_body: 'All stale tags have been removed from this page.',
+      
+      err_custompage_function_missing_title: 'Page backend not found',
+      err_custompage_function_missing_body: 'The administration page you are looking for was properly registered using the page API, but the backend function (<tt>%function_name%</tt>) was not found. If this is a plugin page, then this is almost certainly a bug with the plugin.',
+      err_redirects_exceeded: 'The maximum number of internal redirects has been exceeded.',
+      err_redirect_to_nonexistent: 'This page redirects to another page that doesn\'t exist.',
+      err_redirect_infinite_loop: 'This page infinitely redirects with another page (or another series of pages), and the infinite redirect was trapped.',
+      err_redirect_to_special: 'This page redirects to a Special or Administration page, which is not allowed.',
+      err_access_denied_title: 'You don\'t have permission to view this page.',
+      err_access_denied_body: '<p>Your user account doesn\'t have the necessary permission to view this page. There are a number of possible reasons for this:</p>
+                               <ul>
+                                 <li>You aren\'t logged in. Some pages are restricted to logged-in users.</li>
+                                 <li>The page you\'re trying to view is protected so that only members of a specific usergroup are allowed to read it.</li>
+                               </ul>
+                               <p>If you would like to inquire further about this message, you may contact the %site_administration%.</p>',
+      err_access_denied_siteadmin: 'site administrator',
+      msg_this_is_a_redirector: '<b>This page is a <i>redirector</i>.</b><br />
+                    This means that this page will not show its own content by default. Instead it will display the contents of the page it redirects to.<br /><br />
+                    To create a redirect page, make the <i>first characters</i> in the page content <tt>#redirect [[Page_ID]]</tt>. For more information, see the
+                    Enano <a href="http://enanocms.org/Help:Wiki_formatting" onclick="window.open(this.href); return false;">Wiki formatting guide</a>.<br /><br />
+                    This page redirects to %redirect_target%.'
     },
     catedit: {
       title: 'Select which categories this page should be included in.',