]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
* Introducing substr wrapper function
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 8 Jun 2009 12:55:21 +0000 (12:55 +0000)
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 8 Jun 2009 12:55:21 +0000 (12:55 +0000)
* Wire strips tags (Closes #1045)

git-svn-id: https://code.elgg.org/elgg/trunk@3323 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/mb_wrapper.php
mod/thewire/start.php

index 7b3327edcb8505e95a57ce5a93696c347d50c0c8..411a2d5c2e6a1ada0adcb7a9bd4ebf8e34afb2d3 100644 (file)
                return strtoupper($string);
        }
        
+       /**
+        * Wrapper function: Returns the result of mb_substr if mb_support is present, else the 
+        * result of substr is returned.
+        *
+        * @param string $string The string.
+        * @param int $start Start position.
+        * @param int $length Length.
+        * @param string $charset The charset (if multibyte support is present) : default 'UTF8'
+        * @return string
+        */
+       function elgg_substr($string, $start = 0, $length = null, $charset = 'UTF8')
+       {
+               if (is_callable('mb_substr'))
+                       return mb_substr($string, $start, $length, $charset);
+               
+               return substr($string, $start, $length);
+       }
+       
        // TODO: Other wrapper functions
 ?>
\ No newline at end of file
index 9b313eed8604b86ea85538c894f218993aeaee85..91618a48d7d012a5bcea0dacbe7d77832978ece9 100644 (file)
                        $thewire->access_id = $access_id;\r
                        \r
                        // Set its description appropriately
-                       if (is_callable('mb_substr'))\r
-                               $thewire->description = mb_substr($post, 0, 160);
+                       $thewire->description = elgg_substr(strip_tags($post), 0, 160);
+                       /*if (is_callable('mb_substr'))\r
+                               $thewire->description = mb_substr(strip_tags($post), 0, 160);
                        else
-                               $thewire->description = substr($post, 0, 160);\r
+                               $thewire->description = substr(strip_tags($post), 0, 160);*/\r
                        \r
                    // add some metadata\r
                $thewire->method = $method; //method, e.g. via site, sms etc\r