<?php //$Id: edit.html,v 1.44.2.1 2005/10/29 21:38:39 skodak Exp $
    if (!isset($newentry->format)) {
        $newentry->format = $defaultformat;
    }
    if ($usehtmleditor) { //clean and convert before editing
        $options = new object();
        $options->smiley = false;
        $options->filter = false;
        $newentry->definition = format_text($newentry->definition, $newentry->format, $options);
        $newentry->format = FORMAT_HTML;
    }
?>
<form name="form" method="post" action="edit.php" enctype="multipart/form-data">
<table border="0" cellpadding="5">
<?php
if (isset($errors)) {
?>
    <tr valign="top">
        <td colspan="2" align="center"><strong><font color="red"><?php p($errors) ?></font></strong>
        </td>
    </tr>
<?php
}
?>
<tr valign="top">
<td colspan="2">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="5">
        <tr>
          <td width="150" align="right"><b><?php echo get_string("concept","glossary") ?>:</b></td>
          <td><input type="text" name="concept" size="30" value="<?php p(clean_text($newentry->concept)) ?>" alt="<?php print_string("concept","glossary") ?>" /></td>
        </tr>
        <tr>
          <td align="right"><b><?php echo get_string("categories","glossary") ?>:</b></td>
          <td valign="top">
    <?php
        $categories = get_records("glossary_categories","glossaryid",$glossary->id,'name ASC');
        echo "<select size=\"5\" name=\"categories[]\" multiple=\"multiple\" >";
        echo "<option value=\"0\">" . get_string("notcategorised","glossary") . "</option>";

        if ( $categories ) {
            foreach ( $categories as $category ) {
                echo "  <option ";
                if (isset($newentry->id)) {
                    if ( record_exists("glossary_entries_categories","entryid",$newentry->id,"categoryid",$category->id) ) {
                        echo "selected=\"selected\" " ;
                    }
                }
                echo "value=\"$category->id\">".clean_text($category->name)."</option>\n";
            }
        }
        echo "</select>\n";
    ?>
          </td>
        </tr>
      </table></td>
    <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td valign="top" align="right"><b>
            <?php
              echo get_string("aliases","glossary");
              echo ':<br />';
              helpbutton("aliases2", strip_tags(get_string("aliases", "glossary")), "glossary");
            ?></b>
          </td>
          <td valign="top">
             <textarea rows="2" name="aliases" cols="20"><?php p(clean_text($newentry->aliases)) ?></textarea>
          </td>
        </tr>
        <tr>
          <td colspan="2">
<?php
    if ( !$glossary->usedynalink ) {
      echo '<input type="hidden" name="usedynalink" value="0" />';
      echo '<input type="hidden" name="casesensitive" value="0" />';
      echo '<input type="hidden" name="fullmatch" value="0" />';
    } else {
        echo '<script type="text/javascript">var items = [\'casesensitive\',\'fullmatch\'];</script>';

        if (!empty($newentry->usedynalink)) {
            $selected = "checked=\"checked\"";
        } else {
            $selected = "";
        }
        echo '<input type="checkbox" name="usedynalink" value="1" alt="' . get_string("entryusedynalink","glossary") . '" ' . $selected . ' onclick="return lockoptions(\'form\',\'usedynalink\', items)" /> ';
        print_string("entryusedynalink","glossary");
        echo helpbutton("usedynalinkentry", strip_tags(get_string("usedynalink", "glossary")), "glossary");
        echo '<br />';

        if (!empty($newentry->casesensitive)) {
            $selected = "checked";
        } else {
            $selected = "";
        }
        echo '<input type="checkbox" name="casesensitive" value="1" alt="' . get_string("casesensitive","glossary") . '" ' . $selected . ' /> ';
        print_string("casesensitive","glossary");
        echo helpbutton("casesensitive", strip_tags(get_string("casesensitive", "glossary")), "glossary");
        echo '<br />';


        if (!empty($newentry->fullmatch)) {
            $selected = "checked";
        } else {
            $selected = "";
        }
        echo '<input type="checkbox" name="fullmatch" value="1" alt="' . get_string("fullmatch","glossary") . '" ' . $selected . ' /> ';
        print_string("fullmatch","glossary");
        echo helpbutton("fullmatch", strip_tags(get_string("fullmatch", "glossary")), "glossary");
        echo '<br />';
    }
?>
          </td>
        </tr>
      </table></td>
  </tr>
</table>
</td>
</tr>
<tr valign="top">
    <td align="right"><b>
     <?php print_string("definition", "glossary"); ?>:
     </b></td>
    <td align="left" rowspan="2">
    <?php print_textarea($usehtmleditor, 25, 65, 630, 400, "text", $newentry->definition); ?>
    </td>
</tr>
<tr valign="top">
    <td align="right" valign="middle" nowrap="nowrap">

     <?php
        helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
        echo "<br />";
        if ($usehtmleditor) {
           helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
        } else {
           emoticonhelpbutton("form", "text");
        }
        echo "<br />";
      ?>

    </td>
</tr>
<tr valign="top">
    <td align="right"><b><?php print_string("formattexttype"); ?>:</b></td>
    <td>
    <?php
        if ($usehtmleditor) {   /// Trying this out for a while
            print_string('formathtml');
            echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />';
        } else {
            choose_from_menu(format_text_menu(), "format", $newentry->format, "");
        }
        helpbutton("textformat", get_string("helpformatting"));
     ?>
    </td>
</tr>

<tr valign="top">
    <td align="right"><b><?php print_string("attachment", "glossary") ?>:<br />(<?php print_string("optional") ?>)&nbsp;</b></td>
    <td>
    <?php
       require_once($CFG->dirroot.'/lib/uploadlib.php');
       upload_print_form_fragment(1,array('attachment'),null,false,null,$course->maxbytes,0,false);
       helpbutton("attachment", get_string("attachment", "glossary"), "glossary");
       echo '&nbsp;';
       print_string("maxsize", "", display_size(get_max_upload_file_size($CFG->maxbytes, $course->maxbytes)));
    ?>
    </td>
</tr>
<tr>
<td colspan="2">
    <p align="center">
    <?php if (isset($newentry->id)) {
        echo "<input type=\"hidden\" name=\"e\" value=\"$newentry->id\" />";
    }
  ?>

  <input type="hidden" name="husedynalink" value="1" />
  <input type="hidden" name="hcasesensitive" value="0" />
  <input type="hidden" name="hfullmatch" value="1" />

  <input type="hidden" name="id" value="<?php p($cm->id) ?>" />
  <input type="hidden" name="mode" value="<?php p($mode) ?>" />
  <input type="hidden" name="hook" value="<?php p($hook) ?>" />
  <input type="hidden" name="confirm" value="1" />

  <input type="submit" value="<?php print_string("savechanges") ?>" />
  <input type="reset" value="<?php print_string("revert") ?>" />
  </p>
</td>
</tr>
</table>
</form>
