LastViews - Fully translatable now

16 years 8 months ago #44166 by houbahop
LastViews - Fully translatable now was created by houbahop
Hello,

I have modified the plugin v0_2_9 to make it multilanguage.

I assume that you have joomfish installed to use this. If it's not the case you are not concerned by this modification.

you need to go in
.../ components / com_comprofiler / plugin / user / plug_cblastviewstab-0_2_9 /

editlastviews.php and replace it with the code below AFTER HAVING DONE A BACKUP PLEASE.

[code:1]<?php
/**
* LastView Tab Class for handling the CB tab api
* @version $Id$
* @package Community Builder
* @subpackage lastviews.php
* @author Trail
* @copyright (C) 2005-2006 Trail, www.djtrail.nl
* @license www.gnu.org/copyleft/gpl.html GNU/GPL
*/

// Don't allow direct linking
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

class getLastViewsTab extends cbTabHandler {
/**
* Constructor
*/
function getLastViewsTab() {
$this->cbTabHandler();
}

function getDisplayTab($tab,$user,$ui) {
global $mainframe, $mosConfig_lang, $mosConfig_absolute_path, $mosConfig_live_site, $mosConfig_offset, $database, $my;
$return = "";


// modif houbahop pour multilanguage

$plugin_path=$mainframe->getCfg( 'absolute_path' ).'/components/com_comprofiler/plugin/user/plug_cblastviewstab-0_2_9';

if (file_exists($plugin_path.'/language/'.$mosConfig_lang.'.php')) {
include_once($plugin_path.'/language/'.$mosConfig_lang.'.php');
} else {
include_once($plugin_path.'/language/english.php');
}

//end modif
// also added constant() 8 times below;

$params = $this->params;
$LVexclusionlist = $params->get('LVexclusionlistTXT', '0');
$LVdateformat = $params->get('LVdateformatOPTION', '0');
$LVadmingroup = $params->get('LVadmingroupTXT', '18');
$LVhideadmin = $params->get('LVhideadminOPTION', '1');
$LVhideguests = $params->get('LVhideguestsOPTION', '1');
$listlimit = $params->get('LVlistlimit', '10');
$LVthelast = constant($params->get('LVthelastTXT', 'The Last'));
$LVadmin = constant($params->get('LVadminTXT', '(admin)'));
$LVviews = constant($params->get('LVviewsTXT', 'views'));
$LVavatar = constant($params->get('LVavatarTXT', 'Avatar'));
$LVname = constant($params->get('LVnameTXT', 'Name'));
$LVtime = constant($params->get('LVtimeTXT', 'Time'));
$LVtotal = constant($params->get('LVtotalTXT', 'Total'));
$LVguests = constant($params->get('LVguestsTXT', 'Guests have visited this profile.'));
$LVshowtotal = $params->get('LVshowtotalOPTION', '0');
$LVhidetotal = $params->get('LVhidetotalOPTION', '0');
$LVusername = $params->get('LVusernameOPTION', '0');
$JPKarmaWare = $params->get('JPKarmaWareOPTION', '0');

if (trim($LVexclusionlist == '')) $LVexclusionlist = '0';

$dateFormat = '';
if ($LVdateformat == '0') {
$dateFormat = '%d/%m %H:%M';
} elseif ($LVdateformat == '1') {
$dateFormat = '%d-%m %H:%M';
} elseif ($LVdateformat == '2') {
$dateFormat = '%d/%m/%Y %H:%M';
} elseif ($LVdateformat == '3') {
$dateFormat = '%d-%m-%Y %H:%M';
} elseif ($LVdateformat == '4') {
$dateFormat = '%m/%d %H:%M';
} elseif ($LVdateformat == '5') {
$dateFormat = '%m-%d %H:%M';
} elseif ($LVdateformat == '6') {
$dateFormat = '%m/%d/%Y %H:%M';
} elseif ($LVdateformat == '7') {
$dateFormat = '%m-%d-%Y %H:%M';
} elseif ($LVdateformat == '98') {
$dateFormat = _DATE_FORMAT_LC;
} elseif ($LVdateformat == '99') {
$dateFormat = _DATE_FORMAT_LC2;
}

$sql =
"SELECT "
. "\n v.viewer_id, "
. "lastview, "
. "\n v.viewscount, c.avatar, c.avatarapproved, c.banned, u.username, u.name "
. "\n FROM "
. "\n `#__comprofiler_views` v, `#__comprofiler` c, `#__users` u "
. "\n WHERE "
. "\n v.profile_id = " . $database->getEscaped($user->id)
. "\n AND c.id=v.viewer_id "
. "\n AND u.id=c.id "
. "\n AND c.id NOT IN (" . $database->getEscaped($LVexclusionlist) . "«») "
. "\n ORDER BY "
. "\n v.lastview DESC "
. "\n LIMIT " . $database->getEscaped($listlimit);
$database->setQuery($sql);
$lastviews = $database->loadObjectList();
$viewercount=count($lastviews);

if($tab->description != null) {
$return .=
"<div class=\"tab_Description\">"
. unHtmlspecialchars(getLangDefinition($tab->description))
. "</div>";
}

$return =
"<table cellpadding=\"0\" cellspacing=\"2\" border=\"0\" width=\"95%\" align=\"center\">";

$colspan = 0;
$text = '';
$showLVtotal = true;

if (($my->id == $user->id || $LVshowtotal == '1') && $LVhidetotal != '0') {
$colspan = 4;
$text = htmlspecialchars("$LVthelast $viewercount $LVviews"«»);
$showLVtotal = true;
} elseif ($my->id && ($my->gid == 2 || $my->gid > $LVadmingroup) && ($LVhideadmin != '0')) {
$colspan = 4;
$text = htmlspecialchars("$LVthelast $viewercount $LVviews $LVadmin"«»);
$showLVtotal = true;
} else {
$colspan = 3;
$text = htmlspecialchars("$LVthelast $viewercount $LVviews"«»);
$showLVtotal = false;
}

$return .=
"<tr>"
. "<td class=\"sectiontableheader\" colspan=\"$colspan\" align=\"center\">"
. "<nobr>"
. "<font size=\"4\">$text</font>"
. "</nobr>"
. "</td>"
. "</tr>"
. "<tr>"
. "<td colspan=\"$colspan\" height=\"1\"> </td>"
. "</tr>"
. "<tr>"
. "<td class=\"sectiontableheader\" align=\"center\">"
. "<b>" . htmlspecialchars($LVavatar) . "</b>"
. "</td>"
. "<td class=\"sectiontableheader\" align=\"center\">"
. "<b>" . htmlspecialchars($LVname) . "</b>"
. "</td>"
. "<td class=\"sectiontableheader\" align=\"center\">"
. "<b>" . htmlspecialchars($LVtime) . "</b>"
. "</td>";

if ($showLVtotal) {
$return .=
"<td class=\"sectiontableheader\" align=\"center\">"
. "<b>" . htmlspecialchars($LVtotal) . "</b>"
. "</td>";
}

$return .=
"</tr>";

if ( $LVhideguests != '0') {
$sql =
"SELECT "
. "\n count(viewer_id) "
. "\n FROM "
. "\n `#__comprofiler_views` "
. "\n WHERE "
. "\n profile_id = " . $database->getEscaped($user->id) . " AND viewer_id = 0";
$database->setQuery($sql);
$guestscount = $database->loadResult();
}

if ($viewercount > 0) {
foreach ($lastviews as $lastview) {
//this cool sectiontableentry switch code line was contributed by viames :«»)
$class = (is_int(@$counter++ / 2) ? 'sectiontableentry1' : 'sectiontableentry2');

if ($LVusername == '0') { $viewername = $lastview->username; }
if ($LVusername == '1') { $viewername = $lastview->name; }
if ($LVusername == '2') { $viewername = '' . $lastview->username . ' (' . $lastview->name . ')'; }
if ($LVusername == '3') { $viewername = '' . $lastview->name . ' (' . $lastview->username . ')'; }


if ($lastview->avatar && $lastview->banned != '1' && $lastview->avatarapproved !='0') {
$testimage = "/images/comprofiler/tn$lastview->avatar";

if (file_exists($mosConfig_absolute_path.$testimage)) {
$image = $mosConfig_live_site.$testimage;
} else {
$testimage = "/components/com_comprofiler/plugin/language/$mosConfig_lang/images/tnnophoto.jpg";

if (file_exists($mosConfig_absolute_path.$testimage)) {
$image = $mosConfig_live_site.$testimage;
} else {
$image = "$mosConfig_live_site/components/com_comprofiler/plugin/language/default_language/images/tnnophoto.jpg";
}
}
} else {
$testimage = "/components/com_comprofiler/plugin/language/$mosConfig_lang/images/tnnophoto.jpg";

if (file_exists($mosConfig_absolute_path.$testimage)) {
$image = $mosConfig_live_site.$testimage;
} else {
$image = "$mosConfig_live_site/components/com_comprofiler/plugin/language/default_language/images/tnnophoto.jpg";
}
}


$return.=
"<tr>"
. "<td class=\"$class\" width=\"1%\" align=\"center\">"
. "<font size=\"-3\">"
. "<nobr> "
. "<a href=\""
. sefRelToAbs("index.php?option=com_comprofiler&task=userProfile&user=$lastview->viewer_id"«»)
. "\">"
. "<img border=\"0\" height=\"40\" src=\"$image\">"
. "</a>"
. " </nobr>"
. "</font>"
. "</td>"
. "<td class=\"$class\" align=\"center\">"
. "<font size=\"-3\">"
. "<nobr> "
. "<a href=\""
. sefRelToAbs("index.php?option=com_comprofiler&task=userProfile&user=$lastview->viewer_id"«»)
. "\">"
. "<b>" . htmlspecialchars($viewername) . "</b>"
. "</a>"
. " </nobr>"
. "</font>"
. "</td>"
. "<td class=\"$class\" align=\"center\">"
. "<font size=\"-3\">"
. "<nobr> "
. "<b>" . mosFormatDate( $lastview->lastview, $dateFormat ) . "</b>"
. " </nobr>"
. "</font>"
. "</td>";

if ( $showLVtotal ) {
$return .=
"<td class=\"$class\" width=\"1%\" align=\"center\">"
. "<font size=\"-3\">"
. "<nobr> "
. "<b>$lastview->viewscount</b>"
. " </nobr>"
. "</font>"
. "</td>";
}

$return.="</tr>";
}

if ( $LVhideguests != '0') {
$return .=
"<tr>"
. "<td colspan=\"$colspan\" height=\"1\"> </td>"
. "</tr>"
. "<tr>"
. "<td colspan=\"$colspan\" class=\"sectiontableheader\" align=\"center\">"
. "<font size=\"2\">"
. "<nobr> "
. "<b>$guestscount " . htmlspecialchars($LVguests) . "</b>"
. " </nobr>"
. "</font>"
. "</td>"
. "</tr>";
}

if ($JPKarmaWare != '1') {
$return .=
"<tr>"
. "<td align=\"center\" class=\"sectiontableentry1\" colspan=\"$colspan\">"
. "<font color=\"darkred\">"
. "<B>©</b>"
. "</font> "
. "by "
. "<a href=\"http://www.djtrail.nl\" target=\"_blank\">djTrail "
. "Released as JPKarmaware :«») "
. "<a href=\"www.joomlapolis.com/component/option,com_joomlaboard/Itemid,38/func,view/id,2308/catid,13/\" target=\"_blank\">"
. "<u>Click here to pay due karma</u>"
. "</a> "
. ":«»)"
. "</td>"
. "</tr>";
}

$return .=
"</table>";

return $return;
}
} //end getDisplayTab
} //end class getLastViewsTab.

?>
[/code:1]


Now, create a subfolder language in

.../ components / com_comprofiler / plugin / user / plug_cblastviewstab-0_2_9 /

Upload english.php with the code below.For other languages, copy and rename this file, and translate the text.

[code:1]<?php
DEFINE('_UE_LASTPROFILEVIEW_1','(admin)');
DEFINE('_UE_LASTPROFILEVIEW_2','The Last');
DEFINE('_UE_LASTPROFILEVIEW_3','views');
DEFINE('_UE_LASTPROFILEVIEW_4','Avatar');
DEFINE('_UE_LASTPROFILEVIEW_5','Name');
DEFINE('_UE_LASTPROFILEVIEW_6','Time');
DEFINE('_UE_LASTPROFILEVIEW_7','Total');
DEFINE('_UE_LASTPROFILEVIEW_8','Guest(s) have visited this profile');
?>[/code:1]

For unknown reason, french accents don't work (neither if you use them as "é" or "é"

now, go in backend, edit the CB tab related to LastViews and instead of the the language strings insert (from top to bottom):
_UE_LASTPROFILEVIEW_1
_UE_LASTPROFILEVIEW_2
_UE_LASTPROFILEVIEW_3
_UE_LASTPROFILEVIEW_4
_UE_LASTPROFILEVIEW_5
_UE_LASTPROFILEVIEW_6
_UE_LASTPROFILEVIEW_7
_UE_LASTPROFILEVIEW_8


It should work now :whistle: .




for french users, I give here french.php
unfortunately, without any accents.

[code:1]<?php
DEFINE('_UE_LASTPROFILEVIEW_1','(admin)');
DEFINE('_UE_LASTPROFILEVIEW_2','Les dernieres');
DEFINE('_UE_LASTPROFILEVIEW_3','visites');
DEFINE('_UE_LASTPROFILEVIEW_4','Avatar');
DEFINE('_UE_LASTPROFILEVIEW_5','Nom');
DEFINE('_UE_LASTPROFILEVIEW_6','Date');
DEFINE('_UE_LASTPROFILEVIEW_7','Total');
DEFINE('_UE_LASTPROFILEVIEW_8','Non inscrits ont vus ce profil');
?>[/code:1]


If you like it, please give karma to djtrail and me too if you want :lol:

COMMENT : english.php MUST be at least present.

Post edited by: houbahop, at: 2007/08/26 23:08

Post edited by: houbahop, at: 2007/08/26 23:09

Post edited by: houbahop, at: 2007/08/26 23:10

Post edited by: houbahop, at: 2007/08/26 23:12

Post edited by: houbahop, at: 2007/08/26 23:15

Post edited by: houbahop, at: 2007/08/26 23:17

Post edited by: houbahop, at: 2007/08/26 23:22
Attachments:

Please Log in to join the conversation.

16 years 8 months ago #44274 by Spider666
Replied by Spider666 on topic Re:LastViews - Fully translatable now
Thanks, it's perfect for me since I'm working on a multilingual site.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.164 seconds

Facebook Twitter LinkedIn