function parsetext($text) { $res = $text; // убираем переводы строк внутри тэгов do { $oldRes = $res; $res = preg_replace("/(<[^>]*)[\n\r]/m", '$1 ', $res); } while ($res != $oldRes); $res = auto_link_text($res); $res = strip_tags_attributes($res, array('<strike>', '<s>', '<sup>', '<sub>', '<embed>', '<object>', '<param>', '<p>', '<b>', '<i>', '<br>', '<br/>', '<a>', '<em>', '<font>', '<strong>', '<img>', '<img/>', '<small>', '<big>', '<div>', '<span>')); $res = closetags($res); $res = redirectExternalLinks($res); $res = nl2br($res); $res = str_replace(array("\n", "\r"), " ", $res); $res = trim($res); return $res; }
function replaceTextToLinks($text) { preg_match_all('|<pre>(.*)<\\/pre>|U', $text, $matches); $pre = array(); foreach ($matches[0] as $v) { $code_id = '<code' . mt_rand() . '>'; $pre[$code_id] = $v; $text = str_replace($v, $code_id, $text); } $text = str_replace('<a href', '<a target="_balnk" href', $text); $text = auto_link_text($text, 'urls', array('target' => '_blank'), true, 85); $text = preg_replace_callback('/<a(.*)>(.*)<\\/a>/', 'truncateLongLinks', $text); $text = preg_replace_callback('/<script(.*)>(.*)<\\/script>/si', 'convertJavascriptSpceialCharacters', $text); foreach ($pre as $code_id => $v) { $v = str_replace('<pre>', '<pre class="code" id="' . str_replace(array('<', '>'), '', $code_id) . '">', $v); $text = str_replace($code_id, $v, $text); } return $text; }
/** * * @return mixed s_id on success, false on failure */ public function update_supplier($s_id) { //parse for urls $this->load->helper('text_helper'); $description = auto_link_text($this->input->post('s_description')); if ($s_id) { $sql = 'UPDATE supplier SET s_name = ?, s_description = ? WHERE s_id = ?'; $sql_data = array($this->input->post('s_name'), $description, $s_id); } else { $sql = 'INSERT INTO supplier (s_name, s_description) VALUES (?, ?)'; $sql_data = array($this->input->post('s_name'), $description); } //run query $result = $this->db->query($sql, $sql_data); //all done if ($result && $s_id) { return $s_id; } else { if ($result) { return $this->db->insert_id(); } else { return false; } } }
<table style="border-bottom: 1px dotted #EEEEEE;"> <tr> <td style="padding: 0.5em; width: 40px;"> <?php echo user_pic($top_analyst, 'profile', array('width' => 40)); ?> </td> <td style="padding: 0.5em;"> <span class="text_big"><?php echo user_link($top_analyst); ?> </span> <br /> <span style="color: #666;"><?php echo $top_analyst->group_score; ?> points</span> </td> </tr> </table> <?php } ?> <?php end_slot(); ?> <?php echo auto_link_text(html_entity_decode($group->contest));
</a> <?php } else { ?> <?php echo $feedItem->getTitle(); ?> <?php } ?> </li> <?php $date = $feedItem->getPubDate(); ?> <?php if ($date) { ?> <li class="date"><?php echo $dateFormat ? date($dateFormat, $date) : aDate::pretty($date) . ' ' . aDate::time($date); ?> </li> <?php } ?> <li class="description"><?php echo auto_link_text(aHtml::simplify($feedItem->getDescription(), $markup, false, isset($attributes) ? $attributes : false, isset($styles) ? $styles : false)); ?> </li> </ul> </li>
'); return preg_replace_callback($pattern, $callback, $text); } $followers = $connection->get("https://api.twitter.com/1.1/followers/list.json?cursor=-1&screen_name=" . $twitteruser . "&count=48"); $followersHTML = ''; $tweetsHTML = ''; if (isset($followers->errors)) { echo "<div style='background: white;'>Please configure this module using CometChat Administration Panel.</div>"; exit; } else { foreach ($followers->users as $follower) { $followersHTML .= '<a target="_blank" href="http://www.twitter.com/' . $follower->screen_name . '"><img width=24 height=24 src="' . str_replace('normal', 'mini', $follower->profile_image_url) . '" alt="' . $follower->name . '" title="' . $follower->name . '"></a>'; } $tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $twitteruser . "&count=" . $notweets); foreach ($tweets as $tweet) { $tweetsHTML .= '<li class="tweet">' . auto_link_text($tweet->text) . '<br /><small class="chattime" timestamp="' . strtotime($tweet->created_at) . '"></small></li>'; } } $extrajs = ''; if ($sleekScroller == 1) { $extrajs = '<script>jqcc=jQuery;</script><script src="../../js.php?type=core&name=scroll"></script>'; } echo <<<EOD <!DOCTYPE html> <html> \t<head> \t\t<meta http-equiv="cache-control" content="no-cache"> \t\t<meta http-equiv="pragma" content="no-cache"> \t\t<meta http-equiv="expires" content="-1"> \t\t<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> \t\t<link type="text/css" rel="stylesheet" media="all" href="../../css.php?type=module&name=twitter" />
.appendTo('#video-<?php echo $testcase->getClassName(); ?> '); } }); <?php // Add assertions, failures and errors to stacktrace $stacktrace = 'Assertions: ' . $testcase->getNumberOfAssertions() . ' Failures: ' . $testcase->getNumberOfFailure() . ' Errors: ' . $testcase->getNumberOfErrors(); foreach ($testcase->getErrors() as $error) { $stackstring = htmlify($error->getContent()); $stacktrace = $stacktrace . '<br/>####################################################<br/>## <b>ERROR:</b> ' . $error->getType() . '<br/>####################################################<br/>' . auto_link_text($stackstring); } foreach ($testcase->getFailures() as $failure) { $stackstring = htmlify($failure->getContent()); $stacktrace = $stacktrace . '<br/>####################################################<br/>## <b>FAILURE:</b> ' . $failure->getType() . '<br/>####################################################<br/>' . auto_link_text($stackstring); } // Generate line numbers to use next to source code for easy to find failures and errors $linenumbers = ''; for ($i = 1; $i <= $testcase->getSourcecodeNumberOfLines(); $i++) { // Color red if there is an error on this line $screenshot = $testcase->getScreenshotOnLine($i); if ($testcase->lineHasError($i)) { $linenumbers .= '<font style="BACKGROUND-COLOR: red" color="white">'; if ($screenshot) { $linenumbers .= '<a class="single_image" rel="group-' . $testcase->getClassName() . '" href="' . $result->getTestsDirectoryRelative() . $screenshot . '">'; } $linenumbers .= $i; if ($screenshot) { $linenumbers .= '</a>'; }
<?php use_helper('Text', 'Date'); ?> <ul class="board_news"> <?php foreach ($arrFeeds as $item) { ?> <li><?php echo auto_link_text($item['title'], 'all', array('target' => '_blank')); ?> <div class="news_info"> <span class="date"><?php echo format_datetime($item['date'], 'f'); ?> </span> :: <span class="link"><a href="<?php echo $item['link']; ?> " target="_blank"><?php echo __('More'); ?> </a></span> </div> </li> <?php } ?> </ul>
<?php use_helper('Text'); ?> <?php slot('header_text', $group['display_name']); slot('header_link', sfGuardGroupTable::getInternalUrl($group)); slot("header_subtext", auto_link_text(html_entity_decode($group->blurb))); ?> <?php if ($sf_user->isAuthenticated()) { if (!isset($hide_actions) || !$hide_actions) { ?> <?php slot('header_actions', array('edit' => array('url' => $group->getInternalUrl('edit'), 'condition' => $sf_user->hasCredential('admin') || $sf_user->getGuardUser()->isGroupOwner($group->name)), 'leave group' => array('url' => $group->getInternalUrl('leave'), 'condition' => $sf_user->hasGroup($group->name), 'options' => 'post=true confirm=Are you sure you want to leave this group?'), 'join group' => array('url' => $group->getInternalUrl('join'), 'condition' => !$sf_user->hasGroup($group->name), 'options' => 'post=true'))); } }
?> <h2><?php echo __('Contacts'); ?> :</h2> <p> <dl> <?php foreach ($coms as $com) { ?> <dt><?php echo $com->getCommType(); ?> <dt> <dd><?php echo auto_link_text($com->getEntry()); ?> </dd> <?php } ?> </dl> </p> <?php } ?> <?php if (isset($staff) && $staff) { ?> <h2><?php
<?php use_helper('Text'); foreach ($Comments as $comment) { ?> <fieldset class="opened view_mode"><legend class="view_mode"><b><?php echo __('Notion'); ?> </b> : <?php echo __($comment->getNotionText()); ?> </legend> <?php echo auto_link_text(nl2br($comment->getComment())); ?> </fieldset> <?php } ?>
$vPos = strpos($source, "vine"); $type = 'twitter'; $typePretty = 'Twitter'; $urls = $item->entities->urls; $defaultImage = 'img/default_twitter.png'; $icon = NULL; foreach ($urls as $url) { if (strpos($url->expanded_url, 'vine') !== false) { $profileUrl = NULL; $icon = 'img/icon_vine.png'; $defaultImage = 'img/default_vine.png'; $typePretty = 'Vine'; $type = 'vine'; $link = $url->expanded_url; continue; } } if (isset($item->retweeted_status)) { $rtUser = $item->retweeted_status->user->screen_name; $title = 'RT @' . $rtUser . ': ' . auto_link_text($item->retweeted_status->text); } else { $title = auto_link_text($item->text); } $node = array('id' => $item->id, 'title' => $title, 'image' => $defaultImage, 'copy' => NULL, 'link_copy' => 'View video', 'link' => $link, 'type_pretty' => $typePretty, 'type' => $type, 'icon' => $icon, 'meta' => NULL, 'feed' => NULL, 'epoch' => strtotime($item->created_at), 'profile_url' => $profileUrl); array_push($data, $node); } if (isset($_GET['raw']) && $_GET['raw'] == '1') { echo json_encode($info); } else { echo json_encode($data); }
$t->is(simple_format_text("1\n2\n3"), "<p>1\n<br />2\n<br />3</p>", 'text_simple_format() Ticket #6824'); // text_strip_links() $t->diag('text_strip_links()'); $t->is(strip_links_text("<a href='almost'>on my mind</a>"), "on my mind", 'text_strip_links() strips all links in input'); $t->is(strip_links_text('<a href="first.html">first</a> and <a href="second.html">second</a>'), "first and second", 'text_strip_links() strips all links in input'); // auto_link_text() $t->diag('auto_link_text()'); $email_raw = '*****@*****.**'; $email_result = '<a href="mailto:' . $email_raw . '">' . $email_raw . '</a>'; $link_raw = 'http://www.google.com'; $link_result = '<a href="' . $link_raw . '">' . $link_raw . '</a>'; $link2_raw = 'www.google.com'; $link2_result = '<a href="http://' . $link2_raw . '">' . $link2_raw . '</a>'; $t->is(auto_link_text('hello ' . $email_raw, 'email_addresses'), 'hello ' . $email_result, 'auto_link_text() converts emails to links'); $t->is(auto_link_text('Go to ' . $link_raw, 'urls'), 'Go to ' . $link_result, 'auto_link_text() converts absolute URLs to links'); $t->is(auto_link_text('Go to ' . $link_raw, 'email_addresses'), 'Go to ' . $link_raw, 'auto_link_text() takes a second parameter'); $t->is(auto_link_text('Go to ' . $link_raw . ' and say hello to ' . $email_raw), 'Go to ' . $link_result . ' and say hello to ' . $email_result, 'auto_link_text() converts emails and URLs if no second argument is given'); $t->is(auto_link_text('<p>Link ' . $link_raw . '</p>'), '<p>Link ' . $link_result . '</p>', 'auto_link_text() converts URLs to links'); $t->is(auto_link_text('<p>' . $link_raw . ' Link</p>'), '<p>' . $link_result . ' Link</p>', 'auto_link_text() converts URLs to links'); $t->is(auto_link_text('Go to ' . $link2_raw, 'urls'), 'Go to ' . $link2_result, 'auto_link_text() converts URLs to links even if link does not start with http://'); $t->is(auto_link_text('Go to ' . $link2_raw, 'email_addresses'), 'Go to ' . $link2_raw, 'auto_link_text() converts URLs to links'); $t->is(auto_link_text('<p>Link ' . $link2_raw . '</p>'), '<p>Link ' . $link2_result . '</p>', 'auto_link_text() converts URLs to links'); $t->is(auto_link_text('<p>' . $link2_raw . ' Link</p>'), '<p>' . $link2_result . ' Link</p>', 'auto_link_text() converts URLs to links'); $t->is(auto_link_text('<p>http://www.google.com/?q=symfony Link</p>'), '<p><a href="http://www.google.com/?q=symfony">http://www.google.com/?q=symfony</a> Link</p>', 'auto_link_text() converts URLs to links'); $t->is(auto_link_text('<p>http://www.google.com/?q=symfony+link</p>', 'all', array(), true), '<p><a href="http://www.google.com/?q=symfony+link">http://www.google.com/?q=symfony+li...</a></p>', 'auto_link_text() truncates URLs in links'); $t->is(auto_link_text('<p>http://www.google.com/?q=symfony+link</p>', 'all', array(), true, 32, '***'), '<p><a href="http://www.google.com/?q=symfony+link">http://www.google.com/?q=symfony***</a></p>', 'auto_link_text() takes truncation parameters'); $t->is(auto_link_text('<p>http://twitter.com/#!/fabpot</p>'), '<p><a href="http://twitter.com/#!/fabpot">http://twitter.com/#!/fabpot</a></p>', "auto_link_text() converts URLs with complex fragments to links"); $t->is(auto_link_text('<p>http://twitter.com/#!/fabpot is Fabien Potencier on Twitter</p>'), '<p><a href="http://twitter.com/#!/fabpot">http://twitter.com/#!/fabpot</a> is Fabien Potencier on Twitter</p>', "auto_link_text() converts URLs with complex fragments and trailing text to links"); $t->is(auto_link_text('hello ' . $email_result, 'email_addresses'), 'hello ' . $email_result, "auto_link_text() does not double-link emails"); $t->is(auto_link_text('<p>Link ' . $link_result . '</p>'), '<p>Link ' . $link_result . '</p>', "auto_link_text() does not double-link emails");
?> " target="_blank"> <?php echo image_tag_sf_image($image->getFile(), array('size' => '120x120')); ?> </a></li> <?php } ?> </ul> <?php } ?> <p class="text"> <?php echo auto_link_text(nl2br($message->getDecoratedMessageBody()), 'urls', array('target' => '_blank'), true, 57); ?> </p> </div> <?php /* @todo 添付ファイル ({if $c_message.filename && $smarty.const.OPENPNE_USE_FILEUPLOAD}) <div class="block attachFile"><ul> <li><a href="({t_url m=pc a=do_h_message_file_download})&target_c_message_id=({$c_message.c_message_id})&sessid=({$PHPSESSID})">({$c_message.original_filename})</a></li> </ul></div> ({/if}) */ ?> <div class="operation"> <ul class="moreInfo button">
function testdescriptionTxtFile($filename_txt) { $handle = fopen($filename_txt, "r"); // HTML-ify and get testdescription $testdescription = htmlify(fread($handle, filesize($filename_txt))); // Replace URLs with actual links $testdescription = auto_link_text($testdescription); fclose($handle); }
/** * Parse links in Activity Comments */ function filter_bp_get_activity_content_body($content) { return auto_link_text($content); }
</th> </tr> <?php $prevclass = ''; foreach ($result->getTests() as $testcase) { foreach (array_merge($testcase->getErrors(), $testcase->getFailures()) as $error) { // Replace newlines with <br/> $content = htmlify($error->getContent()); // Split up error info preg_match_all('#((\\w+)::test\\w+)(.+)#', $content, $matches, PREG_PATTERN_ORDER); $testclass_testname = $matches[1][0]; $testclass = $matches[2][0]; // Trim all <br />'s at start of string $rest_contents = preg_replace('#(?i)^(?:<br ?\\/>)*#', '', $matches[3][0]); // Make URLs clickable $rest_contents = auto_link_text($rest_contents); if ($testclass != $prevclass) { $prevclass = $testclass; ?> <tr> <td align="left" bgcolor="<?php echo $color['medium']; ?> "><?php echo $h2_; echo $testclass; ?> - Assertions: <?php echo $testcase->getNumberOfAssertions(); ?> Failures: <?php
<?php echo auto_link_text('http://example.com/');
<?php use_helper('Text', 'Date'); /* * A $commit is an array containing: http://develop.github.com/p/commits.html#listing_commits_on_a_branch */ echo _open('ul'); foreach ($commits as $commit) { echo _tag('li.clickable', _link($commit['url'])->text(auto_link_text(escape($commit['message'])))->set('.block') . _tag('span.quiet.little', format_date($commit['committed_date'], 'd/MM H:mm') . ' by ' . escape($commit['author']['name']))); } echo _close('ul');
<?php use_helper('Text'); /* * An $issue is an array containing: http://develop.github.com/p/issues.html#list_a_projects_issues */ echo _open('ul'); foreach ($issues as $issue) { // link to the issue page on github if ($state == 'open') { $issueLink = _link('http://github.com/' . $user . '/' . $repo . '/issues#issue/' . $issue['number']); } else { $issueLink = _link('http://github.com/' . $user . '/' . $repo . '/issues/' . $state . '#issue/' . $issue['number']); } $issueLink->text($issue['title'])->set('.issue_title'); echo _tag('li.clickable', $issueLink->text(auto_link_text(escape($issue['title'])))->set('.block') . _tag('span.quiet.little', format_date($issue['created_at'], 'd/MM H:mm') . ' by ' . _link('http://github.com/' . $issue['user'])->text(escape($issue['user']))) . _tag('p.issue_text', auto_link_text(escape($issue['body'])))); } echo _close('ul');
$t->is(wrap_text($line), "This is a very long line to be wrapped...\n", 'wrap_text() wraps long lines with a default of 80'); $t->is(wrap_text($line, 10), "This is a\nvery long\nline to be\nwrapped...\n", 'wrap_text() takes a line length as its second argument'); $t->is(wrap_text($line, 5), "This\nis a\nvery\nlong\nline\nto be\nwrapped...\n", 'wrap_text() takes a line length as its second argument'); // simple_format_text() $t->diag('simple_format_text()'); $t->is(simple_format_text("crazy\r\n cross\r platform linebreaks"), "<p>crazy\n<br /> cross\n<br /> platform linebreaks</p>", 'text_simple_format() replaces \\n by <br />'); $t->is(simple_format_text("A paragraph\n\nand another one!"), "<p>A paragraph</p>\n\n<p>and another one!</p>", 'text_simple_format() replaces \\n\\n by <p>'); $t->is(simple_format_text("A paragraph\n With a newline"), "<p>A paragraph\n<br /> With a newline</p>", 'text_simple_format() wrap all string with <p>'); // text_strip_links() $t->diag('text_strip_links()'); $t->is(strip_links_text("<a href='almost'>on my mind</a>"), "on my mind", 'text_strip_links() strips all links in input'); // auto_linking() $t->diag('auto_linking()'); $email_raw = '*****@*****.**'; $email_result = '<a href="mailto:' . $email_raw . '">' . $email_raw . '</a>'; $link_raw = 'http://www.google.com'; $link_result = '<a href="' . $link_raw . '">' . $link_raw . '</a>'; $link2_raw = 'www.google.com'; $link2_result = '<a href="http://' . $link2_raw . '">' . $link2_raw . '</a>'; $t->is(auto_link_text('hello ' . $email_raw, 'email_addresses'), 'hello ' . $email_result, 'auto_linking() converts emails to links'); $t->is(auto_link_text('Go to ' . $link_raw, 'urls'), 'Go to ' . $link_result, 'auto_linking() converts absolute URLs to links'); $t->is(auto_link_text('Go to ' . $link_raw, 'email_addresses'), 'Go to ' . $link_raw, 'auto_linking() takes a second parameter'); $t->is(auto_link_text('Go to ' . $link_raw . ' and say hello to ' . $email_raw), 'Go to ' . $link_result . ' and say hello to ' . $email_result, 'auto_linking() converts emails and URLs if no second argument is given'); $t->is(auto_link_text('<p>Link ' . $link_raw . '</p>'), '<p>Link ' . $link_result . '</p>', 'auto_linking() converts URLs to links'); $t->is(auto_link_text('<p>' . $link_raw . ' Link</p>'), '<p>' . $link_result . ' Link</p>', 'auto_linking() converts URLs to links'); $t->is(auto_link_text('Go to ' . $link2_raw, 'urls'), 'Go to ' . $link2_result, 'auto_linking() converts URLs to links even if link does not start with http://'); $t->is(auto_link_text('Go to ' . $link2_raw, 'email_addresses'), 'Go to ' . $link2_raw, 'auto_linking() converts URLs to links'); $t->is(auto_link_text('<p>Link ' . $link2_raw . '</p>'), '<p>Link ' . $link2_result . '</p>', 'auto_linking() converts URLs to links'); $t->is(auto_link_text('<p>' . $link2_raw . ' Link</p>'), '<p>' . $link2_result . ' Link</p>', 'auto_linking() converts URLs to links'); $t->is(auto_link_text('<p>http://www.google.com/?q=symfony Link</p>'), '<p><a href="http://www.google.com/?q=symfony">http://www.google.com/?q=symfony</a> Link</p>', 'auto_linking() converts URLs to links');
$t->is(simple_format_text("A paragraph\n\n\n\nand another one!"), "<p>A paragraph</p><p>and another one!</p>", 'text_simple_format() replaces \\n\\n\\n\\n by <p>'); $t->is(simple_format_text("A paragraph\n With a newline"), "<p>A paragraph\n<br /> With a newline</p>", 'text_simple_format() wrap all string with <p>'); $t->is(simple_format_text("1\n2\n3"), "<p>1\n<br />2\n<br />3</p>", 'text_simple_format() Ticket #6824'); // text_strip_links() $t->diag('text_strip_links()'); $t->is(strip_links_text("<a href='almost'>on my mind</a>"), "on my mind", 'text_strip_links() strips all links in input'); $t->is(strip_links_text('<a href="first.html">first</a> and <a href="second.html">second</a>'), "first and second", 'text_strip_links() strips all links in input'); // auto_link_text() $t->diag('auto_link_text()'); $email_raw = '*****@*****.**'; $email_result = '<a href="mailto:' . $email_raw . '">' . $email_raw . '</a>'; $link_raw = 'http://www.google.com'; $link_result = '<a href="' . $link_raw . '">' . $link_raw . '</a>'; $link2_raw = 'www.google.com'; $link2_result = '<a href="http://' . $link2_raw . '">' . $link2_raw . '</a>'; $t->is(auto_link_text('hello ' . $email_raw, 'email_addresses'), 'hello ' . $email_result, 'auto_link_text() converts emails to links'); $t->is(auto_link_text('Go to ' . $link_raw, 'urls'), 'Go to ' . $link_result, 'auto_link_text() converts absolute URLs to links'); $t->is(auto_link_text('Go to ' . $link_raw, 'email_addresses'), 'Go to ' . $link_raw, 'auto_link_text() takes a second parameter'); $t->is(auto_link_text('Go to ' . $link_raw . ' and say hello to ' . $email_raw), 'Go to ' . $link_result . ' and say hello to ' . $email_result, 'auto_link_text() converts emails and URLs if no second argument is given'); $t->is(auto_link_text('<p>Link ' . $link_raw . '</p>'), '<p>Link ' . $link_result . '</p>', 'auto_link_text() converts URLs to links'); $t->is(auto_link_text('<p>' . $link_raw . ' Link</p>'), '<p>' . $link_result . ' Link</p>', 'auto_link_text() converts URLs to links'); $t->is(auto_link_text('Go to ' . $link2_raw, 'urls'), 'Go to ' . $link2_result, 'auto_link_text() converts URLs to links even if link does not start with http://'); $t->is(auto_link_text('Go to ' . $link2_raw, 'email_addresses'), 'Go to ' . $link2_raw, 'auto_link_text() converts URLs to links'); $t->is(auto_link_text('<p>Link ' . $link2_raw . '</p>'), '<p>Link ' . $link2_result . '</p>', 'auto_link_text() converts URLs to links'); $t->is(auto_link_text('<p>' . $link2_raw . ' Link</p>'), '<p>' . $link2_result . ' Link</p>', 'auto_link_text() converts URLs to links'); $t->is(auto_link_text('<p>http://www.google.com/?q=symfony Link</p>'), '<p><a href="http://www.google.com/?q=symfony">http://www.google.com/?q=symfony</a> Link</p>', 'auto_link_text() converts URLs to links'); $t->is(auto_link_text('<p>http://www.google.com/?q=symfony+link</p>', 'all', array(), true), '<p><a href="http://www.google.com/?q=symfony+link">http://www.google.com/?q=symfony+li...</a></p>', 'auto_link_text() truncates URLs in links'); $t->is(auto_link_text('<p>http://www.google.com/?q=symfony+link</p>', 'all', array(), true, 32, '***'), '<p><a href="http://www.google.com/?q=symfony+link">http://www.google.com/?q=symfony***</a></p>', 'auto_link_text() takes truncation parameters'); $t->is(auto_link_text('<p>http://twitter.com/#!/fabpot</p>'), '<p><a href="http://twitter.com/#!/fabpot">http://twitter.com/#!/fabpot</a></p>', "auto_link_text() converts URLs with complex fragments to links"); $t->is(auto_link_text('<p>http://twitter.com/#!/fabpot is Fabien Potencier on Twitter</p>'), '<p><a href="http://twitter.com/#!/fabpot">http://twitter.com/#!/fabpot</a> is Fabien Potencier on Twitter</p>', "auto_link_text() converts URLs with complex fragments and trailing text to links");
/** * @see auto_link_text */ function op_auto_link_text($text, $link = 'urls', $href_options = array('target' => '_blank'), $truncate = true, $truncate_len = 57, $pad = '...') { use_helper('Text'); return auto_link_text($text, $link, $href_options, $truncate, $truncate_len, $pad); }
public function getSlotValue($slot, $settings) { return simple_format_text(auto_link_text(strip_tags($slot->getValue($settings['culture'])))); }
function render_value($value) { ProjectConfiguration::getActive()->loadHelpers('Text'); $value = auto_link_text($value); // Simple lists $value = preg_replace('/(?:^\\*.*\\r?\\n)*(?:^\\*.*)/m', "<ul>\n\$0\n</ul>", $value); $value = preg_replace('/(?:^-.*\\r?\\n)*(?:^-.*)/m', "<ul>\n\$0\n</ul>", $value); $value = preg_replace('/^(?:\\*|-)\\s*(.*)(?:\\r?\\n)?/m', '<li>$1</li>', $value); $value = preg_replace('/(?:\\r?\\n){2,}/', "</p><p>", $value, -1, $count); if (0 < $count) { $value = "<p>{$value}</p>"; } $value = preg_replace('/\\r?\\n/', '<br/>', $value); return $value; }
<?php use_helper('Date', 'Text'); ?> <?php slot('sidebar'); include_partial('menu', array('project' => $project)); end_slot(); ?> <h1><?php echo $announcement->getSubject(); ?> </h1> <p><?php echo auto_link_text(simple_format_text($announcement->getDetails())); ?> </p> Posted on <?php echo format_date($announcement->getCreatedAt());
public function getSlotValue($slot) { sfLoader::loadHelpers(array('Text', 'Tag')); return auto_link_text(strip_tags($slot->getValue())); }
/** * Just the basics: escape entities, turn URLs into links, and turn newlines into line breaks. * Also turn email addresses into links (we don't obfuscate them here as that makes them * harder to manipulate some more, but check out aHtml::obfuscateMailto). * * This function is now a wrapper around TextHelper, except for the entity escape which is * not included in simple_format_text for some reason * * @param string $text The text you want converted to basic HTML. * @return string Text with br tags and anchor tags. */ public static function textToHtml($text) { sfContext::getInstance()->getConfiguration()->loadHelpers(array('Tag', 'Text')); return auto_link_text(simple_format_text(htmlentities($text, ENT_COMPAT, 'UTF-8'))); }
$t->is(wrap_text($line, 5), "This\nis a\nvery\nlong\nline\nto be\nwrapped...\n", 'wrap_text() takes a line length as its second argument'); // simple_format_text() $t->diag('simple_format_text()'); $t->is(simple_format_text("crazy\r\n cross\r platform linebreaks"), "<p>crazy\n<br /> cross\n<br /> platform linebreaks</p>", 'text_simple_format() replaces \\n by <br />'); $t->is(simple_format_text("A paragraph\n\nand another one!"), "<p>A paragraph</p>\n\n<p>and another one!</p>", 'text_simple_format() replaces \\n\\n by <p>'); $t->is(simple_format_text("A paragraph\n With a newline"), "<p>A paragraph\n<br /> With a newline</p>", 'text_simple_format() wrap all string with <p>'); // text_strip_links() $t->diag('text_strip_links()'); $t->is(strip_links_text("<a href='almost'>on my mind</a>"), "on my mind", 'text_strip_links() strips all links in input'); // auto_link_text() $t->diag('auto_link_text()'); $email_raw = '*****@*****.**'; $email_result = '<a href="mailto:' . $email_raw . '">' . $email_raw . '</a>'; $link_raw = 'http://www.google.com'; $link_result = '<a href="' . $link_raw . '">' . $link_raw . '</a>'; $link2_raw = 'www.google.com'; $link2_result = '<a href="http://' . $link2_raw . '">' . $link2_raw . '</a>'; $t->is(auto_link_text('hello ' . $email_raw, 'email_addresses'), 'hello ' . $email_result, 'auto_link_text() converts emails to links'); $t->is(auto_link_text('Go to ' . $link_raw, 'urls'), 'Go to ' . $link_result, 'auto_link_text() converts absolute URLs to links'); $t->is(auto_link_text('Go to ' . $link_raw, 'email_addresses'), 'Go to ' . $link_raw, 'auto_link_text() takes a second parameter'); $t->is(auto_link_text('Go to ' . $link_raw . ' and say hello to ' . $email_raw), 'Go to ' . $link_result . ' and say hello to ' . $email_result, 'auto_link_text() converts emails and URLs if no second argument is given'); $t->is(auto_link_text('<p>Link ' . $link_raw . '</p>'), '<p>Link ' . $link_result . '</p>', 'auto_link_text() converts URLs to links'); $t->is(auto_link_text('<p>' . $link_raw . ' Link</p>'), '<p>' . $link_result . ' Link</p>', 'auto_link_text() converts URLs to links'); $t->is(auto_link_text('Go to ' . $link2_raw, 'urls'), 'Go to ' . $link2_result, 'auto_link_text() converts URLs to links even if link does not start with http://'); $t->is(auto_link_text('Go to ' . $link2_raw, 'email_addresses'), 'Go to ' . $link2_raw, 'auto_link_text() converts URLs to links'); $t->is(auto_link_text('<p>Link ' . $link2_raw . '</p>'), '<p>Link ' . $link2_result . '</p>', 'auto_link_text() converts URLs to links'); $t->is(auto_link_text('<p>' . $link2_raw . ' Link</p>'), '<p>' . $link2_result . ' Link</p>', 'auto_link_text() converts URLs to links'); $t->is(auto_link_text('<p>http://www.google.com/?q=symfony Link</p>'), '<p><a href="http://www.google.com/?q=symfony">http://www.google.com/?q=symfony</a> Link</p>', 'auto_link_text() converts URLs to links'); $t->is(auto_link_text('<p>http://www.google.com/?q=symfony+link</p>', 'all', array(), true), '<p><a href="http://www.google.com/?q=symfony+link">http://www.google.com/?q=symfony+li...</a></p>', 'auto_link_text() truncates URLs in links'); $t->is(auto_link_text('<p>http://www.google.com/?q=symfony+link</p>', 'all', array(), true, 32, '***'), '<p><a href="http://www.google.com/?q=symfony+link">http://www.google.com/?q=symfony***</a></p>', 'auto_link_text() takes truncation parameters');
'); return preg_replace_callback($pattern, $callback, $text); } $followers = $connection->get("https://api.twitter.com/1.1/followers/list.json?cursor=-1&screen_name=" . $twitteruser . "&count=48"); $followersHTML = ''; $tweetsHTML = ''; if (isset($followers->errors)) { echo "<div style='background: white;'>Please configure this module using CometChat Administration Panel.</div>"; exit; } else { foreach ($followers->users as $follower) { $followersHTML .= '<a target="_blank" href="http://www.twitter.com/' . $follower->screen_name . '"><img width=24 height=24 src="' . str_replace('normal', 'mini', $follower->profile_image_url) . '" alt="' . $follower->name . '" title="' . $follower->name . '"></a>'; } $tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $twitteruser . "&count=" . $notweets); foreach ($tweets as $tweet) { $tweetsHTML .= '<li class="tweet">' . auto_link_text($tweet->text) . '<br /><small>' . date('Y-m-d H:i:s', strtotime($tweet->created_at)) . '</small></li>'; } } $extrajs = ''; if ($sleekScroller == 1) { $extrajs = '<script>jqcc=jQuery;</script><script src="../../js.php?type=core&name=scroll"></script>'; } echo <<<EOD <!DOCTYPE html> <html> \t<head> \t\t<meta http-equiv="cache-control" content="no-cache"> \t\t<meta http-equiv="pragma" content="no-cache"> \t\t<meta http-equiv="expires" content="-1"> \t\t<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> \t\t<link type="text/css" rel="stylesheet" media="all" href="../../css.php?type=module&name=twitter" />