$string['back'] = "Back";
$string['casesensitive'] = "This entry is case sensitive";
$string['categories'] = "Categories";
+$string['importedcategories'] = "Imported categories";
+$string['cantinsertcat'] = "Can't insert category'";
+$string['cantinsertrec'] = "Can't insert record'";
+$string['cantinsertrel'] = "Can't insert relation category-entry'";
$string['categoryview'] = "Browse by category";
$string['category'] = "Category";
$string['categorydeleted'] = "Category deleted";
$string['cnffullmatch'] = "Define if an entry, when linked, should match the case in the target text by default";
$string['concept'] = "Concept";
$string['concepts'] = "Concepts";
+$string['currentglossary'] = "Current glosssary";
$string['dateview'] = "Browse by date";
$string['deletingcomment'] = "Deleting comment";
$string['defaultapproval'] = "Default approval status";
$string['deleteentry'] = "Delete entry";
$string['deletingnoneemptycategory'] = "Deleting this category will not delete the entries it contains - they will be marked as uncategorised.";
$string['descending'] = "(descending)";
+$string['destination'] = "Destination";
$string['displayformat'] = "Display format";
$string['displayformatdefault'] = "Simple, dictionary style";
$string['displayformatcontinuous'] = "Continuous without author";
$string['displayformat3'] = "Encyclopedia";
$string['displayformat4'] = "FAQ";
$string['displayformat5'] = "Full without author";
+$string['duplicateentry'] = "Duplicate entry";
$string['editcategories'] = "Edit categories";
$string['editalias'] = "Edit alias";
$string['editentry'] = "Edit entry";
$string['editingcomment'] = "Editing comment";
$string['entries'] = "Entries";
+$string['importedentries'] = "Imported entries";
$string['entrieswithoutcategory'] = "Entries without category";
$string['entry'] = "Entry";
$string['entryalreadyexist'] = "Entry already exists";
$string['entryishidden'] = "(this entry is currently hidden)";
$string['entryusedynalink'] = "This entry should be automatically linked";
$string['entryexported'] = "Entry succesfully exported";
+$string['rejectionrpt'] = "Rejection Report";
$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['explainimport'] = "You must specify the file to import and define the criteria of the process.<p>Submit your request and review the results.";
+$string['explainexport'] = "A file has been generated.<br>Download it and keep it safe. You can import it anytime you wish in this or other course.";
$string['exportedentry'] = "Exported entry";
+$string['exportedfile'] = "Exported file";
$string['exportglossary'] = "Export glossary";
$string['exporttomainglossary'] = "Export to main glossary";
+$string['filetoimport'] = "File to import";
$string['fillfields'] = "Concept and definition are mandatory fields.";
$string['fullmatch'] = "Match whole words only<br><small>(when automatically linked)</small>";
$string['glossarytype'] = "Glossary Type";
$string['glosssaryexported'] = "Glossary exported.";
+$string['importcategories'] = "Import categories";
$string['isglobal'] = "Is this glossary global?";
$string['mainglossary'] = "Main glossary";
$string['modulename'] = "Glossary";
$string['modulenameplural'] = "Glossaries";
$string['maxtimehaspassed'] = "Sorry, but the maximum time for editing this comment (\$a) has passed!";
+$string['newglossary'] = "New glossary";
$string['newglossaryentries'] = "New glossary entries:";
+$string['newglossarycreated'] = "New glossary created.";
$string['notcategorised'] = "Not categorised";
$string['nocomment'] = "No comment found";
+$string['noconceptfound'] = "No concept or definition found.";
$string['nocomments'] = "(No comments found on this entry)";
$string['noentries'] = "No entries found in this section";
$string['noentry'] = "No entry found.";
$string['printerfriendly'] = "Printer-friendly version";
$string['question'] = "Question";
+$string['rejectedentries'] = "Rejected entries";
$string['searchindefinition'] = "Search full text";
$string['secondaryglossary'] = "Secondary glossary";
$string['showspecial'] = "Show 'Special' link";
$string['sortbylastupdate'] = "By last update";
$string['standardview'] = "Browse by alphabet";
$string['studentcanpost'] = "Students can add entries";
+$string['totalentries'] = "Total entries";
$string['usedynalink'] = "Automatically link glossary entries";
$string['warningstudentcapost'] = "(Applies only if the glossary is not the main one)";
$string['waitingapproval'] = "Waiting approval";
require_once("../../config.php");
require_once("lib.php");
+ global $CFG, $USER;
require_variable($id); // Course Module ID
- optional_variable($tab,GLOSSARY_STANDARD_VIEW);
optional_variable($l,"ALL");
+ optional_variable($cat,0);
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
error("You must be a teacher to use this page.");
}
- glossary_generate_export_file($glossary);
- redirect("view.php?id=$cm->id&tab=$tab&l=$l",get_string("glosssaryexported","glossary"),1);
- die;
+ $strglossaries = get_string("modulenameplural", "glossary");
+ $strglossary = get_string("modulename", "glossary");
+ $strallcategories = get_string("allcategories", "glossary");
+ $straddentry = get_string("addentry", "glossary");
+ $strnoentries = get_string("noentries", "glossary");
+ $strsearchconcept = get_string("searchconcept", "glossary");
+ $strsearchindefinition = get_string("searchindefinition", "glossary");
+ $strsearch = get_string("search");
+
+ print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname",
+ "$navigation <A HREF=index.php?id=$course->id>$strglossaries</A> -> $glossary->name",
+ "", "", true, update_module_button($cm->id, $course->id, $strglossary),
+ navmenu($course, $cm));
+
+ 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_EXPORT_VIEW;
+ include("tabs.html");
+
+ glossary_generate_export_file($glossary,$l,$cat);
+ print_string("glosssaryexported","glossary");
+
+ if ($CFG->slasharguments) {
+ $ffurl = "../../file.php/$course->id/glossary/" . clean_filename($glossary->name) ."/glossary.xml";
+ } else {
+ $ffurl = "../../file.php?file=/$course->id/glossary/" . clean_filename($glossary->name) ."/glossary.xml";
+ }
+ echo '<p><center><a href="' . $ffurl . '" target=_blank>' . get_string("exportedfile","glossary") . '</a></center><p>'
?>
\ No newline at end of file
--- /dev/null
+<form method="POST" action="import.php" name="form" enctype="multipart/form-data">
+<table border="0" cellpadding="3" cellspacing="3" width="100%">
+<tr>
+ <td align=right valign=top width="30%"><p><b><?php print_string("filetoimport","glossary") ?>:</b></p></td>
+ <td width="70%">
+ <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo get_max_upload_file_size() ?>">
+ <input type="file" name="file" size=40> <br \>
+ <?php
+ helpbutton("filetoimport", get_string("filetoimport", "glossary"), "glossary");
+ print_string("maxsize", "", display_size(get_max_upload_file_size()));
+ ?>
+ </td>
+</tr>
+<tr valign=top>
+ <td align=right colspan="2">
+ <table border="0" cellpadding="0" cellspacing="3" width="100%">
+ <tr>
+ <td width="25%">
+ <p align="right"><?PHP p(get_string("destination","glossary")) ?>:</td>
+ <td width="25%"><select size="1" name="dest">
+ <option selected value="current"><?PHP p(get_string("currentglossary","glossary")) ?></option>
+<?PHP
+// <option value="new">
+//< PHP p(get_string("newglossary","glossary")) ? >
+// </option>
+?>
+ </select> <?PHP helpbutton("destination", get_string("destination", "glossary"), "glossary") ?></td>
+ <td width="25%">
+ <p align="right"><?PHP p(get_string("importcategories","glossary")) ?>:</td>
+ <td width="25%"><input type="checkbox" name="catsincl" value="1"> <?PHP helpbutton("importcategories", get_string("importcategories", "glossary"), "glossary") ?></td>
+ </tr>
+ </table>
+ </td>
+</tr>
+<tr>
+ <td align=right colspan="2">
+ <table border="0" cellpadding="3" cellspacing="3" width="100%">
+ <tr>
+ <td width="50%">
+ <p align="right"><input type="submit" value="<?php print_string("savechanges") ?>"></td>
+ <td width="50%"><input type="reset" value="<?php print_string("revert") ?>"></td>
+ </tr>
+ </table>
+ </td>
+</tr>
+</table>
+<input type="hidden" name="id" value="<?PHP p($id) ?>">
+<input type="hidden" name="l" value="<?PHP p($l) ?>">
+<input type="hidden" name="lasttab" value="<?PHP p($lasttab) ?>">
+<input type="hidden" name="step" value="1">
+</form>
\ No newline at end of file
--- /dev/null
+<?php
+
+ require_once("../../config.php");
+ require_once("lib.php");
+ global $CFG, $USER;
+
+ require_variable($id); // Course Module ID
+
+ optional_variable($step,0);
+ optional_variable($dest,"current"); // current | new
+ optional_variable($file); // file to import
+ optional_variable($catsincl,0); // Import Categories too?
+
+ optional_variable($lasttab,GLOSSARY_STANDARD_VIEW);
+ optional_variable($l,"ALL");
+
+ if (! $cm = get_record("course_modules", "id", $id)) {
+ error("Course Module ID was incorrect");
+ }
+
+ if (! $course = get_record("course", "id", $cm->course)) {
+ error("Course is misconfigured");
+ }
+
+ if (! $glossary = get_record("glossary", "id", $cm->instance)) {
+ error("Course module is incorrect");
+ }
+
+ require_login($course->id);
+ if (!isteacher($course->id)) {
+ error("You must be a teacher to use this page.");
+ }
+
+ if ($course->category) {
+ $navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
+ }
+
+ if ($dest != 'new' and $dest != 'current') {
+ $dest = 'current';
+ }
+ $strglossaries = get_string("modulenameplural", "glossary");
+ $strglossary = get_string("modulename", "glossary");
+ $strallcategories = get_string("allcategories", "glossary");
+ $straddentry = get_string("addentry", "glossary");
+ $strnoentries = get_string("noentries", "glossary");
+ $strsearchconcept = get_string("searchconcept", "glossary");
+ $strsearchindefinition = get_string("searchindefinition", "glossary");
+ $strsearch = get_string("search");
+
+ print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname",
+ "$navigation <A HREF=index.php?id=$course->id>$strglossaries</A> -> $glossary->name",
+ "", "", true, update_module_button($cm->id, $course->id, $strglossary),
+ navmenu($course, $cm));
+
+ 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_IMPORT_VIEW;
+ include("tabs.html");
+
+ if ( !$step ) {
+ include("import.html");
+
+ glossary_print_tabbed_table_end();
+ print_footer($course);
+ exit;
+ }
+
+ $form = data_submitted();
+ $file = $_FILES["file"];
+// if ($xml = glossary_read_imported_file("C:\\download\\moodle\\moodle\\cursos\\10\\glossary\\Testing_Glossary\\glossary.xml") ) {
+ if ($xml = glossary_read_imported_file($file['tmp_name']) ) {
+
+ $importedentries = 0;
+ $importedcats = 0;
+ $entriesrejected = 0;
+ $rejections = '';
+ if ($dest == 'new') {
+ // If the user chose to create a new glossary
+ $xmlglossary = $xml['GLOSSARY']['#']['INFO'][0]['#'];
+
+ if ( $xmlglossary['NAME'][0]['#'] ) {
+ unset($glossary);
+ $glossary->name = $xmlglossary['NAME'][0]['#'];
+ $glossary->course = $course->id;
+ $glossary->globalglossary = $xmlglossary['GLOBALGLOSSARY'][0]['#'];
+ $glossary->intro = $xmlglossary['INTRO'][0]['#'];
+ $glossary->showspecial = $xmlglossary['SHOWSPECIAL'][0]['#'];
+ $glossary->showalphabet = $xmlglossary['SHOWALPHABET'][0]['#'];
+ $glossary->showall = $xmlglossary['SHOWALL'][0]['#'];
+ $glossary->timecreated = time();
+ $glossary->timemodified = time();
+
+ // Setting the default values if no values were passed
+ if ( isset($xmlglossary['STUDENTCANPOST'][0]['#']) ) {
+ $glossary->studentcanpost = $xmlglossary['STUDENTCANPOST'][0]['#'];
+ } else {
+ $glossary->studentcanpost = $CFG->cnfstudentcanpost;
+ }
+ if ( isset($xmlglossary['ALLOWDUPLICATEDENTRIES'][0]['#']) ) {
+ $glossary->allowduplicatedentries = $xmlglossary['ALLOWDUPLICATEDENTRIES'][0]['#'];
+ } else {
+ $glossary->allowduplicatedentries = $CFG->cnfallowdupentries;
+ }
+ if ( isset($xmlglossary['ALLOWCOMMENTS'][0]['#']) ) {
+ $glossary->allowcomments = $xmlglossary['ALLOWCOMMENTS'][0]['#'];
+ } else {
+ $glossary->allowcomments = $CFG->cnfallowcomments;
+ }
+ if ( isset($xmlglossary['USEDYNALINK'][0]['#']) ) {
+ $glossary->usedynalink = $xmlglossary['USEDYNALINK'][0]['#'];
+ } else {
+ $glossary->usedynalink = $CFG->cnflinkglossaries;
+ }
+ if ( isset($xmlglossary['DEFAULTAPPROVAL'][0]['#']) ) {
+ $glossary->defaultapproval = $xmlglossary['DEFAULTAPPROVAL'][0]['#'];
+ } else {
+ $glossary->defaultapproval = $CFG->cnfapprovalstatus;
+ }
+
+ // Include new glossary and return the new ID
+ if ( !$glossary->id = glossary_add_instance($glossary) ) {
+ notify("Error while trying to create the new glossary.");
+ glossary_print_tabbed_table_end();
+ print_footer($course);
+ exit;
+ } else {
+ print_simple_box(get_string("newglossarycreated","glossary"),"center","70%");
+ echo '<p>';
+ }
+ } else {
+ notify("Error while trying to create the new glossary.");
+ glossary_print_tabbed_table_end();
+ print_footer($course);
+ exit;
+ }
+ }
+
+ $xmlentries = $xml['GLOSSARY']['#']['INFO'][0]['#']['ENTRIES'][0]['#']['ENTRY'];
+ for($i = 0; $i < sizeof($xmlentries); $i++) {
+ // Inserting the entries
+ $xmlentry = $xmlentries[$i];
+
+ unset($newentry);
+ $newentry->concept = $xmlentry['#']['CONCEPT'][0]['#'];
+ $newentry->definition = $xmlentry['#']['DEFINITION'][0]['#'];
+
+ $permissiongranted = 1;
+ if ( $newentry->concept and $newentry->definition ) {
+ if ( !$glossary->allowduplicatedentries ) {
+ // checking if the entry is valid (checking if it is duplicated when should not be)
+ if ( $glossary->casesensitive ) {
+ $dupentry = get_record("glossary_entries","concept",$newentry->concept,"glossaryid",$glossary->id);
+ } else {
+ $dupentry = get_record("glossary_entries","ucase(concept)",strtoupper($newentry->concept),"glossaryid",$glossary->id);
+ }
+ if ($dupentry) {
+ $permissiongranted = 0;
+ }
+ }
+ } else {
+ $permissiongranted = 0;
+ }
+ if ($permissiongranted) {
+ $newentry->glossaryid = $glossary->id;
+ $newentry->sourceglossaryid = 0;
+ $newentry->approved = 1;
+ $newentry->userid = $USER->id;
+ $newentry->format = $xmlentry['#']['FORMAT'][0]['#'];
+ $newentry->timecreated = time();
+ $newentry->timemodified = time();
+ $newentry->teacherentry = $xmlentry['#']['TEACHERENTRY'][0]['#'];
+
+ // Setting the default values if no values were passed
+ if ( isset($xmlentry['#']['USEDYNALINK'][0]['#']) ) {
+ $newentry->usedynalink = $xmlentry['#']['USEDYNALINK'][0]['#'];
+ } else {
+ $newentry->usedynalink = $CFG->cnfusedynalink;
+ }
+ if ( isset($xmlentry['#']['CASESENSITIVE'][0]['#']) ) {
+ $newentry->casesensitive = $xmlentry['#']['CASESENSITIVE'][0]['#'];
+ } else {
+ $newentry->casesensitive = $CFG->cnfcasesensitive;
+ }
+ if ( isset($xmlentry['#']['FULLMATCH'][0]['#']) ) {
+ $newentry->fullmatch = $xmlentry['#']['FULLMATCH'][0]['#'];
+ } else {
+ $newentry->fullmatch = $CFG->cnffullmatch;
+ }
+
+ if ( $newentry->id = insert_record("glossary_entries",$newentry) ) {
+ $importedentries++;
+ if ( $catsincl ) {
+ // If the categories must be imported...
+ $xmlcats = $xmlentry['#']['CATEGORIES'][0]['#']['CATEGORY'];
+ for($k = 0; $k < sizeof($xmlcats); $k++) {
+ $xmlcat = $xmlcats[$k];
+ unset($newcat);
+
+ $newcat->name = $xmlcat['#']['NAME'][0]['#'];
+ if ( !$category = get_record("glossary_categories","glossaryid",$glossary->id,"name",$newcat->name) ) {
+ // Create the category if it does not exist
+ unset($category);
+ $category->name = $newcat->name;
+ $category->glossaryid = $glossary->id;
+ if ( !$category->id = insert_record("glossary_categories",$category)) {
+ // add to exception report (can't insert category)
+ $rejections .= "<tr><td> <strong>" . get_string("category","glossary") . ":</strong>$newcat->name</td>" .
+ "<td>" . get_string("cantinsertcat","glossary"). "</td></tr>";
+ } else {
+ $importedcats++;
+ }
+ }
+ if ( $category ) {
+ // inserting the new relation
+ unset($entrycat);
+ $entrycat->entryid = $newentry->id;
+ $entrycat->categoryid = $category->id;
+ if ( !insert_record("glossary_entries_categories",$entrycat) ) {
+ // add to exception report (can't insert relation)
+ $rejections .= "<tr><td> <strong>" . get_string("category","glossary") . ":</strong>$newcat->name</td>" .
+ "<td>" . get_string("cantinsertrel","glossary"). "</td></tr>";
+ }
+ }
+ }
+ }
+ } else {
+ $entriesrejected++;
+ // add to exception report (can't insert new record)
+ $rejections .= "<tr><td>$newentry->concept</td>" .
+ "<td>" . get_string("cantinsertrec","glossary"). "</td></tr>";
+ }
+ } else {
+ $entriesrejected++;
+ if ( $newentry->concept and $newentry->definition ) {
+ // add to exception report (duplicated entry))
+ $rejections .= "<tr><td>$newentry->concept</td>" .
+ "<td>" . get_string("duplicateentry","glossary"). "</td></tr>";
+ } else {
+ // add to exception report (no concept or definition found))
+ $rejections .= "<tr><td>---</td>" .
+ "<td>" . get_string("noconceptfound","glossary"). "</td></tr>";
+ }
+ }
+ }
+ // processed entries
+ echo '<table border=0 width=100%>';
+ echo '<tr>';
+ echo '<td width=50% align=right>';
+ echo get_string("totalentries","glossary");
+ echo ':</td>';
+ echo '<td width=50%>';
+ echo $importedentries + $entriesrejected;
+ echo '</td>';
+ echo '</tr>';
+ echo '<tr>';
+ echo '<td width=50% align=right>';
+ echo get_string("importedentries","glossary");
+ echo ':</td>';
+ echo '<td width=50%>';
+ echo $importedentries;
+ if ( $entriesrejected ) {
+ echo ' <small>(' . get_string("rejectedentries","glossary") . ": $entriesrejected)</small>";
+ }
+ echo '</td>';
+ echo '</tr>';
+ if ( $catsincl ) {
+ echo '<tr>';
+ echo '<td width=50% align=right>';
+ echo get_string("importedcategories","glossary");
+ echo ':</td>';
+ echo '<td width=50%>';
+ echo $importedcats;
+ echo '</td>';
+ echo '</tr>';
+ }
+ echo '</table><hr width=75%>';
+
+ // rejected entries
+ if ($rejections) {
+ echo '<center><table border=0 width=70%>';
+ echo '<tr><td align=center colspan=2 width=100%><strong>' . get_string("rejectionrpt","glossary") . '</strong></tr>';
+ echo $rejections;
+ echo '</table></center><p><hr width=75%>';
+ }
+ } else {
+ notify("Error while trying to read the file.");
+ }
+
+ glossary_print_tabbed_table_end();
+
+/// Finish the page
+ print_footer($course);
+
+?>
\ No newline at end of file
echo '<center>' . get_string("explainaddentry","glossary") . '<p>';
}
+function glossary_print_import_menu($cm, $glossary, $l, $sortkey, $sortorder = "", $tab=GLOSSARY_STANDARD_VIEW) {
+ echo '<center>' . get_string("explainimport","glossary") . '<p>';
+}
+
+function glossary_print_export_menu($cm, $glossary, $l, $sortkey, $sortorder = "", $tab=GLOSSARY_STANDARD_VIEW) {
+ echo '<center>' . get_string("explainexport","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) {
echo "</tr></table></center>";
}
-function glossary_generate_export_file($glossary) {
+function glossary_generate_export_file($glossary,$l, $cat) {
global $CFG;
glossary_check_moddata_dir($glossary);
$h = glossary_open_xml($glossary);
fwrite ($h,glossary_full_tag("USEDYNALINK",2,false,$glossary->usedynalink));
fwrite ($h,glossary_full_tag("DEFAULTAPPROVAL",2,false,$glossary->defaultapproval));
fwrite ($h,glossary_full_tag("GLOBALGLOSSARY",2,false,$glossary->globalglossary));
- $status =fwrite ($h,glossary_end_tag("INFO",1,true));
- if ( $entries = get_records("glossary_entries","glossaryid",$glossary->id) ) {
- $status = fwrite ($h,glossary_start_tag("ENTRIES",1,true));
- foreach ($entries as $entry) {
- if ( $entry->approved ) {
- $status = fwrite($h,glossary_start_tag("ENTRY",2,true));
- fwrite($h,glossary_full_tag("ID",3,false,$entry->id));
- fwrite($h,glossary_full_tag("CONCEPT",3,false,$entry->concept));
- fwrite($h,glossary_full_tag("DEFINITION",3,false,$entry->definition));
- fwrite($h,glossary_full_tag("FORMAT",3,false,$entry->format));
- fwrite($h,glossary_full_tag("ATTACHMENT",3,false,$entry->attachment));
- fwrite($h,glossary_full_tag("USEDYNALINK",3,false,$entry->usedynalink));
- fwrite($h,glossary_full_tag("CASESENSITIVE",3,false,$entry->casesensitive));
- fwrite($h,glossary_full_tag("FULLMATCH",3,false,$entry->fullmatch));
- $status =fwrite($h,glossary_end_tag("ENTRY",2,true));
- }
- }
- $status =fwrite ($h,glossary_end_tag("ENTRIES",1,true));
- }
+ if ( $entries = get_records("glossary_entries","glossaryid",$glossary->id) ) {
+ $status = fwrite ($h,glossary_start_tag("ENTRIES",2,true));
+ foreach ($entries as $entry) {
+ if ( $entry->approved ) {
+ $status = fwrite($h,glossary_start_tag("ENTRY",3,true));
+ fwrite($h,glossary_full_tag("CONCEPT",4,false,$entry->concept));
+ fwrite($h,glossary_full_tag("DEFINITION",4,false,$entry->definition));
+ fwrite($h,glossary_full_tag("FORMAT",4,false,$entry->format));
+ fwrite($h,glossary_full_tag("USEDYNALINK",4,false,$entry->usedynalink));
+ fwrite($h,glossary_full_tag("CASESENSITIVE",4,false,$entry->casesensitive));
+ fwrite($h,glossary_full_tag("FULLMATCH",4,false,$entry->fullmatch));
+ fwrite($h,glossary_full_tag("TEACHERENTRY",4,false,$entry->teacherentry));
+
+ if ( $catentries = get_records("glossary_entries_categories","entryid",$entry->id) ) {
+ $status = fwrite ($h,glossary_start_tag("CATEGORIES",4,true));
+ foreach ($catentries as $catentry) {
+ $category = get_record("glossary_categories","id",$catentry->categoryid);
+
+ $status = fwrite ($h,glossary_start_tag("CATEGORY",5,true));
+ fwrite($h,glossary_full_tag("NAME",6,false,$category->name));
+ $status = fwrite($h,glossary_end_tag("CATEGORY",5,true));
+ }
+ $status = fwrite($h,glossary_end_tag("CATEGORIES",4,true));
+ }
- if ( $categories = get_records("glossary_categories","glossaryid",$glossary->id) ) {
- $status = fwrite ($h,glossary_start_tag("CATEGORIES",1,true));
- foreach ($categories as $category) {
- $status = fwrite ($h,glossary_start_tag("CATEGORY",2,true));
- fwrite($h,glossary_full_tag("NAME",3,false,$category->name));
- if ( $catentries = get_records("glossary_entries_categories","categoryid",$category->id) ) {
- $count = 0;
- foreach ($catentries as $catentry) {
- fwrite($h,glossary_full_tag("ENTRYID$count",3,false,$catentry->entryid));
- $count++;
+ $status =fwrite($h,glossary_end_tag("ENTRY",3,true));
}
}
- $status = fwrite($h,glossary_end_tag("CATEGORY",2,true));
+ $status =fwrite ($h,glossary_end_tag("ENTRIES",2,true));
+
}
- $status = fwrite($h,glossary_end_tag("CATEGORIES",1,true));
- }
+
+
+ $status =fwrite ($h,glossary_end_tag("INFO",1,true));
+
$h = glossary_close_xml($h);
}
// Functions designed by Eloy Lafuente
}
}
+function glossary_read_imported_file($file) {
+require_once "../../lib/xmlize.php";
+ $h = fopen($file,"r");
+ $line = '';
+ if ($h) {
+ while ( !feof($h) ) {
+ $char = fread($h,1024);
+ $line .= $char;
+ }
+ fclose($h);
+ }
+ return xmlize($line);
+}
//Close the file
function glossary_close_xml($h) {
$status = fwrite ($h,glossary_end_tag("GLOSSARY",0,true));
$data[GLOSSARY_IMPORT_VIEW]->caption = "Import Entries";
$data[GLOSSARY_EXPORT_VIEW]->caption = "Export Entries";
-// $data[GLOSSARY_IMPORT_VIEW]->link = "import.php?id=$cm->id&tab=$tab";
-// $data[GLOSSARY_EXPORT_VIEW]->link = "export.php?id=$cm->id&tab=$tab";
+ $data[GLOSSARY_IMPORT_VIEW]->link = "import.php?id=$cm->id";
+ $data[GLOSSARY_EXPORT_VIEW]->link = "export.php?id=$cm->id&l=$l&cat=$cat&tab=".GLOSSARY_CATEGORY_VIEW;
}
$data[GLOSSARY_DATE_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_DATE_VIEW;
$l = "";
glossary_print_addentry_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab);
break;
+ case GLOSSARY_IMPORT_VIEW:
+ $search = "";
+ $l = "";
+ glossary_print_import_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab);
+ break;
+ case GLOSSARY_EXPORT_VIEW:
+ $search = "";
+ $l = "";
+ glossary_print_export_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab);
+ break;
case GLOSSARY_DATE_VIEW:
if (!$sortkey) {
$sortkey = 'UPDATE';