mirror of
https://github.com/Alamantus/Lexiconga.git
synced 2025-08-07 06:17:35 +02:00
Compare commits
4 commits
a5b0fe185b
...
7dd0dfdfa3
Author | SHA1 | Date | |
---|---|---|---|
|
7dd0dfdfa3 | ||
be67f965eb | |||
ed7f06d061 | |||
|
8ffd19cdae |
2 changed files with 17 additions and 22 deletions
|
@ -10,7 +10,7 @@ class PublicDictionary {
|
|||
public $details;
|
||||
public $words;
|
||||
|
||||
function __construct ($dictionary_id) {
|
||||
function __construct ($dictionary_id, $details_only = false) {
|
||||
$this->db = new Db();
|
||||
$this->token = new Token();
|
||||
|
||||
|
@ -19,7 +19,7 @@ class PublicDictionary {
|
|||
);
|
||||
|
||||
$this->details = $this->getPublicDictionaryDetails($dictionary_id);
|
||||
$this->words = $this->getPublicDictionaryWords($dictionary_id);
|
||||
$this->words = $details_only ? [] : $this->getPublicDictionaryWords($dictionary_id);
|
||||
if ($this->details !== false) {
|
||||
$this->details['wordStats'] = $this->getWordStats();
|
||||
}
|
||||
|
@ -123,13 +123,10 @@ class PublicDictionary {
|
|||
return array();
|
||||
}
|
||||
|
||||
public function getSpecificPublicDictionaryWord ($dictionary, $word) {
|
||||
if (is_numeric($dictionary) && is_numeric($word)) {
|
||||
$query = "SELECT words.*, wa.etymology, wa.related, wa.principal_parts 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();
|
||||
public function getSpecificPublicDictionaryWord ($dictionary, $word_id) {
|
||||
if (is_numeric($dictionary) && is_numeric($word_id)) {
|
||||
$results = array_filter($this->getWordsAsEntered(), fn ($row) => $row['word_id'] == $word_id);
|
||||
$result = array_values($results)[0] ?? null;
|
||||
if ($result) {
|
||||
$word = array(
|
||||
'name' => $this->translateOrthography($result['name'], $dictionary),
|
||||
|
@ -265,7 +262,7 @@ WHERE words.dictionary=? AND is_public=1";
|
|||
}
|
||||
|
||||
$target_id = false;
|
||||
$reference_ids = $this->getWordIdsWithName($dictionary_id, $word_to_find);
|
||||
$reference_ids = $this->getWordIdsFromName($word_to_find);
|
||||
|
||||
if (count($reference_ids) > 0) {
|
||||
if ($homonymn !== false && $homonymn > 0) {
|
||||
|
@ -293,16 +290,14 @@ WHERE words.dictionary=? AND is_public=1";
|
|||
return $reference;
|
||||
}
|
||||
|
||||
private function getWordIdsWithName($dictionary, $word_name) {
|
||||
if (is_numeric($dictionary)) {
|
||||
$query = "SELECT word_id FROM words WHERE dictionary=? AND name=?";
|
||||
$results = $this->db->query($query, array($dictionary, $word_name))->fetchAll();
|
||||
private function getWordIdsFromName($word_name) {
|
||||
$results = array_filter($this->getWordsAsEntered(), fn ($row) => $row['name'] == $word_name);
|
||||
$results = array_values($results);
|
||||
if ($results) {
|
||||
return array_map(function ($row) {
|
||||
return intval($row['word_id']);
|
||||
}, $results);
|
||||
}
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
|
|
|
@ -4501,9 +4501,9 @@ path-key@^2.0.1:
|
|||
integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=
|
||||
|
||||
path-parse@^1.0.6:
|
||||
version "1.0.6"
|
||||
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"
|
||||
integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==
|
||||
version "1.0.7"
|
||||
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735"
|
||||
integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==
|
||||
|
||||
pbkdf2@^3.0.3:
|
||||
version "3.1.2"
|
||||
|
|
Loading…
Add table
Reference in a new issue