Display related words in public dictionary render
This commit is contained in:
parent
d1bcfc5b97
commit
4d63aa9034
|
@ -184,6 +184,8 @@ export function renderWords() {
|
|||
details: originalWord.details,
|
||||
etymology: typeof originalWord.etymology === 'undefined' || originalWord.etymology.length < 1 ? null
|
||||
: originalWord.etymology.join(', '),
|
||||
related: typeof originalWord.related === 'undefined' || originalWord.related.length < 1 ? null
|
||||
: originalWord.related.join(', '),
|
||||
wordId: originalWord.wordId,
|
||||
});
|
||||
|
||||
|
@ -204,11 +206,15 @@ export function renderWords() {
|
|||
<dd class="details">
|
||||
${md(word.details)}
|
||||
</dd>
|
||||
${word.etymology === null ? '' : `<hr>
|
||||
<dt>Etymology <small>(Root Word${originalWord.etymology.length !== 1 ? 's' : ''})</small></dt>
|
||||
${word.etymology === null && word.related === null ? '' : `<hr>`}
|
||||
${word.etymology === null ? '' : `<dt>Etymology <small>(Root Word${originalWord.etymology.length !== 1 ? 's' : ''})</small></dt>
|
||||
<dd class="etymology">
|
||||
${md(word.etymology).replace(/<\/?p>/g, '')}
|
||||
</dd>`}
|
||||
${word.related === null ? '' : `<dt>Related Word${originalWord.related.length !== 1 ? 's' : ''}</dt>
|
||||
<dd class="related">
|
||||
${md(word.related).replace(/<\/?p>/g, '')}
|
||||
</dd>`}
|
||||
</dl>
|
||||
</article>`;
|
||||
});
|
||||
|
|
|
@ -99,6 +99,14 @@ class PublicDictionary {
|
|||
}, explode(',', $row['etymology']));
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_null($row['related'])) {
|
||||
if (strlen($row['related']) > 0) {
|
||||
$word['related'] = array_map(function ($root) use($dictionary) {
|
||||
return $this->getWordReferenceHTML(strip_tags($root), $dictionary);
|
||||
}, explode(',', $row['related']));
|
||||
}
|
||||
}
|
||||
|
||||
return $word;
|
||||
}, $this->sortWords($words));
|
||||
|
@ -129,8 +137,8 @@ class PublicDictionary {
|
|||
|
||||
private function getWordsAsEntered() {
|
||||
if (!isset($this->original_words)) {
|
||||
$query = "SELECT words.*, words_advanced.etymology FROM words
|
||||
LEFT JOIN words_advanced ON words_advanced.dictionary = words.dictionary AND words_advanced.word_id = words.word_id
|
||||
$query = "SELECT words.*, wa.etymology, wa.related FROM words
|
||||
LEFT JOIN words_advanced wa ON wa.dictionary = words.dictionary AND wa.word_id = words.word_id
|
||||
JOIN dictionaries ON dictionaries.id = words.dictionary
|
||||
WHERE words.dictionary=? AND is_public=1";
|
||||
$this->original_words = $this->db->query($query, array($this->details['externalID']))->fetchAll();
|
||||
|
|
Loading…
Reference in New Issue