2 require_once 'config.php';
3 require_once 'pair.php';
13 /* If not already loaded for this session, load the config,
14 otherwise set the $config variable to the existing config. */
16 if(!isset($_SESSION['config'])) {
17 $config = new Config('config/config.xml');
18 $_SESSION['config'] = $config;
20 $config = $_SESSION['config'];
23 $pairs = $config->pairs();
24 if(!isset($_POST['selected_pair'])) {
25 $pair_names = array_keys($pairs);
26 $current_pair = $pair_names[0];
28 $current_pair = $_POST['selected_pair'];
30 $pair = $config->get_pair($current_pair);
32 if(!isset($_POST['selected_tag'])) {
33 $tags = $pair->tags();
34 $tag_names = array_keys($tags);
35 $current_tag = $tag_names[0];
37 $current_tag = $_POST['selected_tag'];
41 if(isset($_POST['selected_template'])) {
42 $template = $_POST['selected_template'];
45 $left_lemma = $_POST['left_lemma'];
46 $left_paradigm = $_POST['left_paradigm'];
47 $left_comment = $_POST['left_comment'];
49 $right_lemma = $_POST['right_lemma'];
50 $right_paradigm = $_POST['right_paradigm'];
51 $right_comment = $_POST['right_comment'];
53 $left_lemma_exists = "false";
54 $right_lemma_exists = "false";
56 $left_lemma_exists = $_POST['left_lemma_exists'];
57 $right_lemma_exists = $_POST['right_lemma_exists'];
59 $dictionary_left = $pair->dictionary('left');
60 $left_lemma_exists = $dictionary_left->lemma_exists($left_lemma, $current_tag);
62 $dictionary_right = $pair->dictionary('right');
63 $right_lemma_exists = $dictionary_right->lemma_exists($right_lemma, $current_tag);
65 $restriction = $_POST['restriction'];
67 if(isset($_POST['preview_box'])) {
68 if($_POST['preview_box'] == _('Preview')) {
69 print $_POST['preview_box'];
70 print ' (' . $template . ')';
75 if(isset($_POST['commit_box'])) {
76 if($_POST['commit_box'] == _('Commit')) {
77 print $_POST['commit_box'];
78 print ' (' . $template . ')';
83 if(isset($_POST['clear_box'])) {
84 if($_POST['clear_box'] == _('Clear')) {
97 <title
><?
print _('Dictionary management'); ?
></title
>
98 <link rel
="stylesheet" type
="text/css" href
="styles/default.css"/>
99 <script src
="js/boxover.js"></script
>
102 <form action
="index.php" method
="POST" name
="dixform">
103 <div id
="language_bar">
107 <div width
="100%"> <!-- Header
-->
108 <?
print _('Language pair:'); ?
> <select name
="selected_pair" onChange
="dixform.submit();">
110 $pairs = $config->pairs();
112 foreach($pairs as $pair) {
113 $pair = trim($pair->name
);
114 print ' <option value="' . $pair . '"' . ($pair == $current_pair ?
' selected' : '') . '>' . $pair . '</option>' . "\n ";
120 <?
print _('Part-of-speech:'); ?
> <select name
="selected_tag" onChange
="dixform.submit();">
122 $pair = $config->get_pair($current_pair);
123 $tags = $pair->tags();
125 foreach($tags as $tag) {
127 print '<option value="' . $tag . '"' . ($tag == $current_tag ?
' selected' : '') . '>' . $tag . '</option>' . "\n";
138 $pair = $config->get_pair($current_pair);
139 $dictionary = $pair->dictionary('left');
141 print _($dictionary->language
) . ' <br /><small>(';
142 print $dictionary->file
. ' )</small>';
145 Lemma
:<sup
><span
class="tooltip" title
="header=[Lemma] body=[Type in the lemma, or citation form of the word you wish to add.]">?
</span
></sup
>
146 <input type
="text" name
="left_lemma" value
="<? print $left_lemma; ?>" <?
if($left_lemma_exists == "true") { print 'id="known_word"'; } ?
>>
148 <?
if($left_lemma_exists == "true") { print _("Known lemma"); } ?
>
151 <?
print _('Paradigm'); ?
>:
152 <sup
><span
class="tooltip" title
="header=[Paradigm] body=[Paradigms define how a word inflects, select the one that fits the lemma you added.]">?
</span
></sup
>
153 <select name
="left_paradigm">
155 $pair = $config->get_pair($current_pair);
156 $dictionary = $pair->dictionary('left');
157 $paradigms = $dictionary->paradigms($current_tag);
158 $display_mode = $dictionary->get_display_mode($current_tag);
160 $glosses = $dictionary->glosses();
162 foreach($paradigms as $paradigm) {
163 // if we're in "list mode and there is no gloss for this
164 // paradigm, don't display it
165 if($display_mode == "list" && $glosses[$paradigm->name
] == "") {
168 print '<option value="' . $paradigm->name
. '"';
169 if($paradigm->name
== $left_paradigm) {
172 if($glosses[$paradigm->name
] != "") {
173 print '>' . $glosses[$paradigm->name
] . '</option>'. "\n";
175 print '>' . $paradigm->name
. '</option>'. "\n";
182 <?
print _('Comment'); ?
>:
183 <sup
><span
class="tooltip" title
="header=[Comment] body=[You can leave a comment here.]">?
</span
></sup
>
184 <input type
="text" name
="left_comment" value
="<? print $left_comment; ?>" />
188 if($previewing == 'on') {
189 $pair = $config->get_pair($current_pair);
190 $dictionary = $pair->dictionary('left');
192 $par = $dictionary->get_paradigm($left_paradigm, $current_tag);
193 $stems = $par->stems();
194 $show_stems = $pair->shows($current_tag);
195 $templates = $pair->templates("l");
197 foreach(array_keys($stems) as $stem) {
198 if(sizeof($show_stems) > 1) {
199 // if there is a tag whitelist, use it.
200 foreach($show_stems as $show) {
201 if($show == $stems[$stem][0]) {
202 print $dictionary->incondicional($left_lemma, $left_paradigm) . $stem . '<br />';
203 print '<span id="symbol_list">' . $stems[$stem][0] . '</span>';
208 // if not, display all stem-tag pairs.
209 print $dictionary->incondicional($left_lemma, $left_paradigm) . $stem . '<br />';
210 print '<span id="symbol_list">' . $stems[$stem][0] . '</span>';
214 // if some templates have been retrieved for this pair
215 // check the stem tags of the current paradigm against
216 // the ones stored for each template. if any match, set
217 // the current template.
218 if(sizeof($templates) > 0) {
219 foreach(array_keys($templates) as $tmpl_tag) {
220 if(strstr($stems[$stem][0], $tmpl_tag)) {
221 $template = $templates[$tmpl_tag];
230 $dictionary = $pair->dictionary('left');
231 $left_entrada = $dictionary->generate_monodix_entrada($left_lemma, $left_paradigm, $left_comment, "webform");
234 print '<span id="monodix_entrada"><pre>';
235 print str_replace('>', '>', str_replace('<', '<', $left_entrada));
236 print '</pre></span>';
243 Direction restriction
:<sup
><span
class="tooltip" title
="header=[Direction restriction] body=[Please indicate the direction in which this word pair should be translated.]">?
</span
></sup
>
245 <input type
="radio" name
="restriction" value
="none" <?
if($restriction == 'none' ||
$restriction == '') print ' checked'; ?
>>←→
<br
/>
246 <input type
="radio" name
="restriction" value
="LR" <?
if($restriction == 'LR') print ' checked'; ?
>>→→
<br
/>
247 <input type
="radio" name
="restriction" value
="RL" <?
if($restriction == 'RL') print ' checked'; ?
>>←←
249 <input type
="submit" name
="clear_box" value
="<? print _('Clear'); ?>">
250 <input type
="submit" name
="preview_box" value
="<? print _('Preview'); ?>">
251 <input type
="submit" name
="commit_box" value
="<? print _('Commit'); ?>">
255 if($previewing == "on") {
256 $pair = $config->get_pair($current_pair);
258 $dictionary = $pair->dictionary('bilingual');
268 $pair = $config->get_pair($current_pair);
269 $dictionary = $pair->dictionary('right');
271 print $dictionary->language
. ' <br /><small>(';
272 print $dictionary->file
. ' )</small>';
275 Lemma
:<sup
> 
;</sup
><input type
="text" name
="right_lemma" value
="<? print $right_lemma; ?>" <?
if($right_lemma_exists == "true") { print 'id="known_word"'; } ?
>>
276 <?
if($right_lemma_exists == "true") { print "Known lemma"; } ?
>
279 Paradigm
:<sup
> 
;</sup
><select name
="right_paradigm">
281 $pair = $config->get_pair($current_pair);
282 $dictionary = $pair->dictionary('right');
283 $paradigms = $dictionary->paradigms($current_tag);
284 $display_mode = $dictionary->get_display_mode($current_tag);
286 foreach($paradigms as $paradigm) {
287 // if we're in "list mode and there is no gloss for this
288 // paradigm, don't display it
289 if($display_mode == "list" && $glosses[$paradigm->name
] == "") {
292 print '<option value="' . $paradigm->name
. '"';
293 if($paradigm->name
== $right_paradigm) {
296 print '>' . $paradigm->name
. '</option>'. "\n";
302 <?
print _('Comment'); ?
>:
303 <input type
="text" name
="right_comment" value
="<? print $right_comment; ?>" />
307 if($previewing == 'on') {
308 $pair = $config->get_pair($current_pair);
309 $dictionary = $pair->dictionary('right');
311 $par = $dictionary->get_paradigm($right_paradigm, $current_tag);
312 $stems = $par->stems();
313 $show_stems = $pair->shows($current_tag);
314 $templates = $pair->templates("r");
316 foreach(array_keys($stems) as $stem) {
317 if(sizeof($show_stems) > 1) {
318 foreach($show_stems as $show) {
319 if($show == $stems[$stem][0]) {
320 print $dictionary->incondicional($right_lemma, $right_paradigm) . $stem . '<br />';
321 print '<span id="symbol_list">' . $stems[$stem][0] . '</span>';
326 print $dictionary->incondicional($right_lemma, $right_paradigm) . $stem . '<br />';
327 print '<span id="symbol_list">' . $stems[$stem][0] . '</span>';
331 if(sizeof($templates) > 0) {
332 foreach(array_keys($templates) as $tmpl_tag) {
333 if(strstr($stems[$stem][0], $tmpl_tag)) {
334 $template = $templates[$tmpl_tag];
342 $dictionary = $pair->dictionary('right');
343 $right_entrada = $dictionary->generate_monodix_entrada($right_lemma, $right_paradigm, $right_comment, "webform");
346 print '<span id="monodix_entrada"><pre>';
347 print str_replace('>', '>', str_replace('<', '<', $right_entrada));
348 print '</pre></span>';
356 $pair = $config->get_pair($current_pair);
357 $dictionary = $pair->dictionary('bilingual');
359 if($template != "none") {
360 $bidix_entrada = $dictionary->generate_bidix_entrada_from_template($pair->template_dir(), $template, $left_lemma, $right_lemma, "", "webform");
361 print '<span id="bidix_entrada"><pre>';
362 $bidix_entrada = str_replace('><', '>\n<', str_replace('>', '>', str_replace('<', '<', $bidix_entrada)));
363 $bidix_entrada = str_replace("</e>\n", "</e><br />", $bidix_entrada);
364 print $bidix_entrada;
365 print '</pre></span>';
367 $bidix_entrada = $dictionary->generate_bidix_entrada($left_lemma, $right_lemma, $current_tag, $restriction, "", "webform");
368 print '<span id="bidix_entrada"><pre>';
369 print str_replace('><', '>\n<', str_replace('>', '>', str_replace('<', '<', $bidix_entrada)));
370 print '</span></pre>';
373 print '<input type="hidden" name="selected_template" value="' . $template . '">';
379 if($committing == "on") {
380 $pair = $config->get_pair($current_pair);
382 $dictionary = $pair->dictionary('left');
383 $left_entrada = $dictionary->generate_monodix_entrada($left_lemma, $left_paradigm, $left_comment, "webform");
385 $dictionary = $pair->dictionary('bilingual');
386 if($template != "none") {
387 $bidix_entrada = $dictionary->generate_bidix_entrada_from_template($pair->template_dir(), $template, $left_lemma, $right_lemma, "", "webform");
389 $bidix_entrada = $dictionary->generate_bidix_entrada($left_lemma, $right_lemma, $current_tag, $restriction, "", "webform");
392 $dictionary = $pair->dictionary('right');
393 $right_entrada = $dictionary->generate_monodix_entrada($right_lemma, $right_paradigm, $right_comment, "webform");
395 print '<span id="monodix_entrada">';
396 print str_replace('>', '>', str_replace('<', '<', $left_entrada));
399 print '<span id="bidix_entrada">';
400 print str_replace('>', '>', str_replace('<', '<', $bidix_entrada));
403 print '<span id="monodix_entrada">';
404 print str_replace('>', '>', str_replace('<', '<', $right_entrada));
407 $pair->commit($left_entrada, $bidix_entrada, $right_entrada);