Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //relative time for twitter and facebook
- function getRelativeTime($utimestamp) {
- $reltime = '';
- if (isset($utimestamp)) {
- $types = Array('second', 'minute', 'hour', 'day', 'week', 'month', 'year', 'decade');
- $duration = Array(60, 60, 24, 7, 4.35, 12, 10);
- $gap = (time() - $utimestamp);
- if ($gap > 0) {
- $end = "ago";
- //$end = JText::_('COM_MYSOCIALTIMELINE_TIME_AGO');
- } else {
- $gap = - $gap;
- $end = "to go";
- //$end = JText::_('COM_MYSOCIALTIMELINE_TIME_TOGO');
- }
- for ($i = 0; $gap >= $duration[$i]; $i++) {
- $gap /= $duration[$i];
- $gap = round($gap);
- }
- if ($gap != 1) {
- $types[$i].= "s";
- $typelang = $types[$i];
- $typelang = strtoupper($types[$i]);
- $typelang = 'COM_MYSOCIALTIMELINE_TIME_'.$typelang;
- $reltime = $gap . ' ' . $types[$i] . ' ' . $end;
- //$reltime = $gap . ' ' . JText::_($typelang) . ' ' . $end;
- }
- else{
- //$types[$i].= "s";
- $typelang = $types[$i];
- $typelang = strtoupper($types[$i]);
- $typelang = 'COM_MYSOCIALTIMELINE_TIME_'.$typelang;
- $reltime = $gap . ' ' . $types[$i] . ' ' . $end;
- //$reltime = $gap . ' ' . JText::_($typelang) . ' ' . $end;
- }
- return $reltime;
- }
- }//end function getRelativeTime
- /**
- * Linkify url and hashtag
- *
- * @param type $status_text
- * @return type
- */
- function linkify_linkedin_status($status_text){
- // linkify URLs
- $status_text = preg_replace(
- '/(https?:\/\/\S+)/',
- '<a href="\1">\1</a>',
- $status_text
- );
- // linkify twitter users
- //please note that any thing tagged using @ in linkedin takes to twitter
- $status_text = preg_replace(
- '/(^|\s)@(\w+)/',
- '\1@<a target="_blank" href="http://twitter.com/\2">\2</a>',
- $status_text
- );
- // linkify hash tags
- $status_text = preg_replace(
- '/(^|\s)#(\w+)/',
- '\1#<a target="_blank" href="http://www.linkedin.com/signal/?keywords=%23\2">\2</a>',
- $status_text
- );
- return $status_text;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement