/** * custom action */ public function mainAction() { $Translation = new international_translation(); if ($this->GET['add'] == "true") { $last_item = $Translation->listing("", "id DESC", "0,1"); if (is_numeric($last_item[0]['id'])) { unset($last_item[0]['id']); } else { $last_item[0] = array("locale" => $GLOBALS['onxshop_conf']['global']['locale']); } $last_item[0]['original_string'] = ""; $last_item[0]['translated_string'] = ""; $Translation->insert($last_item[0]); } $dictionary = $Translation->listing("", "id DESC"); foreach ($dictionary as $item) { $this->tpl->assign("ITEM", $item); $this->tpl->parse("content.item"); } return true; }
/** * Output filter for public clients (this filter should only apply when in frontend preview mode) */ public function outputFilterPublic($content) { /** * Substitute constants in the output for logged in users * TODO: highlight in documentation! */ //only when not logged in backoffice if (!Onxshop_Bo_Authentication::getInstance()->isAuthenticated()) { if ($_SESSION['client']['customer']['id'] > 0) { $content = preg_replace("/{{customer.first_name}}/", htmlspecialchars($_SESSION['client']['customer']['first_name']), $content); } else { //assign empty string $content = preg_replace("/{{customer.first_name}}/", '', $content); } } // translations if (ONXSHOP_SIMPLE_TRANSLATION_ENABLED && !ONXSHOP_IN_BACKOFFICE) { $locale = $_SESSION['locale']; $default_locale = $GLOBALS['onxshop_conf']['global']['locale']; if ($locale != $default_locale) { require_once 'models/international/international_translation.php'; $Translation = new international_translation(); $node_id = $_SESSION['last_item'] = $_SESSION['history'][count($_SESSION['history']) - 1]['node_id']; $content = $Translation->translatePage($content, $locale, $node_id); } } return $content; }
/** * main action */ public function mainAction() { /** * TODO: * implement general updateSingleAttribute() */ //print_r($_POST); $model = $this->GET['model']; $attribute = $this->GET['attribute']; $update_value = trim($_POST['update_value']); $original_value = trim($_POST['original_html']); // currently implemented for product_variety.name and price.value switch ($model) { case 'common_node': require_once 'models/common/common_node.php'; $element_id_parts = explode('-', $_POST['element_id']); $variety_id = $element_id_parts[3]; $ModelObj = new common_node(); if (!$ModelObj->updateSingleAttribute($attribute, $update_value, $variety_id)) { msg('Failed', 'error'); } break; case 'ecommerce_product_variety': require_once 'models/ecommerce/ecommerce_product_variety.php'; $element_id_parts = explode('-', $_POST['element_id']); $variety_id = $element_id_parts[3]; $ModelObj = new ecommerce_product_variety(); if (!$ModelObj->updateSingleAttribute($attribute, $update_value, $variety_id)) { msg('Failed', 'error'); } break; case 'ecommerce_price': require_once 'models/ecommerce/ecommerce_price.php'; $ModelObj = new ecommerce_price(); $element_id_parts = explode('-', $_POST['element_id']); $variety_id = $element_id_parts[3]; $last_price = $ModelObj->getLastPriceForVariety($variety_id); //remove anything else than number and decimal point $update_value = preg_replace("/[^0-9\\.]*/", '', $update_value); //update only when the new price is different than old price if (round($last_price['value'], 2) != round($update_value, 2)) { if (!$ModelObj->updateSingleAttribute('value', $update_value, $last_price['id'])) { msg('Failed', 'error'); } } break; case 'international_translation': require_once 'models/international/international_translation.php'; $element_id_parts = explode('-', $_POST['element_id']); $updated_id = $element_id_parts[3]; $ModelObj = new international_translation(); if (!$ModelObj->updateSingleAttribute($attribute, $update_value, $updated_id)) { msg('Failed', 'error'); } break; default: return false; break; } if ($update_value != $original_value) { $value = $update_value; } else { $value = $original_value; } $this->tpl->assign('VALUE', $value); return true; }