Source for file link.php
Documentation is available at link.php
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) 2003-2005 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
==============================================================================
==============================================================================
* Main script for the links tool.
* - Organize links into categories;
* - favorites/bookmarks-like interface;
* - move links up/down within a category;
* - move categories up/down;
* - expand/collapse all categories (except the main "non"-category);
* - add link to 'root' category => category-less link is always visible.
* @author Patrick Cool, main author, completely rewritten
* @author Rene Haentjens, added CSV file import (October 2004)
* @todo improve organisation, tables should come from database library
==============================================================================
==============================================================================
==============================================================================
// name of the language file that needs to be included
include("../inc/global.inc.php");
include(api_get_path(LIBRARY_PATH). 'events.lib.inc.php');
include("linkfunctions.php");
// @todo change the $_REQUEST into $_POST or $_GET
// @todo remove this code
$link_submitted = (!empty($_POST['submitLink'])? $_POST['submitLink']: '');
$category_submitted = (!empty($_POST['submitCategory'])? $_POST['submitCategory']: '');
$urlview = (!empty($_GET['urlview'])? $_GET['urlview']: '');
$submitImport = (!empty($_POST['submitImport'])? $_POST['submitImport']: '');
$down = (!empty($_GET['down'])? $_GET['down']: '');
$up = (!empty($_GET['up'])? $_GET['up']: '');
$catmove = (!empty($_GET['catmove'])? $_GET['catmove']: '');
$editlink = (!empty($_REQUEST['editlink'])? $_REQUEST['editlink']: '');
$id = (!empty($_REQUEST['id'])? $_REQUEST['id']: '');
$urllink = (!empty($_REQUEST['urllink'])? $_REQUEST['urllink']: '');
$title = (!empty($_REQUEST['title'])? $_REQUEST['title']: '');
$description = (!empty($_REQUEST['description'])? $_REQUEST['description']: '');
$selectcategory = (!empty($_REQUEST['selectcategory'])? $_REQUEST['selectcategory']: '');
$submitLink = (!empty($_REQUEST['submitLink'])? $_REQUEST['submitLink']: '');
$action = (!empty($_REQUEST['action'])? $_REQUEST['action']: '');
$category_title = (!empty($_REQUEST['category_title'])? $_REQUEST['category_title']: '');
$submitCategory = (!empty($_REQUEST['submitCategory'])? $_REQUEST['submitCategory']: '');
if (isset ($_GET['action']) && $_GET['action']== 'addlink')
$interbreadcrumb[] = array ('url' => 'link.php', 'name' => get_lang('Links'));
$interbreadcrumb[] = array ('url' => 'link.php?action=addlink', 'name' => get_lang('AddLink'));
if (isset ($_GET['action']) && $_GET['action']== 'addcategory')
$interbreadcrumb[] = array ('url' => 'link.php', 'name' => get_lang('Links'));
$interbreadcrumb[] = array ('url' => 'link.php?action=addcategory', 'name' => get_lang('AddCategory'));
if (isset ($_GET['action']) && $_GET['action']== 'editlink')
$interbreadcrumb[] = array ('url' => 'link.php', 'name' => get_lang('Links'));
$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('EditLink'));
// Database Table definitions
<script type="text/javascript">
function MM_popupMsg(msg) { //v1.0
-----------------------------------------------------------
-----------------------------------------------------------
if(isset ($_GET['action']))
if($_POST["submitImport"])
-----------------------------------------------------------
-----------------------------------------------------------
// 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($submitLink)
if (($_GET['action']== "addlink" or $_GET['action']== "editlink") and empty($_POST['submitLink']))
if ($_GET['action']== "addlink")
echo "<form method=\"post\" action=\"". api_get_self(). "?action=". $_GET['action']. "&urlview=". $urlview. "\">";
if ($_GET['action']== "editlink")
echo "<input type=\"hidden\" name=\"id\" value=\"". $_GET['id']. "\" />";
. "<td align=\"right\">URL<span class=\"required\">*</span> :</td>"
. "<td><input type=\"text\" name=\"urllink\" size=\"50\" value=\"" . (empty($urllink)? 'http://': htmlentities($urllink)) . "\" /></td>" . "</tr>";
. "<td align=\"right\">" . get_lang("LinkName") . " :</td>"
. "<td><input type=\"text\" name=\"title\" size=\"50\" value=\"" . htmlentities($title,ENT_QUOTES,$charset) . "\" /></td>"
"<td align=\"right\" valign=\"top\">" . get_lang("Description") . " :</td>" .
"<td><textarea rows=\"3\" cols=\"50\" name=\"description\">" .
htmlentities($description,ENT_QUOTES,$charset) . "</textarea></td></tr>";
$sqlcategories= "SELECT * FROM ". $tbl_categories. " ORDER BY display_order DESC";
echo "<tr><td align=\"right\">". get_lang("Category"). " :</td><td>",
"<select name=\"selectcategory\">",
"<option value=\"0\">--</option>";
echo "<option value=\"". $myrow["id"]. "\"";
if ($myrow["id"]== $category)
echo ">". $myrow["category_title"]. "</option>";
echo "</select></td></tr>";
echo "<tr><td align=\"right\">". get_lang("OnHomepage"). " ? </td><td><input class=\"checkbox\" type=\"checkbox\" name=\"onhomepage\" id=\"onhomepage\" value=\"1\" $onhomepage><label for=\"onhomepage\"> ". get_lang("Yes"). "</label></td></tr>";
echo "<tr><td></td><td><input type=\"Submit\" name=\"submitLink\" value=\"". get_lang("Ok"). "\" /></td></tr>",
elseif(($_GET['action']== "addcategory" or $_GET['action']== "editcategory") and !$submitCategory)
if ($_GET['action']== "addcategory")
echo "<form method=\"post\" action=\"". api_get_self(). "?action=". $_GET['action']. "&urlview=". $urlview. "\">";
if ($_GET['action']== "editcategory")
echo "<input type=\"hidden\" name=\"id\" value=\"". $id. "\" />";
"<td align=\"right\">". get_lang("CategoryName"). "<span class=\"required\">*</span> :</td>",
"<td><input type=\"text\" name=\"category_title\" size=\"50\" value=\"",htmlentities($category_title,ENT_QUOTES,$charset). "\" /></td>",
"<tr><td align=\"right\" valign=\"top\">". get_lang("Description"). " :</td>",
"<td><textarea rows=\"3\" cols=\"50\" name=\"description\">",htmlentities($description,ENT_QUOTES,$charset). "</textarea></td></tr>",
"<tr><td></td><td><input type=\"Submit\" name=\"submitCategory\" value=\"". get_lang("Ok"). "\" /></td></tr>",
/*elseif(($_GET['action']=="importcsv") and !$submitImport) // RH start
echo "<h4>", get_lang('CsvImport'), "</h4>\n\n",
"<form method=\"post\" action=\"".api_get_self()."?action=".$_GET['action']."&urlview=".$urlview."\" enctype=\"multipart/form-data\">",
// uncomment if you want to set a limit: '<input type="hidden" name="MAX_FILE_SIZE" value="32768">', "\n",
'<input type="file" name="import_file" size="30">', "\n",
"<input type=\"Submit\" name=\"submitImport\" value=\"".get_lang('Ok')."\">",
echo get_lang('CsvExplain');
if (empty($_GET['action']) || ($_GET['action']!= 'editlink' && $_GET['action']!= 'addcategory' && $_GET['action']!= 'addlink') || $link_submitted || $category_submitted)
-----------------------------------------------------------
-----------------------------------------------------------
/* "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=importcsv&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
//number of categories). Show all means urlview=1111 (number of 1 depending on teh number of categories).
$sqlcategories= "SELECT * FROM ". $tbl_categories. " ORDER BY display_order DESC";
for($j = 1; $j <= $aantalcategories; $j++ )
for($j = 1; $j <= $aantalcategories; $j++ )
//Starting the table which contains the categories
$sqlcategories= "SELECT * FROM ". $tbl_categories. " ORDER BY display_order DESC";
echo '<br /><br /><table class="data_table">';
// 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 category_id=0 or category_id IS NULL";
if ($numberofzerocategory!== 0)
echo "<tr><th style=\"font-weight: bold; text-align:left;padding-left: 10px;\"><i>". get_lang('General'). "</i></th></tr>";
// No $view set in the url, thus for each category link it should be all zeros except it's own
// if the $urlview has a 1 for this categorie, this means it is expanded and should be desplayed as a
// - instead of a +, the category is no longer clickable and all the links of this category are displayed
$myrow["description"]= text_filter($myrow["description"]);
echo '<table class="data_table">';
echo '<th width="81%" style="font-weight: bold; text-align:left;padding-left: 5px;">';
echo "<img src=../img/remove.gif> ". htmlentities($myrow["category_title"],ENT_QUOTES,$charset). "</a><br/> ". $myrow["description"];
echo '<table class="data_table">';
echo '<th width="81%" style="font-weight: bold; text-align:left;padding-left: 5px;"><a href="'. api_get_self(). "?". api_get_cidreq(). "&urlview=";
echo "\"><img src=../img/add.gif> ". htmlentities($myrow["category_title"],ENT_QUOTES,$charset);
echo '</a><br /> ';
echo $myrow["description"];
echo '<th style="text-align:center;">';
// displaying the link of the category
////////////////////////////////////////////////////////////////////////////
|