]> git.mjollnir.org Git - moodle.git/commitdiff
- Initial changes to categorize the entries..
authorwillcast <willcast>
Thu, 18 Sep 2003 23:53:05 +0000 (23:53 +0000)
committerwillcast <willcast>
Thu, 18 Sep 2003 23:53:05 +0000 (23:53 +0000)
- 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
mod/glossary/db/mysql.sql
mod/glossary/edit.html
mod/glossary/formats/1.php
mod/glossary/formats/2.php
mod/glossary/lib.php
mod/glossary/version.php

index 599dcc1c058865d0e8264b2283c1c5a8b923a1dd..f80af4a5d39ce714004d84fd1fe7b66c9fcec32d 100644 (file)
@@ -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;
+}
 
 ?>
 
index 5a2da9a71eb6d2116d6dc2452c62cc0439fd2f71..9c8cc9ea27370f293a41173b37b93fd99e3fe13e 100644 (file)
@@ -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');
 
index 8a165d7df542b5d50dee5aec26d93e33b442d248..34cb5af4f46af57525e0d1d1bfd1e6dd8b5195ab 100644 (file)
@@ -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>
        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 
index 8661d2f31595580f8765a4dc053a28c5037ea6c7..2dc657689bb64a4e3b4b807b3125a003cd907aff 100644 (file)
@@ -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>";
 
index 618b3459f1405130dfcb4c6394c299966601f751..70dd0c2079efb6f4077ee19dd0f0bf8e323be69b 100644 (file)
@@ -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>";
 
index 11caf8d06b014a4836abeb7224d4791e054d9fc6..e9d7f357be7aef0e52431145ff0cc64bd87912ce 100644 (file)
@@ -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>";
+}
+
 ?>
index 26836b06be5178418b1a1341534bcaec561518f9..73533470a47100d6577e4e593d0fe79d822c2690 100644 (file)
@@ -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
 
 ?>