Beispiel #1
0
 public function resolve(ResourceLocator $locator)
 {
     if ($locator->hasResourceId()) {
         $context = Claro_Context::getCurrentContext();
         $context[CLARO_CONTEXT_COURSE] = $locator->getCourseId();
         if ($locator->inGroup()) {
             $context[CLARO_CONTEXT_GROUP] = $locator->getGroupId();
         }
         $path = get_path('coursesRepositorySys') . claro_get_course_path($locator->getCourseId());
         // in a group
         if ($locator->inGroup()) {
             $groupData = claro_get_group_data($context);
             $path .= '/group/' . $groupData['directory'];
             $groupId = $locator->getGroupId();
         } else {
             $path .= '/document';
         }
         $path .= '/' . $this->urlDecodePath(ltrim($locator->getResourceId(), '/'));
         $resourcePath = '/' . $this->urlDecodePath(ltrim($locator->getResourceId(), '/'));
         $path = secure_file_path($path);
         if (!file_exists($path)) {
             // throw new Exception("Resource not found {$path}");
             return false;
         } elseif (is_dir($path)) {
             $url = new Url(get_module_entry_url('CLDOC'));
             $url->addParam('cmd', 'exChDir');
             $url->addParam('file', base64_encode($resourcePath));
             return $url->toUrl();
         } else {
             return claro_get_file_download_url($resourcePath, Claro_Context::getUrlContext($context));
         }
     } else {
         return get_module_entry_url('CLDOC');
     }
 }
Beispiel #2
0
 public function resolve(ResourceLocator $locator)
 {
     if ($locator->hasResourceId()) {
         $assignement_id = $locator->getResourceId();
         $url = new Url(get_module_url('CLWRK') . '/work_list.php');
         $url->addParam('assigId', (int) $assignement_id);
         return $url->toUrl();
     } else {
         return get_module_entry_url('CLWRK');
     }
 }
Beispiel #3
0
 public function resolve(ResourceLocator $locator)
 {
     if ($locator->hasResourceId()) {
         $parts = explode('/', ltrim($locator->getResourceId(), '/'));
         if (count($parts) == 1) {
             $url = new Url(get_module_url('CLWIKI') . '/wiki.php');
             $url->addParam('wikiId', (int) $parts[0]);
             return $url->toUrl();
         } elseif (count($parts) == 2) {
             $url = new Url(get_module_url('CLWIKI') . '/page.php');
             $url->addParam('wikiId', (int) $parts[0]);
             $url->addParam('title', $parts[1]);
             return $url->toUrl();
         } else {
             return get_module_entry_url('CLWIKI');
         }
     } else {
         return get_module_entry_url('CLWIKI');
     }
 }
Beispiel #4
0
/**
 * Get url of a module help page
 * @param string $block name of the help block to display
 * @param string $module module label or 'platform'
 * @return string 
 */
function get_help_page_url($block, $module = 'platform')
{
    $helpUrl = new Url(get_path('url') . '/claroline/help/index.php');
    if ($module) {
        $helpUrl->addParam('module', $module);
    }
    $helpUrl->addParam('block', $block);
    return $helpUrl->toUrl();
}
Beispiel #5
0
/**
 * Get the url to download the file at the given file path
 * @param string $file path to the file
 * @param array $context
 * @param string $moduleLabel
 * @since Claroline 1.10.5
 * @return string url to the file
 */
function claro_get_file_download_url($file, $context = null, $moduleLabel = null)
{
    $file = download_url_encode($file);
    if ($GLOBALS['is_Apache'] && get_conf('usePrettyUrl', false)) {
        // slash argument method - only compatible with Apache
        $url = get_path('url') . '/claroline/backends/download.php' . str_replace('%2F', '/', $file);
    } else {
        // question mark argument method, for IIS ...
        $url = get_path('url') . '/claroline/backends/download.php?url=' . $file;
    }
    $urlObj = new Url($url);
    if (!empty($context)) {
        $urlObj->relayContext(Claro_Context::getUrlContext($context));
    } else {
        $urlObj->relayCurrentContext();
    }
    if ($moduleLabel) {
        $urlObj->addParam('moduleLabel', $moduleLabel);
    }
    return $urlObj->toUrl();
}
Beispiel #6
0
 /**
  * @return template object
  * @since 1.10
  * @todo write a CategoryBrowserView class (implementing Display)
  */
 public function getTemplate()
 {
     $currentCategory = $this->getCurrentCategorySettings();
     $categoryList = $this->getSubCategoryList();
     $navigationUrl = new Url($_SERVER['PHP_SELF'] . '#categoryContent');
     /*
      * Build url param list
      * @todo find a better way to do that
      */
     if (isset($_REQUEST['cmd'])) {
         $navigationUrl->addParam('cmd', $_REQUEST['cmd']);
     }
     if (isset($_REQUEST['fromAdmin'])) {
         $navigationUrl->addParam('fromAdmin', $_REQUEST['fromAdmin']);
     }
     if (isset($_REQUEST['uidToEdit'])) {
         $navigationUrl->addParam('uidToEdit', $_REQUEST['uidToEdit']);
     }
     if (isset($_REQUEST['asTeacher'])) {
         $navigationUrl->addParam('asTeacher', $_REQUEST['asTeacher']);
     }
     $courseTreeView = CourseTreeNodeViewFactory::getCategoryCourseTreeView($this->categoryId, $this->userId);
     $courseTreeView->setViewOptions($this->viewOptions);
     $template = new CoreTemplate('categorybrowser.tpl.php');
     $template->assign('currentCategory', $currentCategory);
     $template->assign('categoryBrowser', $this);
     $template->assign('categoryList', $categoryList);
     $template->assign('courseTreeView', $courseTreeView);
     $template->assign('navigationUrl', $navigationUrl->toUrl());
     return $template;
 }
Beispiel #7
0
/**
 * add a GET request variable list to the given URL
 * @param string url url
 * @param array variableList list of the request variables to add
 * @return string url
 */
function add_request_variable_list_to_url($url, $variableList)
{
    $urlObj = new Url($url);
    $urlObj->addParamList($variableList);
    return $urlObj->toUrl();
}
Beispiel #8
0
 public function resolve(ResourceLocator $locator)
 {
     if ($locator instanceof ExternalResourceLocator) {
         return $locator->__toString();
     } else {
         // 1 . get most accurate resolver
         //  1.1 if Module
         if ($locator->inModule()) {
             $resolver = $this->loadModuleResolver($locator->getModuleLabel());
             if (!$resolver) {
                 $resolver = new ToolResolver();
             }
         } elseif ($locator->inGroup()) {
             $resolver = new GroupResolver();
         } elseif ($locator->inCourse()) {
             $resolver = new CourseResolver();
         }
         //  1.4 get base url
         if ($resolver) {
             $url = $resolver->resolve($locator);
         } else {
             $url = get_path('rootWeb');
         }
         $urlObj = new Url($url);
         // 2. add context information
         $context = Claro_Context::getCurrentContext();
         if ($locator->inGroup()) {
             $context[CLARO_CONTEXT_GROUP] = $locator->getGroupId();
         } else {
             if (isset($context[CLARO_CONTEXT_GROUP])) {
                 unset($context[CLARO_CONTEXT_GROUP]);
             }
         }
         if ($locator->inCourse()) {
             $context[CLARO_CONTEXT_COURSE] = $locator->getCourseId();
         } else {
             if (isset($context[CLARO_CONTEXT_COURSE])) {
                 unset($context[CLARO_CONTEXT_COURSE]);
             }
         }
         $urlObj->relayContext(Claro_Context::getUrlContext($context));
         return $urlObj->toUrl();
     }
 }