summaryrefslogtreecommitdiffstats
path: root/phpfspot.class.php
diff options
context:
space:
mode:
authorAndreas Unterkircher <unki@netshadow.at>2007-11-01 10:49:49 +0000
committerAndreas Unterkircher <unki@netshadow.at>2007-11-01 10:49:49 +0000
commite9903870bf7c89c1013a9502282a7b66b139b0e3 (patch)
tree4a20c6352ad517963264849e172df466761cde13 /phpfspot.class.php
parent4ff4a0e7adc87e654f6eefccdd2f43827bd06535 (diff)
make text-shrinking function more general to be used elsewhere
git-svn-id: file:///var/lib/svn/phpfspot/trunk@276 fa6a889d-dae6-447d-9e79-4ba9a3039384
Diffstat (limited to 'phpfspot.class.php')
-rw-r--r--phpfspot.class.php22
1 files changed, 18 insertions, 4 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php
index 723140f..a511648 100644
--- a/phpfspot.class.php
+++ b/phpfspot.class.php
@@ -226,16 +226,30 @@ class PHPFSPOT {
public function getPhotoName($idx, $limit = 0)
{
if($details = $this->get_photo_details($idx)) {
- $name = $details['name'];
- if($limit != 0 && strlen($name) > $limit) {
- $name = substr($name, 0, $limit-5) ."...". substr($name, -($limit-5));
- }
+ $name = $this->shrink_text($details['name'], $limit);
return $name;
}
} // getPhotoName()
/**
+ * shrink text according provided limit
+ *
+ * If the length of the name exceeds $limit the
+ * text will be shortend and some content in between
+ * will be replaced with "..."
+ */
+ private function shrink_text($text, $limit)
+ {
+ if($limit != 0 && strlen($text) > $limit) {
+ $text = substr($text, 0, $limit-5) ."...". substr($text, -($limit-5));
+ }
+
+ return $text;
+
+ } // shrink_text();
+
+ /**
* translate f-spoth photo path
*
* as the full-qualified path recorded in the f-spot database