Esempio n. 1
0
 public function __construct($id_simpleblog_category = null, $id_lang = null, $id_shop = null)
 {
     parent::__construct($id_simpleblog_category, $id_lang, $id_shop);
     if (file_exists(_PS_MODULE_DIR_ . 'ph_simpleblog/covers_cat/' . $this->id_simpleblog_category . '.' . $this->cover)) {
         $this->image = _MODULE_DIR_ . 'ph_simpleblog/covers_cat/' . $this->id_simpleblog_category . '.' . $this->cover;
     }
     if ($this->id) {
         $tags = SimpleBlogTag::getPostTags((int) $this->id);
         $this->tags = $tags;
         if (isset($tags) && isset($tags[$id_lang])) {
             $this->tags_list = $tags[$id_lang];
         }
     }
 }
 public function updateTags($languages, $post)
 {
     $tag_success = true;
     foreach ($languages as $language) {
         if ($value = Tools::getValue('tags_' . $language['id_lang'])) {
             if (!Validate::isTagsList($value)) {
                 $this->errors[] = sprintf(Tools::displayError('The tags list (%s) is invalid.'), $language['name']);
             }
         }
     }
     if (!SimpleBlogTag::deleteTagsForPost((int) $post->id)) {
         $this->errors[] = Tools::displayError('An error occurred while attempting to delete previous tags.');
     }
     foreach ($languages as $language) {
         if ($value = Tools::getValue('tags_' . $language['id_lang'])) {
             $tag_success &= SimpleBlogTag::addTags($language['id_lang'], (int) $post->id, $value);
         }
     }
     if (!$tag_success) {
         $this->errors[] = Tools::displayError('An error occurred while adding tags.');
     }
 }
Esempio n. 3
0
 public function getTags($id_lang)
 {
     if (is_null($this->tags)) {
         $this->tags = SimpleBlogTag::getPostTags($this->id);
     }
     if (!($this->tags && key_exists($id_lang, $this->tags))) {
         return '';
     }
     $result = '';
     foreach ($this->tags[$id_lang] as $tag_name) {
         $result .= $tag_name . ', ';
     }
     return rtrim($result, ', ');
 }