|
|
|
@ -579,7 +579,6 @@ class Link extends Model |
|
|
|
|
'display_order' => $max_display_order, |
|
|
|
|
'on_homepage' => $values['on_homepage'], |
|
|
|
|
'target' => $values['target'], |
|
|
|
|
'category_id' => $values['category_id'], |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
Database::update( |
|
|
|
@ -861,7 +860,6 @@ class Link extends Model |
|
|
|
|
'LinkCategoryAdded', |
|
|
|
|
api_get_user_id() |
|
|
|
|
); |
|
|
|
|
//api_set_default_visibility($category['id'], TOOL_LINK_CATEGORY); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1433,81 +1431,6 @@ class Link extends Model |
|
|
|
|
return $rv; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* CSV file import functions. |
|
|
|
|
* |
|
|
|
|
* @author René Haentjens , Ghent University |
|
|
|
|
*/ |
|
|
|
|
public static function import_link($linkdata) |
|
|
|
|
{ |
|
|
|
|
// url, category_id, title, description, ... |
|
|
|
|
// Field names used in the uploaded file |
|
|
|
|
$known_fields = [ |
|
|
|
|
'url', |
|
|
|
|
'category', |
|
|
|
|
'title', |
|
|
|
|
'description', |
|
|
|
|
'on_homepage', |
|
|
|
|
'hidden', |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
$hide_fields = [ |
|
|
|
|
'kw', |
|
|
|
|
'kwd', |
|
|
|
|
'kwds', |
|
|
|
|
'keyword', |
|
|
|
|
'keywords', |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
// All other fields are added to description, as "name:value". |
|
|
|
|
// Only one hide_field is assumed to be present, <> is removed from value. |
|
|
|
|
if (!($url = trim($linkdata['url'])) || !($title = trim($linkdata['title']))) { |
|
|
|
|
return 0; // 0 = fail |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$cat = ($catname = trim($linkdata['category'])) ? self::get_cat($catname) : 0; |
|
|
|
|
|
|
|
|
|
$regs = []; // Will be passed to ereg() |
|
|
|
|
$d = ''; |
|
|
|
|
foreach ($linkdata as $key => $value) { |
|
|
|
|
if (!in_array($key, $known_fields)) { |
|
|
|
|
if (in_array($key, $hide_fields) && ereg( |
|
|
|
|
'^<?([^>]*)>?$', |
|
|
|
|
$value, |
|
|
|
|
$regs |
|
|
|
|
) |
|
|
|
|
) { // possibly in <...> |
|
|
|
|
if (($kwlist = trim($regs[1])) != '') { |
|
|
|
|
$kw = '<i kw="'.htmlspecialchars($kwlist).'">'; |
|
|
|
|
} else { |
|
|
|
|
$kw = ''; |
|
|
|
|
} |
|
|
|
|
// i.e. assume only one of the $hide_fields will be present |
|
|
|
|
// and if found, hide the value as expando property of an <i> tag |
|
|
|
|
} elseif (trim($value)) { |
|
|
|
|
$d .= ', '.$key.':'.$value; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (!empty($d)) { |
|
|
|
|
$d = substr($d, 2).' - '; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return self::put_link( |
|
|
|
|
$url, |
|
|
|
|
$cat, |
|
|
|
|
$title, |
|
|
|
|
$kw.ereg_replace( |
|
|
|
|
'\[((/?(b|big|i|small|sub|sup|u))|br/)\]', |
|
|
|
|
'<\\1>', |
|
|
|
|
htmlspecialchars($d.$linkdata['description']) |
|
|
|
|
).($kw ? '</i>' : ''), |
|
|
|
|
$linkdata['on_homepage'] ? '1' : '0', |
|
|
|
|
$linkdata['hidden'] ? '1' : '0' |
|
|
|
|
); |
|
|
|
|
// i.e. allow some BBcode tags, e.g. [b]...[/b] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* This function checks if the url is a vimeo link. |
|
|
|
|
* |
|
|
|
@ -1517,7 +1440,7 @@ class Link extends Model |
|
|
|
|
*/ |
|
|
|
|
public static function isVimeoLink($url) |
|
|
|
|
{ |
|
|
|
|
$isLink = strrpos($url, "vimeo.com"); |
|
|
|
|
$isLink = strrpos($url, 'vimeo.com'); |
|
|
|
|
|
|
|
|
|
return $isLink; |
|
|
|
|
} |
|
|
|
@ -1556,9 +1479,9 @@ class Link extends Model |
|
|
|
|
*/ |
|
|
|
|
public static function is_youtube_link($url) |
|
|
|
|
{ |
|
|
|
|
$is_youtube_link = strrpos($url, "youtube") || strrpos( |
|
|
|
|
$is_youtube_link = strrpos($url, 'youtube') || strrpos( |
|
|
|
|
$url, |
|
|
|
|
"youtu.be" |
|
|
|
|
'youtu.be' |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return $is_youtube_link; |
|
|
|
@ -1643,9 +1566,7 @@ class Link extends Model |
|
|
|
|
$show = 'none', |
|
|
|
|
$token = null |
|
|
|
|
) { |
|
|
|
|
$tbl_link = Database::get_course_table(TABLE_LINK); |
|
|
|
|
$tblCIP = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
|
|
|
$categoryId = intval($categoryId); |
|
|
|
|
$categoryId = (int) $categoryId; |
|
|
|
|
|
|
|
|
|
/* Action Links */ |
|
|
|
|
echo '<div class="actions">'; |
|
|
|
@ -1870,6 +1791,9 @@ class Link extends Model |
|
|
|
|
*/ |
|
|
|
|
public static function getCategoryForm($id, $action) |
|
|
|
|
{ |
|
|
|
|
$id = (int) $id; |
|
|
|
|
$action = Security::remove_XSS($action); |
|
|
|
|
|
|
|
|
|
$form = new FormValidator( |
|
|
|
|
'category', |
|
|
|
|
'post', |
|
|
|
@ -1902,7 +1826,7 @@ class Link extends Model |
|
|
|
|
public static function getCategory($id) |
|
|
|
|
{ |
|
|
|
|
$table = Database::get_course_table(TABLE_LINK_CATEGORY); |
|
|
|
|
$id = intval($id); |
|
|
|
|
$id = (int) $id; |
|
|
|
|
$courseId = api_get_course_int_id(); |
|
|
|
|
|
|
|
|
|
if (empty($id) || empty($courseId)) { |
|
|
|
|