[svn r14656] Layout Improvements in Link tool (see FS#2372)

skala
Julio Montoya 18 years ago
parent d39f870340
commit 2f29a8b5b4
  1. 341
      main/link/link.php
  2. 59
      main/link/linkfunctions.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');
?>
<script type="text/javascript">
/* <![CDATA[ */
function MM_popupMsg(msg) { //v1.0
confirm(msg);
}
/* ]]> */
</script>
<?php
/*
-----------------------------------------------------------
Introduction section
-----------------------------------------------------------
*/
Display::display_introduction_section(TOOL_LINK);
// @todo change the $_REQUEST into $_POST or $_GET
// @todo remove this code
$link_submitted = $_POST["submitLink"];
@ -105,60 +78,113 @@ $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');
?>
<script type="text/javascript">
/* <![CDATA[ */
function MM_popupMsg(msg) { //v1.0
confirm(msg);
}
/* ]]> */
</script>
<?php
/*
-----------------------------------------------------------
Action Handling
-----------------------------------------------------------
*/
$nameTools = get_lang("Links");
switch($_GET['action'])
{
case "addlink":
case "addlink":
if($link_submitted)
{
if(!addlinkcategory("link")) // here we add a link
{
unset($submitLink);
}
}
break;
case "addcategory":
{
if(!addlinkcategory("link")) // here we add a link
{
unset($submitLink);
}
}
break;
case "addcategory":
if($category_submitted)
{
if(!addlinkcategory("category")) // here we add a category
{
unset($submitCategory);
}
}
break;
{
if(!addlinkcategory("category")) // here we add a category
{
unset($submitCategory);
}
}
break;
case "importcsv":
if($_POST["submitImport"])
{
import_csvfile();
}
break;
break;
case "deletelink":
deletelinkcategory("link"); // here we delete a link
break;
break;
case "deletecategory":
deletelinkcategory("category"); // here we delete a category
break;
break;
case "editlink":
editlinkcategory("link"); // here we edit a link
break;
break;
case "editcategory":
editlinkcategory("category"); // here we edit a category
break;
break;
case "visible":
change_visibility($_GET['id'],$_GET['scope']); // here we edit a category
break;
break;
case "invisible":
change_visibility($_GET['id'],$_GET['scope']); // here we edit a category
break;
break;
}
/*
-----------------------------------------------------------
Introduction section
-----------------------------------------------------------
*/
Display::display_introduction_section(TOOL_LINK);
if (is_allowed_to_edit())
@ -263,113 +289,132 @@ if (isset($up))
movecatlink($up);
}
/*
-----------------------------------------------------------
Action Links
-----------------------------------------------------------
*/
if(is_allowed_to_edit())
{
echo Display::return_icon('file_html_new.gif')." <a href=\"".api_get_self()."?".api_get_cidreq()."&action=addlink&amp;category=".$category."&amp;urlview=$urlview\">".get_lang("LinkAdd")."</a>\n";
echo Display::return_icon('folder_new.gif')." <a href=\"".api_get_self()."?".api_get_cidreq()."&action=addcategory&amp;urlview=".$urlview."\">".get_lang("CategoryAdd")."</a>\n";
/* "<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
//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')." <a href=\"".api_get_self()."?".api_get_cidreq()."&urlview=";
for($j = 1; $j <= $aantalcategories; $j++)
{
echo "0";
}
echo "\">$shownone</a>";
echo Display::return_icon('add.gif')." <a href=\"".api_get_self()."?".api_get_cidreq()."&urlview=";
for($j = 1; $j <= $aantalcategories; $j++)
{
echo "1";
}
echo "\">$showall</a>";
$sqlcategories="SELECT * FROM ".$tbl_categories." ORDER BY display_order DESC";
$resultcategories=api_sql_query($sqlcategories);
//Starting the table which contains the categories
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";
$result = api_sql_query($sqlLinks);
$numberofzerocategory=mysql_num_rows($result);
if ($numberofzerocategory!==0)
{
echo "<tr><th style=\"font-weight: bold; text-align:left;padding-left: 10px;\"><i>".get_lang('NoCategory')."</i></th></tr>";
echo "<tr><td>";
showlinksofcategory(0);
echo "</td></tr>";
}
$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')." <a href=\"".api_get_self()."?".api_get_cidreq()."&action=addlink&amp;category=".$category."&amp;urlview=$urlview\">".get_lang("LinkAdd")."</a>\n";
echo Display::return_icon('folder_new.gif')." <a href=\"".api_get_self()."?".api_get_cidreq()."&action=addcategory&amp;urlview=".$urlview."\">".get_lang("CategoryAdd")."</a>\n";
/* "<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
//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')." <a href=\"".api_get_self()."?".api_get_cidreq()."&urlview=";
for($j = 1; $j <= $aantalcategories; $j++)
{
echo "0";
}
echo "\">$shownone</a>";
echo Display::return_icon('add.gif')." <a href=\"".api_get_self()."?".api_get_cidreq()."&urlview=";
for($j = 1; $j <= $aantalcategories; $j++)
{
echo "1";
}
echo "\">$showall</a>";
//Starting the table which contains the categories
$sqlcategories="SELECT * FROM ".$tbl_categories." ORDER BY display_order DESC";
$resultcategories=api_sql_query($sqlcategories);
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";
$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 "<tr><th style=\"font-weight: bold; text-align:left;padding-left: 10px;\"><i>".get_lang('General')."</i></th></tr>";
echo '</table>';
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 "<tr>",
"<th style=\"font-weight: bold; text-align:left;padding-left: 10px;\">- <a href=\"".api_get_self()."?".api_get_cidreq()."&urlview=".$newurlview."\">".htmlentities($myrow["category_title"],ENT_QUOTES,$charset)."</a><br/>&nbsp;&nbsp;&nbsp;".$myrow["description"];
if (is_allowed_to_edit())
else
{
showcategoryadmintools($myrow["id"]);
}
echo "</th>",
"</tr>",
"<tr>",
"<td>",showlinksofcategory($myrow["id"])."</td>",
"</tr>";
$view=$urlview;
$view[$i]="1";
}
else
{
echo "<tr><th style=\"font-weight: bold; text-align:left;padding-left: 10px;\">+ <a href=\"".api_get_self()."?".api_get_cidreq()."&urlview=";
echo is_array($view)?implode('',$view):$view;
echo "\">".htmlentities($myrow["category_title"],ENT_QUOTES,$charset)."</a><br />&nbsp;&nbsp;&nbsp;";
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 '<tr>';
echo '<table class="data_table">';
echo '<tr>';
echo '<th width="81%" style="font-weight: bold; text-align:left;padding-left: 5px;">';
echo '<a href="'.api_get_self()."?".api_get_cidreq()."&urlview=".$newurlview."\">";
echo "<img src=../img/remove.gif>&nbsp;&nbsp;".htmlentities($myrow["category_title"],ENT_QUOTES,$charset)."</a><br/>&nbsp;&nbsp;&nbsp;".$myrow["description"];
if (is_allowed_to_edit())
{
echo '<th>';
showcategoryadmintools($myrow["id"]);
echo '</th>';
}
echo '</th>';
echo '</tr>';
echo '</table>';
echo showlinksofcategory($myrow["id"]);
echo '</tr>';
}
echo "</th>",
"</tr>";
else
{
echo '<tr>';
echo '<table class="data_table">';
echo '<tr>';
echo '<th width="81%" style="font-weight: bold; text-align:left;padding-left: 5px;"><a href="'.api_get_self()."?".api_get_cidreq()."&urlview=";
echo is_array($view)?implode('',$view):$view;
echo "\"><img src=../img/add.gif>&nbsp;&nbsp;". htmlentities($myrow["category_title"],ENT_QUOTES,$charset);
echo'</a><br />&nbsp;&nbsp;&nbsp;';
echo $myrow["description"];
if (is_allowed_to_edit())
{
echo '<th style="text-align:center;">';
showcategoryadmintools($myrow["id"]);
echo '</th>';
}
echo '</th>';
echo '</tr>';
echo '</table>';
echo '</tr>';
}
// displaying the link of the category
$i++;
// displaying the link of the category
$i++;
}
echo "</table>";
echo '</table>';
////////////////////////////////////////////////////////////////////////////
}
//////////////////////////////////////////////////////////////////////////////
Display::display_footer();

@ -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 "<table class='data_table'>";
echo '<table class="data_table" width="100%">';
$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 "<tr class='".$css_class."'>", "<td align=\"center\" valign=\"middle\" width=\"15\">", "<a href=\"link_goto.php?".api_get_cidreq()."&link_id=", $myrow[0], "&amp;link_url=", urlencode($myrow[1]), "\" target=\"_blank\">", "<img src=\"../../main/img/file_html.gif\" border=\"0\" alt=\"".get_lang('Links')."\"/>", "</a></td>", "<td width=\"580\" valign=\"top\">", "<a href=\"link_goto.php?".api_get_cidreq()."&link_id=", $myrow[0], "&amp;link_url=", urlencode($myrow[1]), "\" target=\"_blank\">", htmlentities($myrow[2],ENT_QUOTES,$charset), "</a>\n", "<br/>", $myrow[3], "";
echo "<tr class='".$css_class."'>", "<td align=\"center\" valign=\"middle\" width=\"15\">", "<a href=\"link_goto.php?".api_get_cidreq()."&link_id=", $myrow[0], "&amp;link_url=", urlencode($myrow[1]), "\" target=\"_blank\">", "<img src=\"../../main/img/file_html.gif\" border=\"0\" alt=\"".get_lang('Links')."\"/>", "</a></td>", "<td width=\"80%\" valign=\"top\">", "<a href=\"link_goto.php?".api_get_cidreq()."&link_id=", $myrow[0], "&amp;link_url=", urlencode($myrow[1]), "\" target=\"_blank\">", htmlentities($myrow[2],ENT_QUOTES,$charset), "</a>\n", "<br/>", $myrow[3], "";
}
else
{
if (api_is_allowed_to_edit())
{
echo "<tr class='".$css_class."'>", "<td align=\"center\" valign=\"middle\" width=\"15\">", "<a href=\"link_goto.php?".api_get_cidreq()."&link_id=", $myrow[0], "&amp;link_url=", urlencode($myrow[1]), "\" target=\"_blank\" class=\"invisible\">", Display::return_icon('file_html_na.gif', get_lang('Links')),"</a></td>", "<td width=\"580\" valign=\"top\">", "<a href=\"link_goto.php?".api_get_cidreq()."&link_id=", $myrow[0], "&amp;link_url=", urlencode($myrow[1]), "\" target=\"_blank\" class=\"invisible\">", htmlentities($myrow[2],ENT_QUOTES,$charset), "</a>\n", "<br />", $myrow[3], "";
echo "<tr class='".$css_class."'>", "<td align=\"center\" valign=\"middle\" width=\"15\">", "<a href=\"link_goto.php?".api_get_cidreq()."&link_id=", $myrow[0], "&amp;link_url=", urlencode($myrow[1]), "\" target=\"_blank\" class=\"invisible\">", Display::return_icon('file_html_na.gif', get_lang('Links')),"</a></td>", "<td width=\"80%\" valign=\"top\">", "<a href=\"link_goto.php?".api_get_cidreq()."&link_id=", $myrow[0], "&amp;link_url=", urlencode($myrow[1]), "\" target=\"_blank\" class=\"invisible\">", htmlentities($myrow[2],ENT_QUOTES,$charset), "</a>\n", "<br />", $myrow[3], "";
}
}
echo '<td style="text-align:center;">';
if (api_is_allowed_to_edit())
{
echo "<br />", "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=editlink&amp;category=$category&amp;id=$myrow[0]&amp;urlview=$urlview\">", "<img src=\"../img/edit.gif\" border=\"0\" alt=\"", get_lang('Modify'), "\" />", "</a>", " <a href=\"".api_get_self()."?".api_get_cidreq()."&action=deletelink&amp;id=", $myrow[0], "&amp;urlview=", $urlview, "\" onclick=\"javascript:if(!confirm('".get_lang('LinkDelconfirm')."')) return false;\">", "<img src=\"../img/delete.gif\" border=\"0\" alt=\"", get_lang('Delete'), "\" />", "</a>";
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=editlink&amp;category=$category&amp;id=$myrow[0]&amp;urlview=$urlview\" title=\"".get_lang('Modify')."\" >", "<img src=\"../img/edit.gif\" border=\"0\" alt=\"", get_lang('Modify'), "\" />", "</a>";
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=deletelink&amp;id=", $myrow[0], "&amp;urlview=", $urlview, "\" onclick=\"javascript:if(!confirm('".get_lang('LinkDelconfirm')."')) return false;\" title=\"".get_lang('Delete')."\" >", "<img src=\"../img/delete.gif\" border=\"0\" alt=\"", get_lang('Delete'), "\" />", "</a>";
// DISPLAY MOVE UP COMMAND only if it is not the top link
if ($i != 1)
{
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&urlview=".$urlview."&amp;up=", $myrow["id"], "\">", "<img src=../img/up.gif border=0 alt=\"Up\"/>", "</a>\n";
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&urlview=".$urlview."&amp;up=", $myrow["id"], "\" title=\"".get_lang('Up')."\" >", "<img src=../img/up.gif border=0 alt=\"Up\"/>", "</a>\n";
}
else
{
echo '<img src=../img/up_na.gif border=0 alt=\"Up\"/>';
}
// DISPLAY MOVE DOWN COMMAND only if it is not the bottom link
if ($i < $numberoflinks)
{
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&urlview=".$urlview."&amp;down=".$myrow["id"]."\">", "<img src=\"../img/down.gif\" border=\"0\" alt=\"Down\"/>", "</a>\n";
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&urlview=".$urlview."&amp;down=".$myrow["id"]."\" title=\"".get_lang('Down')."\" >", "<img src=\"../img/down.gif\" border=\"0\" alt=\"Down\"/>", "</a>\n";
}
else
{
echo '<img src=../img/down_na.gif border=0 alt=\"Up\"/>';
}
if ($myrow['visibility'] == "1")
{
echo "<a href=\"link.php?".api_get_cidreq()."&action=invisible&amp;id=".$myrow['id']."&amp;scope=link\">".Display::return_icon('visible.gif')."</a>";
echo '<a href="link.php?'.api_get_cidreq().'&action=invisible&amp;id='.$myrow['id'].'&amp;scope=link&amp;urlview='.$urlview.'" title="'.get_lang('langVisible').'"><img src="../img/visible.gif" border="0" /></a>';
}
if ($myrow['visibility'] == "0")
{
echo "<a href=\"link.php?".api_get_cidreq()."&action=visible&amp;id=".$myrow['id']."&amp;scope=link\">".Display::return_icon('invisible.gif')."</a>";
echo '<a href="link.php?'.api_get_cidreq().'&action=visible&amp;id='.$myrow['id'].'&amp;scope=link&amp;urlview='.$urlview.'" title="'.get_lang('langVisible').'"><img src="../img/invisible.gif" border="0" /></a>';
}
}
echo "</td>", "</tr>";
echo '</td>';
echo '</td>';
echo '</tr>';
$i ++;
}
echo "</table>";
echo '</table>';
}
/**
@ -427,19 +442,33 @@ function showcategoryadmintools($categoryid)
global $urlview;
global $aantalcategories;
global $catcounter;
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=editcategory&amp;id=$categoryid&amp;urlview=$amp;urlview\">", "<img src=\"../img/edit.gif\" border=\"0\" alt=\"", get_lang('Modify'), "\"/>", "</a> \n";
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=editcategory&amp;id='.$categoryid.'&amp;urlview=$amp;urlview\" title="'.get_lang('Modify').'" ><img src="../img/edit.gif" border="0" alt="'.get_lang('Modify').' "/></a>';
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=deletecategory&amp;id=", $categoryid, "&amp;urlview=$urlview\" onclick=\"javascript:if(!confirm('".get_lang('CategoryDelconfirm')."')) return false;\">", "<img src=\"../img/delete.gif\" border=\"0\" alt=\"", get_lang('Delete'), "\"/>", "</a>";
// 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 "<a href=\"".api_get_self()."?".api_get_cidreq()."&catmove=true&amp;up=", $categoryid, "&amp;urlview=$urlview\">", "<img src=../img/up.gif border=0 alt=\"Up\"/>", "</a>\n";
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&catmove=true&amp;up=", $categoryid, "&amp;urlview=$urlview\" title=\"".get_lang('Up')."\" >", "<img src=../img/up.gif border=0 alt=\"Up\"/>", "</a>\n";
}
else
{
echo '<img src=../img/up_na.gif border=0 alt=\"Up\"/>';
}
// DISPLAY MOVE DOWN COMMAND only if it is not the bottom link
if ($catcounter < $aantalcategories)
{
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&catmove=true&amp;down=".$categoryid."&amp;urlview=$urlview\">", "<img src=\"../img/down.gif\" border=\"0\" alt=\"Down\"/>", "</a>\n";
}
else
{
echo '<img src=../img/down_na.gif border=0 alt=\"Up\"/>';
}
//echo Display::return_icon('visible.gif');
$catcounter ++;
}

Loading…
Cancel
Save