本文整理汇总了PHP中linkify函数的典型用法代码示例。如果您正苦于以下问题:PHP linkify函数的具体用法?PHP linkify怎么用?PHP linkify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了linkify函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _linkify_html_callback
function _linkify_html_callback($matches)
{
if (isset($matches[2])) {
return $matches[2];
}
return linkify($matches[1]);
}
示例2: __get
function __get($k)
{
if ($k == 'editKey') {
return substr($this->auth, 20, 10);
} else {
if ($k == 'stale') {
$cutoff = time() - 365 * (24 * 60 * 60);
$stamp = strtotime($this->updated);
return $stamp < $cutoff;
} else {
if ($k == 'descriptionHtml') {
return hashlinks(linkify(htmlify($this->description)));
} else {
if ($k == 'descriptionSummary') {
return htmlify(substr_replace($this->description, ' ...', 140), false);
} else {
if ($k == 'rssDate') {
// TODO: Is there a better way to handle the timezone? Mysql times are
// GMT and have to be parsed as such.
$oldtz = date_default_timezone_get();
date_default_timezone_set('GMT');
return date('D, d M Y H:i:s T', strtotime($this->updated));
date_default_timezone_set($oldtz);
}
}
}
}
}
return parent::__get($k);
}
示例3: twitter_generate_output
function twitter_generate_output($user, $number, $callback = '', $step_callback = '', $before = false, $after = false)
{
$tweets = twitter_get_tweets($user);
if (is_null($tweets)) {
return 'Twitter is not configured.';
}
$number = min(20, $number);
$tweets = array_slice($tweets, 0, $number);
if (!empty($callback)) {
return call_user_func($callback, $tweets);
}
$output = $before === false ? '<div class="tt_twitter"><ul class="twitter">' : $before;
$time = time();
$last = count($tweets) - 1;
foreach ($tweets as $i => $tweet) {
$date = $tweet->created_at;
$date = date_parse($date);
$date = mktime(0, 0, 0, $date['month'], $date['day'], $date['year']);
$date = $time - $date;
$seconds = (int) $date;
$date = floor($date / 60);
$minutes = (int) $date;
if ($minutes) {
$date = floor($date / 60);
$hours = (int) $date;
if ($hours) {
$date = floor($date / 24);
$days = (int) $date;
if ($days) {
$date = floor($date / 7);
$weeks = (int) $date;
if ($weeks) {
$date = $weeks . ' week' . (1 === $weeks ? '' : 's') . ' ago';
} else {
$date = $days . ' day' . (1 === $days ? '' : 's') . ' ago';
}
} else {
$date = $hours . ' hour' . (1 === $hours ? '' : 's') . ' ago';
}
} else {
$date = $minutes . ' minute' . (1 === $minutes ? '' : 's') . ' ago';
}
} else {
$date = 'less than a minute ago';
}
$output .= $step_callback === '' ? '<li' . ($i === $last ? ' class="last"' : '') . '>' . linkify($tweet->text) . '<span class="date">' . $date . '</span>' . '</li>' : call_user_func($step_callback, $i, linkify($tweet->text), $date);
}
$output .= $after === false ? '</ul></div>' : $after;
return $output;
}
示例4: get_program_list_from_gdoc
function get_program_list_from_gdoc($source_url)
{
$handle = @fopen($source_url, 'r');
if (!$handle) {
return FALSE;
// failed
}
$program_list = array();
while (($PROG = fgetcsv($handle)) !== FALSE) {
$program = make_program($PROG);
if (!validate_program_data($program)) {
continue;
}
// use strtotime to convert to unix timestamp.
$program['from'] = strtotime($program['from']);
$program['to'] = strtotime($program['to']);
// empty string or NULL will get 0
$program['room'] = intval($program['room']);
$program['type'] = intval($program['type']);
$program['community'] = intval($program['community']);
if (isset($program['bio'])) {
$program['bio'] = Markdown_Without_Markup(linkify($program['bio']));
}
if (isset($program['abstract'])) {
$program['abstract'] = Markdown_Without_Markup(linkify($program['abstract']));
}
if (isset($program['youtube'])) {
$videos = array();
foreach (explode("\n", $program['youtube']) as $url) {
if (trim($url)) {
$videos[] = preg_replace('/^.+v=([^"&?\\/ ]{11}).*$/', '$1', trim($url));
// only get the ID
}
}
$program['youtube'] = $videos;
}
// setting room = -1 and leaving speaker empty indicate a break session
$program['isBreak'] = $program['room'] < 0 && !isset($program['speaker']) ? true : false;
$program_list[] = $program;
}
fclose($handle);
return $program_list;
}
示例5: wk_twitter_update
/**
* Fetches twitter messages
*
* @return The twitter messages
* @param string $username
* @param int $messages[optional]
*/
function wk_twitter_update($username, $messages = 1)
{
//the link to fetch
$link = 'http://search.twitter.com/search.rss?q=from:' . $username . '&rpp=' . $messages;
$data = fetch_page($link);
//include necessary files
include_once 'linkify.php';
//find twit
$twitExtract = "/(?<=<title>).*(?=<\\/title>)/i";
preg_match_all($twitExtract, $data, $twits, PREG_SET_ORDER);
for ($i = 0; $i < $messages; $i++) {
//save twits and linkify
$mytwits[$i] = linkify($twits[$i + 1][0]);
}
//find time
$timeExtract = "/(?<=<pubDate>).*(?=<\\/pubDate>)/i";
preg_match_all($timeExtract, $data, $times, PREG_SET_ORDER);
for ($i = 0; $i < $messages; $i++) {
//save times
$mytimes[$i] = $times[$i + 1][0];
}
//
if ($mytwits[0] != '') {
//add option to db, if it exists, it does nothing
add_option('wk_twitter', '');
$alltwits = '';
$alltimes = '';
for ($i = 0; $i < $messages; $i++) {
$alltwits .= $mytwits[$i];
$alltimes .= $mytimes[$i];
//if not last twit and time, add the seperator
if ($i + 1 != $messages) {
$alltwits .= '|';
$alltimes .= '|';
}
}
$mytime = date('G') * 60 + date('i');
update_option('wk_twitter', $mytime . '~' . $alltwits . '~' . $alltimes);
}
}
示例6: get_sponsors_list_from_gdoc
function get_sponsors_list_from_gdoc($source_url)
{
$handle = @fopen($source_url, 'r');
if (!$handle) {
return FALSE;
// failed
}
$SPONS = array();
// name, level, url, logoUrl, desc, enName, enDesc, zhCnName, zhCnDesc
while (($SPON = fgetcsv($handle)) !== FALSE) {
$sponsor = make_sponsor($SPON);
if (!validate_sponsor_data($sponsor)) {
continue;
}
$level = strtolower($sponsor['level']);
if (!isset($SPONS[$level])) {
$SPONS[$level] = array();
}
// Create JSON object
$SPON_obj = array('name' => array('zh-tw' => $sponsor['name']), 'desc' => array('zh-tw' => Markdown_Without_Markup($sponsor['desc'])), 'url' => $sponsor['url'], 'logoUrl' => MARKSITE_ABSOLUTE_PATH . SPONSOR_LOGO_RELATIVE_PATH . $sponsor['logoUrl']);
if ($sponsor['enName']) {
$SPON_obj['name']['en'] = $sponsor['enName'];
}
if ($sponsor['enDesc']) {
$SPON_obj['desc']['en'] = Markdown_Without_Markup($sponsor['enDesc']);
}
if ($sponsor['zhCnName']) {
$SPON_obj['name']['zh-cn'] = $sponsor['zhCnName'];
}
if ($sponsor['zhCnDesc']) {
$SPON_obj['desc']['zh-cn'] = Markdown_Without_Markup(linkify($sponsor['zhCnDesc']));
}
array_push($SPONS[$level], $SPON_obj);
}
fclose($handle);
return $SPONS;
}
示例7: get_the_tweets
function get_the_tweets($user = 'IARDNews', $count = 1)
{
$consumerkey = 'MrdVKnm7tucOHuCoyZgqRt4lN';
$consumersecret = '0Wi6rdalvoHTCAlmwhKjPr3fUWwACvehu8tgXR3jOS59ZUyv64';
$accesstoken = '942820224-8du6x1ncSvpFeTft6hvFfNxTRfpDssutBXHg6Xaj';
$accesstokensecret = '7LJBQKyYkGUyzQwwc9UeIM8Lxz4ZwsIRQLysQeqaKtCqP';
$connection = new TwitterOAuth($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);
$tweets = $connection->get("statuses/user_timeline", array("screen_name" => $user, "count" => $count, "exclude_replies" => true));
if ($tweets) {
foreach ($tweets as $tweet) {
$name = $tweet->user->screen_name;
$text = linkify($tweet->text);
$time = _time_ago($tweet->created_at);
$link = 'https://twitter.com/' . $name;
$output = '<div class="inner">
<i class="fa fa-twitter"></i>
<div class="name">@' . $name . '</div>
<div class="tweet">' . $text . ' <span class="timeago">• ' . $time . '</span></div>
<a href="' . $link . '" target="_blank" class="btn btn-follow-us">follow us</a>
</div>';
}
}
return $output;
}
示例8: validateInput
}
echo '<form method="post" action="submit_task.php' . $crisisFilterString . '" onsubmit="return validateInput()">';
$userID = getUserID();
$crisisID = null;
if (isset($_GET["crisisid"])) {
$crisisID = intval($_GET["crisisid"]);
}
$task = getTask($crisisID, $userID);
if (is_null($task)) {
echo '<div class="panel"><h2>Thank you</h2><div class="subpanel">There are no more documents to label. Please check back later.</div></div>';
} else {
echo '<h2>Document</h2>';
echo '<div id="document" class="panel text">';
echo '<input type="hidden" name="crisisID" value="' . $crisisID . '" />';
echo '<input type="hidden" name="documentID" value="' . $task->documentID . '" />';
echo "<div class=\"subpanel\">" . linkify($task->getText()) . "</div>";
echo '</div>';
echo '<h2>Labels</h2>';
echo '<div id="options" class="panel">';
foreach ($task->attributeInfo as $attribute) {
$attributeID = $attribute->{'id'};
$attributeName = $attribute->{'name'};
$labels = $attribute->{'labels'};
echo '<div class="subpanel label-list">';
echo "<h3>{$attributeName}</h3>";
echo '<div><ul>';
$dontknowID = $attributeID . "_" . $dontknow;
foreach ($labels as $label) {
$id = $attributeID . '_' . $label->{'id'};
echo '<li><input type="radio" name="attribute_' . $attributeID . '" value="' . $label->{'id'} . '" id="' . $id . '" />';
echo '<label for="' . $id . '" title="' . $label->{'description'} . '">' . $label->{'name'} . '</label></li>';
示例9: toArray
public function toArray()
{
$array = parent::toArray();
// small modifications
$array["unixtime"] = strtotime($array["created_at"]);
$array["edited"] = strtotime($array["updated_at"]);
$array["timeago"] = time_ago($array["created_at"]);
$array["time"] = modding_link(rtrim($array["time"]));
$array["text"] = linkify(modding_link($array["text"]));
$array["icon"] = $array["is_resolved"] ? $this->icons["resolved"] : (@$this->icons[$array["type"]] ?: "");
// renames
$array["id"] = $array["item_id"];
$array["beatmap"] = $array["beatmap_id"];
$array["resolved"] = $array["is_resolved"];
// unsets
unset($array["item_id"]);
unset($array["beatmapset_id"]);
unset($array["beatmap_id"]);
unset($array["is_resolved"]);
unset($array["created_at"]);
unset($array["updated_at"]);
if (!$array["deleted_at"]) {
unset($array["deleted_at"]);
}
return $array;
}
示例10: foreach
<?php
foreach ($contents as $line) {
$line = htmlentities($line);
$proto = trim(substr($line, 0, strpos($line, ':')));
$target = between($line, ' : ', ' ->');
switch ($proto) {
case 'SNMP':
$user = 'N/A';
$password = padpw(between($line, '-> COMMUNITY:', 'INFO:'));
$info = between($line, 'INFO:', false);
PrintCapItem($proto, $target, $user, $password, $info);
break;
case 'HTTP':
$user = between($line, 'USER:', 'PASS:');
$password = padpw(between($line, 'PASS: ', ' INFO:'));
$info = linkify(between($line, 'INFO:', false));
PrintCapItem($proto, $target, $user, $password, $info);
break;
case 'TELNET':
$user = between($line, 'USER:', 'PASS:');
$password = padpw(between($line, 'PASS:', false));
PrintCapItem($proto, $target, $user, $password);
break;
case 'POP':
$user = between($line, 'USER:', 'PASS:');
$password = padpw(between($line, 'PASS:', false));
PrintCapItem($proto, $target, $user, $password);
break;
case 'FTP':
$user = between($line, 'USER:', 'PASS:');
$password = padpw(between($line, 'PASS:', false));
示例11: broadcastWith
/**
* @return array
*/
public function broadcastWith()
{
return ['shout' => ['message' => nl2br(linkify(htmlentities($this->shout->shout))), 'username' => $this->user->username, 'id' => $this->user->id, 'name' => htmlentities($this->user->displayName()), 'admin' => $this->user->isAdmin(), 'profile_pic' => $this->user->getGravatarLink(40), 'created_at' => $this->shout->created_at->diffForHumans()]];
}
示例12: foreach
?>
" title="Subscribe to <?php
echo SITE_TITLE;
?>
via RSS"><img src="themes/mellow/i/rss.png" alt="Feed Icon"></a></div>
<ul id="updatelist">
<?php
$i = 0;
foreach ($tweets as $tweet) {
$tweet->tagify();
$cleantext = $tweet->message;
//$tweet->clean();
echo "<li id=\"tweet-" . $tweet->id . "\" class=\"tweet" . ($i % 2 == 0 ? " altrow" : "") . "\">\n";
echo "<div class=\"userpic\"><a href=\"http://twitter.com/" . $tweet->screen_name . "\"><img src=\"" . $tweet->userpic . "\" alt=\"\" /></a></div>\n";
echo "<div class=\"tweet-meta\"><a href=\"http://twitter.com/" . $tweet->screen_name . "\">" . $tweet->name . "</a> " . relativeTime(strtotime($tweet->published)) . "</div>";
echo "<div class=\"tweet-body\">" . linkify($cleantext) . ' <a href="' . $tweet->permalink() . '" class="permalink">∞</a></div>';
echo "</li>\n";
$i++;
}
?>
</ul>
<?php
if ($tweets) {
echo Paginator::paginate($offset, Tweet::count($tag), PAGE_LIMIT, "index.php?" . ($tag ? 'tag=' . urlencode($tag) . '&' : '') . "offset=");
} else {
echo "<div class=\"tweetless\">\n";
echo "No tweets.\n";
echo "</div>\n";
}
?>
</div>
示例13: formatText
function formatText($text)
{
return "<tt>" . linkify(str_replace("\n", "<br>\n", ereg_replace("^ ", " ", str_replace("\n ", "\n ", preg_replace("/( *) /e", "str_replace(' ',' ','\\1').' '", htmlentities($text)))))) . "</tt>";
}
示例14: get
//.........这里部分代码省略.........
}
$age = '';
if (strlen($rr['birthday'])) {
if (($years = age($rr['birthday'], 'UTC', '')) != 0) {
$age = $years;
}
}
$page_type = '';
if ($rr['total_ratings']) {
$total_ratings = sprintf(tt("%d rating", "%d ratings", $rr['total_ratings']), $rr['total_ratings']);
} else {
$total_ratings = '';
}
$profile = $rr;
if (x($profile, 'locale') == 1 || x($profile, 'region') == 1 || x($profile, 'postcode') == 1 || x($profile, 'country') == 1) {
$gender = x($profile, 'gender') == 1 ? t('Gender: ') . $profile['gender'] : False;
}
$marital = x($profile, 'marital') == 1 ? t('Status: ') . $profile['marital'] : False;
$homepage = x($profile, 'homepage') == 1 ? t('Homepage: ') : False;
$homepageurl = x($profile, 'homepage') == 1 ? $profile['homepage'] : '';
$hometown = x($profile, 'hometown') == 1 ? $profile['hometown'] : False;
$about = x($profile, 'about') == 1 ? bbcode($profile['about']) : False;
$keywords = x($profile, 'keywords') ? $profile['keywords'] : '';
$out = '';
if ($keywords) {
$keywords = str_replace(',', ' ', $keywords);
$keywords = str_replace(' ', ' ', $keywords);
$karr = explode(' ', $keywords);
if ($karr) {
if (local_channel()) {
$r = q("select keywords from profile where uid = %d and is_default = 1 limit 1", intval(local_channel()));
if ($r) {
$keywords = str_replace(',', ' ', $r[0]['keywords']);
$keywords = str_replace(' ', ' ', $keywords);
$marr = explode(' ', $keywords);
}
}
foreach ($karr as $k) {
if (strlen($out)) {
$out .= ', ';
}
if ($marr && in_arrayi($k, $marr)) {
$out .= '<strong>' . $k . '</strong>';
} else {
$out .= $k;
}
}
}
}
$entry = array('id' => ++$t, 'profile_link' => $profile_link, 'public_forum' => $rr['public_forum'], 'photo' => $rr['photo'], 'hash' => $rr['hash'], 'alttext' => $rr['name'] . (local_channel() || remote_channel() ? ' ' . $rr['address'] : ''), 'name' => $rr['name'], 'age' => $age, 'age_label' => t('Age:'), 'profile' => $profile, 'address' => $rr['address'], 'nickname' => substr($rr['address'], 0, strpos($rr['address'], '@')), 'location' => $location, 'location_label' => t('Location:'), 'gender' => $gender, 'total_ratings' => $total_ratings, 'viewrate' => true, 'canrate' => local_channel() ? true : false, 'pdesc' => $pdesc, 'pdesc_label' => t('Description:'), 'marital' => $marital, 'homepage' => $homepage, 'homepageurl' => linkify($homepageurl), 'hometown' => $hometown, 'hometown_label' => t('Hometown:'), 'about' => $about, 'about_label' => t('About:'), 'conn_label' => t('Connect'), 'forum_label' => t('Public Forum:'), 'connect' => $connect_link, 'online' => $online, 'kw' => $out ? t('Keywords: ') : '', 'keywords' => $out, 'ignlink' => $suggest ? z_root() . '/directory?ignore=' . $rr['hash'] : '', 'ignore_label' => t('Don\'t suggest'), 'common_friends' => $common[$rr['address']] ? intval($common[$rr['address']]) : '', 'common_label' => t('Common connections:'), 'common_count' => intval($common[$rr['address']]), 'safe' => $safe_mode);
$arr = array('contact' => $rr, 'entry' => $entry);
call_hooks('directory_item', $arr);
unset($profile);
unset($location);
if (!$arr['entry']) {
continue;
}
if ($sort_order == '' && $suggest) {
$entries[$addresses[$rr['address']]] = $arr['entry'];
// Use the same indexes as originally to get the best suggestion first
} else {
$entries[] = $arr['entry'];
}
}
ksort($entries);
// Sort array by key so that foreach-constructs work as expected
if ($j['keywords']) {
\App::$data['directory_keywords'] = $j['keywords'];
}
logger('mod_directory: entries: ' . print_r($entries, true), LOGGER_DATA);
if ($_REQUEST['aj']) {
if ($entries) {
$o = replace_macros(get_markup_template('directajax.tpl'), array('$entries' => $entries));
} else {
$o = '<div id="content-complete"></div>';
}
echo $o;
killme();
} else {
$maxheight = 94;
$dirtitle = $globaldir ? t('Global Directory') : t('Local Directory');
$o .= "<script> var page_query = '" . $_GET['q'] . "'; var extra_args = '" . extra_query_args() . "' ; divmore_height = " . intval($maxheight) . "; </script>";
$o .= replace_macros($tpl, array('$search' => $search, '$desc' => t('Find'), '$finddsc' => t('Finding:'), '$safetxt' => htmlspecialchars($search, ENT_QUOTES, 'UTF-8'), '$entries' => $entries, '$dirlbl' => $suggest ? t('Channel Suggestions') : $dirtitle, '$submit' => t('Find'), '$next' => alt_pager($a, $j['records'], t('next page'), t('previous page')), '$sort' => t('Sort options'), '$normal' => t('Alphabetic'), '$reverse' => t('Reverse Alphabetic'), '$date' => t('Newest to Oldest'), '$reversedate' => t('Oldest to Newest'), '$suggest' => $suggest ? '&suggest=1' : ''));
}
} else {
if ($_REQUEST['aj']) {
$o = '<div id="content-complete"></div>';
echo $o;
killme();
}
if (\App::$pager['page'] == 1 && $j['records'] == 0 && strpos($search, '@')) {
goaway(z_root() . '/chanview/?f=&address=' . $search);
}
info(t("No entries (some entries may be hidden).") . EOL);
}
}
}
}
return $o;
}
示例15: file_get_contents
// Use the text file tweet_template.txt to construct each tweet in the list
$tweet_template = file_get_contents('tweet_template.txt', FILE_USE_INCLUDE_PATH);
$tweet_list = '';
$tweets_found = 0;
while (($row = mysqli_fetch_assoc($result)) && $tweets_found < TWEET_DISPLAY_COUNT) {
++$tweets_found;
// create a fresh copy of the empty template
$current_tweet = $tweet_template;
// Fill in the template with the current tweet
$current_tweet = str_replace('[profile_image_url]', $row['profile_image_url'], $current_tweet);
$current_tweet = str_replace('[created_at]', twitter_time($row['created_at']), $current_tweet);
$current_tweet = str_replace('[screen_name]', $row['screen_name'], $current_tweet);
$current_tweet = str_replace('[name]', $row['name'], $current_tweet);
$current_tweet = str_replace('[user_mention_title]', USER_MENTION_TITLE . ' ' . $row['screen_name'] . ' (' . $row['name'] . ')', $current_tweet);
$current_tweet = str_replace('[tweet_display_title]', TWEET_DISPLAY_TITLE, $current_tweet);
$current_tweet = str_replace('[tweet_text]', linkify($row['tweet_text']), $current_tweet);
// Include each tweet's id so site.js can request older or newer tweets
$current_tweet = str_replace('[tweet_id]', $row['tweet_id'], $current_tweet);
// Add this tweet to the list
$tweet_list .= $current_tweet;
}
if (!$tweets_found) {
if (isset($_GET['last'])) {
$tweet_list = '<strong>No more tweets found</strong><br />';
} else {
$tweet_list = '<strong>No tweets found</strong><br />';
}
}
if (isset($_GET['last'])) {
// Called by site.js with Ajax, so print HTML to the browser
print $tweet_list;