Example #1
0
 public function createResourceLocator($courseId, $relativePath, $isVisible, $isNavigable, $groupId)
 {
     $fileLoc = new ClarolineResourceLocator($courseId, 'CLDOC', format_url_path($relativePath), $groupId);
     $fileResource = new LinkerResource(basename($relativePath), $fileLoc, true, $isVisible, $isNavigable);
     return $fileResource;
 }
Example #2
0
/**
 * Enter description here...
 *
 * @param string $query
 * @return string
 */
function format_url_query($query)
{
    $ret = '';
    if (strpos($query, '&') !== false || strpos($query, '&') !== false || strpos($query, '=') !== false) {
        $queryArray = preg_split('~(&|&)~', $query);
        $parts = array();
        foreach ($queryArray as $part) {
            if (preg_match('~(.*?)=(.*?)~', $part)) {
                $parts[] = preg_replace_callback('~(.+?)=(.+)~', 'query_make_part', $part);
            } elseif (preg_match('~/?[^=]+~', $part)) {
                // option 1 :
                $parts[] = '/' . format_url_path(substr($part, 1));
                // option 2
                // $parts[] = $part;
                // option 3
                // $parts[] = rawurlencode($part);
            } else {
                // option 1
                // $parts[] = $part;
                // option 2
                // $parts[] = rawurlencode($part);
            }
        }
        $ret = implode('&', $parts);
    } elseif (strpos($query, '/') !== false) {
        $ret = format_url_path($query);
    } else {
        $ret = rawurlencode($query);
    }
    return $ret;
}