[geeklog-cvs] geeklog: Set language direction in templates for printable versi...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sat Oct 18 14:28:52 EDT 2008


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/2e64149d5578
changeset: 6455:2e64149d5578
user:      Dirk Haun <dirk at haun-online.de>
date:      Sat Oct 18 19:17:03 2008 +0200
description:
Set language direction in templates for printable versions of articles and static pages. Also set $LANG_DIRECTION to 'ltr' now if the language file does not already define it (bug #0000762)

diffstat:

7 files changed, 88 insertions(+), 74 deletions(-)
plugins/staticpages/functions.inc                       |   60 ++++++------
plugins/staticpages/templates/printable.thtml           |    2 
public_html/article.php                                 |   70 ++++++++-------
public_html/docs/history                                |    3 
public_html/layout/professional/article/printable.thtml |    2 
public_html/lib-common.php                              |   21 +---
public_html/staticpages/index.php                       |    4 

diffs (271 lines):

diff -r 32e4014e6a01 -r 2e64149d5578 plugins/staticpages/functions.inc
--- a/plugins/staticpages/functions.inc	Sat Oct 18 16:05:06 2008 +0200
+++ b/plugins/staticpages/functions.inc	Sat Oct 18 19:17:03 2008 +0200
@@ -395,46 +395,50 @@
 * @return   string              HTML for the static page
 *
 */
-function SP_printPage ($page, $A)
+function SP_printPage($page, $A)
 {
-    global $_CONF, $LANG01, $_TABLES;
+    global $_CONF, $_TABLES, $LANG01, $LANG_DIRECTION;
 
-    $template_path = staticpages_templatePath ();
-    $print = new Template ($template_path);
-    $print->set_file (array ('print' => 'printable.thtml'));
-    $print->set_var ('site_url', $_CONF['site_url']);
-    $print->set_var ('site_name', $_CONF['site_name']);
-    $print->set_var ('site_slogan', $_CONF['site_slogan']);
+    $template_path = staticpages_templatePath();
+    $print = new Template($template_path);
+    $print->set_file(array('print' => 'printable.thtml'));
+    $print->set_var('site_url', $_CONF['site_url']);
+    $print->set_var('site_admin_url', $_CONF['site_admin_url']);
+    $print->set_var('layout_url', $_CONF['layout_url']);
+    $print->set_var('site_name', $_CONF['site_name']);
+    $print->set_var('site_slogan', $_CONF['site_slogan']);
 
-    $print->set_var ('page_title', $_CONF['site_name'] . ' - '
-                                   . stripslashes ($A['sp_title']));
-    $sp_url = COM_buildUrl ($_CONF['site_url']
-                               . '/staticpages/index.php?page=' . $page);
-    $print->set_var ('sp_url', $sp_url);
-    $print->set_var ('sp_title', stripslashes ($A['sp_title']));
-    $print->set_var ('sp_content',
-            SP_render_content (stripslashes ($A['sp_content']), $A['sp_php']));
-    $print->set_var ('sp_hits', COM_numberFormat ($A['sp_hits']));
+    $print->set_var('direction', $LANG_DIRECTION);
+    $print->set_var('page_title', $_CONF['site_name'] . ' - '
+                                  . stripslashes($A['sp_title']));
+    $sp_url = COM_buildUrl($_CONF['site_url']
+                                  . '/staticpages/index.php?page=' . $page);
+    $print->set_var('sp_url', $sp_url);
+    $print->set_var('sp_title', stripslashes($A['sp_title']));
+    $print->set_var('sp_content',
+            SP_render_content(stripslashes($A['sp_content']), $A['sp_php']));
+    $print->set_var('sp_hits', COM_numberFormat($A['sp_hits']));
     if ($A['commentcode'] >= 0) {
         $commentsUrl = $sp_url . '#comments';
         $comments = DB_count($_TABLES['comments'],
                              array('sid', 'type'), array($page, 'staticpages'));
-        $numComments = COM_numberFormat ($comments);
-        $print->set_var ('story_comments', $numComments);
-        $print->set_var ('comments_url', $commentsUrl);
-        $print->set_var ('comments_text', $numComments . ' ' . $LANG01[3]);
-        $print->set_var ('comments_count', $numComments);
-        $print->set_var ('lang_comments', $LANG01[3]);
-        $comments_with_count = sprintf ($LANG01[121], $numComments);
+        $numComments = COM_numberFormat($comments);
+        $print->set_var('story_comments', $numComments);
+        $print->set_var('comments_url', $commentsUrl);
+        $print->set_var('comments_text', $numComments . ' ' . $LANG01[3]);
+        $print->set_var('comments_count', $numComments);
+        $print->set_var('lang_comments', $LANG01[3]);
+        $comments_with_count = sprintf($LANG01[121], $numComments);
 
         if ($comments > 0) {
-            $comments_with_count = COM_createLink($comments_with_count, $commentsUrl);
+            $comments_with_count = COM_createLink($comments_with_count,
+                                                  $commentsUrl);
         }
-        $print->set_var ('comments_with_count', $comments_with_count);
+        $print->set_var('comments_with_count', $comments_with_count);
     }
-    $print->parse ('output', 'print');
+    $print->parse('output', 'print');
 
-    return $print->finish ($print->get_var ('output'));
+    return $print->finish($print->get_var('output'));
 }
 
 /**
diff -r 32e4014e6a01 -r 2e64149d5578 plugins/staticpages/templates/printable.thtml
--- a/plugins/staticpages/templates/printable.thtml	Sat Oct 18 16:05:06 2008 +0200
+++ b/plugins/staticpages/templates/printable.thtml	Sat Oct 18 19:17:03 2008 +0200
@@ -3,7 +3,7 @@
 <head>
     <title>{page_title}</title>
 </head>
-<body>
+<body dir="{direction}">
     <h1>{sp_title}</h1>
 
     <p>{sp_content}</p>
diff -r 32e4014e6a01 -r 2e64149d5578 public_html/article.php
--- a/public_html/article.php	Sat Oct 18 16:05:06 2008 +0200
+++ b/public_html/article.php	Sat Oct 18 19:17:03 2008 +0200
@@ -136,51 +136,57 @@
     } elseif ( $output == STORY_INVALID_SID ) {
         $display .= COM_refresh($_CONF['site_url'] . '/index.php');
     } elseif (($mode == 'print') && ($_CONF['hideprintericon'] == 0)) {
-        $story_template = new Template ($_CONF['path_layout'] . 'article');
-        $story_template->set_file ('article', 'printable.thtml');
-        $story_template->set_var ('xhtml', XHTML);
-        $story_template->set_var ('page_title',
+        $story_template = new Template($_CONF['path_layout'] . 'article');
+        $story_template->set_file('article', 'printable.thtml');
+        $story_template->set_var('xhtml', XHTML);
+        $story_template->set_var('direction', $LANG_DIRECTION);
+        $story_template->set_var('page_title',
                 $_CONF['site_name'] . ': ' . $story->displayElements('title'));
-        $story_template->set_var ( 'story_title', $story->DisplayElements( 'title' ) );
-        header ('Content-Type: text/html; charset=' . COM_getCharset ());
-        $story_template->set_var ('story_date', $story->displayElements('date'));
+        $story_template->set_var('story_title',
+                                 $story->DisplayElements('title'));
+        header('Content-Type: text/html; charset=' . COM_getCharset());
+        $story_template->set_var('story_date', $story->displayElements('date'));
 
         if ($_CONF['contributedbyline'] == 1) {
-            $story_template->set_var ('lang_contributedby', $LANG01[1]);
-            $authorname = COM_getDisplayName ($story->displayElements('uid'));
-            $story_template->set_var ('author', $authorname);
-            $story_template->set_var ('story_author', $authorname);
-            $story_template->set_var ('story_author_username', $story->DisplayElements('username'));
+            $story_template->set_var('lang_contributedby', $LANG01[1]);
+            $authorname = COM_getDisplayName($story->displayElements('uid'));
+            $story_template->set_var('author', $authorname);
+            $story_template->set_var('story_author', $authorname);
+            $story_template->set_var('story_author_username',
+                                     $story->DisplayElements('username'));
         }
 
-        $story_template->set_var ('story_introtext',
-                                    $story->DisplayElements('introtext'));
-        $story_template->set_var ('story_bodytext',
-                                    $story->DisplayElements('bodytext'));
+        $story_template->set_var('story_introtext',
+                                 $story->DisplayElements('introtext'));
+        $story_template->set_var('story_bodytext',
+                                 $story->DisplayElements('bodytext'));
 
-        $story_template->set_var ('site_url', $_CONF['site_url']);
-        $story_template->set_var ('layout_url', $_CONF['layout_url']);
-        $story_template->set_var ('site_name', $_CONF['site_name']);
-        $story_template->set_var ('site_slogan', $_CONF['site_slogan']);
-        $story_template->set_var ('story_id', $story->getSid());
-        $articleUrl = COM_buildUrl ($_CONF['site_url']
-                                    . '/article.php?story=' . $story->getSid());
+        $story_template->set_var('site_url', $_CONF['site_url']);
+        $story_template->set_var('site_admin_url', $_CONF['site_admin_url']);
+        $story_template->set_var('layout_url', $_CONF['layout_url']);
+        $story_template->set_var('site_name', $_CONF['site_name']);
+        $story_template->set_var('site_slogan', $_CONF['site_slogan']);
+        $story_template->set_var('story_id', $story->getSid());
+        $articleUrl = COM_buildUrl($_CONF['site_url']
+                                   . '/article.php?story=' . $story->getSid());
         if ($story->DisplayElements('commentcode') >= 0) {
             $commentsUrl = $articleUrl . '#comments';
             $comments = $story->DisplayElements('comments');
-            $numComments = COM_numberFormat ($comments);
-            $story_template->set_var ('story_comments', $numComments);
-            $story_template->set_var ('comments_url', $commentsUrl);
-            $story_template->set_var ('comments_text',
+            $numComments = COM_numberFormat($comments);
+            $story_template->set_var('story_comments', $numComments);
+            $story_template->set_var('comments_url', $commentsUrl);
+            $story_template->set_var('comments_text',
                     $numComments . ' ' . $LANG01[3]);
-            $story_template->set_var ('comments_count', $numComments);
-            $story_template->set_var ('lang_comments', $LANG01[3]);
-            $comments_with_count = sprintf ($LANG01[121], $numComments);
+            $story_template->set_var('comments_count', $numComments);
+            $story_template->set_var('lang_comments', $LANG01[3]);
+            $comments_with_count = sprintf($LANG01[121], $numComments);
 
             if ($comments > 0) {
-                $comments_with_count = COM_createLink($comments_with_count, $commentsUrl);
+                $comments_with_count = COM_createLink($comments_with_count,
+                                                      $commentsUrl);
             }
-            $story_template->set_var ('comments_with_count', $comments_with_count);
+            $story_template->set_var('comments_with_count',
+                                     $comments_with_count);
         }
         $story_template->set_var ('lang_full_article', $LANG08[33]);
         $story_template->set_var ('article_url', $articleUrl);
diff -r 32e4014e6a01 -r 2e64149d5578 public_html/docs/history
--- a/public_html/docs/history	Sat Oct 18 16:05:06 2008 +0200
+++ b/public_html/docs/history	Sat Oct 18 19:17:03 2008 +0200
@@ -3,6 +3,9 @@
 ??? ??, 2008 (1.5.2)
 ------------
 
+- Set language direction in templates for printable versions of articles and
+  static pages. Also set $LANG_DIRECTION to 'ltr' now if the language file does
+  not already define it (bug #0000762) [Dirk]
 - Removing an element from the middle of the censorlist caused the censoring
   to act up (bug #0000763) [Dirk]
 - Saving a story tried to update a feed of type 'geeklog' instead of 'article'
diff -r 32e4014e6a01 -r 2e64149d5578 public_html/layout/professional/article/printable.thtml
--- a/public_html/layout/professional/article/printable.thtml	Sat Oct 18 16:05:06 2008 +0200
+++ b/public_html/layout/professional/article/printable.thtml	Sat Oct 18 19:17:03 2008 +0200
@@ -3,7 +3,7 @@
 <head>
     <title>{page_title}</title>
 </head>
-<body>
+<body dir="{direction}">
     <h1>{story_title}</h1>
     <h3>{story_date}</h3>
     <b>{lang_contributedby} {story_author}</b>
diff -r 32e4014e6a01 -r 2e64149d5578 public_html/lib-common.php
--- a/public_html/lib-common.php	Sat Oct 18 16:05:06 2008 +0200
+++ b/public_html/lib-common.php	Sat Oct 18 19:17:03 2008 +0200
@@ -394,7 +394,12 @@
 *
 */
 
-require_once( $_CONF['path_language'] . $_CONF['language'] . '.php' );
+require_once $_CONF['path_language'] . $_CONF['language'] . '.php';
+
+if (empty($LANG_DIRECTION)) {
+    // default to left-to-right
+    $LANG_DIRECTION = 'ltr';
+}
 
 COM_switchLocaleSettings();
 
@@ -1047,7 +1052,7 @@
             }
         }
     }
