$string['addcomment'] = "Add comment";
$string['addentry'] = "Add a new entry";
-$string['approve'] = "Approve";
+$string['addingcomment'] = "Add a comment";
$string['aliases'] = "Alias(es)";
$string['allentries'] = "ALL";
$string['allcategories'] = "All Categories";
$string['allowcomments'] = "Allow comments on entries";
$string['allowduplicatedentries'] = "Duplicated entries allowed";
$string['answer'] = "Answer";
+$string['approve'] = "Approve";
+$string['authorview'] = "Browse by Author";
$string['areyousuredelete'] = "Are you sure you want to delete this entry?";
$string['areyousuredeletecomment'] = "Are you sure you want to delete this comment?";
+$string['areyousureexport'] = "Are you sure you want to export this entry to";
$string['ascending'] = "(ascending)";
$string['attachment'] = "Attachment";
$string['back'] = "Back";
$string['editingcomment'] = "Editing comment";
$string['entries'] = "Entries";
$string['importedentries'] = "Imported entries";
+$string['entbypage'] = "Entries shown by page";
$string['entrieswithoutcategory'] = "Entries without category";
$string['entry'] = "Entry";
$string['entryalreadyexist'] = "Entry already exists";
$string['glosssaryexported'] = "Glossary exported.";
$string['importcategories'] = "Import categories";
$string['isglobal'] = "Is this glossary global?";
+$string['linkcategory'] = "Automatically link this category";
$string['mainglossary'] = "Main glossary";
$string['modulename'] = "Glossary";
$string['modulenameplural'] = "Glossaries";
$string['maxtimehaspassed'] = "Sorry, but the maximum time for editing this comment (\$a) has passed!";
$string['newglossary'] = "New glossary";
+$string['newentries'] = "New glossary entries";
$string['newglossaryentries'] = "New glossary entries:";
$string['newglossarycreated'] = "New glossary created.";
$string['notcategorised'] = "Not categorised";
$string['nocomments'] = "(No comments found on this entry)";
$string['noentries'] = "No entries found in this section";
$string['noentry'] = "No entry found.";
+$string['numberofentries'] = "Number of entries";
$string['onebyline'] = "(one by line)";
$string['printerfriendly'] = "Printer-friendly version";
$string['question'] = "Question";
--- /dev/null
+<P ALIGN=CENTER><B>Definition destination of imported entries</B></P>
+
+<P>You can specify where do you want to import the entries:</p>
+<ul>
+<li><strong>Current Glossary:</strong> Will append the imported entries to the current glossary.</li>
+<li><strong>New Glossary:</strong> Will create a new glossary based on the information found in the XML file selected and will insert the new entries on it.</li>
+</ul>
--- /dev/null
+<P ALIGN=CENTER><B>Defining number of entries shown by page</B></P>
+
+<P>You can specify the number of entries shown by page. This number depends on the configuration of the glossary.</p>
+
+<p>The more automatically linked entries you have, the lower this number should be in order to avoid long answer time from the application.</p>
+
+<p>Note: If you get a timout error when browsing a glossary, it probable needs to have a lower number of entries shown by page.</p>
--- /dev/null
+<P ALIGN=CENTER><B>File to import</B></P>
+
+<P>Select the XML file which contains the entries to import.</p>
--- /dev/null
+<P ALIGN=CENTER><B>Importing categories</B></P>
+
+<P>By default, all the entries will be imported. You can specify if you want the categories to be imported as well (it will import the relationship between the imported categories and the imported entries also).</p>
<li><a href="help.php?module=glossary&file=studentcanpost.html">Students can post entries</a>
<li><a href="help.php?module=glossary&file=allowcomments.html">Comments on entries</a>
<li><a href="help.php?module=glossary&file=displayformat.html">Display formats for entries</a>
+ <li><a href="help.php?module=glossary&file=entbypage.html">Number of entries shown by page</a>
<li><a href="help.php?module=glossary&file=shows.html">Browsing options in Alphabet View frame</a>
+ <li><a href="help.php?module=glossary&file=linkcategories.html">Automatically linking categories</a>
+ <li><a href="help.php?module=glossary&file=filetoimport.html">Importing entries</a>
+ <li><a href="help.php?module=glossary&file=importcategories.html">Importing categories</a>
+ <li><a href="help.php?module=glossary&file=destination.html">Destination of the entries to import</a>
</ul>
</blockquote>
--- /dev/null
+<P ALIGN=CENTER><B>Automatically linking categories</B></P>
+
+<P>You can specify if you want the categories to be automatically linked or not.</p>
+
+<p>Note: Categories are linked based on a case sensitive, full whole match.</p>
require_variable($id); // Course Module ID
optional_variable($eid); // Entry ID
- optional_variable($tab,GLOSSARY_APPROVAL_VIEW);
- optional_variable($l,"ALL");
+ optional_variable($mode,"approval");
+ optional_variable($hook,"ALL");
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
} else {
add_to_log($course->id, "glossary", "approve entry", "showentry.php?id=$cm->id&eid=$eid", "$eid");
}
- redirect("view.php?id=$cm->id&tab=$tab&l=$l",get_string("entryapproved","glossary"),1);
+ redirect("view.php?id=$cm->id&mode=$mode&hook=$hook",get_string("entryapproved","glossary"),1);
die;
?>
\ No newline at end of file
fwrite ($bf,full_tag("ID",6,false,$glo_cat->id));
fwrite ($bf,full_tag("GLOSSARYID",6,false,$glo_cat->glossaryid));
fwrite ($bf,full_tag("NAME",6,false,$glo_cat->name));
+ fwrite ($bf,full_tag("USEDYNALINK",6,false,$glo_cat->usedynalink));
$status = backup_glossary_entries_categories ($bf,$preferences,$glo_cat->id);
echo "<br />";
}
- glossary_print_entry($course, $cm, $glossary, $entry);
+ echo "<p align=center>";
+ echo "<table class=\"generalbox\" width=\"70%\" align=\"center\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\">";
+ echo "<tr bgcolor=$THEME->cellheading2><td align=center>";
+ echo "<table border=0 width=100%><tr><td width=33%></td><td width=33% align=center>";
+ echo get_string("commentson","glossary") . " <b>$entry->concept</b></td>";
+ echo "<td width=33% align=right>";
+ echo "</td></tr></table>";
+
+ echo "</td></tr>";
+ echo "<tr><TD WIDTH=100% BGCOLOR=\"#FFFFFF\">";
+ 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);
+ echo "</td>";
+ echo "</TR></table>";
+
echo "<center>";
echo "<br />";
<tr valign=top>
<td align=right><p>glossary_entbypage:</td>
<td>
- <input name=glossary_entbypage type=text size=5 value="<?php p($CFG->glossary_entbypage) ?>">
+ <input name=glossary_entbypage type=text size=3 value="<?php p($CFG->glossary_entbypage) ?>">
</td>
<td>
<?php print_string("entbypage", "glossary") ?>
</td>
</tr>
<tr valign=top>
- <td align=right><p>students_can_post_entries:</td>
+ <td align=right><p>glossary_studentspost:</td>
<td>
- <SELECT size=1 name=cnfstudentcanpost>
+ <SELECT size=1 name=glossary_studentspost>
<?php
$yselected = "";
$nselected = "";
- if ($CFG->cnfstudentcanpost) {
+ if ($CFG->glossary_studentspost) {
$yselected = " SELECTED ";
} else {
$nselected = " SELECTED ";
</td>
</tr>
<tr valign=top>
- <td align=right><p>allow_duplicated_entries:</td>
+ <td align=right><p>glossary_dupentries:</td>
<td>
- <SELECT size=1 name=cnfallowdupentries>
+ <SELECT size=1 name=glossary_dupentries>
<?php
$yselected = "";
$nselected = "";
- if ($CFG->cnfallowdupentries) {
+ if ($CFG->glossary_dupentries) {
$yselected = " SELECTED ";
} else {
$nselected = " SELECTED ";
</td>
</tr>
<tr valign=top>
- <td align=right><p>allow_comments:</td>
+ <td align=right><p>glossary_allowcomments:</td>
<td>
- <SELECT size=1 name=cngallowcomments>
+ <SELECT size=1 name=glossary_allowcomments>
<?php
$yselected = "";
$nselected = "";
- if ($CFG->cngallowcomments) {
+ if ($CFG->glossary_allowcomments) {
$yselected = " SELECTED ";
} else {
$nselected = " SELECTED ";
</SELECT>
</td>
<td>
- <?php print_string("cngallowcomments", "glossary") ?>
+ <?php print_string("cnfallowcomments", "glossary") ?>
</td>
</tr>
<tr valign=top>
- <td align=right><p>automatically_link_glossaries:</td>
+ <td align=right><p>glossary_linkbydefault:</td>
<td>
- <SELECT size=1 name=cnflinkglossaries>
+ <SELECT size=1 name=glossary_linkbydefault>
<?php
$yselected = "";
$nselected = "";
- if ($CFG->cnflinkglossaries) {
+ if ($CFG->glossary_linkbydefault) {
$yselected = " SELECTED ";
} else {
$nselected = " SELECTED ";
</td>
</tr>
<tr valign=top>
- <td align=right><p>default_approval_status:</td>
+ <td align=right><p>glossary_defaultapproval:</td>
<td>
- <SELECT size=1 name=cnfapprovalstatus>
+ <SELECT size=1 name=glossary_defaultapproval>
<?php
$yselected = "";
$nselected = "";
- if ($CFG->cnfapprovalstatus) {
+ if ($CFG->glossary_defaultapproval) {
$yselected = " SELECTED ";
} else {
$nselected = " SELECTED ";
<td colspan = 3 align=center><strong>Entry Level Default Settings</strong></td>
</tr>
<tr valign=top>
- <td align=right><p>automatically_link_entry:</td>
+ <td align=right><p>glossary_linkentries:</td>
<td>
- <SELECT size=1 name=cnflinkentry>
+ <SELECT size=1 name=glossary_linkentries>
<?php
$yselected = "";
$nselected = "";
- if ($CFG->cnflinkentry) {
+ if ($CFG->glossary_linkentries) {
$yselected = " SELECTED ";
} else {
$nselected = " SELECTED ";
</td>
</tr>
<tr valign=top>
- <td align=right><p>case_sensitive:</td>
+ <td align=right><p>glossary_casesensitive:</td>
<td>
- <SELECT size=1 name=cnfcasesensitive>
+ <SELECT size=1 name=glossary_casesensitive>
<?php
$yselected = "";
$nselected = "";
- if ($CFG->cnfcasesensitive) {
+ if ($CFG->glossary_casesensitive) {
$yselected = " SELECTED ";
} else {
$nselected = " SELECTED ";
</td>
</tr>
<tr valign=top>
- <td align=right><p>match_whole_words:</td>
+ <td align=right><p>glossary_fullmatch:</td>
<td>
- <SELECT size=1 name=cnffullmatch>
+ <SELECT size=1 name=glossary_fullmatch>
<?php
$yselected = "";
$nselected = "";
- if ($CFG->cnffullmatch) {
+ if ($CFG->glossary_fullmatch) {
$yselected = " SELECTED ";
} else {
$nselected = " SELECTED ";
PRIMARY KEY (`id`)
) TYPE=MyISAM COMMENT='entries alias'");
}
+
+ if ( $oldversion < 2003111500 ) {
+ execute_sql( "ALTER TABLE `{$CFG->prefix}glossary_categories`
+ ADD `usedynalink` TINYINT(2) UNSIGNED NOT NULL DEFAULT '1' AFTER `name`" );
+
+ execute_sql( "ALTER TABLE `{$CFG->prefix}glossary`
+ ADD `entbypage` TINYINT(3) UNSIGNED NOT NULL DEFAULT '10' AFTER `globalglossary`" );
+
+ }
return true;
}
usedynalink tinyint(2) unsigned NOT NULL default '1',
defaultapproval tinyint(2) unsigned NOT NULL default '1',
globalglossary tinyint(2) unsigned NOT NULL default '0',
+ entbypage tinyint(3) unsigned NOT NULL default '10',
timecreated int(10) unsigned NOT NULL default '0',
timemodified int(10) unsigned NOT NULL default '0',
PRIMARY KEY (id)
id int(10) unsigned NOT NULL auto_increment,
glossaryid int(10) unsigned NOT NULL default '0',
name varchar(255) NOT NULL default '',
+ usedynalink tinyint(2) unsigned NOT NULL default '1',
PRIMARY KEY (id)
) TYPE=MyISAM COMMENT='all categories for glossary entries';
allowcomments int2 NOT NULL default '0',
usedynalink int2 NOT NULL default '1',
globalglossary int2 NOT NULL default '0',
+ entbypage int NOT NULL default '10',
timecreated int4 NOT NULL default '0',
timemodified int4 NOT NULL default '0',
PRIMARY KEY (id)
id SERIAL,
glossaryid int4 NOT NULL default '0',
name varchar(255) NOT NULL default '',
+ usedynalink int2 NOT NULL default '1',
PRIMARY KEY (id)
);
<input type="hidden" name=mode value="delete">
<input type="hidden" name=go value="1">
<input type="hidden" name=entry value="<?php echo $entry ?>">
-<input type="hidden" name=currentview value="<?=$currentview ?>">
-<input type="hidden" name=cat value="<?=$cat ?>">
+<input type="hidden" name=mode value="<?=$mode ?>">
+<input type="hidden" name=hook value="<?=$hook ?>">
<input type="submit" value=" <?php print_string("yes")?> ">
<input type=button value=" <?php print_string("no")?> " onclick="javascript:history.go(-1);">
require_variable($mode); // edit or delete
optional_variable($go); // commit the operation?
optional_variable($entry); // entry id
- optional_variable($tab); // browsing entries by categories?
- optional_variable($cat); // categoryID
+ require_variable($prevmode); // current frame
+ optional_variable($hook); // pivot id
$strglossary = get_string("modulename", "glossary");
$strglossaries = get_string("modulenameplural", "glossary");
if ($mode == "edit" or $mode == "delete" ) {
echo "<p>";
- if ( isteacher($cm->id) or $glossary->studentcanpost ) {
+ if ( isteacher($course->id) or $glossary->studentcanpost ) {
if ($go) { // the operation was confirmed.
if ( $mode == "delete") {
// if it is an imported entry, just delete the relation
print_simple_box_end();
}
print_footer($course);
- add_to_log($course->id, "glossary", "delete entry", "view.php?id=$cm->id&tab=$tab&cat=$cat", $entry);
- redirect("view.php?id=$cm->id&tab=$tab&cat=$cat");
+ add_to_log($course->id, "glossary", "delete entry", "view.php?id=$cm->id&mode=$prevmode&hook=$hook", $entry);
+ redirect("view.php?id=$cm->id&mode=$prevmode&hook=$hook");
} else { // the operation has not been confirmed yet so ask the user to do so
if ( $mode == "delete") {
print_simple_box_start("center","40%", "#FFBBBB");
<input type="hidden" name=mode value="delete">
<input type="hidden" name=go value="1">
<input type="hidden" name=entry value="<?php p($entry) ?>">
- <input type="hidden" name=tab value=<?php p($tab) ?>>
- <input type="hidden" name=cat=<?php p($cat) ?>>
+ <input type="hidden" name=prevmode value=<?php p($prevmode) ?>>
+ <input type="hidden" name=hook value=<?php p($hook) ?>>
<input type="submit" value=" <?php print_string("yes")?> ">
<input type=button value=" <?php print_string("no")?> " onclick="javascript:history.go(-1);">
}
$entries = get_records_select("glossary_entries", "glossaryid IN ($glossaries) AND usedynalink != 0 and approved != 0 and concept != ''","$ebylenght glossaryid","id,glossaryid,concept,casesensitive,$GLOSSARY_CONCEPT_IS_ENTRY category,fullmatch");
- $categories = get_records_select("glossary_categories", "glossaryid IN ($glossaries)", "$cbylenght glossaryid,id","id,glossaryid,name concept, 1 casesensitive,$GLOSSARY_CONCEPT_IS_CATEGORY category, 1 fullmatch");
+ $categories = get_records_select("glossary_categories", "glossaryid IN ($glossaries) AND usedynalink != 0", "$cbylenght glossaryid,id","id,glossaryid,name concept, 1 casesensitive,$GLOSSARY_CONCEPT_IS_CATEGORY category, 1 fullmatch");
if ( $entries and $categories ) {
$concepts = array_merge($entries, $categories);
usort($concepts,'glossary_sort_entries_by_lenght');
}
$cm = get_coursemodule_from_instance("glossary", $glossary->id, $courseid);
$title = strip_tags("$glossary->name: " . get_string("category","glossary"). " $category->name");
- $href_tag_begin = "<a class=\"autolink\" title=\"$title\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&tab=1&cat=$concept->id\">";
+ $href_tag_begin = "<a class=\"autolink\" title=\"$title\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&mode=cat&hook=$concept->id\">";
} else {
$concepttitle = urlencode($concept->concept);
$title = strip_tags("$glossary->name: $concepttitle");
$currentconcept = str_replace("|", "\|", $concept->concept);
$currentconcept = str_replace("'", "\'", $currentconcept);
+ $currentconcept = str_replace("*", "\*", $currentconcept);
if ( $currentconcept = trim(strip_tags($currentconcept)) ) {
if ( !$concept->category ) {
if ( $aliases = get_records("glossary_alias","entryid",$concept->id) ) {
<table border=0>
<tr>
<td align=center width=58%>
-
+<?PHP
+ if ( !$glossary->usedynalink ) {
+ echo '<input type="hidden" name=usedynalink value="0">';
+ echo '<input type="hidden" name=casesensitive value="0">';
+ echo '<input type="hidden" name=fullmatch value="0">';
+ } else {
+?>
<table border=0 width=100%>
<tr><td align=right width=80%><small><?php echo get_string("entryusedynalink","glossary") ?>:</small></td><td width=20%>
<script>
<input type="checkbox" name="fullmatch" value=1 <?php p($selected) ?>> <?php helpbutton("fullmatch", strip_tags(get_string("fullmatch", "glossary")), "glossary") ?>
</td></tr>
</table>
+<?PHP
+ } // end-if !$usedynalink
+?>
</td>
<td align=center width=42% valign=top>
<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 ?>">
+ <input type="hidden" name=mode value="<?=$mode ?>">
+ <input type="hidden" name=hook value="<?=$hook ?>">
<input type="hidden" name=confirm value="1">
<input type="submit" value="<?php print_string("savechanges") ?>">
optional_variable($e); // EntryID
optional_variable($confirm,0); // proceed. Edit the edtry
-optional_variable($tab); // categories if by category?
-optional_variable($cat); // CategoryID
+optional_variable($mode); // categories if by category?
+optional_variable($hook); // CategoryID
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
if ( !isset($form->usedynalink) ) {
$form->usedynalink = 0;
}
+ if ( !isset($form->casesensitive) ) {
+ $form->casesensitive = 0;
+ }
+ if ( !isset($form->fullmatch) ) {
+ $form->fullmatch = 0;
+ }
$timenow = time();
$form->text = clean_text($form->text, $form->format);
if (! update_record("glossary_entries", $newentry)) {
error("Could not update your glossary");
} else {
- add_to_log($course->id, "glossary", "update entry", "view.php?id=$cm->id&eid=$newentry->id&tab=$tab&cat=$cat", "$newentry->id");
+ add_to_log($course->id, "glossary", "update entry", "view.php?id=$cm->id&mode=entry&hook=$newentry->id", "$newentry->id");
}
} else {
error("Could not update this glossary entry because this concept already exist.");
unset($newentry->attachment);
}
set_field("glossary_entries", "attachment", $newfilename, "id", $newentry->id);
- add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&eid=$newentry->id&tab=$tab&cat=$cat", "$newentry->id");
+ add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&mode=entry&hook=$newentry->id", "$newentry->id");
}
} else {
error("Could not insert this glossary entry because this concept already exist.");
}
}
- redirect("view.php?id=$cm->id&eid=$newentry->id&tab=$tab&cat=$cat");
+ redirect("view.php?id=$cm->id&mode=entry&hook=$newentry->id");
die;
} else {
if ($e) {
<INPUT type="text" name="name" size=30 value="<?=$name ?>">
</td>
</tr>
+<tr valign=top>
+ <td align=right><p><b><?php echo get_string("linkcategory","glossary") ?>:</b></p></td>
+ <td>
+ <select size="1" name="usedynalink">
+ <option value="1" <?php
+ if ( $usedynalink ) {
+ echo "selected";
+ }
+ ?>><?php echo get_string("yes") ?></option>
+ <option value="0" <?php
+ if ( !$usedynalink ) {
+ echo "selected";
+ }
+ ?>><?php echo get_string("no") ?>
+ </option>
+ </select> <?php helpbutton("linkcategory", get_string("linkcategory", "glossary"), "glossary") ?>
+ </td>
+</tr>
<td colspan=2>
<p align=center>
<input type="hidden" name=id value="<?=$cm->id ?>">
<input type="hidden" name=action value="<?=$action?>">
<input type="hidden" name=confirm value=1>
- <input type="hidden" name=cat value=<?php p($cat) ?>>
+ <input type="hidden" name=mode value='cat'>
+ <input type="hidden" name=hook value="<?=$hook?>">
<input type="submit" value="<?php print_string("savechanges") ?>">
<input type="reset" value="<?php print_string("back","glossary") ?>" onclick="javascript:history.go(-1);">
</P>
require_once("lib.php");
require_variable($id); // Course Module ID, or
- optional_variable($cat); // category ID
+ optional_variable($mode); // cat
+ optional_variable($hook); // category ID
optional_variable($action); // what to do
+ optional_variable($usedynalink); // category ID
optional_variable($confirm); // confirm the action
optional_variable($name); // confirm the action
"", "", true, update_module_button($cm->id, $course->id, $strglossary),
navmenu($course, $cm));
- if ( $cat ) {
- $category = get_record("glossary_categories","id",$cat);
+ if ( $hook ) {
+ $category = get_record("glossary_categories","id",$hook);
if ( $action == "edit" ) {
if ( $confirm ) {
$action = "";
- $CategoryObject->id = $cat;
- $CategoryObject->name = $name;
+ $cat->id = $hook;
+ $cat->name = $name;
+ $cat->usedynalink = $usedynalink;
- if ( !update_record("glossary_categories", $CategoryObject) ) {
+ if ( !update_record("glossary_categories", $cat) ) {
error("Weird error. The category was not updated.");
redirect("editcategories.php?id=$cm->id");
} else {
- add_to_log($course->id, "glossary", "edit category", "editcategories.php?id=$cm->id", $cat);
+ add_to_log($course->id, "glossary", "edit category", "editcategories.php?id=$cm->id", $hook);
}
} else {
echo "<p align=\"center\">" . get_string("edit"). " " . get_string("category","glossary") . "<font size=\"3\">";
$name = $category->name;
+ $usedynalink = $category->usedynalink;
require "editcategories.html";
print_footer();
die;
} elseif ( $action == "delete" ) {
if ( $confirm ) {
- delete_records("glossary_entries_categories","categoryid", $cat);
- delete_records("glossary_categories","id", $cat);
+ delete_records("glossary_entries_categories","categoryid", $hook);
+ delete_records("glossary_categories","id", $hook);
print_simple_box_start("center","40%", "#FFBBBB");
echo "<center>" . get_string("categorydeleted","glossary") ."</center>";
print_footer($course);
- add_to_log($course->id, "glossary", "delete category", "editcategories.php?id=$cm->id", $cat);
+ add_to_log($course->id, "glossary", "delete category", "editcategories.php?id=$cm->id", $hook);
redirect("editcategories.php?id=$cm->id");
} else {
<input type="hidden" name=id value="<?php p($cm->id) ?>">
<input type="hidden" name=action value="delete">
<input type="hidden" name=confirm value="1">
- <input type="hidden" name=cat value="<?php echo $cat ?>">
+ <input type="hidden" name=mode value="<?php echo $mode ?>">
+ <input type="hidden" name=hook value="<?php echo $hook ?>">
<table border=0 widTH=100><tr><td align=right width=50%>
<input type="submit" value=" <?php print_string("yes")?> ">
</form>
} else {
$action = "";
- $CategoryObject->name = $name;
- $CategoryObject->glossaryid = $glossary->id;
+ $cat->name = $name;
+ $cat->usedynalink = $usedynalink;
+ $cat->glossaryid = $glossary->id;
- if ( ! $CategoryObject->id = insert_record("glossary_categories", $CategoryObject) ) {
+ if ( ! $cat->id = insert_record("glossary_categories", $cat) ) {
error("Weird error. The category was not inserted.");
redirect("editcategories.php?id=$cm->id");
} else {
- add_to_log($course->id, "glossary", "add category", "editcategories.php?id=$cm->id", $CategoryObject->id);
+ add_to_log($course->id, "glossary", "add category", "editcategories.php?id=$cm->id", $cat->id);
}
}
} else {
</td>
<td width="10%" align="center"><b>
<?php
- echo "<a href=\"editcategories.php?id=$cm->id&action=delete&cat=$category->id\"><img alt=\"" . get_string("delete") . "\"src=\"../../pix/t/delete.gif\" height=11 width=11 border=0></a> ";
- echo "<a href=\"editcategories.php?id=$cm->id&action=edit&cat=$category->id\"><img alt=\"" . get_string("edit") . "\" src=\"../../pix/t/edit.gif\" height=11 width=11 border=0></a>";
+ echo "<a href=\"editcategories.php?id=$cm->id&action=delete&mode=cat&hook=$category->id\"><img alt=\"" . get_string("delete") . "\"src=\"../../pix/t/delete.gif\" height=11 width=11 border=0></a> ";
+ echo "<a href=\"editcategories.php?id=$cm->id&action=edit&mode=cat&hook=$category->id\"><img alt=\"" . get_string("edit") . "\" src=\"../../pix/t/edit.gif\" height=11 width=11 border=0></a>";
?>
</b></td>
</tr>
echo print_single_button("editcategories.php", $options, get_string("add") . " " . get_string("category","glossary"), "get");
echo "</td><td align=left>";
unset($options['action']);
- $options['currentview'] = "categories";
+ $options['mode'] = 'cat';
+ $options['hook'] = $hook;
echo print_single_button("view.php", $options, get_string("back","glossary") );
echo "</td></tr>";
echo "</tablee>";
$strsearchindefinition = get_string("searchindefinition", "glossary");
$strsearch = get_string("search");
+ $navigation = "";
+ if ($course->category) {
+ $navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
+ require_login($course->id);
+ }
+
print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname",
"$navigation <A HREF=index.php?id=$course->id>$strglossaries</A> -> $glossary->name",
"", "", true, update_module_button($cm->id, $course->id, $strglossary),
require_variable($id); // course module ID
require_variable($entry); // Entry ID
optional_variable($confirm); // confirmation
- optional_variable($currentview);
- optional_variable($cat);
+ optional_variable($mode);
+ optional_variable($hook);
global $THEME, $USER, $CFG;
if ( !$confirm ) {
echo "<center>";
-
- notice_yesno ("<center><h2>$entry->concept</h2><p align=center>Seguro que desea agregar esta entrada a<br><b>$mainglossary->name</b>?",
- "exportentry.php?id=$id¤tview=$currentview&cat=$cat&entry=$entry->id&confirm=1",
- "view.php?id=$cm->id¤tview=$currentview&cat=$cat&eid=".$entry->id );
+ $areyousure = get_string("areyousureexport","glossary");
+ notice_yesno ("<center><h2>$entry->concept</h2><p align=center>$areyousure<br><b>$mainglossary->name</b>?",
+ "exportentry.php?id=$id&mode=$mode&hook=$hook&entry=$entry->id&confirm=1",
+ "view.php?id=$cm->id&mode=$mode&hook=$hook" );
} else {
if ( ! $mainglossary->allowduplicatedentries ) {
print_simple_box_start("center", "60%", "$THEME->cellheading");
echo "<p align=center><font size=3>$entryexported</font></p></font>";
- print_continue("view.php?id=$cm->id&eid=".$entry->id);
+ print_continue("view.php?id=$cm->id&mode=entry&hook=".$entry->id);
print_simple_box_end();
print_footer();
- redirect("view.php?id=$cm->id&eid=".$entry->id);
+ redirect("view.php?id=$cm->id&mode=entry&hook=".$entry->id);
die;
}
} else {
echo "<p align=center><font size=3>$entryalreadyexist</font></p></font>";
echo "<p align=center>";
- print_continue("view.php?id=$cm->id&eid=".$entry->id);
+ print_continue("view.php?id=$cm->id&mode=entry&hook=".$entry->id);
print_simple_box_end();
}
}
} else {
print_simple_box_start("center", "60%", "#FFBBBB");
- echo "<p align=center><font size=3>A weird error was found while trying to export this entry. Operation cancelled.</font></p></font>";
+ notice("A weird error was found while trying to export this entry. Operation cancelled.");
- print_continue("view.php?id=$cm->id&eid=".$entry->id);
+ print_continue("view.php?id=$cm->id&mode=entry&hook=".$entry->id);
print_simple_box_end();
}
<?PHP // $Id$
-function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $tab="",$cat="") {
+function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons=1) {
global $THEME, $CFG, $USER;
$colour = $THEME->cellheading2;
echo "</td>";
echo "<td nowrap valign=\"top\" width=100% bgcolor=\"$THEME->cellheading\" class=\"forumpostheader\">";
- glossary_print_entry_approval($cm, $entry, $tab);
+ glossary_print_entry_approval($cm, $entry, $mode);
glossary_print_entry_attachment($entry,"html","right");
echo "<b>";
echo "\n<td width=100% bgcolor=\"$THEME->cellcontent\" class=\"forumpostmessage\">";
glossary_print_entry_definition($entry);
- glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$tab,$cat);
+ glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons);
} else {
echo "<center>";
<?PHP // $Id$
-function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $tab="",$cat="") {
+function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons=1) {
global $THEME, $CFG, $USER;
$colour = $THEME->cellheading2;
print_user_picture($user->id, $course->id, $user->picture);
echo "</td>";
echo "<td align=\"top\" nowrap width=100% bgcolor=\"$THEME->cellheading\" class=\"forumpostheader\">";
- glossary_print_entry_approval($cm, $entry, $tab);
+ glossary_print_entry_approval($cm, $entry, $mode);
echo "<b>";
glossary_print_entry_concept($entry);
echo "</b><br />";
}
glossary_print_entry_definition($entry);
- glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$tab,$cat);
+ glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons);
} else {
echo "<center>";
<?PHP // $Id$
-function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$tab="",$cat="") {
+function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$mode="",$hook="",$printicons=1) {
global $THEME, $USER;
if ( $entry ) {
echo '<tr>';
echo "<td width=100% bgcolor=\"$colour\">";
$entry->course = $course->id;
- glossary_print_entry_approval($cm, $entry, $tab);
+ glossary_print_entry_approval($cm, $entry, $mode);
glossary_print_entry_attachment($entry,"html","right");
echo '<b>' . get_string("question","glossary") . ':</b> ';
echo glossary_print_entry_definition($entry);
- glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $tab, $cat);
+ glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook,$printicons);
echo '</td></tr></table>';
} else {
<?PHP // $Id$
-function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$tab="",$cat="") {
+function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$mode="",$hook="",$printicons=1) {
global $THEME, $USER;
$colour = $THEME->cellheading2;
echo "\n<tr>";
echo "<td width=100% bgcolor=\"$colour\">";
- glossary_print_entry_approval($cm, $entry, $tab);
+ glossary_print_entry_approval($cm, $entry, $mode);
if ($entry) {
glossary_print_entry_attachment($entry,"html","right");
echo "<b>";
echo "\n<tr><td width=100% bgcolor=\"$THEME->cellcontent\">";
glossary_print_entry_definition($entry);
- glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $tab, $cat);
+ glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook,$printicons);
} else {
echo "<center>";
print_string("noentry", "glossary");
optional_variable($file); // file to import
optional_variable($catsincl,0); // Import Categories too?
- optional_variable($lasttab,GLOSSARY_STANDARD_VIEW);
- optional_variable($l,"ALL");
+ optional_variable($mode,'letter');
+ optional_variable($hook,"ALL");
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
$glossary->name = addslashes(utf8_decode($xmlglossary['NAME'][0]['#']));
$glossary->course = $course->id;
$glossary->globalglossary = $xmlglossary['GLOBALGLOSSARY'][0]['#'];
+ $glossary->entbypage = $xmlglossary['ENTBYPAGE'][0]['#'];
$glossary->intro = addslashes(utf8_decode($xmlglossary['INTRO'][0]['#']));
$glossary->showspecial = $xmlglossary['SHOWSPECIAL'][0]['#'];
$glossary->showalphabet = $xmlglossary['SHOWALPHABET'][0]['#'];
unset($newcat);
$newcat->name = $xmlcat['#']['NAME'][0]['#'];
+ $newcat->usedynalink = $xmlcat['#']['USEDYNALINK'][0]['#'];
if ( !$category = get_record("glossary_categories","glossaryid",$glossary->id,"name",$newcat->name) ) {
// Create the category if it does not exist
unset($category);
define("GLOSSARY_SHOW_ALL_CATEGORIES", 0);
define("GLOSSARY_SHOW_NOT_CATEGORISED", -1);
+define("GLOSSARY_NO_VIEW", -1);
define("GLOSSARY_STANDARD_VIEW", 0);
define("GLOSSARY_CATEGORY_VIEW", 1);
define("GLOSSARY_DATE_VIEW", 2);
-define("GLOSSARY_ADDENTRY_VIEW", 3);
-define("GLOSSARY_IMPORT_VIEW", 4);
-define("GLOSSARY_EXPORT_VIEW", 5);
-define("GLOSSARY_APPROVAL_VIEW", 6);
+define("GLOSSARY_AUTHOR_VIEW", 3);
+define("GLOSSARY_ADDENTRY_VIEW", 4);
+define("GLOSSARY_IMPORT_VIEW", 5);
+define("GLOSSARY_EXPORT_VIEW", 6);
+define("GLOSSARY_APPROVAL_VIEW", 7);
define("GLOSSARY_FORMAT_SIMPLE", 0);
define("GLOSSARY_FORMAT_CONTINUOUS", 1);
} else {
if ($categories = get_records("glossary_categories","glossaryid",$glossary->id)) {
$cats = "";
- foreach ( $categories as $cat ) {
+ foreach ( $categories as $hook ) {
$cats .= "$cat->id,";
}
$cats = substr($cats,0,-1);
/// $return->time = the time they did it
/// $return->info = a short text description
- return $return;
+ if ($entries = glossary_get_user_entries($glossary->id, $user->id)) {
+ $result->info = count($entries) . ' ' . get_string("entries", "glossary");
+
+ $lastpost = array_pop($entries);
+ $result->time = $lastpost->timemodified;
+ return $result;
+ }
+ return NULL;
+}
+
+function glossary_get_user_entries($glossaryid, $userid) {
+/// Get all the entries for a user in a glossary
+ global $CFG;
+
+ return get_records_sql("SELECT e.*, u.firstname, u.lastname, u.email, u.picture
+ FROM {$CFG->prefix}glossary g,
+ {$CFG->prefix}glossary_entries e,
+ {$CFG->prefix}user u
+ WHERE g.id = '$glossaryid'
+ AND e.glossaryid = g.id
+ AND e.userid = '$userid'
+ AND e.userid = u.id
+ ORDER BY e.timemodified ASC");
}
function glossary_user_complete($course, $user, $mod, $glossary) {
/// Print a detailed representation of what a user has done with
/// a given particular instance of this module, for user activity reports.
+ global $CFG;
- return true;
+ if ($entries = glossary_get_user_entries($glossary->id, $user->id)) {
+ if ( $glossary->displayformat == GLOSSARY_FORMAT_SIMPLE or
+ $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
+ print_simple_box_start("center","70%");
+ } else {
+ echo '<table width="95%" boder="0"><tr><td>';
+ }
+ foreach ($entries as $entry) {
+ $cm = get_coursemodule_from_instance("glossary", $glossary->id, $course->id);
+ glossary_print_entry($course, $cm, $glossary, $entry,"","",0);
+ echo '<p>';
+ }
+ if ( $glossary->displayformat == GLOSSARY_FORMAT_SIMPLE or
+ $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
+ print_simple_box_end();
+ } else {
+ echo '</td></tr></table>';
+ }
+ }
}
function glossary_print_recent_activity($course, $isteacher, $timestart) {
if (!$logs = get_records_select("log", "time > '$timestart' AND ".
"course = '$course->id' AND ".
"module = 'glossary' AND ".
- "action = 'add %' ", "time ASC")) {
+ "action = 'add entry'", "time ASC")) {
return false;
}
foreach ($logs as $log) {
//Create a temp valid module structure (course,id)
- $tempmod->course = $log->course;
- $tempmod->id = $log->info;
- //Obtain the visible property from the instance
+ $tempmod->course = $log->course;
+ $entry = get_record("glossary_entries","id",$log->info);
+ $tempmod->id = $entry->glossaryid;
+ //Obtain the visible property from the instance
$modvisible = instance_is_visible($log->module,$tempmod);
//Only if the mod is visible
return $content;
}
+function glossary_log_info($log) {
+ global $CFG;
+
+ return get_record_sql("SELECT e.*, u.firstname, u.lastname
+ FROM {$CFG->prefix}glossary_entries e,
+ {$CFG->prefix}user u
+ WHERE e.id = '$log->info'
+ AND u.id = '$log->userid'");
+}
+
function glossary_cron () {
/// Function to be run periodically according to the moodle cron
/// This function searches for things that need to be done, such
/// Any other glossary functions go here. Each of them must have a name that
/// starts with glossary_
-function glossary_log_info($log) {
- global $CFG;
- return get_record_sql("SELECT g.*, u.firstname, u.lastname
- FROM {$CFG->prefix}glossary_entries g,
- {$CFG->prefix}user u
- WHERE g.glossaryid = '$log->info'
- AND u.id = '$log->userid'");
+function glossary_debug($debug,$text,$br=1) {
+ if ( $debug ) {
+ echo '<font color=red>' . $text . '</font>';
+ if ( $br ) {
+ echo '<br>';
+ }
+ }
}
function glossary_get_entries($glossaryid, $entrylist, $pivot = "") {
WHERE (glossaryid = $glossary->id or sourceglossaryid = $glossary->id) $where $orderby");
}
-function glossary_get_entries_by_category($glossary, $cat, $where="", $orderby="", $pivot = "") {
+function glossary_get_entries_by_category($glossary, $hook, $where="", $orderby="", $pivot = "") {
global $CFG;
if ($where) {
$where = " and $where";
}
return get_records_sql("SELECT $pivot ge.*
FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories c
- WHERE (ge.id = c.entryid and c.categoryid = $cat) and
+ WHERE (ge.id = c.entryid and c.categoryid = $hook) and
(ge.glossaryid = $glossary->id or ge.sourceglossaryid = $glossary->id) $where $orderby");
}
-function glossary_print_entry($course, $cm, $glossary, $entry, $tab="",$cat="") {
+function glossary_print_entry($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons = 1) {
global $THEME, $USER, $CFG;
- if ($entry->approved or ($USER->id == $entry->userid and !isteacher($course->id)) or $tab == GLOSSARY_APPROVAL_VIEW) {
+ if ($entry->approved or ($USER->id == $entry->userid and !isteacher($course->id)) or $mode == 'approval') {
$permissiongranted = 0;
$formatfile = "$CFG->dirroot/mod/glossary/formats/$glossary->displayformat.php";
$functionname = "glossary_print_entry_by_format";
}
if ( !$basicformat and $permissiongranted ) {
- glossary_print_entry_by_format($course, $cm, $glossary, $entry,$tab,$cat);
+ glossary_print_entry_by_format($course, $cm, $glossary, $entry,$mode,$hook,$printicons);
} else {
switch ( $glossary->displayformat ) {
- case GLOSSARY_FORMAT_SIMPLE:
- glossary_print_entry_by_default($course, $cm, $glossary, $entry,$tab,$cat);
- break;
- case GLOSSARY_FORMAT_CONTINUOUS:
- glossary_print_entry_continuous($course, $cm, $glossary, $entry,$tab,$cat);
- break;
+ case GLOSSARY_FORMAT_SIMPLE:
+ glossary_print_entry_by_default($course, $cm, $glossary, $entry,$mode,$hook,$printicons);
+ break;
+ case GLOSSARY_FORMAT_CONTINUOUS:
+ glossary_print_entry_continuous($course, $cm, $glossary, $entry,$mode,$hook,$printicons);
+ break;
}
}
}
echo format_text($definition, $entry->format);
}
-function glossary_print_entry_aliases($course, $cm, $glossary, $entry,$tab="",$cat="", $mode = 'print') {
+function glossary_print_entry_aliases($course, $cm, $glossary, $entry,$mode="",$hook="", $type = 'print') {
$return = '';
if ( $aliases = get_records("glossary_alias","entryid",$entry->id) ) {
foreach ($aliases as $alias) {
// $return = "<table border=0 align=$align><tr><td>$return</td></tr></table>";
}
}
- if ($mode == 'print') {
+ if ($type == 'print') {
echo $return;
} else {
return $return;
}
}
-function glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab="",$cat="", $mode = 'print') {
+function glossary_print_entry_icons($course, $cm, $glossary, $entry,$mode="",$hook="", $type = 'print') {
global $THEME, $USER;
$importedentry = ($entry->sourceglossaryid == $glossary->id);
$mainglossary = get_record("glossary","mainglossary",1,"course",$course->id);
if ( $mainglossary ) { // if there is a main glossary defined, allow to export the current entry
- $return .= " <a title=\"" . get_string("exporttomainglossary","glossary") . "\" href=\"exportentry.php?id=$cm->id&entry=$entry->id&tab=$tab&cat=$cat\"><img src=\"export.gif\" height=11 width=11 border=0></a> ";
+ $return .= " <a title=\"" . get_string("exporttomainglossary","glossary") . "\" href=\"exportentry.php?id=$cm->id&entry=$entry->id&mode=$mode&hook=$hook\"><img src=\"export.gif\" height=11 width=11 border=0></a> ";
}
}
// Exported entries can be updated/deleted only by teachers in the main glossary
if ( !$importedentry and ($isteacher or !$ismainglossary) ) {
- $return .= " <a title=\"" . get_string("delete") . "\" href=\"deleteentry.php?id=$cm->id&mode=delete&entry=$entry->id&tab=$tab&cat=$cat\"><img src=\"";
+ $return .= " <a title=\"" . get_string("delete") . "\" href=\"deleteentry.php?id=$cm->id&mode=delete&entry=$entry->id&prevmode=$mode&hook=$hook\"><img src=\"";
$return .= $icon;
$return .= "\" height=11 width=11 border=0></a> ";
- $return .= " <a title=\"" . get_string("edit") . "\" href=\"edit.php?id=$cm->id&e=$entry->id&tab=$tab&cat=$cat\"><img src=\"../../pix/t/edit.gif\" height=11 width=11 border=0></a>";
+ $return .= " <a title=\"" . get_string("edit") . "\" href=\"edit.php?id=$cm->id&e=$entry->id&mode=$mode&hook=$hook\"><img src=\"../../pix/t/edit.gif\" height=11 width=11 border=0></a>";
} elseif ( $importedentry ) {
$return .= " <font size=-1>" . get_string("exportedentry","glossary") . "</font>";
}
}
$return .= " "; // just to make up a little the output in Mozilla ;)
- if ($mode == 'print') {
+ if ($type == 'print') {
echo $return;
} else {
return $return;
}
}
-function glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $tab, $cat) {
+function glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook,$printicons) {
- $aliases = glossary_print_entry_aliases($course, $cm, $glossary, $entry, $tab, $cat,"html");
- $icons = glossary_print_entry_icons($course, $cm, $glossary, $entry, $tab, $cat,"html");
+ $aliases = glossary_print_entry_aliases($course, $cm, $glossary, $entry, $mode, $hook,"html");
+ $icons = "";
+ if ( $printicons ) {
+ $icons = glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode, $hook,"html");
+ }
if ( $aliases ) {
echo '<table border="0" width="100%" align="center"><tr>' .
'<td align="right" width="50%" valign=top><font size=1>' .
}
}
-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_approval($cm, $entry, $mode) {
+ if ( $mode == 'approval' and !$entry->approved ) {
+ echo "<a title=\"" . get_string("approve","glossary"). "\" href=\"approve.php?id=$cm->id&eid=$entry->id&mode=$mode\"><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="") {
+function glossary_print_entry_by_default($course, $cm, $glossary, $entry,$mode="",$hook="",$printicons=1) {
global $THEME, $USER;
$colour = $THEME->cellheading2;
echo "\n<TR>";
echo "<TD WIDTH=100% class=\"generalbox\" valign=\"top\" BGCOLOR=\"#FFFFFF\">";
- glossary_print_entry_approval($cm, $entry, $tab);
+ glossary_print_entry_approval($cm, $entry, $mode);
glossary_print_entry_attachment($entry,"html","right");
echo "<b>";
glossary_print_entry_concept($entry);
echo ":</b> ";
glossary_print_entry_definition($entry);
- glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$tab,$cat);
+ glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons);
echo "</td>";
echo "</TR>";
}
-function glossary_print_entry_continuous($course, $cm, $glossary, $entry,$tab="",$cat="") {
+function glossary_print_entry_continuous($course, $cm, $glossary, $entry,$mode="",$hook="",$printicons=1) {
global $THEME, $USER;
if ($entry) {
- glossary_print_entry_approval($cm, $entry, $tab);
+ glossary_print_entry_approval($cm, $entry, $mode);
glossary_print_entry_attachment($entry,"html","right");
glossary_print_entry_concept($entry);
echo " ";
+
glossary_print_entry_definition($entry);
- glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $tab, $cat);
+ if ( $printicons ) {
+ $icons = glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode, $hook,"html");
+ echo "($icons)";
+ }
}
}
echo "</center><p></td></tr></table></center>";
}
-function glossary_print_approval_menu($cm, $glossary, $l, $sortkey, $sortorder = "",$tab=GLOSSARY_STANDARD_VIEW) {
+function glossary_print_approval_menu($cm, $glossary,$mode, $hook, $sortkey = '', $sortorder = '') {
if ($glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) {
echo '<center>' . get_string("explainalphabet","glossary") . '<p>';
}
- glossary_print_special_links($cm, $glossary,$l, $tab);
+ glossary_print_special_links($cm, $glossary, $mode, $hook);
- glossary_print_alphabet_links($cm, $glossary,$l, $tab);
+ glossary_print_alphabet_links($cm, $glossary, $mode, $hook);
- glossary_print_all_links($cm, $glossary,$l, $tab);
+ glossary_print_all_links($cm, $glossary, $mode, $hook);
- glossary_print_sorting_links($cm, $sortkey,$sortorder, $tab);
+ glossary_print_sorting_links($cm, $mode, $sortkey, $sortorder);
}
-function glossary_print_addentry_menu($cm, $glossary, $l, $sortkey, $sortorder = "", $tab=GLOSSARY_STANDARD_VIEW) {
+function glossary_print_addentry_menu($cm, $glossary, $mode, $hook, $sortkey='', $sortorder = '') {
echo '<center>' . get_string("explainaddentry","glossary") . '<p>';
}
-function glossary_print_import_menu($cm, $glossary, $l, $sortkey, $sortorder = "", $tab=GLOSSARY_STANDARD_VIEW) {
+function glossary_print_import_menu($cm, $glossary, $mode, $hook, $sortkey='', $sortorder = '') {
echo '<center>' . get_string("explainimport","glossary") . '<p>';
}
-function glossary_print_export_menu($cm, $glossary, $l, $sortkey, $sortorder = "", $tab=GLOSSARY_STANDARD_VIEW) {
+function glossary_print_export_menu($cm, $glossary, $mode, $hook, $sortkey='', $sortorder = '') {
echo '<center>' . get_string("explainexport","glossary") . '<p>';
}
-function glossary_print_alphabet_menu($cm, $glossary, $l, $sortkey, $sortorder = "", $tab=GLOSSARY_STANDARD_VIEW) {
- if ( $tab != GLOSSARY_DATE_VIEW ) {
+function glossary_print_alphabet_menu($cm, $glossary, $mode, $hook, $sortkey='', $sortorder = '') {
+ if ( $mode != 'date' ) {
if ($glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) {
echo '<center>' . get_string("explainalphabet","glossary") . '<p>';
}
- glossary_print_special_links($cm, $glossary,$l, $tab);
+ glossary_print_special_links($cm, $glossary, $mode, $hook);
- glossary_print_alphabet_links($cm, $glossary,$l, $tab);
+ glossary_print_alphabet_links($cm, $glossary, $mode, $hook);
- glossary_print_all_links($cm, $glossary,$l, $tab);
+ glossary_print_all_links($cm, $glossary, $mode, $hook);
} else {
- glossary_print_sorting_links($cm, $sortkey,$sortorder, $tab);
+ glossary_print_sorting_links($cm, $mode, $sortkey,$sortorder);
+ }
+}
+
+function glossary_print_author_menu($cm, $glossary,$mode, $hook, $sortkey = '', $sortorder = '') {
+ if ($glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) {
+ echo '<center>' . get_string("explainalphabet","glossary") . '<p>';
}
+
+ glossary_print_alphabet_links($cm, $glossary, $mode, $hook);
+ echo "<br />";
+ glossary_print_all_links($cm, $glossary, $mode, $hook);
}
-function glossary_print_categories_menu($course, $cm, $glossary, $cat, $category) {
+function glossary_print_categories_menu($cm, $glossary, $hook, $category) {
global $CFG, $THEME;
echo '<table border=0 width=100%>';
echo '<tr>';
echo '<td align=center width=20%>';
if ( isteacher($course->id) ) {
$options['id'] = $cm->id;
- $options['cat'] = $cat;
+ $options['mode'] = 'cat';
+ $options['hook'] = $hook;
echo print_single_button("editcategories.php", $options, get_string("editcategories","glossary"), "get");
}
echo '</td>';
if ( $category ) {
echo $category->name;
} else {
- if ( $cat == GLOSSARY_SHOW_NOT_CATEGORISED ) {
+ if ( $hook == GLOSSARY_SHOW_NOT_CATEGORISED ) {
echo get_string("entrieswithoutcategory","glossary");
$selected = GLOSSARY_SHOW_NOT_CATEGORISED;
- } elseif ( $cat == GLOSSARY_SHOW_ALL_CATEGORIES ) {
+ } elseif ( $hook == GLOSSARY_SHOW_ALL_CATEGORIES ) {
echo get_string("allcategories","glossary");
$selected = GLOSSARY_SHOW_ALL_CATEGORIES;
echo '</b></td>';
echo '<td align=center width=20%>';
- echo popup_form("$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&tab=" . GLOSSARY_CATEGORY_VIEW . "&cat=", $menu, "catmenu", $selected, "",
+ echo popup_form("$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&mode=cat&hook=", $menu, "catmenu", $selected, "",
"", "", false);
echo '</td>';
echo '</table>';
}
-function glossary_print_all_links($cm, $glossary, $l, $tab) {
+function glossary_print_all_links($cm, $glossary, $mode, $hook) {
global $CFG;
if ( $glossary->showall and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) {
$strallentries = get_string("allentries", "glossary");
- if ( $l == 'ALL' ) {
+ if ( $hook == 'ALL' ) {
echo "<b>$strallentries</b>";
} else {
$strexplainall = strip_tags(get_string("explainall","glossary"));
- echo "<a title=\"$strexplainall\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&l=ALL&tab=$tab\">$strallentries</a>";
+ echo "<a title=\"$strexplainall\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&mode=$mode&hook=ALL\">$strallentries</a>";
}
}
}
-function glossary_print_special_links($cm, $glossary, $l, $tab) {
+function glossary_print_special_links($cm, $glossary, $mode, $hook) {
global $CFG;
if ( $glossary->showspecial and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS ) {
$strspecial = get_string("special", "glossary");
- if ( $l == 'SPECIAL' ) {
+ if ( $hook == 'SPECIAL' ) {
echo "<b>$strspecial</b> | ";
} else {
$strexplainspecial = strip_tags(get_string("explainspecial","glossary"));
- echo "<a title=\"$strexplainspecial\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&l=SPECIAL&tab=$tab\">$strspecial</a> | ";
+ echo "<a title=\"$strexplainspecial\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&mode=$mode&hook=SPECIAL\">$strspecial</a> | ";
}
}
}
-function glossary_print_alphabet_links($cm, $glossary,$l, $tab) {
+function glossary_print_alphabet_links($cm, $glossary, $mode, $hook) {
global $CFG;
if ( $glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS ) {
$alphabet = explode(",", get_string("alphabet"));
$letters_by_line = 14;
for ($i = 0; $i < count($alphabet); $i++) {
- if ( $l == $alphabet[$i] and $l) {
+ if ( $hook == $alphabet[$i] and $hook) {
echo "<b>$alphabet[$i]</b>";
} else {
- echo "<a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&l=$alphabet[$i]&tab=$tab\">$alphabet[$i]</a>";
+ echo "<a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&mode=$mode&hook=$alphabet[$i]\">$alphabet[$i]</a>";
}
if ((int) ($i % $letters_by_line) != 0 or $i == 0) {
echo ' | ';
}
}
-function glossary_print_sorting_links($cm, $sortkey,$sortorder, $tab) {
+function glossary_print_sorting_links($cm, $mode, $sortkey = '',$sortorder = '') {
global $CFG;
$strsort = get_string("sortchronogically", "glossary");
$strsortbycreation = get_string("sortbycreation", "glossary");
$cordertitle = get_string("ascending","glossary");
$uordertitle = get_string("ascending","glossary");
}
- echo "<br>$strsort: $ubtag<a title=\"$strsortbylastupdate $uordertitle\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&sortkey=UPDATE$uneworder&tab=$tab\">$strsortbylastupdate$uicon</a>$uendbtag | ".
- "$cbtag<a title=\"$strsortbycreation $cordertitle\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&sortkey=CREATION$cneworder&tab=$tab\">$strsortbycreation$cicon</a>$cendbtag</p>";
+ echo "<br>$strsort: $ubtag<a title=\"$strsortbylastupdate $uordertitle\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&sortkey=UPDATE$uneworder&mode=$mode\">$strsortbylastupdate$uicon</a>$uendbtag | ".
+ "$cbtag<a title=\"$strsortbycreation $cordertitle\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&sortkey=CREATION$cneworder&mode=$mode\">$strsortbycreation$cicon</a>$cendbtag</p>";
}
function glossary_sort_entries ( $entry0, $entry1 ) {
echo "</tr></table></center>";
}
-function glossary_generate_export_file($glossary, $l = "", $cat = 0) {
+function glossary_generate_export_file($glossary, $hook = "", $hook = 0) {
global $CFG;
glossary_check_moddata_dir($glossary);
$h = glossary_open_xml($glossary);
fwrite ($h,glossary_full_tag("USEDYNALINK",2,false,$glossary->usedynalink));
fwrite ($h,glossary_full_tag("DEFAULTAPPROVAL",2,false,$glossary->defaultapproval));
fwrite ($h,glossary_full_tag("GLOBALGLOSSARY",2,false,$glossary->globalglossary));
+ fwrite ($h,glossary_full_tag("ENTBYPAGE",2,false,$glossary->entbypage));
if ( $entries = get_records("glossary_entries","glossaryid",$glossary->id) ) {
$status = fwrite ($h,glossary_start_tag("ENTRIES",2,true));
foreach ($entries as $entry) {
$permissiongranted = 1;
- if ( $l ) {
- switch ( $l ) {
+ if ( $hook ) {
+ switch ( $hook ) {
case "ALL":
case "SPECIAL":
break;
default:
- $permissiongranted = ($entry->concept[ strlen($l)-1 ] == $l);
+ $permissiongranted = ($entry->concept[ strlen($hook)-1 ] == $hook);
break;
}
}
- if ( $cat ) {
- switch ( $cat ) {
+ if ( $hook ) {
+ switch ( $hook ) {
case GLOSSARY_SHOW_ALL_CATEGORIES:
break;
case GLOSSARY_SHOW_NOT_CATEGORISED:
$permissiongranted = !record_exists("glossary_entries_categories","entryid",$entry->id);
break;
default:
- $permissiongranted = record_exists("glossary_entries_categories","entryid",$entry->id, "categoryid",$cat);
+ $permissiongranted = record_exists("glossary_entries_categories","entryid",$entry->id, "categoryid",$hook);
break;
}
}
$status = fwrite ($h,glossary_start_tag("CATEGORY",5,true));
fwrite($h,glossary_full_tag("NAME",6,false,$category->name));
+ fwrite($h,glossary_full_tag("USEDYNALINK",6,false,$category->usedynalink));
$status = fwrite($h,glossary_end_tag("CATEGORY",5,true));
}
$status = fwrite($h,glossary_end_tag("CATEGORIES",4,true));
}
return $status;
}
-?>
+?>
\ No newline at end of file
global $CFG;
if (!isset($form->studentcanpost)) {
- $form->studentcanpost = $CFG->cnfstudentcanpost;
+ $form->studentcanpost = $CFG->glossary_studentspost;
}
if (!isset($form->allowduplicatedentries)) {
- $form->allowduplicatedentries = $CFG->cnfallowdupentries;
+ $form->allowduplicatedentries = $CFG->glossary_dupentries;
}
if (!isset($form->allowcomments)) {
- $form->allowcomments = $CFG->cnfallowcomments;
+ $form->allowcomments = $CFG->glossary_allowcomments;
}
if (!isset($form->usedynalink)) {
- $form->usedynalink = $CFG->cnflinkglossaries;
+ $form->usedynalink = $CFG->glossary_linkbydefault;
}
if (!isset($form->defaultapproval)) {
- $form->defaultapproval = $CFG->cnfapprovalstatus;
+ $form->defaultapproval = $CFG->glossary_defaultapproval;
+}
+if (!isset($form->entbypage)) {
+ $form->entbypage = $CFG->glossary_entbypage;
}
if (!isset($form->mainglossary)) {
$form->mainglossary = 0;
<textarea name="intro" rows=5 cols=50 wrap="virtual"><?php p($form->intro) ?></textarea>
</td>
</tr>
+<TR valign=top>
+ <TD align=right><P><B><?php echo get_string("entbypage", "glossary") ?>:</B></P></TD>
+ <TD>
+ <input name=entbypage type=text size=2 value="<?php p($form->entbypage) ?>"> <?php helpbutton("entbypage", get_string("entbypage", "glossary"), "glossary") ?>
+ </TD>
+</TR>
+
<!-- More rows go in here... -->
<?php
if (isadmin() ) {
global $CFG;
require_variable($id); // Course Module ID
- require_variable($tab,GLOSSARY_STANDARD_VIEW); // format to show the entries
+ require_variable($mode,"letter"); // format to show the entries
optional_variable($sortkey,"UPDATE"); // Sorting key if TAB = GLOSSARY_DATE_VIEW
optional_variable($sortorder,"asc"); // Sorting order if TAB = GLOSSARY_DATE_VIEW
- optional_variable($l,"ALL");
+ optional_variable($hook,"ALL");
optional_variable($eid);
optional_variable($search);
- optional_variable($cat,GLOSSARY_SHOW_ALL_CATEGORIES);
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if ( $eid ) {
- $l = '';
- $tab = GLOSSARY_STANDARD_VIEW;
+ $mode = 'entry';
}
/// Generating the SQL based on the format to show
- switch ($tab) {
- case GLOSSARY_CATEGORY_VIEW:
+ switch ($mode) {
+ case "cat":
$where = '';
- if ($cat) {
- if ( $cat != GLOSSARY_SHOW_ALL_CATEGORIES and $cat != GLOSSARY_SHOW_NOT_CATEGORISED ) {
- $where = 'and c.id = ' . $cat;
+ if ($hook) {
+ if ( $hook != GLOSSARY_SHOW_ALL_CATEGORIES and $hook != GLOSSARY_SHOW_NOT_CATEGORISED ) {
+ $where = 'and c.id = ' . $hook;
}
}
- $entries = get_records_sql("SELECT c.name pivot, e.*
+ $entries = get_records_sql("SELECT ec.id, c.name pivot, e.*
FROM {$CFG->prefix}glossary_entries e,
{$CFG->prefix}glossary_entries_categories ec,
{$CFG->prefix}glossary_categories as c
break;
- case GLOSSARY_DATE_VIEW:
+ case "date":
//// Valid sorting values
switch ($sortkey) {
case 'CREATION':
ORDER BY e.$sortkey $sortorder");
break;
- case GLOSSARY_STANDARD_VIEW:
+ case "letter":
default:
switch ($CFG->dbtype) {
case "postgres7":
break;
}
- if ( $l ) {
- if ($l != 'ALL' and $l != 'SPECIAL') {
+ if ( $hook ) {
+ if ($hook != 'ALL' and $hook != 'SPECIAL') {
switch ($CFG->dbtype) {
case 'postgres7':
- $where = 'and substr(ucase(concept),1,' . strlen($l) . ') = \'' . strtoupper($l) . '\'';
+ $where = 'and substr(ucase(concept),1,' . strlen($hook) . ') = \'' . strtoupper($hook) . '\'';
break;
case 'mysql':
- $where = 'and left(ucase(concept),' . strlen($l) . ") = '$l'";
+ $where = 'and left(ucase(concept),' . strlen($hook) . ") = '" . strtoupper($hook) . "'";
break;
default:
$where = '';
$where = " and e.id = $eid";
}
- $entries = get_records_sql("SELECT $pivot pivot, e.*
+ $entries = get_records_sql("SELECT e.id, $pivot pivot, e.*
FROM {$CFG->prefix}glossary_entries e
WHERE (e.glossaryid = $glossary->id or e.sourceglossaryid = $glossary->id)
AND e.approved != 0 $where
echo get_string("noentries","glossary");
exit;
}
+
$groupheader = '';
$tableisopen = 0;
foreach ($entries as $entry) {
$pivot = $entry->pivot;
- if ( $CFG->dbtype != "postgres7" and $CFG->dbtype != "mysql" and $tab != GLOSSARY_CATEGORY_VIEW) {
+ if ( $CFG->dbtype != "postgres7" and $CFG->dbtype != "mysql" and $mode != "cat") {
$pivot = $pivot[0];
}
- if ($tab != GLOSSARY_DATE_VIEW) {
- if ($groupheader != $pivot) {
+ if ($mode != "date") {
+ if (strtoupper($groupheader) != strtoupper($pivot)) {
/// Printing th eheader of the group
if ($tableisopen) {
//Now, build the GLOSSARY_CATEGORIES record structure
$category->glossaryid = $new_glossary_id;
$category->name = backup_todb($cat_info['#']['NAME']['0']['#']);
+ $category->usedynalink = backup_todb($cat_info['#']['USEDYNALINK']['0']['#']);
$newid = insert_record ("glossary_categories",$category);
require_once("../../config.php");
require_once("lib.php");
- require_variable($concept);
+ optional_variable($concept);
optional_variable($courseid,0);
+ optional_variable($eid,0);
print_header();
- $entries = get_records_sql("select e.* from {$CFG->prefix}glossary_entries e, {$CFG->prefix}glossary g".
+ if ( $eid ) {
+ $entries = get_records_sql("select e.* from {$CFG->prefix}glossary_entries e, {$CFG->prefix}glossary g".
+ " where (e.id = $eid)");
+ } elseif ( $concept ) {
+ $entries = get_records_sql("select e.* from {$CFG->prefix}glossary_entries e, {$CFG->prefix}glossary g".
" where e.glossaryid = g.id and".
" (e.casesensitive != 0 and ucase(concept) = '" . strtoupper(trim($concept)). "' or".
" e.casesensitive = 0 and concept = '$concept') and".
" (g.course = $courseid or g.globalglossary) and".
" e.usedynalink != 0 and g.usedynalink != 0");
-
- glossary_print_dynaentry($courseid, $entries);
+ }
+ if ( $entries ) {
+ glossary_print_dynaentry($courseid, $entries);
+ }
close_window_button();
?>
$data[GLOSSARY_STANDARD_VIEW]->caption = get_string("standardview", "glossary");
$data[GLOSSARY_CATEGORY_VIEW]->caption = get_string("categoryview", "glossary");
$data[GLOSSARY_DATE_VIEW]->caption = get_string("dateview", "glossary");
+ $data[GLOSSARY_AUTHOR_VIEW]->caption = get_string("authorview","glossary");
if (!isguest()) {
if ( isteacher($course->id) or $glossary->studentcanpost ) {
$data[GLOSSARY_ADDENTRY_VIEW]->caption = get_string("addentry", "glossary");
$data[GLOSSARY_EXPORT_VIEW]->caption = "Export Entries";
$data[GLOSSARY_IMPORT_VIEW]->link = "import.php?id=$cm->id";
- $data[GLOSSARY_EXPORT_VIEW]->link = "export.php?id=$cm->id&l=$l&cat=$cat&tab=".GLOSSARY_CATEGORY_VIEW;
+ $data[GLOSSARY_EXPORT_VIEW]->link = "export.php?id=$cm->id&tab=".GLOSSARY_CATEGORY_VIEW;
+
+ $data[GLOSSARY_IMPORT_VIEW]->link = "import.php?id=$cm->id";
+ $data[GLOSSARY_EXPORT_VIEW]->link = "export.php?id=$cm->id&mode=$mode&hook=$hook";
+
}
- $data[GLOSSARY_DATE_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_DATE_VIEW;
+// $data[GLOSSARY_DATE_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_DATE_VIEW;
+
+ $data[GLOSSARY_DATE_VIEW]->link = "view.php?id=$id&mode=date";
+
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;
- }
+ $data[GLOSSARY_STANDARD_VIEW]->link = "view.php?id=$id";
+ $data[GLOSSARY_CATEGORY_VIEW]->link = "view.php?id=$id&mode=cat";
+ $data[GLOSSARY_AUTHOR_VIEW]->link = "view.php?id=$id&mode=author";
+ }
if (isteacher($course->id)) {
$data[GLOSSARY_APPROVAL_VIEW]->caption = get_string("waitingapproval", "glossary");
if ($hiddenentries) {
$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;
+
+ $data[GLOSSARY_APPROVAL_VIEW]->link = "view.php?id=$id&mode=approval";
+
} elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) {
$tab = $framebydefault;
}
/// printing header of the current tab
echo '<center>';
glossary_print_tabbed_table_start($data, $tab, $glossary_tCFG);
+
switch ($tab) {
case GLOSSARY_CATEGORY_VIEW:
- glossary_print_categories_menu($course, $cm, $glossary, $cat, $category);
+ glossary_print_categories_menu($cm, $glossary, $hook, $category);
break;
case GLOSSARY_APPROVAL_VIEW:
- glossary_print_approval_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab);
+ glossary_print_approval_menu($cm, $glossary, $mode, $hook, $sortkey, $sortorder);
break;
case GLOSSARY_ADDENTRY_VIEW:
$search = "";
$l = "";
- glossary_print_addentry_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab);
+ glossary_print_addentry_menu($cm, $glossary, $mode, $hook, $sortkey, $sortorder);
+ break;
+ case GLOSSARY_AUTHOR_VIEW:
+ $search = "";
+ glossary_print_author_menu($cm, $glossary, "author", $hook, $sortkey, $sortorder, 'print');
break;
case GLOSSARY_IMPORT_VIEW:
$search = "";
$l = "";
- glossary_print_import_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab);
+ glossary_print_import_menu($cm, $glossary, 'import', $hook, $sortkey, $sortorder);
break;
case GLOSSARY_EXPORT_VIEW:
$search = "";
$l = "";
- glossary_print_export_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab);
+ glossary_print_export_menu($cm, $glossary, 'export', $hook, $sortkey, $sortorder);
break;
case GLOSSARY_DATE_VIEW:
if (!$sortkey) {
if (!$sortorder) {
$sortorder = 'desc';
}
+ glossary_print_alphabet_menu($cm, $glossary, "date", $hook, $sortkey, $sortorder);
+ break;
case GLOSSARY_STANDARD_VIEW:
default:
- glossary_print_alphabet_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab);
+ glossary_print_alphabet_menu($cm, $glossary, "letter", $hook, $sortkey, $sortorder);
if ($search) {
echo "<h3>$strsearch: $search</h3>";
}
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2003110400; // The current module version (Date: YYYYMMDDXX)
+$module->version = 2003111500; // The current module version (Date: YYYYMMDDXX)
$module->cron = 0; // Period for cron to check this module (secs)
$release = "0.5 development"; // User-friendly version number
-<?php // $Id$
-
+<?php
/// This page prints a particular instance of glossary
require_once("../../config.php");
require_once("lib.php");
-
+ $debug = 0;
+
require_variable($id); // Course Module ID
- optional_variable($l,""); // letter to look for
- optional_variable($offset,0); // entries to bypass (paging purpouses)
- optional_variable($eid); // Entry ID
- optional_variable($search, ""); // search string
- optional_variable($includedefinition); // include definition in search function?
-
- optional_variable($tab); // browsing entries by categories?
- optional_variable($cat); // categoryID
+ optional_variable($tab,GLOSSARY_NO_VIEW); // browsing entries by categories?
- optional_variable($sortkey,""); // Sorted view: CREATION or UPDATE
- optional_variable($sortorder,""); // it define the order of the sorting (ASC or DESC)
+ optional_variable($mode,"letter"); // [ "term" | "entry" | "cat" | "date" |
+ // "letter" | "search" | "author" | "approval" ]
+ optional_variable($hook,""); // the term, entry, cat, etc... to look for based on mode
- global $CFG;
- $entriesbypage = $CFG->glossary_entbypage;
+ optional_variable($fullsearch,0); // full search (concept and definition) when searching?
+
+ optional_variable($sortkey,""); // Sorted view:
+ // [ CREATION | UPDATE | concept | timecreated | ... ]
+ optional_variable($sortorder,""); // it defines the order of the sorting (ASC or DESC)
+
+ optional_variable($offset,0); // entries to bypass (for paging purpouses)
- if (!$entriesbypage) {
- $entriesbypage = 10;
- }
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
- }
-
- if ($tab == GLOSSARY_ADDENTRY_VIEW and !$eid) {
- redirect("edit.php?id=$cm->id&tab=$tab");
- }
-
+ }
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
- }
-
+ }
if (! $glossary = get_record("glossary", "id", $cm->instance)) {
error("Course module is incorrect");
}
+/// redirecting if adding a new entry
+ if ($tab == GLOSSARY_ADDENTRY_VIEW ) {
+ redirect("edit.php?id=$cm->id&mode=$mode");
+ }
+
+/// setting the defaut number of entries per page if not set
+ global $CFG, $THEME, $USER;
+
+ if ( !$entriesbypage = $glossary->entbypage ) {
+ $entriesbypage = 10;
+ }
+
+/// setting the right fram for a "Continuous" glossary
+ if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
+ $mode = 'date';
+ }
+
+/// Processing standard security processes
+ $navigation = "";
if ($course->category) {
+ $navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
require_login($course->id);
}
if (!$cm->visible and !isteacher($course->id)) {
notice(get_string("activityiscurrentlyhidden"));
}
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
+/// stablishing flag variables
if ( $sortorder = strtolower($sortorder) ) {
if ($sortorder != 'asc' and $sortorder != 'desc') {
$sortorder = '';
- } else {
- $l = ''; /// if we are sorting by date, reset the searching by terms or letters
- $search = '';
}
}
if ( $sortkey = strtoupper($sortkey) ) {
$sortkey = '';
}
}
-/// in this point:
-/// $sortkey = CREATION | UPDATE | ''
-/// $sortorder = asc | desc | ''
- if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
- $tab = $framebydefault;
-
- if ( !$sortkey ) {
- $sortkey = 'CREATION';
- }
- if ( !$sortorder ) {
- $sortorder = 'asc';
- }
- } else {
- if ( !$sortkey ) {
- $sortkey = 'concept';
- }
- if ( !$sortorder ) {
- $sortorder = 'asc';
- }
- }
+ switch ( $mode = strtolower($mode) ) {
+ case 'search': /// looking for terms containing certain word(s)
+ $tab = GLOSSARY_STANDARD_VIEW;
-// creating matrix of words to search if apply
- $search = trim(strip_tags($search));
- if ($search and !$eid) { /// searching terms
- $l = '';
- $searchterms = explode(' ', $search); // Search for words independently
+ $searchterms = explode(' ', $hook); // Search for words independently
foreach ($searchterms as $key => $searchterm) {
if (strlen($searchterm) < 2) {
unset($searchterms[$key]);
}
}
- $search = trim(implode(' ', $searchterms));
- $tab = $framebydefault;
- } elseif ($eid) { /// searching a specify entry
+ $hook = trim(implode(' ', $searchterms));
+ break;
+
+ case 'entry': /// Looking for a certain entry id
$tab = GLOSSARY_STANDARD_VIEW;
- $search = '';
- }
+ break;
+
+ case 'cat': /// Looking for a certain cat
+ $tab = GLOSSARY_CATEGORY_VIEW;
+ if ( $hook > 0 ) {
+ $category = get_record("glossary_categories","id",$hook);
+ }
+ break;
- $alphabet = explode(',', get_string("alphabet"));
- 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'; /// show ALL by default in the waiting approval frame
+ case 'approval': /// Looking for entries waiting for approval
+ $tab = GLOSSARY_APPROVAL_VIEW;
+ if ( !$hook and !$sortkey and !$sortorder) {
+ $hook = 'ALL';
}
- } elseif ($eid) {
- $l = '';
- }
-
- $category = '';
- if ($tab == GLOSSARY_CATEGORY_VIEW) {
- $l = '';
- if ($cat > 0) {
- $category = get_record("glossary_categories", "id", $cat);
- if (!$category) {
- $cat = '';
- }
+ break;
+
+ case 'term': /// Looking for entries that include certain term in its concept, definition or aliases
+ $tab = GLOSSARY_STANDARD_VIEW;
+ break;
+
+ case 'date':
+ $tab = GLOSSARY_DATE_VIEW;
+ if ( !$sortkey ) {
+ $sortkey = 'UPDATE';
}
- }
+ if ( !$sortorder ) {
+ $sortorder = 'desc';
+ }
+ break;
-/// Printing the page header
- if ($course->category) {
- $navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
- }
+ case 'author': /// Looking for entries, browsed by author
+ $tab = GLOSSARY_AUTHOR_VIEW;
+ if ( !$hook ) {
+ $hook = 'ALL';
+ }
+ break;
+
+ case 'letter': /// Looking for entries that begin with a certain letter, ALL or SPECIAL characters
+ default:
+ $tab = GLOSSARY_STANDARD_VIEW;
+ if ( !$hook ) {
+ $hook = 'ALL';
+ }
+ break;
+ }
+
+ switch ( $tab ) {
+ case GLOSSARY_IMPORT_VIEW:
+ case GLOSSARY_EXPORT_VIEW:
+ case GLOSSARY_APPROVAL_VIEW:
+ $isuserframe = 0;
+ break;
+ default:
+ $isuserframe = 1;
+ break;
+ }
+
+/// Printing the heading
$strglossaries = get_string("modulenameplural", "glossary");
$strglossary = get_string("modulename", "glossary");
$strallcategories = get_string("allcategories", "glossary");
navmenu($course, $cm));
echo '<p align="center"><font size="3"><b>' . stripslashes_safe($glossary->name);
- if ($tab == GLOSSARY_CATEGORY_VIEW | $tab == GLOSSARY_STANDARD_VIEW |
- $tab == GLOSSARY_DATE_VIEW) {
+ if ($isuserframe ) {
/// the "Print" icon
- echo " <a title =\"". get_string("printerfriendly","glossary") . "\" target=\"_blank\" href=\"print.php?id=$cm->id&tab=$tab&cat=$cat&l=$l&eid=$eid&sortkey=$sortkey&sortorder=$sortorder\">";
+ echo " <a title =\"". get_string("printerfriendly","glossary") . "\" target=\"_blank\" href=\"print.php?id=$cm->id&tab=$tab&mode=$mode&hook=$hook&sortkey=$sortkey&sortorder=$sortorder\">";
echo '<img border=0 src="print.gif"/></a>';
}
echo '</b></font></p>';
/// Info box
-
if ( $glossary->intro ) {
print_simple_box_start('center','70%');
echo format_text($glossary->intro);
}
/// Search box
-
echo '<p>';
print_simple_box_start("center", "", $THEME->cellheading);
echo '<p>';
echo '<form method="POST" action="view.php">';
echo '<input type="submit" value="'.$strsearch.'" name="searchbutton"> ';
- echo '<input type="text" name="search" size="20" value=""> ';
- echo '<input type="checkbox" name="includedefinition" value="1">';
- echo $strsearchindefinition;
+ echo '<input type="text" name="hook" size="20" value=""> ';
+ echo '<input type="checkbox" name="fullsearch" value="1">';
+ echo '<input type="hidden" name="mode" value="search">';
echo '<input type="hidden" name="id" value="'.$cm->id.'">';
+ echo $strsearchindefinition;
echo '</form>';
echo '</p>';
- print_simple_box_end();
-
+ print_simple_box_end();
-/// Tabbed browsing sections
include("tabs.html");
-
-/// Printing the entries
- switch ($sortkey) {
- case 'CREATION':
- $orderby = "timecreated $sortorder";
- break;
- case 'UPDATE':
- $orderby = "timemodified $sortorder";
- break;
- default:
- $orderby .= "$sortkey $sortorder";
+ switch ( $sortkey ) {
+ case "CREATION":
+ $sortkey = "timecreated";
+ break;
+
+ case "UPDATE":
+ $sortkey = "timemodified";
+ default:
+ break;
}
+/// Creating the SQL statements
+
+/// Pivot is the field that set the break by groups (category, initial, author name, etc)
+
+/// fullpivot indicate if the whole pivot should be compared agasint the db or just the first letter
+/// printpivot indicate if the pivot should be printed or not
+ $fullpivot = 1;
+ $printpivot = 1;
+
+// global $db;
+// $db->debug = true;
+
switch ($tab) {
- case GLOSSARY_CATEGORY_VIEW:
- if ($cat == GLOSSARY_SHOW_ALL_CATEGORIES) {
- $sqlselect = "SELECT gec.id gecid, gc.name, gc.id CID, ge.*";
- $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge,
- {$CFG->prefix}glossary_entries_categories gec,
- {$CFG->prefix}glossary_categories gc";
- $sqlwhere = "WHERE (ge.glossaryid = '$glossary->id' or ge.sourceglossaryid = '$glossary->id') AND
- gec.entryid = ge.id AND
- gc.id = gec.categoryid";
-
- if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
- $sqlorderby = ' ORDER BY gc.name, ge.timecreated';
- } else {
- $sqlorderby = ' ORDER BY gc.name, ge.concept';
- }
- $count = count_records_sql("select count(*) $sqlfrom $sqlwhere");
- $sqllimit = " LIMIT $offset, $entriesbypage";
+ case GLOSSARY_CATEGORY_VIEW:
+ if ($hook == GLOSSARY_SHOW_ALL_CATEGORIES ) {
+
+ $sqlselect = "SELECT gec.id, gc.name pivot, ge.*";
+ $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge,
+ {$CFG->prefix}glossary_entries_categories gec,
+ {$CFG->prefix}glossary_categories gc";
+ $sqlwhere = "WHERE (ge.glossaryid = '$glossary->id' OR ge.sourceglossaryid = '$glossary->id') AND
+ ge.id = gec.entryid AND gc.id = gec.categoryid AND
+ (ge.approved != 0 OR ge.userid = $USER->id)";
- $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit");
+ if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
+ $sqlorderby = ' ORDER BY gc.name, ge.timecreated';
} else {
- if ( $cat == GLOSSARY_SHOW_NOT_CATEGORISED ) {
- $sqlselect = "SELECT *";
- $sqlfrom = "FROM {$CFG->prefix}glossary_entries";
- $sqlwhere = "WHERE (glossaryid = $glossary->id or sourceglossaryid = $glossary->id)";
- $sqlorderby = "ORDER BY $orderby";
-
- $count = count_records_sql("select count(*) $sqlfrom $sqlwhere");
- $sqllimit = " LIMIT $offset, $entriesbypage";
- $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit");
- } else {
- $sqlselect = "SELECT *";
- $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories c";
- $sqlwhere = "WHERE (ge.id = c.entryid and c.categoryid = $cat) and
- (ge.glossaryid = $glossary->id or ge.sourceglossaryid = $glossary->id)";
- $sqlorderby = "ORDER BY $orderby";
-
- $count = count_records_sql("select count(*) $sqlfrom $sqlwhere");
- $sqllimit = " LIMIT $offset, $entriesbypage";
- $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit");
- }
+ $sqlorderby = ' ORDER BY gc.name, ge.concept';
+ }
+
+ } elseif ($hook == GLOSSARY_SHOW_NOT_CATEGORISED ) {
+
+ $printpivot = 0;
+ $sqlselect = "SELECT concept pivot, ge.*";
+ $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge";
+ $sqlwhere = "WHERE (glossaryid = '$glossary->id' OR sourceglossaryid = '$glossary->id') AND
+ (ge.approved != 0 OR ge.userid = $USER->id)";
+
+
+ $sqlorderby = ' ORDER BY concept';
+
+ } else {
+
+ $printpivot = 0;
+ $sqlselect = "SELECT ce.id, c.name pivot, ge.*";
+ $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories ce, {$CFG->prefix}glossary_categories c";
+ $sqlwhere = "WHERE ge.id = ce.entryid AND ce.categoryid = $hook AND
+ ce.categoryid = c.id AND ge.approved != 0 AND
+ (ge.glossaryid = $glossary->id OR ge.sourceglossaryid = $glossary->id) AND
+ (ge.approved != 0 OR ge.userid = $USER->id)";
+
+ $sqlorderby = ' ORDER BY c.name, ge.concept';
+
+ }
+ $count = count_records_sql("select count(*) $sqlfrom $sqlwhere");
+ $sqllimit = " LIMIT $offset, $entriesbypage";
+ $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit");
+ break;
+ case GLOSSARY_AUTHOR_VIEW:
+
+ $where = '';
+ switch ($CFG->dbtype) {
+ case 'postgres7':
+ $usernamefield = "u.firstname || ' ' || u.lastname";
+ $where = "AND substr(ucase($usernamefield),1," . strlen($hook) . ") = '" . strtoupper($hook) . "'";
+ break;
+ case 'mysql':
+ $usernamefield = "CONCAT(CONCAT(u.firstname,' '), u.lastname)";
+ $where = "AND left(ucase($usernamefield)," . strlen($hook) . ") = '$hook'";
+ break;
+ }
+ if ( $hook == 'ALL' ) {
+ $where = '';
+ }
+
+ $sqlselect = "SELECT ge.id, $usernamefield pivot, u.id uid, ge.*";
+ $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}user u";
+ $sqlwhere = "WHERE ge.userid = u.id AND
+ ge.approved != 0
+ $where AND
+ (ge.glossaryid = $glossary->id OR ge.sourceglossaryid = $glossary->id)";
+ $sqlorderby = "ORDER BY $usernamefield, ge.concept";
+
+ $count = count_records_sql("select count(*) $sqlfrom $sqlwhere");
+ $sqllimit = " LIMIT $offset, $entriesbypage";
+ $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit");
+ break;
+ case GLOSSARY_APPROVAL_VIEW:
+ $fullpivot = 0;
+ $printpivot = 0;
+
+ $where = '';
+ if ($hook != 'ALL' and $hook != 'SPECIAL') {
+ switch ($CFG->dbtype) {
+ case 'postgres7':
+ $where = 'AND substr(ucase(concept),1,' . strlen($hook) . ') = \'' . strtoupper($hook) . '\'';
+ break;
+ case 'mysql':
+ $where = 'AND left(ucase(concept),' . strlen($hook) . ") = '$hook'";
+ break;
+ }
+ }
+
+ $sqlselect = "SELECT ge.concept pivot, ge.*";
+ $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge";
+ $sqlwhere = "WHERE (ge.glossaryid = $glossary->id OR ge.sourceglossaryid = $glossary->id) AND
+ ge.approved = 0 $where";
+
+ if ( $sortkey ) {
+ $sqlorderby = "ORDER BY $sortkey $sortorder";
+ } else {
+ $sqlorderby = "ORDER BY ge.concept";
+ }
+
+ $count = count_records_sql("select count(*) $sqlfrom $sqlwhere");
+ $sqllimit = " LIMIT $offset, $entriesbypage";
+ $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit");
+ break;
+ case GLOSSARY_DATE_VIEW:
+ case GLOSSARY_STANDARD_VIEW:
+ default:
+ $sqlselect = "SELECT ge.concept pivot, ge.*";
+ $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge";
+
+ $where = '';
+ $fullpivot = 0;
+ if ($CFG->dbtype == "postgres7") {
+ $LIKE = "ILIKE"; // case-insensitive
+ } else {
+ $LIKE = "LIKE";
+ }
+
+ switch ( $mode ) {
+ case 'search':
+ $printpivot = 0;
+ $where = "AND ( ge.concept $LIKE '%$hook%'";
+ if ( $fullsearch ) {
+ $where .= "OR ge.definition $LIKE '%$hook%')";
+ } else {
+ $where .= ")";
}
- $currentcategory = "";
break;
- case GLOSSARY_APPROVAL_VIEW:
- $allentries = glossary_get_entries_sorted($glossary, 'approved = 0',$orderby);
- $currentletter = '';
+
+ case 'term':
+ $printpivot = 0;
+ $sqlfrom .= ", {$CFG->prefix}glossary_alias ga";
+ $where = "AND ge.id = ga.entryid AND ( ge.concept = '$hook' OR ga.alias = '$hook' )";
break;
- case GLOSSARY_DATE_VIEW:
- $l = 'ALL';
- case GLOSSARY_STANDARD_VIEW:
- default:
- if ($search) { // looking for a term
- $allentries = glossary_search_entries($searchterms, $glossary, $includedefinition);
- } elseif ($eid) { // looking for an entry
- $allentries = get_records_select("glossary_entries", "id = $eid");
- } elseif ( $l or $sortkey ) {
- $where = '';
- if ($l != 'ALL' and $l != 'SPECIAL') {
- switch ($CFG->dbtype) {
- case 'postgres7':
- $where = 'and substr(ucase(concept),1,' . strlen($l) . ') = \'' . strtoupper($l) . '\'';
- break;
- case 'mysql':
- $where = 'and left(ucase(concept),' . strlen($l) . ") = '$l'";
- break;
- default:
- $where = '';
- }
+
+ case 'entry':
+ $printpivot = 0;
+ $where = "AND ge.id = $hook";
+ break;
+
+ case 'letter':
+ if ($hook != 'ALL' and $hook != 'SPECIAL') {
+ switch ($CFG->dbtype) {
+ case 'postgres7':
+ $where = 'AND substr(ucase(concept),1,' . strlen($hook) . ') = \'' . strtoupper($hook) . '\'';
+ break;
+ case 'mysql':
+ $where = 'AND left(ucase(concept),' . strlen($hook) . ") = '$hook'";
+ break;
}
- $sqlselect = "SELECT *";
- $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge";
- $sqlwhere = "WHERE (ge.glossaryid = $glossary->id or ge.sourceglossaryid = $glossary->id) $where";
- $sqlorderby = "ORDER BY $orderby";
- $count = count_records_sql("select count(*) $sqlfrom $sqlwhere");
- $sqllimit = " LIMIT $offset, $entriesbypage";
- $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit");
}
- $currentletter = '';
break;
+ }
+
+ $sqlwhere = "WHERE (ge.glossaryid = $glossary->id or ge.sourceglossaryid = $glossary->id) AND
+ (ge.approved != 0 OR ge.userid = $USER->id)
+ $where";
+ switch ( $tab ) {
+ case GLOSSARY_DATE_VIEW:
+ $sqlorderby = "ORDER BY $sortkey $sortorder";
+ break;
+
+ case GLOSSARY_STANDARD_VIEW:
+ $sqlorderby = "ORDER BY ge.concept";
+ default:
+ break;
+ }
+
+ $count = count_records_sql("select count(*) $sqlfrom $sqlwhere");
+ $sqllimit = " LIMIT $offset, $entriesbypage";
+ $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit");
+
+ break;
}
-
- $dumpeddefinitions = 0;
+/*
+ print_simple_box_start("center","85%");
+ print_object($allentries);
+ print_simple_box_end();
+ $db->debug=false;
+*/
+
+/// printing the entries
+
+ $entriesshown = 0;
+ $currentpivot = '';
+ if ( $hook == 'SPECIAL' ) {
+ $alphabet = explode(",", get_string("alphabet"));
+ }
if ($allentries) {
+ /// printing the paging links
$paging = '';
if ($count > $entriesbypage ) {
for ($i = 0; ($i*$entriesbypage) < $count ; $i++ ) {
if ($offset / $entriesbypage == $i) {
$paging .= '<strong>' . ($i + 1 ) . '</strong>';
} else {
- $paging .= "<a href=\"view.php?id=$id&l=$l&search=$search&tab=$tab&cat=$cat&includedefinition=$includedefinition&sortkey=$sortkey&sortored=$sortorder&offset=" . ($i*$entriesbypage) . "\">" . ($i+1) . '</a>';
+ $paging .= "<a href=\"view.php?id=$id&mode=$mode&hook=$hook&offset=" . ($i*$entriesbypage) . "\">" . ($i+1) . '</a>';
}
}
$paging = "<font size=1><center>" . get_string ("jumpto") . " $paging</center></font>";
}
- echo "$paging<p>";
+ echo "$paging";
+ glossary_debug($debug,'<div align=right><font size=1>SELECT normal:' . count($allentries) . '</font></div>',0);
+ glossary_debug($debug,'<div align=right><font size=1>SELECT count(*):' . $count . '</font></div>',0);
+
if ($glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS) {
- echo '<table border=0 cellspacing=0 width=95% valign=top cellpadding=5><tr><td align=left bgcolor="#FFFFFF">';
+ $printpivot = 0;
}
+
foreach ($allentries as $entry) {
- $dumptoscreen = 0;
- $firstletter = strtoupper(substr(ltrim($entry->concept), 0, strlen($l)));
- if ($l) {
- if ($l == 'ALL' or $sortkey == 'CREATION' or $sortkey == 'UPDATE' or $firstletter == $l) {
- if ($currentletter != $firstletter[0]) {
- if ($entry->approved or ($USER->id == $entry->userid and !isteacher($course->id)) or $tab == GLOSSARY_APPROVAL_VIEW) {
- $currentletter = $firstletter[0];
-
- if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {
- if ($dumpeddefinitions > 0) {
- echo '</table></center><p>';
- }
- echo "\n<center><table border=0 cellspacing=0 width=95% valign=top cellpadding=5><tr><td align=center bgcolor=\"$THEME->cellheading2\">";
- }
- if ($l == 'ALL' and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) {
- if ($tab != GLOSSARY_DATE_VIEW) {
- echo "<b>$currentletter</b>";
- }
- }
-
- if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {
- echo '</center></td></tr></table></center>';
- if ($dumpeddefinitions > 0) {
- echo '<center><table border=0 cellspacing=0 width=95% valign=top cellpadding=5>';
- }
- }
- }
+//glossary_debug($debug,"<b>$entry->concept</b>");
+ $pivot = $entry->pivot;
+ if ( !$fullpivot ) {
+ $pivot = $pivot[0];
+ }
+
+ /// Validating special cases not covered by the SQL statement
+ $showentry = 1;
+ if ( $mode == 'letter' and $hook != 'SPECIAL' and $hook != 'ALL' ) {
+ if ( substr($entry->concept, 0, strlen($hook)) != $hook ) {
+ $showentry = 0;
+ }
+ }
+$num=0;
+//glossary_debug($debug,(++$num) . ": $showentry");
+ if ( $hook == 'SPECIAL' ) {
+ $initial = $entry->concept[0];
+ for ($i = 0; $i < count($alphabet); $i++) {
+ $curletter = $alphabet[$i];
+ if ( $curletter == $initial ) {
+
+ $showentry = 0;
+ break;
}
- $dumptoscreen = 1;
- } elseif ($l == 'SPECIAL' and ord($firstletter) != ord('Ñ') and
- (ord($firstletter) < ord('A') or ord($firstletter) > ord('Z'))) {
- $dumptoscreen = 1;
- }
- } else {
- if ($tab == GLOSSARY_CATEGORY_VIEW) {
- if ($category) { // if we are browsing a category
- $dumptoscreen = 1;
- } else {
- if ($cat == GLOSSARY_SHOW_NOT_CATEGORISED) { // Not categorized
- if (! record_exists("glossary_entries_categories", "entryid", $entry->id)) {
- $dumptoscreen = 1;
- }
- } else { // All categories
- if ($currentcategory != $entry->CID) {
- if ($entry->approved or ($USER->id == $entry->userid and !isteacher($course->id)) or $tab == GLOSSARY_APPROVAL_VIEW) {
- $currentcategory = $entry->CID;
- if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {
- if ($dumpeddefinitions > 0) {
- echo '</table></center><p>';
- }
- echo "\n<center><table border=0 cellspacing=0 width=95% valign=top cellpadding=10><tr><td align=center bgcolor=\"$THEME->cellheading2\">";
- }
- if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
- echo '<center>';
- }
- echo "<b>$entry->name</b>";
- if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
- echo '</center><p>';
- }
- }
- }
- $dumptoscreen = 1;
-
- if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {
- echo '</center></td></tr></table></center>';
- if ($dumpeddefinitions > 0) {
- echo '<center><table border=1 cellspacing=0 width=95% valign=top cellpadding=10>';
- }
- }
-
- $dumptoscreen = 1;
- }
- }
- } else {
- $dumptoscreen = 1;
- }
+ }
}
-
- if ($dumptoscreen) {
- $dumpeddefinitions++;
-
+//glossary_debug($debug,(++$num) . ": $showentry");
+ if ( $mode == 'cat' and $hook == GLOSSARY_SHOW_NOT_CATEGORISED ) {
+ if ( record_exists("glossary_entries_categories", "entryid", $entry->id)) {
+ $showentry = 0;
+ }
+ }
+//glossary_debug($debug,(++$num) . ": $showentry");
+ if ( $mode != 'approval' ) {
+ if ( !$entry->approved and isteacher($course->id, $entry->userid) ) {
+ $showentry = 0;
+ }
+ }
+//glossary_debug($debug,(++$num) . ": $showentry");
+ /// ok, if it's a valid entry.. Print it.
+ if ( $showentry ) {
+
+ /// if there's a group break
+ if ( $currentpivot != $pivot ) {
+
+ // print the group break if apply and necessary
+ if ( $printpivot ) {
+ if ( $tableisopen ) {
+ print_simple_box_end();
+ $tableisopen = 0;
+ }
+ $currentpivot = $pivot;
+
+ echo '<p>';
+ echo '<table width="95%" border="0" class="generaltabselected" bgcolor="' . $THEME->cellheading2 . '">';
+
+ echo '<tr>';
+ if ( isset($entry->uid) ) {
+ // printing the user icon if defined (only when browsing authors)
+ echo '<td align="left">';
+
+ $user = get_record("user","id",$entry->uid);
+ print_user_picture($user->id, $course->id, $user->picture);
+ } else {
+ echo '<td align="center">';
+ }
+
+ echo "<strong> $currentpivot</strong>" ;
+ echo '</td></tr></table>';
+
+ if ($glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS OR
+ $glossary->displayformat == GLOSSARY_FORMAT_SIMPLE ) {
+ print_simple_box_start("center","95%","#ffffff","5","generalbox");
+ $tableisopen = 1;
+ }
+ }
+ }
+
+ if ( !$tableisopen ) {
+ if ($glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS OR
+ $glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {
+ print_simple_box_start("center","95%","#ffffff","5","generalbox");
+ $tableisopen = 1;
+ }
+ }
+
$concept = $entry->concept;
$definition = $entry->definition;
- if ($dumpeddefinitions == 1) {
- if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {
- echo '<center><table border=1 cellspacing=0 width=95% valign=top cellpadding=10>';
- }
+ /// highligh the term if necessary
+ if ($mode == 'search') {
+ $entry->concept = highlight($hook, $concept);
+ $entry->definition = highlight($hook, $definition);
}
- if ($search) {
- $entry->concept = highlight($search, $concept);
- $entry->definition = highlight($search, $definition);
- }
-
- glossary_print_entry($course, $cm, $glossary, $entry, $tab, $cat);
- if ($glossary->displayformat != GLOSSARY_FORMAT_SIMPLE) {
- echo '<p>';
- }
- }
- }
- }
- if (! $dumpeddefinitions) {
- print_simple_box_start("center", "70%", "$THEME->cellheading2");
- if (!$search) {
- echo "<center>$strnoentries</center>";
- } else {
- echo '<center>';
- print_string("searchhelp");
- echo '</center>';
- }
- print_simple_box_end();
- } else {
- if ( $paging ) {
- echo "<table border=0><tr><td>$paging</td></tr></table>";
+
+ /// and finally print the entry.
+ glossary_print_entry($course, $cm, $glossary, $entry, $mode, $hook);
+ $entriesshown++;
+// echo '<p>';
+ }
}
- switch ($glossary->displayformat) {
- case GLOSSARY_FORMAT_CONTINUOUS:
- echo '</td></tr></table><p>';
- break;
- case GLOSSARY_FORMAT_SIMPLE:
- echo '</table></center><p>';
- break;
- }
- }
-
+ if ( $tableisopen ) {
+ if ($glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS OR
+ $glossary->displayformat == GLOSSARY_FORMAT_SIMPLE ) {
+ print_simple_box_end();
+ $tableisopen = 0;
+ }
+ }
+ }
+ if ( !$entriesshown ) {
+ print_simple_box('<center>' . get_string("noentries","glossary") . '</center>',"center","95%");
+ }
+
echo '</center>';
glossary_print_tabbed_table_end();
+ if ( $debug ) {
+ echo '<p>';
+ print_simple_box("$sqlselect<br> $sqlfrom<br> $sqlwhere<br> $sqlorderby<br> $sqllimit","center","85%");
+ }
/// Finish the page
print_footer($course);
-
-?>
+?>
\ No newline at end of file