Login or create new account.

By registering on joomprod.com, you will have immediate access to all our free products and to the public side of our support forum.

Enjoy our subscriptions.

Each of our subscriptions allow you to enjoy the private side of the support forum and all the update of our products for a period ranging from 3 months to 1 year.

Payment And immediate download.

After subscribing to one of our subscription, the products are immediately downloadable.

Login

Or Register
Accueil / forum / Public Forum / Main Forum / [RESOLVED] Hyperlinks In description (TestArea)

Support Availability Because we must sleep sometimes

Working days: Monday to Friday.
Reply time: Depending on the complexity of your support issue it's usually between a few hours to 48 hours.

Support is only guaranteed to paid subscribers

AdsManager - End of life

It is with great regrets that we have chosen to end the developpement of Adsmanager and its other associated components.

AdsManager is born 10 years ago and, as of today, the number of new subscriptions and downloads have fallen and we cannot maintain the component anymore.

All active subscribers will be able to continue enjoying support until the end of their subscription.

The components will be free and no support will be provided anymore for the other users.

×

Notice

The forum is in read only mode.

× OLD Forum post could be checked here : forum.joomprod.com

[RESOLVED] Hyperlinks In description (TestArea)

  • Larenz
  • Larenz's Avatar
  • Offline
  • User
  • User
  • Hola! Visítame en http://facebook.com/arsyflex
More
10 years 6 months ago #7424 by Larenz
Then the correct code is this:

// CODIGO PARA URL
	function array_field($ar, $field) {
	  $a = array();
	  foreach($ar as $r) array_push($a, $r[$field]);
	  return $a;
	}
	function absolute_url($uri, $external=false, $param=false) {
	  if(!preg_match("#^https?://#i", $uri)) {
	    $uri = "http://$uri";
	  }
	  return  $uri;
	}
 
	function htmlize_links($s) {
	  preg_match_all("#(?!<=\S)(https?://)?(www\.)?[a-z0-9\.\-]+\.(com|org|edu|net|us|gov|uk|name|info|gl)(/\S*)?#i", $s, $matches, PREG_SET_ORDER);
	  if($matches) {
	    $links = $this->array_field($matches, 0);
	    foreach($links as $i => $link) $links[$i] = preg_replace('/[\)\]]+$/', '', $link);
	    $links = array_unique($links);
	    foreach($links as $l) {
	      $url      = $this->absolute_url($l);
	      $link     = "<a href='$url' target='_blank'>$l</a>";
	      $regexp   = "|(?!<=\S)".preg_quote($l, '|')."(?=[\s\)])|";
		  $s        = preg_replace($regexp, $link, $s); 
	    }
	  }
	  return $s;
	}
// FIN DE CÓDIGO PARA URL

Thanks for the correction. At the first time it was not working for me but now it its working well.

La mejor manera de saber que algo puede hacerse es porque alguien ya lo hizo primero.
The following user(s) said Thank You: adarr
More
10 years 6 months ago - 10 years 6 months ago #7438 by loic
Good news :).

I update the topic subject to resolved.

Best regards.
Last edit: 10 years 6 months ago by loic.
The following user(s) said Thank You: adarr
More
10 years 6 months ago #7451 by ilinear
Dear loic,

Sorry to inform that, I still having failure on doing so.

I had copy and place as what you mention. However, still unable

Kindly check my attached file in txt.

Am I placing the code at wrong line?

Please help.
The following user(s) said Thank You: adarr
More
10 years 6 months ago #7465 by loic
Hello,

The solution to detect the link in the textarea is a customer's idea and the code comes from the same customer.

Usually, we don't do any support for that kind of development, but I still tried to help you.
The code I gave to you works on my test site and I don't know why it doesn't on your website.

I can't spend more time on this problem but maybe you can ask your question in the original post. The user who had this idea may know why this solution don't work.

Also, don't forget to call the function 'htmlize_links' in the 'showFieldValue' function in the helper file, line 210, this code:
case 'textarea':
$return .= str_replace(array("\r\n", "\n", "\r"), "<br />", $value);
break;

Must be like that:
case 'textarea':
$return .= str_replace(array("\r\n", "\n", "\r"), "<br />", $this->htmlize_links($value));
break;

I'm sorry I cannot help you more.

Best regards.
The following user(s) said Thank You: ilinear, adarr
  • Larenz
  • Larenz's Avatar
  • Offline
  • User
  • User
  • Hola! Visítame en http://facebook.com/arsyflex
More
10 years 6 months ago #7476 by Larenz

ilinear wrote: Dear loic,

Sorry to inform that, I still having failure on doing so.

I had copy and place as what you mention. However, still unable

Kindly check my attached file in txt.

Am I placing the code at wrong line?

Please help.


What version of AdsManager are you using? Maybe I can help you fix this or at least I´ll try because I´m not an expert as Loic is :D

You should attach your field.php file. However, I made this as follows:
<?php
/**
 * @package		AdsManager
 * @copyright	Copyright (C) 2010-2014 Juloa.com. All rights reserved.
 * @license		GNU/GPL
 */
 
// no direct access
defined('_JEXEC') or die('Restricted access');
 
/**
 * Content Component HTML Helper
 *
 * @static
 * @package		Joomla
 * @subpackage	Content
 * @since 1.5
 */
class JHTMLAdsmanagerField
{
	var $content;
	var $conf;
	var $field_values;
	var $mode;
	var $plugins;
	var $_db;
 
	// CODIGO PARA URL
	function array_field($ar, $field) {
	  $a = array();
	  foreach($ar as $r) array_push($a, $r[$field]);
	  return $a;
	}
	function absolute_url($uri, $external=false, $param=false) {
	  if(!preg_match("#^https?://#i", $uri)) {
	    $uri = "http://$uri";
	  }
	  return  $uri;
	}
 
	function htmlize_links($s) {
	  preg_match_all("#(?!<=\S)(https?://)?(www\.)?[a-z0-9\.\-]+\.(com|org|edu|net|us|gov|uk|name|info|gl)(/\S*)?#i", $s, $matches, PREG_SET_ORDER);
	  if($matches) {
	    $links = $this->array_field($matches, 0);
	    foreach($links as $i => $link) $links[$i] = preg_replace('/[\)\]]+$/', '', $link);
	    $links = array_unique($links);
	    foreach($links as $l) {
	      $url      = $this->absolute_url($l);
	      $link     = "<a href='$url' target='_blank'>$l</a>";
	      $regexp   = "|(?!<=\S)".preg_quote($l, '|')."(?=[\s\)])|";
		  $s        = preg_replace($regexp, $link, $s); 
	    }
	  }
	  return $s;
	}
// FIN DE CÓDIGO PARA URL

As you see I added my code at the begining of that file (field.php) then I found the following line:
case 'textarea':
       $return .= str_replace(array("\r\n", "\n", "\r"), "<br />", $value);
       break;

And changed it by this:
case 'textarea':
        $return .= str_replace(array("\r\n", "\n", "\r"), "<br />", $this->htmlize_links($value));
        break;

Hope this work for you!

La mejor manera de saber que algo puede hacerse es porque alguien ya lo hizo primero.
The following user(s) said Thank You: ilinear, adarr
More
10 years 6 months ago #7479 by ilinear
Dear loic and Larenz,

Thank you very much for all help and supports provided to me .

Appreciating.

I did every steps as suggested here, still no luck and unable to auto detect the hyper-link.

I'm using ad Version 2911, loic also did edited the field.php for me, but still unable work out the outcome.

So far, decide to let go this option, or maybe in future, will request a quote from loic to solve this issue.

Once again, thank you very much.
The following user(s) said Thank You: adarr
Moderators: perry
Time to create page: 0.256 seconds
Powered by Kunena Forum