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'); } }
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'); } }
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'); } }
/** * 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(); }
/** * 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(); }
/** * @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; }
/** * add a GET request variable to the given URL * @param string url url * @param string name name of the variable * @param string value value of the variable * @return string url */ function add_request_variable_to_url($url, $name, $value) { $urlObj = new Url($url); $urlObj->addParam($name, $value); return $urlObj->toUrl(); }