-    $header->set_var('lang_id', $langId );
+    $header->set_var('lang_id', $langId);
     if (!empty($_CONF['languages']) && !empty($_CONF['language_files'])) {
         $header->set_var('lang_attribute', $langAttr);
     } else {
@@ -1084,16 +1089,8 @@
     $header->set_var( 'css_url', $_CONF['layout_url'] . '/style.css' );
     $header->set_var( 'theme', $_CONF['theme'] );
 
-    $header->set_var( 'charset', COM_getCharset());
-    if( empty( $LANG_DIRECTION ))
-    {
-        // default to left-to-right
-        $header->set_var( 'direction', 'ltr' );
-    }
-    else
-    {
-        $header->set_var( 'direction', $LANG_DIRECTION );
-    }
+    $header->set_var('charset', COM_getCharset());
+    $header->set_var('direction', $LANG_DIRECTION);
 
     // Now add variables for buttons like e.g. those used by the Yahoo theme
     $header->set_var( 'button_home', $LANG_BUTTONS[1] );
diff -r 32e4014e6a01 -r 2e64149d5578 public_html/staticpages/index.php
--- a/public_html/staticpages/index.php	Sat Oct 18 16:05:06 2008 +0200
+++ b/public_html/staticpages/index.php	Sat Oct 18 19:17:03 2008 +0200
@@ -75,6 +75,10 @@
 
 $retval = SP_returnStaticpage($page, $display_mode, $comment_order, $comment_mode, $msg);
 
+if ($display_mode == 'print') {
+    header('Content-Type: text/html; charset=' . COM_getCharset());
+}
+
 echo $retval;
 
 ?>



More information about the geeklog-cvs mailing list