• Welcome to Simple Machines Community Forum. Please login or sign up.
September 18, 2021, 03:03:38 AM

News:

Want to get involved in developing SMF, then why not lend a hand on our github!


SMF, Joomla, The Bridge and UTF-8, XHTML compliance?

Started by spiros, December 31, 2005, 12:28:26 PM

Previous topic - Next topic

spiros

December 31, 2005, 12:28:26 PM Last Edit: December 31, 2005, 07:33:39 PM by spiros
I noticed that when accessing directly a bridged forum xhtml is valid; when this is done through mambo (.../com_smf/...) plenty of xhtml errors appear (I also use an xhtml mambo template).

I guess it might be worth the trouble making the bridge xhtml compliant...

Orstio

The biggest part of making your bridge XHTML compliant is making the <head> area of your SMF theme conditional, by putting in something like this:

if (!defined(_VALID_MOS)){

[SMF Header, up to the <body> tag]

}

That should eliminate most of your XHTML errors.  There is, of course, more you can do.  I know I spent a lot of time getting all my components/modules to use &amp; instead of &, etc.

spiros

Thanks Orstio.

The funny thing is that many xhtml errors also appear in the mambo home page, indicating the the login mod has problems.

I tried your suggestion but all I got was

if (!defined(_VALID_MOS)){     }

which was not parsed. Maybe I put it in the wrong place (index.template.php)


