Problem with Wolverine recent_topics Module & utf-8

Started by samurai-lupin, April 03, 2008, 05:55:25 AM

Previous topic - Next topic

samurai-lupin

Hello,

I am seeking desperate help on wolverfines fine recent_topics module. The only problem involved with this module is that it will not display utf-8 characters properly. I am for example using a German language board involving characters like Ä, Ö or Ü and those do not get displayerd properly.

Could someone please let me know what changes I need to make to the code so it will display them properly???

I have made a posting at joomlahack.com but others have had the same problem and there hasn't been a reply within a year.

/* no direct access */
defined( '_VALID_MOS' ) or die( 'Restricted Access.' );
global $database, $mainframe;
global $context, $txt, $settings, $user_info, $modSettings;

/* 1.5 params-get() second parameter is a default (-Wolverine)*/
//These defaults are identical to the defaults set in mod_smf_recent_topics.xml
$moduleclass_sfx        = $params->get( 'moduleclass_sfx', '' );
$bln_icon               = $params->get( 'bln_icon', 0 );
$bln_board              = $params->get( 'bln_board', 0 );
$int_num_topics         = $params->get( 'int_num_topics', 5 );
$bln_date_time          = $params->get( 'bln_date_time', 0 );
$int_num_char           = $params->get( 'int_num_char', 10 );
$bln_real_name          = $params->get( 'namedisplay', 0 );
$marquee_scroll         = $params->get( 'marquee_scroll', 0 );
$scroll_amount          = $params->get( 'scroll_amount', 1 );
$scroll_delay           = $params->get( 'scroll_delay', 2 );
$scroll_pause           = $params->get( 'scroll_pause', 1 );
$scroll_height          = $params->get( 'scroll_height', 200 );
$bln_replies            = $params->get( 'bln_replies', 1 );
$bln_poster             = $params->get( 'bln_poster', 1 );
$external               = $params->get( 'external', 0);


//2.0 first, get the class object, then use it to load the params
$jsmf =& jsmfFrontend::singleton();
$jsmfConfig = jsmfFrontend::loadParams();


/*1.6.2 Get the ID_MEMBER using $user_info['username'] (-Wolverine)*/
/*1.7.1 Check if not guest and if ID_MEMBER isn't set */
if(!$user_info['is_guest'] && (!isset($ID_MEMBER) || empty($ID_MEMBER))) {
     $query =
        "SELECT ID_MEMBER " .
        "FROM {$jsmfConfig->smf_prefix}members " .
        "WHERE memberName = '".$user_info['username']."'";
     $database->setQuery($query);
     $row = null;
     $database->loadObject($row);
     if (!empty($row)) {
          $ID_MEMBER = $row->ID_MEMBER;
     } else {
          echo "Error fetching ID_MEMBER: ".$database->getErrorMsg();
          return false;
     }
}
$exclude_boards = array();
$output_method = 'echo';

