]> git.mjollnir.org Git - moodle.git/commitdiff
Basic fixing of tabs for glossary
authormoodler <moodler>
Thu, 1 Feb 2007 06:54:15 +0000 (06:54 +0000)
committermoodler <moodler>
Thu, 1 Feb 2007 06:54:15 +0000 (06:54 +0000)
mod/glossary/edit.php
mod/glossary/export.php
mod/glossary/import.php
mod/glossary/lib.php
mod/glossary/tabs.html [deleted file]
mod/glossary/tabs.php [new file with mode: 0644]
mod/glossary/view.php
theme/standard/styles_layout.css

index 28bfb4c5422450602cf9f919c661d0d05ddea79d..66054d158b3bb6c46b42d68e48a06b7622a9cd91 100644 (file)
@@ -204,7 +204,7 @@ echo '<br />';
 
 /// Tabbed browsing sections
 $tab = GLOSSARY_ADDENTRY_VIEW;
-include("tabs.html");
+include("tabs.php");
 
 if (!$e) {
     require_capability('mod/glossary:write', $context);
@@ -212,10 +212,9 @@ if (!$e) {
 
 $mform->display();
 
-echo '</center>'; //TODO remove center tag from here and tabs.html
 glossary_print_tabbed_table_end();
 
 
 print_footer($course);
 
-?>
\ No newline at end of file
+?>
index 4497f5d154043138d74612ffe3cca15f299178be..e27b601cf0de4d5123bdbb42140fa7c0cbef2142 100644 (file)
@@ -59,7 +59,7 @@
 
 /// Tabbed browsing sections
     $tab = GLOSSARY_EXPORT_VIEW;
-    include("tabs.html");
+    include("tabs.php");
 
     ?>
     <form action="exportfile.php" method="post">
@@ -73,7 +73,6 @@
     </form>
     <?php
 
-    echo '</center>';
     glossary_print_tabbed_table_end();
     print_footer();
 ?>
index cbedf0b4d3600cd55ae54794394e06a29eccebca..371e96037a5a626d4432b741dc4e7e9a8e617cd9 100644 (file)
@@ -60,7 +60,7 @@
 
 /// Tabbed browsing sections
     $tab = GLOSSARY_IMPORT_VIEW;
-    include("tabs.html");
+    include("tabs.php");
 
     if ( !$step ) {
         include("import.html");
index c1c699281eb0c3798d08ced05119e76a0a37caf5..1f3bb88093186eca6982709d79b10221305b8d0a 100644 (file)
@@ -1205,61 +1205,8 @@ function glossary_print_attachments($entry, $return=NULL, $align="left") {
     return $imagereturn;
 }
 
-function glossary_print_tabbed_table_start($data, $currenttab, $tabsperrow=4) {
-
-$tabs                 = count($data);
-$tabwidth             = (int) (100 / $tabsperrow);
-
-$currentrow           = ( $currenttab - ( $currenttab % $tabsperrow) ) / $tabsperrow;
-
-$numrows              = (int) ( $tabs / $tabsperrow ) + 1;
-
-
-/// Following lines are to create a tab object so that
-/// we can use the new tab objects and functions
-$tabrows = array();
-$tabnumber = 0;
-$row = array();
-$inactive = array();
-foreach ($data as $tab) {
-    $row[] = new tabobject($tabnumber, $tab->link, $tab->caption);
-    if (empty($tab->link)) {
-        $inactive[] = $tabnumber;
-    }
-    $tabnumber++;
-    if (($tabnumber % $tabsperrow) == 0) {
-        $tabrows[] = $row;
-        unset($row);
-        $row = array();
-    }
-}
-//Add the last row! if it contains anything!
-if (!empty($row)) {
-    $tabrows[] = $row;
-}
-
-
-?>
-  <table cellspacing="0" class="glossarydisplay">
-    <tr>
-      <td width="100%">
-
-<?php print_tabs($tabrows, $currenttab, $inactive);
-
-?>
-      </td>
-    </tr>
-    <tr>
-      <td width="100%" class="entryboxheader"><hr /></td>
-    </tr>
-    <tr>
-      <td width="100%" class="entrybox">
-          <center>
-<?php
-}
-
 function glossary_print_tabbed_table_end() {
-     echo "</td></tr></table></center>";
+     echo "</div></div>";
 }
 
 function glossary_print_approval_menu($cm, $glossary,$mode, $hook, $sortkey = '', $sortorder = '') {
diff --git a/mod/glossary/tabs.html b/mod/glossary/tabs.html
deleted file mode 100644 (file)
index e238316..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-<?php  // $Id$
-    if (!isset($sortorder)) {
-        $sortorder = '';
-    }    
-    if (!isset($sortkey)) {
-        $sortkey = '';
-    }
-    
-    //make sure variables are properly cleaned
-    $sortkey   = clean_param($sortkey, PARAM_ALPHA);// Sorted view: CREATION | UPDATE | FIRSTNAME | LASTNAME...
-    $sortorder = clean_param($sortorder, PARAM_ALPHA);   // it defines the order of the sorting (ASC or DESC)
-
-    echo '<center>';
-
-    $data[GLOSSARY_STANDARD_VIEW]->caption = get_string("standardview", "glossary");
-    $data[GLOSSARY_CATEGORY_VIEW]->caption = get_string("categoryview", "glossary");
-    $data[GLOSSARY_DATE_VIEW]->caption = get_string("dateview", "glossary");
-    $data[GLOSSARY_AUTHOR_VIEW]->caption = get_string("authorview","glossary");
-
-    if (has_capability('mod/glossary:write', $context)) {
-        $data[GLOSSARY_ADDENTRY_VIEW]->caption = get_string("addentry", "glossary");
-        $data[GLOSSARY_ADDENTRY_VIEW]->link = "edit.php?id=$cm->id";
-    }
-    if (has_capability('mod/glossary:import', $context)) {
-        $data[GLOSSARY_IMPORT_VIEW]->caption = get_string("importentries", "glossary");
-        $data[GLOSSARY_IMPORT_VIEW]->link = "import.php?id=$cm->id";
-    }
-        
-    if (has_capability('mod/glossary:export', $context)) {
-        $data[GLOSSARY_EXPORT_VIEW]->caption = get_string("exportentries", "glossary");     
-        $data[GLOSSARY_EXPORT_VIEW]->link = "export.php?id=$cm->id&amp;mode=$mode&amp;hook=$hook";
-    }
-
-//    $data[GLOSSARY_DATE_VIEW]->link = "view.php?id=$id&amp;tab=".GLOSSARY_DATE_VIEW;
-
-    $data[GLOSSARY_DATE_VIEW]->link = "view.php?id=$id&amp;mode=date";
-
-    $data[GLOSSARY_STANDARD_VIEW]->link = "view.php?id=$id&amp;mode=letter";
-    $data[GLOSSARY_CATEGORY_VIEW]->link = "view.php?id=$id&amp;mode=cat";
-    $data[GLOSSARY_AUTHOR_VIEW]->link = "view.php?id=$id&amp;mode=author";
-
-    if (has_capability('mod/glossary:approve', $context)) {
-        $data[GLOSSARY_APPROVAL_VIEW]->caption = get_string("waitingapproval", "glossary");
-        $data[GLOSSARY_APPROVAL_VIEW]->link = "";
-
-        $hiddenentries = get_records_select("glossary_entries","glossaryid  = $glossary->id and approved = 0");
-        if ($hiddenentries) {
-            $data[GLOSSARY_APPROVAL_VIEW]->caption .= " (" . count($hiddenentries) . " " . get_string("entries","glossary") . ")";
-            $data[GLOSSARY_APPROVAL_VIEW]->link = "view.php?id=$id&amp;mode=approval";
-
-        } elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) {  //Teachers going to approval view and without entries->go to defaulttab
-            $tab = $defaulttab;
-        }
-    } elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) { //Non-teachers going to approval view go to defaulttab
-        $tab = $defaulttab;
-    }
-
-/// printing header of the current tab
-    glossary_print_tabbed_table_start($data, $tab, 4);
-    if (!isset($category)) {
-        $category = "";
-    }
-
-    
-    switch ($tab) {
-        case GLOSSARY_CATEGORY_VIEW:
-            glossary_print_categories_menu($cm, $glossary, $hook, $category);
-        break;
-        case GLOSSARY_APPROVAL_VIEW:
-            glossary_print_approval_menu($cm, $glossary, $mode, $hook, $sortkey, $sortorder);
-        break;
-        case GLOSSARY_ADDENTRY_VIEW:
-            $search = "";
-            $l = "";
-            glossary_print_addentry_menu($cm, $glossary, $mode, $hook, $sortkey, $sortorder);
-        break;
-        case GLOSSARY_AUTHOR_VIEW:
-            $search = "";
-            glossary_print_author_menu($cm, $glossary, "author", $hook, $sortkey, $sortorder, 'print');
-        break;
-        case GLOSSARY_IMPORT_VIEW:
-            $search = "";
-            $l = "";
-            glossary_print_import_menu($cm, $glossary, 'import', $hook, $sortkey, $sortorder);
-        break;
-        case GLOSSARY_EXPORT_VIEW:
-            $search = "";
-            $l = "";
-            glossary_print_export_menu($cm, $glossary, 'export', $hook, $sortkey, $sortorder);
-        break;
-        case GLOSSARY_DATE_VIEW:
-            if (!$sortkey) {
-                $sortkey = 'UPDATE';
-            }
-            if (!$sortorder) {
-                $sortorder = 'desc';
-            }
-            glossary_print_alphabet_menu($cm, $glossary, "date", $hook, $sortkey, $sortorder);
-        break;
-        case GLOSSARY_STANDARD_VIEW:
-        default:
-            glossary_print_alphabet_menu($cm, $glossary, "letter", $hook, $sortkey, $sortorder);
-            if ($mode == 'search' and $hook) {
-                echo "<h3>$strsearch: $hook</h3>";
-            } 
-        break;
-    } 
-    echo '<hr />';
-?> 
diff --git a/mod/glossary/tabs.php b/mod/glossary/tabs.php
new file mode 100644 (file)
index 0000000..23fb047
--- /dev/null
@@ -0,0 +1,143 @@
+<?php  // $Id$
+    if (!isset($sortorder)) {
+        $sortorder = '';
+    }    
+    if (!isset($sortkey)) {
+        $sortkey = '';
+    }
+    
+    //make sure variables are properly cleaned
+    $sortkey   = clean_param($sortkey, PARAM_ALPHA);// Sorted view: CREATION | UPDATE | FIRSTNAME | LASTNAME...
+    $sortorder = clean_param($sortorder, PARAM_ALPHA);   // it defines the order of the sorting (ASC or DESC)
+
+    $toolsrow = array();
+    $browserow = array();
+    $inactive = array();
+    $activated = array();
+
+
+    if (has_capability('mod/glossary:write', $context)) {
+        $toolsrow[] = new tabobject(GLOSSARY_ADDENTRY_VIEW, 
+                                    $CFG->wwwroot.'/mod/glossary/edit.php?id='.$cm->id, 
+                                    get_string('addentry', 'glossary'));
+    }
+    if (has_capability('mod/glossary:import', $context)) {
+        $toolsrow[] = new tabobject(GLOSSARY_IMPORT_VIEW, 
+                                    $CFG->wwwroot.'/mod/glossary/import.php?id='.$cm->id, 
+                                    get_string('importentries', 'glossary'));
+    }
+    if (has_capability('mod/glossary:export', $context)) {
+        $toolsrow[] = new tabobject(GLOSSARY_EXPORT_VIEW, 
+                                    $CFG->wwwroot.'/mod/glossary/export.php?id='.$cm->id.
+                                    '&amp;mode='.$mode.'&amp;hook='.$hook, 
+                                    get_string('exportentries', 'glossary'));
+    }
+
+    if (has_capability('mod/glossary:approve', $context)) {
+        if ($hiddenentries = count_records_select('glossary_entries',"glossaryid  = $glossary->id and approved = 0")) {
+            $toolsrow[] = new tabobject(GLOSSARY_APPROVAL_VIEW, 
+                                        $CFG->wwwroot.'/mod/glossary/view.php?id='.$id.'&amp;mode=approval',
+                                        get_string("waitingapproval", "glossary"). ' ('.$hiddenentries.')');
+
+        } else if ($tab == GLOSSARY_APPROVAL_VIEW) {  
+         // Teachers going to approval view and without entries->go to defaulttab
+            $tab = $defaulttab;
+        }
+    } else if ($tab == GLOSSARY_APPROVAL_VIEW) { 
+     // Non-teachers going to approval view go to defaulttab
+        $tab = $defaulttab;
+    }
+
+
+    $browserow[] = new tabobject(GLOSSARY_STANDARD_VIEW, 
+                                 $CFG->wwwroot.'/mod/glossary/view.php?id='.$id.'&amp;mode=letter',
+                                 get_string('standardview', 'glossary'));
+
+    $browserow[] = new tabobject(GLOSSARY_CATEGORY_VIEW, 
+                                 $CFG->wwwroot.'/mod/glossary/view.php?id='.$id.'&amp;mode=cat', 
+                                 get_string('categoryview', 'glossary'));
+
+    $browserow[] = new tabobject(GLOSSARY_DATE_VIEW, 
+                                 $CFG->wwwroot.'/mod/glossary/view.php?id='.$id.'&amp;mode=date',
+                                 get_string('dateview', 'glossary'));
+
+    $browserow[] = new tabobject(GLOSSARY_AUTHOR_VIEW, 
+                                 $CFG->wwwroot.'/mod/glossary/view.php?id='.$id.'&amp;mode=author',
+                                 get_string('authorview', 'glossary'));
+
+    if ($tab < GLOSSARY_STANDARD_VIEW || $tab > GLOSSARY_AUTHOR_VIEW) {   // We are on second row
+        $inactive = array('edit');
+        $activated = array('edit');
+
+        $browserow[] = new tabobject('edit', '#', get_string('edit'));
+    }
+
+/// Put all this info together
+
+    $tabrows = array();
+    $tabrows[] = $browserow;     // Always put these at the top
+    if ($toolsrow) {
+        $tabrows[] = $toolsrow;
+    }
+
+
+?>
+  <div class="glossarydisplay">
+
+
+<?php print_tabs($tabrows, $tab, $inactive, $activated); ?>
+
+  <div width="100%" class="entrybox">
+
+<?php
+    if (!isset($category)) {
+        $category = "";
+    }
+
+    
+    switch ($tab) {
+        case GLOSSARY_CATEGORY_VIEW:
+            glossary_print_categories_menu($cm, $glossary, $hook, $category);
+        break;
+        case GLOSSARY_APPROVAL_VIEW:
+            glossary_print_approval_menu($cm, $glossary, $mode, $hook, $sortkey, $sortorder);
+        break;
+        case GLOSSARY_ADDENTRY_VIEW:
+            $search = "";
+            $l = "";
+            glossary_print_addentry_menu($cm, $glossary, $mode, $hook, $sortkey, $sortorder);
+        break;
+        case GLOSSARY_AUTHOR_VIEW:
+            $search = "";
+            glossary_print_author_menu($cm, $glossary, "author", $hook, $sortkey, $sortorder, 'print');
+        break;
+        case GLOSSARY_IMPORT_VIEW:
+            $search = "";
+            $l = "";
+            glossary_print_import_menu($cm, $glossary, 'import', $hook, $sortkey, $sortorder);
+        break;
+        case GLOSSARY_EXPORT_VIEW:
+            $search = "";
+            $l = "";
+            glossary_print_export_menu($cm, $glossary, 'export', $hook, $sortkey, $sortorder);
+        break;
+        case GLOSSARY_DATE_VIEW:
+            if (!$sortkey) {
+                $sortkey = 'UPDATE';
+            }
+            if (!$sortorder) {
+                $sortorder = 'desc';
+            }
+            glossary_print_alphabet_menu($cm, $glossary, "date", $hook, $sortkey, $sortorder);
+        break;
+        case GLOSSARY_STANDARD_VIEW:
+        default:
+            glossary_print_alphabet_menu($cm, $glossary, "letter", $hook, $sortkey, $sortorder);
+            if ($mode == 'search' and $hook) {
+                echo "<h3>$strsearch: $hook</h3>";
+            } 
+        break;
+    } 
+    echo '<hr />';
+?> 
index d5f27abe5fd8c52a1e0706047d47f1e2d4bccc73..01ace7c3d54afa43c548dc9b614e8aa68ab3ca1c 100644 (file)
     echo '</form>';
     echo '<br />';
 
-    include("tabs.html");
+    include("tabs.php");
 
     include_once("sql.php");
 
         echo '</div>';
     }
     echo '<br />';
-    echo '</center>';
     glossary_print_tabbed_table_end();
 
 /// Finish the page
index d352f302c95f3239477fe2b4f7845e64b99b8448..530636f796cc0832c49045c0347cf28489b8e121 100644 (file)
@@ -2646,7 +2646,10 @@ body#mod-forum-search .introcontent {
 }
 
 .glossarydisplay {
-  width: 70%;
+  width: 80%;
+  margin-left:auto;
+  margin-right:auto;
+  text-align:center;
 }
 
 .glossarydisplay .tabs {