public function initFormFeatures($obj) { if (!$this->default_form_language) { $this->getLanguages(); } $tpl_path = _PS_MODULE_DIR_ . 'advancedfeaturesvalues/views/templates/admin/products/features.tpl'; $data = $this->context->smarty->createTemplate($tpl_path, $this->context->smarty); $data->assign('default_form_language', $this->default_form_language); $data->assign('languages', $this->_languages); if (!Feature::isFeatureActive()) { $this->displayWarning($this->l('This feature has been disabled. ') . ' <a href="index.php?tab=AdminPerformance&token=' . Tools::getAdminTokenLite('AdminPerformance') . '#featuresDetachables">' . $this->l('Performances') . '</a>'); } else { if ($obj->id) { if ($this->product_exists_in_shop) { $features = Feature::getFeatures($this->context->language->id, Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP); foreach ($features as $k => $tab_features) { $features[$k]['current_item'] = array(); $features[$k]['val'] = array(); $custom = true; foreach ($obj->getFeatures() as $tab_products) { if ($tab_products['id_feature'] == $tab_features['id_feature']) { $features[$k]['current_item'][] = $tab_products['id_feature_value']; } } $features[$k]['featureValues'] = FeatureValue::getFeatureValuesWithLang($this->context->language->id, (int) $tab_features['id_feature']); if (count($features[$k]['featureValues'])) { foreach ($features[$k]['featureValues'] as $value) { if (in_array($value['id_feature_value'], $features[$k]['current_item'])) { $custom = false; } } } if ($custom && !empty($features[$k]['current_item'])) { $features[$k]['val'] = FeatureValue::getFeatureValueLang($features[$k]['current_item'][0]); } } $data->assign('available_features', $features); $data->assign('product', $obj); $data->assign('link', $this->context->link); $data->assign('default_form_language', $this->default_form_language); } else { $this->displayWarning($this->l('You must save the product in this shop before adding features.')); } } else { $this->displayWarning($this->l('You must save this product before adding features.')); } } $this->tpl_form_vars['custom_form'] = $data->fetch(); }
function displayFormFeatures($obj, $languages, $defaultLanguage) { global $cookie, $currentIndex; if ($obj->id) { $feature = Feature::getFeatures(intval($cookie->id_lang)); $ctab = ''; foreach ($feature as $tab) { $ctab .= 'ccustom_' . $tab['id_feature'] . '¤'; } $ctab = rtrim($ctab, '¤'); echo ' <table cellpadding="5"> <tr> <td colspan="2"><b>' . $this->l('Assign features to this product') . '</b></td> </tr> </table> <hr style="width:730px;"><br />'; // Header $nb_feature = Feature::nbFeatures(intval($cookie->id_lang)); echo ' <table border="0" cellpadding="0" cellspacing="0" class="table" style="width:600px;"> <tr> <th>' . $this->l('Features') . '</td> <th style="width:220px">' . $this->l('Value') . '</td> <th style="width:170px">' . $this->l('Customized') . '</td> </tr>'; if (!$nb_feature) { echo '<tr><td colspan="3" style="text-align:center;">' . $this->l('No features defined') . '</td></tr>'; } echo '</table>'; // Listing if ($nb_feature) { echo ' <table cellpadding="5" style="width:600px; margin-top:10px">'; foreach ($feature as $tab_features) { $current_item = false; $custom = false; $product_features = $obj->getFeatures(); foreach ($product_features as $tab_products) { if ($tab_products['id_feature'] == $tab_features['id_feature']) { $current_item = $tab_products['id_feature_value']; } } echo ' <tr> <td>' . $tab_features['name'] . '</td> <td style="width:220px"> <select name="feature_' . $tab_features['id_feature'] . '_value"> <option value="0">--- </option>'; $feature_values = FeatureValue::getFeatureValues($tab_features['id_feature']); foreach ($feature_values as $tab_values) { if (!$tab_values['custom']) { $value = FeatureValue::selectLang(FeatureValue::getFeatureValueLang($tab_values['id_feature_value']), intval($cookie->id_lang)); echo '<option value="' . $tab_values['id_feature_value'] . '"' . ($current_item == $tab_values['id_feature_value'] ? ' selected="selected"' : '') . '>' . substr($value, 0, 40) . (Tools::strlen($value) > 40 ? '...' : '') . ' </option>'; } else { $custom = true; } } echo ' </select> </td> <td style="width:170px">'; $tab_customs = array(); if ($custom) { $tab_customs = FeatureValue::getFeatureValueLang($current_item); } foreach ($languages as $language) { $custom_lang = FeatureValue::selectLang($tab_customs, $language['id_lang']); echo ' <div id="ccustom_' . $tab_features['id_feature'] . '_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;"> <input type="text" name="custom_' . $tab_features['id_feature'] . '_' . $language['id_lang'] . '" size="20" value="' . htmlentities(Tools::getValue('custom_' . $tab_features['id_feature'] . '_' . $language['id_lang'], $custom_lang), ENT_COMPAT, 'UTF-8') . '" /> </div>'; } $this->displayFlags($languages, $defaultLanguage, $ctab, 'ccustom_' . $tab_features['id_feature']); echo ' </td> </tr>'; } echo ' <tr> <td> </td> <td style="height:50px; " valign="bottom"><input type="submit" name="submitProductFeature" id="submitProductFeature" value="' . $this->l('Update features') . '" class="button" /></td> </tr>'; } echo '</table> <hr style="width:730px;"> <div style="text-align:center;"> <a href="index.php?tab=AdminFeatures&addfeature&token=' . Tools::getAdminToken('AdminFeatures' . intval(Tab::getIdFromClassName('AdminFeatures')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/add.gif" alt="new_features" title="' . $this->l('Create new features') . '" /> ' . $this->l('Create new features') . '</a> </div>'; } else { echo '<b>' . $this->l('You must save this product before adding features') . '.</b>'; } }
function getFeatures($prod_id) { $features = Product::getFeaturesStatic((int) $prod_id); $params = array(); foreach ($features as $feature) { $feature_name = Feature::getFeature($this->id_lang, $feature['id_feature']); $feature_name = $feature_name['name']; $feature_values = FeatureValue::getFeatureValueLang($feature['id_feature_value']); $feature_value = null; foreach ($feature_values as $f_value) { $feature_value = $f_value['value']; if ($f_value['id_lang'] == $this->id_lang) { break; } } if ($feature_value != null) { $params[$feature_name] = $feature_value; } } return $params; }
public function displayFormFeatures($obj, $languages, $defaultLanguage) { global $cookie, $currentIndex; //duplicate AdminTab::displayForm for display flag near traanslateable input fields $allowEmployeeFormLang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; echo ' <script type="text/javascript"> $(document).ready(function() { id_language = ' . $defaultLanguage . '; languages = new Array();'; foreach ($languages as $k => $language) { echo ' languages[' . $k . '] = { id_lang: ' . (int) $language['id_lang'] . ', iso_code: \'' . $language['iso_code'] . '\', name: \'' . htmlentities($language['name'], ENT_COMPAT, 'UTF-8') . '\' };'; } echo ' displayFlags(languages, id_language, ' . $allowEmployeeFormLang . '); }); </script>'; if ($obj->id) { // $feature = Feature::getFeatures(intval($cookie->id_lang)); include_once 'ExFeature.php'; $feature = ExFeature::getFeatures($defaultLanguage); $ctab = ''; foreach ($feature as $group) { foreach ($group["features"] as $f) { $ctab .= 'ccustom_' . $f['id'] . '¤'; } } $ctab = rtrim($ctab, '¤'); ?> <table cellpadding="5"> <tr> <td colspan="2"><b><?php echo $this->l('Assign features to this product'); ?> </b></td> </tr> </table> <hr style="width:730px;" /> <a href="#" id="all_close" class="module_toggle_all"><?php echo $this->l('Collapse all'); ?> </a> <a id="all_open" class="module_toggle_all" href="#"><?php echo $this->l('Expand all'); ?> </a><br /> <?php // Header $nb_feature = Feature::nbFeatures(intval($cookie->id_lang)); ?> <table border="0" cellpadding="0" cellspacing="0" class="table" style="width:906px;"> <tr> <th style="width:30%; padding-left:10px;"><?php echo $this->l('Features'); ?> </td> <th style="width:25%"><?php echo $this->l('Value'); ?> </td> <th style="width:45%"><?php echo $this->l('Customized'); ?> </td> </tr> <?php if (!$nb_feature) { ?> <tr><td colspan="3" style="text-align:center;">'.$this->l('No features defined').'</td></tr> <?php } ?> </table> <?php // Listing if ($nb_feature) { $pfeatures = Product::getFeaturesStatic($obj->id); $product_features = array(); foreach ($pfeatures as $pf) { if (!array_key_exists($pf["id_feature"], $product_features)) { $product_features[$pf["id_feature"]] = array(); } $product_features[$pf["id_feature"]][] = $pf["id_feature_value"]; } unset($pfeatures); $odd = 0; ?> <?php // <table cellpadding="5" style="width:743px; margin-top:10px"> ?> <?php //Main loop foreach ($feature as $gid => $group) { ?> <div id="cgroup<?php echo $gid; ?> " class="header_module"> <span class="nbr_module" style="width:100px;text-align:right; margin-right: 125px;"><?php echo count($group["features"]); ?> <?php echo $this->l('features'); ?> </span> <a class="header_module_toggle" id="group_<?php echo $gid; ?> " href="modgo_search_filter" style="margin-left: 5px;"> <span style="padding-right:0.5em"> <img class="header_module_img" id="search_filter_img" src="../img/admin/more.png" alt="" /> </span><?php echo $group["name"]; ?> </a> </div> <div id="group_<?php echo $gid; ?> _content" class="tab_module_content" style="display:none;border:solid 1px #CCC"> <div id="modgo_blocksearch"> <table style="width:100%" cellpadding="0" cellspacing="0"> <?php foreach ($group["features"] as $tab_features) { $current_item = false; $custom = true; foreach ($obj->getFeatures() as $tab_products) { if ($tab_products['id_feature'] == $tab_features['id_feature']) { $current_item = $tab_products['id_feature_value']; } } $featureValues = FeatureValue::getFeatureValuesWithLang((int) $cookie->id_lang, (int) $tab_features['id_feature']); echo ' <tr> <td style="padding-left: 10px; width: 30%">' . $tab_features['name'] . '</td> <td style="width: 25%">'; if (sizeof($featureValues)) { echo ' <select id="feature_' . $tab_features['id_feature'] . '_value" name="feature_' . $tab_features['id_feature'] . '_value" onchange="$(\'.custom_' . $tab_features['id_feature'] . '_\').val(\'\');"> <option value="0">--- </option>'; foreach ($featureValues as $value) { if ($current_item == $value['id_feature_value']) { $custom = false; } echo '<option value="' . $value['id_feature_value'] . '"' . ($current_item == $value['id_feature_value'] ? ' selected="selected"' : '') . '>' . substr($value['value'], 0, 40) . (Tools::strlen($value['value']) > 40 ? '...' : '') . ' </option>'; } echo '</select>'; } else { echo '<input type="hidden" name="feature_' . $tab_features['id_feature'] . '_value" value="0" /><span style="font-size: 10px; color: #666;">' . $this->l('N/A') . ' - <a href="index.php?tab=AdminFeatures&addfeature_value&id_feature=' . (int) $tab_features['id_feature'] . '&token=' . Tools::getAdminToken('AdminFeatures' . (int) Tab::getIdFromClassName('AdminFeatures') . (int) $cookie->id_employee) . '" style="color: #666; text-decoration: underline;">' . $this->l('Add pre-defined values first') . '</a></span>'; } echo ' </td> <td style="width:45%" class="translatable">'; $tab_customs = $custom ? FeatureValue::getFeatureValueLang($current_item) : array(); foreach ($languages as $language) { echo ' <div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left; margin-top: 5px; margin-bottom: 5px;"> <textarea class="custom_' . $tab_features['id_feature'] . '_" name="custom_' . $tab_features['id_feature'] . '_' . $language['id_lang'] . '" cols="40" rows="1" onkeyup="$(\'#feature_' . $tab_features['id_feature'] . '_value\').val(0);" >' . htmlentities(Tools::getValue('custom_' . $tab_features['id_feature'] . '_' . $language['id_lang'], FeatureValue::selectLang($tab_customs, $language['id_lang'])), ENT_COMPAT, 'UTF-8') . '</textarea> </div>'; } /* echo '<div style=" float: left; margin-top: 10px; margin-left: 5px">' .$this->displayFlags($languages, $defaultLanguage, $ctab, 'ccustom_'.$tab_features['id_feature'], true). '</div>'; */ echo ' </td> </tr>'; } ?> </table> </div> </div> <?php } ?> <div id="updateFeatureAdminContainer" style="text-align: center; margin-top: 10px;"> <input type="submit" name="submitProductFeature" id="submitProductFeature" value="<?php echo $this->l('Update features'); ?> " class="button" /> </div> <?php } ?> <hr style="width:730px;" /> <div style="text-align:center;"> <a href="index.php?tab=AdminExFeatures&addfeature&token=<?php echo Tools::getAdminToken('AdminExFeatures' . intval(Tab::getIdFromClassName('AdminExFeatures')) . intval($cookie->id_employee)); ?> " onclick="return confirm('<?php echo $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false); ?> ');"> <img src="../img/admin/add.gif" alt="new_features" title="<?php echo $this->l('Create new features'); ?> " /> <?php echo $this->l('Create new features'); ?> </a> </div> <?php } else { echo '<b>' . $this->l('You must save this product before adding features') . '.</b>'; } }
function displayFormFeatures($obj) { global $cookie, $currentIndex; parent::displayForm(); if ($obj->id) { $feature = Feature::getFeatures((int) $cookie->id_lang); $ctab = ''; foreach ($feature as $tab) { $ctab .= 'ccustom_' . $tab['id_feature'] . '¤'; } $ctab = rtrim($ctab, '¤'); echo ' <table cellpadding="5"> <tr> <td colspan="2"> <b>' . $this->l('Assign features to this product:') . '</b><br /> <ul style="margin: 10px 0 0 20px;"> <li>' . $this->l('You can specify a value for each relevant feature regarding this product, empty fields will not be displayed.') . '</li> <li>' . $this->l('You can either set a specific value, or select among existing pre-defined values you added previously.') . '</li> </ul> </td> </tr> </table> <hr style="width:100%;" /><br />'; // Header $nb_feature = Feature::nbFeatures((int) $cookie->id_lang); echo ' <table border="0" cellpadding="0" cellspacing="0" class="table" style="width:900px;"> <tr> <th>' . $this->l('Feature') . '</td> <th style="width:30%">' . $this->l('Pre-defined value') . '</td> <th style="width:40%"><u>' . $this->l('or') . '</u> ' . $this->l('Customized value') . '</td> </tr>'; if (!$nb_feature) { echo '<tr><td colspan="3" style="text-align:center;">' . $this->l('No features defined') . '</td></tr>'; } echo '</table>'; // Listing if ($nb_feature) { echo ' <table cellpadding="5" style="width: 900px; margin-top: 10px">'; foreach ($feature as $tab_features) { $current_item = false; $custom = true; foreach ($obj->getFeatures() as $tab_products) { if ($tab_products['id_feature'] == $tab_features['id_feature']) { $current_item = $tab_products['id_feature_value']; } } $featureValues = FeatureValue::getFeatureValuesWithLang((int) $cookie->id_lang, (int) $tab_features['id_feature']); echo ' <tr> <td>' . $tab_features['name'] . '</td> <td style="width: 30%">'; if (sizeof($featureValues)) { echo ' <select id="feature_' . $tab_features['id_feature'] . '_value" name="feature_' . $tab_features['id_feature'] . '_value" onchange="$(\'.custom_' . $tab_features['id_feature'] . '_\').val(\'\');"> <option value="0">--- </option>'; foreach ($featureValues as $value) { if ($current_item == $value['id_feature_value']) { $custom = false; } echo '<option value="' . $value['id_feature_value'] . '"' . ($current_item == $value['id_feature_value'] ? ' selected="selected"' : '') . '>' . substr($value['value'], 0, 40) . (Tools::strlen($value['value']) > 40 ? '...' : '') . ' </option>'; } echo '</select>'; } else { echo '<input type="hidden" name="feature_' . $tab_features['id_feature'] . '_value" value="0" /><span style="font-size: 10px; color: #666;">' . $this->l('N/A') . ' - <a href="index.php?tab=AdminFeatures&addfeature_value&id_feature=' . (int) $tab_features['id_feature'] . '&token=' . Tools::getAdminToken('AdminFeatures' . (int) Tab::getIdFromClassName('AdminFeatures') . (int) $cookie->id_employee) . '" style="color: #666; text-decoration: underline;">' . $this->l('Add pre-defined values first') . '</a></span>'; } echo ' </td> <td style="width:40%" class="translatable">'; $tab_customs = $custom ? FeatureValue::getFeatureValueLang($current_item) : array(); foreach ($this->_languages as $language) { echo ' <div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;"> <textarea class="custom_' . $tab_features['id_feature'] . '_" name="custom_' . $tab_features['id_feature'] . '_' . $language['id_lang'] . '" cols="40" rows="1" onkeyup="if (isArrowKey(event)) return ;$(\'#feature_' . $tab_features['id_feature'] . '_value\').val(0);" >' . htmlentities(Tools::getValue('custom_' . $tab_features['id_feature'] . '_' . $language['id_lang'], FeatureValue::selectLang($tab_customs, $language['id_lang'])), ENT_COMPAT, 'UTF-8') . '</textarea> </div>'; } echo ' </td> </tr>'; } echo ' <tr> <td style="height: 50px; text-align: center;" colspan="3"><input type="submit" name="submitProductFeature" id="submitProductFeature" value="' . $this->l('Save modifications') . '" class="button" /></td> </tr>'; } echo '</table> <hr style="width:100%;" /> <div style="text-align:center;"> <a href="index.php?tab=AdminFeatures&addfeature&token=' . Tools::getAdminToken('AdminFeatures' . (int) Tab::getIdFromClassName('AdminFeatures') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('You will lose all modifications not saved, you may want to save modifications first?', __CLASS__, true, false) . '\');"><img src="../img/admin/add.gif" alt="new_features" title="' . $this->l('Add a new feature') . '" /> ' . $this->l('Add a new feature') . '</a> </div>'; } else { echo '<b>' . $this->l('You must save this product before adding features') . '.</b>'; } }
private function initContentForFeatures() { $tlwvvxr = "features"; ${"GLOBALS"}["pihske"] = "features"; $jxbahojyvlt = "available_features_all"; $fotyrrre = "available_features_all"; $lueyeppw = "features"; ${"GLOBALS"}["iavdbtipeie"] = "tab_features"; ${$lueyeppw} = Feature::getFeatures($this->id_language); foreach (${$tlwvvxr} as ${${"GLOBALS"}["qtxqhylrbsm"]} => ${${"GLOBALS"}["iavdbtipeie"]}) { ${"GLOBALS"}["ringgeomwho"] = "tab_products"; $oovownr = "k"; $dibecrefieyf = "k"; ${"GLOBALS"}["llnriurbfb"] = "features"; ${"GLOBALS"}["krrouj"] = "k"; ${"GLOBALS"}["ezrxbtdf"] = "features"; ${${"GLOBALS"}["nrjxzlhiqjg"]}[${${"GLOBALS"}["krrouj"]}]["current_item"] = false; ${${"GLOBALS"}["nrjxzlhiqjg"]}[${$dibecrefieyf}]["val"] = array(); ${${"GLOBALS"}["vwmhyvovziq"]} = true; foreach ($this->object->getFeatures() as ${${"GLOBALS"}["ringgeomwho"]}) { $hozllwqodl = "features"; $koyfxiz = "k"; ${"GLOBALS"}["hkqtkv"] = "tab_products"; ${"GLOBALS"}["icrwrssx"] = "tab_products"; $wbqcupctp = "tab_features"; if (${${"GLOBALS"}["hkqtkv"]}["id_feature"] == ${$wbqcupctp}["id_feature"]) { ${$hozllwqodl}[${$koyfxiz}]["current_item"] = ${${"GLOBALS"}["icrwrssx"]}["id_feature_value"]; } } ${${"GLOBALS"}["nrjxzlhiqjg"]}[${${"GLOBALS"}["qtxqhylrbsm"]}]["featureValues"] = FeatureValue::getFeatureValuesWithLang($this->id_language, (int) ${${"GLOBALS"}["kowgsfpm"]}["id_feature"]); if (count(${${"GLOBALS"}["nrjxzlhiqjg"]}[${$oovownr}]["featureValues"])) { $gtmlwoq = "features"; $ryjttmtpvt = "k"; foreach (${$gtmlwoq}[${$ryjttmtpvt}]["featureValues"] as ${${"GLOBALS"}["kzwkbwmzgtl"]}) { $rtsfkxsq = "features"; $tduybwwrxb = "value"; if (${$rtsfkxsq}[${${"GLOBALS"}["qtxqhylrbsm"]}]["current_item"] == ${$tduybwwrxb}["id_feature_value"]) { ${${"GLOBALS"}["vwmhyvovziq"]} = false; } } } if (${${"GLOBALS"}["vwmhyvovziq"]}) { ${${"GLOBALS"}["llnriurbfb"]}[${${"GLOBALS"}["qtxqhylrbsm"]}]["val"] = FeatureValue::getFeatureValueLang(${${"GLOBALS"}["ezrxbtdf"]}[${${"GLOBALS"}["qtxqhylrbsm"]}]["current_item"]); } } ${$jxbahojyvlt} = ""; foreach (${${"GLOBALS"}["nrjxzlhiqjg"]} as ${${"GLOBALS"}["jtsfpdcbh"]}) { ${"GLOBALS"}["tpyuivnp"] = "available_features_all"; ${${"GLOBALS"}["mogxjutudv"]} = ${${"GLOBALS"}["tpyuivnp"]} . "custom_" . ${${"GLOBALS"}["jtsfpdcbh"]}["id_feature"] . "¤"; } self::$smarty->assign(array("available_features_all" => ${$fotyrrre}, "available_features" => ${${"GLOBALS"}["pihske"]})); }
public function initFormFeatures($obj) { $data = $this->createTemplate($this->tpl_form); if (!Feature::isFeatureActive()) { $this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:') . ' <a href="index.php?tab=AdminPerformance&token=' . Tools::getAdminTokenLite('AdminPerformance') . '#featuresDetachables">' . $this->l('Performances') . '</a>'); } else { if ($obj->id) { if ($this->product_exists_in_shop) { $features = Feature::getFeatures($this->context->language->id); foreach ($features as $k => $tab_features) { $features[$k]['current_item'] = false; $features[$k]['val'] = array(); $custom = true; foreach ($obj->getFeatures() as $tab_products) { if ($tab_products['id_feature'] == $tab_features['id_feature']) { $features[$k]['current_item'] = $tab_products['id_feature_value']; } } $features[$k]['featureValues'] = FeatureValue::getFeatureValuesWithLang($this->context->language->id, (int) $tab_features['id_feature']); if (count($features[$k]['featureValues'])) { foreach ($features[$k]['featureValues'] as $value) { if ($features[$k]['current_item'] == $value['id_feature_value']) { $custom = false; } } } if ($custom) { $features[$k]['val'] = FeatureValue::getFeatureValueLang($features[$k]['current_item']); } } $data->assign('available_features', $features); $data->assign('product', $obj); $data->assign('link', $this->context->link); $data->assign('languages', $this->_languages); $data->assign('default_form_language', $this->default_form_language); } else { $this->displayWarning($this->l('You must save this product in this shop before adding features.')); } } else { $this->displayWarning($this->l('You must save this product before adding features.')); } } $this->tpl_form_vars['custom_form'] = $data->fetch(); }