0

Hi guys
I used the joomla cms for web development.
Actually i install the roknewsrotator module and use it for Persian language that it decode with UTF-8.
i don't know why the News rotators module want to show some news in UTF-8 language, at the end of the sentences it showed this icon : �
i try to fix it, but until now, i was unsuccessful.
I find all of php file of this module and change all of them from ANSI to UTF-8.
But the problem persist.
If anyone can help me, please guide me.
Thank you

2
Contributors
9
Replies
10
Views
5 Years
Discussion Span
Last Post by diafol
0

Thank you ardav

I tried that, but unfortunately same problem.

here in the module code, do you think that there is something incorrect in that?!
Look at the line 10 to 14.
I think something is wrong in there.

defined('_JEXEC') or die('Restricted access');

require_once (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
jimport('joomla.utilities.date');

class modRokNewsRotatorHelper
{
	function prepareContent( $text, $length=300 ) {
		// strips tags won't remove the actual jscript
		$text = preg_replace( "'<script[^>]*>.*?</script>'si", "", $text );
		$text = preg_replace( '/{.+?}/', '', $text);
		// replace line breaking tags with whitespace
		$text = preg_replace( "'<(br[^/>]*?/|hr[^/>]*?/|/(div|h[1-6]|li|p|td))>'si", ' ', $text );
		$text = strip_tags( $text );
		if (strlen($text) > $length) $text = substr($text, 0, $length) . "...";
		return $text;
	}	
	
	function getRotatorImage($text) {
        $regex = "#<!--IMAGE\s(.*?)IMAGE-->#s";
        preg_match( $regex, $text, $matches );
        if (sizeof($matches)==2) return trim($matches[1]);
        else return false;
    }
	
	function getList(&$params)
	{
		global $mainframe;

		$db			=& JFactory::getDBO();
		$user		=& JFactory::getUser();
		$userId		= (int) $user->get('id');

		$count		= (int) $params->get('count', 5);
		$catid		= trim( $params->get('catid') );
		$secid		= trim( $params->get('secid') );
		$show_front	= $params->get('show_front', 1);
		$aid		= $user->get('aid', 0);

		$text_length = intval($params->get( 'preview_count', 75) );

		$contentConfig = &JComponentHelper::getParams( 'com_content' );
		$access		= !$contentConfig->get('shownoauth');

		$nullDate	= $db->getNullDate();
		$now		= date('Y-m-d H:i:s', time());

		$where		= 'a.state = 1'
			. ' AND ( a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).' )'
			. ' AND ( a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).' )'
			;

		// User Filter
		switch ($params->get( 'user_id' ))
		{
			case 'by_me':
				$where .= ' AND (created_by = ' . (int) $userId . ' OR modified_by = ' . (int) $userId . ')';
				break;
			case 'not_me':
				$where .= ' AND (created_by <> ' . (int) $userId . ' AND modified_by <> ' . (int) $userId . ')';
				break;
		}

		// Ordering
		switch ($params->get( 'ordering' ))
		{
			case 'm_dsc':
				$ordering		= 'a.modified DESC, a.created DESC';
				break;
			case 'c_dsc':
			default:
				$ordering		= 'a.created DESC';
				break;
		}

        if ($show_front != 2) {
    		if ($catid)
    		{
    			$ids = explode( ',', $catid );
    			JArrayHelper::toInteger( $ids );
    			$catCondition = ' AND (cc.id=' . implode( ' OR cc.id=', $ids ) . ')';
    		}
    		if ($secid)
    		{
    			$ids = explode( ',', $secid );
    			JArrayHelper::toInteger( $ids );
    			$secCondition = ' AND (s.id=' . implode( ' OR s.id=', $ids ) . ')';
    		}
    	}

		// Content Items only
		$query = 'SELECT a.*, ' .
			' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'.
			' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug'.
			' FROM #__content AS a' .
			($show_front == '0' ? ' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' : '') .
			($show_front == '2' ? ' INNER JOIN #__content_frontpage AS f ON f.content_id = a.id' : '') .
			' INNER JOIN #__categories AS cc ON cc.id = a.catid' .
			' INNER JOIN #__sections AS s ON s.id = a.sectionid' .
			' WHERE '. $where .' AND s.id > 0' .
			($access ? ' AND a.access <= ' .(int) $aid. ' AND cc.access <= ' .(int) $aid. ' AND s.access <= ' .(int) $aid : '').
			($catid && $show_front != 2 ? $catCondition : '').
			($secid && $show_front != 2 ? $secCondition : '').
			($show_front == '0' ? ' AND f.content_id IS NULL ' : '').
			' AND s.published = 1' .
			' AND cc.published = 1' .
			' ORDER BY '. $ordering;


		$db->setQuery($query, 0, $count);
		$rows = $db->loadObjectList();

		$i		= 0;
		$lists	= array();
		foreach ( $rows as $row )
		{
		    $lists[$i]->mainimage = modRokNewsRotatorHelper::getRotatorImage($row->introtext);
			$lists[$i]->link = ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid);
			$lists[$i]->title = htmlspecialchars( $row->title );
			$lists[$i]->introtext = modRokNewsRotatorHelper::prepareContent($row->introtext, $params->get('preview_count', 300));
			$lists[$i]->date = new JDate( $row->created );
			$i++;
		}

		return $lists;
	}



}

Edited by Mojtabarahimi: Add the code line.

0

There's nothing there that I can see. Put this at the top of the page:

header('Content-Type: text/html; charset=utf-8');

If that doesn't work, there's a bit of code I sometimes use for stubborn encoding problems:

