public function display($tpl = null) { $extra_field = new extra_field(); $option = JRequest::getVar('option', '', 'request', 'string'); JToolBarHelper::title(JText::_('COM_REDSHOP_FIELDS_MANAGEMENT_DETAIL'), 'redshop_fields48'); $document = JFactory::getDocument(); $document->addScript('components/' . $option . '/assets/js/fields.js'); $uri = JFactory::getURI(); $this->setLayout('default'); $lists = array(); $detail = $this->get('data'); $filed_data = $extra_field->getFieldValue($detail->field_id); $isNew = $detail->field_id < 1; $text = $isNew ? JText::_('COM_REDSHOP_NEW') : JText::_('COM_REDSHOP_EDIT'); JToolBarHelper::title(JText::_('COM_REDSHOP_FIELDS') . ': <small><small>[ ' . $text . ' ]</small></small>', 'redshop_fields48'); JToolBarHelper::apply(); JToolBarHelper::save(); if ($isNew) { JToolBarHelper::cancel(); } else { JToolBarHelper::cancel('cancel', JText::_('JTOOLBAR_CLOSE')); } $redtemplate = new Redtemplate(); $optiontype = $redtemplate->getFieldTypeSections(); $optionsection = $redtemplate->getFieldSections(); $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $detail->published); $lists['show_in_front'] = JHTML::_('select.booleanlist', 'field_show_in_front', 'class="inputbox"', $detail->field_show_in_front); $lists['display_in_product'] = JHTML::_('select.booleanlist', 'display_in_product', 'class="inputbox"', $detail->display_in_product); $lists['display_in_checkout'] = JHTML::_('select.booleanlist', 'display_in_checkout', 'class="inputbox"', $detail->display_in_checkout); $lists['required'] = JHTML::_('select.booleanlist', 'required', 'class="inputbox"', $detail->required); $lists['type'] = JHTML::_('select.genericlist', $optiontype, 'field_type', 'class="inputbox" size="1" onchange="field_select(this.value)" ', 'value', 'text', $detail->field_type); $disable = ""; if ($detail->field_type == 15) { $disable = "disabled='disabled' "; } $lists['section'] = JHTML::_('select.genericlist', $optionsection, 'field_section', 'class="inputbox" size="1" ' . $disable . ' onchange="sectionValidation(this.value)"', 'value', 'text', $detail->field_section); $lists['extra_data'] = $filed_data; $this->lists = $lists; $this->detail = $detail; $this->request_url = $uri->toString(); parent::display($tpl); }
/** * Load the fields for export * * @return void */ private function loadFields() { $extra_field = new extra_field(); $producthelper = new producthelper(); $db = JFactory::getDbo(); $query = "SELECT * FROM `#__redshop_fields` ORDER BY field_id asc "; $this->_db->setQuery($query); $cur = $this->_db->loadObjectList(); $ret = null; for ($i = 0; $i < count($cur); $i++) { if ($i == 0) { echo "field_id,field_title,field_name_field,field_type,field_desc,field_class,field_section,field_maxlength,field_cols,field_rows,field_size,field_show_in_front,required,published,data_id,data_txt,itemid,section,value_id,field_value,field_name,data_number"; echo "\r\n"; } $query = 'SELECT data_id,`data_txt`,`itemid`,`section` FROM `#__redshop_fields_data` WHERE `fieldid` = ' . $cur[$i]->field_id . ' and section!=""'; $this->_db->setQuery($query); $data = $this->_db->loadObjectList(); $attr = array(); $datavalue = $extra_field->getFieldValue($cur[$i]->field_id); $attrvalue = array(); echo $cur[$i]->field_id . "," . $cur[$i]->field_title . "," . $cur[$i]->field_name . "," . $cur[$i]->field_type . "," . $cur[$i]->field_desc . "," . $cur[$i]->field_class . "," . $cur[$i]->field_section . "," . $cur[$i]->field_maxlength . "," . $cur[$i]->field_cols . "," . $cur[$i]->field_rows . "," . $cur[$i]->field_size . "," . $cur[$i]->field_show_in_front . "," . $cur[$i]->required . "," . $cur[$i]->published . "\n"; for ($att = 0; $att < count($data); $att++) { $product_details = $producthelper->getProductById($data[$att]->itemid); echo $cur[$i]->field_id . ",,,,,,,,,,,,,," . $data[$att]->data_id . ",\"" . $data[$att]->data_txt . "\"," . $data[$att]->itemid . "," . $data[$att]->section . ",,,," . $product_details->product_number . ",\n"; } for ($attrvalue = 0; $attrvalue < count($datavalue); $attrvalue++) { echo $cur[$i]->field_id . ",,,,,,,,,,,,,,,,,," . $datavalue[$attrvalue]->value_id . "," . $datavalue[$attrvalue]->field_value . "," . $datavalue[$attrvalue]->field_name . ",\n"; } } }
public function field_save($id, $post) { $extra_field = new extra_field(); $value_id = array(); $extra_name = array(); $extra_value = array(); if (array_key_exists("value_id", $post)) { $extra_value = JRequest::getVar('extra_value', '', 'post', 'string', JREQUEST_ALLOWRAW); $value_id = $post["value_id"]; if ($post["field_type"] == 11 || $post["field_type"] == 13) { $extra_name = JRequest::getVar('extra_name_file', '', 'files', 'array'); $total = count($extra_name['name']); } else { $extra_name = JRequest::getVar('extra_name', '', 'post', 'string', JREQUEST_ALLOWRAW); $total = count($extra_name); } } $filed_data_id = $extra_field->getFieldValue($id); if (count($filed_data_id) > 0) { $fid = array(); foreach ($filed_data_id as $f) { $fid[] = $f->value_id; } $del_fid = array_diff($fid, $value_id); if (count($del_fid) > 0) { $this->field_delete($del_fid, 'value_id'); } } for ($j = 0; $j < $total; $j++) { $set = ""; if ($post["field_type"] == 11 || $post["field_type"] == 13) { if ($extra_value[$j] != "" && $extra_name['name'][$j] != "") { $filename = time() . "_" . $extra_name['name'][$j]; $src = $extra_name['tmp_name'][$j]; $dest = REDSHOP_FRONT_IMAGES_RELPATH . 'extrafield/' . $filename; JFile::upload($src, $dest); $set = " field_name='" . $filename . "', "; } } else { $filename = $extra_name[$j]; $set = " field_name='" . $filename . "', "; } if ($value_id[$j] == "") { $query = "INSERT INTO " . $this->_table_prefix . "fields_value " . "(field_id,field_name,field_value) " . "VALUE ( '" . $id . "','" . $filename . "','" . $extra_value[$j] . "' ) "; } else { $query = "UPDATE " . $this->_table_prefix . "fields_value " . "SET " . $set . " field_value='" . $extra_value[$j] . "' " . "WHERE value_id='" . $value_id[$j] . "' "; } $this->_db->setQuery($query); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } } }