Well, I don´t need a like for my problem. I need a solution.
<?php
class *******_AutoLink_ViewPublic_Helper_AutoLink
{
protected static $_linkCache = null;
/**
* Auto Links the given string.
*
* @param string $string
* @param array|null $autoLinks Words to replace link. Null to use option value.
*
* @return string
*/
public static function autoLinkString($string, array $autoLinks = null)
{
$allowCache = ($autoLinks === null); // ok to use cache for default
$linkCache = ($allowCache ? self::$_linkCache : null);
if ($linkCache === null)
{
if ($autoLinks === null)
{
$autoLinks = XenForo_Application::getSimpleCacheData('bralAutoLinks');
}
if (!$autoLinks)
{
if ($allowCache)
{
self::$_linkCache = array();
}
return $string;
}
$linkCache = self::buildAutoLinkArray($autoLinks);
if ($allowCache)
{
self::$_linkCache = $linkCache;
}
}
if (!empty($linkCache))
{
$limitLink = XenForo_Application::get('options')->BRAL_limitLinkPost;
try
{
$string = preg_replace(array_keys($linkCache), $linkCache, $string->__toString(), $limitLink);
}
catch (Exception $e)
{
$string = preg_replace(array_keys($linkCache), $linkCache, $string, $limitLink);
}
}
return $string;
}
/**
* Builds the AutoLink array.
*
* @param array $words List of words (from option format)
*
* @return array Possible keys: active, inactive with key-value search/replace pairs
*/
public static function buildAutoLinkArray(array $autoLinks)
{
$linkCache = array();
if (!empty($autoLinks))
{
$active = array();
$replaceAtag = XenForo_Application::get('options')->BRAL_replaceATag;
foreach ($autoLinks AS $autoLink)
{
$word = htmlentities($autoLink['word'], ENT_QUOTES);
if(!$replaceAtag){
$search = "#(?<=\W|^)(?!((<.*?)|(<a.*?)))". preg_quote($word, '#') . "(?!(([^<>]*?)>)|([^>]*?</a>))(?=\W|$)#iu";
}else{
$search = '#(?<=\W|^)' . preg_quote($word, '#') . '(?!(([^<>]*?)>))(?=\W|$)#iu';
}
$rel = $autoLink['rel']==0?'':' rel="nofolow"';
$alt = empty($autoLink['alt'])?'':' title="'.$autoLink['alt'].'"';
$target = empty($autoLink['target'])?'_blank':$autoLink['target'];
$active[$search] = '<a'.$rel.$alt.' target="'.$target.'" href="'.$autoLink['replace'].'" title="'.$word.'" class="AutoLinkClickListener">'.$word.'</a>';
}
$linkCache = $active;
}
return $linkCache;
}
}
if (!empty($linkCache))
{
$limitLink = XenForo_Application::get('options')->BRAL_limitLinkPost;
try
{
$string = preg_replace(array_keys($linkCache), $linkCache, $string->__toString(), $limitLink);
}
catch (Exception $e)
{
$string = preg_replace(array_keys($linkCache), $linkCache, $string, $limitLink);
}
}
if (!empty($linkCache))
{
$limitLink = XenForo_Application::get('options')->BRAL_limitLinkPost;
try
{
if ($string instanceof XenForo_BbCode_TextWrapper)
{
$string = $string->__toString();
}
}
catch (Exception $e){}
$string = preg_replace(array_keys($linkCache), $linkCache, $string, $limitLink);
}
Thanks for your suggestion and i'd like to offer you a custom work service to sort your request out.I would love to see this extended to include features such as http://www.jv-extensions.com/products/jv-contentlinks for Joomla.
The ability to monetise content by post number, allowing people to buy keyword phrases in a specific post only, priceless. And all automatic via the defined XF payment system being used.
Possibly the ability to approve / reject with refund, just as a moderation protection.
Please consider just making it! I'm sure you will sell this like hot cakes if that was included!Thanks for your suggestion and i'd like to offer you a custom work service to sort your request out.
Regards,
I think it would actually become their highest grossing add-on, to be honest, especially if sold at a reasonable entry price.I'm sure you will sell this like hot cakes if that was included!
Feel free to get it custom made by them then and then sell it off. As a customer of this specific add-on, all those features would be bloat for me.I think it would actually become their highest grossing add-on, to be honest, especially if sold at a reasonable entry price.
We use essential cookies to make this site work, and optional cookies to enhance your experience.