From: willcast
Date: Tue, 16 Sep 2003 18:51:40 +0000 (+0000)
Subject: - Display format of entries is now modular.
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=e179048ec195a34859d4226df5f6150ca56993aa;p=moodle.git
- Display format of entries is now modular.
- Entries can have an optional file
- English help files.
- Now the alphabet is a language string so it is now usable in other languages.
KNOWN BUGS:
- It does not backup nor restore the attached files of the entries.
---
diff --git a/mod/glossary/README.txt b/mod/glossary/README.txt
index 1f4b462043..71fa1b67a0 100644
--- a/mod/glossary/README.txt
+++ b/mod/glossary/README.txt
@@ -20,8 +20,9 @@ Quick install instructions
1) Copy the files inside lang/en (glossary.php and help/*.*) to your lang/en folder. Please, forgive my english... I tried to do my best... I'll appreciate if you send me correct translations of these files (I've also included the spanish translation as well).
2) Create a folder inside your moodle/mod folder and copy all other files inside it.
-3) Visit your admin page to install the module
-4) Enjoy it.
+3) If you are using a them that uses its own set of icons (like cordoroyblue), you will need to copy the icon.gif and export.gif into your folder of custom icons.
+4) Visit your admin page to install the module
+5) Enjoy it.
Please, send me your comments and suggestions. It will help me improve this module.
diff --git a/mod/glossary/backuplib.php b/mod/glossary/backuplib.php
index 37532e6ec6..937cd8174c 100644
--- a/mod/glossary/backuplib.php
+++ b/mod/glossary/backuplib.php
@@ -10,7 +10,7 @@
// |
// |
// glossary_entries
- // (UL,pk->id, fk->glossaryid)
+ // (UL,pk->id, fk->glossaryid, files)
//
// Meaning: pk->primary key field of the table
// fk->foreign key to link with parent
@@ -41,6 +41,9 @@
fwrite ($bf,full_tag("ALLOWDUPLICATEDENTRIES",4,false,$glossary->allowduplicatedentries));
fwrite ($bf,full_tag("DISPLAYFORMAT",4,false,$glossary->displayformat));
fwrite ($bf,full_tag("MAINGLOSSARY",4,false,$glossary->mainglossary));
+ fwrite ($bf,full_tag("SHOWSPECIAL",4,false,$glossary->showspecial));
+ fwrite ($bf,full_tag("SHOWALPHABET",4,false,$glossary->showalphabet));
+ fwrite ($bf,full_tag("SHOWALL",4,false,$glossary->showall));
fwrite ($bf,full_tag("TIMECREATED",4,false,$glossary->timecreated));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$glossary->timemodified));
@@ -83,6 +86,7 @@
fwrite ($bf,full_tag("CONCEPT",6,false,$glo_ent->concept));
fwrite ($bf,full_tag("DEFINITION",6,false,$glo_ent->definition));
fwrite ($bf,full_tag("FORMAT",6,false,$glo_ent->format));
+ fwrite ($bf,full_tag("ATTACHMENT",6,false,$glo_ent->attachment));
fwrite ($bf,full_tag("TEACHERENTRY",6,false,$glo_ent->teacherentry));
$status =fwrite ($bf,end_tag("ENTRY",5,true));
@@ -97,6 +101,30 @@
}
+ //Backup glossary files because we've selected to backup user info
+ //and files are user info's level
+ function backup_glossary_files($bf,$preferences) {
+
+ global $CFG;
+
+ $status = true;
+
+ //First we check to moddata exists and create it as necessary
+ //in temp/backup/$backup_code dir
+ $status = check_and_create_moddata_dir($preferences->backup_unique_code);
+ //Now copy the forum dir
+ if ($status) {
+ //Only if it exists !! Thanks to Daniel Miksik.
+ if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/glossary")) {
+ $status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/glossary",
+ $CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/glossary");
+ }
+ }
+
+ return $status;
+
+ }
+
////Return an array of info (name,value)
function glossary_check_backup_mods($course,$user_data=false,$backup_unique_code) {
//First the course data
diff --git a/mod/glossary/db/mysql.php b/mod/glossary/db/mysql.php
index b8c2e655da..599dcc1c05 100644
--- a/mod/glossary/db/mysql.php
+++ b/mod/glossary/db/mysql.php
@@ -1,30 +1,46 @@
-prefix}glossary` ".
- " ADD `allowduplicatedentries` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `studentcanpost` , ".
- " ADD `displayformat` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `allowduplicatedentries` , ".
- " ADD `mainglossary` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `displayformat` ");
-
- execute_sql(" ALTER TABLE `{$CFG->prefix}glossary_entries` ".
- " ADD timecreated INT(10) UNSIGNED NOT NULL default '0' AFTER `format` , ".
- " ADD timemodified INT(10) UNSIGNED NOT NULL default '0' AFTER `timecreated` , ".
- " ADD teacherentry TINYINT(2) UNSIGNED NOT NULL default '0' AFTER `timemodified` ");
-
- execute_sql(" INSERT INTO {$CFG->prefix}log_display VALUES ('glossary', 'delete', 'glossary', 'name') ");
- execute_sql(" INSERT INTO {$CFG->prefix}log_display VALUES ('glossary', 'delete entry', 'glossary', 'name') ");
-
- }
-
- return true;
-}
-
-?>
-
+prefix}glossary` ".
+ " ADD `allowduplicatedentries` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `studentcanpost` , ".
+ " ADD `displayformat` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `allowduplicatedentries` , ".
+ " ADD `mainglossary` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `displayformat` ");
+
+ execute_sql(" ALTER TABLE `{$CFG->prefix}glossary_entries` ".
+ " ADD timecreated INT(10) UNSIGNED NOT NULL default '0' AFTER `format` , ".
+ " ADD timemodified INT(10) UNSIGNED NOT NULL default '0' AFTER `timecreated` , ".
+ " ADD teacherentry TINYINT(2) UNSIGNED NOT NULL default '0' AFTER `timemodified` ");
+
+ execute_sql(" INSERT INTO {$CFG->prefix}log_display VALUES ('glossary', 'delete', 'glossary', 'name') ");
+ execute_sql(" INSERT INTO {$CFG->prefix}log_display VALUES ('glossary', 'delete entry', 'glossary', 'name') ");
+ }
+
+ if ( $oldversion < 2003091500 ) {
+ execute_sql(" ALTER TABLE `{$CFG->prefix}glossary_entries` ".
+ " ADD attachment VARCHAR(100) NOT NULL default '' AFTER `format`");
+ }
+
+ if ( $oldversion < 2003091600 ) {
+ execute_sql(" ALTER TABLE `{$CFG->prefix}glossary` ".
+ " ADD `showspecial` TINYINT(2) UNSIGNED DEFAULT '1' NOT NULL AFTER `mainglossary` , ".
+ " ADD `showalphabet` TINYINT(2) UNSIGNED DEFAULT '1' NOT NULL AFTER `showspecial` , ".
+ " ADD `showall` TINYINT(2) UNSIGNED DEFAULT '1' NOT NULL AFTER `showalphabet` ");
+ }
+
+ return true;
+}
+
+
+
+?>
+
+
+
diff --git a/mod/glossary/db/mysql.sql b/mod/glossary/db/mysql.sql
index b3c6615b15..5a2da9a71e 100644
--- a/mod/glossary/db/mysql.sql
+++ b/mod/glossary/db/mysql.sql
@@ -1,62 +1,55 @@
# This file contains a complete database schema for all the
-
# tables used by this module, written in SQL
-
# It may also contain INSERT statements for particular data
-
# that may be used, especially new entries in the table log_display
-
-
-#
-# Table structure for table `glossary`
-#
-
-CREATE TABLE prefix_glossary (
- id int(10) unsigned NOT NULL auto_increment,
- course int(10) unsigned NOT NULL default '0',
- name varchar(255) NOT NULL default '',
- studentcanpost tinyint(2) unsigned NOT NULL default '0',
-
- allowduplicatedentries tinyint(2) unsigned NOT NULL default '0',
- displayformat tinyint(2) unsigned NOT NULL default '0',
- mainglossary tinyint(2) unsigned NOT NULL default '0',
-
- timecreated int(10) unsigned NOT NULL default '0',
- timemodified int(10) unsigned NOT NULL default '0',
- PRIMARY KEY (id)
-) TYPE=MyISAM COMMENT='all glossaries';
-
-#
-# Table structure for table `glossary_entries`
-#
-
-CREATE TABLE prefix_glossary_entries (
- id int(10) unsigned NOT NULL auto_increment,
- glossaryid int(10) unsigned NOT NULL default '0',
- userid int(10) unsigned NOT NULL default '0',
-
- concept varchar(255) NOT NULL default '',
- definition text NOT NULL,
- format tinyint(2) unsigned NOT NULL default '0',
- timecreated int(10) unsigned NOT NULL default '0',
- timemodified int(10) unsigned NOT NULL default '0',
-
- teacherentry tinyint(2) unsigned NOT NULL default '0',
-
- PRIMARY KEY (id)
-) TYPE=MyISAM COMMENT='all glossary entries';
-
-#
-# Dumping data for table `log_display`
-#
-
-INSERT INTO prefix_log_display VALUES ('glossary', 'add', 'glossary', 'name');
-INSERT INTO prefix_log_display VALUES ('glossary', 'update', 'glossary', 'name');
-
-INSERT INTO prefix_log_display VALUES ('glossary', 'view', 'glossary', 'name');
-INSERT INTO prefix_log_display VALUES ('glossary', 'view all', 'glossary', 'name');
-
-INSERT INTO prefix_log_display VALUES ('glossary', 'add entry', 'glossary', 'name');
-INSERT INTO prefix_log_display VALUES ('glossary', 'update entry', 'glossary', 'name');
\ No newline at end of file
+#
+# Table structure for table `glossary`
+#
+
+CREATE TABLE prefix_glossary (
+ id int(10) unsigned NOT NULL auto_increment,
+ course int(10) unsigned NOT NULL default '0',
+ name varchar(255) NOT NULL default '',
+ studentcanpost tinyint(2) unsigned NOT NULL default '0',
+ allowduplicatedentries tinyint(2) unsigned NOT NULL default '0',
+ displayformat tinyint(2) unsigned NOT NULL default '0',
+ mainglossary tinyint(2) unsigned NOT NULL default '0',
+ showspecial tinyint(2) unsigned NOT NULL default '1',
+ showalphabet tinyint(2) unsigned NOT NULL default '1',
+ showall tinyint(2) unsigned NOT NULL default '1',
+ timecreated int(10) unsigned NOT NULL default '0',
+ timemodified int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (id)
+) TYPE=MyISAM COMMENT='all glossaries';
+
+#
+# Table structure for table `glossary_entries`
+#
+
+CREATE TABLE prefix_glossary_entries (
+ id int(10) unsigned NOT NULL auto_increment,
+ glossaryid int(10) unsigned NOT NULL default '0',
+ userid int(10) unsigned NOT NULL default '0',
+ concept varchar(255) NOT NULL default '',
+ definition text NOT NULL,
+ format tinyint(2) unsigned NOT NULL default '0',
+ attachment VARCHAR(100) NOT NULL default '',
+ timecreated int(10) unsigned NOT NULL default '0',
+ timemodified int(10) unsigned NOT NULL default '0',
+ teacherentry tinyint(2) unsigned NOT NULL default '0',
+ PRIMARY KEY (id)
+) TYPE=MyISAM COMMENT='all glossary entries';
+
+#
+# Dumping data for table `log_display`
+#
+
+INSERT INTO prefix_log_display VALUES ('glossary', 'add', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'update', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'view', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'view all', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'add entry', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'update entry', 'glossary', 'name');
+
diff --git a/mod/glossary/edit.html b/mod/glossary/edit.html
index 55ad7a99ed..8a165d7df5 100644
--- a/mod/glossary/edit.html
+++ b/mod/glossary/edit.html
@@ -1,4 +1,4 @@
-
- echo "wwwroot/mod/glossary/view.php?id=$id&l=SPECIAL\">$strspecial | ";
-
- $middle = (int) ( (ord("Z") - ord("A")) / 2) ;
- for ($i = ord("A"); $i <= ord("Z"); $i++) {
- echo "wwwroot/mod/glossary/view.php?id=$id&l=" . chr($i) . "\">" . chr($i) . "";
- if ( $i - ord("A") - 1 != $middle ) {
- echo " | ";
- } else {
- echo "
";
- }
-
- if ($i == ord("N") ) {
- echo "wwwroot/mod/glossary/view.php?id=$id&l=Ñ\">Ñ | ";
- }
-
+ if ( $glossary->showspecial ) {
+ echo "
wwwroot/mod/glossary/view.php?id=$id&l=SPECIAL\">$strspecial | ";
}
- echo "wwwroot/mod/glossary/view.php?id=$id&l=ALL\">$strallentries
";
-
+ if ( $glossary->showalphabet ) {
+ $alphabet = explode("|", get_string("alphabet","glossary"));
+ $letters_by_line = 14;
+ for ($i = 0; $i < count($alphabet); $i++) {
+ echo "wwwroot/mod/glossary/view.php?id=$id&l=$alphabet[$i]\">$alphabet[$i]";
+ if ((int) ($i % $letters_by_line) != 0 or $i == 0) {
+ echo " | ";
+ } else {
+ echo "
";
+ }
+ }
+ }
+
+ if ( $glossary->showall ) {
+ echo "wwwroot/mod/glossary/view.php?id=$id&l=ALL\">$strallentries
";
+ }
+
if (isteacher($course->id) or $glossary->studentcanpost) {
$options = array ("id" => "$cm->id");
echo "";
@@ -151,7 +153,7 @@
if ( $CurrentLetter != $FirstLetter ) {
$CurrentLetter = $FirstLetter;
- if ( $glossary->displayformat == 2 ) {
+ if ( $glossary->displayformat == 0 ) {
if ( $DumpedDefinitions != 1) {
echo "";
}
@@ -159,7 +161,7 @@
}
echo $CurrentLetter;
- if ( $glossary->displayformat == 2 ) {
+ if ( $glossary->displayformat == 0 ) {
echo "\n";
if ( $DumpedDefinitions != 1) {
echo "\n
";
@@ -181,7 +183,7 @@
$definition = $entry->definition;
if ( $DumpedDefinitions == 1 ) {
- if ( $glossary->displayformat == 2 ) {
+ if ( $glossary->displayformat == 0 ) {
echo "\n";
}
}
@@ -191,7 +193,7 @@
}
glossary_print_entry($course, $cm, $glossary, $entry);
- if ( $glossary->displayformat != 2 ) {
+ if ( $glossary->displayformat != 0 ) {
echo "";
}
}
@@ -208,7 +210,7 @@
}
print_simple_box_end();
} else {
- if ( $glossary->displayformat == 2 ) {
+ if ( $glossary->displayformat == 0 ) {
echo "\n
";
}
}
@@ -216,4 +218,4 @@
/// Finish the page
print_footer($course);
-?>
\ No newline at end of file
+?>