clickable() public static method

Makes twitter links, @usernames and #hashtags clickable.
public static clickable ( stdClass $status ) : string
$status stdClass
return string
Ejemplo n.º 1
0
 function __construct($status)
 {
     $this->status = $status;
     $this->readable = \Twitter::clickable($status);
     $this->link = "https://twitter.com/{$status->user->screen_name}/status/{$status->id_str}";
     $this->mobileLink = "https://mobile.twitter.com/{$status->user->screen_name}/status/{$status->id_str}";
 }
Ejemplo n.º 2
0
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Twitter timeline demo</title>

<ul>
<?php 
foreach ($channel->status as $status) {
    ?>
	<li><a href="http://twitter.com/<?php 
    echo $status->user->screen_name;
    ?>
"><img src="<?php 
    echo htmlspecialchars($status->user->profile_image_url);
    ?>
">
		<?php 
    echo htmlspecialchars($status->user->name);
    ?>
</a>:
		<?php 
    echo Twitter::clickable($status->text);
    ?>
		<small>at <?php 
    echo date("j.n.Y H:i", strtotime($status->created_at));
    ?>
</small>
	</li>
<?php 
}
?>
</ul>
Ejemplo n.º 3
0
		<?php 
foreach ($statuses as $status) {
    ?>
			<li><a href="http://twitter.com/<?php 
    echo $status->user->screen_name;
    ?>
"><img src="<?php 
    echo htmlspecialchars($status->user->profile_image_url);
    ?>
">
				<?php 
    echo htmlspecialchars($status->user->name);
    ?>
</a>:
				<?php 
    echo Twitter::clickable($status);
    ?>
				<small>at <?php 
    echo date("j.n.Y H:i", strtotime($status->created_at));
    ?>
</small>
			</li>
		<?php 
}
?>
		</ul>

		</form>
</body>
</html>
Ejemplo n.º 4
0
<?php

include dirname(__FILE__) . "/../app/app.php";
$dbTwitter = $db->modul_twitter[WEB_ID];
$twitter_username = trim((string) $dbTwitter['twitter_username']);
if ($twitter_username == "") {
    exit;
}
require_once dirname(__FILE__) . '/twitter-php/twitter.class.php';
$twitter = new Twitter('2bAPmsWQsQENPUPsZkmkg', '6JmH47npRapf7Gy448eF3LLvFPYgN1cZf0S5cYA2Yw', '12213012-49ciz2RcpRpH0JOFECmYSFwpeYQcnt63Y6sAAj3zm', '8lfmu0WVmQSlwmMoNfNvDGV2ZRez6cbIXOF23pgNjS66q');
$statuses = $twitter->cachedRequest("statuses/user_timeline", array("screen_name" => $twitter_username));
// echo '<pre>';
// var_dump($statuses);
$jsonData = array();
$i = 0;
foreach ($statuses as $status) {
    $jsonData[$i] = array("date" => date("d.m.Y, H:i", strtotime($status->created_at)), "user_name" => htmlspecialchars($status->user->screen_name), "status" => str_replace("'", "&#39;", Twitter::clickable($status)), "user_profile_image" => $status->user->profile_image_url, "tweet_url" => 'https://twitter.com/' . $twitter_username . '/status/' . $status->id_str);
    $i++;
}
// print_r($jsonData);
$dbTwitter->update(array("data_json" => json_encode($jsonData)));
Ejemplo n.º 5
0
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Twitter search demo</title>

