/** * Constructs an object for the specified resource file. * Reads the resource file as the INI-file. * * $filename - , * . , * . * * @param string $filename - the resource filename without extension * @param string $zone is necessary to specify the resource file path * @access public */ function MessageResources($filename = "", $zone = "CustomerZone", $shortname = null) { global $application; $this->filename = $filename; $this->zone = $zone; if ($shortname == null) { $this->shortname = modApiFunc("Modules_Manager", "getShortNameByResFile", $filename); if ($this->shortname == null) { $this->shortname = 'SYS'; if ($this->filename == '') { $this->filename = $application->getAppIni('PATH_ADMIN_RESOURCES') . 'system-messages-eng.ini'; } } } else { $this->shortname = $shortname; if ($this->shortname == 'CZ') { if ($this->filename == '') { $this->filename = getTemplateFileAbsolutePath('resources/messages.ini'); } } } $this->messages = modApiFunc("Resources", "getMessageGroupByPrefix", $this->shortname); if ($this->shortname == 'SYS' && isset($this->messages['COPYRIGHT_TEXT'])) { $this->messages['COPYRIGHT_TEXT'] = sprintf($this->messages['COPYRIGHT_TEXT'], date("Y")); } }
function onAction() { global $application; $request = $application->getInstance('Request'); #$msgres = $application->getInstance("MessageResources", "messages"); # Preparing template filler for product description $this->templateFiller = $application->getInstance('TmplFiller'); $is_error = false; $errors = $this->verify($_POST); if (!empty($errors)) { modApiFunc("Session", "set", "GC_errors", $errors); modApiFunc("Session", "set", "SessionPost", $_POST); $req = new Request(); $req->setView("GiftCertificate"); #_print($req->getURL());die; $application->redirect($req); return; } # create new GC as product of gift certificate product type $product_type = modApiFunc('Catalog', 'getProductType', GC_PRODUCT_TYPE_ID); $product_info["Name"] = $this->getGCName($_POST['gc_from'], $_POST['gc_to']); $product_info["SalePrice"] = $this->getGCAmount($_POST['gc_amount']); $product_info["SmallImage"] = ""; $product_info["LargeImage"] = ""; # Shipping Information if ($_POST['gc_sendtype'] == 'P') { $product_info["FreeShipping"] = modApiFunc("Settings", "getParamValue", "GIFT_CERTIFICATES", "GC_FREE_SHIPPING"); $product_info["NeedShipping"] = modApiFunc("Settings", "getParamValue", "GIFT_CERTIFICATES", "GC_NEED_SHIPPING"); $product_info["Weight"] = modApiFunc("Settings", "getParamValue", "GIFT_CERTIFICATES", "GC_WEIGHT"); $product_info["PerItemShippingCost"] = modApiFunc("Settings", "getParamValue", "GIFT_CERTIFICATES", "GC_PER_ITEM_SHIPPING_COST"); $product_info["PerItemHandlingCost"] = modApiFunc("Settings", "getParamValue", "GIFT_CERTIFICATES", "GC_PER_ITEM_HANDLING_COST"); } else { $product_info["NeedShipping"] = "2"; // No shipping needeed for e-mail delivery } $gc_data = array(); foreach ($_POST as $p => $v) { if ($p == "gc_country_id" && !empty($v)) { $gc_data["gc_country"] = modApiFunc('Location', 'getCountry', $v); } else { if ($p == "gc_state_id" && !empty($v)) { $gc_data["gc_state"] = modApiFunc('Location', 'getState', $v); } else { $gc_data[$p] = addslashes($v); } } } if ($_POST['gc_sendtype'] == 'P') { $product_info["DetailedDescription"] = $this->templateFiller->fill("", getTemplateFileAbsolutePath("gift-certificate/create-gc-form/default/gc-info-description-post.tpl.html"), $gc_data); } else { if ($_POST['gc_sendtype'] == 'E') { $product_info["DetailedDescription"] = $this->templateFiller->fill("", getTemplateFileAbsolutePath("gift-certificate/create-gc-form/default/gc-info-description-email.tpl.html"), $gc_data); } } foreach ($product_type['attr'] as $view_tag => $attr) { if (preg_match("/gc_/i", $view_tag)) { if (isset($_POST[$view_tag]) && !empty($_POST[$view_tag])) { $product_info[$view_tag] = trim($_POST[$view_tag]); } else { $product_info[$view_tag] = getLabel('GIFTCERTIFICATE_EMPTY_FIELD'); } } } $category_id = -1; $prod_id = modApiFunc('Catalog', 'addProductInfo', GC_PRODUCT_TYPE_ID, $category_id, $product_info); // create new GC product in database $data = array('parent_entity' => 'product', 'entity_id' => $prod_id, 'options' => array(), 'qty' => 1); $options_sent = "no"; if (!$is_error) { if (!empty($stock_discarded_by_warning)) { modApiFunc('Session', 'set', 'StockDiscardedBy', $stock_discarded_by_warning); } modApiFunc('Cart', 'addToCart', $data); $request = new Request(); #$request->setView(CURRENT_REQUEST_URL); $request->setView('CartContent'); $application->redirect($request); } else { if ($discard_by != 'none') { modApiFunc('Session', 'set', 'OptionsDiscardedBy', $discard_by); } if ($stock_discarded_by != 'none') { modApiFunc('Session', 'set', 'StockDiscardedBy', $stock_discarded_by); } modApiFunc('Session', 'set', 'sentCombination', $data['options']); $request = new Request(); $request->setView(CURRENT_REQUEST_URL); /*$request->setView('ProductInfo'); $request->setAction('SetCurrentProduct'); $request->setKey('prod_id',$prod_id); $request->setProductID($prod_id); $p = new CProductInfo($prod_id); $request->setCategoryID($p->chooseCategoryID());*/ $application->redirect($request); } }
<HEAD> <TITLE>Page Not Found</TITLE> <META name="author" content="Avactis Team" /> <META http-equiv="Content-type" content="text/html; charset=UTF-8" /> <META name="viewport" content="width=device-width, minimumscale=1.0, maximum-scale=1.0" /> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link href='http://fonts.googleapis.com/css?family=Merriweather' rel='stylesheet' type='text/css'> <style> .fa-search { display:none !important;} .search_404 {width:40%;} </style> </HEAD> <?php include getTemplateFileAbsolutePath('pages/templates/part.header.tpl.html'); ?> <BODY> <div id="wrapper"> <br><br><br><br><br><br> <center> <h1><?php xmsg('ERRD', 'TITLE_404'); ?> </h1> <h2><?php xmsg('ERRD', 'SUBTITLE_404'); ?> </h2>
function outAPICustomSpace() { global $application; $short_api_name = _ml_strtolower(str_replace("Shipping_Module_", "", $this->current_api_name)); $custom_file_name = $short_api_name . "-custom-space.html"; $tmp_tpl = $application->getBlockTemplate($this->BlockTemplateName); $full_path_to_file = getTemplateFileAbsolutePath($tmp_tpl["template"]["directory"] . "/" . $custom_file_name); if (file_exists($full_path_to_file)) { return file_get_contents($full_path_to_file); } else { return ""; } }
/** * Reads given template file contents. * It prepares it for filling. * It fills it with template variables values provided. * It does special HTML formatting if needed, e.g. draw red debug template frames. * * * @param string $folder_name Template file path: full folder path. * @param string $tmpl_short_filename Template file path: file name. * @param arrat $vars Template variables values. * @return string template html contents with tags replaced with their values. */ function fill($folder_name, $tmpl_short_filename, $vars, $customer_zone = false) { //Open file, read contents, replace tags. $this->PreviousTemplateFilename = $this->CurrentTemplateFilename; if ($customer_zone) { $this->CurrentTemplateFilename = getTemplateFileAbsolutePath($this->TemplateDirPrefix . $folder_name . $tmpl_short_filename); } else { $this->CurrentTemplateFilename = $this->TemplateDirPrefix . $folder_name . "views/admin/templates/" . $tmpl_short_filename; if (!is_file($this->CurrentTemplateFilename)) { $this->CurrentTemplateFilename = $this->TemplateDirPrefix . $folder_name . $tmpl_short_filename; } if (!is_file($this->CurrentTemplateFilename)) { $this->CurrentTemplateFilename = modApiFunc('application', 'getAppIni', 'PATH_ADMIN_TPLS_VIEWS') . $folder_name . $tmpl_short_filename; } } $code_to_include = $this->getCachedCode($this->CurrentTemplateFilename); if ($code_to_include === null) { $tpl_file = new CFile($this->CurrentTemplateFilename); $code_to_include = $tpl_file->getContent(); // , ( > 128) $code_to_include = convertTemplate($code_to_include); if ($code_to_include === FALSE) { CTrace::backtrace(); _fatal("TMPL_FILLER_ERROR_CANNOT_READ_FILE", $this->CurrentTemplateFilename); } $code_to_include = '?>' . $this->removeTemplateWrapper($code_to_include); $this->saveInCache($this->CurrentTemplateFilename, $code_to_include); } $text = $this->includeTmplCode($code_to_include); $_vars = array(); foreach ($vars as $key => $value) { $_vars['{' . $key . '}'] = $value; } $text = strtr($text, $_vars); $text = $this->addCrossSiteProtectinField($text); return $text; }
function outputPageByMap($page) { global $__TPL_DIR__, $__TPL_URL__, $application; $page = basename($page); $map_file = modApiFunc('Layout_CMS', 'getThemePath') . 'map.ini'; $use_cached = false; if (file_exists($map_file)) { $ini_cache = $application->getIniCache(); $map_mtime = filemtime($map_file); if ($map_mtime == $ini_cache->read($map_file . '-mtime')) { $map = $ini_cache->read($map_file); $use_cached = true; } else { CProfiler::ioStart($map_file, 'parse'); $map = parse_ini_file($map_file, true); CProfiler::ioStop(); $ini_cache->write($map_file . '-mtime', $map_mtime); $ini_cache->write($map_file, $map); } } else { $map = modApiFunc('Layout_CMS', 'generateMap', $page); } if (isset($map['default'])) { $map_default = $map['default']; } if (isset($map[$page])) { $map = array_merge($map_default, $map[$page]); } else { _fatal("The page [{$page}] not found in the map file [{$map_file}]"); } $template_path = getTemplateFileAbsolutePath('pages/templates/' . $map['template']); $tpl_cache = $application->getTplCache(); $template_mtime = filemtime($template_path); if ($template_mtime == $tpl_cache->read($template_path . '-mtime')) { $template_content = $tpl_cache->read($template_path); } else { $template_file = new CFile($template_path); $template_content = $template_file->getContent(); $tpl_cache->write($template_path . '-mtime', $template_mtime); $tpl_cache->write($template_path, $template_content); $use_cached = false; } if ($use_cached) { $contents = $tpl_cache->read($template_path . '-' . $page); } if (!isset($contents)) { $replace = array(); foreach ($map as $k => $v) { $replace['#' . $k . '#'] = $v; $replace['[' . $k . ']'] = htmlentities($v, ENT_QUOTES); } $contents = '?>' . strtr($template_content, $replace); $tpl_cache->write($template_path . '-' . $page, $contents); } ob_start(); eval($contents); $contents = ob_get_contents(); ob_end_clean(); $contents = str_replace('<br>', '<br/>', $contents); return $contents; }