|
|
|
@ -964,20 +964,21 @@ class Link extends Model |
|
|
|
|
/** |
|
|
|
|
* Displays all the links of a given category. |
|
|
|
|
* |
|
|
|
|
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University |
|
|
|
|
* @author Julio Montoya |
|
|
|
|
* |
|
|
|
|
* @param $catid |
|
|
|
|
* @param int $courseId |
|
|
|
|
* @param int $session_id |
|
|
|
|
* @param int $catid |
|
|
|
|
* @param int $courseId |
|
|
|
|
* @param int $session_id |
|
|
|
|
* @param bool $showActionLinks |
|
|
|
|
* |
|
|
|
|
* @return string |
|
|
|
|
* @author Julio Montoya |
|
|
|
|
* |
|
|
|
|
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University |
|
|
|
|
*/ |
|
|
|
|
public static function showLinksPerCategory($catid, $courseId, $session_id) |
|
|
|
|
public static function showLinksPerCategory($catid, $courseId, $session_id, $showActionLinks = true) |
|
|
|
|
{ |
|
|
|
|
global $token; |
|
|
|
|
$_user = api_get_user_info(); |
|
|
|
|
$catid = intval($catid); |
|
|
|
|
$catid = (int) $catid; |
|
|
|
|
|
|
|
|
|
$links = self::getLinksPerCategory($catid, $courseId, $session_id); |
|
|
|
|
$content = ''; |
|
|
|
@ -1137,7 +1138,9 @@ class Link extends Model |
|
|
|
|
); |
|
|
|
|
$url = api_get_path(WEB_CODE_PATH).'link/link_goto.php?'.api_get_cidreq().'&link_id='.$linkId.'&link_url='.urlencode($myrow['url']); |
|
|
|
|
$content .= '<div class="list-group-item">'; |
|
|
|
|
$content .= '<div class="pull-right"><div class="btn-group">'.$toolbar.'</div></div>'; |
|
|
|
|
if ($showActionLinks) { |
|
|
|
|
$content .= '<div class="pull-right"><div class="btn-group">'.$toolbar.'</div></div>'; |
|
|
|
|
} |
|
|
|
|
$content .= '<h4 class="list-group-item-heading">'; |
|
|
|
|
$content .= $iconLink; |
|
|
|
|
$content .= Display::tag( |
|
|
|
@ -1558,42 +1561,68 @@ class Link extends Model |
|
|
|
|
* @param int $categoryId |
|
|
|
|
* @param string $show |
|
|
|
|
* @param null $token |
|
|
|
|
* @param bool $showActionLinks |
|
|
|
|
* |
|
|
|
|
* @return string |
|
|
|
|
*/ |
|
|
|
|
public static function listLinksAndCategories( |
|
|
|
|
$course_id, |
|
|
|
|
$session_id, |
|
|
|
|
$categoryId, |
|
|
|
|
$show = 'none', |
|
|
|
|
$token = null |
|
|
|
|
$token = null, |
|
|
|
|
$showActionLinks = true |
|
|
|
|
) { |
|
|
|
|
$categoryId = (int) $categoryId; |
|
|
|
|
|
|
|
|
|
/* Action Links */ |
|
|
|
|
echo '<div class="actions">'; |
|
|
|
|
if (api_is_allowed_to_edit(null, true)) { |
|
|
|
|
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addlink&category_id='.$categoryId.'">'. |
|
|
|
|
Display::return_icon('new_link.png', get_lang('LinkAdd'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addcategory&category_id='.$categoryId.'">'. |
|
|
|
|
Display::return_icon('new_folder.png', get_lang('CategoryAdd'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
} |
|
|
|
|
$content = ''; |
|
|
|
|
|
|
|
|
|
$categories = self::getLinkCategories($course_id, $session_id); |
|
|
|
|
$countCategories = count($categories); |
|
|
|
|
if (!empty($countCategories)) { |
|
|
|
|
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=list&show=none">'; |
|
|
|
|
echo Display::return_icon('forum_listview.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM).' </a>'; |
|
|
|
|
$linksPerCategory = self::showLinksPerCategory(0, $course_id, $session_id, $showActionLinks); |
|
|
|
|
|
|
|
|
|
if ($showActionLinks) { |
|
|
|
|
/* Action Links */ |
|
|
|
|
$content = '<div class="actions">'; |
|
|
|
|
if (api_is_allowed_to_edit(null, true)) { |
|
|
|
|
$content .= '<a href="'.api_get_self().'?'.api_get_cidreq( |
|
|
|
|
).'&action=addlink&category_id='.$categoryId.'">'. |
|
|
|
|
Display::return_icon('new_link.png', get_lang('LinkAdd'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
$content .= '<a href="'.api_get_self().'?'.api_get_cidreq( |
|
|
|
|
).'&action=addcategory&category_id='.$categoryId.'">'. |
|
|
|
|
Display::return_icon('new_folder.png', get_lang('CategoryAdd'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=list&show=all">'; |
|
|
|
|
echo Display::return_icon('forum_nestedview.png', get_lang('NestedView'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
if (!empty($countCategories)) { |
|
|
|
|
$content .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=list&show=none">'; |
|
|
|
|
$content .= Display::return_icon( |
|
|
|
|
'forum_listview.png', |
|
|
|
|
get_lang('FlatView'), |
|
|
|
|
'', |
|
|
|
|
ICON_SIZE_MEDIUM |
|
|
|
|
).' </a>'; |
|
|
|
|
|
|
|
|
|
$content .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=list&show=all">'; |
|
|
|
|
$content .= Display::return_icon( |
|
|
|
|
'forum_nestedview.png', |
|
|
|
|
get_lang('NestedView'), |
|
|
|
|
'', |
|
|
|
|
ICON_SIZE_MEDIUM |
|
|
|
|
).'</a>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$content .= Display::url( |
|
|
|
|
Display::return_icon('pdf.png', get_lang('ExportToPdf'), '', ICON_SIZE_MEDIUM), |
|
|
|
|
api_get_self().'?'.api_get_cidreq().'&action=export' |
|
|
|
|
); |
|
|
|
|
$content .= '</div>'; |
|
|
|
|
} |
|
|
|
|
echo '</div>'; |
|
|
|
|
$linksPerCategory = self::showLinksPerCategory(0, $course_id, $session_id); |
|
|
|
|
|
|
|
|
|
if (empty($countCategories)) { |
|
|
|
|
echo $linksPerCategory; |
|
|
|
|
$content .= $linksPerCategory; |
|
|
|
|
} else { |
|
|
|
|
if (!empty($linksPerCategory)) { |
|
|
|
|
echo Display::panel($linksPerCategory, get_lang('NoCategory')); |
|
|
|
|
$content .= Display::panel($linksPerCategory, get_lang('NoCategory')); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1629,16 +1658,16 @@ class Link extends Model |
|
|
|
|
$header .= '<a class="'.$visibilityClass.'" href="'.api_get_self().'?'.api_get_cidreq().'&category_id='.$myrow['id'].'">'; |
|
|
|
|
$header .= Display::return_icon('forum_listview.png'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$header .= Security::remove_XSS($myrow['category_title']).'</a>'; |
|
|
|
|
$header .= '<div class="pull-right">'; |
|
|
|
|
|
|
|
|
|
if (api_is_allowed_to_edit(null, true)) { |
|
|
|
|
if ($session_id == $myrow['session_id']) { |
|
|
|
|
$header .= $strVisibility; |
|
|
|
|
$header .= self::showCategoryAdminTools($myrow, $counter, count($categories)); |
|
|
|
|
} else { |
|
|
|
|
$header .= get_lang('EditionNotAvailableFromSession'); |
|
|
|
|
if ($showActionLinks) { |
|
|
|
|
if (api_is_allowed_to_edit(null, true)) { |
|
|
|
|
if ($session_id == $myrow['session_id']) { |
|
|
|
|
$header .= $strVisibility; |
|
|
|
|
$header .= self::showCategoryAdminTools($myrow, $counter, count($categories)); |
|
|
|
|
} else { |
|
|
|
|
$header .= get_lang('EditionNotAvailableFromSession'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1651,10 +1680,12 @@ class Link extends Model |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
echo Display::panel($myrow['description'].$childrenContent, $header); |
|
|
|
|
$content .= Display::panel($myrow['description'].$childrenContent, $header); |
|
|
|
|
|
|
|
|
|
$counter++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $content; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|