<ul>
<?php 
foreach ($results as $result) {
    ?>
	<li><a href="http://twitter.com/<?php 
    echo $result->from_user;
    ?>
"><img src="<?php 
    echo htmlspecialchars($result->profile_image_url);
    ?>
" width="48">
		<?php 
    echo htmlspecialchars($result->from_user);
    ?>
</a>:
		<?php 
    echo Twitter::clickable($result->text);
    ?>
		<small>at <?php 
    echo date("j.n.Y H:i", strtotime($result->created_at));
    ?>
</small>
	</li>
<?php 
}
?>
</ul>
Ejemplo n.º 6
0
require_once __DIR__ . '/../cockpit/bootstrap.php';
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/functions.php';
$app = new Silex\Application();
$app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), unserialize(TWIG_CONFIG));
$app['twig'] = $app->share($app->extend('twig', function (Twig_Environment $twig, Silex\Application $app) {
    $twig->addGlobal('globals', unserialize(TWIG_GLOBALS));
    $filter = new Twig_SimpleFilter('form', function ($string) {
        return form($string);
    });
    $twig->addFilter($filter);
    $click = new Twig_SimpleFilter('clickable', function ($string) {
        return Twitter::clickable($string);
    });
    $twig->addFilter($click);
    $markdown = new Twig_SimpleFilter('md', function ($string) {
        return cockpit("cockpit")->markdown($string);
    });
    $twig->addFilter($markdown);
    $thumb = new Twig_SimpleFilter('thumb', function ($string) {
        return cockpit("mediamanager")->thumbnail($string, "300", "100");
    });
    $twig->addFilter($thumb);
    $crop = new Twig_SimpleFilter('crop', function ($string, $size) {
        $par = explode(",", $size);
        return cockpit("mediamanager")->thumbnail($string, $par[0], $par[1]);
    });
    $twig->addFilter($crop);
Ejemplo n.º 7
0
        return $presenter->redirectUrl($lang);
    }
    // create template
    $template = $presenter->createTemplate()->setFile(__DIR__ . '/app/' . $lang . '.latte');
    // register template helpers like {$foo|date}
    $template->registerHelper('date', function ($date) use($lang) {
        if ($lang === 'en') {
            return date('F j, Y', (int) $date);
        } else {
            static $months = array(1 => 'leden', 'únor', 'březen', 'duben', 'květen', 'červen', 'červenec', 'srpen', 'září', 'říjen', 'listopad', 'prosinec');
            $date = getdate((int) $date);
            return "{$date['mday']}. {$months[$date['mon']]} {$date['year']}";
        }
    });
    $template->registerHelper('tweet', function ($s) {
        return Twitter::clickable($s);
    });
    $template->registerHelper('rss', function ($path) {
        return Feed::loadRss($path);
    });
    $template->registerHelper('texy', array(new Texy(), 'process'));
    return $template;
});
// http://davidgrudl.com/sources
$container->router[] = new Route('sources', function ($presenter) {
    $template = $presenter->createTemplate()->setFile(__DIR__ . '/app/sources.latte');
    $template->registerHelper('source', function ($file, $lang = NULL) {
        return preg_replace('#<br ?/?>#', '', highlight_file($file, TRUE));
    });
    return $template;
});
Ejemplo n.º 8
0
function twitter()
{
	header('Content-type: text/html; charset=utf-8');

	require_once(ROOT . 'interfase/twitter.php');

	$a = decode_ht('.htsa');

	foreach ($a as $i => $row) {
		$a[$i] = _decode($row);
	}

	$twitter = new Twitter($a[0], $a[1], $a[2], $a[3]);
	$channel = $twitter->load(Twitter::ME, 10);

	foreach ($channel->status as $status) {
		$in_reply = (int) $status->in_reply_to_user_id;

		if ($in_reply) {
			continue;
		}

		$sql = 'SELECT tw_status
			FROM _twitter
			WHERE tw_status = ?';


		// Mon Aug 22 03:31:16 +0000 2011
		$created_at = $status->created_at;
		$format = 'D M d H:i:s P Y';

		$at = date_parse_from_format($format, $created_at);

		/*
		 * int gmmktime ([ int $hour = gmdate("H") [, int $minute = gmdate("i") [, int $second = gmdate("s") [, i
		 * nt $month = gmdate("n") [, int $day = gmdate("j") [, int $year = gmdate("Y") [, int $is_dst = -1 ]]]]]]] )
		 * */

		$created_date = gmmktime($at['hour'], $at['minute'], $at['second'], $at['month'], $at['day'], $at['year']);
		$message = htmlentities(Twitter::clickable($status->text), ENT_NOQUOTES, 'UTF-8');
		$message = str_replace(array('&lt;', '&gt;'), array('<', '>'), $message);

		$sql_insert = array(
			'status' => (string) $status->id,
			'time' => $created_date,
			'message' => $message,
			'name' => (string) $status->user->screen_name,
			'followers' => (int) $status->user->followers_count,
			'friends' => (int) $status->user->friends_count
		);

		echo '<pre>';
		print_r($sql_insert);
		echo '</pre>';
		//exit;

		// id created_at text

		//echo $status->created_at . '<br /><br />';
		//echo  . '<br /><br />';
	}

	/*
	 * <li><a href="http://twitter.com/<?php echo $status->user->screen_name ?>"><img src="<?php echo htmlspecialchars($status->user->profile_image_url) ?>">
			<?php echo htmlspecialchars($status->user->name) ?></a>:
			<?php echo Twitter::clickable($status->text) ?>
			<small>at <?php echo date("j.n.Y H:i", strtotime($status->created_at)) ?></small>
		</li>
	 * */
}