예제 #1
0
 /**
  * Load the form
  */
 protected function loadForm()
 {
     // create form
     $this->frm = new BackendForm('edit');
     $this->frm->addText('price', $this->record['price'], null, 'inputText price', 'inputTextError price');
     $this->frm->addText('tags', BackendTagsModel::getTags($this->URL->getModule(), $this->record['id']), null, 'inputText tagBox', 'inputTextError tagBox');
     $this->frm->addDropdown('related_products', $this->allProductsGroupedByCategories, $this->relatedProducts, true);
     $this->frm->addCheckbox('allow_comments', $this->record['allow_comments'] === 'Y' ? true : false);
     $this->frm->addCheckbox('frontpage', $this->record['frontpage']);
     $this->frm->addCheckbox('contact', $this->record['contact']);
     $this->frm->addDropdown('ballcolor', BackendCatalogModel::$ballColorArray, $this->record['ballcolor']);
     foreach ((array) BackendModel::get('fork.settings')->get('Core', 'languages') as $key => $language) {
         $productLanguage = BackendCatalogModel::getLanguage($this->id, $language);
         $fieldTitle = $this->frm->addText("title_" . strtolower($language), $productLanguage['title']);
         $fieldText = $this->frm->addEditor("text_" . strtolower($language), $productLanguage['text']);
         $fieldSummary = $this->frm->addEditor("summary_" . strtolower($language), $productLanguage['summary']);
         $fieldBalltext = $this->frm->addText("balltext_" . strtolower($language), $productLanguage['balltext']);
         $this->fieldLanguages[$key]["key"] = $key;
         $this->fieldLanguages[$key]["language"] = $language;
         $this->fieldLanguages[$key]["title"] = $fieldTitle->parse();
         $this->fieldLanguages[$key]["text"] = $fieldText->parse();
         $this->fieldLanguages[$key]["summary"] = $fieldSummary->parse();
         $this->fieldLanguages[$key]["balltext"] = $fieldBalltext->parse();
     }
     // categories
     $this->frm->addDropdown('category_id', $this->categories, $this->record['category_id']);
     $this->frm->addDropdown('brand_id', $this->brands, $this->record['brand_id']);
     $specificationsHTML = array();
     $first = true;
     // specifications
     foreach ($this->specifications as $specification) {
         $specificationName = 'specification' . $specification['id'];
         $languages = array();
         $fields = array();
         // parse specification into template
         $this->tpl->assign('id', $specification['id']);
         $this->tpl->assign('label', $specification['title']);
         $this->tpl->assign('spec', true);
         foreach ((array) BackendModel::get('fork.settings')->get('Core', 'languages') as $key => $language) {
             $value = BackendCatalogModel::getSpecificationValue($specification['id'], $this->record['id'], $language);
             // check if value is set
             $value = isset($value['value']) ? $value['value'] : null;
             $specificationName = 'specification' . $specification['id'] . '_' . $language;
             $specificationText = $this->frm->addText($specificationName, $value);
             $specificationHTML = $specificationText->parse();
             $fields[] = array('field' => $specificationHTML);
             $languages[] = array('language' => $language);
         }
         $this->tpl->assign('fields', $fields);
         //--Check first loop
         if ($first == false) {
             $languages = array();
         }
         $this->tpl->assign('languages', $languages);
         $specificationsHTML[]['specification'] = $this->tpl->getContent(BACKEND_MODULES_PATH . '/' . $this->getModule() . '/Layout/Templates/Specification.tpl');
     }
     $this->tpl->assign('specifications', $specificationsHTML);
     // meta object
     $this->meta = new BackendMeta($this->frm, $this->record['meta_id'], 'title_nl', true);
     // set callback for generating a unique URL
     $this->meta->setUrlCallback('Backend\\Modules\\Catalog\\Engine\\Model', 'getURL', array($this->record['id']));
     //--Media
     $this->media = new BackendMediaHelper($this->frm, (string) $this->getModule(), (int) $this->id, (string) $this->getAction(), 'product');
 }