Skip to content
Browse files

- 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
  • Loading branch information...
1 parent 0a855df commit 06d94a52284241d61892e5deeb2216010479c8e5 willcast committed Sep 18, 2003
View
30 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;
+}
?>
View
24 mod/glossary/db/mysql.sql
@@ -43,6 +43,27 @@ CREATE TABLE prefix_glossary_entries (
) 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');
View
86 mod/glossary/edit.html
@@ -1,52 +1,49 @@
+<?
+ global $CFG, $THEME;
+ require_once("../../config.php");
+?>
<FORM name="theform" method="post" <?=$onsubmit ?> action="edit.php" enctype="multipart/form-data">
-<table>
-<tr>
- <td align=right>
+<table class=generalbox cellpadding=5 bgcolor="<? p($THEME->cellheading)?>">
+<tr valign=top>
+ <td align=right><p><b><?php echo get_string("concept","glossary") ?>:</b></p></td>
+ <td>
+ <INPUT type="text" name="concept" size=30 value="<? p($form->concept) ?>">
+ </td>
+</tr>
+<tr valign=top>
+ <td align=right><p><b><? echo get_string("definition","glossary") ?>:</b></p>
<font size="1">
- <?PHP
+ <?php
helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
echo "<br />";
if ($usehtmleditor) {
helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
} else {
- emoticonhelpbutton("theform", "text");
+ emoticonhelpbutton("form", "description");
}
?>
- <br />
+ <br />
</font>
</td>
-</tr>
-
-<tr>
- <td align=center>
- <? echo get_string("concept","glossary") ?>: <INPUT type="text" name="concept" size=30 value="<? p($form->concept) ?>">
- </td>
-</tr>
-<tr>
- <td align=center><p>
- <? echo get_string("definition","glossary").":" ?>
+ <td>
+ <?php
+ print_textarea($usehtmleditor, 20, 60, 680, 400, "text", $entry->text);
+
+ echo "<p align=right>";
+ helpbutton("textformat", get_string("helpformatting"));
+ print_string("formattexttype");
+ echo ":&nbsp;";
+ if (!$form->format) {
+ $form->format = $defaultformat;
+ }
+ choose_from_menu(format_text_menu(), "format", $entry->format, "");
+ if ($entry->id) {
+ echo "<input type=\"hidden\" name=entry value=\"$entry->id\">";
+ }
+ echo "</p>";
+ ?>
</td>
</tr>
-
-</table>
-
-<? print_textarea($usehtmleditor, 20, 60, 630, 400, "text", $entry->text); ?>
-
-<p align=center>
-<?PHP
- print_string("formattexttype");
- echo ":&nbsp;";
- choose_from_menu(format_text_menu(), "format", $entry->format, "");
- echo "<font size=\"1\">";
- helpbutton("textformat", get_string("helpformatting"));
- echo "</font>";
- if ($entry->id) {
- echo "<input type=\"hidden\" name=entry value=\"$entry->id\">";
- }
-?>
-</p>
-
-<table border=0>
<tr valign=top>
<td align=right><p><b><?php print_string("attachment", "glossary") ?>:<br \>(<?php print_string("optional") ?>)&nbsp;</b></p></td>
<td>
@@ -57,15 +54,20 @@
print_string("maxsize", "", display_size(get_max_upload_file_size()));
?>
</td>
-
+</tr>
+<tr>
+<td colspan=2>
+ <p align=center>
+ <input type="hidden" name=id value="<?=$cm->id ?>">
+ <input type="submit" value="<? print_string("savechanges") ?>">
+ <input type="reset" value="<? print_string("revert") ?>">
+ </P>
+</td>
</tr>
</table>
+</p>
+
-<p align=center>
-<input type="hidden" name=id value="<?=$cm->id ?>">
-<input type="submit" value="<? print_string("savechanges") ?>">
-<input type="reset" value="<? print_string("revert") ?>">
-</P>
</form>
<?PHP
View
2 mod/glossary/formats/1.php
@@ -8,7 +8,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry) {
// } else {
// $colour = $THEME->cellheading;
// }
- echo "<table width=70% border=0><tr><td>";
+ echo "<table width=95% border=0><tr><td>";
echo "\n<TABLE BORDER=1 CELLSPACING=0 width=100% valign=top cellpadding=10>";
View
2 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 "<table width=70% border=0><tr><td>";
+ echo "<table width=95% border=0><tr><td>";
echo "\n<TABLE BORDER=1 CELLSPACING=0 valign=top cellpadding=10>";
View
106 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;
+
+?>
+ <center>
+ <table border="0" cellpadding="0" cellspacing="0" width="<? p($TableWidth) ?>">
+ <tr>
+ <td width="100%">
+
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
+
+<?
+$TabProccessed = 0;
+for ($row = 0; $row < $NumRows; $row++) {
+ echo "<tr>\n";
+ if ( $row != $CurrentRow ) {
+ for ($col = 0; $col < $TabsPerRow; $col++) {
+ if ( $TabProccessed < $Tabs ) {
+ if ($TabProccessed == $CurrentTab) {
+ $CurrentColor = $CurrentTabColor;
+ } else {
+ $CurrentColor = $TabColor;
+ }
+ ?>
+ <td width="<? p($TabWidth) ?>%" bgcolor="<? p($CurrentColor) ?>" align="center">
+ <b><a href="<? p($data[$TabProccessed]->link) ?>"><? p($data[$TabProccessed]->caption) ?></a></b></td>
+ <? if ($col < $TabsPerRow) { ?>
+ <td width="<? p($TabSeparation) ?>" align="center">&nbsp;</td>
+ <? }
+ } else {
+ $CurrentColor = "";
+ }
+ $TabProccessed++;
+ }
+ } else {
+ $FirstTabInCurrentRow = $TabProccessed;
+ $TabProccessed += $TabsPerRow;
+ }
+ echo "</tr><tr><td colspan=" . (2* $TabsPerRow) . " ></td></tr>\n";
+}
+ echo "<tr>\n";
+ $TabProccessed = $FirstTabInCurrentRow;
+ for ($col = 0; $col < $TabsPerRow; $col++) {
+ if ( $TabProccessed < $Tabs ) {
+ if ($TabProccessed == $CurrentTab) {
+ $CurrentColor = $CurrentTabColor;
+ } else {
+ $CurrentColor = $TabColor;
+ }
+ ?>
+ <td width="<? p($TabWidth) ?>%" bgcolor="<? p($CurrentColor) ?>" align="center">
+ <b><a href="<? p($data[$TabProccessed]->link) ?>"><? p($data[$TabProccessed]->caption) ?></a></b></td>
+ <? if ($col < $TabsPerRow) { ?>
+ <td width="<? p($TabSeparation) ?>" align="center">&nbsp;</td>
+ <? }
+ } else {
+ if ($NumRows > 1) {
+ $CurrentColor = $TabColor;
+ } else {
+ $CurrentColor = "";
+ }
+ echo "<td colspan = " . (2 * ($TabsPerRow - $col)) . " bgcolor=\"$CurrentColor\" align=\"center\">";
+ echo "</td>";
+
+ $col = $TabsPerRow;
+ }
+ $TabProccessed++;
+ }
+ echo "</tr>\n";
+ ?>
+
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td width="100%" bgcolor="<? p($TableColor) ?>"><hr></td>
+ </tr>
+ <tr>
+ <td width="100%" bgcolor="<? p($TableColor) ?>">
+ <center>
+<?
+}
+
+function print_tabbed_table_end() {
+ echo "</center><p></td></tr></table></center>";
+}
+
?>
View
4 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
?>

0 comments on commit 06d94a5

Please sign in to comment.
Something went wrong with that request. Please try again.