本文整理汇总了PHP中Tools::ucfirst方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::ucfirst方法的具体用法?PHP Tools::ucfirst怎么用?PHP Tools::ucfirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tools
的用法示例。
在下文中一共展示了Tools::ucfirst方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
public function add()
{
$taskName = Tools::ucfirst($this->getParam('task_name'));
$taskValue = (int) $this->getParam('task_value', 0);
$taskValue = $taskValue == 0 ? Registry::get('min_task_value') : ($taskValue < Registry::get('min_task_value') ? Registry::get('min_task_value') : ($taskValue > Registry::get('max_task_value') ? Registry::get('max_task_value') : $taskValue));
if (empty($taskName)) {
exit(json_encode(['result' => 'fail', 'message' => 'Поле "Название задачи" должно быть заполнено!']));
}
$email = $this->getParam('email');
if (empty($email)) {
$id = Registry::get('user')->id;
} else {
$id = DB::run()->query('select id from users where email = ' . DB::run()->quote($email) . ' and family = ' . Registry::get('user')->family)->fetchColumn();
}
$resp = DB::run()->query('select name from tasks where user_id = ' . $id . ' and name = ' . DB::run()->quote($taskName))->fetchColumn();
if ($resp) {
exit(json_encode(['result' => 'fail', 'message' => 'Задача с таким названием уже существует!']));
}
$stmt = DB::run()->prepare('insert into tasks (user_id, family_id, name, value) values (?, ?, ?, ?)');
try {
DB::run()->beginTransaction();
$stmt->execute([$id, Registry::get('user')->family, $taskName, $taskValue]);
DB::run()->commit();
exit(json_encode(['result' => 'done', 'message' => 'Новая задача успешно добавлена!', 'type' => 'add-task']));
} catch (PDOException $e) {
DB::run()->rollBack();
exit(json_encode(['result' => 'fail', 'message' => $e->getMessage()]));
}
}
示例2: initContent
/**
* @see FrontController::initContent()
*/
public function initContent()
{
$this->display_column_left = false;
parent::initContent();
if (!$this->isTokenValid()) {
die($this->module->l($this->module->displayName . ' Error: (invalid token)'));
}
$cart = $this->context->cart;
$address = new Address((int) $cart->id_address_invoice);
$customer = new Customer((int) $cart->id_customer);
$currency = $this->context->currency;
$country = new Country((int) $address->id_country);
if (!Configuration::get('SOFORTBANKING_USER_ID')) {
die($this->module->l($this->module->displayName . ' Error: (invalid or undefined userId)'));
}
if (!Configuration::get('SOFORTBANKING_PROJECT_ID')) {
die($this->module->l($this->module->displayName . ' Error: (invalid or undefined projectId)'));
}
if (!Validate::isLoadedObject($address) || !Validate::isLoadedObject($customer) || !Validate::isLoadedObject($currency)) {
die($this->module->l($this->module->displayName . ' Error: (invalid address or customer)'));
}
$parameters = array('user_id' => Configuration::get('SOFORTBANKING_USER_ID'), 'project_id' => Configuration::get('SOFORTBANKING_PROJECT_ID'), 'sender_holder' => '', '', '', 'sender_country_id' => $country->iso_code, 'amount' => number_format($cart->getOrderTotal(), 2, '.', ''), 'currency_id' => $currency->iso_code, 'reason_1' => time() . '-' . (int) $cart->id, 'reason_2' => $customer->firstname . ' ' . Tools::ucfirst(Tools::strtolower($customer->lastname)), 'user_variable_0' => $customer->secure_key, 'user_variable_1' => (int) $cart->id, 'user_variable_2' => '', 'user_variable_3' => '', 'user_variable_4' => '', 'user_variable_5' => '', 'project_password' => Configuration::get('SOFORTBANKING_PROJECT_PW'));
$this->context->smarty->assign(array('this_path' => $this->module->getPathUri(), 'nbProducts' => $cart->nbProducts(), 'total' => $cart->getOrderTotal(), 'version' => _PS_VERSION_, 'hash' => sha1(implode('|', $parameters)), 'gateway' => 'https://www.sofortueberweisung.de/payment/start', 'cprotect' => Configuration::get('SOFORTBANKING_CPROTECT'), 'parameters' => $parameters, 'mod_lang' => $this->isSupportedLang()));
$this->setTemplate(Configuration::get('SOFORTBANKING_REDIRECT') == 'Y' ? 'payment_redirect.tpl' : 'payment_execution.tpl');
}
示例3: getFields
public function getFields()
{
parent::validateFields();
$fields['id_profile'] = (int) $this->id_profile;
$fields['id_lang'] = (int) $this->id_lang;
$fields['lastname'] = pSQL($this->lastname);
$fields['firstname'] = pSQL(Tools::ucfirst($this->firstname));
$fields['email'] = pSQL($this->email);
$fields['passwd'] = pSQL($this->passwd);
$fields['last_passwd_gen'] = pSQL($this->last_passwd_gen);
if (empty($this->stats_date_from)) {
$this->stats_date_from = date('Y-m-d 00:00:00');
}
$fields['stats_date_from'] = pSQL($this->stats_date_from);
if (empty($this->stats_date_to)) {
$this->stats_date_to = date('Y-m-d 23:59:59', strtotime('+1 year'));
}
$fields['stats_date_to'] = pSQL($this->stats_date_to);
$fields['bo_color'] = pSQL($this->bo_color);
$fields['bo_theme'] = pSQL($this->bo_theme);
$fields['bo_uimode'] = pSQL($this->bo_uimode);
$fields['bo_show_screencast'] = (int) $this->bo_show_screencast;
$fields['active'] = (int) $this->active;
return $fields;
}
示例4: postProcess
/**
* Start forms process
* @see FrontController::postProcess()
*/
public function postProcess()
{
$origin_newsletter = (bool) $this->customer->newsletter;
if (isset($_POST['years']) && isset($_POST['months']) && isset($_POST['days'])) {
$this->customer->birthday = (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
}
if (Tools::isSubmit('submitIdentity')) {
if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) && !(Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '')) {
$this->errors[] = Tools::displayError('Invalid date of birth.');
} else {
$email = trim(Tools::getValue('email'));
$this->customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
if (isset($_POST['old_passwd'])) {
$_POST['old_passwd'] = trim($_POST['old_passwd']);
}
if (!Validate::isEmail($email)) {
$this->errors[] = Tools::displayError('This email address is not valid');
} elseif ($this->customer->email != $email && Customer::customerExists($email, true)) {
$this->errors[] = Tools::displayError('An account using this email address has already been registered.');
} elseif (!isset($_POST['old_passwd']) || empty($_POST['old_passwd']) || Tools::encrypt($_POST['old_passwd']) != $this->context->cookie->passwd) {
$this->errors[] = Tools::displayError('The password you entered is incorrect.');
} elseif ($_POST['passwd'] != $_POST['confirmation']) {
$this->errors[] = Tools::displayError('The password and confirmation do not match.');
} else {
$prev_id_default_group = $this->customer->id_default_group;
// Merge all errors of this file and of the Object Model
$this->errors = array_merge($this->errors, $this->customer->validateController());
}
if (!count($this->errors)) {
$this->customer->id_default_group = (int) $prev_id_default_group;
$this->customer->firstname = Tools::ucfirst(Tools::strtolower($this->customer->firstname));
if (!isset($_POST['newsletter'])) {
$this->customer->newsletter = 0;
} elseif (!$origin_newsletter && isset($_POST['newsletter'])) {
if ($module_newsletter = Module::getInstanceByName('blocknewsletter')) {
if ($module_newsletter->active) {
$module_newsletter->confirmSubscription($this->customer->email);
}
}
}
if (!isset($_POST['optin'])) {
$this->customer->optin = 0;
}
if (Tools::getValue('passwd')) {
$this->context->cookie->passwd = $this->customer->passwd;
}
if ($this->customer->update()) {
$this->context->cookie->customer_lastname = $this->customer->lastname;
$this->context->cookie->customer_firstname = $this->customer->firstname;
$this->context->smarty->assign('confirmation', 1);
} else {
$this->errors[] = Tools::displayError('The information cannot be updated.');
}
}
}
} else {
$_POST = array_map('stripslashes', $this->customer->getFields());
}
return $this->customer;
}
示例5: hold
public function hold()
{
$userId = (int) $this->getParam('user_id');
if ($userId) {
$isId = DB::run()->query('select id from users where id = ' . $userId . ' and family = ' . Registry::get('user')->family . ' limit 1')->fetch();
if (!$isId) {
exit(json_encode(['result' => 'fail', 'message' => 'Пользователь не находится в данной семье']));
}
} else {
$userId = Registry::get('user')->id;
}
$reason = $this->getParam('task_name');
$value = (int) $this->getParam('task_value', 0);
$value = $value == 0 ? Registry::get('min_task_value') : ($value < Registry::get('min_task_value') ? Registry::get('min_task_value') : ($value > Registry::get('max_task_value') ? Registry::get('max_task_value') : $value));
if (empty($reason)) {
exit(json_encode(['result' => 'fail', 'message' => 'Поле "Причина удержания баллов" должно быть заполнено!']));
}
$stmt = DB::run()->prepare('insert into points (user_id, task_id, hold_reason, value, date) values (?, ?, ?, ?, ?)');
try {
DB::run()->beginTransaction();
$stmt->execute([$userId, 0, Tools::ucfirst($reason), -$value, date('Y-m-d H:i:s')]);
DB::run()->commit();
exit(json_encode(['result' => 'done', 'message' => 'Снятие баллов произведено успешно!', 'type' => 'hold-points']));
} catch (PDOException $e) {
DB::run()->rollBack();
exit(json_encode(['result' => 'fail', 'message' => $e->getMessage()]));
}
}
示例6: preProcess
public function preProcess()
{
parent::preProcess();
$customer = new Customer((int) self::$cookie->id_customer);
if (isset($_POST['years']) && isset($_POST['months']) && isset($_POST['days'])) {
$customer->birthday = (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
}
if (Tools::isSubmit('submitIdentity')) {
if (Module::getInstanceByName('blocknewsletter')->active) {
if (!isset($_POST['optin'])) {
$customer->optin = 0;
}
if (!isset($_POST['newsletter'])) {
$customer->newsletter = 0;
}
}
if (!isset($_POST['id_gender'])) {
$_POST['id_gender'] = 9;
}
if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) && !(Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '')) {
$this->errors[] = Tools::displayError('Invalid date of birth');
} else {
$customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
$id_customer_exists = (int) Customer::customerExists(Tools::getValue('email'), true, false);
if ($id_customer_exists && $id_customer_exists != (int) self::$cookie->id_customer) {
$this->errors[] = Tools::displayError('An account is already registered with this e-mail.');
}
$_POST['old_passwd'] = trim($_POST['old_passwd']);
if (empty($_POST['old_passwd']) || Tools::encrypt($_POST['old_passwd']) != self::$cookie->passwd) {
$this->errors[] = Tools::displayError('Your password is incorrect.');
} elseif ($_POST['passwd'] != $_POST['confirmation']) {
$this->errors[] = Tools::displayError('Password and confirmation do not match');
} else {
$prev_id_default_group = $customer->id_default_group;
$this->errors = array_unique(array_merge($this->errors, $customer->validateController(true, true)));
}
if (!count($this->errors)) {
$customer->id_default_group = (int) $prev_id_default_group;
$customer->firstname = Tools::ucfirst(Tools::strtolower($customer->firstname));
if (Tools::getValue('passwd')) {
self::$cookie->passwd = $customer->passwd;
}
if ($customer->update()) {
self::$cookie->customer_lastname = $customer->lastname;
self::$cookie->customer_firstname = $customer->firstname;
self::$smarty->assign('confirmation', 1);
} else {
$this->errors[] = Tools::displayError('Cannot update information');
}
}
}
} else {
$_POST = array_map('stripslashes', $customer->getFields());
}
$birthday = $customer->birthday ? explode('-', $customer->birthday) : array('-', '-', '-');
/* Generate years, months and days */
self::$smarty->assign(array('years' => Tools::dateYears(), 'sl_year' => $birthday[0], 'months' => Tools::dateMonths(), 'sl_month' => $birthday[1], 'days' => Tools::dateDays(), 'sl_day' => $birthday[2], 'errors' => $this->errors));
self::$smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active);
}
示例7: preProcess
public function preProcess()
{
parent::preProcess();
$customer = new Customer((int) self::$cookie->id_customer);
if (sizeof($_POST)) {
$exclusion = array('secure_key', 'old_passwd', 'passwd', 'active', 'date_add', 'date_upd', 'last_passwd_gen', 'newsletter_date_add', 'id_default_group');
$fields = $customer->getFields();
foreach ($fields as $key => $value) {
if (!in_array($key, $exclusion)) {
$customer->{$key} = key_exists($key, $_POST) ? trim($_POST[$key]) : 0;
}
}
}
if (isset($_POST['years']) and isset($_POST['months']) and isset($_POST['days'])) {
$customer->birthday = (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
}
if (Tools::isSubmit('submitIdentity')) {
if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) and !(Tools::getValue('months') == '' and Tools::getValue('days') == '' and Tools::getValue('years') == '')) {
$this->errors[] = Tools::displayError('Invalid date of birth');
} else {
$customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
$_POST['old_passwd'] = trim($_POST['old_passwd']);
if (empty($_POST['old_passwd']) or Tools::encrypt($_POST['old_passwd']) != self::$cookie->passwd) {
$this->errors[] = Tools::displayError('Your password is incorrect.');
} elseif ($_POST['passwd'] != $_POST['confirmation']) {
$this->errors[] = Tools::displayError('Password and confirmation do not match');
} else {
$prev_id_default_group = $customer->id_default_group;
$this->errors = $customer->validateControler();
}
if (!sizeof($this->errors)) {
$customer->id_default_group = (int) $prev_id_default_group;
$customer->firstname = Tools::ucfirst(Tools::strtolower($customer->firstname));
if (Tools::getValue('passwd')) {
self::$cookie->passwd = $customer->passwd;
}
if ($customer->update()) {
self::$cookie->customer_lastname = $customer->lastname;
self::$cookie->customer_firstname = $customer->firstname;
self::$smarty->assign('confirmation', 1);
} else {
$this->errors[] = Tools::displayError('Cannot update information');
}
}
}
} else {
$_POST = array_map('stripslashes', $customer->getFields());
}
if ($customer->birthday) {
$birthday = explode('-', $customer->birthday);
} else {
$birthday = array('-', '-', '-');
}
/* Generate years, months and days */
self::$smarty->assign(array('years' => Tools::dateYears(), 'sl_year' => $birthday[0], 'months' => Tools::dateMonths(), 'sl_month' => $birthday[1], 'days' => Tools::dateDays(), 'sl_day' => $birthday[2], 'errors' => $this->errors));
self::$smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active);
}
示例8: getSkins
/**
*
*/
public static function getSkins($theme)
{
$folder = _PS_ALL_THEMES_DIR_ . $theme . '/sass/skins/*.scss';
$dirs = glob($folder);
$output = array();
foreach ($dirs as $dir) {
$file = str_replace('.scss', '', basename($dir));
$output[] = array('id' => $file, 'name' => Tools::ucfirst($file));
}
return $output;
}
示例9: getFields
public function getFields()
{
parent::validateFields();
$fields['id_profile'] = intval($this->id_profile);
$fields['lastname'] = pSQL(Tools::strtoupper($this->lastname));
$fields['firstname'] = pSQL(Tools::ucfirst($this->firstname));
$fields['email'] = pSQL($this->email);
$fields['passwd'] = pSQL($this->passwd);
$fields['last_passwd_gen'] = pSQL($this->last_passwd_gen);
$fields['stats_date_from'] = pSQL($this->stats_date_from);
$fields['stats_date_to'] = pSQL($this->stats_date_to);
$fields['active'] = intval($this->active);
return $fields;
}
示例10: getThemes
public function getThemes()
{
if ($this->themes) {
return $this->themes;
}
$themes = array();
$directories = glob(_PS_ALL_THEMES_DIR_ . $this->theme_name . '/css/themes/*.css');
$themes[] = array('skin' => 'default', 'rehook' => PtsThemeSample::isReHookBySkin($this->theme_name, 'default'), 'name' => $this->l('Default'));
if ($directories) {
foreach ($directories as $dir) {
$skin = str_replace('.css', '', basename($dir));
$rehook = PtsThemeSample::isReHookBySkin($this->theme_name, $skin);
$themes[] = array('skin' => $skin, 'rehook' => $rehook, 'name' => $this->l(Tools::ucfirst($skin)));
}
}
return $themes;
}
示例11: installModuleTab
/**
* Install Module Tabs
*/
private function installModuleTab($title, $class_sfx = '', $parent = '')
{
$class = 'Admin' . Tools::ucfirst($this->name) . Tools::ucfirst($class_sfx);
if ($parent == '') {
$position = Tab::getCurrentTabId();
} else {
$position = Tab::getIdFromClassName($parent);
}
$tab = new Tab();
$tab->class_name = $class;
$tab->module = $this->name;
$tab->id_parent = (int) $position;
$langs = Language::getLanguages(false);
foreach ($langs as $l) {
$tab->name[$l['id_lang']] = $title;
}
return $tab->add(true, false);
}
示例12: getFields
public function getFields()
{
parent::validateFields();
$fields['id_profile'] = (int) $this->id_profile;
$fields['id_lang'] = (int) $this->id_lang;
$fields['lastname'] = pSQL($this->lastname);
$fields['firstname'] = pSQL(Tools::ucfirst($this->firstname));
$fields['email'] = pSQL($this->email);
$fields['passwd'] = pSQL($this->passwd);
$fields['last_passwd_gen'] = pSQL($this->last_passwd_gen);
$fields['stats_date_from'] = pSQL($this->stats_date_from);
$fields['stats_date_to'] = pSQL($this->stats_date_to);
$fields['bo_color'] = pSQL($this->bo_color);
$fields['bo_theme'] = pSQL($this->bo_theme);
$fields['bo_uimode'] = pSQL($this->bo_uimode);
$fields['active'] = (int) $this->active;
return $fields;
}
示例13: loadEngines
public function loadEngines()
{
if (!$this->engines) {
$wds = glob(dirname(__FILE__) . '/widget/*.php');
foreach ($wds as $w) {
if (basename($w) == 'index.php') {
continue;
}
require_once $w;
$f = str_replace('.php', '', basename($w));
$class = 'LeoWidget' . Tools::ucfirst($f);
if (class_exists($class)) {
$this->engines[$f] = new $class();
$this->engines[$f]->id_shop = Context::getContext()->shop->id;
$this->engines[$f]->langID = Context::getContext()->language->id;
$this->engineTypes[$f] = $this->engines[$f]->getWidgetInfo();
$this->engineTypes[$f]['type'] = $f;
$this->engineTypes[$f]['for'] = $this->engines[$f]->for_module;
}
}
}
}
示例14: loadEngines
public function loadEngines()
{
if (!$this->engines) {
$wds = glob(dirname(__FILE__) . '/widget/*.php');
foreach ($wds as $w) {
$paths = explode('/', $w);
$last = array_pop($paths);
if ($last != 'index.php') {
require_once $w;
$f = str_replace('.php', '', basename($w));
$class = 'PsMegamenuWidget' . Tools::ucfirst($f);
if (class_exists($class)) {
$this->engines[$f] = new $class();
$this->engines[$f]->id_shop = Context::getContext()->shop->id;
$this->engines[$f]->lang_id = Context::getContext()->language->id;
$this->engine_types[$f] = $this->engines[$f]->getWidgetInfo();
$this->engine_types[$f]['type'] = $f;
}
}
}
}
}
示例15: toCamelCase
/**
* Translates a string with underscores into camel case (e.g. first_name -> firstName)
* @prototype string public static function toCamelCase(string $str[, bool $capitalise_first_char = false])
*/
public static function toCamelCase($str, $catapitalise_first_char = false)
{
$str = Tools::strtolower($str);
if ($catapitalise_first_char) {
$str = Tools::ucfirst($str);
}
return preg_replace_callback('/_+([a-z])/', create_function('$c', 'return strtoupper($c[1]);'), $str);
}