$this->direction
can only be used on templates and there is no JLanguage
property to get the actual value ltr
or rtl
. So you could do something along the lines if this instead:
$lang = JFactory::getLanguage();
$dir = $lang->get('rtl');
if($dir == 0) {
//do soemthing
}
else {
//do something else
}