mysql_query('SET names=utf8');
	mysql_query('SET character_set_client=utf8');
	mysql_query('SET character_set_connection=utf8');
	mysql_query('SET character_set_results=utf8');
	mysql_query('SET collation_connection=utf8_unicode_ci');
0

Thank you ardav for your reply.
I do that, but the problem persist! :(
i don't know why! it is the first time that i have dealing with this problem.
You can see the website with this link : http://www.ikgsch.com
Pay attention to central slider, some slides doesn't have any problem and some of them have got problem.

I found some java script file in the module folder.
Have a see :

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('e 12=9 1y({1z:\'1.3\',7:{s:1B,14:1I,10:L,W:F,b:F,15:F,D:\'f/1J.1s\'},1i:6(p,7){5.p=$(p);5.1h(7);5.f=5.p.1g(\'.O > H\');5.a=$$(\'#\'+p+\' .q-V A.q A.1f\');5.k=0;5.17();5.19();5.x=\'l\';m(5.7.10)1j.I(\'1e\',5.d.h(5));g 5},17:6(){e r=5;$$(5.a,5.f).J(\'1n\',\'1m\');e f=5.f.S(1);e a=5.a.S(1);f.o(6(O){O.X(5.f[0]).J(\'y\',0)},5);a.o(6(q){q.X(5.a[0]).J(\'y\',0)},5);e Y=$$(\'.q-V\').S(1);Y.o(6(q){q.1l().1o()});e b=9 t(\'A\',{\'u\':\'b\'}).w(5.p);5.1a=9 t(\'H\',{\'u\':\'B-z\',\'T\':\'1b\',\'N\':\'z\',\'U\':5.7.D}).w(b);5.18=9 t(\'H\',{\'u\':\'B-n\',\'T\':\'1d\',\'N\':\'n\',\'U\':5.7.D}).w(b);5.Z=9 t(\'H\',{\'1c\':\'d-l\',\'u\':\'B-l\',\'T\':\'1k/1H\',\'N\':\'d/l\',\'U\':5.7.D}).w(b);m(!5.7.b)b.J(\'1M\',\'1F\');m(5.7.15&&5.7.b){e C=9 P.Q(b,\'y\',{1D:L}).1C(0);5.p.1G({\'1L\':C.v.h(C,1),\'1K\':C.v.h(C,0)})};m(5.7.W){(5.f.E).G(6(i){(2).G(6(j){9 t(\'A\',{\'u\':\'i\'+(j+1)}).w(5.f[i])}.h(5))}.h(5))}(4).G(6(i){9 t(\'A\',{\'u\':\'1p c\'+(i+1)}).w(5.a[0].1t())}.h(5));5.8=[];(5.a.E).G(6(i){5.8[i]=[9 P.Q(5.f[i],\'y\',{s:5.7.s,1r:6(){r.K=F},1q:6(){r.K=L}}),9 P.Q(5.a[i],\'y\',{s:5.7.s})]}.h(5));g 5},19:6(){e r=5,M=$(\'d-l\');5.1a.I(\'R\',5.11.h(5));5.18.I(\'R\',5.n.h(5));5.Z.I(\'R\',6(){m(r.x==\'d\'){r.l();M.16=\'B-d\'}1u{r.d();M.16=\'B-l\'}});g 5},11:6(){m(5.K)g 5;e z=(!5.k)?5.a.E-1:5.k-1;5.8[5.k].o(6(8){8.v(0)});5.8[z].o(6(8){8.v(1)});5.k=z;g 5},n:6(){m(5.K)g 5;e n=(5.k==5.a.E-1)?0:5.k+1;5.8[5.k].o(6(8){8.v(0)});5.8[n].o(6(8){8.v(1)});5.k=n;g 5},d:6(){m(5.x==\'d\')g 5;5.x=\'d\';5.13=5.n.1x(5.7.14+5.7.s,5);g 5},l:6(){5.x=\'l\';$1w(5.13);g 5}});12.1v(9 1E,9 1A);',62,111,'|||||this|function|options|fx|new|content|controls||play|var|images|return|bind|||current|stop|if|next|each|container|story|self|duration|Element|class|start|inject|status|opacity|prev|div|control|controlsFx|blankimage|length|true|times|img|addEvent|setStyle|transitioning|false|playstop|alt|image|Fx|Style|click|slice|title|src|block|corners|injectAfter|stories|arrowPlay|autoplay|previous|RokNewsRotator|timer|delay|autohide|className|build|arrowNext|attachEvents|arrowPrev|Previous|id|Next|load|padding|getElements|setOptions|initialize|window|Play|empty|absolute|position|remove|corner|onComplete|onStart|png|getParent|else|implement|clear|periodical|Class|version|Options|1000|set|wait|Events|none|addEvents|Stop|5000|blank|mouseleave|mouseenter|display'.split('|'),0,{}))
0

Had a look - seems to be the character before the '...' in some slides. Is it the same character every time?

0

yes, i checked each slides exactly.
All of them are same.
i think there is a problem in coding and php source.
:(

0

Just thought, it could be because you have Persian chars and substr is chopping them incorrectly - in the middle of the character:

if (strlen($text) > $length) $text = substr($text, 0, $length) . "...";

Try using mb_* string function equivalents with Persian:

http://php.net/manual/en/function.mb-substr.php

Persian uses multi-byte characters (I think).

if (mb_strlen($text,'UTF-8') > $length) $text = mb_substr($text, 0, $length, 'UTF-8') . "...";

Hope that works :)

0

WoooooooooooooooooooooooW!!!!
You are great man!!! very very great!
I don't know how can i say thank you to you.
You didn't just help me to fix this problem. You learn something new to me and in the future i know that i need that.
Thank you very much
If any thing availabe that i can do it for you, please let me know.
Thank you man.
All the best
Regards

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.