<html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>
[
b]if (!defined(_VALID_MOS)){[/b]
<
head>
        <
meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
        <
meta name="description" content="', $context['page_title'], '" />
        <
meta name="keywords" content="PHP, MySQL, bulletin, board, free, open, source, smf, simple, machines, forum" />
	
<
script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/script.js?rc1"></script>
        <
script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
                
var smf_theme_url "', $settings['theme_url'], '";
                var 
smf_images_url "', $settings['images_url'], '";
                var 
smf_scripturl "', $scripturl, '";
                var 
smf_session_id "', $context['session_id'], '";
        
// ]]></script>
        
<title>', $context['page_title'], '</title>';

	
// The ?rc1 part of this link is just here to make sure browsers don'
t cache it wrongly.
	
echo 
'
	
<link rel="stylesheet" type="text/css" href="'
$settings['theme_url'], '/style.css?rc1" />
	
<link rel="stylesheet" type="text/css" href="'
$settings['default_theme_url'], '/print.css?rc1" media="print" />';
        
// pre-configured colorsets
        
$mycolors_back=array('#585C68','#585C68','#d8d0c8','#585C68','#585C68');
        
$mycolors_win1=array('#e1e1e1','#e1e1e8','#d0c8c0','#e5e5e5','#e0c0c0');
        
$mycolors_win2=array('#eaeaea','#e6e6ea','#e0d8d0','#f2f2f2','#f0d0d0');
        
$mycolors_title=array('#909590','#909097','#888078','#a0a0a0','#887070');
        
$mycolors_cat=array('#d0d5d0','#d0d0d9','#c8c0b8','#e0e0e0','#c8b0b0');
        
$mycolors_body=array('#f8f8f8','#f8f8ff','#f4f0ea','#fafafa','#f4e0e0');
        
$mycolors_user=array('#e0e3e0','#e0e0e6','#d6d0c6','#f0f0f0','#d6c0c0');
        
$mycolors_unread=array('#f0f4f0','#f0f0f6','#eae4e0','#f5f5f5','#ead4d4');
        
$mycolors_news=array('#f8f8f8','#f8f8fb','#f8f4f0','#fbfbfb','#f8e4e4');
        
$mycolors_search=array('#d8dbd9','#d0d0d8','#d8d4d0','#e0e0e0','#d8c4c4');
       
$mycolors_topbox=array('#f0f0f0','#f0f0f5','#f0eae8','#f5f5f5','#f0dada');

        if(isset(
$settings['mycolors']) && !empty($settings['mycolors']))
             
$set_mycol=$settings['mycolors'];
        else
             
$set_mycol=0;

        echo 
'
        <style type="text/css"><!--
        body
           {
               background-color: ' 
.$mycolors_back[$set_mycol]. ';
           }
           .windowbg
          {
               background-color: ' 
.$mycolors_win1[$set_mycol]. ';
           }
           .windowbg2
          {
               background-color: ' 
.$mycolors_win2[$set_mycol]. ';
          }
         .titlebg, tr.titlebg td, .titlebg a:link, .titlebg a:visited
         {
               background-color: ' 
.$mycolors_title[$set_mycol]. ';
         }
         .catbg , .catbg2
        {
               background-color: ' 
.$mycolors_cat[$set_mycol]. ';
         }
         #bodyarea
         {
               background-color: ' 
.$mycolors_body[$set_mycol]. ';
          }

           --></style>'
;

        
/* Internet Explorer 4/5 and Opera 6 just don't do font sizes properly. (they are big...)
                Thus, in Internet Explorer 4, 5, and Opera 6 this will show fonts one size smaller than usual.
                Note that this is affected by whether IE 6 is in standards compliance mode.. if not, it will also be big.
                Standards compliance mode happens when you use xhtml... */
        
if ($context['browser']['needs_size_fix'])
                echo 
'
        <link rel="stylesheet" type="text/css" href="'
$settings['default_theme_url'], '/fonts-compat.css" />';

        
// Show all the relative links, such as help, search, contents, and the like.
        
echo '
        <link rel="help" href="'
$scripturl'?action=help" target="_blank" />
        <link rel="search" href="' 
$scripturl '?action=search" />
        <link rel="contents" href="'
$scripturl'" />';

        
// If RSS feeds are enabled, advertise the presence of one.
        
if (!empty($modSettings['xmlnews_enable']))
                echo 
'
        <link rel="alternate" type="application/rss+xml" title="'
$context['forum_name'], ' - RSS" href="'$scripturl'?type=rss;action=.xml" />';

        
// If we're viewing a topic, these should be the previous and next topics, respectively.
        
if (!empty($context['current_topic']))
                echo 
'
        <link rel="prev" href="'
$scripturl'?topic='$context['current_topic'], '.0;prev_next=prev" />
        <link rel="next" href="'
$scripturl'?topic='$context['current_topic'], '.0;prev_next=next" />';

        
// If we're in a board, or a topic for that matter, the index will be the board's index.
        
if (!empty($context['current_board']))
                echo 
'
        <link rel="index" href="' 
$scripturl '?board=' $context['current_board'] . '.0" />';

        
// We'll have to use the cookie to remember the header...
        
if ($context['user']['is_guest'])
                
$options['collapse_header'] = !empty($_COOKIE['upshrink']);

        
// Output any remaining HTML headers. (from mods, maybe?)
        
echo $context['html_headers'], '

        <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
                var current_header = '
, empty($options['collapse_header']) ? 'false' 'true'';

                function shrinkHeader(mode)
                {'
;

        
// Guests don't have theme options!!
        
if ($context['user']['is_guest'])
                echo 
'
                        document.cookie = "upshrink=" + (mode ? 1 : 0);'
;
        else
                echo 
'
                        smf_setThemeOption("collapse_header", mode ? 1 : 0);'
;

        echo 
'
                        document.getElementById("upshrink").src = smf_images_url + (mode ? "/upshrink2.gif" : "/upshrink.gif");

                        document.getElementById("upshrinkHeader").style.display = mode ? "none" : "";

                        current_header = mode;
                }
        // ]]></script>

        <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
                var current_headertext = '
, empty($options['collapse_headertext']) ? 'false' 'true'';

                function shrinkHeadertext(mode)
                {'
;

        
// Guests don't have theme options!!
        
if ($context['user']['is_guest'])
                echo 
'
                        document.cookie = "upshrinktext=" + (mode ? 1 : 0);'
;
        else
                echo 
'
                        document.getElementById("upshrinkTemptext").src = "'
$scripturl'?action=jsoption;var=collapse_headertext;val=" + (mode ? 1 : 0) + ";sesc='$context['session_id'], ';" + (new Date().getTime());';

        echo 
'
                        document.getElementById("upshrinktext").src = smf_images_url + (mode ? "/upshrink2.gif" : "/upshrink.gif");

                        document.getElementById("upshrinkHeadertext").style.display = mode ? "none" : "";'
;

        echo 
'     current_headertext = mode;
                }
        // ]]></script>'
;

if(isset(
$settings['sidebar']) && !empty($settings['sidebar'])){
        echo 
'<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
                var current_headerside = '
, empty($options['collapse_headerside']) ? 'false' 'true'';

                function shrinkHeaderside(mode)
                {'
;

        
// Guests don't have theme options!!
        
if ($context['user']['is_guest'])
                echo 
'
                        document.cookie = "upshrinkside=" + (mode ? 1 : 0);'
;
        else
                echo 
'
                        document.getElementById("upshrinkTempside").src = "'
$scripturl'?action=jsoption;var=collapse_headerside;val=" + (mode ? 1 : 0) + ";sesc='$context['session_id'], ';" + (new Date().getTime());';

        echo 
'
                        document.getElementById("upshrinkside").src = smf_images_url + (mode ? "/upshrink2.gif" : "/upshrink.gif");

                        document.getElementById("upshrinkHeaderside").style.display = mode ? "none" : "";'
;

        echo 
'     current_headerside = mode;
                }
        // ]]></script>'
;
}
echo 
'
 </head>
[b]}[/b]
<body style="margin-left: 20px; margin-right: 20px;"><table width="100%" align="center" cellpadding="0" cellspacing="0">'
;







