Skip to content

Commit

Permalink
added version 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Todor Iliev committed Mar 11, 2012
1 parent dd727a1 commit 2790ee6
Show file tree
Hide file tree
Showing 4 changed files with 230 additions and 29 deletions.
7 changes: 4 additions & 3 deletions README.md
@@ -1,12 +1,13 @@
ITPShare Module for Joomla!
==========================
( Version 1.9 )
( Version v2.0 )
--------------------------



Changelog
---------
v2.0
----
* Improved the multilanguage

v1.9
-----
Expand Down
215 changes: 201 additions & 14 deletions helper.php
Expand Up @@ -41,9 +41,19 @@ public static function getTwitter($params, $url, $title){
$html = "";
if($params->get("twitterButton")) {

$html = '
/**** Get locale code ***/
if(!$params->get("dynamicLocale")) {
$locale = $params->get("twitterLanguage", "en");
} else {
$tag = JFactory::getLanguage()->getTag();
$locale = str_replace("-","_", $tag);
$locales = self::getButtonsLocales($locale);
$locale = JArrayHelper::getValue($locales, "twitter", "en");
}

$html = '
<div class="itp-share-tw">
<a href="https://twitter.com/share" class="twitter-share-button" data-url="' . $url . '" data-text="' . $title . '" data-via="' . $params->get("twitterName") . '" data-lang="' . $params->get("twitterLanguage") . '" data-size="' . $params->get("twitterSize") . '" data-related="' . $params->get("twitterRecommend") . '" data-hashtags="' . $params->get("twitterHashtag") . '" data-count="' . $params->get("twitterCounter") . '">Tweet</a>
<a href="https://twitter.com/share" class="twitter-share-button" data-url="' . $url . '" data-text="' . $title . '" data-via="' . $params->get("twitterName") . '" data-lang="' . $locale . '" data-size="' . $params->get("twitterSize") . '" data-related="' . $params->get("twitterRecommend") . '" data-hashtags="' . $params->get("twitterHashtag") . '" data-count="' . $params->get("twitterCounter") . '">Tweet</a>
<script type="text/javascript">!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div>
';
Expand All @@ -53,14 +63,23 @@ public static function getTwitter($params, $url, $title){
}

public static function getGooglePlusOne($params, $url, $title){
$language = "";

if($params->get("plusLocale")) {
$language = " {lang: '" . $params->get("plusLocale") . "'};";
}

$html = "";
if($params->get("plusButton")) {

/**** Get locale code ***/
if(!$params->get("dynamicLocale")) {
$locale = $params->get("plusLocale", "en");
} else {
$tag = JFactory::getLanguage()->getTag();
$locale = str_replace("-","_", $tag);
$locales = self::getButtonsLocales($locale);
$locale = JArrayHelper::getValue($locales, "google", "en");
}

$language = " {lang: '" . $locale . "'};";

$html .= '<div class="itp-share-gone">';

switch($params->get("plusRenderer")) {
Expand Down Expand Up @@ -162,37 +181,42 @@ public static function getFacebookLike($params, $url, $title){
$html = "";
if($params->get("facebookLikeButton")) {

if($params->get("fbDynamicLocale", 0)) {
$fbLocale = JFactory::getLanguage();
$fbLocale = $fbLocale->getTag();
$fbLocale = str_replace("-","_",$fbLocale);
/**** Get locale code ***/
if(!$params->get("dynamicLocale")) {
$locale = $params->get("fbLocale", "en_US");
} else {
$fbLocale = $params->get("fbLocale", "en_US");
$tag = JFactory::getLanguage()->getTag();
$locale = str_replace("-","_", $tag);
$locales = self::getButtonsLocales($locale);
$locale = JArrayHelper::getValue($locales, "facebook", "en_US");
}

/**** Faces ***/
$faces = (!$params->get("facebookLikeFaces")) ? "false" : "true";

/**** Layout Styles ***/
$layout = $params->get("facebookLikeType", "button_count");
if(strcmp("box_count", $layout)==0){
$height = "80";
} else {
$height = "25";
}

/**** Generate code ***/
$html = '<div class="itp-share-fbl">';

switch($params->get("facebookLikeRenderer")) {

case 0: // iframe
$html .= self::genFacebookLikeIframe($params, $url, $layout, $faces, $height, $fbLocale);
$html .= self::genFacebookLikeIframe($params, $url, $layout, $faces, $height, $locale);
break;

case 1: // XFBML
$html .= self::genFacebookLikeXfbml($params, $url, $layout, $faces, $height, $fbLocale);
$html .= self::genFacebookLikeXfbml($params, $url, $layout, $faces, $height, $locale);
break;

default: // HTML5
$html .= self::genFacebookLikeHtml5($params, $url, $layout, $faces, $height, $fbLocale);
$html .= self::genFacebookLikeHtml5($params, $url, $layout, $faces, $height, $locale);
break;
}

Expand Down Expand Up @@ -597,4 +621,167 @@ public static function getBuffer($params, $url, $title){
return $html;
}


public static function getButtonsLocales($locale) {

// Default locales
$result = array(
"twitter" => "en",
"facebook" => "en_US",
"google" => "en"
);

// The locales map
$locales = array (
"en_US" => array(
"twitter" => "en",
"facebook" => "en_US",
"google" => "en"
),
"en_GB" => array(
"twitter" => "en",
"facebook" => "en_GB",
"google" => "en_GB"
),
"th_TH" => array(
"twitter" => "th",
"facebook" => "th_TH",
"google" => "th"
),
"ms_MY" => array(
"twitter" => "msa",
"facebook" => "ms_MY",
"google" => "ms"
),
"tr_TR" => array(
"twitter" => "tr",
"facebook" => "tr_TR",
"google" => "tr"
),
"hi_IN" => array(
"twitter" => "hi",
"facebook" => "hi_IN",
"google" => "hi"
),
"tl_PH" => array(
"twitter" => "fil",
"facebook" => "tl_PH",
"google" => "fil"
),
"zh_CN" => array(
"twitter" => "zh-cn",
"facebook" => "zh_CN",
"google" => "zh"
),
"ko_KR" => array(
"twitter" => "ko",
"facebook" => "ko_KR",
"google" => "ko"
),
"it_IT" => array(
"twitter" => "it",
"facebook" => "it_IT",
"google" => "it"
),
"da_DK" => array(
"twitter" => "da",
"facebook" => "da_DK",
"google" => "da"
),
"fr_FR" => array(
"twitter" => "fr",
"facebook" => "fr_FR",
"google" => "fr"
),
"pl_PL" => array(
"twitter" => "pl",
"facebook" => "pl_PL",
"google" => "pl"
),
"nl_NL" => array(
"twitter" => "nl",
"facebook" => "nl_NL",
"google" => "nl"
),
"id_ID" => array(
"twitter" => "in",
"facebook" => "nl_NL",
"google" => "in"
),
"hu_HU" => array(
"twitter" => "hu",
"facebook" => "hu_HU",
"google" => "hu"
),
"fi_FI" => array(
"twitter" => "fi",
"facebook" => "fi_FI",
"google" => "fi"
),
"es_ES" => array(
"twitter" => "es",
"facebook" => "es_ES",
"google" => "es"
),
"ja_JP" => array(
"twitter" => "ja",
"facebook" => "ja_JP",
"google" => "ja"
),
"nn_NO" => array(
"twitter" => "no",
"facebook" => "nn_NO",
"google" => "no"
),
"ru_RU" => array(
"twitter" => "ru",
"facebook" => "ru_RU",
"google" => "ru"
),
"pt_PT" => array(
"twitter" => "pt",
"facebook" => "pt_PT",
"google" => "pt"
),
"pt_BR" => array(
"twitter" => "pt",
"facebook" => "pt_BR",
"google" => "pt"
),
"sv_SE" => array(
"twitter" => "sv",
"facebook" => "sv_SE",
"google" => "sv"
),
"zh_HK" => array(
"twitter" => "zh-tw",
"facebook" => "zh_HK",
"google" => "zh_HK"
),
"zh_TW" => array(
"twitter" => "zh-tw",
"facebook" => "zh_TW",
"google" => "zh_TW"
),
"de_DE" => array(
"twitter" => "de",
"facebook" => "de_DE",
"google" => "de"
),
"bg_BG" => array(
"twitter" => "en",
"facebook" => "bg_BG",
"google" => "bg"
),

);

if(isset($locales[$locale])) {
$result = $locales[$locale];
}

return $result;

}

}
36 changes: 24 additions & 12 deletions mod_itpshare.xml
Expand Up @@ -48,18 +48,30 @@
<option value="horizontal">Horizontal</option>
</field>
<field name="twitterLanguage" type="list" default="en" label="Twitter Language" description="Choose the language of the Twitter button." >
<option value="nl">Dutch</option>
<option value="en">English</option>
<option value="en">English</option>
<option value="th">Thai</option>
<option value="msa">Malay</option>
<option value="tr">Turkish</option>
<option value="hi">Hindi</option>
<option value="fil">Filipino</option>
<option value="zh-cn">Simplified Chinese</option>
<option value="ko">Korean</option>
<option value="it">Italian</option>
<option value="da">Danish</option>
<option value="fr">French</option>
<option value="gr">German</option>
<option value="pl">Polish</option>
<option value="nl">Dutch</option>
<option value="id">Indonesian</option>
<option value="it">Italian</option>
<option value="hu">Hungarian</option>
<option value="fi">Finnish</option>
<option value="es">Spanish</option>
<option value="jp">Japanese</option>
<option value="ko">Korean</option>
<option value="pt">Portuguese</option>
<option value="no">Norwegian</option>
<option value="ru">Russian</option>
<option value="es">Spanish</option>
<option value="tr">Turkish</option>
<option value="pt">Portuguese</option>
<option value="sv">Swedish</option>
<option value="zh-tw">Traditional Chinese</option>
<option value="de">German</option>
</field>

<field name="spacer2" type="spacer" class="text" label="############# TUMBLR SETTINGS #############" />
Expand Down Expand Up @@ -115,10 +127,6 @@
<option value="verdana">verdana</option>
</field>
<field name="facebookLikeWidth" type="text" default="90" label="Facebook Like Width" description="Enter the width of your Facebook Like button." />
<field name="fbDynamicLocale" type="radio" default="0" label="Auto language" description="If you set 'Yes' the plugin will take Joomla! locale settings automatically.">
<option value="0">No</option>
<option value="1">Yes</option>
</field>
<field name="fbLocale" type="list" default="en_US" label="Language" description="A list with locations and language for the button. Default location - English [en_US].">
<option value="af_ZA">Afrikaans</option>
<option value="ar_AR">Arabic</option>
Expand Down Expand Up @@ -481,6 +489,10 @@
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="dynamicLocale" type="radio" default="0" label="Auto language" description="If you set 'Yes' the plugin will take Joomla! locale settings automatically.">
<option value="0">No</option>
<option value="1">Yes</option>
</field>

<field name="spacer17" type="spacer" class="text" label="############# ADDITIONAL BUTTONS #############" />
<field name="ebuttons1" type="textarea" default="" label="A Button code 1" description="Insert an additional button ccode that will be included. If you need to specify a URL or title, use {URL} and {TITLE} for that." cols="50" rows="10" filter="raw" />
Expand Down
1 change: 1 addition & 0 deletions style.css
Expand Up @@ -56,6 +56,7 @@

.itp-share-pinterest {
float:left;
margin-left:10px;
margin-top:10px;
}

Expand Down

0 comments on commit 2790ee6

Please sign in to comment.