예제 #1
0
 public function renderCategoryTree($root = null, $selected_cat = array(), $input_name = 'categoryBox', $use_radio = false, $use_search = false, $disabled_categories = array(), $use_in_popup = false, $use_shop_context = false)
 {
     global $cookie;
     $html = parent::renderCategoryTree($root, $selected_cat, $input_name, $use_radio, $use_search, $disabled_categories, $use_in_popup, $use_shop_context);
     if (Module::isInstalled('agilemultipleseller') and !(int) Configuration::get('AGILE_MS_ALLOW_REGISTER_ATHOME')) {
         if ((int) $cookie->id_employee == 0 or (int) $cookie->profile == (int) Configuration::get('AGILE_MS_PROFILE_ID')) {
             require_once _PS_ROOT_DIR_ . "/modules/agilemultipleseller/agilemultipleseller.php";
             $html .= AgileMultipleSeller::jsForHideHome();
         }
     }
     return $html;
 }
예제 #2
0
    public function renderForm()
    {
        $form_output = '';
        $defaultLanguage = $this->default_form_language;
        if (!$this->loadObject(true)) {
            return;
        }
        $obj = $this->object;
        $lang_value = $this->default_form_language;
        $activeLanguages = Language::getLanguages(true);
        $form_output .= '<form class="defaultForm adminposts" id="' . $this->table . '_form" action="' . self::$currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post" enctype="multipart/form-data">
                            ' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '');
        $form_output .= '</fieldset><div class="clear space">&nbsp;</div>

                    <fieldset>
                        
                    <legend><img src="../img/admin/translation.gif"> ' . $this->l('Content') . '</legend>';
        if (count($activeLanguages) > 1) {
            $lang_options = array();
            foreach ($activeLanguages as $l) {
                $lang_options[] = array('value' => $l['id_lang'], 'title' => $l['name']);
            }
            $lang_options[] = array('value' => 0, 'title' => $this->l('All languages'));
            $form_output .= HelperFieldFormNew::displaySelectField('id_lang', $lang_options, $lang_value, $this->l('Language :'));
        } else {
            $form_output .= '<input type="hidden" name="id_lang" value="0" />';
        }
        $form_output .= HelperFieldFormNew::displayTextField('title', $this->getFieldValue($obj, 'title'), 'text', $this->l('Title :'), NULL, array('required' => true, 'class' => 'copy2friendlyBlogUrl', 'id' => 'title_' . $lang_value));
        $form_output .= HelperFieldFormNew::displayTextField('description', $this->getFieldValue($obj, 'description'), 'textarea', $this->l('Description :'), NULL, array('tinymce' => true));
        $form_output .= '</fieldset><div class="clear space">&nbsp;</div>';
        // MEDIAS
        $form_output .= '<fieldset>
                            <legend><img src="../img/admin/picture.gif"> ' . $this->l('Medias') . '</legend>
                            <label>' . $this->l('Images :') . ' </label>
                            <div class="margin-form">
                                <input type="file" accept="gif|jpg|png" maxlength="' . $this->conf['nb_max_img'] . '" id="img" name="img" /> .jpg, .png, .gif
                            </div>
                            <div class="margin-form" id="blog-img-list"></div>
                            
                            <div class="margin-form">';
        $relative = rtrim($this->conf['img_save_path'], '/') . "/";
        $images = $this->getFieldValue($obj, 'img');
        if ($images) {
            $form_output .= ' <img src="' . __PS_BASE_URI__ . $relative . 'thumb/' . $images . '" alt="' . $images . '" style="max-height:200px;" />';
        }
        $form_output .= '</fieldset>';
        $form_output .= '<div class="clear space">&nbsp;</div>';
        // CATEGORIES
        $form_output .= '<fieldset><legend><img src="../img/admin/tab-categories.gif"> ' . $this->l('Categories') . '</legend>';
        $form_output .= '<label>&nbsp;</label>
					<div class="margin-form"> ';
        $post_categories = Tools::getValue('groupBox', $obj->getCategories());
        $categories = PhotosCategory::listCategories(false, false);
        if (is_array($categories) && count($categories)) {
            $form_output .= '<table cellspacing="0" cellpadding="0" class="table" style="min-width:500px;">
                                <tr>
                                    <th style="width:40px;"><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'groupBox[]\', this.checked)" /></th>
                                    <th style="width:30px;">' . $this->l('ID') . '</th>
                                    <th>' . $this->l('Category name') . '</th>
                                </tr>';
            $irow = 0;
            foreach ($categories as $cat) {
                $form_output .= '
                                    <tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '">
                                            <td><input type="checkbox" name="groupBox[]" class="groupBox" id="groupBox_' . $cat['id_photo_cat'] . '" value="' . $cat['id_photo_cat'] . '" ' . (in_array($cat['id_photo_cat'], $post_categories) ? 'checked="checked" ' : '') . '/></td>
                                            <td>' . $cat['id_photo_cat'] . '</td>
                                            <td><label for="groupBox_' . $cat['id_photo_cat'] . '" class="t">' . $cat['name'] . ' ' . (count($activeLanguages) > 1 && $cat['iso_code'] != '' ? '(' . $cat['iso_code'] . ')' : '') . ' </label></td>
                                    </tr>';
            }
            $form_output .= '
                                </table>
                                <p style="padding:0px; margin:10px 0px 10px 0px;">' . $this->l('Mark all checkbox(es) of categories to which the photo is to be in') . '</p>';
        } else {
            $form_output .= '<p>' . $this->l('No category created') . '</p>';
        }
        $form_output .= '</div>';
        $form_output .= '</fieldset><div class="clear space">&nbsp;</div>';
        $helper = new HelperCore();
        $helper->module = new MyPhotos();
        $template = $helper->createTemplate('form_photo.tpl');
        $iso_code = $this->context->language->iso_code;
        $iso = file_exists(_PS_ROOT_DIR_ . '/js/tiny_mce/langs/' . $iso_code . '.js') ? $iso_code : 'en';
        $iso_tiny_mce = file_exists(_PS_JS_DIR_ . 'tiny_mce/langs/' . $iso_code . '.js') ? $iso_code : 'en';
        $this->addjQueryPlugin(array('autocomplete', 'ajaxfileupload', 'date'));
        $this->addJS(array(_MODULE_DIR_ . $this->module->name . '/js/photo.js', _MODULE_DIR_ . $this->module->name . '/js/jquery.MultiFile.pack.js', _PS_JS_DIR_ . 'tiny_mce/tiny_mce.js', _PS_JS_DIR_ . 'tinymce.inc.js', _PS_JS_DIR_ . 'fileuploader.js'));
        $this->addJqueryUI(array('ui.core', 'ui.datepicker'));
        $this->toolbar_btn['save-and-stay'] = array('href' => '#', 'desc' => $this->l('Save and stay'));
        $title = array($this->l('Photo'), $obj->id ? $this->l('Edit') : $this->l('Add new'));
        $template->assign(array('show_toolbar' => true, 'path_css' => _THEME_CSS_DIR_, 'toolbar_btn' => $this->toolbar_btn, 'currentIndex' => self::$currentIndex, 'toolbar_scroll' => true, 'title' => $title, 'ad' => dirname($_SERVER['PHP_SELF']), 'form_content' => $form_output, 'iso_tiny_mce' => $iso_tiny_mce, 'iso' => $iso, 'tinymce' => true, 'vat_number' => file_exists(_PS_MODULE_DIR_ . 'vatnumber/ajax.php'), 'languages' => $this->_languages, 'id_lang_default' => $defaultLanguage, 'defaultFormLanguage' => $defaultLanguage, 'allowEmployeeFormLang' => $this->allow_employee_form_lang));
        $form_content = $template->fetch();
        return $form_content;
    }
예제 #3
0
    public function renderForm()
    {
        $form_output = '';
        $defaultLanguage = $this->default_form_language;
        if (!$this->loadObject(true)) {
            return;
        }
        $obj = $this->object;
        $lang_value = $this->default_form_language;
        $activeLanguages = Language::getLanguages(true);
        $form_output .= '<form class="defaultForm adminposts" id="' . $this->table . '_form" action="' . self::$currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post" enctype="multipart/form-data">
                            ' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '');
        $form_output .= '</fieldset><div class="clear space">&nbsp;</div>

                    <fieldset>
                        
                    <legend><img src="../img/admin/translation.gif"> ' . $this->l('Content') . '</legend>';
        if (count($activeLanguages) > 1) {
            $lang_options = array();
            foreach ($activeLanguages as $l) {
                $lang_options[] = array('value' => $l['id_lang'], 'title' => $l['name']);
            }
            $lang_options[] = array('value' => 0, 'title' => $this->l('All languages'));
            $form_output .= HelperFieldForm::displaySelectField('id_lang', $lang_options, $obj->id_lang, $this->l('Language :'));
        } else {
            $form_output .= '<input type="hidden" name="id_lang" value="0" />';
        }
        $form_output .= HelperFieldForm::displayTextField('title', $this->getFieldValue($obj, 'title'), 'text', $this->l('Title :'), NULL, array('required' => true, 'class' => 'copy2friendlyBlogUrl', 'id' => 'title_' . $lang_value));
        $form_output .= HelperFieldForm::displayTextField('excerpt', $this->getFieldValue($obj, 'excerpt'), 'textarea', $this->l('Excerpt :'), $this->l('Article summary for lists'), array('rows' => 3));
        $form_output .= HelperFieldForm::displayTextField('content', $this->getFieldValue($obj, 'content'), 'textarea', $this->l('Content :'), NULL, array('tinymce' => true));
        $form_output .= '</fieldset><div class="clear space">&nbsp;</div>';
        // MEDIAS
        $form_output .= '<fieldset>
                            <legend><img src="../img/admin/picture.gif"> ' . $this->l('Medias') . '</legend>
                            <label>' . $this->l('Images/Videos :') . ' </label>
                            <div class="margin-form">
                                <input type="file" accept="gif|jpg|png|mp4|flv|wmv" maxlength="' . $this->conf['nb_max_img'] . '" id="blog_img" name="blog_img[]" /> .jpg, .png, .gif, .mp4, .flv, .wmv
                            </div>
                            <div class="margin-form" id="blog-img-list"></div>
                            
                            <div class="margin-form">';
        $relative = rtrim($this->conf['img_save_path'], '/') . "/";
        $images = Tools::getValue('id_blog_post') ? $obj->getImages() : array();
        if (count($images)) {
            $form_output .= '<table class="table" cellpadding="0" cellspacing="0" style="min-width:700px;">
                                        <tr>
                                        <th>' . $this->l('Image/Video') . '</th>
                                        <th>' . $this->l('Default') . '</th>
                                        <th>' . $this->l('Position') . '</th>
                                        <th>' . $this->l('Delete') . '</th>
                                        </tr>';
            $irow = 0;
            foreach ($images as $val) {
                $filename = $val['img_name'];
                if (file_exists(_PS_ROOT_DIR_ . "/" . $relative . $filename)) {
                    $form_output .= '<tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '">
                                                    <td><img src="' . __PS_BASE_URI__ . $relative . 'thumb/' . $filename . '" alt="' . $filename . '" style="max-height:200px;" /></td>
                                                    <td><input type="radio" id="blog_img_default_' . $val['id_blog_image'] . '" name="blog_img_default" ' . (intval($val['default']) == 1 ? 'checked' : '') . ' value="' . $val['id_blog_image'] . '" /></td>
                                                    <td><input type="text" name="img_pos[' . $val['id_blog_image'] . ']" value="' . $val['position'] . '" size="2" /></td>
                                                    <td style="width:70px; text-align:center">
                                                        <a href="' . self::$currentIndex . '&deleteImg&update' . $this->table . '&token=' . $this->token . '&id_' . $this->table . '=' . $obj->id . '&id_img=' . $val['id_blog_image'] . '" title="' . $this->l('Delete') . '" onclick="if(!confirm(\'' . $this->l('Are you sure you want to delete this picture ?') . '\')) return false;"><img src="../img/admin/delete.gif" alt="' . $this->l('Delete') . '" /></a></td> 
                                                  </tr>';
                }
            }
            $form_output .= "</table>";
        }
        $form_output .= '</fieldset>';
        $form_output .= '<div class="clear space">&nbsp;</div>';
        if (isset($this->conf['category_active']) && $this->conf['category_active'] == 1) {
            // CATEGORIES
            $form_output .= '<fieldset><legend><img src="../img/admin/tab-categories.gif"> ' . $this->l('Categories') . '</legend>';
            $form_output .= '<label>&nbsp;</label>
					<div class="margin-form"> ';
            $post_categories = Tools::getValue('groupBox', $obj->getCategories());
            $categories = BlogCategory::listCategories(false, false);
            if (is_array($categories) && count($categories)) {
                $form_output .= '<table cellspacing="0" cellpadding="0" class="table" style="min-width:500px;">
                                <tr>
                                    <th style="width:40px;"><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'groupBox[]\', this.checked)" /></th>
                                    <th style="width:30px;">' . $this->l('ID') . '</th>
                                    <th>' . $this->l('Category name') . '</th>
                                </tr>';
                $irow = 0;
                foreach ($categories as $cat) {
                    $form_output .= '
                                    <tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '">
                                            <td><input type="checkbox" name="groupBox[]" class="groupBox" id="groupBox_' . $cat['id_blog_category'] . '" value="' . $cat['id_blog_category'] . '" ' . (in_array($cat['id_blog_category'], $post_categories) ? 'checked="checked" ' : '') . '/></td>
                                            <td>' . $cat['id_blog_category'] . '</td>
                                            <td><label for="groupBox_' . $cat['id_blog_category'] . '" class="t">' . $cat['name'] . ' ' . (count($activeLanguages) > 1 && $cat['iso_code'] != '' ? '(' . $cat['iso_code'] . ')' : '') . ' </label></td>
                                    </tr>';
                }
                $form_output .= '
                                </table>
                                <p style="padding:0px; margin:10px 0px 10px 0px;">' . $this->l('Mark all checkbox(es) of categories to which the post is to be in') . '</p>';
            } else {
                $form_output .= '<p>' . $this->l('No category created') . '</p>';
            }
            $form_output .= '</div>';
            $form_output .= '</fieldset><div class="clear space">&nbsp;</div>';
        }
        if (isset($this->conf['product_active']) && $this->conf['product_active'] == 1) {
            // PRODUCTS
            $form_output .= '<fieldset>
                                    <legend><img src="../img/admin/tab-products.gif"> ' . $this->l('Related products') . '</legend>';
            $accessories = Tools::getValue('id_blog_post') ? $obj->getProducts(false) : array();
            $form_output .= '<div id="divAccessories">';
            foreach ($accessories as $accessory) {
                $form_output .= $accessory['name'] . (!empty($accessory['reference']) ? ' (' . $accessory['reference'] . ')' : '') . ' <span class="delAccessory" name="' . $accessory['id_product'] . '" style="cursor:pointer;"><img src="../img/admin/delete.gif" class="middle" alt="Delete" /></span><br />';
            }
            $form_output .= '</div>';
            $form_output .= '<div class="margin-form"> 

                                <input type="hidden" name="inputAccessories" id="inputAccessories" value="';
            foreach ($accessories as $accessory) {
                $form_output .= $accessory['id_product'] . '-';
            }
            $form_output .= '" />	
                                <input type="hidden" name="nameAccessories" id="nameAccessories" value="';
            foreach ($accessories as $accessory) {
                $form_output .= $accessory['name'] . '¤';
            }
            $form_output .= '" />';
            $form_output .= '<div id="ajax_choose_product" style="padding:6px; padding-top:2px; width:600px;">
                                        <p class="clear">' . $this->l('Begin typing the first letters of the product name, then select the product from the drop-down list:') . '</p>
                                        <input type="text" value="" id="product_autocomplete_input" />
                                        <img onclick="$(this).prev().search();" style="cursor: pointer;" src="../img/admin/add.gif" alt="' . $this->l('Add a product') . '" />
                                    </div';
            $form_output .= '</div>';
            $form_output .= '</fieldset><div class="clear space">&nbsp;</div>';
        }
        if (isset($this->conf['related_active']) && $this->conf['related_active'] == 1) {
            // RELATED ARTICLES
            $form_output .= '<fieldset>
					<legend><img src="../img/admin/tab-categories.gif"> ' . $this->l('Related blog posts') . '</legend>';
            $blog_related = Tools::getValue('groupRelated', $obj->getRelatedIds(true));
            $articles = BlogPost::listPosts(false, false, null, null, false, null, null, $obj->id);
            $form_output .= '<label> &nbsp; </label>
                             <div class="margin-form" style="height:140px; overflow-x:hidden; overflow-y:scroll; padding:0;">';
            if (count($articles)) {
                $form_output .= '<table cellspacing="0" cellpadding="0" class="table" style="min-width:500px;">
                                <tr>
                                        <th style="width:40px;"></th>
                                        <th style="width:30px;">' . $this->l('ID') . '</th>
                                        <th>' . $this->l('Title') . '</th>
                                </tr>';
                $irow = 0;
                foreach ($articles as $post) {
                    if ($post['id_blog_post'] == $obj->id) {
                        continue;
                    }
                    $iso = count($activeLanguages) > 1 && $post['id_lang'] != 0 ? '(' . Language::getIsoById($post['id_lang']) . ')' : '';
                    $form_output .= '<tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '">
                                                                <td><input type="checkbox" name="groupRelated[]" class="groupBox" id="groupRelated_' . $post['id_blog_post'] . '" value="' . $post['id_blog_post'] . '" ' . (in_array($post['id_blog_post'], $blog_related) ? 'checked="checked" ' : '') . '/></td>
                                                                <td>' . $post['id_blog_post'] . '</td>
                                                                <td><label for="groupRelated_' . $post['id_blog_post'] . '" class="t">' . $post['title'] . ' ' . $iso . '</label></td>
                                                        </tr>';
                }
                $form_output .= '</table>';
                $form_output .= '</div> <p style="font-size:11px;">' . $this->l('Select related posts') . '</p> <div class="clear">&nbsp;</div>';
            } else {
                $form_output .= '<p>' . $this->l('No posts created') . '</p>';
            }
            $form_output .= '</fieldset><div class="clear space">&nbsp;</div>';
        }
        $form_output .= '<fieldset><legend>' . $this->l('SEO - Post metas') . '</legend>';
        $form_output .= HelperFieldForm::displayTextField('link_rewrite', $this->getFieldValue($obj, 'link_rewrite'), 'text', $this->l('Friendly URL :'), $this->l('Only letters and the minus (-) character are allowed'), array('id' => 'link_rewrite_' . $lang_value));
        $form_output .= HelperFieldForm::displayTextField('meta_description', $this->getFieldValue($obj, 'meta_description'), 'textarea', $this->l('META description :'), $this->l('Search engines meta description'), array('rows' => 2));
        $form_output .= HelperFieldForm::displayTextField('meta_keywords', $this->getFieldValue($obj, 'meta_keywords'), 'text', $this->l('META keywords :'), $this->l('Separate keywords by ,'));
        $form_output .= '</fieldset><div class="clear space">&nbsp;</div>';
        $form_output .= '<fieldset><legend><img src="../img/admin/cog.gif"> ' . $this->l('Publication options') . '</legend>';
        $status_options = array(array('value' => 'published', 'title' => $this->l('Published')), array('value' => 'drafted', 'title' => $this->l('Drafted')), array('value' => 'suspended', 'title' => $this->l('Suspended')));
        $status_value = $this->getFieldValue($obj, 'status');
        $form_output .= HelperFieldForm::displaySelectField('status', $status_options, $status_value, $this->l('Status :'));
        if (isset($this->conf['comment_active']) && $this->conf['comment_active'] == 1) {
            $comments_options = array(array('value' => '1', 'title' => $this->l('Enabled')), array('value' => '0', 'title' => $this->l('Disabled')));
            $comments_value = !$obj->id ? 1 : $this->getFieldValue($obj, 'allow_comments');
            $form_output .= HelperFieldForm::displayRadioField('allow_comments', $comments_options, $comments_value, $this->l('Allow comments :'));
        }
        $date_on = $this->getFieldValue($obj, 'date_on') == "" ? date('Y-m-d') : $this->getFieldValue($obj, 'date_on');
        $form_output .= HelperFieldForm::displayDateField('date_on', $date_on, $this->l('Publication date :'));
        if (Shop::isFeatureActive()) {
            $form_output .= '<label>&nbsp;</label>
                             <div class="margin-form">';
            $helperForm = new HelperForm();
            $helperForm->identifier = $this->identifier;
            $helperForm->table = $this->table;
            $helperForm->id = $obj->id;
            $form_output .= $helperForm->renderAssoShop();
            $form_output .= '</div>';
        }
        $form_output .= '</fieldset><div class="clear space">&nbsp;</div>';
        $form_output .= '<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
                    
                    <input type="submit" class="button" name="submitAdd' . $this->table . '" value="' . $this->l('Save') . '" id="' . $this->table . '_form_submit_btn" />
			
		</form>
		
		<div class="clear space">&nbsp;</div>';
        $helper = new HelperCore();
        $helper->module = new Psblog();
        $template = $helper->createTemplate('form_blog_post.tpl');
        $iso_code = $this->context->language->iso_code;
        $iso = file_exists(_PS_ROOT_DIR_ . '/js/tiny_mce/langs/' . $iso_code . '.js') ? $iso_code : 'en';
        $iso_tiny_mce = file_exists(_PS_JS_DIR_ . 'tiny_mce/langs/' . $iso_code . '.js') ? $iso_code : 'en';
        $this->addjQueryPlugin(array('autocomplete', 'ajaxfileupload', 'date'));
        $this->addJS(array(_MODULE_DIR_ . $this->module->name . '/js/psblog.js', _MODULE_DIR_ . $this->module->name . '/js/jquery.MultiFile.pack.js', _PS_JS_DIR_ . 'tiny_mce/tiny_mce.js', _PS_JS_DIR_ . 'tinymce.inc.js', _PS_JS_DIR_ . 'fileuploader.js'));
        $this->addJqueryUI(array('ui.core', 'ui.datepicker'));
        $this->toolbar_btn['save-and-stay'] = array('href' => '#', 'desc' => $this->l('Save and stay'));
        $title = array($this->l('Blog'), $obj->id ? $this->l('Edit') : $this->l('Add new'));
        $template->assign(array('show_toolbar' => true, 'path_css' => _THEME_CSS_DIR_, 'toolbar_btn' => $this->toolbar_btn, 'currentIndex' => self::$currentIndex, 'toolbar_scroll' => true, 'title' => $title, 'ad' => dirname($_SERVER['PHP_SELF']), 'form_content' => $form_output, 'iso_tiny_mce' => $iso_tiny_mce, 'iso' => $iso, 'tinymce' => true, 'vat_number' => file_exists(_PS_MODULE_DIR_ . 'vatnumber/ajax.php'), 'languages' => $this->_languages, 'id_lang_default' => $defaultLanguage, 'defaultFormLanguage' => $defaultLanguage, 'allowEmployeeFormLang' => $this->allow_employee_form_lang));
        $form_content = $template->fetch();
        return $form_content;
    }