本文整理汇总了PHP中Translate::string方法的典型用法代码示例。如果您正苦于以下问题:PHP Translate::string方法的具体用法?PHP Translate::string怎么用?PHP Translate::string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translate
的用法示例。
在下文中一共展示了Translate::string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public function update()
{
$product_id = 0;
// Redirect to product create if product_id is not exists
if (isset($this->request->get['product_id'])) {
$product_id = (int) $this->request->get['product_id'];
} else {
// Log hack attempt
$this->security_log->write('Try to get product without product_id param');
$this->response->redirect($this->url->link('account/product/create'));
}
// Redirect to login page if user is not logged
if (!$this->auth->isLogged()) {
$this->response->redirect($this->url->link('account/account/login', 'redirect=' . urlencode($this->url->link('account/product/update', 'product_id=' . $product_id))));
}
// Check if user has product
if (!$this->model_catalog_product->userHasProduct($this->auth->getId(), $product_id)) {
// Log hack attempt
$this->security_log->write('Try to get not own\'s product_id #' . $product_id);
// Redirect to safe page
$this->response->redirect($this->url->link('account/product'));
}
if ('POST' == $this->request->getRequestMethod() && $this->_validateProductForm()) {
// Load dependencies
$translate = new Translate();
$color = new Color();
// Create languages registry
$languages = array();
foreach ($this->model_common_language->getLanguages() as $language) {
$languages[$language->language_id] = $language->code;
}
// Set active directory
$directory = DIR_STORAGE . $this->auth->getId() . DIR_SEPARATOR;
// Start transaction
$this->db->beginTransaction();
// Add product
$this->model_catalog_product->updateProduct($product_id, $this->request->post['category_id'], $this->request->post['currency_id'], $this->request->post['regular_price'], $this->request->post['exclusive_price'], $this->request->post['withdraw_address'], FilterUri::alias($this->request->post['product_description'][$this->language->getId()]['title']), (int) $this->auth->isVerified());
// Add 301 rule if product has new URI
$url = new Url($this->db, $this->request, $this->response, $this->url->link('common/home'));
$old_url = $this->url->link('catalog/product', 'product_id=' . $product_id);
$new_url = $url->link('catalog/product', 'product_id=' . $product_id);
if ($old_url != $new_url) {
$this->model_common_redirect->createRedirect(301, str_replace($this->url->link('common/home'), false, $old_url), str_replace($this->url->link('common/home'), false, $new_url));
}
// Add product description
$this->model_catalog_product->deleteProductDescriptions($product_id);
foreach ($this->request->post['product_description'] as $language_id => $product_description) {
$this->model_catalog_product->createProductDescription($product_id, $language_id, empty(trim($product_description['title'])) ? $translate->string($this->request->post['product_description'][$this->language->getId()]['title'], $this->language->getCode(), $languages[$language_id]) : $product_description['title'], empty(trim($product_description['description'])) ? $translate->string($this->request->post['product_description'][$this->language->getId()]['description'], $this->language->getCode(), $languages[$language_id]) : $product_description['description']);
}
// Add Tags
$this->model_catalog_product->deleteProductToTagByProductId($product_id);
// Prepare tags from request
foreach ($this->request->post['product_description'] as $language_id => $product_description) {
// Process current language not empty field only
if (!empty($product_description['tags']) && $language_id == $this->language->getId()) {
// Separate a tags string and create multilingual registry
foreach (explode(',', $product_description['tags']) as $name) {
// Get tag id
$name = mb_strtolower(trim($name));
// Saved tags registry
if ($tag = $this->model_catalog_tag->getTagByName($name)) {
$tag_id = $tag->tag_id;
} else {
// Create new tag
$tag_id = $this->model_catalog_tag->addTag();
// Create descriptions for each language
foreach ($languages as $language_id => $code) {
$this->model_catalog_tag->addTagDescription($tag_id, $language_id, $translate->string($name, $this->language->getCode(), $code));
}
}
// Save new relations
$this->model_catalog_product->addProductToTag($product_id, $tag_id);
}
}
}
// Add file
if ($file_content = file_get_contents($directory . $this->request->post['product_file_id'] . '.' . STORAGE_FILE_EXTENSION)) {
$this->model_catalog_product->deleteProductFiles($product_id);
$product_file_id = $this->model_catalog_product->createProductFile($product_id, md5($file_content), sha1($file_content));
rename($directory . $this->request->post['product_file_id'] . '.' . STORAGE_FILE_EXTENSION, $directory . $product_file_id . '.' . STORAGE_FILE_EXTENSION);
}
// Add demos
$this->model_catalog_product->deleteProductDemos($product_id);
if (isset($this->request->post['demo'])) {
foreach ($this->request->post['demo'] as $row => $demo) {
$product_demo_id = $this->model_catalog_product->createProductDemo($product_id, $demo['sort_order'], $demo['url'], $this->request->post['main_demo'] == $row ? 1 : 0);
foreach ($demo['title'] as $language_id => $title) {
$this->model_catalog_product->createProductDemoDescription($product_demo_id, $language_id, empty(trim($title)) ? $translate->string($demo['title'][$this->language->getId()], $this->language->getCode(), $languages[$language_id]) : $title);
}
}
}
// Update images
$this->model_catalog_product->deleteProductImages($product_id);
if (isset($this->request->post['image'])) {
foreach ($this->request->post['image'] as $row => $image) {
// Add new images
$product_image_id = $this->model_catalog_product->createProductImage($product_id, $image['sort_order'], $this->request->post['main_image'] == $row ? 1 : 0, isset($image['watermark']) ? 1 : 0);
// Generate image titles
foreach ($image['title'] as $language_id => $title) {
$this->model_catalog_product->createProductImageDescription($product_image_id, $language_id, empty(trim($title)) ? $translate->string($image['title'][$this->language->getId()], $this->language->getCode(), $languages[$language_id]) : $title);
//.........这里部分代码省略.........
示例2:
echo $page == $i ? "selected" : "";
?>
><?php
echo Translate::string("results.page");
?>
<?php
echo $i + 1;
?>
of <?php
echo $total;
?>
</option>
<?php
}
?>
</select>
<input type="hidden" id="total-pages" value="<?php
echo $total;
?>
">
<a href="" class="btn next-page"><?php
echo Translate::string("results.next_page");
?>
▶</a>
</section>
<?php
}
?>
<script src="lib/js/results-list.js"></script>
<?php
}
示例3:
&sub_cat_id=<?php
echo $cat["id"];
?>
#advert-create"><?php
echo Translate::string("categorySub." . Product::slugify($cat["name"]));
?>
</a></label>
</li>
<?php
}
} else {
?>
<li>
<input type="radio" name="subCategory" value="" id="sub-cat-0">
<label for="sub-cat-0"><?php
echo Translate::string("categories.no_sub_categories");
?>
</label>
</li>
<?php
}
?>
<script type="text/javascript">
$("#create-sub-cat li").unbind().click(function (e) {
e.preventDefault();
// uncheck whatever was checked before by the php $_GET
$("#create-sub-cat input").prop("checked", false);
// make the currently clicked input to checked
$(this).children("input").prop("checked", true);
});
示例4:
<div id="uploaded_images"></div>
</div>
</div>
</div>
<div id="step-2" class="hidden">
<h1><?php
echo Translate::string("create_ad.preview_of_your_advertisement");
?>
</h1>
<div id="preview-container">
<?php
// include("lib/ajax/advertisement-expanded.php");
?>
</div>
<button class="fullwidth" style="margin:60px 0 10px 0;"><?php
echo Translate::string("create_ad.continue_to_next_step");
?>
</button>
<button class="fullwidth" ><?php
echo Translate::string("create_ad.make_changes");
?>
</button>
</div>
<div id="step-3" class="hidden"></div>
<?php
}
?>
</div>
</section><?php
// #advert-create
示例5: spl_autoload_register
$birthday = $_POST["birthday"];
// optional
$password = $_POST["password"];
$confirm_password = $_POST["confirm_password"];
$javascript = $_POST["javascript"];
$javascript = 1;
$role_id = 2;
$lang_id = 1;
// Auto load the class when it is beeing created
spl_autoload_register(function ($class) {
require_once "../classes/" . $class . ".class.php";
});
if ($password != $confirm_password) {
die(Translate::string("register_alert.passwords_dont_match"));
}
if (empty($name) or empty($email) or empty($phone) or empty($password) or empty($confirm_password)) {
die(Translate::string("register_alert.fill_out_all_fields"));
} else {
try {
$user = new User();
$user->company_name = $company_name;
$user->company_number = $company_number;
$user->company_address = $company_address;
$user->company_zip = $company_zip;
$user->phone_2 = $phone_2;
$user->registerUser($name, $role_id, $email, $password, $phone, $lang_id, $birthday, $javascript, true);
echo Translate::string("register_alert.registration_success_please_login");
} catch (Exception $e) {
echo '' . $e->getMessage();
}
}
示例6: input
//.........这里部分代码省略.........
if ($name) {
echo "name='" . $name . "[]'";
}
?>
type="<?php
echo $type;
?>
">
<label for="<?php
echo $value['slug'] . '-' . $count;
?>
" ><?php
echo $valueName;
?>
</label>
</div>
<?php
}
?>
<?php
if ($more) {
?>
<div class="add-more-checkbox-wrap hidden">
<input type="checkbox" checked="true" ><label></label>
<input autocomplete="off" type="text" <?php
if ($name) {
echo "name='" . $name . "[]'";
}
?>
class="add-more-checkbox-input" >
<div title="Remove" class="remove-checkbox-input">X</div>
</div>
<a href="?more" class="btn add-more-checkbox-btn">+ <?php
echo Translate::string("form.add_more_btn");
?>
</a>
<?php
}
?>
</div>
</div>
<?php
} else {
echo "<div class='form-element {$class}'>";
if ($label) {
?>
<label <?php
if ($labelID) {
echo "id='" . $labelClass . "'";
}
?>
<?php
if ($id) {
echo "for='" . $id . "'";
}
?>
<?php
if ($labelClass) {
echo "class='" . $labelClass . "'";
}
?>
><?php
echo $label;
?>
</label> <?php
示例7: spl_autoload_register
<?php
require_once "../includes/session.php";
require_once "../includes/sanitize-all.php";
// Auto load the class when it is beeing created
spl_autoload_register(function ($class) {
require_once "../classes/" . $class . ".class.php";
});
if (empty($_POST["email"]) or empty($_POST["token"]) or empty($_POST["new-reset-password"]) or empty($_POST["confirm-reset-password"]) or empty($_POST["javascript"])) {
die(Translate::string("reset_password_alert.all_fields_required"));
}
if ($_POST["new-reset-password"] != $_POST["confirm-reset-password"]) {
die(Translate::string("reset_password_alert.passwords_dont_match"));
}
$email = $_POST["email"];
$token = $_POST["token"];
$new_password = $_POST["new-reset-password"];
$session_id = session_id();
$ip_address = $_SERVER['REMOTE_ADDR'];
$javascript = $_POST["javascript"];
$browser = $_SERVER['HTTP_USER_AGENT'];
if (!User::isTokenValid($email, $token)) {
die(Translate::string("reset_password_alert.token_expired"));
}
$user = new User();
$reset = $user->resetPassword($email, $new_password);
if (!$reset or !$user->destroyToken($token)) {
die(Translate::string("reset_password_alert.something_went_wrong"));
}
$user->insertLog("password changed", $email, $javascript, $browser, $ip, $session_id);
$user->checkCredentials($email, $new_password, $javascript, $browser, $ip_address, $session_id);
示例8: ob_get_contents
?>
<form id="reset-password-form" action="lib/ajax/reset-password.php" method="post" >
<input type="hidden" name="token" required="required" value="<?php
echo $_GET["reset-password"];
?>
">
<input type="hidden" name="email" required="required" value="<?php
echo $_GET["email"];
?>
">
<input class="hidden javascript-check" type="checkbox" name="javascript" value="1">
<?php
FormElement::input(array('id' => "new-reset-password", 'name' => "new-reset-password", 'label' => Translate::string("reset_password.new_passoword_label"), 'placeholder' => Translate::string("reset_password.new_passoword_placeholder"), 'type' => "password", 'required' => true));
FormElement::input(array('id' => "confirm-reset-password", 'name' => "confirm-reset-password", 'label' => Translate::string("reset_password.new_passoword_confirm_label"), 'placeholder' => Translate::string("reset_password.new_passoword_confirm_placeholder"), 'type' => "password", 'required' => true));
?>
<button>Reset Password</button>
</form>
<?php
$reset_password_modal_content = ob_get_contents();
ob_end_clean();
// end recording
} else {
$reset_password_modal_content = "<p>" . Translate::string("reset_password.expired_token") . "</p>";
}
$reset_password_modal_id = "reset-password";
$reset_password_modal_title = Translate::string("reset_password.modal_title");
$reset_password_modal_footer = '<a href="#">' . Translate::string("reset_password.modal_footer") . '</a>';
// get the modal
DocElement::modal($reset_password_modal_id, $reset_password_modal_title, $reset_password_modal_content, $reset_password_modal_footer);
}
示例9: array
// Get language registry
$statement = $db->query('SELECT * FROM `language`');
$languages = array();
foreach ($statement->fetchAll() as $language) {
$languages[$language->language_id] = $language->code;
}
// Translate product descriptions
$statement = $db->query("SELECT * FROM `product_description` WHERE `title` = '' OR description = ''");
if ($statement->rowCount()) {
foreach ($statement->fetchAll() as $untranslated) {
// Get translated data
$translated = $db->prepare("SELECT `product_id`, `language_id`, `title`, `description` FROM `product_description` WHERE `title` <> '' AND `description` <> '' AND `product_id` = ? LIMIT 1");
$translated->execute(array($untranslated->product_id));
if ($translated->rowCount() && ($translated = $translated->fetch())) {
// Translate title
if (empty($untranslated->title) && false !== ($title = $translate->string($translated->title, $languages[$translated->language_id], $languages[$untranslated->language_id]))) {
$update = $db->prepare("UPDATE `product_description` SET `title` = ? WHERE `product_id` = ? AND `language_id` = ? LIMIT 1");
$update->execute(array($title, $untranslated->product_id, $untranslated->language_id));
$total_translated++;
}
// Translate description
if (empty($untranslated->description) && false !== ($description = $translate->string($translated->description, $languages[$translated->language_id], $languages[$untranslated->language_id]))) {
$update = $db->prepare("UPDATE `product_description` SET `description` = ? WHERE `product_id` = ? AND `language_id` = ? LIMIT 1");
$update->execute(array($description, $untranslated->product_id, $untranslated->language_id));
$total_translated++;
}
}
}
}
// Translate tag descriptions
$statement = $db->query("SELECT * FROM `tag_description` WHERE `name` = ''");
示例10:
require_once "../classes/" . $class . ".class.php";
});
require_once "../includes/sanitize-all.php";
require_once "../includes/session.php";
$top_ad_page = $_POST["top_ad_page"];
$categoryID = $_POST["categoryID"];
$hidden = "hidden";
} else {
$hidden = "";
$top_ad_page = 0;
$categoryID = "%";
}
?>
<div class="container">
<h2><?php
echo Translate::string("top_ads.title");
?>
</h2>
<!--ajax-->
<div class="top-ad-container">
<div id="top-ad-pages">
<div class="top-ad-page<?php
echo $top_ad_page;
?>
top-ad-page <?php
echo $hidden;
?>
currentTopAdPage" data-top-ad-page-id="<?php
echo $top_ad_page;
?>
">
示例11: getSelectOfAllCategories
public function getSelectOfAllCategories($settings = array())
{
// name, order, first-option, id, class
// Setting the defaults
if (!empty($settings["id"])) {
$id = $settings["id"];
} else {
$id = false;
}
if (!empty($settings["class"])) {
$class = $settings["class"];
} else {
$class = false;
}
if (!empty($settings["name"])) {
$name = $settings["name"];
} else {
$name = "category";
}
if (!empty($settings["required"])) {
$required = $settings["required"];
} else {
$required = false;
}
if (!empty($settings["multiple"])) {
$multiple = $settings["multiple"];
} else {
$multiple = false;
}
if (!empty($settings["inlineCss"])) {
$inlineCss = $settings["inlineCss"];
} else {
$inlineCss = false;
}
if (!empty($settings["price"])) {
$price = $settings["price"];
} else {
$price = false;
}
if (!empty($settings["order"])) {
$order = $settings["order"];
} else {
$order = "name ASC";
}
if (!empty($settings["first-option"])) {
$first_option = $settings["first-option"];
} else {
$first_option = "-- Select Category --";
}
$this->query("SELECT DISTINCT m.* FROM categories_main as m, categories_sub as s WHERE m.id = s.main_cat_id ORDER BY " . $order);
$mainCategories = $this->fetchAll();
?>
<select name="<?php
echo $name;
?>
" <?php
if ($id) {
echo "id='" . $id . "'";
}
?>
<?php
if ($class) {
echo "class='" . $class . "'";
}
?>
<?php
if ($required) {
echo "required";
}
?>
<?php
if ($multiple) {
echo "multiple";
}
?>
<?php
if ($inlineCss) {
echo "style='" . $inlineCss . "'";
}
?>
>
<option value=""><?php
echo $first_option;
?>
</option>
<?php
if ($mainCategories) {
?>
<?php
foreach ($mainCategories as $mCat) {
?>
<optgroup label="<?php
echo Translate::string("categoryMain." . Product::slugify($mCat['name']));
?>
">
<?php
$this->query("SELECT id, name FROM categories_sub WHERE main_cat_id = :mCatID ORDER BY " . $order);
$this->bind(':mCatID', $mCat['id']);
$subCategories = $this->fetchAll();
?>
//.........这里部分代码省略.........
示例12:
?>
</em> <?php
echo $user_info["name"];
?>
</p>
<p><em><?php
echo Translate::string("contact_seller_modal.email");
?>
</em> <a href="mailto:<?php
echo $user_info["email"];
?>
"><?php
echo $user_info["email"];
?>
</a></p>
<p><em><?php
echo Translate::string("contact_seller_modal.phone");
?>
</em> <a href="tel:<?php
echo $user_info["phone"];
?>
"><?php
echo $user_info["phone"];
?>
</a></p>
<?php
// $modal_content = ob_get_contents();
// ob_end_clean(); // end recording
// echo $modal_content;
// get the modal
// DocElement::modal($alert_modal_id, $title, $modal_content, $footer);
示例13: array
<a href="#" class="left" id="logo" style="position: relative;">
<img src="lib/images/elements/logo.svg" alt="finnplus logo image">
<span style="font-family: 'Lato', sans-serif; font-weight: 300; font-size: 1rem; position: absolute; left: 0; bottom: 2.2rem; color: #2b3990;" >New or Used</span>
<span style="font-family: 'Lato', sans-serif; font-weight: 300; font-size: 1rem; position: absolute; right: 1.2rem; bottom: 2.2rem; color: #2b3990;" >Buy or Sell</span>
</a>
<div class="two-third right">
<div id="search-container">
<form id="search-form" action="main-search.php" method="GET" role="search">
<?php
$select_options = array("id" => "search-cat-select", "class" => "btn", "name" => "category", "first-option" => Translate::string("header.main_search_category_first_option"), "required" => false);
$db->getSelectOfAllCategories($select_options);
?>
<span id="search-cat-span" class="btn"><?php
echo Translate::string("header.main_search_category_first_option");
?>
</span>
<input type="text" name="search" placeholder="<?php
echo Translate::string("header.main_search_placeholder");
?>
" required="required">
<button type="submit" id="search-btn"><?php
echo Translate::string("header.main_search_button");
?>
</button>
</form>
</div>
</div>
</div>
</section><?php
// #header
示例14: session_start
if (!$_SESSION) {
session_start();
}
// Auto load the class when it is beeing created
spl_autoload_register(function ($class) {
require_once "../classes/" . $class . ".class.php";
});
if (empty($_POST["email"])) {
die(Translate::string("forgot_password.email_missing"));
} else {
require_once "../includes/sanitize-all.php";
$email = $_POST["email"];
if (!User::userEmailExist($email)) {
die(Translate::string("forgot_password.wrong_email"));
}
$token = User::insertToken($email);
if (!$token) {
die("token insert failed");
}
$reset_link = "http://www.finnplus.no/?reset-password=" . $token . "&email=" . urlencode($email);
$mailto = $email;
$subject = Translate::string("forgot_password.email_subject");
$headers = "Mime-Version: 1.0 \r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1 \r\n";
$headers .= "From: <no-reply@FinnPluss.no> \r\n";
// $headers .= "Reply-to: info@finnplus.no \r\n";
$message = sprintf(Translate::string("forgot_password.email_message"), "<br><a href='" . $reset_link . "'>", $reset_link . "</a><hr>");
$send_mail = mail($mailto, $subject, $message, $headers);
// Send the email
echo $send_mail ? Translate::string("forgot_password.email_send_success_message") : Translate::string("forgot_password.email_send_failure_message");
}
示例15: getCompareItem
public function getCompareItem($advert_id)
{
$db = new Database();
$db->query("SELECT id, title, price, currency, city_name, country_code, zip, date_created FROM products_view WHERE id = :id LIMIT 1");
$db->bind(":id", $advert_id);
$advert = $db->single();
if ($advert) {
$db->query("SELECT uuid FROM product_images WHERE product_id = :id ORDER BY date_uploaded ASC LIMIT 1");
$db->bind(":id", $advert_id);
$advert_img = $db->single();
?>
<div class="compare-item row">
<div class="cell"><div class="compare-thumb"><img alt="test image" src="lib/images/uploads/thumbnail/<?php
echo $advert_img["uuid"];
?>
"></div></div>
<div class="cell"><?php
echo $advert["id"];
?>
</div>
<div class="cell"><?php
echo $advert["title"];
?>
</div>
<div class="cell"><?php
echo $advert["price"];
?>
<?php
echo $advert["currency"];
?>
</div>
<div class="cell"><?php
echo $advert["city_name"];
?>
(<?php
echo $advert["zip"];
?>
), <?php
echo strtoupper($advert["country_code"]);
?>
</div>
<div class="cell"><?php
echo $advert["date_created"];
?>
</div>
<div class="cell"><a data-id="<?php
echo $advert["id"];
?>
<" class="remove-link remove-from-compare-btn"><?php
echo Translate::string("compare.remove");
?>
</a></div>
</div>
<?php
} else {
echo "<p>No advert found for compare</p>";
}
}