/** * Returns all the descriptions of a course. * @throws InvalidArgumentException if the $cid in not provided. * @webservice{/module/MOBILE/GEN/getResourcesList/cidReq} * @ws_arg{method,getResourcesList} * @ws_arg{cidReq,SYSCODE of requested cours} * @return array of Descriptions object */ function getResourcesList($args) { $module = isset($args['module']) ? $args['module'] : null; $cid = claro_get_current_course_id(); if ($cid == null || $module == null) { throw new InvalidArgumentException('Missing cid argument!'); } $list = array(); FromKernel::uses('core/linker.lib'); ResourceLinker::init(); $locator = new ClarolineResourceLocator($cid, $module, null, claro_get_current_group_id()); if (ResourceLinker::$Navigator->isNavigable($locator)) { $resourceList = ResourceLinker::$Navigator->getResourceList($locator); foreach ($resourceList as $lnk) { $inLocator = $lnk->getLocator(); $item['title'] = $lnk->getName(); $item['visibility'] = $lnk->isVisible(); $item['url'] = str_replace(get_path('url'), "", get_path('rootWeb')) . ResourceLinker::$Resolver->resolve($inLocator); if ($inLocator->hasResourceId()) { $item['resourceId'] = $inLocator->getResourceId(); } else { $item['resourceId'] = $item['url']; } if (claro_is_allowed_to_edit() || $item['visibility']) { $list[] = $item; } } } return $list; }
public function renderContent() { // Init linker FromKernel::uses('core/linker.lib'); ResourceLinker::init(); $output = ''; $output .= '<dl id="portletAbout">' . "\n"; $toolIntroIterator = new ToolIntroductionIterator($this->courseCode); if (count($toolIntroIterator) > 0) { $introList = ''; foreach ($toolIntroIterator as $introItem) { if ($introItem->getVisibility() == 'SHOW') { // Display attached resources (if any) $currentLocator = ResourceLinker::$Navigator->getCurrentLocator(array('id' => $introItem->getId())); $currentLocator->setModuleLabel('CLINTRO'); $currentLocator->setResourceId($introItem->getId()); $resources = ResourceLinker::renderLinkList($currentLocator); // Prepare the render $introList .= '<dt>' . "\n" . '</dt>' . "\n" . '<dd' . (!$toolIntroIterator->hasNext() ? ' class="last"' : '') . '>' . "\n" . claro_parse_user_text($introItem->getContent()) . "\n" . $resources . (claro_is_allowed_to_edit() ? '<div class="manageTools"><a href="' . claro_htmlspecialchars(Url::Contextualize(get_module_url('CLTI') . '/index.php?cmd=rqEd&id=' . $introItem->getId())) . '" title="' . get_lang('Edit this item') . '"> <img src="' . get_icon_url('edit') . '" alt="' . get_lang('Edit') . '" /> </a> <a href="' . claro_htmlspecialchars(Url::Contextualize(get_module_url('CLTI') . '/index.php?cmd=exDel&id=' . $introItem->getId())) . '" title="' . get_lang('Delete this item') . '"> <img src="' . get_icon_url('delete') . '" alt="' . get_lang('Delete') . '" /> </a></div>' : '') . '</dd>' . "\n"; } } } if (count($toolIntroIterator) == 0 || empty($introList)) { $output .= '<dt></dt>' . '<dd>' . "\n" . ' ' . get_lang('No headline') . '. ' . (claro_is_allowed_to_edit() ? '<a href="' . claro_htmlspecialchars(Url::Contextualize(get_module_url('CLTI') . '/index.php?cmd=rqAdd')) . '">' . get_lang('Would you like to add one ?') . '</a>' . "\n" : '') . '</dd>' . "\n"; } else { $output .= $introList; } $output .= '</dl>'; return $output; }
?> <div class="item<?php if ($this->intro->getVisibility() != 'SHOW') { ?> hidden<?php } ?> "> <div class="content"> <p><?php echo claro_parse_user_text($this->intro->getContent()); ?> </p> <?php echo ResourceLinker::renderLinkList($this->rsLocator); ?> </div> <?php if (claro_is_allowed_to_edit()) { ?> <div class="manageTools"> <a href="<?php echo claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=rqEd&id=' . $this->intro->getId())); ?> " title="<?php echo get_lang('Edit this item'); ?>
* @author Claroline Team <*****@*****.**> * @author Frederic Minne <*****@*****.**> * @license http://www.gnu.org/copyleft/gpl.html * GNU GENERAL PUBLIC LICENSE version 2 or later * @package core.linker */ try { require_once dirname(__FILE__) . '/../inc/claro_init_global.inc.php'; FromKernel::uses('core/linker.lib', 'utils/ajax.lib', 'utils/input.lib'); ResourceLinker::init(); $userInput = Claro_UserInput::getInstance(); $userInput->setValidator('cmd', new Claro_Validator_AllowedList(array('getLinkList', 'getResourceList', 'resolveLocator'))); $cmd = $userInput->get('cmd', 'getResourceList'); $locator = isset($_REQUEST['crl']) && !empty($_REQUEST['crl']) ? ClarolineResourceLocator::parse(rawurldecode($_REQUEST['crl'])) : ResourceLinker::$Navigator->getCurrentLocator(array()); if ('getLinkList' == $cmd) { $linkListIt = ResourceLinker::getLinkList($locator); // FIXME : use getResourceName instead of the title recorded in database ! if (empty($linkListIt)) { $linkList = array(); } else { $linkList = array(); // $linkList = iterator_to_array( $linkListIt ); foreach ($linkListIt as $link) { $linkList[] = array('crl' => $link['crl'], 'name' => ResourceLinker::$Resolver->getResourceName(ClarolineResourceLocator::parse($link['crl']))); } } $response = new Json_Response($linkList); } elseif ('resolveLocator' == $cmd) { $resourceLinkerResolver = new ResourceLinkerResolver(); $url = $resourceLinkerResolver->resolve($locator); $response = new Json_Response(array('url' => $url));
$output = ''; if (!empty($subTitle)) { $titleParts = array('mainTitle' => $nameTools, 'subTitle' => $subTitle); } else { $titleParts = $nameTools; } Claroline::getDisplay()->body->appendContent(claro_html_tool_title($titleParts, null, $cmdList)); Claroline::getDisplay()->body->appendContent($dialogBox->render()); /** * FORM TO FILL OR MODIFY AN ANNOUNCEMENT */ if ($displayForm) { // DISPLAY ADD ANNOUNCEMENT COMMAND // Ressource linker if ($_REQUEST['cmd'] == 'rqEdit') { ResourceLinker::setCurrentLocator(ResourceLinker::$Navigator->getCurrentLocator(array('id' => (int) $_REQUEST['id']))); } $template = new ModuleTemplate($tlabelReq, 'form.tpl.php'); $template->assign('formAction', Url::Contextualize($_SERVER['PHP_SELF'])); $template->assign('relayContext', claro_form_relay_context()); $template->assign('cmd', $formCmd); $template->assign('announcement', $announcement); Claroline::getDisplay()->body->appendContent($template->render()); } /** * ANNOUNCEMENTS LIST */ if ($displayList) { // Get notification date if (claro_is_user_authenticated()) { $date = $claro_notifier->get_notification_date(claro_get_current_user_id());
if ($toolIntro->save()) { $currentLocator = ResourceLinker::$Navigator->getCurrentLocator(array('id' => (int) $toolIntro->getId())); $resourceList = isset($_REQUEST['resourceList']) ? $_REQUEST['resourceList'] : array(); ResourceLinker::updateLinkList($currentLocator, $resourceList); $dialogBox->success(get_lang('Introduction added')); // Notify that the introsection has been created $claroline->notifier->notifyCourseEvent('introsection_created', claro_get_current_course_id(), claro_get_current_tool_id(), $toolIntro->getId(), claro_get_current_group_id(), '0'); } } elseif ($cmd == 'exEd') { $toolIntro = new ToolIntro($id); $toolIntro->handleForm(); //TODO inputs validation if ($toolIntro->save()) { $currentLocator = ResourceLinker::$Navigator->getCurrentLocator(array('id' => (int) $toolIntro->getId())); $resourceList = isset($_REQUEST['resourceList']) ? $_REQUEST['resourceList'] : array(); ResourceLinker::updateLinkList($currentLocator, $resourceList); $dialogBox->success(get_lang('Introduction modified')); // Notify that the introsection has been modified $claroline->notifier->notifyCourseEvent('introsection_modified', claro_get_current_course_id(), claro_get_current_tool_id(), $toolIntro->getId(), claro_get_current_group_id(), '0'); } } elseif ($cmd == 'exDel') { $toolIntro = new ToolIntro($id); if ($toolIntro->delete()) { $dialogBox->success(get_lang('Introduction deleted')); //TODO linker_delete_resource('CLINTRO_'); } } elseif ($cmd == 'exMvUp') { $toolIntro = new ToolIntro($id); if ($toolIntro->load()) { if ($toolIntro->moveUp()) { $dialogBox->success(get_lang('Introduction moved up'));
" /> <?php echo get_lang('Invisible'); ?> </label> </dt> </dl> </div> </fieldset> <fieldset> <legend><?php echo get_lang('Attached resources'); ?> </legend> <?php echo ResourceLinker::renderLinkerBlock(); ?> </fieldset> <input type="submit" class="claroButton" name="submitEvent" value="<?php echo get_lang('Ok'); ?> " /> <?php echo claro_html_button(claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'])), get_lang('Cancel')); ?> </form> <hr />
public static function init() { if (!self::$_initialized) { self::$Navigator = new ResourceLinkerNavigator(); self::$Resolver = new ResourceLinkerResolver(); self::$_initialized = true; } }
?> <h2><?php echo claro_htmlspecialchars($event['title']); ?> </h2><?php } ?> <?php if (!empty($event['content'])) { echo claro_parse_user_text($event['content']); } ?> </div> <?php echo ResourceLinker::renderLinkList($event['currentLocator']); ?> <?php if (claro_is_allowed_to_edit()) { ?> <div class="manageTools"> <a href="<?php echo claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=rqEdit&id=' . $event['id'])); ?> "> <img src="<?php echo get_icon_url('edit'); ?> " alt="<?php echo get_lang('Modify');
?> </h2><?php } ?> <?php if (!empty($announcement['content'])) { echo claro_parse_user_text($announcement['content']); } ?> </div> <?php if (!empty($announcement['currentLocator'])) { ?> <?php echo ResourceLinker::renderLinkList($announcement['currentLocator']); ?> <?php } ?> <?php if (claro_is_allowed_to_edit()) { ?> <div class="manageTools"> <a href="<?php echo claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=rqEdit&id=' . $announcement['id'])); ?> "> <img src="<?php
} else { foreach ($textIntroList as $thisIntroKey => $thisTextIntro) { $introId = $thisTextIntro['id']; $introVisibility = $thisTextIntro['visibility']; if ($introVisibility == 'SHOW' || $intro_editAllowed) { $cssClass = $introVisibility == 'HIDE' ? ' invisible' : ''; $cssClass = $intro_editAllowed ? ' editable' : ''; $intro_content = claro_parse_user_text($thisTextIntro['content']); $section = ''; if (trim(strip_tags($intro_content, '<img><embed><object>')) != '') { $section .= $intro_content . "\n"; } elseif ($intro_editAllowed) { $section .= '<div style="text-align:center;background-color:silver;margin:3px;">' . get_lang('This zone is empty') . '</div>' . "\n"; } $currentLocator = ResourceLinker::$Navigator->getCurrentLocator(array('id' => $thisTextIntro['id'])); $section .= ResourceLinker::renderLinkList($currentLocator); if ($intro_dispCommand) { $section .= '<div class="toolbar">' . "\n"; $section .= '<a class="claroCmd" href="' . htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?introCmd=rqEd&introId=' . $introId)) . '">' . '<img src="' . get_icon_url('edit') . '" alt="' . get_lang('Edit') . '" />' . '</a>' . "\n" . '<a class="claroCmd" href="' . htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?introCmd=exDel&introId=' . $introId)) . '" ' . 'onclick="javascript:if(!confirm(\'' . clean_str_for_javascript(get_lang('Confirm Operation') . ' : ' . get_lang('Delete')) . '\')) ' . 'return false;">' . '<img src="' . get_icon_url('delete') . '" alt="' . get_lang('Delete') . '" />' . '</a>' . "\n"; if ($thisIntroKey > 0) { $section .= '<a class="claroCmd" href="' . htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?introCmd=exMvUp&introId=' . $introId)) . '">' . '<img src="' . get_icon_url('move_up') . '" alt="' . get_lang('Move up') . '" />' . '</a> '; } if ($thisIntroKey + 1 < $introListCount) { $section .= ' <a class="claroCmd" href="' . htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?introCmd=exMvDown&introId=' . $introId)) . '">' . '<img src="' . get_icon_url('move_down') . '" alt="' . get_lang('Move down') . '" />' . '</a>'; } // Visibility if ($introVisibility == 'SHOW') { $section .= '<a class="claroCmd" href="' . htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?introCmd=mkInvisible&introId=' . $introId)) . '" title="' . get_lang('Click to make invisible') . '">'; $section .= '<img src="' . get_icon_url('visible') . '" alt="' . get_lang('Visible') . '" />'; $section .= '</a>' . "\n"; } else {
/** * Redefines renderLinkerBlock while ResourceLinker::renderLinkerBlock do not allow to pass * bacend url as argument * * @return unknown */ public static function renderLinkerBlock($backendUrl = NULL) { parent::init(); return '<div id="lnk_panel">' . "\n" . '<div id="lnk_ajax_loading"><img src="' . get_icon_url('loading') . '" alt="" /></div>' . "\n" . '<div id="lnk_selected_resources"></div>' . "\n" . '<h4 id="lnk_location"></h4>' . "\n" . '<div id="lnk_back_link"></div>' . '<div id="lnk_resources"></div>' . "\n" . '<div id="lnk_hidden_fields"></div>' . "\n" . '</div>' . "\n\n"; }