/**
  * renderForm contains all necessary initialization needed for all tabs
  *
  * @return void
  */
 public function renderList()
 {
     //this code for select or upload IMG
     $tpl = $this->createTemplate('imagemanager.tpl');
     $sortBy = Tools::getValue('sortBy');
     $reloadBack = Tools::getValue('reloadBack');
     if ($reloadBack) {
         $images = $this->getImageList($sortBy);
         $tpl->assign(array('images' => $images, 'reloadBack' => $reloadBack));
         die(Tools::jsonEncode($tpl->fetch()));
     }
     $reloadSliderImage = Tools::getValue('reloadSliderImage');
     if ($reloadSliderImage) {
         $images = $this->getImageList($sortBy);
         $tpl->assign(array('images' => $images, 'reloadSliderImage' => $reloadSliderImage));
         die(Tools::jsonEncode($tpl->fetch()));
     }
     $images = $this->getImageList($sortBy);
     $image_uploader = new HelperImageUploader('file');
     $image_uploader->setSavePath($this->img_path);
     $url = Context::getContext()->link->getAdminLink('AdminLeomanagewidgetsImages') . '&ajax=1&action=addSliderImage' . $this->paramLink;
     $image_uploader->setMultiple(true)->setUseAjax(true)->setUrl($url);
     $tpl->assign(array('countImages' => count($images), 'images' => $images, 'max_image_size' => $this->max_image_size / 1024 / 1024, 'image_uploader' => $image_uploader->render(), 'imgManUrl' => Context::getContext()->link->getAdminLink('AdminLeomanagewidgetsImages') . $this->paramLink, 'token' => $this->token));
     return $tpl->fetch();
 }
 /**
  * renderForm contains all necessary initialization needed for all tabs
  *
  * @return void
  */
 public function renderList()
 {
     $tpl = $this->createTemplate('imagesmanagement.tpl');
     $sort_by = Tools::getValue('sortBy');
     $reload_slider_image = Tools::getValue('reloadSliderImage');
     $images = $this->getImageList($sort_by);
     $tpl->assign(array('images' => $images, 'reloadSliderImage' => $reload_slider_image));
     if ($reload_slider_image) {
         die(Tools::jsonEncode($tpl->fetch()));
     }
     $image_uploader = new HelperImageUploader('file');
     $image_uploader->setSavePath($this->img_path);
     $image_uploader->setMultiple(true)->setUseAjax(true)->setUrl(Context::getContext()->link->getAdminLink('AdminPspagebuilderImage') . '&ajax=1&action=addSliderImage');
     $tpl->assign(array('countImages' => count($images), 'images' => $images, 'max_image_size' => $this->max_image_size / 1024 / 1024, 'image_uploader' => $image_uploader->render(), 'imgManUrl' => Context::getContext()->link->getAdminLink('AdminPspagebuilderImage'), 'token' => $this->token, 'imgUploadDir' => $this->img_path, 'add_cls' => Tools::getValue('modal') ? 'modalshowed' : ''));
     return $tpl->fetch();
 }
 /**
  * renderForm contains all necessary initialization needed for all tabs
  *
  * @return void
  */
 public function renderList()
 {
     //this code for typo
     $typo = Tools::getValue('typo');
     if ($typo) {
         //check css file in theme
         if (file_exists(_PS_THEME_DIR_ . 'css/modules/leosliderlayer/css/typo.css')) {
             $typoDir = _THEME_DIR_ . 'css/' . str_replace('//', '/', 'modules/leosliderlayer') . '/css/typo.css';
         } else {
             $typoDir = __PS_BASE_URI__ . str_replace('//', '/', 'modules/leosliderlayer') . '/css/typo.css';
         }
         $this->addCss($typoDir, 'all');
         $this->addJS(__PS_BASE_URI__ . 'modules/leosliderlayer/assets/admin/jquery-ui-1.10.3.custom.min.js');
         $content = Tools::file_get_contents($this->context->link->getMediaLink($typoDir));
         preg_match_all('#\\.tp-caption\\.(\\w+)\\s*{\\s*#', $content, $matches);
         if (isset($matches[1])) {
             $captions = $matches[1];
         }
         $tpl = $this->createTemplate('typo.tpl');
         $tpl->assign(array('typoDir' => $typoDir, 'captions' => $captions, 'field' => Tools::getValue('field')));
         return $tpl->fetch();
     }
     //this code for select or upload IMG
     $tpl = $this->createTemplate('imagemanager.tpl');
     $sortBy = Tools::getValue('sortBy');
     $reloadSliderImage = Tools::getValue('reloadSliderImage');
     $images = $this->getImageList($sortBy);
     $tpl->assign(array('images' => $images, 'reloadSliderImage' => $reloadSliderImage));
     if ($reloadSliderImage) {
         die(Tools::jsonEncode($tpl->fetch()));
     }
     $image_uploader = new HelperImageUploader('file');
     $image_uploader->setSavePath($this->img_path);
     $url = Context::getContext()->link->getAdminLink('AdminLeoSliderLayer') . '&ajax=1&action=addSliderImage';
     $image_uploader->setMultiple(true)->setUseAjax(true)->setUrl($url);
     $tpl->assign(array('countImages' => count($images), 'images' => $images, 'max_image_size' => $this->max_image_size / 1024 / 1024, 'image_uploader' => $image_uploader->render(), 'imgManUrl' => Context::getContext()->link->getAdminLink('AdminLeoSliderLayer'), 'token' => $this->token, 'imgUploadDir' => $this->img_path));
     return $tpl->fetch();
 }
