Skip to content

Commit

Permalink
- Cosmetic changes... Changing the Add Entry button for a new tab
Browse files Browse the repository at this point in the history
- Creating two new tabs for the future export/import features.
- Improving a little the Printer-Friendly version (now it shows what you were watching in the previous frame)
  • Loading branch information
willcast committed Nov 3, 2003
1 parent fe98ea9 commit ea14e78
Show file tree
Hide file tree
Showing 9 changed files with 242 additions and 163 deletions.
6 changes: 4 additions & 2 deletions lang/en/glossary.php
Expand Up @@ -15,7 +15,7 @@
$string['ascending'] = "(ascending)";
$string['attachment'] = "Attachment";
$string['back'] = "Back";
$string['casesensitive'] = "This entry is<br>case sensitive";
$string['casesensitive'] = "This entry is case sensitive";
$string['categories'] = "Categories";
$string['categoryview'] = "Browse by category";
$string['category'] = "Category";
Expand Down Expand Up @@ -51,6 +51,7 @@
$string['displayformat4'] = "FAQ";
$string['displayformat5'] = "Full without author";
$string['editcategories'] = "Edit categories";
$string['editalias'] = "Edit alias";
$string['editentry'] = "Edit entry";
$string['editingcomment'] = "Editing comment";
$string['entries'] = "Entries";
Expand All @@ -60,11 +61,12 @@
$string['entryapproved'] = "This entry has been approved";
$string['entrydeleted'] = "Entry deleted";
$string['entryishidden'] = "(this entry is currently hidden)";
$string['entryusedynalink'] = "This entry should be<br>automatically linked";
$string['entryusedynalink'] = "This entry should be automatically linked";
$string['entryexported'] = "Entry succesfully exported";
$string['explainspecial'] = "Shows entries that do not begin with a letter";
$string['explainalphabet'] = "Browse the glossary using this index";
$string['explainall'] = "Shows ALL entries on one page";
$string['explainaddentry'] = "Add a new entry to the current glossary.<br>Concept and definition are mandatory fields.";
$string['exportedentry'] = "Exported entry";
$string['exportglossary'] = "Export glossary";
$string['exporttomainglossary'] = "Export to main glossary";
Expand Down
9 changes: 8 additions & 1 deletion mod/glossary/dynalink.php
Expand Up @@ -67,7 +67,14 @@ function glossary_dynamic_link($courseid, $text) {
"onClick=\"return openpopup('/mod/glossary/showentry.php?courseid=$courseid\&concept=$concept->concept', 'entry', 'menubar=0,location=0,scrollbars,resizable,width=600,height=450', 0);\">";
}

$currentconcept = trim(strip_tags($concept->concept));
$currentconcept = trim(strip_tags(str_replace("|", "\|", $concept->concept)));
if ( !$concept->category ) {
if ( $aliases = get_records("glossary_alias","entryid",$concept->id) ) {
foreach ($aliases as $alias) {
$currentconcept .= "|" . trim(strip_tags(str_replace("|", "\|", $alias->alias)));
}
}
}
$text = glossary_link_concepts($text,$currentconcept,$href_tag_begin, "</a>",$concept->casesensitive,$concept->fullmatch);
}
}
Expand Down
103 changes: 41 additions & 62 deletions mod/glossary/edit.html
Expand Up @@ -22,7 +22,10 @@
</tr>
<tr valign=top>
<td align=right><p><b><?php echo get_string("categories","glossary") ?>:</b></p></td>
<td>
<td>
<table border=0>
<tr>
<td>
<?php
$categories = get_records("glossary_categories","glossaryid",$glossary->id);
echo "<select size=\"6\" name=\"categories[]\" multiple=\"yes\">";
Expand All @@ -41,11 +44,10 @@
}
?>
</select>
</td>
</tr>
<tr valign=top>
<td align=right><p><b><?php echo get_string("entryusedynalink","glossary") ?>:</b></p></td>
<td>
<td width=100%>
<table border=0 width=100%>
<tr><td align=right width=80%><small><?php echo get_string("entryusedynalink","glossary") ?>:</small></td><td width=20%>
<script>
var items = ['casesensitive','fullmatch'];
</script>
Expand All @@ -59,61 +61,38 @@
$selected = "checked";
}
?>
<input type="checkbox" name="usedynalink" value=1 <?php p($selected) ?> onclick="return lockoptions('form','usedynalink', items)"> <?php helpbutton("usedynalink", get_string("usedynalink", "glossary"), "glossary") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p><b><?php echo get_string("casesensitive","glossary") ?>:</b></p></td>
<td>
<select size="1" name="casesensitive">
<option value=1 <?php
if ( isset($newentry->casesensitive) ) {
if ( $newentry->casesensitive ) {
echo "selected";
}
} elseif ( $CFG->cnfcasesensitive ) {
echo "selected";
}
?>
><?php echo get_string("yes") ?></option>
<option value=0 <?php
if ( isset($newentry->casesensitive) ) {
if ( !$newentry->casesensitive ) {
echo "selected";
}
} elseif ( !$CFG->cnfcasesensitive ) {
echo "selected";
}
?>><?php echo get_string("no") ?>
</option>
</select> <?php helpbutton("casesensitive", get_string("casesensitive", "glossary"), "glossary") ?>
<input type="checkbox" name="usedynalink" value=1 <?php p($selected) ?> onclick="return lockoptions('form','usedynalink', items)"> <?php helpbutton("usedynalink", strip_tags(get_string("usedynalink"), "glossary"), "glossary") ?>
</td></tr>
<tr><td align=right width=80%><small><?php echo get_string("casesensitive","glossary") ?>:</small></td><td width=20%>
<?php
$selected = "";
if ( isset($newentry->casesensitive) ) {
if ($newentry->casesensitive) {
$selected = "checked";
}
} elseif ( $CFG->cnfcasesensitive ) {
$selected = "checked";
}
?>
<input type="checkbox" name="casesensitive" value=1 <?php p($selected) ?>> <?php helpbutton("casesensitive", strip_tags(get_string("casesensitive", "glossary")), "glossary") ?>
</td></tr>
<tr><td align=right width=80%><small><?php echo get_string("fullmatch","glossary") ?>:</small></td><td width=20%>
<?php
$selected = "";
if ( isset($newentry->fullmatch) ) {
if ($newentry->fullmatch) {
$selected = "checked";
}
} elseif ( $CFG->cnffullmatch ) {
$selected = "checked";
}
?>
<input type="checkbox" name="fullmatch" value=1 <?php p($selected) ?>> <?php helpbutton("fullmatch", strip_tags(get_string("fullmatch", "glossary")), "glossary") ?>
</td></tr>
</table>
</td>
</tr>
<tr valign=top>
<td align=right><p><b><?php echo get_string("fullmatch","glossary") ?>:</b></p></td>
<td>
<select size="1" name="fullmatch">
<option value=1 <?php
if ( isset($newentry->fullmatch) ) {
if ( $newentry->fullmatch ) {
echo "selected";
}
} elseif ( $CFG->cnffullmatch ) {
echo "selected";
}
?>
><?php echo get_string("yes") ?></option>
<option value=0 <?php
if ( isset($newentry->fullmatch) ) {
if ( !$newentry->fullmatch ) {
echo "selected";
}
} elseif ( !$CFG->cnffullmatch ) {
echo "selected";
}
?>><?php echo get_string("no") ?>
</option>
</select> <?php helpbutton("fullmatch", get_string("fullmatch", "glossary"), "glossary") ?>
</tr>
</table>
</td>
</tr>
<tr valign=top>
Expand Down Expand Up @@ -160,9 +139,9 @@
</tr>
<tr>
<td colspan=2>
<p align=center>
<?php if (isset($newentry->id)) {
echo "<input type=\"hidden\" name=e value=\"$newentry->id\">";
<p align=center>
<?php if (isset($newentry->id)) {
echo "<input type=\"hidden\" name=e value=\"$newentry->id\">";
}
?>

Expand Down
17 changes: 16 additions & 1 deletion mod/glossary/edit.php
Expand Up @@ -188,11 +188,26 @@
<A HREF=\"view.php?id=$cm->id\">$glossary->name</A> -> $stredit", "form.text",
"", true, "", navmenu($course, $cm));

print_heading($glossary->name);
echo '<p align="center"><font size="3"><b>' . stripslashes_safe($glossary->name);
echo '</b></font></p>';

/// Info box

if ( $glossary->intro ) {
print_simple_box_start('center','70%');
echo format_text($glossary->intro);
print_simple_box_end();
}

/// Tabbed browsing sections
$tab = GLOSSARY_ADDENTRY_VIEW;
include("tabs.html");

include("edit.html");

echo '</center>';
glossary_print_tabbed_table_end();

print_footer($course);

?>
2 changes: 1 addition & 1 deletion mod/glossary/export.php
Expand Up @@ -5,7 +5,7 @@

require_variable($id); // Course Module ID

optional_variable($tab,GLOSSARY_APPROVAL_VIEW);
optional_variable($tab,GLOSSARY_STANDARD_VIEW);
optional_variable($l,"ALL");

if (! $cm = get_record("course_modules", "id", $id)) {
Expand Down
49 changes: 39 additions & 10 deletions mod/glossary/lib.php
Expand Up @@ -11,7 +11,10 @@
define("GLOSSARY_STANDARD_VIEW", 0);
define("GLOSSARY_CATEGORY_VIEW", 1);
define("GLOSSARY_DATE_VIEW", 2);
define("GLOSSARY_APPROVAL_VIEW", 3);
define("GLOSSARY_ADDENTRY_VIEW", 3);
define("GLOSSARY_IMPORT_VIEW", 4);
define("GLOSSARY_EXPORT_VIEW", 5);
define("GLOSSARY_APPROVAL_VIEW", 6);

define("GLOSSARY_FORMAT_SIMPLE", 0);
define("GLOSSARY_FORMAT_CONTINUOUS", 1);
Expand Down Expand Up @@ -93,6 +96,7 @@ function glossary_delete_instance($id) {
$ents = substr($ents,0,-1);
if ($ents) {
delete_records_select("glossary_comments", "entryid in ($ents)");
delete_records_select("glossary_alias", "entryid in ($ents)");
}
}
delete_records("glossary_entries", "glossaryid", "$glossary->id");
Expand Down Expand Up @@ -214,36 +218,45 @@ function glossary_log_info($log) {
AND u.id = '$log->userid'");
}

function glossary_get_entries($glossaryid, $entrylist) {
function glossary_get_entries($glossaryid, $entrylist, $pivot = "") {
global $CFG;
if ($pivot) {
$pivot .= ",";
}

return get_records_sql("SELECT id,userid,concept,definition,format
return get_records_sql("SELECT $pivot id,userid,concept,definition,format
FROM {$CFG->prefix}glossary_entries
WHERE glossaryid = '$glossaryid'
AND id IN ($entrylist)");
}
function glossary_get_entries_sorted($glossary, $where="", $orderby="") {
function glossary_get_entries_sorted($glossary, $where="", $orderby="", $pivot = "") {
global $CFG;
if ($where) {
$where = " and $where";
}
if ($orderby) {
$orderby = " ORDER BY $orderby";
}
return get_records_sql("SELECT *
if ($pivot) {
$pivot .= ",";
}
return get_records_sql("SELECT $pivot *
FROM {$CFG->prefix}glossary_entries
WHERE (glossaryid = $glossary->id or sourceglossaryid = $glossary->id) $where $orderby");
}

function glossary_get_entries_by_category($glossary, $cat, $where="", $orderby="") {
function glossary_get_entries_by_category($glossary, $cat, $where="", $orderby="", $pivot = "") {
global $CFG;
if ($where) {
$where = " and $where";
}
if ($orderby) {
$orderby = " ORDER BY $orderby";
}
return get_records_sql("SELECT ge.*
if ($pivot) {
$pivot .= ",";
}
return get_records_sql("SELECT $pivot ge.*
FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories c
WHERE (ge.id = c.entryid and c.categoryid = $cat) and
(ge.glossaryid = $glossary->id or ge.sourceglossaryid = $glossary->id) $where $orderby");
Expand Down Expand Up @@ -284,9 +297,20 @@ function glossary_print_entry($course, $cm, $glossary, $entry, $tab="",$cat="")
}
}
}
function glossary_print_entry_concept($entry) {
echo $entry->concept;
}
function glossary_print_entry_concept($entry, $alias = true) {
static $glossary; // to avoid unnecessary calls when dealing with the same glossary
static $cm;
echo $entry->concept;
/*
if ($alias) {
if ($glossary->id != $entry->glossaryid) {
$glossary = get_record("glossary","id",$entry->glossaryid);
$cm = get_coursemodule_from_instance("glossary", $glossary->id, $glossary->course);
}
echo " <a title=\"" . get_string("editalias","glossary") . "\" href=\"alias.php?id=$cm->id&eid=$entry->id\"><img border=0 src=alias.gif></a>";
}
*/
}

function glossary_print_entry_definition($entry) {
$definition = str_ireplace($entry->concept,"<nolink>$entry->concept</nolink>",$entry->definition);
Expand Down Expand Up @@ -397,6 +421,7 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab="",$cat
echo " <font size=-1>" . get_string("exportedentry","glossary") . "</font>";
}
}
echo "&nbsp;&nbsp;"; // just to make up a little the output in Mozilla ;)
}

function glossary_search_entries($searchterms, $glossary, $includedefinition) {
Expand Down Expand Up @@ -808,6 +833,10 @@ function glossary_print_approval_menu($cm, $glossary, $l, $sortkey, $sortorder =
glossary_print_sorting_links($cm, $sortkey,$sortorder, $tab);
}

function glossary_print_addentry_menu($cm, $glossary, $l, $sortkey, $sortorder = "", $tab=GLOSSARY_STANDARD_VIEW) {
echo '<center>' . get_string("explainaddentry","glossary") . '<p>';
}

function glossary_print_alphabet_menu($cm, $glossary, $l, $sortkey, $sortorder = "", $tab=GLOSSARY_STANDARD_VIEW) {
if ( $tab != GLOSSARY_DATE_VIEW ) {
if ($glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) {
Expand Down

0 comments on commit ea14e78

Please sign in to comment.