Module: appdb Branch: master Commit: 647a307fa9da3bc4d53aab98d12bcc9d0fdacd67 URL: http://source.winehq.org/git/appdb.git/?a=commit;h=647a307fa9da3bc4d53aab98d...
Author: Alexander Nicolaysen Sørnes alex@thehandofagony.com Date: Sat Aug 9 00:41:50 2008 +0200
Add an ellipsis when cutting urls
---
include/application.php | 2 +- include/util.php | 16 ++++++++++++++++ include/version.php | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/include/application.php b/include/application.php index 1d1fac6..57fcb57 100644 --- a/include/application.php +++ b/include/application.php @@ -744,7 +744,7 @@ class Application { $oVendor = new Vendor($this->iVendorId);
// set URL - $appLinkURL = ($this->sWebpage) ? "<a href="".$this->sWebpage."">".substr(stripslashes($this->sWebpage),0,30)."</a>": " "; + $appLinkURL = ($this->sWebpage) ? trimmed_link($this->sWebpage,30) : " ";
// start display application echo html_frame_start("","98%","",0); diff --git a/include/util.php b/include/util.php index 49ddedf..bf6f8df 100644 --- a/include/util.php +++ b/include/util.php @@ -917,6 +917,22 @@ function HtmlAreaLoaderScript($aTextareas) }
/** + * Cuts the link text to the specified number of chars if it's longer, + * and adds an ellipsis + */ +function trimmed_link($shUrl, $iLength) +{ + $shText = $shUrl; + $shEnd = ''; + if(strlen($shUrl) > $iLength) + { + $shText = substr($shUrl, 0, $iLength); + $shText .= '...'; + } + return "<a href="$shUrl">$shText</a>"; +} + +/** * Remove html formatting from description and extract the first part of the description only. * This is to be used for search results, application summary tables, etc. */ diff --git a/include/version.php b/include/version.php index b6ed1bf..4bbf882 100644 --- a/include/version.php +++ b/include/version.php @@ -822,7 +822,7 @@ class version { $oCategory->display($oApp->iAppId, $this->iVersionId);
// set URL - $appLinkURL = ($oApp->sWebpage) ? "<a href="".$oApp->sWebpage."">".substr(stripslashes($oApp->sWebpage),0,30)."</a>": " "; + $appLinkURL = ($oApp->sWebpage) ? trimmed_link($oApp->sWebpage,30) : " ";
// start version display echo html_frame_start("","98%","",0);