$query =
        "SELECT
            mem.realName, m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName, t.numReplies, t.ID_LAST_MSG,
            IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
            IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
            IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon
        FROM ({$jsmfConfig->smf_prefix}messages AS m, {$jsmfConfig->smf_prefix}topics AS t, {$jsmfConfig->smf_prefix}boards AS b, {$jsmfConfig->smf_prefix}messages AS ms)
            LEFT JOIN {$jsmfConfig->smf_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
            LEFT JOIN {$jsmfConfig->smf_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
            LEFT JOIN {$jsmfConfig->smf_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
        WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($int_num_topics, 5)) . "
            AND t.ID_LAST_MSG = m.ID_MSG
            AND b.ID_BOARD = t.ID_BOARD" . (empty($exclude_boards) ? '' : "
            AND b.ID_BOARD NOT IN (" . implode(', ', $exclude_boards) . ")") . "
            AND $user_info[query_see_board]
            AND ms.ID_MSG = t.ID_FIRST_MSG
        ORDER BY t.ID_LAST_MSG DESC
        LIMIT $int_num_topics";
$database->setQuery($query);
$result = null;
$result = $database->query();

if (!empty($result)) {

    $posts = array();
while ($row = mysql_fetch_assoc($result)) {
// Censor the subject.
censorText($row['subject']);


// Build the array.
$posts[] = array(
            'board'  => array(
                    'id'        => $row['ID_BOARD'],
                    'name'      => $row['bName'],
                    'href'      => $jsmf->fixLink('index.php?board=' . $row['ID_BOARD'] . '.0'),
                    'link'      => '<a href="'.$jsmf->fixLink('index.php?board=' . $row['ID_BOARD'] . '.0').'">' . $row['bName'] . '</a>'
            ),
'topic'  => $row['ID_TOPIC'],
            'member' => array(
                    'username'  => $row['posterName'],
                    'name'      => $row['realName'],
                    'id'        => $row['ID_MEMBER'],
                    'href'      => !empty($row['ID_MEMBER']) ? $jsmf->fixLink('index.php?action=profile;u=' . $row['ID_MEMBER']) : '',
                    'link'      => !empty($row['ID_MEMBER']) ? '<a href="' .$jsmf->fixLink('index.php?action=profile;u=' . $row['ID_MEMBER']) . '" title="' . $txt[92] . ' ' . $row['posterName'] . '" '. ($external) ? 'target="_blank" ' : '' . '>' . ($bln_real_name ? $row['realName'] : $row['posterName']) . '</a>' : ($bln_real_name ? $row['realName'] : $row['posterName'])
            ),
            'subject'       => $row['subject'],
            'short_subject' => strlen(un_htmlspecialchars($row['subject'])) > 25 ? htmlspecialchars(substr(un_htmlspecialchars($row['subject']), 0, 22) . '...') : $row['subject'],
            'time'          => timeformat($row['posterTime']),
            'timestamp'     => $row['posterTime'],
//            'href'          => $jsmf->fixLink('index.php?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . '#new'),
            'href'          => $jsmf->fixLink('index.php?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new'),
//            'link'          => '<a href="' . $jsmf->fixLink('index.php?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . '#new') . '">' . $row['subject'] . '</a>',
            'link'          => '<a href="' . $jsmf->fixLink('index.php?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new') . '">' . $row['subject'] . '</a>',
            /* 1.6 Use the msg id to determine if the post is new (-Wolverine)*/
            'new'           => !empty($row['isRead']),
            'new_from'      => $row['new_from'],
            'replies'       => $row['numReplies'],
            //images_url is the url to the theme that is selected for the site.  Alternative is default_images_url which is the default theme.
            'icon'          => '<img src="' . $settings['images_url']. '/post/' . $row['icon'] . '.gif" alt="' . $row['icon'] . '" border="0" />'
);


}

} else {
     echo "Error fetching Recent Topics: ".$database->getErrorMsg();
     return false;
}

// Just return it.
/* 1.5 Use strcmp, much better method for string comparisons (-Wolverine)*/
if (strcmp($output_method, 'echo') != 0 || empty($posts)) {
return $posts;
}

/* 1.5 PHPNuke marquee scrolling (-Wolverine)*/
//PHPNuke scrolling adapted from Forums Scroll V2
//Original Author: Telli
//E-mail: [email protected]
//Home Page: www.Codezwiz.com
//if($bln_marquee_scroll) {
// echo '<marquee behavior="scroll" direction="',$str_scroll_direction,'"', ($int_scroll_amount != 0 ? " scrollamount=\"$int_scroll_amount\"" : ""),'',($int_scroll_delay != 0  ? " scrolldelay=\"$int_scroll_delay\"" : ""),' onmouseover=\'this.stop()\' onmouseout=\'this.start()\'>';
//}

if ($marquee_scroll) {

/*
<style type="text/css">
#marqueecontainer{
/*position: relative; *
/*width: 200px; marquee width *
/*height: 200px; marquee height *
/*background-color: white;*
overflow: hidden;
/*border: 3px solid orange;*
padding: 2px;
/*padding-left: 4px;*
}
</style>*/
echo '
<script type="text/javascript">
/***********************************************
* Cross browser Marquee II- � Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var delayb4scroll='.($scroll_delay*1000).' //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed='.$scroll_amount.' //Specify marquee scroll speed (larger is faster 1-10)
var pauseit='.$scroll_pause.' //Pause marquee onMousever (0=no. 1=yes)?
var copyspeed = marqueespeed
var pausespeed = (pauseit == 0) ? copyspeed : 0
var actualheight = \'\'

function scrollmarquee(){
    if (parseInt(cross_marquee.style.top) > (actualheight*(-1)+8)) {
        cross_marquee.style.top = parseInt(cross_marquee.style.top)-copyspeed+"px"
    } else {
        cross_marquee.style.top = parseInt(marqueeheight)+8+"px"
    }
}

function initializemarquee(){
    cross_marquee=document.getElementById("vmarquee")
    cross_marquee.style.top=0
    marqueeheight=document.getElementById("marqueecontainer").offsetHeight
    actualheight=cross_marquee.offsetHeight
    //if Opera or Netscape 7x, add scrollbars to scroll and exit
    if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){
        cross_marquee.style.height = marqueeheight+"px"
        cross_marquee.style.overflow = "scroll"
        return
    }
    setTimeout(\'lefttime=setInterval("scrollmarquee()",30)\', delayb4scroll)
}

if (window.addEventListener) {
    window.addEventListener("load", initializemarquee, false)
} else if (window.attachEvent) {
    window.attachEvent("onload", initializemarquee)
} else if (document.getElementById) {
    window.onload=initializemarquee
}
</script>
<div id="marqueecontainer" onmouseover="copyspeed=pausespeed" onmouseout="copyspeed=marqueespeed" style="position: relative; height: '.$scroll_height.'px; overflow: hidden; padding: 2px;">
<div id="vmarquee" style="position: absolute; width: 98%;">';

}


echo '<ul class="latestnews',$moduleclass_sfx,'"> ';
foreach ($posts as $post) {

//        $post['href'] = removeTrailingSlash($post['href']);
//        $post['member']['link'] = removeTrailingSlash($post['member']['link']);
        echo "\n";
echo '<li class="latestnews'.$moduleclass_sfx.'">';

        //This section is done this way(very explicit) so that
        //future options can be built into the module easier

        //Start subject link
echo '<a class="latestnews'.$moduleclass_sfx.'" href="'.$post['href'].'" ';
        //external links
        if ($external) {
        echo 'target="_blank" ';
        }
        echo '>';





        //let's leave the formatting to our users in the future

        //1.7-3 Let them display the topic icon.
        if($bln_icon) {
            echo $post['icon'];
            //space
            echo ' ';
        }

if ($bln_board) {
echo '<i>'.$post['board']['name'].'</i> : ';
}


        if(!empty($int_num_char)) {
            //$subject_chars = str_replace('&amp;', '&', $post['subject']);
            //$subject_chars = substr($subject_chars, 0, $int_num_char);
            //$subject_chars = str_replace('&', '&amp;', $subject_chars);
            //echo $subject_chars;
            echo substr(html_entity_decode($post['subject']), 0, $int_num_char);
if(strlen($post['subject']) > $int_num_char) {
                echo '...';
            }
        }
        else {
            //echo $post['subject'];
            echo html_entity_decode($post['subject']);
        }
        echo '</a>';

        if($bln_replies) {
            //space
            echo ' ';
            //output the number of posts for this subject
            echo '('.$post['replies'].')';
        }

        if($bln_poster) {
            //space
            echo ' ';
            //this is the 'by' in 'by username'
            echo $txt[525];

            //space
            echo ' ';

            //member link
            //echo $post['member']['link'];
            echo '<a class="latestnews'.$moduleclass_sfx.'" href="'.$post['member']['href'].'" ';
            //external links
            if ($external) {
                echo 'target="_blank" ';
            }
            //echo 'title="' . $txt[92] . ' ' . $post['member']['username'] . '" '.
            //echo '>';

            if ($bln_real_name) {
            echo 'title="' . $txt[92] . ' ' . $post['member']['name'] . '" > '.$post['member']['name'].'</a>';
            } else {
                echo 'title="' . $txt[92] . ' ' . $post['member']['username'] . '" > '.$post['member']['username'].'</a>';
            }

        }

if ($bln_date_time) {
            //space
            echo ' ';
echo '-';
            //space
            echo ' ';
            echo $post['time'];
}

        if(empty($post['new'])) {
            //space
            echo ' ';
            //link
            echo '<a href="' . $post['href'] . '" ';
            if ($external) {
            echo 'target="_blank" ';
            }
            echo '>';
            //image
            echo '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" />';
            echo '</a>';
        }
echo '</li>';
}
echo '</ul>';

if($marquee_scroll) {
echo '</div></div>';
}

?>


Thank you

Orstio

QuoteI have made a posting at joomlahack.com but others have had the same problem and there hasn't been a reply within a year.

Even so, you will find better support for joomlahacks products at joomlahacks.com.

samurai-lupin

Well, but as there have been people with the same problem but not received a reply for well over a year I doubt my probem would get solved there. It's a pitty but I don't know what else to do.

Advertisement: