phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

Long URL's


 
Search this topic... | Search MOD Requests... | Search Box
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Author Message
Jim_UK
Board Member



Joined: 19 Nov 2008

Posts: 538
Location: North West UK


flag
PostPosted: Mon Jun 25, 2012 3:00 pm 
Post subject: Long URL's

Is my memory fading or was there a mod to truncate long url's?
Despite showing my users over and over again how to use the url bbcode many still post url's that occupy a couple of lines of text. They don't affect the board layout as I must have, in the dim and distant past, installed a mod to stop that but nevertheless still annoying to get the long ones.
If the answer is yes does anyone have the mod. I have looked on phpbbhacks but no joy.

Thanks
Jim
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Mon Jun 25, 2012 4:38 pm 
Post subject: Re: Long URL's

I don't see one either, but it should be easy enough to make using substr_replace(). I don't have time now, but I could probably look into it tonight if you need help with it.
Back to top
Jim_UK
Board Member



Joined: 19 Nov 2008

Posts: 538
Location: North West UK


flag
PostPosted: Mon Jun 25, 2012 4:47 pm 
Post subject: Re: Long URL's

Salvatos wrote:
I don't see one either, but it should be easy enough to make using substr_replace(). I don't have time now, but I could probably look into it tonight if you need help with it.


Thanks for the offer but the more I think about it the more I am sure that it exists. "Tiny url" keeps popping into my head.
The problem is that I have reached the age were only bits stick and not the full story.

Jim
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Mon Jun 25, 2012 10:15 pm 
Post subject: Re: Long URL's

Well, there's a website called TinyURL, but you have to actually go there and create a custom link every time you need a new one.

Quote:
The problem is that I have reached the age were only bits stick and not the full story.

I can relate, I got there before I was twenty...
Back to top
Jim_UK
Board Member



Joined: 19 Nov 2008

Posts: 538
Location: North West UK


flag
PostPosted: Tue Jun 26, 2012 6:58 am 
Post subject: Re: Long URL's

Salvatos wrote:
Well, there's a website called TinyURL, but you have to actually go there and create a custom link every time you need a new one.


Illustrates what I mean - I remember that site and clearly not what I need for my users.
The search continues.

Jim
Back to top
dogs and things
Board Member



Joined: 18 Nov 2008

Posts: 621
Location: Spain


flag
PostPosted: Tue Jun 26, 2012 7:06 am 
Post subject: Re: Long URL's

Hi Jim:

I guess this is the one you have in mind, I use it and it works as expected.

Code:
##############################################################
## MOD Title: Chunk Long URLs
## MOD Author: Joe Belmaati < belmaati@gmail.com > (Joe Belmaati) N/A
## MOD Description: Tired of long urls that strecth your phpBB layout?
## This mod will chunk long urls.
## MOD Version: 1.0.0
##
## Installation Level: Easy
## Installation Time: 1 Minute
## Files To Edit: includes/bbcode.php
##
## Included Files: N/A
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## For security purposes, please check: http://www.phpbb.com/mods/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://www.phpbb.com/mods/
##############################################################
## Author Notes: The long links will look like this:
## http://yoursite.com/fhjfgjf.....dfhdj.php. Short urls will
## not be touched
##############################################################
## MOD History:
##
##   2006-08-16 - 1.0.0
##      - submitted to MODs datatbase at phpBB
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ OPEN ]------------------------------------------
#
includes/bbcode.php
#
#-----[ FIND ]------------------------------------------
#
   // matches an email@domain type address at the start of a line, or after a space.
#
#-----[ BEFORE, ADD ]------------------------------------------
#
   chunk_url($ret);

#
#-----[ FIND ]------------------------------------------
#
/**
* Nathan Codding - Feb 6, 2001
#
#-----[ BEFORE, ADD ]------------------------------------------
#
/**
* Chunk long urls to avoid page stretching. This function splits a
* long url into chunks, then glues it back together with a couple
* of dots. This gaggle of code could be boiled down to fewer lines,
* but it would make it hard to read.
*/
function chunk_url(&$ret)
{
   /**
    * Split the string into an array. Then loop through
    * the array and process each link separately.
    */
   $links = explode('<a', $ret);
   $countlinks = count($links);
   for ($i = 0; $i < $countlinks; $i++)
   {
      $link = $links[$i];

      /**
       * If the array element is a hyperlink then put the missing
       * '<a' back in, as we will not be imploding...
       */
      $link = (preg_match('#(.*)(href=")#is', $link)) ? '<a' . $link : $link;

      $begin = strpos($link, '>') + 1;
      $end = strpos($link, '<', $begin);
      $length = $end - $begin;
      $urlname = substr($link, $begin, $length);

      /**
       * We chunk urls that are longer than 50 characters. Just change
       * '50' to a value that suits your taste. We are not chunking the link
       * text unless if begins with 'http://', 'ftp://', or 'www.'
       */
      $shorturlname = (strlen($urlname) > 50 && preg_match('#^(http://|ftp://|www\.)#is', $urlname)) ? substr_replace($urlname, '.....', 30, -10) : $urlname;
      $ret = str_replace('>' . $urlname . '<', '>' . $shorturlname . '<', $ret);
   }
}
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM

_________________
phpBB2 will never die, I hope!
Back to top
Jim_UK
Board Member



Joined: 19 Nov 2008

Posts: 538
Location: North West UK


flag
PostPosted: Tue Jun 26, 2012 7:11 am 
Post subject: Re: Long URL's

Hi and thanks,
I will give it a go. I am tired of asking them to use bbcode to reduce link to text such as "Click here"

Jim
Back to top
dogs and things
Board Member



Joined: 18 Nov 2008

Posts: 621
Location: Spain


flag
PostPosted: Tue Jun 26, 2012 7:14 am 
Post subject: Re: Long URL's

There's this mod that ads a popup to the url bbcode button asking for anchor text and url.

But that seems quite useless as people don´t click on that button and tend to simply paste urls.

So yes, this mod seems to be the best you can do.

_________________
phpBB2 will never die, I hope!
Back to top
Jim_UK
Board Member



Joined: 19 Nov 2008

Posts: 538
Location: North West UK


flag
PostPosted: Tue Jun 26, 2012 9:00 am 
Post subject: Re: Long URL's

Installed, tested and works great. Just what I was looking for.

Many thanks
Jim
Back to top
dogs and things
Board Member



Joined: 18 Nov 2008

Posts: 621
Location: Spain


flag
PostPosted: Tue Jun 26, 2012 9:21 am 
Post subject: Re: Long URL's

You're welcome Jim, glad I could help you out. icon_wink.gif
_________________
phpBB2 will never die, I hope!
Back to top
lumpy burgertushie
Board Member



Joined: 19 Nov 2008

Posts: 214


flag
PostPosted: Thu Jun 28, 2012 4:48 pm 
Post subject: Re: Long URL's

Jim_UK wrote:
Hi and thanks,
I will give it a go. I am tired of asking them to use bbcode to reduce link to text such as "Click here"

Jim


just curious, why do you care if they use the bbcode or just paste the link?


robert
Back to top
Jim_UK
Board Member



Joined: 19 Nov 2008

Posts: 538
Location: North West UK


flag
PostPosted: Thu Jun 28, 2012 5:53 pm 
Post subject: Re: Long URL's

Just the appearance Robert although one or two users have claimed that they break the board layout. I have a mod installed that forces a text wrap so not sure why they experience it.

Jim
Back to top
Display posts from previous:   
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0123 seconds using 16 queries. (SQL 0.0028 Parse 0.0003 Other 0.0092)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo