コード例 #1
0
 public function ajaxProcessDeletePostImage()
 {
     $response = true;
     $SimpleBlogPostImage = new SimpleBlogPostImage((int) Tools::getValue('id_simpleblog_post_image'));
     $response &= $SimpleBlogPostImage->delete();
     if ($response) {
         die(Tools::jsonEncode(array('status' => 'ok', 'id' => $SimpleBlogPostImage->id_simpleblog_post_image, 'confirmations' => array($this->_conf[7]))));
     } else {
         $this->jsonError(Tools::displayError('An error occurred while attempting to delete the product image.'));
     }
 }
コード例 #2
0
ファイル: SimpleBlogPost.php プロジェクト: evgrishin/se1614
 public static function getPosts($id_lang, $limit = 10, $id_simpleblog_category = null, $page = null, $active = true, $orderby = false, $orderway = false, $exclude = null, $featured = false, $author = false, $id_shop = null, $filter = false, $selected = array(), $check_access = true)
 {
     $context = Context::getContext();
     $start = $limit * ($page == 0 ? 0 : $page - 1);
     $sql = new DbQuery();
     $sql->select('*');
     $sql->from('simpleblog_post', 'sbp');
     if ($id_lang) {
         $sql->innerJoin('simpleblog_post_lang', 'l', 'sbp.id_simpleblog_post = l.id_simpleblog_post AND l.id_lang = ' . (int) $id_lang);
     }
     if (!$id_shop) {
         $id_shop = $context->shop->id;
     }
     $sql->innerJoin('simpleblog_post_shop', 'sbps', 'sbp.id_simpleblog_post = sbps.id_simpleblog_post AND sbps.id_shop = ' . (int) $id_shop);
     if ($active) {
         $sql->where('sbp.active = 1');
     }
     if (isset($id_simpleblog_category) && (int) $id_simpleblog_category > 0) {
         $childrens = SimpleBlogCategory::getChildrens((int) $id_simpleblog_category);
         if ($childrens && sizeof($childrens)) {
             $child_categories = array((int) $id_simpleblog_category);
             foreach ($childrens as $child) {
                 $child_categories[] = $child['id_simpleblog_category'];
             }
             $sql->where('sbp.id_simpleblog_category IN (' . join(',', $child_categories) . ')');
         } else {
             $sql->where('sbp.id_simpleblog_category = ' . (int) $id_simpleblog_category);
         }
     }
     if ($exclude) {
         $sql->where('sbp.id_simpleblog_post != ' . (int) $exclude);
     }
     if ($featured) {
         $sql->where('sbp.is_featured = 1');
     }
     if ($author && Configuration::get('PH_BLOG_POST_BY_AUTHOR')) {
         $sql->where('sbp.author = \'' . pSQL($author) . '\'');
     }
     if ($filter) {
         $sql->where('sbp.id_simpleblog_post ' . $filter . ' (' . join(',', $selected) . ')');
     }
     $sql->where('sbp.date_add <= \'' . SimpleBlogHelper::now(Configuration::get('PH_BLOG_TIMEZONE')) . '\'');
     if (!$orderby) {
         $orderby = 'sbp.date_add';
     }
     if (!$orderway) {
         $orderway = 'DESC';
     }
     $sql->orderBy($orderby . ' ' . $orderway);
     $sql->limit($limit, $start);
     $result = Db::getInstance()->executeS($sql);
     if (sizeof($result) && $check_access == true) {
         $result = self::checkAccess($result);
     }
     if (sizeof($result)) {
         foreach ($result as &$row) {
             $category_rewrite = SimpleBlogCategory::getRewriteByCategory($row['id_simpleblog_category'], $id_lang);
             $category_obj = new SimpleBlogCategory($row['id_simpleblog_category'], $id_lang);
             $category_url = SimpleBlogCategory::getLink($category_obj->link_rewrite, $id_lang);
             if (file_exists(_PS_MODULE_DIR_ . 'ph_simpleblog/covers/' . $row['id_simpleblog_post'] . '.' . $row['cover'])) {
                 $row['banner'] = _MODULE_DIR_ . 'ph_simpleblog/covers/' . $row['id_simpleblog_post'] . '.' . $row['cover'];
                 $row['banner_thumb'] = _MODULE_DIR_ . 'ph_simpleblog/covers/' . $row['id_simpleblog_post'] . '-thumb.' . $row['cover'];
                 $row['banner_wide'] = _MODULE_DIR_ . 'ph_simpleblog/covers/' . $row['id_simpleblog_post'] . '-wide.' . $row['cover'];
             }
             if (file_exists(_PS_MODULE_DIR_ . 'ph_simpleblog/featured/' . $row['id_simpleblog_post'] . '.' . $row['featured'])) {
                 $row['featured'] = _MODULE_DIR_ . 'ph_simpleblog/featured/' . $row['id_simpleblog_post'] . '.' . $row['featured'];
             }
             $row['url'] = self::getLink($row['link_rewrite'], $category_obj->link_rewrite, $id_lang);
             $row['category'] = $category_obj->name;
             $row['category_rewrite'] = $category_obj->link_rewrite;
             $row['category_url'] = $category_url;
             $tags = SimpleBlogTag::getPostTags($row['id_simpleblog_post']);
             $row['tags'] = isset($tags[$id_lang]) && sizeof($tags[$id_lang] > 0) ? $tags[$id_lang] : false;
             $row['post_type'] = SimpleBlogPostType::getSlugById($row['id_simpleblog_post_type']);
             if ($row['post_type'] == 'gallery') {
                 $row['gallery'] = SimpleBlogPostImage::getAllById($row['id_simpleblog_post']);
             }
         }
     } else {
         return;
     }
     return $result;
 }