Esempio n. 4
0
 public function hookDisplayBackOfficeCategory($params)
 {
     $category = new Category((int) Tools::getValue('id_category'));
     $files = array();
     if ($category->level_depth < 1) {
         return;
     }
     for ($i = 0; $i < 3; $i++) {
         if (file_exists(_PS_CAT_IMG_DIR_ . (int) $category->id . '-' . $i . '_thumb.jpg')) {
             $files[$i]['type'] = HelperImageUploader::TYPE_IMAGE;
             $files[$i]['image'] = ImageManager::thumbnail(_PS_CAT_IMG_DIR_ . (int) $category->id . '-' . $i . '_thumb.jpg', $this->context->controller->table . '_' . (int) $category->id . '-' . $i . '_thumb.jpg', 100, 'jpg', true, true);
             $files[$i]['delete_url'] = Context::getContext()->link->getAdminLink('AdminBlockCategories') . '&deleteThumb=' . $i . '&id_category=' . (int) $category->id;
         }
     }
     $helper = new HelperImageUploader();
     $helper->setMultiple(true)->setUseAjax(true)->setName('thumbnail')->setFiles($files)->setMaxFiles(3)->setUrl(Context::getContext()->link->getAdminLink('AdminBlockCategories') . '&ajax=1&id_category=' . $category->id . '&action=uploadThumbnailImages');
     $this->smarty->assign('helper', $helper->render());
     return $this->display(__FILE__, 'views/blockcategories_admin.tpl');
 }
Esempio n. 5
0
    public function initFormImages($obj)
    {
        $data = $this->createTemplate($this->tpl_form);
        if ((bool) $obj->id) {
            if ($this->product_exists_in_shop) {
                $data->assign('product', $this->loadObject());
                $shops = false;
                if (Shop::isFeatureActive()) {
                    $shops = Shop::getShops();
                }
                if ($shops) {
                    foreach ($shops as $key => $shop) {
                        if (!$obj->isAssociatedToShop($shop['id_shop'])) {
                            unset($shops[$key]);
                        }
                    }
                }
                $data->assign('shops', $shops);
                $count_images = Db::getInstance()->getValue('
					SELECT COUNT(id_product)
					FROM ' . _DB_PREFIX_ . 'image
					WHERE id_product = ' . (int) $obj->id);
                $images = Image::getImages($this->context->language->id, $obj->id);
                foreach ($images as $k => $image) {
                    $images[$k] = new Image($image['id_image']);
                }
                if ($this->context->shop->getContext() == Shop::CONTEXT_SHOP) {
                    $current_shop_id = (int) $this->context->shop->id;
                } else {
                    $current_shop_id = 0;
                }
                $languages = Language::getLanguages(true);
                $image_uploader = new HelperImageUploader('file');
                $image_uploader->setMultiple(!(Tools::getUserBrowser() == 'Apple Safari' && Tools::getUserPlatform() == 'Windows'))->setUseAjax(true)->setUrl(Context::getContext()->link->getAdminLink('AdminProducts') . '&ajax=1&id_product=' . (int) $obj->id . '&action=addProductImage');
                $data->assign(array('countImages' => $count_images, 'id_product' => (int) Tools::getValue('id_product'), 'id_category_default' => (int) $this->_category->id, 'images' => $images, 'iso_lang' => $languages[0]['iso_code'], 'token' => $this->token, 'table' => $this->table, 'max_image_size' => $this->max_image_size / 1024 / 1024, 'up_filename' => (string) Tools::getValue('virtual_product_filename_attribute'), 'currency' => $this->context->currency, 'current_shop_id' => $current_shop_id, 'languages' => $this->_languages, 'default_language' => (int) Configuration::get('PS_LANG_DEFAULT'), 'image_uploader' => $image_uploader->render()));
                $type = ImageType::getByNameNType('%', 'products', 'height');
                if (isset($type['name'])) {
                    $data->assign('imageType', $type['name']);
                } else {
                    $data->assign('imageType', 'small_default');
                }
            } else {
                $this->displayWarning($this->l('You must save the product in this shop before adding images.'));
            }
        } else {
            $this->displayWarning($this->l('You must save this product before adding images.'));
        }
        $this->tpl_form_vars['custom_form'] = $data->fetch();
    }
 public function renderForm()
 {
     $this->post_format_fields = smartblog::$post_meta_fields;
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     $shops = false;
     if (Shop::isFeatureActive()) {
         $shops = Shop::getShops();
     }
     if ($shops) {
         foreach ($shops as $key => $shop) {
             if (!$obj->isAssociatedToShop($shop['id_shop'])) {
                 unset($shops[$key]);
             }
         }
     }
     $languages = Language::getLanguages(false);
     //Added From Old
     /*         * ************* featured image ****************** */
     $featured_image = _MODULE_SMARTBLOG_DIR_ . $obj->id . '.jpg';
     $image_url = ImageManager::thumbnail($featured_image, $this->table . '_' . pSQL(Tools::getvalue('id_smart_blog_post')) . '.jpg', 200, 'jpg', true, true);
     $image_size = file_exists($featured_image) ? filesize($featured_image) / 1000 : false;
     /*         * ************* featured image ****************** */
     // image gallary
     $id_smart_blog_post = (int) Tools::getValue('id_smart_blog_post');
     $images = SmartBlogGallaryImage::getImages($this->context->language->id, $id_smart_blog_post);
     foreach ($images as $k => $image) {
         $images[$k] = new SmartBlogGallaryImage($image['id_smart_blog_gallary_images']);
     }
     //start sdsimage type
     $image_uploader = new HelperImageUploader('file');
     $image_uploader->setMultiple(!(Tools::getUserBrowser() == 'Apple Safari' && Tools::getUserPlatform() == 'Windows'))->setUseAjax(true)->setUrl(Context::getContext()->link->getAdminLink('AdminSmartBlogAjax') . '&ajax=1&id_smart_blog_post=' . (int) Tools::getvalue('id_smart_blog_post') . '&action=addGallaryImage');
     // test code
     $root = BlogCategory::getRootCategory();
     $default_category = $root['id_smart_blog_category'];
     if (!Tools::isSubmit('id_smart_blog_post')) {
         $selected_cat = BlogCategory::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->default_form_language);
     } else {
         if (Tools::isSubmit('categoryBox')) {
             $selected_cat = BlogCategory::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->default_form_language);
         } else {
             $selected_cat = BlogCategory::getPostCategoriesFull((int) Tools::getValue('id_smart_blog_post'), $this->default_form_language);
         }
     }
     $categories = array();
     foreach ($selected_cat as $key => $category) {
         $categories[] = $key;
     }
     $tree = new SmartBlogHelperTreeCategories('smartblog-associated-categories-tree', 'Associated categories');
     $tree->setTemplate('tree_associated_categories.tpl')->setHeaderTemplate('tree_associated_header.tpl')->setRootCategory((int) $root['id_category'])->setUseCheckBox(true)->setUseSearch(false)->setSelectedCategories($categories);
     // end test code
     $temp_employees = Employee::getEmployees();
     $employees = array();
     foreach ($temp_employees as $employee) {
         $employee['fullname'] = $employee['firstname'] . ' ' . $employee['lastname'];
         $employee['id_select'] = $employee['id_employee'];
         $employees[] = $employee;
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Blog Post')), 'input' => array(array('type' => 'text', 'label' => $this->l('Blog Title'), 'name' => 'meta_title', 'id' => 'name', 'class' => 'copyMeta2friendlyURL', 'size' => 60, 'required' => true, 'desc' => $this->l('Enter Your Blog Post Title'), 'lang' => true), array('type' => 'select', 'label' => $this->l('Author'), 'name' => 'id_author', 'options' => array('query' => $employees, 'id' => 'id_select', 'name' => 'fullname')), array('type' => 'textarea', 'label' => $this->l('Description'), 'name' => 'content', 'lang' => true, 'rows' => 10, 'cols' => 62, 'class' => 'rte', 'autoload_rte' => true, 'desc' => $this->l('Enter Your Post Description')), array('type' => 'file', 'label' => $this->l('Featured Image:'), 'name' => 'image', 'display_image' => true, 'image' => $image_url ? $image_url : false, 'size' => $image_size, 'delete_url' => self::$currentIndex . '&' . $this->identifier . '=' . pSQL(Tools::getvalue('id_smart_blog_post')) . '&token=' . $this->token . '&deleteImage=1', 'hint' => $this->l('Upload a feature image from your computer.')), array('type' => 'html', 'label' => $this->l('Blog Categories'), 'name' => 'id_category_big', 'required' => true, 'html_content' => $tree->render(), 'desc' => $this->l('Select Your Parent Category')), array('type' => 'text', 'label' => $this->l('Meta Keyword'), 'name' => 'meta_keyword', 'lang' => true, 'size' => 60, 'required' => false, 'desc' => $this->l('Enter Your Post Meta Keyword. Separated by comma(,)')), array('type' => 'textarea', 'label' => $this->l('Short Description'), 'name' => 'short_description', 'rows' => 10, 'cols' => 62, 'lang' => true, 'required' => true, 'desc' => $this->l('Enter Your Post Short Description')), array('type' => 'textarea', 'label' => $this->l('Meta Description'), 'name' => 'meta_description', 'rows' => 10, 'cols' => 62, 'lang' => true, 'required' => false, 'desc' => $this->l('Enter Your Post Meta Description')), array('type' => 'text', 'label' => $this->l('Link Rewrite'), 'name' => 'link_rewrite', 'size' => 60, 'lang' => true, 'required' => false, 'desc' => $this->l('Enetr Your Post Slug. Use In SEO Friendly URL')), array('type' => 'tags', 'label' => $this->l('Tag'), 'name' => 'tags', 'size' => 60, 'lang' => true, 'required' => false, 'hint' => array($this->l('To add "tags" click in the field, write something, and then press "Enter."'), $this->l('Invalid characters:') . ' &lt;&gt;;=#{}')), array('type' => 'switch', 'label' => $this->l('Comment Status'), 'name' => 'comment_status', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('You Can Enable or Disable Your Comments')), array('label' => $this->l('Published Date'), 'name' => 'created', 'title' => $this->l('Published date'), 'type' => 'datetime'), array('type' => 'associations', 'label' => $this->l('Related Product(s)'), 'name' => 'associations', 'size' => 60, 'lang' => true, 'required' => false), array('type' => 'switch', 'label' => $this->l('Status'), 'name' => 'active', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'switch', 'label' => $this->l('Is Featured?'), 'name' => 'is_featured', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))))), 'gallary' => array('images' => array('count' => count($images), 'max_image_size' => $this->max_image_size / 1024 / 1024, 'table' => $this->table, 'images' => $images, 'id_smart_blog_post' => (int) Tools::getValue('id_smart_blog_post'), 'object' => $this->object, 'image_uploader' => $image_uploader->render())));
     $this->fields_form['input'][] = array('type' => 'radio', 'label' => $this->l('Post Format'), 'name' => 'post_type', 'required' => true, 'values' => array(array('id' => 'post_type_default', 'value' => '', 'label' => '<i class="icon-home"></i> ' . $this->l('None')), array('id' => 'post_type_gallery', 'value' => 'gallery', 'label' => '<i class="icon-picture"></i> ' . $this->l('Gallery')), array('id' => 'post_type_audio', 'value' => 'audio', 'label' => '<i class="icon-music"></i> ' . $this->l('Audio')), array('id' => 'post_type_video', 'value' => 'video', 'label' => '<i class="icon-film"></i> ' . $this->l('Video')), array('id' => 'post_type_quote', 'value' => 'quote', 'label' => '<i class="icon-quote-left"></i> ' . $this->l('Quote')), array('id' => 'post_type_link', 'value' => 'link', 'label' => '<i class="icon-link"></i> ' . $this->l('Link'))));
     $this->fields_form['input'][] = array('type' => 'html', 'label' => $this->l('Post Format Fields'), 'name' => 'post_format_fields', 'html_content' => $this->AdminMetaFields(), 'desc' => $this->l('Set exclusive fields for the post format'));
     if (Shop::isFeatureActive()) {
         $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso');
     }
     if (!($SmartBlogPost = $this->loadObject(true))) {
         return;
     }
     $this->fields_form['submit'] = array('title' => $this->l('Save'));
     $image = ImageManager::thumbnail(_MODULE_SMARTBLOG_DIR_ . $SmartBlogPost->id_smart_blog_post . '.jpg', $this->table . '_' . (int) $SmartBlogPost->id_smart_blog_post . '.' . $this->imageType, 350, $this->imageType, true);
     $this->fields_value = array('image' => $image ? $image : false, 'size' => $image ? filesize(_MODULE_SMARTBLOG_DIR_ . $SmartBlogPost->id_smart_blog_post . '.jpg') / 1000 : false);
     if (Tools::getvalue('id_smart_blog_post') != '' && Tools::getvalue('id_smart_blog_post') != NULL) {
         foreach (Language::getLanguages(false) as $lang) {
             $this->fields_value['tags'][(int) $lang['id_lang']] = SmartBlogPost::getProductTagsBylang((int) Tools::getvalue('id_smart_blog_post'), (int) $lang['id_lang']);
         }
     }
     $this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
     // related product using Accessories block
     $accessories = SmartBlogPost::getAccessoriesLight($this->context->language->id, $SmartBlogPost->id_smart_blog_post);
     if ($post_accessories = Tools::getValue('inputAccessories')) {
         $post_accessories_tab = explode('-', $post_accessories);
         foreach ($post_accessories_tab as $accessory_id) {
             if (!$this->haveThisAccessory($accessory_id, $accessories) && ($accessory = Product::getAccessoryById($accessory_id))) {
                 $accessories[] = $accessory;
             }
         }
     }
     $this->tpl_form_vars['accessories'] = $accessories;
     /* image gallary */
     $this->tpl_form_vars['images'] = $images;
     $this->tpl_form_vars['image_uploader'] = $image_uploader->render();
     $this->tpl_form_vars['max_image_size'] = $this->max_image_size / 1024 / 1024;
     $this->tpl_form_vars['languages'] = $languages;
     $this->tpl_form_vars['iso_lang'] = $languages[0]['iso_code'];
     $this->tpl_form_vars['imageType'] = 'home-small';
     $this->tpl_form_vars['id_smart_blog_post'] = (int) Tools::getValue('id_smart_blog_post');
     $this->tpl_form_vars['default_language'] = (int) Configuration::get('PS_LANG_DEFAULT');
     $this->tpl_form_vars['table'] = $this->table;
     $this->tpl_form_vars['token'] = Tools::getAdminTokenLite('AdminBlogPost');
     $this->tpl_form_vars['gallary_path'] = _MODULE_DIR_ . 'smartblog/gallary/';
     // $this->tpl_form_vars['token_book'] = Tools::getAdminTokenLite('AdminBook');
     return parent::renderForm();
 }
 public function renderForm()
 {
     $this->initFormToolbar();
     if (!$this->loadObject(true)) {
         return;
     }
     $obj = $this->loadObject(true);
     /**
     
     
                 POST IMAGES
     
     
             **/
     $cover = false;
     $featured = false;
     if (isset($obj->id)) {
         $this->display = 'edit';
         $cover = ImageManager::thumbnail(_PS_MODULE_DIR_ . 'ph_simpleblog/covers/' . $obj->id . '.' . $obj->cover, 'ph_simpleblog_' . $obj->id . '.' . $obj->cover, 350, $obj->cover, false);
         $featured = ImageManager::thumbnail(_PS_MODULE_DIR_ . 'ph_simpleblog/featured/' . $obj->id . '.' . $obj->featured, 'ph_simpleblog_featured_' . $obj->id . '.' . $obj->featured, 350, $obj->featured, false);
     } else {
         $this->display = 'add';
     }
     $this->fields_value = array('cover' => $cover ? $cover : false, 'cover_size' => $cover ? filesize(_PS_MODULE_DIR_ . 'ph_simpleblog/covers/' . $obj->id . '.' . $obj->cover) / 1000 : false, 'featured' => $featured ? $featured : false, 'featured_size' => $featured ? filesize(_PS_MODULE_DIR_ . 'ph_simpleblog/featured/' . $obj->id . '.' . $obj->featured) / 1000 : false);
     /**
     
     
                 POST TAGS
                 
     
             **/
     $obj->tags = SimpleBlogTag::getPostTags($obj->id);
     /**
     
     
                 GLOBAL $
                 
     
             **/
     $this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
     $this->tpl_form_vars['languages'] = $this->_languages;
     $this->tpl_form_vars['simpleblogpost'] = $obj;
     $this->tpl_form_vars['is_16'] = $this->is_16;
     /**
     
     
                 POST ACCESS
                 
     
             **/
     if (isset($obj->id) && $obj->access) {
         $groupAccess = unserialize($obj->access);
         foreach ($groupAccess as $groupAccessID => $value) {
             $groupBox = 'groupBox_' . $groupAccessID;
             $this->fields_value[$groupBox] = $value;
         }
     } else {
         $groups = Group::getGroups($this->context->language->id);
         $preselected = array(Configuration::get('PS_UNIDENTIFIED_GROUP'), Configuration::get('PS_GUEST_GROUP'), Configuration::get('PS_CUSTOMER_GROUP'));
         foreach ($groups as $group) {
             $this->fields_value['groupBox_' . $group['id_group']] = in_array($group['id_group'], $preselected);
         }
     }
     /**
     
             Default publication date for new posts
     
             **/
     if (!isset($obj->id)) {
         $this->fields_value['date_add'] = date('Y-m-d H:i:s');
     }
     $available_categories = SimpleBlogCategory::getCategories($this->context->language->id, true, false);
     foreach ($available_categories as &$category) {
         if ($category['is_child']) {
             $category['name'] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $category['name'];
         }
     }
     $i = 0;
     $this->fields_form[$i]['form'] = array('legend' => array('title' => $this->l('SimpleBlog Post'), 'icon' => 'icon-folder-close'), 'input' => array(array('type' => 'select', 'label' => $this->l('Post type:'), 'name' => 'id_simpleblog_post_type', 'required' => true, 'options' => array('id' => 'id_simpleblog_post_type', 'query' => SimpleBlogPostType::getAll(), 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Category:'), 'name' => 'id_simpleblog_category', 'required' => true, 'options' => array('id' => 'id', 'query' => $available_categories, 'name' => 'name')), array('type' => 'text', 'label' => $this->l('Author:'), 'name' => 'author'), array('type' => 'text', 'label' => $this->l('Title:'), 'name' => 'title', 'required' => true, 'lang' => true, 'id' => 'name', 'class' => 'copyNiceUrl'), array('type' => 'textarea', 'label' => $this->l('Short content:'), 'name' => 'short_content', 'lang' => true, 'rows' => 5, 'cols' => 40, 'autoload_rte' => true), array('type' => 'textarea', 'label' => $this->l('Full post content:'), 'name' => 'content', 'lang' => true, 'rows' => 15, 'cols' => 40, 'autoload_rte' => true), array('type' => 'tags', 'label' => $this->l('Tags:'), 'desc' => $this->l('separate by comma for eg. ipod, apple, something'), 'name' => 'tags', 'required' => false, 'lang' => true), array('type' => 'switch', 'label' => $this->l('Featured?'), 'name' => 'is_featured', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'is_featured_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'is_featured_off', 'value' => 0, 'label' => $this->l('No')))), array('type' => 'switch', 'label' => $this->l('Displayed:'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'radio', 'label' => $this->l('Allow comments?'), 'name' => 'allow_comments', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'allow_comments_1', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'allow_comments_2', 'value' => 2, 'label' => $this->l('No')), array('id' => 'allow_comments_3', 'value' => 3, 'label' => $this->l('Use global setting'))))), 'submit' => array('title' => $this->l('Save and stay'), 'class' => 'button', 'stay' => true));
     $i++;
     if (isset($obj->id)) {
         $this->addjQueryPlugin(array('thickbox', 'ajaxfileupload'));
         // Get images
         $images = SimpleBlogPostImage::getAllById($obj->id);
         foreach ($images as $k => $image) {
             $images[$k] = new SimpleBlogPostImage($image['id_simpleblog_post_image']);
         }
         $image_uploader = new HelperImageUploader('file');
         $image_uploader->setMultiple(!(Tools::getUserBrowser() == 'Apple Safari' && Tools::getUserPlatform() == 'Windows'))->setUseAjax(true)->setUrl(Context::getContext()->link->getAdminLink('AdminSimpleBlogPosts') . '&ajax=1&id_simpleblog_post=' . (int) $obj->id . '&action=addPostImages');
         $this->tpl_form_vars['images'] = $images;
         $this->tpl_form_vars['image_uploader'] = $image_uploader->render();
         $this->fields_form[$i]['form'] = array('legend' => array('title' => $this->l('Post type options'), 'icon' => 'icon-folder-close'), 'input' => array(array('type' => 'text', 'label' => $this->l('External URL:'), 'name' => 'external_url', 'form_group_class' => 'simpleblog-post-type simpleblog-post-type-' . SimpleBlogPostType::getIdBySlug('url'), 'lang' => true), array('type' => 'textarea', 'label' => $this->l('Video embed code:'), 'name' => 'video_code', 'lang' => true, 'form_group_class' => 'simpleblog-post-type simpleblog-post-type-' . SimpleBlogPostType::getIdBySlug('video'), 'desc' => $this->l('Remember to "Allow iframes on HTML fields" in Preferences -> General')), array('type' => 'file', 'multiple' => true, 'ajax' => true, 'name' => 'post_images', 'label' => $this->l('Add images to gallery'), 'required' => false, 'lang' => false, 'form_group_class' => 'simpleblog-post-type simpleblog-post-type-' . SimpleBlogPostType::getIdBySlug('gallery'))), 'submit' => array('title' => $this->l('Save and stay'), 'class' => 'button', 'stay' => true));
         $i++;
     } else {
         $this->fields_form[$i]['form'] = array('legend' => array('title' => $this->l('Post type options'), 'icon' => 'icon-folder-close'), 'description' => $this->l('Specific post type options will be available after saving post'));
         $i++;
     }
     $this->fields_form[$i]['form'] = array('legend' => array('title' => $this->l('Post Images'), 'image' => $this->is_16 ? null : '../img/t/AdminImages.gif', 'icon' => 'icon-picture'), 'input' => array(array('type' => 'file', 'label' => $this->l('Post cover:'), 'display_image' => true, 'name' => 'cover', 'desc' => $this->l('Upload a image from your computer.')), array('type' => 'file', 'label' => $this->l('Post featured image:'), 'display_image' => true, 'name' => 'featured', 'desc' => $this->l('Upload a image from your computer. Featured image will be displayed only if you want on the single post page.'))), 'submit' => array('title' => $this->l('Save and stay'), 'class' => 'button', 'stay' => true));
     $i++;
     $available_products = self::getSimpleProducts($this->context->language->id);
     foreach ($available_products as &$available_related_product) {
         if (empty($available_related_product['product_name'])) {
             if (isset($available_related_product['name']) && !empty($available_related_product['name'])) {
                 $available_related_product['product_name'] = $available_related_product['name'];
             }
         }
     }
     $this->fields_form[$i]['form'] = array('legend' => array('title' => $this->l('Related products')), 'input' => array(array('type' => 'select', 'label' => $this->l('Product:'), 'name' => 'id_product[]', 'id' => 'select_product', 'multiple' => true, 'required' => false, 'options' => array('id' => 'id_product', 'query' => $available_products, 'name' => 'product_name'))), 'submit' => array('title' => $this->l('Save and stay'), 'class' => 'button', 'stay' => true));
     $i++;
     $this->fields_value['id_product[]'] = explode(',', $obj->id_product);
     $this->fields_form[$i]['form'] = array('legend' => array('title' => $this->l('SEO'), 'icon' => 'icon-folder-close'), 'input' => array(array('type' => 'text', 'label' => $this->l('Meta title:'), 'name' => 'meta_title', 'lang' => true), array('type' => 'text', 'label' => $this->l('Meta description:'), 'name' => 'meta_description', 'lang' => true), array('type' => 'text', 'label' => $this->l('Meta keywords:'), 'name' => 'meta_keywords', 'lang' => true), array('type' => 'text', 'label' => $this->l('Friendly URL:'), 'name' => 'link_rewrite', 'required' => true, 'lang' => true)), 'submit' => array('title' => $this->l('Save and stay'), 'class' => 'button', 'stay' => true));
     $i++;
     $unidentified = new Group(Configuration::get('PS_UNIDENTIFIED_GROUP'));
     $guest = new Group(Configuration::get('PS_GUEST_GROUP'));
     $default = new Group(Configuration::get('PS_CUSTOMER_GROUP'));
     $unidentified_group_information = sprintf($this->l('%s - All people without a valid customer account.'), '<b>' . $unidentified->name[$this->context->language->id] . '</b>');
     $guest_group_information = sprintf($this->l('%s - Customer who placed an order with the guest checkout.'), '<b>' . $guest->name[$this->context->language->id] . '</b>');
     $default_group_information = sprintf($this->l('%s - All people who have created an account on this site.'), '<b>' . $default->name[$this->context->language->id] . '</b>');
     $this->fields_form[$i]['form'] = array('legend' => array('title' => $this->l('Availability')), 'input' => array(array('type' => 'datetime', 'label' => $this->l('Publication date:'), 'name' => 'date_add', 'desc' => $this->l('Remember to set correctly your timezone in Simple Blog -> Settings. Current timezone:') . ' ' . Configuration::get('PH_BLOG_TIMEZONE') . ', ' . $this->l('current time with this setting:') . ' ' . SimpleBlogHelper::now(Configuration::get('PH_BLOG_TIMEZONE')), 'required' => true), array('type' => 'group', 'label' => $this->l('Group access'), 'name' => 'groupBox', 'values' => Group::getGroups(Context::getContext()->language->id), 'info_introduction' => $this->l('You now have three default customer groups.'), 'unidentified' => $unidentified_group_information, 'guest' => $guest_group_information, 'customer' => $default_group_information, 'hint' => $this->l('Mark all of the customer groups which you would like to have access to this category.'))), 'submit' => array('title' => $this->l('Save and stay'), 'class' => 'button', 'stay' => true));
     $i++;
     if (Shop::isFeatureActive()) {
         $this->fields_form[$i]['form'] = array('legend' => array('title' => $this->l('Shop association:')), 'input' => array(array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso')));
     }
     $this->multiple_fieldsets = true;
     return parent::renderForm();
 }