Orstio

No, it will need to go before the echo statement that contains the html tags.  You can't drop php into your html that way. ;)

spiros

Thanks Orstio,

Which echo statement? There are so many of those I am lost...

Orstio

It's impossible to give terribly detailed instructions with this.  Every theme is different -- there is no way to give out instructions that would encompass every theme, and also give detailed code.

This is the best I can do to help:

http://www.simplemachines.org/community/index.php?topic=38051.msg279445#msg279445

spiros

December 31, 2005, 07:33:20 PM #6 Last Edit: December 31, 2005, 07:39:11 PM by spiros
No problem Orstio,

It is not important as I am currently checking RC2.  I reinstalled forum (as upgrade came up with unicode problems) just to realize that there are major unicode problems in this release (which is quite sad given that joomla is moving to a core UTF-8 approach in 1.1). Indeed, I feel that SMF people should try a bit harder to provide UTF-8 compliance in SMF.

More details here
http://www.simplemachines.org/community/index.php?topic=63235.0


spiros

Some minor UTF problems of the previous releases have been solved by a Greek guy (!!!) despite the fact that I mentioned them in this forum.

If anybody wants to know the solution here are the posts (with the code which has to be replaced)

http://www.mamboclub.net/forum/showthread.php?t=1467

For the problem of corrupting characters in topic subject (i.e. �):

/Sources/Post.php

// Make sure the subject isn't too long - taking into account special characters.
$strlen_subject = preg_replace('~&(#\d{4,5}|#[3-9]\d{2,4}|#2[6-9]\d|quot|#039|amp|lt|gt);~', '_', $form_subject);
// Clip off the excess characters (100 - 104 is negative) - hopefully roughly making it as long as need be.
if (strlen($strlen_subject) > 100)
$form_subject = substr($form_subject, 0, 100 - strlen($strlen_subject));


As well as

   // At this point, we want to make sure the subject isn't too long.
$strlen_subject = preg_replace('~&(#\d{4,5}|#[3-9]\d{2,4}|#2[6-9]\d|quot|#039|amp|lt|gt);~', '_', stripslashes($_POST['subject']));
// We're stripping and adding the slashes to correctly trim it, and we're only taking off what's needed to make $strlen_subject 100.
if (strlen($strlen_subject) > 100)
$_POST['subject'] = addslashes(substr(stripslashes($_POST['subject']), 0, 100 - strlen($strlen_subject)));

// Hack to make it so &#324324... can't happen.
$_POST['subject'] = preg_replace('~&(#\d*)?$~', '', $_POST['subject']);


And replace all 100 with 150

For the problem of corrupting characters in latest post / last post find in


In /Sources/BoardIndex.php Find

censorText($row_board['subject']);
$row_board['short_subject'] = shorten_subject($row_board['subject'], 24);
$this_last_post = array(


and change 24 to 25.

chadness

Quote from: Orstio on December 31, 2005, 02:35:00 PM
The biggest part of making your bridge XHTML compliant is making the <head> area of your SMF theme conditional, by putting in something like this:

if (!defined(_VALID_MOS)){

[SMF Header, up to the <body> tag]

}

That should eliminate most of your XHTML errors.  There is, of course, more you can do.  I know I spent a lot of time getting all my components/modules to use &amp; instead of &, etc.

Nice idea!  That's cleaner than the if (empty($_REQUEST['option'])){way of doing that I'm used to.

Advertisement: