private function getValue($id, $type, $lang) { $key = "product." . $id . "." . $type . "." . $lang; return LanguageHelper::getTranslatedValue($key); }
/** * Create an e-mail and check whether we are on localhost or not. * If localhost, we can't send an e-mail because of missing e-mail * provider. Otherwise, send an e-mail to the client with all * information concerning the ordering. * @return boolean e-mail send state */ private function sendMail() { $receiver = StringUtils::removeTags($_POST["name-email"]); $subject = LanguageHelper::getTranslatedValue(Config::EMAIL_SUBJECT); $message = $this->createMailBody(); // to send an HTML e-mail, the Content-type header must be set $headers = "MIME-Version: 1.0 \r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1 \r\n"; // additional headers $headers .= "From: 'lawnmower.ch Online Shop' <" . Config::EMAIL_SHOP_ADDRESS . "> \r\n"; if (Config::EMAIL_USE_BCC) { $headers .= "Bcc: " . Config::EMAIL_SHOP_ADDRESS . "\r\n"; } // if we are on localhost, always return true if (StringUtils::isLocalhost()) { return true; } // try to send the e-mail and return whether it was sent or not return mail($receiver, $subject, $message, $headers); }
/** * This method loads the key translations if necessary, * and replaces all text-keys with the chosen language translation. */ protected function handleTranslations($template) { // if translations aren't loaded yet, do it once if (!isset($_SESSION[Session::TRANSLATIONS])) { LanguageHelper::loadTranslations(); } // $matches[0] contains the results of the complete pattern // $matches[1] contains the results which matched the pattern inside the brackets (-> see regex pattern) preg_match_all(LanguageHelper::REGEX_TRANSLATION_KEYS, $template, $matches); foreach ($matches[1] as $match) { $template = str_replace("?{" . $match . "}", LanguageHelper::getTranslatedValue($match), $template); } return $template; }