video thumbnails are displayed as slideshow when mouse is over; video widget bugs...
[living-lab-site.git] / application / helpers / MY_url_helper.php
1 <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
3 /**
4  * Encodes CI segments for using them in URLs.
5  * Useful when the last page needs to be remembered in the URL.
6  * The function replaces all '/' with '\' and then encodes with urlencode PHP
7  * function.
8  * 
9  * @param string $str   segments string to encode
10  * @param string $disallowed_prefix     if $str start with $disallowed_prefix the
11  * function returns a null string.
12  * @return string       the encoded segments
13  */
14 function urlencode_segments($str, $disallowed_prefix = NULL)
15 {
16         if ($disallowed_prefix && strpos($str, $disallowed_prefix) === 0)
17                 return '';
18         
19         $str = str_replace('/', '\\', $str);
20         return urlencode($str);
21 }
22
23 /**
24  * Decodes a string encoded with urlencode_segments helper.
25  * 
26  * @param string $str   string to decode
27  * @return string       the valid CI segments decoded from $str
28  */
29 function urldecode_segments($str)
30 {
31         $str = urldecode($str);
32         return str_replace('\\', '/', $str);
33 }
34
35 /* End of file MY_url_helper.php */
36 /* Location: ./application/helpers/MY_url_helper.php */