本文整理汇总了PHP中Tools类的典型用法代码示例。如果您正苦于以下问题:PHP Tools类的具体用法?PHP Tools怎么用?PHP Tools使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tools类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendOrderReplay
public function sendOrderReplay($data = NULL)
{
if (!$data || empty($data['content'])) {
return 'Can not send empty data';
}
$data['send_url'] .= 'php/interface.php?m=clerk&c=UserQuiz&a=GetClientReply';
$_utilFRGInterface = $this->_getGlobalData('Util_FRGInterface', 'object');
$_utilFRGInterface->set_sendUrl($data['send_url']);
$fileData = $data['file_img'];
$isFile = is_file($fileData);
if ($isFile) {
$webPath = pathinfo($fileData);
$data['ReplyFile'] = 'http://' . $_SERVER['HTTP_HOST'] . '/Upload/Service/' . date('Ymd', CURRENT_TIME) . '/' . $webPath["basename"];
}
unset($data['send_url'], $data['file_img']);
$data['_sign'] = md5(TAKE_KEY . CURRENT_TIME);
$data['_verifycode'] = CURRENT_TIME;
$_utilFRGInterface->setPost($data);
$data = $_utilFRGInterface->callInterface();
$errorInfo = Tools::getLang('SEND_MSG', 'Control_WorkOrder');
if ($data) {
if ($data['msgno'] == 1) {
return true;
}
$errorInfo = Tools::getLang('FRG_SEND_ERROR', 'Control_WorkOrder', array('data[message]' => $data['message']));
}
if ($isFile) {
unlink($fileData);
}
return $errorInfo;
}
示例2: getTranslationsFieldsChild
/**
* Check then return multilingual fields for database interaction
*
* @return array Multilingual fields
*/
public function getTranslationsFieldsChild()
{
parent::validateFieldsLang();
$fieldsArray = array('title', 'url');
$fields = array();
$languages = Language::getLanguages(false);
$defaultLanguage = (int) Configuration::get('PS_LANG_DEFAULT');
foreach ($languages as $language) {
$fields[$language['id_lang']]['id_lang'] = (int) $language['id_lang'];
$fields[$language['id_lang']][self::$definition['primary']] = (int) $this->id;
foreach ($fieldsArray as $field) {
if (!Validate::isTableOrIdentifier($field)) {
die(Tools::displayError());
}
if (isset($this->{$field}[$language['id_lang']]) and !empty($this->{$field}[$language['id_lang']])) {
$fields[$language['id_lang']][$field] = pSQL($this->{$field}[$language['id_lang']], true);
} elseif (in_array($field, $this->fieldsRequiredLang)) {
$fields[$language['id_lang']][$field] = pSQL($this->{$field}[$defaultLanguage], true);
} else {
$fields[$language['id_lang']][$field] = '';
}
}
}
return $fields;
}
示例3: getContent
public function getContent()
{
// If we try to update the settings
$output = '';
if (isset($_POST['submitModule'])) {
Configuration::updateValue('blocksocial_facebook', $_POST['facebook_url'] != '' ? $_POST['facebook_url'] : '');
Configuration::updateValue('blocksocial_twitter', $_POST['twitter_url'] != '' ? $_POST['twitter_url'] : '');
Configuration::updateValue('blocksocial_rss', $_POST['rss_url'] != '' ? $_POST['rss_url'] : '');
$output = '<div class="conf confirm">' . $this->l('Configuration updated') . '</div>';
}
return '
<h2>' . $this->displayName . '</h2>
' . $output . '
<form action="' . Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']) . '" method="post">
<fieldset class="width2">
<label for="facebook_url">' . $this->l('Facebook URL: ') . '</label>
<input type="text" id="facebook_url" name="facebook_url" value="' . Tools::safeOutput(Configuration::get('blocksocial_facebook') != "" ? Configuration::get('blocksocial_facebook') : "") . '" />
<div class="clear"> </div>
<label for="twitter_url">' . $this->l('Twitter URL: ') . '</label>
<input type="text" id="twitter_url" name="twitter_url" value="' . Tools::safeOutput(Configuration::get('blocksocial_twitter') != "" ? Configuration::get('blocksocial_twitter') : "") . '" />
<div class="clear"> </div>
<label for="rss_url">' . $this->l('RSS URL: ') . '</label>
<input type="text" id="rss_url" name="rss_url" value="' . Tools::safeOutput(Configuration::get('blocksocial_rss') != "" ? Configuration::get('blocksocial_rss') : "") . '" />
<div class="clear"> </div>
<br /><center><input type="submit" name="submitModule" value="' . $this->l('Update settings') . '" class="button" /></center>
</fieldset>
</form>';
}
示例4: renderContent
public function renderContent($args, $setting)
{
$t = array('name' => '', 'image_folder_path' => '', 'limit' => 12, 'columns' => 4);
$protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
$url = Tools::htmlentitiesutf8($protocol . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__);
$setting = array_merge($t, $setting);
$oimages = array();
if ($setting['image_folder_path']) {
$path = _PS_ROOT_DIR_ . '/' . trim($setting['image_folder_path']) . '/';
$path = str_replace("//", "/", $path);
if (is_dir($path)) {
$images = glob($path . '*.*');
$exts = array('jpg', 'gif', 'png');
foreach ($images as $cnt => $image) {
$ext = Tools::substr($image, Tools::strlen($image) - 3, Tools::strlen($image));
if (in_array(Tools::strtolower($ext), $exts)) {
if ($cnt < (int) $setting['limit']) {
$i = str_replace("\\", "/", '' . $setting['image_folder_path'] . "/" . basename($image));
$i = str_replace("//", "/", $i);
$oimages[] = $url . $i;
}
}
}
}
}
$images = array();
$setting['images'] = $oimages;
$output = array('type' => 'image', 'data' => $setting);
return $output;
}
示例5: _prepareHook
protected function _prepareHook($params)
{
$languages = Language::getLanguages(true, $this->context->shop->id);
if (!count($languages)) {
return false;
}
$link = new Link();
if ((int) Configuration::get('PS_REWRITING_SETTINGS')) {
$default_rewrite = array();
if (Dispatcher::getInstance()->getController() == 'product' && ($id_product = (int) Tools::getValue('id_product'))) {
$rewrite_infos = Product::getUrlRewriteInformations((int) $id_product);
foreach ($rewrite_infos as $infos) {
$default_rewrite[$infos['id_lang']] = $link->getProductLink((int) $id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int) $infos['id_lang']);
}
}
if (Dispatcher::getInstance()->getController() == 'category' && ($id_category = (int) Tools::getValue('id_category'))) {
$rewrite_infos = Category::getUrlRewriteInformations((int) $id_category);
foreach ($rewrite_infos as $infos) {
$default_rewrite[$infos['id_lang']] = $link->getCategoryLink((int) $id_category, $infos['link_rewrite'], $infos['id_lang']);
}
}
if (Dispatcher::getInstance()->getController() == 'cms' && (($id_cms = (int) Tools::getValue('id_cms')) || ($id_cms_category = (int) Tools::getValue('id_cms_category')))) {
$rewrite_infos = isset($id_cms) && !isset($id_cms_category) ? CMS::getUrlRewriteInformations($id_cms) : CMSCategory::getUrlRewriteInformations($id_cms_category);
foreach ($rewrite_infos as $infos) {
$arr_link = isset($id_cms) && !isset($id_cms_category) ? $link->getCMSLink($id_cms, $infos['link_rewrite'], null, $infos['id_lang']) : $link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']);
$default_rewrite[$infos['id_lang']] = $arr_link;
}
}
$this->smarty->assign('lang_rewrite_urls', $default_rewrite);
}
return true;
}
示例6: postProcess
public function postProcess()
{
$cart = $this->context->cart;
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
Tools::redirect('index.php?controller=order&step=1');
}
// Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
$authorized = false;
foreach (Module::getPaymentModules() as $module) {
if ($module['name'] == 'cheque') {
$authorized = true;
break;
}
}
if (!$authorized) {
die($this->module->l('This payment method is not available.', 'validation'));
}
$customer = new Customer($cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}
$currency = $this->context->currency;
$total = (double) $cart->getOrderTotal(true, Cart::BOTH);
$mailVars = array('{cheque_name}' => Configuration::get('CHEQUE_NAME'), '{cheque_address}' => Configuration::get('CHEQUE_ADDRESS'), '{cheque_address_html}' => str_replace("\n", '<br />', Configuration::get('CHEQUE_ADDRESS')));
$this->module->validateOrder((int) $cart->id, Configuration::get('PS_OS_CHEQUE'), $total, $this->module->displayName, NULL, $mailVars, (int) $currency->id, false, $customer->secure_key);
Tools::redirect('index.php?controller=order-confirmation&id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
}
示例7: getContent
public function getContent()
{
$html = '';
// If we try to update the settings
if (isset($_POST['submitModule'])) {
Configuration::updateValue('blockcontactinfos_company', isset($_POST['company']) && $_POST['company'] != '' ? $_POST['company'] : Configuration::get('PS_SHOP_NAME'));
Configuration::updateValue('blockcontactinfos_address', isset($_POST['address']) && $_POST['address'] != '' ? $_POST['address'] : '');
Configuration::updateValue('blockcontactinfos_phone', isset($_POST['phone']) && $_POST['phone'] != '' ? $_POST['phone'] : '');
Configuration::updateValue('blockcontactinfos_email', isset($_POST['email']) && $_POST['email'] != '' ? $_POST['email'] : Configuration::get('PS_SHOP_EMAIL'));
$html .= '<div class="confirm">' . $this->l('Configuration updated') . '</div>';
}
$html .= '
<h2>' . $this->displayName . '</h2>
<form action="' . Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']) . '" method="post">
<fieldset>
<p><label for="company">' . $this->l('Company name') . ' :</label>
<input type="text" id="company" name="company" value="' . Tools::safeOutput(Configuration::get('blockcontactinfos_company')) . '" /></p>
<p><label for="address">' . $this->l('Address') . ' :</label>
<textarea id="address" name="address" cols="60" rows="4">' . Tools::safeOutput(Configuration::get('blockcontactinfos_address')) . '</textarea></p>
<p><label for="phone">' . $this->l('Phone number') . ' :</label>
<input type="text" id="phone" name="phone" value="' . Tools::safeOutput(Configuration::get('blockcontactinfos_phone')) . '" /></p>
<p><label for="email">' . $this->l('Email') . ' :</label>
<input type="text" id="email" name="email" value="' . Tools::safeOutput(Configuration::get('blockcontactinfos_email')) . '" /> </p>
<div class="margin-form">
<input type="submit" name="submitModule" value="' . $this->l('Update settings') . '" class="button" /></center>
</div>
</fieldset>
</form>
';
return $html;
}
示例8: displayTop
/**
* displays available actions in the top of the order list
*/
public function displayTop()
{
$header = "<fieldset>";
$header .= "<div id='header_sceau'>\n\t\t\t\t<div class='sceau_control'>\n\t\t\t\t\t<a href='index.php?tab=AdminSceau&action=ResendOrders&token=" . Tools::getAdminTokenLite('AdminSceau') . "'>\n\t\t\t\t\t\t<img src='" . _PS_BASE_URL_ . __PS_BASE_URI__ . "modules/fianetsceau/img/sceauresend14.png'/>" . $this->l('Resend orders') . "\n\t\t\t\t\t</a>\n\t\t\t\t</div>\n\t\t\t</div>";
$header .= '</fieldset>';
echo $header;
}
示例9: rev_uploader
private function rev_uploader()
{
$key = Tools::getValue('security_key');
if (empty($key) || Tools::encrypt(GlobalsRevSlider::MODULE_NAME) != $key) {
echo json_encode(array('error_on' => 1, 'error_details' => 'Security Error'));
die;
}
$targetFolder = ABSPATH . '/uploads/';
$randnum = rand(00, 9999999);
$sds_time = time();
$NewFileName = $randnum . '-' . $sds_time;
//$verifyToken = md5('unique_salt' . $_POST['timestamp']);
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
//$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetPath = $targetFolder;
//$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
// Validate the file type
$fileTypes = array('jpg', 'jpeg', 'gif', 'png');
// File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'], $fileTypes)) {
// $worked = UniteFunctionsWPRev::import_media_img($tempFile, $targetPath, $randnum.$_FILES['Filedata']['name']);
$worked = UniteFunctionsWPRev::import_media_img($tempFile, $targetPath, $NewFileName . '.' . $fileParts['extension']);
if (!empty($worked)) {
echo '1';
}
} else {
echo '0';
}
}
}
示例10: displayForm
public function displayForm()
{
// Get default Language
$default_lang = (int) Configuration::get('PS_LANG_DEFAULT');
// Init Fields form array
$fields_form[0]['form'] = array('legend' => array('title' => $this->l('Settings')), 'input' => array(array('type' => 'text', 'label' => $this->l('ID Facebook:'), 'name' => 'facebookgraph_id', 'size' => '100', 'desc' => $this->l('A Facebook Platform application ID that administers this page.')), array('type' => 'text', 'label' => $this->l('Name shop:'), 'name' => 'facebookgraph_name', 'size' => '100', 'desc' => $this->l('Name of this shop.')), array('type' => 'text', 'label' => $this->l('Url shop:'), 'name' => 'facebookgraph_url', 'size' => '100', 'desc' => $this->l('The canonical URL of this shop.')), array('type' => 'text', 'label' => $this->l('Type shop:'), 'name' => 'facebookgraph_type', 'size' => '100', 'desc' => $this->l('The type of this shop.')), array('type' => 'text', 'label' => $this->l('Title:'), 'name' => 'facebookgraph_title', 'size' => '100', 'desc' => $this->l('The title of this shop.')), array('type' => 'text', 'label' => $this->l('Description:'), 'name' => 'facebookgraph_description', 'size' => '100', 'desc' => $this->l('A one to two sentence description of this shop.')), array('type' => 'text', 'label' => $this->l('Image url:'), 'name' => 'facebookgraph_image', 'size' => '100', 'desc' => $this->l('An image URL which should represent your shop within the graph. The image must be at least 50px by 50px (though minimum 200px by 200px is preferred) and have a maximum aspect ratio of 3:1. We support PNG, JPEG and GIF formats.'))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
$helper = new HelperForm();
// Module, t oken and currentIndex
$helper->module = $this;
$helper->name_controller = $this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name;
// Language
$helper->default_form_language = $default_lang;
$helper->allow_employee_form_lang = $default_lang;
// Title and toolbar
$helper->title = $this->displayName;
$helper->show_toolbar = true;
// false -> remove toolbar
$helper->toolbar_scroll = true;
// yes - > Toolbar is always visible on the top of the screen.
$helper->submit_action = 'submit' . $this->name;
$helper->toolbar_btn = array('save' => array('desc' => $this->l('Save'), 'href' => AdminController::$currentIndex . '&configure=' . $this->name . '&save' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules')), 'back' => array('href' => AdminController::$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to list')));
// Load current value
$helper->fields_value['facebookgraph_id'] = Configuration::get('facebookgraph_id');
$helper->fields_value['facebookgraph_type'] = Configuration::get('facebookgraph_type');
$helper->fields_value['facebookgraph_title'] = Configuration::get('facebookgraph_title');
$helper->fields_value['facebookgraph_url'] = Configuration::get('facebookgraph_url');
$helper->fields_value['facebookgraph_name'] = Configuration::get('facebookgraph_name');
$helper->fields_value['facebookgraph_image'] = Configuration::get('facebookgraph_image');
$helper->fields_value['facebookgraph_description'] = Configuration::get('facebookgraph_description');
return $helper->generateForm($fields_form);
}
示例11: initContent
public function initContent()
{
$this->errors[] = $this->trans('Controller not found', array(), 'Admin.Notifications.Error');
$tpl_vars['controller'] = Tools::getvalue('controllerUri', Tools::getvalue('controller'));
$this->context->smarty->assign($tpl_vars);
parent::initContent();
}
示例12: upgrade_module_0_9
function upgrade_module_0_9($module)
{
$module_path = $module->getLocalPath();
$img_folder_path = $module->getLocalPath() . 'img';
$fixture_img_path = $module->getLocalPath() . 'img' . DIRECTORY_SEPARATOR . 'fixtures';
if (!Tools::file_exists_cache($img_folder_path)) {
mkdir($img_folder_path);
}
if (!Tools::file_exists_cache($fixture_img_path)) {
mkdir($fixture_img_path);
}
$files = scandir($module->getLocalPath());
foreach ($files as $file) {
if (strncmp($file, 'advertising', 11) == 0) {
if ($file == 'advertising.jpg') {
copy($module_path . $file, $fixture_img_path . DIRECTORY_SEPARATOR . $file);
} else {
copy($module_path . $file, $img_folder_path . DIRECTORY_SEPARATOR . $file);
}
unlink($module_path . $file);
}
}
Tools::clearCache(Context::getContext()->smarty, $module->getTemplatePath('blockadvertising.tpl'));
return true;
}
示例13: displayHelp
public static function displayHelp($label, $iso_lang, $country, $ps_version)
{
$infos = HelpAccess::retrieveInfos($label, $iso_lang, $country, $ps_version);
if (array_key_exists('image', $infos) && $infos['image'] != 'none') {
echo '
<a class="help-button" href="#" onclick="showHelp(\'' . HelpAccess::URL . '\',\'' . $label . '\',\'' . $iso_lang . '\',\'' . $ps_version . '\',\'' . $infos['version'] . '\',\'' . $country . '\');" title="' . Tools::htmlentitiesUTF8($infos['tooltip']) . '">
<img id="help-' . $label . '" src="../img/admin/' . Tools::htmlentitiesUTF8($infos['image']) . '" alt="" class="middle" style="margin-top: -5px"/> ' . Tools::displayError('HELP') . '
</a>
';
if (!empty($infos['tooltip'])) {
echo ' <script type="text/javascript">
$(document).ready(function() {
$("a.help-button").cluetip({
splitTitle: "|",
cluetipClass: "help-button",
showTitle: false,
arrows: true,
dropShadow: false,
positionBy: "auto"
});
});
</script>';
}
}
}
示例14: createEntityCustomer
public function createEntityCustomer($identifier, array $data, array $data_lang)
{
if ($identifier == 'John') {
$data['passwd'] = Tools::encrypt('123456789');
}
return $this->createEntity('customer', $identifier, 'Customer', $data, $data_lang);
}
示例15: hookAdminStatsModules
public function hookAdminStatsModules($params)
{
$totalVisits = $this->getTotalVisits();
$totalGuests = $this->getTotalGuests();
if (Tools::getValue('export')) {
$this->csvExport(array('layers' => 2, 'type' => 'line', 'option' => 3));
}
$this->_html = '
<fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->displayName . '</legend>
<p><center>
<img src="../img/admin/down.gif" />' . $this->l('A visit corresponds to an internet user coming to your shop. Until the end of their session, only one visit is counted.') . '
' . $this->l('A visitor is an unknown person, who has not registered or logged on, surfing on your shop. A visitor can come and visit your shop many times.') . '
</center></p>
<div style="margin-top:20px"></div>
<p>' . $this->l('Total visits:') . ' ' . $totalVisits . '</p>
<p>' . $this->l('Total visitors:') . ' ' . $totalGuests . '</p>
' . ($totalVisits ? ModuleGraph::engine(array('layers' => 2, 'type' => 'line', 'option' => 3)) . '<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=1"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a></p>' : '') . '
</fieldset>
<br class="clear" />
<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> ' . $this->l('Guide') . '</legend>
<h2>' . $this->l('Determine the interest of a visit') . '</h2>
' . $this->l('The visitors\' evolution graph strongly resembles the visits\' graph, but provides additional information:') . '<br />
<ul>
<li>' . $this->l('If this is the case, congratulations, your website is well planned and pleasing.') . '</li>
<li>' . $this->l('Otherwise, the conclusion is not so simple. The problem can be aesthetic or ergonomic, or else the offer is not sufficient. It is also possible that these visitors mistakenly came here without particular interest for your shop; this phenomenon often happens with the search engines.') . '</li>
</ul>
' . $this->l('This information is mostly qualitative: you have to determine the interest of a disjointed visit.') . '<br />
</fieldset>';
return $this->_html;
}