category-less link is always visible. * * @author Patrick Cool, main author, completely rewritten * @author Rene Haentjens, added CSV file import (October 2004) * @package dokeos.link * @todo improve organisation, tables should come from database library ============================================================================== */ /* ============================================================================== INIT SECTION ============================================================================== */ // name of the language file that needs to be included $language_file = "link"; // including libraries include("../inc/global.inc.php"); include(api_get_path(LIBRARY_PATH).'events.lib.inc.php'); include("linkfunctions.php"); $this_section=SECTION_COURSES; api_protect_course_script(); // @todo change the $_REQUEST into $_POST or $_GET // @todo remove this code $link_submitted = $_POST["submitLink"]; $category_submitted = $_POST["submitCategory"]; $urlview = $_GET["urlview"]; $submitImport = $_POST["submitImport"]; $down = $_GET['down']; $up = $_GET['up']; $catmove = $_GET['catmove']; $editlink = $_REQUEST['editlink']; $id = $_REQUEST['id']; $urllink = $_REQUEST['urllink']; $title = $_REQUEST['title']; $description = $_REQUEST['description']; $selectcategory = $_REQUEST['selectcategory']; $submitLink = $_REQUEST['submitLink']; $action = $_REQUEST['action']; $category_title = $_REQUEST['category_title']; $submitCategory = $_REQUEST['submitCategory']; $nameTools = get_lang('Links'); if ($_GET['action']=='addlink') { $nameTools = ''; $interbreadcrumb[] = array ('url' => 'link.php', 'name' => get_lang('Links')); $interbreadcrumb[] = array ('url' => 'link.php?action=addlink', 'name' => get_lang('AddLink')); } if ($_GET['action']=='addcategory') { $nameTools = ''; $interbreadcrumb[] = array ('url' => 'link.php', 'name' => get_lang('Links')); $interbreadcrumb[] = array ('url' => 'link.php?action=addcategory', 'name' => get_lang('AddCategory')); } if ($_GET['action']=='editlink') { $nameTools = ''; $interbreadcrumb[] = array ('url' => 'link.php', 'name' => get_lang('Links')); $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('EditLink')); } // Database Table definitions $tbl_link = Database::get_course_table(TABLE_LINK); $tbl_categories = Database::get_course_table(TABLE_LINK_CATEGORY); //statistics event_access_tool(TOOL_LINK); Display::display_header($nameTools, 'Links'); ?> "; if ($_GET['action']=="addlink") {echo get_lang("LinkAdd");} else {echo get_lang("LinkMod");} echo "\n\n"; if ($category=="") {$category=0;} echo "
"; if ($_GET['action']=="editlink") { echo ""; } echo "" . "" . "" . ""; echo "" . "" . "" . "" . "" . "" . ""; $sqlcategories="SELECT * FROM ".$tbl_categories." ORDER BY display_order DESC"; $resultcategories = api_sql_query($sqlcategories)or die("Error: " . mysql_error()); if(mysql_num_rows($resultcategories)) { echo ""; } echo ""; echo "", "
URL* :
" . get_lang("LinkName") . " :
" . get_lang("Description") . " :
".get_lang("Category")." :", "
".get_lang("OnHomepage")." ?
", "
"; } elseif(($_GET['action']=="addcategory" or $_GET['action']=="editcategory") and !$submitCategory) { echo "

"; if ($_GET['action']=="addcategory") {echo get_lang("CategoryAdd");} else {echo get_lang("CategoryMod");} echo "

\n\n"; echo "
"; if ($_GET['action']=="editcategory") { echo ""; } echo "", "", "", "", "", "", "", "
".get_lang("CategoryName")."* :
".get_lang("Description")." :
", "
"; } /*elseif(($_GET['action']=="importcsv") and !$submitImport) // RH start { echo "

", get_lang('CsvImport'), "

\n\n", "
", // uncomment if you want to set a limit: '', "\n", '', "\n", "", "
"; echo get_lang('CsvExplain'); }*/ } if (isset($down)) { movecatlink($down); } if (isset($up)) { movecatlink($up); } if ($_GET['action']!='editlink' && $_GET['action']!='addcategory' && $_GET['action']!='addlink' || $link_submitted || $category_submitted) { /* ----------------------------------------------------------- Action Links ----------------------------------------------------------- */ if(is_allowed_to_edit()) { echo Display::return_icon('file_html_new.gif')." ".get_lang("LinkAdd")."\n"; echo Display::return_icon('folder_new.gif')." ".get_lang("CategoryAdd")."\n"; /* "".get_lang('CsvImport')."\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"; $resultcategories=api_sql_query($sqlcategories); $aantalcategories = @mysql_num_rows($resultcategories); echo Display::return_icon('remove.gif')." $shownone"; echo Display::return_icon('add.gif')." $showall"; //Starting the table which contains the categories $sqlcategories="SELECT * FROM ".$tbl_categories." ORDER BY display_order DESC"; $resultcategories=api_sql_query($sqlcategories); echo '

'; // 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"; $result = api_sql_query($sqlLinks); $numberofzerocategory=mysql_num_rows($result); if ($numberofzerocategory!==0) { echo ""; echo '
".get_lang('General')."
'; showlinksofcategory(0); } $i=0; $catcounter=1; $view="0"; while ($myrow=@mysql_fetch_array($resultcategories)) { if (!isset($urlview)) { // No $view set in the url, thus for each category link it should be all zeros except it's own makedefaultviewcode($i); } else { $view=$urlview; $view[$i]="1"; } // 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"]); if ($urlview[$i]=="1") { $newurlview=$urlview; $newurlview[$i]="0"; echo ''; echo ''; echo ''; echo ''; } echo ''; echo ''; echo '
'; echo '"; echo "  ".htmlentities($myrow["category_title"],ENT_QUOTES,$charset)."
   ".$myrow["description"]; if (is_allowed_to_edit()) { echo '
'; showcategoryadmintools($myrow["id"]); echo '
'; echo showlinksofcategory($myrow["id"]); echo ''; } else { echo ''; echo ''; echo ''; echo ''; } echo ''; echo ''; echo '
  ". htmlentities($myrow["category_title"],ENT_QUOTES,$charset); echo'
   '; echo $myrow["description"]; if (is_allowed_to_edit()) { echo '
'; showcategoryadmintools($myrow["id"]); echo '
'; echo ''; } // displaying the link of the category $i++; } echo ''; //////////////////////////////////////////////////////////////////////////// } Display::display_footer(); ?>