From: willcast Date: Sat, 15 Nov 2003 15:55:47 +0000 (+0000) Subject: - Rewrite of the internal API in order to, hopefully, create an easy way to handle... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=1ac87c73976764fe43dbef8f1a0dd6ce205a3147;p=moodle.git - Rewrite of the internal API in order to, hopefully, create an easy way to handle the flow of data internally and externally. - Adding a new frame: Browse by Author - A new, friendly way to show entries (asked by Martin): view?id=cm&mode=term&hook=[concept | alias ] - Handling user activies, outline and complete. - Properly showing new entries in recent activity box. - Adding a flag to categories to specify if a category should or should not be automatically linked. - Adding some missing strings and files as well. - Adding a field to each glossary that specify how many entries by pages it should show. --- diff --git a/lang/en/glossary.php b/lang/en/glossary.php index 8e1d5aa32f..17b815524b 100644 --- a/lang/en/glossary.php +++ b/lang/en/glossary.php @@ -3,15 +3,18 @@ $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"; @@ -62,6 +65,7 @@ $string['editentry'] = "Edit entry"; $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"; @@ -88,11 +92,13 @@ $string['glossarytype'] = "Glossary Type"; $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"; @@ -101,6 +107,7 @@ $string['noconceptfound'] = "No concept or definition found."; $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"; diff --git a/lang/en/help/glossary/destination.html b/lang/en/help/glossary/destination.html new file mode 100644 index 0000000000..c7d59c2b4b --- /dev/null +++ b/lang/en/help/glossary/destination.html @@ -0,0 +1,7 @@ +

Definition destination of imported entries

+ +

You can specify where do you want to import the entries:

+ diff --git a/lang/en/help/glossary/entbypage.html b/lang/en/help/glossary/entbypage.html new file mode 100644 index 0000000000..b2fac23588 --- /dev/null +++ b/lang/en/help/glossary/entbypage.html @@ -0,0 +1,7 @@ +

Defining number of entries shown by page

+ +

You can specify the number of entries shown by page. This number depends on the configuration of the glossary.

+ +

The more automatically linked entries you have, the lower this number should be in order to avoid long answer time from the application.

+ +

Note: If you get a timout error when browsing a glossary, it probable needs to have a lower number of entries shown by page.

diff --git a/lang/en/help/glossary/filetoimport.html b/lang/en/help/glossary/filetoimport.html new file mode 100644 index 0000000000..e1f11414d9 --- /dev/null +++ b/lang/en/help/glossary/filetoimport.html @@ -0,0 +1,3 @@ +

File to import

+ +

Select the XML file which contains the entries to import.

diff --git a/lang/en/help/glossary/importcategories.html b/lang/en/help/glossary/importcategories.html new file mode 100644 index 0000000000..146e6220d5 --- /dev/null +++ b/lang/en/help/glossary/importcategories.html @@ -0,0 +1,3 @@ +

Importing categories

+ +

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).

diff --git a/lang/en/help/glossary/index.html b/lang/en/help/glossary/index.html index 1fce87c84d..1ca4d3faa1 100644 --- a/lang/en/help/glossary/index.html +++ b/lang/en/help/glossary/index.html @@ -11,7 +11,12 @@ Glossary level help files:
  • Students can post entries
  • Comments on entries
  • Display formats for entries +
  • Number of entries shown by page
  • Browsing options in Alphabet View frame +
  • Automatically linking categories +
  • Importing entries +
  • Importing categories +
  • Destination of the entries to import diff --git a/lang/en/help/glossary/linkcategory.html b/lang/en/help/glossary/linkcategory.html new file mode 100644 index 0000000000..da55df4b41 --- /dev/null +++ b/lang/en/help/glossary/linkcategory.html @@ -0,0 +1,5 @@ +

    Automatically linking categories

    + +

    You can specify if you want the categories to be automatically linked or not.

    + +

    Note: Categories are linked based on a case sensitive, full whole match.

    diff --git a/mod/glossary/approve.php b/mod/glossary/approve.php index 711d55145f..1d9166f378 100644 --- a/mod/glossary/approve.php +++ b/mod/glossary/approve.php @@ -6,8 +6,8 @@ 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"); @@ -33,6 +33,6 @@ } 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 diff --git a/mod/glossary/backuplib.php b/mod/glossary/backuplib.php index 834c9cc719..2adcfa57be 100644 --- a/mod/glossary/backuplib.php +++ b/mod/glossary/backuplib.php @@ -90,6 +90,7 @@ 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); diff --git a/mod/glossary/comment.php b/mod/glossary/comment.php index 8bdda5c265..67a14bbe8e 100644 --- a/mod/glossary/comment.php +++ b/mod/glossary/comment.php @@ -80,8 +80,28 @@ echo "
    "; } - glossary_print_entry($course, $cm, $glossary, $entry); + echo "

    "; + echo ""; + echo "cellheading2>"; + echo ""; + echo "
    "; + echo ""; + echo "
    "; + echo get_string("commentson","glossary") . " $entry->concept"; + echo "
    "; + + echo "
    "; + if ($entry->attachment) { + $entry->course = $course->id; + echo "
    "; + echo glossary_print_attachments($entry,"html"); + echo "
    "; + } + echo "$entry->concept: "; + echo format_text($entry->definition, $entry->format); + echo "
    "; + echo "

    "; echo "
    "; diff --git a/mod/glossary/config.html b/mod/glossary/config.html index d515b3d6ea..60bcf6cd8d 100644 --- a/mod/glossary/config.html +++ b/mod/glossary/config.html @@ -11,20 +11,20 @@

    glossary_entbypage: - + -

    students_can_post_entries: +

    glossary_studentspost: - cnfstudentcanpost) { + if ($CFG->glossary_studentspost) { $yselected = " SELECTED "; } else { $nselected = " SELECTED "; @@ -39,13 +39,13 @@ -

    allow_duplicated_entries: +

    glossary_dupentries: - cnfallowdupentries) { + if ($CFG->glossary_dupentries) { $yselected = " SELECTED "; } else { $nselected = " SELECTED "; @@ -60,13 +60,13 @@ -

    allow_comments: +

    glossary_allowcomments: - cngallowcomments) { + if ($CFG->glossary_allowcomments) { $yselected = " SELECTED "; } else { $nselected = " SELECTED "; @@ -77,17 +77,17 @@ - + -

    automatically_link_glossaries: +

    glossary_linkbydefault: - cnflinkglossaries) { + if ($CFG->glossary_linkbydefault) { $yselected = " SELECTED "; } else { $nselected = " SELECTED "; @@ -102,13 +102,13 @@ -

    default_approval_status: +

    glossary_defaultapproval: - cnfapprovalstatus) { + if ($CFG->glossary_defaultapproval) { $yselected = " SELECTED "; } else { $nselected = " SELECTED "; @@ -126,13 +126,13 @@ Entry Level Default Settings -

    automatically_link_entry: +

    glossary_linkentries: - cnflinkentry) { + if ($CFG->glossary_linkentries) { $yselected = " SELECTED "; } else { $nselected = " SELECTED "; @@ -147,13 +147,13 @@ -

    case_sensitive: +

    glossary_casesensitive: - cnfcasesensitive) { + if ($CFG->glossary_casesensitive) { $yselected = " SELECTED "; } else { $nselected = " SELECTED "; @@ -168,13 +168,13 @@ -

    match_whole_words: +

    glossary_fullmatch: - cnffullmatch) { + if ($CFG->glossary_fullmatch) { $yselected = " SELECTED "; } else { $nselected = " SELECTED "; diff --git a/mod/glossary/db/mysql.php b/mod/glossary/db/mysql.php index ca3b52a11b..71fba487b1 100644 --- a/mod/glossary/db/mysql.php +++ b/mod/glossary/db/mysql.php @@ -165,6 +165,15 @@ function glossary_upgrade($oldversion) { 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; } diff --git a/mod/glossary/db/mysql.sql b/mod/glossary/db/mysql.sql index 2948f77654..84b547f519 100644 --- a/mod/glossary/db/mysql.sql +++ b/mod/glossary/db/mysql.sql @@ -24,6 +24,7 @@ CREATE TABLE prefix_glossary ( 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) @@ -71,6 +72,7 @@ CREATE TABLE prefix_glossary_categories ( 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'; diff --git a/mod/glossary/db/postgres7.sql b/mod/glossary/db/postgres7.sql index 6c737d8674..06e11a4d1e 100644 --- a/mod/glossary/db/postgres7.sql +++ b/mod/glossary/db/postgres7.sql @@ -23,6 +23,7 @@ CREATE TABLE prefix_glossary ( 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) @@ -58,6 +59,7 @@ CREATE TABLE prefix_glossary_categories ( id SERIAL, glossaryid int4 NOT NULL default '0', name varchar(255) NOT NULL default '', + usedynalink int2 NOT NULL default '1', PRIMARY KEY (id) ); diff --git a/mod/glossary/deleteentry.html b/mod/glossary/deleteentry.html index 0629aa0f47..23a524f525 100644 --- a/mod/glossary/deleteentry.html +++ b/mod/glossary/deleteentry.html @@ -4,8 +4,8 @@ - - + + "> " onclick="javascript:history.go(-1);"> diff --git a/mod/glossary/deleteentry.php b/mod/glossary/deleteentry.php index eda4582fc9..4dffa32ea5 100644 --- a/mod/glossary/deleteentry.php +++ b/mod/glossary/deleteentry.php @@ -7,8 +7,8 @@ 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"); @@ -50,7 +50,7 @@ if ($mode == "edit" or $mode == "delete" ) { echo "

    "; - 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 @@ -74,8 +74,8 @@ 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"); @@ -88,8 +88,8 @@ - > - > + > + > "> " onclick="javascript:history.go(-1);"> diff --git a/mod/glossary/dynalink.php b/mod/glossary/dynalink.php index d146706fe7..ea7a89fc4d 100644 --- a/mod/glossary/dynalink.php +++ b/mod/glossary/dynalink.php @@ -35,7 +35,7 @@ } $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'); @@ -60,7 +60,7 @@ } $cm = get_coursemodule_from_instance("glossary", $glossary->id, $courseid); $title = strip_tags("$glossary->name: " . get_string("category","glossary"). " $category->name"); - $href_tag_begin = "wwwroot/mod/glossary/view.php?id=$cm->id&tab=1&cat=$concept->id\">"; + $href_tag_begin = "wwwroot/mod/glossary/view.php?id=$cm->id&mode=cat&hook=$concept->id\">"; } else { $concepttitle = urlencode($concept->concept); $title = strip_tags("$glossary->name: $concepttitle"); @@ -70,6 +70,7 @@ $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) ) { diff --git a/mod/glossary/edit.html b/mod/glossary/edit.html index aafc2679cf..e953d456b3 100644 --- a/mod/glossary/edit.html +++ b/mod/glossary/edit.html @@ -49,7 +49,13 @@ if (isset($errors)) {
    - +usedynalink ) { + echo ''; + echo ''; + echo ''; + } else { +?>
    :