1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

Issue #372 - I have added toDate() to the text-parser - for returning dates formatted for HTML. It should be backwards compatible and currently supports Livestamp.js . Example usage: echo $tp->toDate(1370234650);

This commit is contained in:
Cameron 2013-06-02 21:46:53 -07:00
parent 1950c4a1a9
commit 46955b8e68

View File

@ -1761,6 +1761,8 @@ class e_parse extends e_parser
}
function toAttribute($text)
{
// URLs posted without HTML access may have an & in them.
@ -1837,6 +1839,9 @@ class e_parse extends e_parser
}
/**
* Set the dimensions of a thumbNail (generated by thumbUrl)
*/
public function setThumbSize($w=null,$h=null,$crop=null)
{
if($w)
@ -2365,8 +2370,28 @@ class e_parse extends e_parser
}
return $text;
}
/**
* Display a Date in the browser.
* Includes support for 'livestamp' (http://mattbradley.github.io/livestampjs/)
* @param integer $datestamp - unix timestamp
* @param string $format - short | long | relative
* @return HTML with converted date.
*/
public function toDate($datestamp = null, $format='short')
{
if(!is_numeric($datestamp)){ return; }
return '<span data-livestamp="'.$datestamp.'">'.e107::getDate()->convert($datestamp, $format).'</span>';
}
/**
* Convert Text to a suitable format for use in emails. eg. relative links will be replaced with full links etc.
* @param string $text
* @param boolean $posted - if the text has been posted. (uses stripslashes etc)
* @param string $mods - flags for text transformation.
*/
public function toEmail($text, $posted = "", $mods = "parse_sc, no_make_clickable")
{
if ($posted === TRUE)
@ -2384,7 +2409,9 @@ class e_parse extends e_parser
}
// Given an email address, returns a link including js-based obfuscation
/**
* Given an email address, returns a link including js-based obfuscation
*/
function emailObfuscate($email, $words = '', $subject = '')
{
if(strpos($email, '@') === FALSE)
@ -2400,6 +2427,8 @@ class e_parse extends e_parser
return "<a rel='external' href='javascript:window.location=\"mai\"+\"lto:\"+".$reassembled.$subject.";self.close();' onmouseover='window.status=\"mai\"+\"lto:\"+".$reassembled."; return true;' onmouseout='window.status=\"\";return true;'>".$words.'</a>';
}
public function __get($name)
{
switch($name)