Setting link target _blank by default see BT#4358

skala
Julio Montoya 13 years ago
parent f0f03abbf4
commit 2a332409ff
  1. 172
      main/inc/lib/link.lib.php
  2. 83
      main/link/link.php

@ -26,18 +26,18 @@ class Link extends Model {
var $is_course_model = true;
var $columns = array('id', 'c_id','url','title','description','category_id', 'display_order', 'on_homepage', 'target', 'session_id');
var $required = array('url', 'title');
public function __construct() {
$this->table = Database::get_course_table(TABLE_LINK);
}
public function save($params) {
$course_info = api_get_course_info();
$course_info = api_get_course_info();
$params['session_id'] = api_get_session_id();
$params['category_id'] = isset($params['category_id']) ? $params['category_id'] : 0;
$id = parent::save($params);
if (!empty($id)) {
$id = parent::save($params);
if (!empty($id)) {
api_item_property_update($course_info, TOOL_LINK, $id, 'LinkAdded', api_get_user_id());
}
return $id;
@ -56,8 +56,8 @@ function addlinkcategory($type) {
global $msgErr;
$ok = true;
$course_id = api_get_course_int_id();
$course_id = api_get_course_int_id();
if ($type == 'link') {
$tbl_link = Database :: get_course_table(TABLE_LINK);
@ -68,11 +68,11 @@ function addlinkcategory($type) {
$selectcategory = Security :: remove_XSS($_POST['selectcategory']);
if ($_POST['onhomepage'] == '') {
$onhomepage = 0;
$onhomepage = 0;
} else {
$onhomepage = Security :: remove_XSS($_POST['onhomepage']);
$onhomepage = Security :: remove_XSS($_POST['onhomepage']);
}
if (empty($_POST['target_link'])) {
$target = '_self'; // Default target.
} else {
@ -96,7 +96,7 @@ function addlinkcategory($type) {
// If the URL is invalid, an error occurs.
// Ivan, 13-OCT-2010, Chamilo 1.8.8: Let us still tolerate PHP 5.1.x and avoid a specific bug in filter_var(), see http://bugs.php.net/51192
//if (!filter_var($urllink, FILTER_VALIDATE_URL)) {
if (!api_valid_url($urllink, true)) { // A check against an absolute URL
if (!api_valid_url($urllink, true)) { // A check against an absolute URL
$msgErr = get_lang('GiveURL');
Display :: display_error_message(get_lang('GiveURL'));
$ok = false;
@ -109,11 +109,11 @@ function addlinkcategory($type) {
$session_id = api_get_session_id();
$sql = "INSERT INTO " . $tbl_link . " (c_id, url, title, description, category_id, display_order, on_homepage, target, session_id)
VALUES (".$course_id.", '".Database :: escape_string($urllink) . "','" . Database :: escape_string($title) . "','" . Database :: escape_string($description) . "','" .
VALUES (".$course_id.", '".Database :: escape_string($urllink) . "','" . Database :: escape_string($title) . "','" . Database :: escape_string($description) . "','" .
Database :: escape_string($selectcategory) . "','" . Database :: escape_string($order) . "', '" . Database :: escape_string($onhomepage) . "','" .
Database :: escape_string($target) . "','" . Database :: escape_string($session_id) . "')";
$catlinkstatus = get_lang('LinkAdded');
$catlinkstatus = get_lang('LinkAdded');
Database :: query($sql);
$link_id = Database :: insert_id();
@ -153,7 +153,7 @@ function addlinkcategory($type) {
'link_id' => (int) $link_id
),
SE_USER => (int) api_get_user_id(),
);
$ic_slide->xapian_data = serialize($xapian_data);
$description = $all_specific_terms . ' ' . $description;
@ -207,7 +207,7 @@ function addlinkcategory($type) {
$order = $orderMax +1;
$order = intval($order);
$session_id = api_get_session_id();
$sql = "INSERT INTO ".$tbl_categories." (c_id, category_title, description, display_order, session_id)
$sql = "INSERT INTO ".$tbl_categories." (c_id, category_title, description, display_order, session_id)
VALUES (".$course_id.", '" .Database::escape_string($category_title) . "', '" . Database::escape_string($description) . "', '$order', '$session_id')";
Database :: query($sql);
@ -233,11 +233,11 @@ function addlinkcategory($type) {
*/
function deletelinkcategory($type) {
global $catlinkstatus;
global $_course;
global $_course;
$tbl_link = Database :: get_course_table(TABLE_LINK);
$tbl_categories = Database :: get_course_table(TABLE_LINK_CATEGORY);
$TABLE_ITEM_PROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$course_id = api_get_course_int_id();
if ($type == 'link') {
@ -301,19 +301,19 @@ function delete_link_from_search_engine($course_id, $link_id) {
/**
*
*
* Get link info
* @param int link id
* @return array link info
*
* @return array link info
*
* */
function get_link_info($id) {
$tbl_link = Database :: get_course_table(TABLE_LINK);
$course_id = api_get_course_int_id();
$sql = "SELECT * FROM " . $tbl_link . " WHERE c_id = $course_id AND id='" . intval($id) . "' ";
$result = Database::query($sql);
if (Database::num_rows($result)) {
$data = Database::fetch_array($result);
}
@ -350,7 +350,7 @@ function editlinkcategory($type) {
$tbl_link = Database :: get_course_table(TABLE_LINK);
$tbl_categories = Database :: get_course_table(TABLE_LINK_CATEGORY);
$course_id = api_get_course_int_id();
if ($type == 'link') {
@ -483,7 +483,7 @@ function editlinkcategory($type) {
'link_id' => (int) $link_id
),
SE_USER => (int) api_get_user_id(),
);
$ic_slide->xapian_data = serialize($xapian_data);
$link_description = $all_specific_terms . ' ' . $link_description;
@ -541,7 +541,7 @@ function editlinkcategory($type) {
// This is used to put the modified info of the category-form into the database.
if ($submit_category) {
$sql = "UPDATE " . $tbl_categories . " SET category_title='" . Database :: escape_string($_POST['category_title']) . "', description='" . Database :: escape_string($_POST['description']) . "'
$sql = "UPDATE " . $tbl_categories . " SET category_title='" . Database :: escape_string($_POST['category_title']) . "', description='" . Database :: escape_string($_POST['description']) . "'
WHERE c_id = $course_id AND id='" . Database :: escape_string($_POST['id']) . "'";
Database :: query($sql);
Display :: display_confirmation_message(get_lang('CategoryModded'));
@ -568,7 +568,7 @@ function makedefaultviewcode($locatie) {
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
*/
function change_visibility($id, $scope) {
global $_course, $_user;
global $_course, $_user;
if ($scope == 'link') {
api_item_property_update($_course, TOOL_LINK, $id, $_GET['action'], $_user['user_id']);
Display :: display_confirmation_message(get_lang('VisibilityChanged'));
@ -589,17 +589,17 @@ function showlinksofcategory($catid) {
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id, true, true);
$catid = intval($catid);
$course_id = api_get_course_int_id();
$sqlLinks = "SELECT *, link.id FROM " . $tbl_link . " link, " . $TABLE_ITEM_PROPERTY . " itemproperties
$course_id = api_get_course_int_id();
$sqlLinks = "SELECT *, link.id FROM " . $tbl_link . " link, " . $TABLE_ITEM_PROPERTY . " itemproperties
WHERE itemproperties.tool='" . TOOL_LINK . "' AND
link.id=itemproperties.ref AND
link.category_id='" . $catid . "' AND
(itemproperties.visibility='0' OR itemproperties.visibility='1')
link.id=itemproperties.ref AND
link.category_id='" . $catid . "' AND
(itemproperties.visibility='0' OR itemproperties.visibility='1')
$condition_session AND
link.c_id = ".$course_id." AND
itemproperties.c_id = ".$course_id."
itemproperties.c_id = ".$course_id."
ORDER BY link.display_order DESC";
$result = Database :: query($sqlLinks);
$numberoflinks = Database :: num_rows($result);
@ -607,49 +607,49 @@ function showlinksofcategory($catid) {
echo '<table class="data_table" width="100%">';
$i = 1;
while ($myrow = Database :: fetch_array($result)) {
// Validacion when belongs to a session.
$session_img = api_get_session_image($myrow['session_id'], $_user['status']);
$css_class = $i % 2 == 0 ? $css_class = 'row_odd' : $css_class = 'row_even';
$link_validator = '';
if (api_is_allowed_to_edit(null, true)) {
$link_validator = ''.Display::url(Display::return_icon('preview_view.png', get_lang('CheckURL'), array(), 16), '#', array('onclick'=>"check_url('".$myrow['id']."', '".addslashes($myrow['url'])."');"));
$link_validator = ''.Display::url(Display::return_icon('preview_view.png', get_lang('CheckURL'), array(), 16), '#', array('onclick'=>"check_url('".$myrow['id']."', '".addslashes($myrow['url'])."');"));
$link_validator .= Display::span('', array('id'=>'url_id_'.$myrow['id']));
}
if ($myrow['visibility'] == '1') {
echo '<tr class="'.$css_class.'">';
echo '<td align="center" valign="middle" width="15">';
echo '<a href="link_goto.php?', api_get_cidreq(), '&amp;link_id=', $myrow['id'], '&amp;link_url=', urlencode($myrow['url']), '" target="_blank">
<img src="../../main/img/link.gif" border="0" alt="', get_lang('Link'), '"/></a></td>
<td width="80%" valign="top"><a href="link_goto.php?', api_get_cidreq(), '&amp;link_id=', $myrow['id'], '&amp;link_url=', urlencode($myrow['url']), '" target="', $myrow['target'], '">';
echo '<a href="link_goto.php?'.api_get_cidreq().'&amp;link_id='.$myrow['id'].'&amp;link_url='.urlencode($myrow['url']).'" target="_blank">
<img src="../../main/img/link.gif" border="0" alt="'.get_lang('Link').'"/></a></td>
<td width="80%" valign="top"><a href="link_goto.php?'.api_get_cidreq().'&amp;link_id='.$myrow['id'].'&amp;link_url='.urlencode($myrow['url']).'" target="'.$myrow['target'].'">';
echo Security :: remove_XSS($myrow['url']);
echo '</a>';
echo '</a>';
echo $link_validator;
echo $session_img;
echo '<br />', $myrow['title'];
echo '<br />'.$myrow['title'];
} else {
if (api_is_allowed_to_edit(null, true)) {
echo '<tr class="'.$css_class.'">';
echo '<td align="center" valign="middle" width="15"><a href="link_goto.php?', api_get_cidreq(), '&amp;link_id=', $myrow['id'], "&amp;link_url=", urlencode($myrow['url']), '" target="_blank" class="invisible">';
echo '<td align="center" valign="middle" width="15"><a href="link_goto.php?'.api_get_cidreq().'&amp;link_id='.$myrow['id']."&amp;link_url=".urlencode($myrow['url']).'" target="_blank" class="invisible">';
echo Display :: return_icon('link_na.gif', get_lang('Link')), '</a>';
echo '</td><td width="80%" valign="top"><a href="link_goto.php?', api_get_cidreq(), '&amp;link_id=', $myrow['id'], '&amp;link_url=', urlencode($myrow['url']),'" target="', $myrow['target'], '" class="invisible">';
echo Security :: remove_XSS($myrow['url']);
echo "</a>";
echo $link_validator;
echo $link_validator;
echo $session_img, '<br />', $myrow['title'];
}
}
echo '<td style="text-align:center;">';
if (api_is_allowed_to_edit(null, true)) {
if ($session_id == $myrow['session_id']) {
echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;sec_token='.$token.'&amp;action=editlink&amp;category=' . (!empty ($category) ? $category : '') . '&amp;id=' . $myrow['id'] . '&amp;urlview=' . $urlview . '" title="' . get_lang('Modify') . '">' .
if ($session_id == $myrow['session_id']) {
echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;sec_token='.$token.'&amp;action=editlink&amp;category=' . (!empty ($category) ? $category : '') . '&amp;id=' . $myrow['id'] . '&amp;urlview=' . $urlview . '" title="' . get_lang('Modify') . '">' .
Display :: return_icon('edit.png', get_lang('Modify'), array (), ICON_SIZE_SMALL) . '</a>';
// DISPLAY MOVE UP COMMAND only if it is not the top link.
/*
if ($i != 1) {
@ -657,25 +657,25 @@ function showlinksofcategory($catid) {
} else {
echo Display :: return_icon('up_na.png', get_lang('Up'), array (), ICON_SIZE_SMALL) . '</a>';
}
// DISPLAY MOVE DOWN COMMAND only if it is not the bottom link.
if ($i < $numberoflinks) {
echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;sec_token='.$token.'&amp;urlview=' . $urlview . '&amp;down=' . $myrow[0] . '" title="' . get_lang('Down') . '">' . Display :: return_icon('down.png', get_lang('Down'), array (), ICON_SIZE_SMALL) . '', "</a>\n";
} else {
echo Display :: return_icon('down_na.png', get_lang('Down'), array (), ICON_SIZE_SMALL) . '', "</a>\n";
}*/
if ($myrow['visibility'] == '1') {
echo '<a href="link.php?' . api_get_cidreq() . '&amp;sec_token='.$token.'&amp;action=invisible&amp;id=' . $myrow['id'] . '&amp;scope=link&amp;urlview=' . $urlview . '" title="' . get_lang('Hide') . '">' .
echo '<a href="link.php?' . api_get_cidreq() . '&amp;sec_token='.$token.'&amp;action=invisible&amp;id=' . $myrow['id'] . '&amp;scope=link&amp;urlview=' . $urlview . '" title="' . get_lang('Hide') . '">' .
Display :: return_icon('visible.png', get_lang('Hide'), array (), ICON_SIZE_SMALL) . '</a>';
}
if ($myrow['visibility'] == '0') {
echo ' <a href="link.php?' . api_get_cidreq() . '&amp;sec_token='.$token.'&amp;action=visible&amp;id=' . $myrow['id'] . '&amp;scope=link&amp;urlview=' . $urlview . '" title="' . get_lang('Show') . '">' .
echo ' <a href="link.php?' . api_get_cidreq() . '&amp;sec_token='.$token.'&amp;action=visible&amp;id=' . $myrow['id'] . '&amp;scope=link&amp;urlview=' . $urlview . '" title="' . get_lang('Show') . '">' .
Display :: return_icon('invisible.png', get_lang('Show'), array (), ICON_SIZE_SMALL) . '</a>';
}
echo ' <a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;sec_token='.$token.'&amp;action=deletelink&amp;id=', $myrow['id'], '&amp;urlview=', $urlview, "\" onclick=\"javascript: if(!confirm('" . get_lang('LinkDelconfirm') . "')) return false;\" title=\"" . get_lang('Delete') . '">' .
echo ' <a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;sec_token='.$token.'&amp;action=deletelink&amp;id=', $myrow['id'], '&amp;urlview=', $urlview, "\" onclick=\"javascript: if(!confirm('" . get_lang('LinkDelconfirm') . "')) return false;\" title=\"" . get_lang('Delete') . '">' .
Display :: return_icon('delete.png', get_lang('Delete'), array (), ICON_SIZE_SMALL) . '</a>';
} else {
echo Display :: return_icon('edit_na.png', get_lang('EditionNotAvailableFromSession'), array (), ICON_SIZE_SMALL); //get_lang('EditionNotAvailableFromSession');
}
@ -695,21 +695,21 @@ function showcategoryadmintools($categoryid) {
global $urlview, $aantalcategories, $catcounter, $token;
echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;sec_token='.$token.'&amp;action=editcategory&amp;id=' . $categoryid . '&amp;urlview=' . $urlview . '" title=' . get_lang('Modify') . '">' . Display :: return_icon('edit.png', get_lang('Modify'), array (), ICON_SIZE_SMALL) . '</a>';
// DISPLAY MOVE UP COMMAND only if it is not the top link.
if ($catcounter != 1) {
echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;sec_token='.$token.'&amp;catmove=true&amp;up=', $categoryid, '&amp;urlview=' . $urlview . '" title="' . get_lang('Up') . '">' . Display :: return_icon('up.png', get_lang('Up'), array (), ICON_SIZE_SMALL) . '</a>';
} else {
echo Display :: return_icon('up_na.png', get_lang('Up'), array (), ICON_SIZE_SMALL) . '</a>';
}
// DISPLAY MOVE DOWN COMMAND only if it is not the bottom link.
if ($catcounter < $aantalcategories) {
echo '<a href="' . api_get_self() . '?' . api_get_cidreq() .'&amp;sec_token='.$token.'&amp;catmove=true&amp;down=' . $categoryid . '&amp;urlview=' . $urlview . '">
' . Display :: return_icon('down.png', get_lang('Down'), array (), ICON_SIZE_SMALL) . '</a>';
} else {
echo Display :: return_icon('down_na.png', get_lang('Down'), array (), ICON_SIZE_SMALL) . '</a>';
}
}
echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;sec_token='.$token.'&amp;action=deletecategory&amp;id=', $categoryid, "&amp;urlview=$urlview\" onclick=\"javascript: if(!confirm('" . get_lang('CategoryDelconfirm') . "')) return false;\">", Display :: return_icon('delete.png', get_lang('Delete'), array (), ICON_SIZE_SMALL) . '</a>';
$catcounter++;
}
@ -751,16 +751,16 @@ function movecatlink($catlinkid) {
// This code is copied and modified from announcements.php.
if (!empty($sortDirection)) {
if (!in_array(trim(strtoupper($sortDirection)), array ('ASC', 'DESC'))){
$sortDirection = 'ASC';
}
if ($catmove == 'true') {
$sqlcatlinks = "SELECT id, display_order FROM " . $movetable . " WHERE c_id = $course_id ORDER BY display_order $sortDirection";
} else {
$sqlcatlinks = "SELECT id, display_order FROM " . $movetable . "
WHERE c_id = $course_id AND category_id='" . $catid[0] . "'
$sqlcatlinks = "SELECT id, display_order FROM " . $movetable . "
WHERE c_id = $course_id AND category_id='" . $catid[0] . "'
ORDER BY display_order $sortDirection";
}
$linkresult = Database :: query($sqlcatlinks);
@ -800,7 +800,7 @@ function get_cat($catname) {
// Get category id (existing or make new).
$tbl_categories = Database :: get_course_table(TABLE_LINK_CATEGORY);
$course_id = api_get_course_int_id();
$result = Database :: query("SELECT id FROM " . $tbl_categories . " WHERE c_id = $course_id AND category_title='" . Database::escape_string($catname) . "'");
if (Database :: num_rows($result) >= 1 && ($row = Database :: fetch_array($result))) {
return $row['id']; // Several categories with same name: take the first.
@ -808,7 +808,7 @@ function get_cat($catname) {
$result = Database :: query("SELECT MAX(display_order) FROM " . $tbl_categories);
list ($max_order) = Database :: fetch_row($result);
Database :: query("INSERT INTO " . $tbl_categories . " (c_id, category_title, description, display_order)
Database :: query("INSERT INTO " . $tbl_categories . " (c_id, category_title, description, display_order)
VALUES (".$course_id.", '" . Database::escape_string($catname) . "','','" . ($max_order +1) . "')");
return Database :: insert_id();
}
@ -819,9 +819,9 @@ function get_cat($catname) {
*/
function put_link($url, $cat, $title, $description, $on_homepage, $hidden) {
$tbl_link = Database :: get_course_table(TABLE_LINK);
$course_id = api_get_course_int_id();
$urleq = "url='" . Database :: escape_string($url) . "'";
$cateq = "category_id=" . intval($cat);
@ -829,7 +829,7 @@ function put_link($url, $cat, $title, $description, $on_homepage, $hidden) {
$result = Database :: query("SELECT id FROM $tbl_link WHERE c_id = $course_id AND " . $urleq . ' AND ' . $cateq);
if (Database :: num_rows($result) >= 1 && ($row = Database :: fetch_array($result))) {
Database :: query("UPDATE $tbl_link set title='" . Database :: escape_string($title) . "', description='" . Database :: escape_string($description) . "'
Database :: query("UPDATE $tbl_link set title='" . Database :: escape_string($title) . "', description='" . Database :: escape_string($description) . "'
WHERE c_id = $course_id AND id='" . Database :: escape_string($row['id']) . "'");
$ipu = 'LinkUpdated';
@ -839,7 +839,7 @@ function put_link($url, $cat, $title, $description, $on_homepage, $hidden) {
$result = Database :: query("SELECT MAX(display_order) FROM $tbl_link WHERE c_id = $course_id AND category_id='" . intval($cat) . "'");
list ($max_order) = Database :: fetch_row($result);
Database :: query("INSERT INTO $tbl_link (c_id, url, title, description, category_id, display_order, on_homepage)
Database :: query("INSERT INTO $tbl_link (c_id, url, title, description, category_id, display_order, on_homepage)
VALUES (".api_get_course_int_id().", '" . Database :: escape_string($url) . "','" . Database :: escape_string($title) . "','" . Database :: escape_string($description) . "','" . intval($cat) . "','" . (intval($max_order) + 1) . "','" . intval($on_homepage) . "')");
$id = Database :: insert_id();
@ -970,7 +970,7 @@ function import_csvfile() {
/**
* This function checks if the url is a youtube link
* @author Jorge Frisancho
* @author Julio Montoya - Fixing code
* @author Julio Montoya - Fixing code
* @version 1.0
*/
function is_youtube_link($url) {
@ -983,34 +983,34 @@ function get_youtube_video_id($url) {
$len = 11;
// The ID string starts after "v=", which is usually right after
// "youtube.com/watch?" in the URL
$pos = strpos($url, "v=");
// "youtube.com/watch?" in the URL
$pos = strpos($url, "v=");
$id = '';
//If false try other options
if ($pos === false) {
if ($pos === false) {
$url_parsed = parse_url($url);
//Youtube shortener
//http://youtu.be/ID
//http://youtu.be/ID
$pos = strpos($url, "youtu.be");
if ($pos == false) {
$id = '';
} else {
} else {
return substr($url_parsed['path'], 1);
}
}
//if empty try the youtube.com/embed/ID
if (empty($id)) {
$pos = strpos($url, "embed");
if ($pos === false) {
return '';
} else {
} else {
return substr($url_parsed['path'], 7);
}
}
}
}
} else {
// Offset the start location to match the beginning of the ID string
$pos += 2;

@ -41,12 +41,12 @@ $htmlHeadXtra[] = '<script type="text/javascript">
}
}
});
function check_url(id, url) {
var url = "'.api_get_path(WEB_AJAX_PATH).'link.ajax.php?a=check_url&url=" +url;
var loading = " '.addslashes(Display::return_icon('loading1.gif')).'";
$("#url_id_"+id).html(loading);
$("#url_id_"+id).load(url);
$("#url_id_"+id).html(loading);
$("#url_id_"+id).load(url);
}
</script>';
@ -122,21 +122,21 @@ function MM_popupMsg(msg) { //v1.0
$nameTools = get_lang('Links');
if (isset($_GET['action'])) {
$check_token = Security::check_token('request');
$check_token = Security::check_token('request');
if ($check_token) {
switch ($_GET['action']) {
case 'addlink':
if ($link_submitted) {
if (!addlinkcategory("link")) { // Here we add a link
unset($submit_link);
}
}
}
break;
case 'addcategory':
if ($category_submitted) {
if (!addlinkcategory('category')) { // Here we add a category
unset($submit_category);
}
}
}
break;
case 'importcsv':
@ -144,14 +144,14 @@ if (isset($_GET['action'])) {
import_csvfile();
}
break;
case 'deletelink':
deletelinkcategory('link'); // Here we delete a link
case 'deletelink':
deletelinkcategory('link'); // Here we delete a link
break;
case 'deletecategory':
deletelinkcategory('category'); // Here we delete a category
deletelinkcategory('category'); // Here we delete a category
break;
case 'editlink':
editlinkcategory('link'); // Here we edit a link
editlinkcategory('link'); // Here we edit a link
break;
case 'editcategory':
editlinkcategory('category'); // Here we edit a category
@ -174,34 +174,35 @@ Display::display_introduction_section(TOOL_LINK);
if (api_is_allowed_to_edit(null, true) && isset($_GET['action'])) {
echo '<div class="actions">';
if (!empty($_GET['lp_id']) || !empty($_POST['lp_id'])){
if (!empty($_POST['lp_id'])){
if (!empty($_GET['lp_id']) || !empty($_POST['lp_id'])){
if (!empty($_POST['lp_id'])){
$lp_id = Security::remove_XSS($_POST['lp_id']);
} else {
$lp_id = Security::remove_XSS($_GET['lp_id']);
}
echo "<a href=\"../newscorm/lp_controller.php?".api_get_cidreq()."&gradebook=&action=add_item&type=step&lp_id=".$lp_id."#resource_tab-3\">".Display::return_icon('back.png', get_lang("BackTo").' '.get_lang("LearningPaths"),'',ICON_SIZE_MEDIUM)."</a>";
}
echo "<a href=\"../newscorm/lp_controller.php?".api_get_cidreq()."&gradebook=&action=add_item&type=step&lp_id=".$lp_id."#resource_tab-3\">".Display::return_icon('back.png', get_lang("BackTo").' '.get_lang("LearningPaths"),'',ICON_SIZE_MEDIUM)."</a>";
} else {
//echo '<a href="link.php?cidReq='.Security::remove_XSS($_GET['cidReq']).'&amp;urlview='.Security::remove_XSS($_GET['urlview']).'">'.Display::return_icon('back.png', get_lang('BackToLinksOverview'),'',ICON_SIZE_MEDIUM).'</a>';
}
}
echo '</div>';
// Displaying the correct title and the form for adding a category or link. This is only shown when nothing
// has been submitted yet, hence !isset($submit_link)
if (($_GET['action'] == 'addlink' || $_GET['action'] == 'editlink') && empty($_POST['submitLink'])) {
if ($category == '') {
$category = 0;
}
}
echo '<form class="form-horizontal" method="post" action="'.api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&amp;urlview='.Security::remove_XSS($urlview).'">';
if ($_GET['action'] == 'addlink') {
echo '<legend>'.get_lang('LinkAdd').'</legend>';
} else {
echo '<legend>'.get_lang('LinkMod').'</legend>';
}
}
echo '<input type="hidden" name="sec_token" value="'.$token.'" />';
if ($_GET['action'] == 'editlink') {
$clean_link_id = intval($_GET['id']);
$link_info = get_link_info($_GET['id']);
@ -216,9 +217,11 @@ if (api_is_allowed_to_edit(null, true) && isset($_GET['action'])) {
}
$target_link = $link_info['target'];
}
echo '<input type="hidden" name="id" value="'.$clean_link_id.'" />';
}
} else {
$target_link = "_blank";
}
echo ' <div class="control-group">
<label class="control-label">
<span class="form_required">*</span> URL
@ -275,7 +278,7 @@ if (api_is_allowed_to_edit(null, true) && isset($_GET['action'])) {
</div>';
}
echo ' <div class="control-group">
<label class="control-label">
<label class="control-label">
</label>
<div class="controls">
<input class="checkbox" type="checkbox" name="onhomepage" id="onhomepage" value="1"'.$onhomepage.'><label for="onhomepage"> '.get_lang('OnHomepage').'?</label>
@ -290,7 +293,7 @@ if (api_is_allowed_to_edit(null, true) && isset($_GET['action'])) {
$targets = array('_self'=>get_lang('LinkOpenSelf'),'_blank'=>get_lang('LinkOpenBlank'),'_parent'=>get_lang('LinkOpenParent'),'_top'=>get_lang('LinkOpenTop'));
foreach ($targets as $target_id => $target) {
$selected = '';
if ($target_id == $target_link) {
if ($target_id == $target_link) {
$selected = ' selected="selected"';
}
echo ' <option value="'.$target_id.'"'.$selected.'>'.$target.'</option> ';
@ -301,17 +304,17 @@ if (api_is_allowed_to_edit(null, true) && isset($_GET['action'])) {
</span>
</div>
</div>';
if (api_get_setting('search_enabled') == 'true') {
require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
$specific_fields = get_specific_field_list();
echo ' <div class="control-group">
<label class="control-label">
'.get_lang('SearchFeatureDoIndexLink').'
</label>
<div class="controls">
<label for="index_document">
<label for="index_document">
<input class="checkbox" type="checkbox" name="index_document" id="index_document" checked="checked">
'.get_lang('Yes').'
</label>
@ -339,7 +342,7 @@ if (api_is_allowed_to_edit(null, true) && isset($_GET['action'])) {
<input name="%s" type="text" value="%s"/>
</div>
</div>';
echo sprintf($sf_textbox, $specific_field['name'], $specific_field['code'], $default_values);
}
}
@ -351,11 +354,11 @@ if (api_is_allowed_to_edit(null, true) && isset($_GET['action'])) {
<div class="controls">
<button class="btn save" type="submit" name="submitLink" value="OK">'.get_lang('SaveLink').'</button>
</div>
</div>';
echo '</form>';
} elseif(($_GET['action'] == 'addcategory' || $_GET['action'] == 'editcategory') && !$submit_category) {
</div>';
echo '</form>';
} elseif(($_GET['action'] == 'addcategory' || $_GET['action'] == 'editcategory') && !$submit_category) {
echo '<form class="form-horizontal" method="post" action="'.api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&amp;urlview='.Security::remove_XSS($urlview).'">';
if ($_GET['action'] == 'addcategory') {
echo '<legend>'.get_lang('CategoryAdd').'</legend>';
$my_cat_title = get_lang('CategoryAdd');
@ -363,7 +366,7 @@ if (api_is_allowed_to_edit(null, true) && isset($_GET['action'])) {
echo '<legend>'.get_lang('CategoryMod').'</legend>';
$my_cat_title = get_lang('CategoryMod');
}
echo '<input type="hidden" name="sec_token" value="'.$token.'" />';
if ($_GET['action'] == 'editcategory') {
echo '<input type="hidden" name="id" value="'.$id.'" />';
@ -411,9 +414,9 @@ if (empty($_GET['action']) || ($_GET['action'] != 'editlink' && $_GET['action']
echo '<div class="actions">';
if (api_is_allowed_to_edit(null, true)) {
$urlview = Security::remove_XSS($urlview);
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=addlink&amp;category='.(!empty($category) ? $category : '').'&amp;urlview='.$urlview.'">'.Display::return_icon('new_link.png', get_lang('LinkAdd'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=addlink&amp;category='.(!empty($category) ? $category : '').'&amp;urlview='.$urlview.'">'.Display::return_icon('new_link.png', get_lang('LinkAdd'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=addcategory&amp;urlview='.$urlview.'">'.Display::return_icon('new_folder.png', get_lang('CategoryAdd'),'',ICON_SIZE_MEDIUM).'</a>';
/* "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=importcsv&amp;urlview=".$urlview."\">".get_lang('CsvImport')."</a>\n", // RH*/
}
// Making the show none / show all links. Show none means urlview=0000 (number of zeros depending on the
@ -422,7 +425,7 @@ if (empty($_GET['action']) || ($_GET['action'] != 'editlink' && $_GET['action']
$resultcategories = Database::query($sqlcategories);
$aantalcategories = Database::num_rows($resultcategories);
if ($aantalcategories > 0) {
$resultcategories = Database::query($sqlcategories);
$resultcategories = Database::query($sqlcategories);
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&urlview=';
for ($j = 1; $j <= $aantalcategories; $j++) {
echo '0';
@ -435,14 +438,14 @@ if (empty($_GET['action']) || ($_GET['action'] != 'editlink' && $_GET['action']
echo '">'.Display::return_icon('view_tree.png', $showall,'',ICON_SIZE_MEDIUM).'</a>';
}
echo '</div>';
// Displaying the links which have no category (thus category = 0 or NULL), if none present this will not be displayed
$sqlLinks = "SELECT * FROM ".$tbl_link." WHERE c_id = $course_id AND category_id=0 OR category_id IS NULL";
$result = Database::query($sqlLinks);
$numberofzerocategory = Database::num_rows($result);
if ($numberofzerocategory !== 0) {
echo '<table class="data_table">';
echo '<table class="data_table">';
echo '<tr><th style="font-weight: bold; text-align:left;padding-left: 10px;">'.get_lang('General').'</th></tr>';
echo '</table>';
showlinksofcategory(0);

Loading…
Cancel
Save