/**
  * 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;
 }
Beispiel #2
0
 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&amp;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&amp;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;
 }
Beispiel #3
0
 * CLAROLINE
 *
 * Claroline Resource Linker ajax backend
 *
 * @version     $Revision: 13348 $
 * @copyright   (c) 2001-2011, Universite catholique de Louvain (UCL)
 * @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'])));
            }
Beispiel #4
0
 public function toArray()
 {
     ResourceLinker::init();
     $parent = ResourceLinker::$Navigator->getParent($this->getLocator());
     $locator = $this->getLocator();
     if ($locator instanceof ExternalResourceLocator) {
         $clext_resolver = new CLEXT_Resolver();
         return array('name' => $clext_resolver->getResourceName($locator), 'icon' => get_icon_url('link'), 'crl' => $this->getLocator()->__toString(), 'parent' => false, 'isVisible' => true, 'isLinkable' => $this->isLinkable() ? true : false, 'isNavigable' => false);
     } else {
         if ($locator->inModule()) {
             $moduleIcon = get_module_data($locator->getModuleLabel(), 'icon');
             $iconUrl = get_module_url($locator->getModuleLabel()) . '/' . $moduleIcon;
         } elseif ($locator->inGroup()) {
             $iconUrl = get_icon_url('group');
         } elseif ($locator->inCourse()) {
             $iconUrl = get_icon_url('course');
         } else {
             $iconUrl = get_icon_url('forbidden');
         }
         return array('name' => $this->getName(), 'icon' => $iconUrl, 'crl' => $this->getLocator()->__toString(), 'parent' => !empty($parent) ? $parent->__toString() : false, 'isVisible' => $this->isVisible() ? true : false, 'isLinkable' => $this->isLinkable() ? true : false, 'isNavigable' => $this->isNavigable() ? true : false);
     }
 }
Beispiel #5
0
 /**
  * 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";
 }