mirror of
				https://github.com/Alamantus/Lexiconga.git
				synced 2025-11-04 10:17:01 +01:00 
			
		
		
		
	Compare commits
	
		
			4 commits
		
	
	
		
			fa7cdee8cf
			...
			7ce75c0e6c
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
							 | 
						7ce75c0e6c | ||
| be67f965eb | |||
| ed7f06d061 | |||
| 
							 | 
						c81fa9c29a | 
					 3 changed files with 19 additions and 24 deletions
				
			
		| 
						 | 
					@ -31,7 +31,7 @@
 | 
				
			||||||
    "sharp": "^0.29.3"
 | 
					    "sharp": "^0.29.3"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "dependencies": {
 | 
					  "dependencies": {
 | 
				
			||||||
    "marked": "^3.0.8",
 | 
					    "marked": "^4.0.10",
 | 
				
			||||||
    "normalize.css": "^8.0.1",
 | 
					    "normalize.css": "^8.0.1",
 | 
				
			||||||
    "papaparse": "^5.3.0",
 | 
					    "papaparse": "^5.3.0",
 | 
				
			||||||
    "upup": "^1.1.0"
 | 
					    "upup": "^1.1.0"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,7 +10,7 @@ class PublicDictionary {
 | 
				
			||||||
  public $details;
 | 
					  public $details;
 | 
				
			||||||
  public $words;
 | 
					  public $words;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function __construct ($dictionary_id) {
 | 
					  function __construct ($dictionary_id, $details_only = false) {
 | 
				
			||||||
    $this->db = new Db();
 | 
					    $this->db = new Db();
 | 
				
			||||||
    $this->token = new Token();
 | 
					    $this->token = new Token();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,7 @@ class PublicDictionary {
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $this->details = $this->getPublicDictionaryDetails($dictionary_id);
 | 
					    $this->details = $this->getPublicDictionaryDetails($dictionary_id);
 | 
				
			||||||
    $this->words = $this->getPublicDictionaryWords($dictionary_id);
 | 
					    $this->words = $details_only ? [] : $this->getPublicDictionaryWords($dictionary_id);
 | 
				
			||||||
    if ($this->details !== false) {
 | 
					    if ($this->details !== false) {
 | 
				
			||||||
      $this->details['wordStats'] = $this->getWordStats();
 | 
					      $this->details['wordStats'] = $this->getWordStats();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -123,13 +123,10 @@ class PublicDictionary {
 | 
				
			||||||
    return array();
 | 
					    return array();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public function getSpecificPublicDictionaryWord ($dictionary, $word) {
 | 
					  public function getSpecificPublicDictionaryWord ($dictionary, $word_id) {
 | 
				
			||||||
    if (is_numeric($dictionary) && is_numeric($word)) {
 | 
					    if (is_numeric($dictionary) && is_numeric($word_id)) {
 | 
				
			||||||
      $query = "SELECT words.*, wa.etymology, wa.related, wa.principal_parts FROM words
 | 
					      $results = array_filter($this->getWordsAsEntered(), fn ($row) => $row['word_id'] == $word_id);
 | 
				
			||||||
      LEFT JOIN words_advanced wa ON wa.dictionary = words.dictionary AND wa.word_id = words.word_id
 | 
					      $result = array_values($results)[0] ?? null;
 | 
				
			||||||
      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();
 | 
					 | 
				
			||||||
      if ($result) {
 | 
					      if ($result) {
 | 
				
			||||||
        $word = array(
 | 
					        $word = array(
 | 
				
			||||||
          'name' => $this->translateOrthography($result['name'], $dictionary),
 | 
					          'name' => $this->translateOrthography($result['name'], $dictionary),
 | 
				
			||||||
| 
						 | 
					@ -265,7 +262,7 @@ WHERE words.dictionary=? AND is_public=1";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $target_id = false;
 | 
					    $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 (count($reference_ids) > 0) {
 | 
				
			||||||
      if ($homonymn !== false && $homonymn > 0) {
 | 
					      if ($homonymn !== false && $homonymn > 0) {
 | 
				
			||||||
| 
						 | 
					@ -293,15 +290,13 @@ WHERE words.dictionary=? AND is_public=1";
 | 
				
			||||||
    return $reference;
 | 
					    return $reference;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private function getWordIdsWithName($dictionary, $word_name) {
 | 
					  private function getWordIdsFromName($word_name) {
 | 
				
			||||||
    if (is_numeric($dictionary)) {
 | 
					    $results = array_filter($this->getWordsAsEntered(), fn ($row) => $row['name'] == $word_name);
 | 
				
			||||||
      $query = "SELECT word_id FROM words WHERE dictionary=? AND name=?";
 | 
					    $results = array_values($results);
 | 
				
			||||||
      $results = $this->db->query($query, array($dictionary, $word_name))->fetchAll();
 | 
					    if ($results) {
 | 
				
			||||||
      if ($results) {
 | 
					      return array_map(function ($row) {
 | 
				
			||||||
        return array_map(function ($row) {
 | 
					        return intval($row['word_id']);
 | 
				
			||||||
          return intval($row['word_id']);
 | 
					      }, $results);
 | 
				
			||||||
        }, $results);
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return array();
 | 
					    return array();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3864,10 +3864,10 @@ map-visit@^1.0.0:
 | 
				
			||||||
  dependencies:
 | 
					  dependencies:
 | 
				
			||||||
    object-visit "^1.0.0"
 | 
					    object-visit "^1.0.0"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
marked@^3.0.8:
 | 
					marked@^4.0.10:
 | 
				
			||||||
  version "3.0.8"
 | 
					  version "4.0.10"
 | 
				
			||||||
  resolved "https://registry.yarnpkg.com/marked/-/marked-3.0.8.tgz#2785f0dc79cbdc6034be4bb4f0f0a396bd3f8aeb"
 | 
					  resolved "https://registry.yarnpkg.com/marked/-/marked-4.0.10.tgz#423e295385cc0c3a70fa495e0df68b007b879423"
 | 
				
			||||||
  integrity sha512-0gVrAjo5m0VZSJb4rpL59K1unJAMb/hm8HRXqasD8VeC8m91ytDPMritgFSlKonfdt+rRYYpP/JfLxgIX8yoSw==
 | 
					  integrity sha512-+QvuFj0nGgO970fySghXGmuw+Fd0gD2x3+MqCWLIPf5oxdv1Ka6b2q+z9RP01P/IaKPMEramy+7cNy/Lw8c3hw==
 | 
				
			||||||
 | 
					
 | 
				
			||||||
math-random@^1.0.1:
 | 
					math-random@^1.0.1:
 | 
				
			||||||
  version "1.0.4"
 | 
					  version "1.0.4"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue