<form name="form" method="post" action="deleteentry.php">
-<input type="hidden" name=id value="<?php p($cm->id) ?>">
+<input type="hidden" name=id value="<?php p($cm->id) ?>">
<input type="hidden" name=mode value="delete">
<input type="hidden" name=go value="1">
<input type="hidden" name=entry value="<?php echo $entry ?>">
<center>
-<form name="theform" method="post" <?=$onsubmit ?> action="edit.php" enctype="multipart/form-data">
+<form name="form" method="post" <?=$onsubmit ?> action="edit.php" enctype="multipart/form-data">
<table class=generalbox cellpadding=5 bgcolor="<?php p($THEME->cellheading)?>">
<tr valign=top>
<td align=right><p><b><?php echo get_string("concept","glossary") ?>:</b></p></td>
<tr valign=top>
<td align=right><p><b><?php echo get_string("entryusedynalink","glossary") ?>:</b></p></td>
<td>
- <select size="1" name="usedynalink">
- <option value="1" <?php
- if ( isset($newentry->usedynalink) ) {
- if ($newentry->usedynalink) {
- echo "selected";
- }
- }
- ?>
- ><?php echo get_string("yes") ?></option>
- <option value="0" <?php
- if ( isset($newentry->usedynalink) ) {
- if (!$newentry->usedynalink) {
- echo "selected";
- }
- }
- ?>><?php echo get_string("no") ?>
- </option>
- </select> <?php helpbutton("usedynalink", get_string("usedynalink", "glossary"), "glossary") ?>
+ <script>
+ var items = ['casesensitive','fullmatch'];
+ </script>
+<?php
+ $selected = "";
+ if ( isset($newentry->usedynalink) ) {
+ if ($newentry->usedynalink) {
+ $selected = "checked";
+ }
+ }
+?>
+ <input type="checkbox" name="usedynalink" value=1 <?php p($selected) ?> onclick="return lockoptions('form','usedynalink', items)"> <?php helpbutton("usedynalink", get_string("usedynalink", "glossary"), "glossary") ?>
</td>
</tr>
<tr valign=top>
echo "<input type=\"hidden\" name=e value=\"$newentry->id\">";
}
?>
+
+ <input type="hidden" name=husedynalink value="1">
+ <input type="hidden" name=hcasesensitive value="0">
+ <input type="hidden" name=hfullmatch value="1">
+
<input type="hidden" name=id value="<?=$cm->id ?>">
<input type="hidden" name=tab value="<?=$tab ?>">
<input type="hidden" name=cat value="<?=$cat ?>">
<?PHP
if ($usehtmleditor) {
- print_richedit_javascript("theform", "text", "yes");
+ print_richedit_javascript("form", "text", "yes");
}
?>
}
if ( $confirm ) {
$form = data_submitted();
-
+ if ( !isset($form->usedynalink) ) {
+ $form->usedynalink = 0;
+ }
$timenow = time();
$form->text = clean_text($form->text, $form->format);
echo "\n<td bgcolor=\"$colour\" width=35 valign=top class=\"forumpostpicture\">";
if ($entry) {
print_user_picture($user->id, $course->id, $user->picture);
- }
- echo "</td>";
- echo "<td nowrap valign=\"top\" width=100% bgcolor=\"$THEME->cellheading\" class=\"forumpostheader\">";
- if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
- echo "<a title=\"" . get_string("approve","glossary"). "\" href=\"approve.php?id=$cm->id&eid=$entry->id&tab=$tab\"><IMG align=\"right\" src=\"check.gif\" border=0 width=\"34\" height=\"34\"></a>";
- }
- if ($entry->attachment) {
- $entry->course = $glossary->course;
- echo "<table border=0 align=right><tr><td>";
- echo glossary_print_attachments($entry, "html");
- echo "</td></tr></table>";
- }
- if ($entry) {
- echo "<b>$entry->concept</b><br />";
+
+ echo "</td>";
+ echo "<td nowrap valign=\"top\" width=100% bgcolor=\"$THEME->cellheading\" class=\"forumpostheader\">";
+
+ glossary_print_entry_approval($cm, $entry, $tab);
+ glossary_print_entry_attachment($entry,"html","right");
+
+ echo "<b>";
+ glossary_print_entry_concept($entry);
+ echo "</b><br />";
+
echo "<font size=\"2\">$strby $user->firstname $user->lastname</font>";
echo " <font size=1>(".get_string("lastedited").": ".
userdate($entry->timemodified).")</font>";
- }
- echo "</tr>";
+ echo "</tr>";
- echo "\n<tr>";
- echo "\n<td bgcolor=\"$colour\" width=35 valign=top class=\"forumpostside\"> </td>";
- echo "\n<td width=100% bgcolor=\"$THEME->cellcontent\" class=\"forumpostmessage\">";
- if ($entry) {
- echo format_text($entry->definition, $entry->format);
+ echo "\n<tr>";
+ echo "\n<td bgcolor=\"$colour\" width=35 valign=top class=\"forumpostside\"> </td>";
+ echo "\n<td width=100% bgcolor=\"$THEME->cellcontent\" class=\"forumpostmessage\">";
+
+ glossary_print_entry_definition($entry);
glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab,$cat);
} else {
echo "\n<td bgcolor=\"$colour\" width=35 valign=top class=\"forumpostpicture\">";
if ($entry) {
print_user_picture($user->id, $course->id, $user->picture);
- }
- echo "</td>";
- echo "<td align=\"top\" nowrap width=100% bgcolor=\"$THEME->cellheading\" class=\"forumpostheader\">";
- if ($entry) {
- if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
- echo "<a title=\"" . get_string("approve","glossary"). "\" href=\"approve.php?id=$cm->id&eid=$entry->id&tab=$tab\"><IMG align=\"right\" src=\"check.gif\" border=0 width=\"34\" height=\"34\"></a>";
- }
- echo "<b>$entry->concept</b><br />";
+ echo "</td>";
+ echo "<td align=\"top\" nowrap width=100% bgcolor=\"$THEME->cellheading\" class=\"forumpostheader\">";
+ glossary_print_entry_approval($cm, $entry, $tab);
+ echo "<b>";
+ glossary_print_entry_concept($entry);
+ echo "</b><br />";
echo "<font size=\"2\">$strby $user->firstname $user->lastname</font>";
echo " <font size=1>(".get_string("lastedited").": ".
userdate($entry->timemodified).")</font>";
- }
- echo "</tr>";
+ echo "</tr>";
+
+ echo "\n<tr>";
+ echo "\n<td bgcolor=\"$colour\" width=35 valign=top class=\"forumpostside\"> </td>";
+ echo "\n<td width=100% align=\"top\" bgcolor=\"$THEME->cellcontent\" class=\"forumpostmessage\">";
- echo "\n<tr>";
- echo "\n<td bgcolor=\"$colour\" width=35 valign=top class=\"forumpostside\"> </td>";
- echo "\n<td width=100% align=\"top\" bgcolor=\"$THEME->cellcontent\" class=\"forumpostmessage\">";
- if ($entry) {
if ($entry->attachment) {
$entry->course = $course->id;
if (strlen($entry->definition)%2) {
} else {
$align = "left";
}
- echo "<table border=0 align=$align><tr><td>";
- echo glossary_print_attachments($entry);
- echo "</td></tr></table>";
+ glossary_print_entry_attachment($entry,"",$align);
}
- echo format_text($entry->definition, $entry->format);
+ glossary_print_entry_definition($entry);
glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab,$cat);
if ( $entry ) {
$colour = $THEME->cellheading2;
- echo "\n<table border=1 cellspacing=0 width=95% valign=top cellpadding=10>";
+ echo '<table border=1 cellspacing=0 width=95% valign=top cellpadding=10>';
- echo "\n<tr>";
+ echo '<tr>';
echo "<td width=100% bgcolor=\"$colour\">";
$entry->course = $course->id;
- if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
- echo "<a title=\"" . get_string("approve","glossary"). "\" href=\"approve.php?id=$cm->id&eid=$entry->id&tab=$tab\"><IMG align=\"right\" src=\"check.gif\" border=0 width=\"34\" height=\"34\"></a>";
- }
- if ($entry->attachment) {
- echo "<table border=0 align=right><tr><td>";
- echo glossary_print_attachments($entry, "html");
- echo "</td></tr></table>";
- }
- echo "<b>" . get_string("question","glossary") . ":</b> $entry->concept<br>";
- echo " <font size=1>".get_string("lastedited").": ".userdate($entry->timemodified)."</font></tr>";
- echo "\n<tr><td width=100% bgcolor=\"$THEME->cellcontent\">";
- echo "<b>" . get_string("answer","glossary") . ":</b> " . format_text($entry->definition, $entry->format);
+ glossary_print_entry_approval($cm, $entry, $tab);
+ glossary_print_entry_attachment($entry,"html","right");
+
+ echo '<b>' . get_string("question","glossary") . ':</b> ';
+ echo glossary_print_entry_concept($entry) . '<br>';
+ echo ' <font size=1>' . get_string("lastedited").': '.userdate($entry->timemodified) . '</font></tr>';
+ echo "<tr><td width=100% bgcolor=\"$THEME->cellcontent\">";
+ echo '<b>' . get_string("answer","glossary") . ':</b> ';
+ echo glossary_print_entry_definition($entry);
+
glossary_print_entry_icons($course, $cm, $glossary, $entry, $tab, $cat);
- echo "</td></tr></table>\n";
+ echo '</td></tr></table>';
} else {
- echo "<center>";
+ echo '<center>';
print_string("noentry", "glossary");
- echo "</center>";
+ echo '</center>';
}
}
echo "\n<tr>";
echo "<td width=100% bgcolor=\"$colour\">";
- if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
- echo "<a title=\"" . get_string("approve","glossary"). "\" href=\"approve.php?id=$cm->id&eid=$entry->id&tab=$tab\"><IMG align=\"right\" src=\"check.gif\" border=0 width=\"34\" height=\"34\"></a>";
- }
- if ($entry->attachment) {
- $entry->course = $course->id;
- echo "<table border=0 align=right><tr><td>";
- echo glossary_print_attachments($entry, "html");
- echo "</td></tr></table>";
- }
- echo "<b>$entry->concept</b><br>";
+ glossary_print_entry_approval($cm, $entry, $tab);
if ($entry) {
+ glossary_print_entry_attachment($entry,"html","right");
+ echo "<b>";
+ glossary_print_entry_concept($entry);
+ echo "</b><br />";
echo " <font size=1>".get_string("lastedited").": ".userdate($entry->timemodified)."</font>";
- }
- echo "</tr>";
-
- echo "\n<tr><td width=100% bgcolor=\"$THEME->cellcontent\">";
- if ($entry) {
- echo format_text($entry->definition, $entry->format);
-
+ echo "</tr>";
+ echo "\n<tr><td width=100% bgcolor=\"$THEME->cellcontent\">";
+
+ glossary_print_entry_definition($entry);
glossary_print_entry_icons($course, $cm, $glossary, $entry, $tab, $cat);
-
} else {
echo "<center>";
print_string("noentry", "glossary");
$link = "<A HREF=\"view.php?id=$glossary->coursemodule\">$glossary->name</A>";
}
- $count = count_records("glossary_entries", "glossaryid", $glossary->id);
+ $count = count_records_sql("SELECT COUNT(*) FROM {$CFG->prefix}glossary_entries where (glossaryid = $glossary->id or sourceglossaryid = $glossary->id)");
if ($course->format == "weeks" or $course->format == "topics") {
if (empty($glossary->section)) {
}
}
}
+function glossary_print_entry_concept($entry) {
+ echo $entry->concept;
+}
+
+function glossary_print_entry_definition($entry) {
+ $definition = str_ireplace($entry->concept,"<nolink>$entry->concept</nolink>",$entry->definition);
+ echo format_text($definition, $entry->format);
+}
+
+function glossary_print_entry_attachment($entry,$format,$align) {
+/// valid format values: html : Return the HTML link for the attachment as an icon
+/// text : Return the HTML link for tha attachment as text
+/// blank : Print the output to the screen
+ if ($entry->attachment) {
+ $glossary = get_record("glossary","id",$entry->glossaryid);
+ $entry->course = $glossary->course; //used inside print_attachment
+ echo "<table border=0 align=$align><tr><td>";
+ echo glossary_print_attachments($entry,$format,$align);
+ echo "</td></tr></table>";
+ }
+}
+
+function glossary_print_entry_approval($cm, $entry, $tab) {
+ if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
+ echo "<a title=\"" . get_string("approve","glossary"). "\" href=\"approve.php?id=$cm->id&eid=$entry->id&tab=$tab\"><IMG align=\"right\" src=\"check.gif\" border=0 width=\"34\" height=\"34\"></a>";
+ }
+}
function glossary_print_entry_by_default($course, $cm, $glossary, $entry,$tab="",$cat="") {
global $THEME, $USER;
$colour = $THEME->cellheading2;
echo "\n<TR>";
- echo "<TD WIDTH=100% valign=\"top\" BGCOLOR=\"#FFFFFF\">";
- if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
- echo "<a title=\"" . get_string("approve","glossary"). "\" href=\"approve.php?id=$cm->id&eid=$entry->id&tab=$tab\"><IMG align=\"right\" src=\"check.gif\" border=0 width=\"34\" height=\"34\"></a>";
- }
- if ($entry->attachment) {
- $entry->course = $course->id;
- echo "<table border=0 align=right><tr><td>";
- echo glossary_print_attachments($entry,"html");
- echo "</td></tr></table>";
- }
- echo "<b>$entry->concept</b>: ";
- echo format_text($entry->definition, $entry->format);
- glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab,$cat);
+ echo "<TD WIDTH=100% class=\"generalbox\" valign=\"top\" BGCOLOR=\"#FFFFFF\">";
+ glossary_print_entry_approval($cm, $entry, $tab);
+ glossary_print_entry_attachment($entry,"html","right");
+ echo "<b>";
+ glossary_print_entry_concept($entry);
+ echo ":</b> ";
+ glossary_print_entry_definition($entry);
+ glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab,$cat);
echo "</td>";
echo "</TR>";
}
function glossary_print_entry_continuous($course, $cm, $glossary, $entry,$tab="",$cat="") {
global $THEME, $USER;
if ($entry) {
- if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
- echo "<a title=\"" . get_string("approve","glossary"). "\" href=\"approve.php?id=$cm->id&eid=$entry->id&tab=$tab\"><IMG align=\"right\" src=\"check.gif\" border=0 width=\"34\" height=\"34\"></a>";
- }
- if ($entry->attachment) {
- $entry->course = $course->id;
- echo "<table border=0 align=right><tr><td>";
- echo glossary_print_attachments($entry, "html");
- echo "</td></tr></table>";
- }
- echo " $entry->concept ";
- echo format_text($entry->definition, $entry->format);
-
+ glossary_print_entry_approval($cm, $entry, $tab);
+ glossary_print_entry_attachment($entry,"html","right");
+ glossary_print_entry_concept($entry);
+ echo " ";
+ glossary_print_entry_definition($entry);
glossary_print_entry_icons($course, $cm, $glossary, $entry, $tab, $cat);
}
}
+
function glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab="",$cat="") {
global $THEME, $USER;
function glossary_print_comment($course, $cm, $glossary, $entry, $comment) {
global $THEME, $CFG, $USER;
-// if ($entry->timemarked < $entry->modified) {
- $colour = $THEME->cellheading2;
-// } else {
-// $colour = $THEME->cellheading;
-// }
+ $colour = $THEME->cellheading2;
$user = get_record("user", "id", $comment->userid);
$strby = get_string("writtenby","glossary");
echo "<br><FONT SIZE=1>(".get_string("lastedited").": ".userdate($comment->timemodified).")</FONT></small><br>";
echo "</TD>";
- echo "<TD NOWRAP valign=top WIDTH=75% BGCOLOR=\"$THEME->cellcontent\">";
+ echo "<TD valign=top WIDTH=75% BGCOLOR=\"$THEME->cellcontent\">";
if ($comment) {
echo format_text($comment->comment, $comment->format);
} else {
echo "</td></tr></table>";
}
- function glossary_print_dynaentry($courseid, $entries) {
- global $THEME, $USER;
-
- $colour = $THEME->cellheading2;
-
- echo "\n<center><table width=95% border=0><tr>";
- echo "<td width=100%\">";
- if ( $entries ) {
- foreach ( $entries as $entry ) {
+function glossary_print_dynaentry($courseid, $entries) {
+ global $THEME, $USER;
- if (! $glossary = get_record("glossary", "id", $entry->glossaryid)) {
- error("Glossary ID was incorrect or no longer exists");
- }
- if (! $course = get_record("course", "id", $glossary->course)) {
- error("Glossary is misconfigured - don't know what course it's from");
- }
- if (!$cm = get_coursemodule_from_instance("glossary", $entry->glossaryid, $courseid) ) {
- error("Glossary is misconfigured - don't know what course module it is ");
- }
+ $colour = $THEME->cellheading2;
- glossary_print_entry($course, $cm, $glossary, $entry);
+ echo "\n<center><table width=95% border=0><tr>";
+ echo "<td width=100%\">";
+ if ( $entries ) {
+ foreach ( $entries as $entry ) {
+ if (! $glossary = get_record("glossary", "id", $entry->glossaryid)) {
+ error("Glossary ID was incorrect or no longer exists");
}
+ if (! $course = get_record("course", "id", $glossary->course)) {
+ error("Glossary is misconfigured - don't know what course it's from");
+ }
+ if (!$cm = get_coursemodule_from_instance("glossary", $entry->glossaryid, $courseid) ) {
+ error("Glossary is misconfigured - don't know what course module it is ");
+ }
+ glossary_print_entry($course, $cm, $glossary, $entry);
}
- echo "</td>";
- echo "</tr></table></center>";
}
+ echo "</td>";
+ echo "</tr></table></center>";
+}
?>
}
add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id&tab=$tab", "$glossary->id");
+/// stablishing default tab
+ $framebydefault = GLOSSARY_STANDARD_VIEW;
+ if ($glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS) {
+ $framebydefault = GLOSSARY_DATE_VIEW;
+ }
/// checking for valid values for sortorder and sortkey
if ( $sortorder = strtolower($sortorder) ) {
if ($sortorder != 'asc' and $sortorder != 'desc') {
$sortorder = '';
} else {
- $l = '';
+ $l = ''; /// if we are sorting by date, reset the searching by terms or letters
$search = '';
}
}
$sortkey = '';
}
}
+/// in this point:
+/// $sortkey = CREATION | UPDATE | ''
+/// $sortorder = asc | desc | ''
+
+ if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
+ $tab = $framebydefault;
- if ( $sortkey or $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS) {
- if ( !$sortkey and $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS) {
+ if ( !$sortkey ) {
$sortkey = 'CREATION';
- $sortorder = 'asc';
}
if ( !$sortorder ) {
$sortorder = 'asc';
}
} else {
- $orderby = 'concept ASC';
+ if ( !$sortkey ) {
+ $sortkey = 'concept';
+ }
+ if ( !$sortorder ) {
+ $sortorder = 'asc';
+ }
}
// creating matrix of words to search if apply
$search = trim(strip_tags($search));
- if ($search and !$eid) {
+ if ($search and !$eid) { /// searching terms
$l = '';
$searchterms = explode(' ', $search); // Search for words independently
foreach ($searchterms as $key => $searchterm) {
}
}
$search = trim(implode(' ', $searchterms));
- $tab = GLOSSARY_STANDARD_VIEW;
- } elseif ($eid) {
+ $tab = $framebydefault;
+ } elseif ($eid) { /// searching a specify entry
$search = '';
}
$alphabet = explode('|', get_string("alphabet","glossary"));
- if ($l == '' and $search == '' and $sortkey == '' and !$eid) {
+ if ($l == '' and $search == '' and !$eid) {
// if the user is just entering the glossary...
if ($tab != GLOSSARY_APPROVAL_VIEW) {
$l = $alphabet[0];
} else {
- $l = 'ALL';
+ $l = 'ALL'; /// show ALL by default in the waiting approval frame
}
} elseif ($eid) {
$l = '';
$glossary_tCFG->TabsPerRow = 4;
$glossary_tCFG->TabSeparation = 4;
- $data[GLOSSARY_STANDARD_VIEW]->link = "view.php?id=$id";
$data[GLOSSARY_STANDARD_VIEW]->caption = get_string("standardview", "glossary");
-
- $data[GLOSSARY_CATEGORY_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_CATEGORY_VIEW;
$data[GLOSSARY_CATEGORY_VIEW]->caption = get_string("categoryview", "glossary");
-
- $data[GLOSSARY_DATE_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_DATE_VIEW;
$data[GLOSSARY_DATE_VIEW]->caption = get_string("dateview", "glossary");
+ $data[GLOSSARY_DATE_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_DATE_VIEW;
+ if ( $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS ) {
+ $data[GLOSSARY_STANDARD_VIEW]->link = "view.php?id=$id";
+ $data[GLOSSARY_CATEGORY_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_CATEGORY_VIEW;
+ }
+
if (isteacher($course->id)) {
$data[GLOSSARY_APPROVAL_VIEW]->caption = get_string("waitingapproval", "glossary");
$data[GLOSSARY_APPROVAL_VIEW]->link = "";
$data[GLOSSARY_APPROVAL_VIEW]->caption .= "<br><font size=1>(" . count($hiddenentries) . " " . get_string("entries","glossary") . ")</font>";
$data[GLOSSARY_APPROVAL_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_APPROVAL_VIEW;
} elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) {
- $tab = GLOSSARY_STANDARD_VIEW;
+ $tab = $framebydefault;
}
} elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) {
- $tab = GLOSSARY_STANDARD_VIEW;
+ $tab = $framebydefault;
}
/// printing header of the current tab
/// Printing the entries
+ switch ($sortkey) {
+ case 'CREATION':
+ $orderby = "timecreated $sortorder";
+ break;
+ case 'UPDATE':
+ $orderby = "timemodified $sortorder";
+ break;
+ default:
+ $orderby = "$sortkey $sortorder";
+ }
+
switch ($tab) {
case GLOSSARY_CATEGORY_VIEW:
if ($cat == GLOSSARY_SHOW_ALL_CATEGORIES) {
} elseif ($eid) { // looking for an entry
$allentries = get_records_select("glossary_entries", "id = $eid");
} elseif ( $l or $sortkey ) {
- if ($sortkey == 'CREATION') {
- $orderby = "timecreated $sortorder";
- } else {
- $orderby = "timemodified $sortorder";
- }
$where = '';
if ($l != 'ALL' and $l != 'SPECIAL') {
switch ($CFG->dbtype) {
} else {
switch ($glossary->displayformat) {
case GLOSSARY_FORMAT_CONTINUOUS:
- echo '</td></tr></table>';
+ echo '</td></tr></table><p>';
break;
case GLOSSARY_FORMAT_SIMPLE:
- echo '</table></center>';
+ echo '</table></center><p>';
break;
}
}