From ea14e7837359cc52f562c5bf15c72a59e5b19ed1 Mon Sep 17 00:00:00 2001 From: willcast Date: Mon, 3 Nov 2003 02:26:44 +0000 Subject: [PATCH] - Cosmetic changes... Changing the Add Entry button for a new tab - Creating two new tabs for the future export/import features. - Improving a little the Printer-Friendly version (now it shows what you were watching in the previous frame) --- lang/en/glossary.php | 6 ++- mod/glossary/dynalink.php | 9 +++- mod/glossary/edit.html | 103 +++++++++++++++----------------------- mod/glossary/edit.php | 17 ++++++- mod/glossary/export.php | 2 +- mod/glossary/lib.php | 49 ++++++++++++++---- mod/glossary/print.php | 36 +++++++++++-- mod/glossary/tabs.html | 84 +++++++++++++++++++++++++++++++ mod/glossary/view.php | 99 ++++++------------------------------ 9 files changed, 242 insertions(+), 163 deletions(-) create mode 100644 mod/glossary/tabs.html diff --git a/lang/en/glossary.php b/lang/en/glossary.php index 715214b047c89..f72ed0ad109c5 100644 --- a/lang/en/glossary.php +++ b/lang/en/glossary.php @@ -15,7 +15,7 @@ $string['ascending'] = "(ascending)"; $string['attachment'] = "Attachment"; $string['back'] = "Back"; -$string['casesensitive'] = "This entry is
case sensitive"; +$string['casesensitive'] = "This entry is case sensitive"; $string['categories'] = "Categories"; $string['categoryview'] = "Browse by category"; $string['category'] = "Category"; @@ -51,6 +51,7 @@ $string['displayformat4'] = "FAQ"; $string['displayformat5'] = "Full without author"; $string['editcategories'] = "Edit categories"; +$string['editalias'] = "Edit alias"; $string['editentry'] = "Edit entry"; $string['editingcomment'] = "Editing comment"; $string['entries'] = "Entries"; @@ -60,11 +61,12 @@ $string['entryapproved'] = "This entry has been approved"; $string['entrydeleted'] = "Entry deleted"; $string['entryishidden'] = "(this entry is currently hidden)"; -$string['entryusedynalink'] = "This entry should be
automatically linked"; +$string['entryusedynalink'] = "This entry should be automatically linked"; $string['entryexported'] = "Entry succesfully exported"; $string['explainspecial'] = "Shows entries that do not begin with a letter"; $string['explainalphabet'] = "Browse the glossary using this index"; $string['explainall'] = "Shows ALL entries on one page"; +$string['explainaddentry'] = "Add a new entry to the current glossary.
Concept and definition are mandatory fields."; $string['exportedentry'] = "Exported entry"; $string['exportglossary'] = "Export glossary"; $string['exporttomainglossary'] = "Export to main glossary"; diff --git a/mod/glossary/dynalink.php b/mod/glossary/dynalink.php index 7762b41ee097e..b48d07e6b3200 100644 --- a/mod/glossary/dynalink.php +++ b/mod/glossary/dynalink.php @@ -67,7 +67,14 @@ function glossary_dynamic_link($courseid, $text) { "onClick=\"return openpopup('/mod/glossary/showentry.php?courseid=$courseid\&concept=$concept->concept', 'entry', 'menubar=0,location=0,scrollbars,resizable,width=600,height=450', 0);\">"; } - $currentconcept = trim(strip_tags($concept->concept)); + $currentconcept = trim(strip_tags(str_replace("|", "\|", $concept->concept))); + if ( !$concept->category ) { + if ( $aliases = get_records("glossary_alias","entryid",$concept->id) ) { + foreach ($aliases as $alias) { + $currentconcept .= "|" . trim(strip_tags(str_replace("|", "\|", $alias->alias))); + } + } + } $text = glossary_link_concepts($text,$currentconcept,$href_tag_begin, "",$concept->casesensitive,$concept->fullmatch); } } diff --git a/mod/glossary/edit.html b/mod/glossary/edit.html index faa4a8e4e6fe7..d05cddd810950 100644 --- a/mod/glossary/edit.html +++ b/mod/glossary/edit.html @@ -22,7 +22,10 @@

:

- + + + + - - - - - - - +
id); echo " -

:

+ + + - - - - + + +
: @@ -59,61 +61,38 @@ $selected = "checked"; } ?> - onclick="return lockoptions('form','usedynalink', items)"> -

:

- + onclick="return lockoptions('form','usedynalink', items)"> +
: +casesensitive) ) { + if ($newentry->casesensitive) { + $selected = "checked"; + } + } elseif ( $CFG->cnfcasesensitive ) { + $selected = "checked"; + } +?> + > +
: +fullmatch) ) { + if ($newentry->fullmatch) { + $selected = "checked"; + } + } elseif ( $CFG->cnffullmatch ) { + $selected = "checked"; + } +?> + > +

:

- +
@@ -160,9 +139,9 @@ -

- id)) { - echo "id\">"; +

+ id)) { + echo "id\">"; } ?> diff --git a/mod/glossary/edit.php b/mod/glossary/edit.php index e3c1cb61dabc9..b56c02eeca9c6 100644 --- a/mod/glossary/edit.php +++ b/mod/glossary/edit.php @@ -188,11 +188,26 @@ id\">$glossary->name -> $stredit", "form.text", "", true, "", navmenu($course, $cm)); -print_heading($glossary->name); + echo '

' . stripslashes_safe($glossary->name); + echo '

'; +/// Info box + + if ( $glossary->intro ) { + print_simple_box_start('center','70%'); + echo format_text($glossary->intro); + print_simple_box_end(); + } + +/// Tabbed browsing sections +$tab = GLOSSARY_ADDENTRY_VIEW; +include("tabs.html"); include("edit.html"); +echo ''; +glossary_print_tabbed_table_end(); + print_footer($course); ?> diff --git a/mod/glossary/export.php b/mod/glossary/export.php index d079f31bec9a2..84d8ae953307b 100644 --- a/mod/glossary/export.php +++ b/mod/glossary/export.php @@ -5,7 +5,7 @@ require_variable($id); // Course Module ID - optional_variable($tab,GLOSSARY_APPROVAL_VIEW); + optional_variable($tab,GLOSSARY_STANDARD_VIEW); optional_variable($l,"ALL"); if (! $cm = get_record("course_modules", "id", $id)) { diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 86a233046bab2..f807b501eeff7 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -11,7 +11,10 @@ define("GLOSSARY_STANDARD_VIEW", 0); define("GLOSSARY_CATEGORY_VIEW", 1); define("GLOSSARY_DATE_VIEW", 2); -define("GLOSSARY_APPROVAL_VIEW", 3); +define("GLOSSARY_ADDENTRY_VIEW", 3); +define("GLOSSARY_IMPORT_VIEW", 4); +define("GLOSSARY_EXPORT_VIEW", 5); +define("GLOSSARY_APPROVAL_VIEW", 6); define("GLOSSARY_FORMAT_SIMPLE", 0); define("GLOSSARY_FORMAT_CONTINUOUS", 1); @@ -93,6 +96,7 @@ function glossary_delete_instance($id) { $ents = substr($ents,0,-1); if ($ents) { delete_records_select("glossary_comments", "entryid in ($ents)"); + delete_records_select("glossary_alias", "entryid in ($ents)"); } } delete_records("glossary_entries", "glossaryid", "$glossary->id"); @@ -214,15 +218,18 @@ function glossary_log_info($log) { AND u.id = '$log->userid'"); } -function glossary_get_entries($glossaryid, $entrylist) { +function glossary_get_entries($glossaryid, $entrylist, $pivot = "") { global $CFG; + if ($pivot) { + $pivot .= ","; + } - return get_records_sql("SELECT id,userid,concept,definition,format + return get_records_sql("SELECT $pivot id,userid,concept,definition,format FROM {$CFG->prefix}glossary_entries WHERE glossaryid = '$glossaryid' AND id IN ($entrylist)"); } -function glossary_get_entries_sorted($glossary, $where="", $orderby="") { +function glossary_get_entries_sorted($glossary, $where="", $orderby="", $pivot = "") { global $CFG; if ($where) { $where = " and $where"; @@ -230,12 +237,15 @@ function glossary_get_entries_sorted($glossary, $where="", $orderby="") { if ($orderby) { $orderby = " ORDER BY $orderby"; } - return get_records_sql("SELECT * + if ($pivot) { + $pivot .= ","; + } + return get_records_sql("SELECT $pivot * FROM {$CFG->prefix}glossary_entries WHERE (glossaryid = $glossary->id or sourceglossaryid = $glossary->id) $where $orderby"); } -function glossary_get_entries_by_category($glossary, $cat, $where="", $orderby="") { +function glossary_get_entries_by_category($glossary, $cat, $where="", $orderby="", $pivot = "") { global $CFG; if ($where) { $where = " and $where"; @@ -243,7 +253,10 @@ function glossary_get_entries_by_category($glossary, $cat, $where="", $orderby=" if ($orderby) { $orderby = " ORDER BY $orderby"; } - return get_records_sql("SELECT ge.* + if ($pivot) { + $pivot .= ","; + } + 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 (ge.glossaryid = $glossary->id or ge.sourceglossaryid = $glossary->id) $where $orderby"); @@ -284,9 +297,20 @@ function glossary_print_entry($course, $cm, $glossary, $entry, $tab="",$cat="") } } } -function glossary_print_entry_concept($entry) { - echo $entry->concept; -} +function glossary_print_entry_concept($entry, $alias = true) { +static $glossary; // to avoid unnecessary calls when dealing with the same glossary +static $cm; + echo $entry->concept; +/* + if ($alias) { + if ($glossary->id != $entry->glossaryid) { + $glossary = get_record("glossary","id",$entry->glossaryid); + $cm = get_coursemodule_from_instance("glossary", $glossary->id, $glossary->course); + } + echo " id&eid=$entry->id\">"; + } +*/ + } function glossary_print_entry_definition($entry) { $definition = str_ireplace($entry->concept,"$entry->concept",$entry->definition); @@ -397,6 +421,7 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab="",$cat echo " " . get_string("exportedentry","glossary") . ""; } } + echo "  "; // just to make up a little the output in Mozilla ;) } function glossary_search_entries($searchterms, $glossary, $includedefinition) { @@ -808,6 +833,10 @@ function glossary_print_approval_menu($cm, $glossary, $l, $sortkey, $sortorder = glossary_print_sorting_links($cm, $sortkey,$sortorder, $tab); } +function glossary_print_addentry_menu($cm, $glossary, $l, $sortkey, $sortorder = "", $tab=GLOSSARY_STANDARD_VIEW) { + echo '
' . get_string("explainaddentry","glossary") . '

'; +} + function glossary_print_alphabet_menu($cm, $glossary, $l, $sortkey, $sortorder = "", $tab=GLOSSARY_STANDARD_VIEW) { if ( $tab != GLOSSARY_DATE_VIEW ) { if ($glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) { diff --git a/mod/glossary/print.php b/mod/glossary/print.php index 96894a8cef9ed..1d66474275c72 100644 --- a/mod/glossary/print.php +++ b/mod/glossary/print.php @@ -8,6 +8,10 @@ require_variable($tab,GLOSSARY_STANDARD_VIEW); // 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($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"); @@ -26,16 +30,26 @@ error("You must be logged to use this page."); } + if ( $eid ) { + $l = ''; + $tab = GLOSSARY_STANDARD_VIEW; + } /// Generating the SQL based on the format to show switch ($tab) { case GLOSSARY_CATEGORY_VIEW: + $where = ''; + if ($cat) { + if ( $cat != GLOSSARY_SHOW_ALL_CATEGORIES and $cat != GLOSSARY_SHOW_NOT_CATEGORISED ) { + $where = 'and c.id = ' . $cat; + } + } $entries = get_records_sql("SELECT c.name pivot, e.* FROM {$CFG->prefix}glossary_entries e, {$CFG->prefix}glossary_entries_categories ec, {$CFG->prefix}glossary_categories as c WHERE e.id = ec.entryid AND ec.categoryid = c.id AND (e.glossaryid = $glossary->id or e.sourceglossaryid = $glossary->id) - AND e.approved != 0 + AND e.approved != 0 $where ORDER BY c.name, e.concept"); break; @@ -78,15 +92,31 @@ break; } + if ( $l ) { + 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 = ''; + } + } + } elseif ($eid) { + $where = " and e.id = $eid"; + } + $entries = get_records_sql("SELECT $pivot pivot, e.* FROM {$CFG->prefix}glossary_entries e WHERE (e.glossaryid = $glossary->id or e.sourceglossaryid = $glossary->id) - AND e.approved != 0 + AND e.approved != 0 $where ORDER BY e.concept $sortorder"); break; } - echo '

' . get_string("course") . ': ' . $course->fullname . '
'; echo get_string("modulename","glossary") . ': ' . $glossary->name . '

'; diff --git a/mod/glossary/tabs.html b/mod/glossary/tabs.html new file mode 100644 index 0000000000000..4c0673621f299 --- /dev/null +++ b/mod/glossary/tabs.html @@ -0,0 +1,84 @@ +'; + $glossary_tCFG->TabTableBGColor = $THEME->cellheading; + $glossary_tCFG->ActiveTabColor = $THEME->cellheading; + $glossary_tCFG->InactiveTabColor = $THEME->cellcontent2; + $glossary_tCFG->InactiveFontColor= $THEME->hidden; + $glossary_tCFG->TabTableWidth = "70%"; + $glossary_tCFG->TabsPerRow = 4; + $glossary_tCFG->TabSeparation = 4; + + $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"); + if (!isguest()) { + if ( isteacher($course->id) or $glossary->studentcanpost ) { + $data[GLOSSARY_ADDENTRY_VIEW]->caption = get_string("addentry", "glossary"); + $data[GLOSSARY_ADDENTRY_VIEW]->link = "edit.php?id=$cm->id"; + } + } + + if ( isteacher($course->id) ) { + $data[GLOSSARY_IMPORT_VIEW]->caption = "Import Entries"; + $data[GLOSSARY_EXPORT_VIEW]->caption = "Export Entries"; + +// $data[GLOSSARY_IMPORT_VIEW]->link = "import.php?id=$cm->id&tab=$tab"; +// $data[GLOSSARY_EXPORT_VIEW]->link = "export.php?id=$cm->id&tab=$tab"; + } + + $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 = ""; + + $hiddenentries = get_records_select("glossary_entries","glossaryid = $glossary->id and approved = 0"); + if ($hiddenentries) { + $data[GLOSSARY_APPROVAL_VIEW]->caption .= "
(" . count($hiddenentries) . " " . get_string("entries","glossary") . ")"; + $data[GLOSSARY_APPROVAL_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_APPROVAL_VIEW; + } elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) { + $tab = $framebydefault; + } + } elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) { + $tab = $framebydefault; + } + +/// printing header of the current tab + echo '
'; + glossary_print_tabbed_table_start($data, $tab, $glossary_tCFG); + switch ($tab) { + case GLOSSARY_CATEGORY_VIEW: + glossary_print_categories_menu($course, $cm, $glossary, $cat, $category); + break; + case GLOSSARY_APPROVAL_VIEW: + glossary_print_approval_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab); + break; + case GLOSSARY_ADDENTRY_VIEW: + $search = ""; + $l = ""; + glossary_print_addentry_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab); + break; + case GLOSSARY_DATE_VIEW: + if (!$sortkey) { + $sortkey = 'UPDATE'; + } + if (!$sortorder) { + $sortorder = 'desc'; + } + case GLOSSARY_STANDARD_VIEW: + default: + glossary_print_alphabet_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab); + if ($search) { + echo "

$strsearch: $search

"; + } + break; + } + echo '
'; +?> \ No newline at end of file diff --git a/mod/glossary/view.php b/mod/glossary/view.php index 003db7615a9df..664b088907393 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -20,6 +20,10 @@ 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"); } @@ -89,6 +93,7 @@ $search = trim(implode(' ', $searchterms)); $tab = $framebydefault; } elseif ($eid) { /// searching a specify entry + $tab = GLOSSARY_STANDARD_VIEW; $search = ''; } @@ -135,8 +140,12 @@ navmenu($course, $cm)); echo '

' . stripslashes_safe($glossary->name); - echo ' '; - echo ''; + if ($tab == GLOSSARY_CATEGORY_VIEW | $tab == GLOSSARY_STANDARD_VIEW | + $tab == GLOSSARY_DATE_VIEW) { + /// the "Print" icon + echo " id&tab=$tab&cat=$cat&l=$l&eid=$eid&sortkey=$sortkey&sortorder=$sortorder\">"; + echo ''; + } echo '

'; /// Info box @@ -147,28 +156,9 @@ print_simple_box_end(); } -/// Add buttons - - if (!isguest()) { - if ( isteacher($course->id) or $glossary->studentcanpost ) { - unset($options); - $options = array ("id" => "$cm->id"); - echo '

'; - print_single_button("edit.php", $options, $straddentry); - echo '

'; - } - } - -/* - unset($options); - $options = array ("id" => "$cm->id"); - echo '

'; - print_single_button("export.php", $options, get_string("exportglossary","glossary")); - echo '

'; -*/ - /// Search box + echo '

'; print_simple_box_start("center", "", $THEME->cellheading); echo '

'; echo '

'; @@ -183,66 +173,7 @@ /// Tabbed browsing sections - echo '

'; - $glossary_tCFG->TabTableBGColor = $THEME->cellheading; - $glossary_tCFG->ActiveTabColor = $THEME->cellheading; - $glossary_tCFG->InactiveTabColor = $THEME->cellcontent2; - $glossary_tCFG->InactiveFontColor= $THEME->hidden; - $glossary_tCFG->TabTableWidth = "70%"; - $glossary_tCFG->TabsPerRow = 4; - $glossary_tCFG->TabSeparation = 4; - - $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_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 = ""; - - $hiddenentries = get_records_select("glossary_entries","glossaryid = $glossary->id and approved = 0"); - if ($hiddenentries) { - $data[GLOSSARY_APPROVAL_VIEW]->caption .= "
(" . count($hiddenentries) . " " . get_string("entries","glossary") . ")"; - $data[GLOSSARY_APPROVAL_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_APPROVAL_VIEW; - } elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) { - $tab = $framebydefault; - } - } elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) { - $tab = $framebydefault; - } - -/// printing header of the current tab - echo '

'; - glossary_print_tabbed_table_start($data, $tab, $glossary_tCFG); - switch ($tab) { - case GLOSSARY_CATEGORY_VIEW: - glossary_print_categories_menu($course, $cm, $glossary, $cat, $category); - break; - case GLOSSARY_APPROVAL_VIEW: - glossary_print_approval_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab); - break; - case GLOSSARY_DATE_VIEW: - if (!$sortkey) { - $sortkey = 'UPDATE'; - } - if (!$sortorder) { - $sortorder = 'desc'; - } - case GLOSSARY_STANDARD_VIEW: - default: - glossary_print_alphabet_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab); - if ($search) { - echo "

$strsearch: $search

"; - } - break; - } - echo '
'; + include("tabs.html"); /// Printing the entries @@ -336,7 +267,9 @@ echo "\n
cellheading2\">"; } if ($l == 'ALL' and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) { - echo "$currentletter"; + if ($tab != GLOSSARY_DATE_VIEW) { + echo "$currentletter"; + } } if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {