From 2f29a8b5b4e398e8af1817861d0c8c60f25e33f0 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 Mar 2008 22:50:37 +0100 Subject: [PATCH] [svn r14656] Layout Improvements in Link tool (see FS#2372) --- main/link/link.php | 341 ++++++++++++++++++++---------------- main/link/linkfunctions.php | 59 +++++-- 2 files changed, 237 insertions(+), 163 deletions(-) diff --git a/main/link/link.php b/main/link/link.php index a8c4fb435c..bef5de32b4 100644 --- a/main/link/link.php +++ b/main/link/link.php @@ -3,7 +3,7 @@ ============================================================================== Dokeos - elearning and course management software - Copyright (c) 2004-2005 Dokeos S.A. + Copyright (c) 2004-2008 Dokeos S.A. Copyright (c) 2003-2005 Ghent University (UGent) Copyright (c) 2001 Universite catholique de Louvain (UCL) @@ -17,7 +17,7 @@ See the GNU General Public License for more details. - Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium + Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium Mail: info@dokeos.com ============================================================================== */ @@ -58,33 +58,6 @@ $this_section=SECTION_COURSES; api_protect_course_script(); -// 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); -$nameTools = get_lang("Links"); -Display::display_header($nameTools, 'Links'); -?> - - - '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'); +?> + + +".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"; - - - -$sqlcategories="SELECT * FROM ".$tbl_categories." ORDER BY display_order DESC"; -$resultcategories=api_sql_query($sqlcategories); - -//Starting the table which contains the categories -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 ""; - } -$i=0; -$catcounter=1; -$view="0"; -while ($myrow=@mysql_fetch_array($resultcategories)) +if ($_GET['action']!='editlink' && $_GET['action']!='addcategory' && $_GET['action']!='addlink' || $link_submitted || $category_submitted) +{ + /* + ----------------------------------------------------------- + Action Links + ----------------------------------------------------------- + */ + + if(is_allowed_to_edit()) { - if (!isset($urlview)) + 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 '

".get_lang('NoCategory')."
"; - showlinksofcategory(0); - 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) { - // No $view set in the url, thus for each category link it should be all zeros except it's own - makedefaultviewcode($i); + echo ""; + echo '
".get_lang('General')."
'; + showlinksofcategory(0); } - else + + $i=0; + $catcounter=1; + $view="0"; + + while ($myrow=@mysql_fetch_array($resultcategories)) + { + if (!isset($urlview)) { - $view=$urlview; - $view[$i]="1"; + // No $view set in the url, thus for each category link it should be all zeros except it's own + makedefaultviewcode($i); } - // 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 "", - "- ".htmlentities($myrow["category_title"],ENT_QUOTES,$charset)."
   ".$myrow["description"]; - if (is_allowed_to_edit()) + else { - showcategoryadmintools($myrow["id"]); - } - echo "", - "", - "", - "",showlinksofcategory($myrow["id"])."", - ""; - + $view=$urlview; + $view[$i]="1"; } - else - { - - echo "+ ".htmlentities($myrow["category_title"],ENT_QUOTES,$charset)."
   "; - echo $myrow["description"]; - - if (is_allowed_to_edit()) + // 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") { - showcategoryadmintools($myrow["id"]); + $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 ''; } - 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++; + // displaying the link of the category + $i++; } -echo ""; + echo ''; + //////////////////////////////////////////////////////////////////////////// +} + + -////////////////////////////////////////////////////////////////////////////// Display::display_footer(); diff --git a/main/link/linkfunctions.php b/main/link/linkfunctions.php index cc34f3b94a..d6b3cdd8ae 100644 --- a/main/link/linkfunctions.php +++ b/main/link/linkfunctions.php @@ -370,7 +370,8 @@ function showlinksofcategory($catid) $sqlLinks = "SELECT * 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')ORDER BY link.display_order DESC"; $result = api_sql_query($sqlLinks); $numberoflinks = mysql_num_rows($result); - echo ""; + + echo '
'; $i = 1; while ($myrow = mysql_fetch_array($result)) { @@ -380,42 +381,56 @@ function showlinksofcategory($catid) $myrow[3] = text_filter($myrow[3]); if ($myrow['visibility'] == '1') { - echo "", "", "", "", "", "", "", "", "", ""; + echo ''; + echo ''; + echo ''; $i ++; } - echo "
", "", "\"".get_lang('Links')."\"/", "", "", htmlentities($myrow[2],ENT_QUOTES,$charset), "\n", "
", $myrow[3], ""; + echo "
", "", "\"".get_lang('Links')."\"/", "", "", htmlentities($myrow[2],ENT_QUOTES,$charset), "\n", "
", $myrow[3], ""; } else { if (api_is_allowed_to_edit()) { - echo "
", "", Display::return_icon('file_html_na.gif', get_lang('Links')),"", "", htmlentities($myrow[2],ENT_QUOTES,$charset), "\n", "
", $myrow[3], ""; + echo "
", "", Display::return_icon('file_html_na.gif', get_lang('Links')),"", "", htmlentities($myrow[2],ENT_QUOTES,$charset), "\n", "
", $myrow[3], ""; } } + + echo '
'; if (api_is_allowed_to_edit()) { - echo "
", "", "\"",", "", " ", "\"",", ""; + echo "", "\"",", ""; + echo "", "\"",", ""; // DISPLAY MOVE UP COMMAND only if it is not the top link if ($i != 1) { - echo "", "\"Up\"/", "\n"; + echo "", "\"Up\"/", "\n"; } + else + { + echo '\"Up\"/'; + } + // DISPLAY MOVE DOWN COMMAND only if it is not the bottom link if ($i < $numberoflinks) { - echo "", "\"Down\"/", "\n"; + echo "", "\"Down\"/", "\n"; } + else + { + echo '\"Up\"/'; + } + if ($myrow['visibility'] == "1") { - echo "".Display::return_icon('visible.gif').""; + echo ''; } if ($myrow['visibility'] == "0") { - echo "".Display::return_icon('invisible.gif').""; + echo ''; } - } - echo "
"; + echo ''; } /** @@ -427,19 +442,33 @@ function showcategoryadmintools($categoryid) global $urlview; global $aantalcategories; global $catcounter; - - echo "", "\"",", " \n"; + + echo ''.get_lang('Modify').' '; echo "", "\"",", ""; - // DISPLAY MOVE UP COMMAND only if it is not the top link + + // DISPLAY MOVE UP COMMAND only if it is not the top link if ($catcounter != 1) { - echo "", "\"Up\"/", "\n"; + echo "", "\"Up\"/", "\n"; + } + else + { + echo '\"Up\"/'; } + // DISPLAY MOVE DOWN COMMAND only if it is not the bottom link if ($catcounter < $aantalcategories) { echo "", "\"Down\"/", "\n"; } + else + { + echo '\"Up\"/'; + } + + //echo Display::return_icon('visible.gif'); + + $catcounter ++; }