mirror of
https://github.com/Alamantus/Lexiconga.git
synced 2025-07-07 08:04:16 +02:00
Provide etymology & related in public word view
This commit is contained in:
parent
4d63aa9034
commit
a30bdf5d63
1 changed files with 23 additions and 2 deletions
|
@ -117,10 +117,13 @@ class PublicDictionary {
|
||||||
|
|
||||||
public function getSpecificPublicDictionaryWord ($dictionary, $word) {
|
public function getSpecificPublicDictionaryWord ($dictionary, $word) {
|
||||||
if (is_numeric($dictionary) && is_numeric($word)) {
|
if (is_numeric($dictionary) && is_numeric($word)) {
|
||||||
$query = "SELECT words.* FROM words JOIN dictionaries ON id = dictionary WHERE dictionary=? AND word_id=? AND is_public=1";
|
$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 words.word_id=? AND dictionaries.is_public=1";
|
||||||
$result = $this->db->query($query, array($dictionary, $word))->fetch();
|
$result = $this->db->query($query, array($dictionary, $word))->fetch();
|
||||||
if ($result) {
|
if ($result) {
|
||||||
return array(
|
$word = array(
|
||||||
'name' => $this->translateOrthography($result['name'], $dictionary),
|
'name' => $this->translateOrthography($result['name'], $dictionary),
|
||||||
'pronunciation' => $result['pronunciation'],
|
'pronunciation' => $result['pronunciation'],
|
||||||
'partOfSpeech' => $result['part_of_speech'],
|
'partOfSpeech' => $result['part_of_speech'],
|
||||||
|
@ -130,6 +133,24 @@ class PublicDictionary {
|
||||||
'createdOn' => intval($result['created_on']),
|
'createdOn' => intval($result['created_on']),
|
||||||
'wordId' => intval($result['word_id']),
|
'wordId' => intval($result['word_id']),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!is_null($result['etymology'])) {
|
||||||
|
if (strlen($result['etymology']) > 0) {
|
||||||
|
$word['etymology'] = array_map(function ($root) use($dictionary) {
|
||||||
|
return $this->getWordReferenceHTML(strip_tags($root), $dictionary);
|
||||||
|
}, explode(',', $result['etymology']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_null($result['related'])) {
|
||||||
|
if (strlen($result['related']) > 0) {
|
||||||
|
$word['related'] = array_map(function ($root) use($dictionary) {
|
||||||
|
return $this->getWordReferenceHTML(strip_tags($root), $dictionary);
|
||||||
|
}, explode(',', $result['related']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $word;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue