mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-01 23:29:45 +00:00
Changing variable name to make consistency between others methods.
This commit is contained in:
parent
e7074c1e5c
commit
61845090ed
1 changed files with 18 additions and 19 deletions
|
@ -110,56 +110,55 @@ class TextHelper extends AppHelper {
|
||||||
* strings like http:// and ftp://.
|
* strings like http:// and ftp://.
|
||||||
*
|
*
|
||||||
* @param string $text Text to add links to
|
* @param string $text Text to add links to
|
||||||
* @param array $htmlOptions Array of HTML options.
|
* @param array $options Array of HTML options.
|
||||||
* @return string The text with links
|
* @return string The text with links
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function autoLinkUrls($text, $htmlOptions = array()) {
|
function autoLinkUrls($text, $options = array()) {
|
||||||
$options = 'array(';
|
$linkOptions = 'array(';
|
||||||
foreach ($htmlOptions as $option => $value) {
|
foreach ($options as $option => $value) {
|
||||||
$value = var_export($value, true);
|
$value = var_export($value, true);
|
||||||
$options .= "'$option' => $value, ";
|
$linkOptions .= "'$option' => $value, ";
|
||||||
}
|
}
|
||||||
$options .= ')';
|
$linkOptions .= ')';
|
||||||
|
|
||||||
$text = preg_replace_callback('#(?<!href="|">)((?:http|https|ftp|nntp)://[^ <]+)#i', create_function('$matches',
|
$text = preg_replace_callback('#(?<!href="|">)((?:http|https|ftp|nntp)://[^ <]+)#i', create_function('$matches',
|
||||||
'$Html = new HtmlHelper(); $Html->tags = $Html->loadConfig(); return $Html->link($matches[0], $matches[0],' . $options . ');'), $text);
|
'$Html = new HtmlHelper(); $Html->tags = $Html->loadConfig(); return $Html->link($matches[0], $matches[0],' . $linkOptions . ');'), $text);
|
||||||
|
|
||||||
return preg_replace_callback('#(?<!href="|">)(?<!http://|https://|ftp://|nntp://)(www\.[^\n\%\ <]+[^<\n\%\,\.\ <])(?<!\))#i',
|
return preg_replace_callback('#(?<!href="|">)(?<!http://|https://|ftp://|nntp://)(www\.[^\n\%\ <]+[^<\n\%\,\.\ <])(?<!\))#i',
|
||||||
create_function('$matches', '$Html = new HtmlHelper(); $Html->tags = $Html->loadConfig(); return $Html->link($matches[0], "http://" . strtolower($matches[0]),' . $options . ');'), $text);
|
create_function('$matches', '$Html = new HtmlHelper(); $Html->tags = $Html->loadConfig(); return $Html->link($matches[0], "http://" . strtolower($matches[0]),' . $linkOptions . ');'), $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds email links (<a href="mailto:....) to a given text.
|
* Adds email links (<a href="mailto:....) to a given text.
|
||||||
*
|
*
|
||||||
* @param string $text Text
|
* @param string $text Text
|
||||||
* @param array $htmlOptions Array of HTML options.
|
* @param array $options Array of HTML options.
|
||||||
* @return string The text with links
|
* @return string The text with links
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function autoLinkEmails($text, $htmlOptions = array()) {
|
function autoLinkEmails($text, $options = array()) {
|
||||||
$options = 'array(';
|
$linkOptions = 'array(';
|
||||||
|
foreach ($options as $option => $value) {
|
||||||
foreach ($htmlOptions as $option => $value) {
|
|
||||||
$value = var_export($value, true);
|
$value = var_export($value, true);
|
||||||
$options .= "'$option' => $value, ";
|
$linkOptions .= "'$option' => $value, ";
|
||||||
}
|
}
|
||||||
$options .= ')';
|
$linkOptions .= ')';
|
||||||
|
|
||||||
return preg_replace_callback('#([_A-Za-z0-9+-]+(?:\.[_A-Za-z0-9+-]+)*@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*)#',
|
return preg_replace_callback('#([_A-Za-z0-9+-]+(?:\.[_A-Za-z0-9+-]+)*@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*)#',
|
||||||
create_function('$matches', '$Html = new HtmlHelper(); $Html->tags = $Html->loadConfig(); return $Html->link($matches[0], "mailto:" . $matches[0],' . $options . ');'), $text);
|
create_function('$matches', '$Html = new HtmlHelper(); $Html->tags = $Html->loadConfig(); return $Html->link($matches[0], "mailto:" . $matches[0],' . $linkOptions . ');'), $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert all links and email adresses to HTML links.
|
* Convert all links and email adresses to HTML links.
|
||||||
*
|
*
|
||||||
* @param string $text Text
|
* @param string $text Text
|
||||||
* @param array $htmlOptions Array of HTML options.
|
* @param array $options Array of HTML options.
|
||||||
* @return string The text with links
|
* @return string The text with links
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function autoLink($text, $htmlOptions = array()) {
|
function autoLink($text, $options = array()) {
|
||||||
return $this->autoLinkEmails($this->autoLinkUrls($text, $htmlOptions), $htmlOptions);
|
return $this->autoLinkEmails($this->autoLinkUrls($text, $options), $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue