From 06d94a52284241d61892e5deeb2216010479c8e5 Mon Sep 17 00:00:00 2001 From: willcast Date: Thu, 18 Sep 2003 23:53:05 +0000 Subject: [PATCH] - Initial changes to categorize the entries.. - A new function in lib that perhaps could be used in other modules: print_tabbed_table_start and print_tabbed_table_end --- mod/glossary/db/mysql.php | 30 ++++++++++- mod/glossary/db/mysql.sql | 24 +++++++++ mod/glossary/edit.html | 86 +++++++++++++++--------------- mod/glossary/formats/1.php | 2 +- mod/glossary/formats/2.php | 2 +- mod/glossary/lib.php | 106 +++++++++++++++++++++++++++++++++++++ mod/glossary/version.php | 4 +- 7 files changed, 206 insertions(+), 48 deletions(-) diff --git a/mod/glossary/db/mysql.php b/mod/glossary/db/mysql.php index 599dcc1c05886..f80af4a5d39ce 100644 --- a/mod/glossary/db/mysql.php +++ b/mod/glossary/db/mysql.php @@ -35,10 +35,36 @@ function glossary_upgrade($oldversion) { " ADD `showall` TINYINT(2) UNSIGNED DEFAULT '1' NOT NULL AFTER `showalphabet` "); } - return true; -} + if ( $oldversion < 2003091800 ) { + + execute_sql("CREATE TABLE `{$CFG->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 '', + PRIMARY KEY (`id`) + ) TYPE=MyISAM COMMENT='all categories for glossary entries'"); + + execute_sql("CREATE TABLE `{$CFG->prefix}glossary_entries_categories` ( + `categoryid` INT(10) UNSIGNED NOT NULL default '1', + `entryid` INT(10) UNSIGNED NOT NULL default '0', + PRIMARY KEY (`categoryid`, `entryid`) + ) TYPE=MyISAM COMMENT='categories of each glossary entry'"); + + // creating a default category for every glossary + execute_sql("INSERT INTO `{$CFG->prefix}glossary_categories` (`glossaryid`, `name`) + SELECT `id`, '" . get_string("main","glossary") . "' FROM `{$CFG->prefix}glossary`"); + + // setting the default category for every entry. + execute_sql("INSERT INTO `{$CFG->prefix}glossary_entries_categories` (`categoryid`, `entryid`) + SELECT c.id, e.id + FROM `{$CFG->prefix}glossary_entries` e, `{$CFG->prefix}glossary_categories` c + WHERE e.glossaryid = c.glossaryid"); + } + + return true; +} ?> diff --git a/mod/glossary/db/mysql.sql b/mod/glossary/db/mysql.sql index 5a2da9a71eb6d..9c8cc9ea27370 100644 --- a/mod/glossary/db/mysql.sql +++ b/mod/glossary/db/mysql.sql @@ -42,6 +42,27 @@ CREATE TABLE prefix_glossary_entries ( PRIMARY KEY (id) ) TYPE=MyISAM COMMENT='all glossary entries'; +# +# Table structure for table `glossary_cageories` +# + +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 '', + PRIMARY KEY (id) +) TYPE=MyISAM COMMENT='all categories for glossary entries'; + +# +# Table structure for table `glossary_entries_category` +# + +CREATE TABLE prefix_glossary_entries_categories ( + categoryid int(10) unsigned NOT NULL default '1', + entryid int(10) unsigned NOT NULL default '0', + PRIMARY KEY (categoryid, entryid) +) TYPE=MyISAM COMMENT='categories of each glossary entry'; + # # Dumping data for table `log_display` # @@ -52,4 +73,7 @@ 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'); +INSERT INTO prefix_log_display VALUES ('glossary', 'add category', 'glossary', 'name'); +INSERT INTO prefix_log_display VALUES ('glossary', 'update category', 'glossary', 'name'); +INSERT INTO prefix_log_display VALUES ('glossary', 'delete category', 'glossary', 'name'); diff --git a/mod/glossary/edit.html b/mod/glossary/edit.html index 8a165d7df542b..34cb5af4f46af 100644 --- a/mod/glossary/edit.html +++ b/mod/glossary/edit.html @@ -1,52 +1,49 @@ +
action="edit.php" enctype="multipart/form-data"> - - -
+ + + + + + + - - - - - - - - -

:

+ +

:

- "; if ($usehtmleditor) { helpbutton("richtext", get_string("helprichtext"), "moodle", true, true); } else { - emoticonhelpbutton("theform", "text"); + emoticonhelpbutton("form", "description"); } ?> -
+
- : -

- +

+ text); + + echo "

"; + helpbutton("textformat", get_string("helpformatting")); + print_string("formattexttype"); + echo ": "; + if (!$form->format) { + $form->format = $defaultformat; + } + choose_from_menu(format_text_menu(), "format", $entry->format, ""); + if ($entry->id) { + echo "id\">"; + } + echo "

"; + ?>
- -text); ?> - -

-format, ""); - echo ""; - helpbutton("textformat", get_string("helpformatting")); - echo ""; - if ($entry->id) { - echo "id\">"; - } -?> -

- - - + + +

:
(

@@ -57,15 +54,20 @@ print_string("maxsize", "", display_size(get_max_upload_file_size())); ?>
+

+ + "> + "> +

+
+

+ -

- -"> -"> -

cellheading; // } - echo "
"; + echo "
"; echo "\n"; diff --git a/mod/glossary/formats/2.php b/mod/glossary/formats/2.php index 618b3459f1405..70dd0c2079efb 100644 --- a/mod/glossary/formats/2.php +++ b/mod/glossary/formats/2.php @@ -13,7 +13,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry) { $user = get_record("user", "id", $entry->userid); $strby = get_string("writtenby","glossary"); - echo "
"; + echo "
"; echo "\n"; diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 11caf8d06b014..e9d7f357be7ae 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -178,6 +178,7 @@ function glossary_print_entry($course, $cm, $glossary, $entry) { } else { $PermissionGranted = 1; } + if ( $glossary->displayformat > 0 and $PermissionGranted ) { glossary_print_entry_by_format($course, $cm, $glossary, $entry); } else { @@ -491,4 +492,109 @@ function glossary_print_attachments($entry, $return=NULL) { return $imagereturn; } +function print_tabbed_table_start($data, $CurrentTab, $tTHEME = NULL) { + +if ( !$tTHEME ) { + global $THEME; + $tTHEME = $THEME; +} + +$TableColor = $tTHEME->TabTableBGColor; +$TableWidth = $tTHEME->TabTableWidth; +$CurrentTabColor = $tTHEME->ActiveTabColor; +$TabColor = $tTHEME->InactiveTabColor; +$TabsPerRow = $tTHEME->TabsPerRow; +$TabSeparation = $tTHEME->TabSeparation; + +$Tabs = count($data); +$TabWidth = (int) (100 / $TabsPerRow); + +$CurrentRow = ( $CurrentTab - ( $CurrentTab % $TabsPerRow) ) / $TabsPerRow; + +$NumRows = (int) ( $Tabs / $TabsPerRow ) + 1; + +?> +
+
+ + + + + + + +
+ + + +\n"; + if ( $row != $CurrentRow ) { + for ($col = 0; $col < $TabsPerRow; $col++) { + if ( $TabProccessed < $Tabs ) { + if ($TabProccessed == $CurrentTab) { + $CurrentColor = $CurrentTabColor; + } else { + $CurrentColor = $TabColor; + } + ?> + + + + \n"; +} + echo "\n"; + $TabProccessed = $FirstTabInCurrentRow; + for ($col = 0; $col < $TabsPerRow; $col++) { + if ( $TabProccessed < $Tabs ) { + if ($TabProccessed == $CurrentTab) { + $CurrentColor = $CurrentTabColor; + } else { + $CurrentColor = $TabColor; + } + ?> + + + + 1) { + $CurrentColor = $TabColor; + } else { + $CurrentColor = ""; + } + echo ""; + + $col = $TabsPerRow; + } + $TabProccessed++; + } + echo "\n"; + ?> + +
+ caption) ?> 
+ caption) ?> "; + echo "
+

+
+

"; +} + ?> diff --git a/mod/glossary/version.php b/mod/glossary/version.php index 26836b06be517..73533470a4710 100644 --- a/mod/glossary/version.php +++ b/mod/glossary/version.php @@ -5,9 +5,9 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2003091600; // The current module version (Date: YYYYMMDDXX) +$module->version = 2003091800; // The current module version (Date: YYYYMMDDXX) $module->cron = 0; // Period for cron to check this module (secs) -$release = "0.3 development"; // User-friendly version number +$release = "0.3.1 development"; // User-friendly version number ?>