Browse Source

Change the structure of the smiley cache

Visman 4 years ago
parent
commit
f045592a9b
2 changed files with 7 additions and 6 deletions
  1. 3 4
      app/Core/Parser.php
  2. 4 2
      app/Models/SmileyList/Load.php

+ 3 - 4
app/Core/Parser.php

@@ -46,12 +46,11 @@ class Parser extends Parserus
                 || '1' == $this->c->config->o_smilies
             )
         ) {
-            $smilies = $this->c->smilies->list; //????
+            $smilies = [];
 
-            foreach ($smilies as &$cur) {
-                $cur = $this->c->PUBLIC_URL . '/img/sm/' . $cur;
+            foreach ($this->c->smilies->list as $cur) {
+                $smilies[$cur['text']] = $this->c->PUBLIC_URL . '/img/sm/' . $cur['image'];
             }
-            unset($cur);
 
             $info = $this->c->BBCODE_INFO;
 

+ 4 - 2
app/Models/SmileyList/Load.php

@@ -16,12 +16,14 @@ class Load extends Method
      */
     public function load(): SmileyList
     {
-        $query = 'SELECT sm.text, sm.image
+        $query = 'SELECT sm.id, sm.text, sm.image, sm.disp_position
             FROM ::smilies AS sm
             ORDER BY sm.disp_position';
 
-        $list = $this->c->DB->query($query)->fetchAll(PDO::FETCH_KEY_PAIR); //???? text уникальное?
+        $list = $this->c->DB->query($query)->fetchAll(PDO::FETCH_UNIQUE);
+
         $this->model->list = $list;
+
         $this->c->Cache->set('smilies', $list);
 
         return $this->model;