Fitur Linktrans dan LongURL


Langkar pertama, masuk ke file common/twitter.php!
Kemudian cari function link_trans($url) , function twitter_entities_links($entities_urls,$out) dan function theme_external_link($url, $content = null) .
Ganti isi dari fungsi yang disebut diatas dengan code di bawah ini :

function link_trans($url) {
switch (setting_fetch(‘linktrans’, ‘d’)) {
case ‘o’:
$atext = $url;
break;

case ‘d’:
$url = ((stripos($url,’http://’) !== 0) && (stripos($url,’https://’) !== 0)) ? ‘http://’.$url : $url;
$urlpara = parse_url($url);
$atext = "[{$urlpara[host]}]";
break;
case ‘l’:
$atext = "[link]";
break;
}
return $atext;
}

dan

function twitter_entities_links($entities_urls,$out) {
foreach($entities_urls as $urls) {
if($urls->display_url != "") {
$display_url = $urls->display_url;
} else {
$display_url = $urls->url;
}

$expanded_url = ($urls->expanded_url) ? $urls->expanded_url : $urls->url;

$lurl = (setting_fetch(‘longurl’) == ‘yes’ && LONG_URL == ‘ON’) ? long_url($expanded_url) : $expanded_url;

if (setting_fetch(‘gwt’) == ‘on’) // If the user wants links to go via GWT
{
$encoded = urlencode($lurl);
$link = "http://google.com/gwt/n?u={$encoded}";
} else {
$link = $lurl;
}
$atext = link_trans($display_url);
$link_html = ‘<a href="’ . $link . ‘" rel="external nofollow noreferrer">’ . $atext . ‘</a>’;
$url = $urls->url;

// Replace all URLs *UNLESS* they have already been linked (for example to an image)
$pattern = ‘#((?<!href\=(\’|\"))’.preg_quote($url,’#’).’)#i’;
$out = preg_replace($pattern,$link_html, $out);
}
return $out;
}

function twitter_parse_tags($input, $entities = false) {

// Use the Entities to replace hyperlink URLs
// http://dev.twitter.com/pages/tweet_entities
if($entities) {
$out = $input;
$out = ($entities->urls) ? twitter_entities_links($entities->urls,$out) : $out;
$out = ($entities->media) ? twitter_entities_links($entities->media,$out) : $out;
} else { // If Entities haven’t been returned, use Autolink
// Create an array containing all URLs
$urls = Twitter_Extractor::create($input)
->extractURLs();

$out = $input;

// Hyperlink the URLs
if (setting_fetch(‘gwt’) == ‘on’) // If the user wants links to go via GWT
{
foreach($urls as $url)
{

if (setting_fetch(‘longurl’) == ‘yes’ && LONG_URL == ‘ON’) {
$lurl = long_url($url);
} else {
$lurl = $url;
}
$encoded = urlencode($lurl);
$atext = link_trans($lurl);
$out = str_replace($url, "<a href=’http://google.com/gwt/n?u={$encoded}’ rel=’external nofollow noreferrer’>{$atext}</a>", $out);
}
} else {
$out = Twitter_Autolink::create($out)
->setTarget(”)
->addLinksToURLs();
foreach($urls as $url)
{
if (setting_fetch(‘longurl’) == ‘yes’ && LONG_URL == ‘ON’) {
$lurl = long_url($url);
$out = str_replace(‘href="’.$url.’"’, ‘href="’.$lurl.’"’, $out);
} else {
$lurl = $url;
}
$atext = link_trans($lurl);
$out = str_replace(">{$url}</a>", ">{$atext}</a>", $out);
}
}
}

// Hyperlink the @ and lists
$out = Twitter_Autolink::create($out)
->setTarget(”)
->addLinksToUsernamesAndLists();

// Hyperlink the #
$out = Twitter_Autolink::create($out)
->setTarget(”)
->addLinksToHashtags();

//Linebreaks. Some clients insert \n for formatting.
$out = nl2br($out);

// Emails
$tok = strtok($out, " \n\t\n\r"); // Tokenise the string by whitespace

while ($tok !== false) { // Go through all the tokens
$at = stripos($tok, "@"); // Does the string contain an "@"?

if ($at && $at > 0) { // @ is in the string & isn’t the first character
$tok = trim($tok, "?.,!\"\’"); // Remove any trailing punctuation

if (filter_var($tok, FILTER_VALIDATE_EMAIL)) { // Use the internal PHP email validator
$email = $tok;
$out = str_replace($email, "<a href=\"mailto:{$email}\">{$email}</a>", $out); // Create the mailto: link
}
}
$tok = strtok(" \n\t\n\r"); // Move to the next token
}

//Return the completed string
return $out;
}

dan

function theme_external_link($url, $content = null) {
//Long URL functionality. Also uncomment function long_url($shortURL)
if (setting_fetch(‘longurl’) == ‘yes’ && LONG_URL == ‘ON’) {
$lurl = long_url($url);
} else {
$lurl = $url;
}
if (!$content) {
//Used to wordwrap long URLs
//return "<a href=’$url’ target=’_blank’>". wordwrap(long_url($url), 64, "\n", true) ."</a>";
$atext = link_trans($lurl);
return "<a href=’$lurl’ rel=’external nofollow noreferrer’>$atext</a>";
} else {
return "<a href=’$lurl’ rel=’external nofollow noreferrer’>$content</a>";
}
}

kemudian masuk ke file /common/settinga.php

Di function settings_page($args) tambahkan fungsi :

$settings[‘longurl’] = $_POST[‘longurl’];
$settings[‘linktrans’] = $_POST[‘linktrans’];

selanjutnya, masukkan kode di bawah ini sesudah fungsi $gwt

$longurl = array(
‘on’ => ‘On’,
‘off’ => ‘Off’,
);

$linktrans = array(
‘o’ => ‘Full URL’,
‘d’ => ‘Domain Only’,
‘l’ => ‘[link]’,
);

Tambahkan kode :

if (LONG_URL == ‘ON’) { $content .= ‘<p><label>Show Long URL Services:<br /><select name="longurl">’.theme(‘options’, $longurl, setting_fetch(‘longurl’)).'</select></label></p>’;}
$content .= ‘<p><label>Showing URL:<br /><select name="linktrans">’.theme(‘options’, $linktrans, setting_fetch(‘linktrans’, ‘d’)).'</select></label><br /><span class="texts">Note: Domain Only means change https://twitter.com/JaHIY to [twitter.com]</span></p><hr />’;

Sesudah kode :

$content .= theme(‘options’, $gwt, setting_fetch(‘gwt’, $GLOBALS[‘current_theme’] == ‘text’ ? ‘on’ : ‘off’));
$content .= ‘</select><small><br />Google Web Transcoder (GWT) converts third-party sites into small, speedy pages suitable for older phones and people with less bandwidth.</small></p>’;

Jangan lupa kunjungi & gunakan Twitter Client dari kami di alamat www.imorv.com atau www.motweet.co.tvūüôā

@fays_ozunu

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: