本文整理汇总了PHP中Lang::trans方法的典型用法代码示例。如果您正苦于以下问题:PHP Lang::trans方法的具体用法?PHP Lang::trans怎么用?PHP Lang::trans使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lang
的用法示例。
在下文中一共展示了Lang::trans方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validatePattern
protected function validatePattern()
{
$result = false;
if ($this->pattern && strlen($this->value) && !preg_match("~{$this->pattern}~", $this->value)) {
$result = Lang::trans('PATTERN_MISMATCH');
}
return $result;
}
示例2: init
protected function init()
{
parent::init();
$this->addValidator(function () {
if ($this->multiple && array_diff($this->value, array_keys($this->values))) {
return Lang::trans('SELECT_INVALID_VALUE');
}
});
}
示例3: init
public function init()
{
parent::init();
$this->addValidator(function (Field $field) {
if (strlen($field->value) && !is_numeric($field->value)) {
$field->addError(Lang::trans('NUMERIC_VALUE'));
} elseif (strlen($field->value) && $field->min && $field->value < $field->min) {
$field->addError(Lang::trans('MIN_VALUE', $field->min));
} elseif (strlen($field->value) && $field->max && $field->value > $field->max) {
$field->addError(Lang::trans('MAX_VALUE', $field->max));
}
});
}
示例4: validateUpload
protected function validateUpload()
{
$errorNames = array(UPLOAD_ERR_INI_SIZE => 'UPLOAD_ERR_INI_SIZE', UPLOAD_ERR_FORM_SIZE => 'UPLOAD_ERR_FORM_SIZE', UPLOAD_ERR_PARTIAL => 'UPLOAD_ERR_PARTIAL', UPLOAD_ERR_NO_FILE => 'UPLOAD_ERR_NO_FILE', UPLOAD_ERR_NO_TMP_DIR => 'UPLOAD_ERR_NO_TMP_DIR', UPLOAD_ERR_CANT_WRITE => 'UPLOAD_ERR_CANT_WRITE', UPLOAD_ERR_EXTENSION => 'UPLOAD_ERR_EXTENSION');
$result = [];
if ($this->value) {
$values = (array) $this->value;
$errors = (array) $_FILES[$this->name]['error'];
foreach ($values as $i => $value) {
if (strlen($value) && ($errNo = $errors[$i])) {
$error = isset($errNo, $errorNames) ? $errorNames[$errNo] : 'UPLOAD_UNKNOWN_ERROR';
$result[] = "[{$value}] : " . Lang::trans($error);
}
}
}
return $result;
}
示例5: run
/**
* Execute rsync command with formatting & colorizing.
*
* @param string $commandLine A Command to execute.
* @param boolean $verbose Verbose mose flag.
* @param boolean $log Output log flag.
* @return integer Execution code.
*/
public function run($commandLine, $verbose, $log)
{
$result = $this->executor->execute($commandLine);
$outputs = $this->executor->getOutput();
$errorOutputs = $this->executor->getErrorOutput();
$this->output = array();
$fileCnt = 0;
foreach ($outputs as $output) {
$line = trim($output);
// Put in log.
if ($log) {
\Log::info($line);
}
// Format & colorize output.
// Maybe for Mac
if (starts_with($line, "Number of files transferred")) {
$parts = explode(":", $line);
$this->output[] = \Lang::trans('syncle::SyncleCommand.MaxFileTransferred', array('file' => trim($parts[1])));
} elseif (starts_with($line, "Total transferred file size")) {
$parts = explode(":", $line);
$this->output[] = \Lang::trans('syncle::SyncleCommand.LinuxFileTransferred', array('file' => trim($parts[1])));
} elseif (starts_with($line, 'sending incremental file list')) {
if ($verbose) {
$this->output[] = \Lang::trans('syncle::SyncleCommand.LinuxSentList');
}
} elseif (starts_with($line, 'sent ')) {
// Replace double spaces to single one.
$parts = explode(' ', str_replace(' ', ' ', $line));
$this->output[] = \Lang::trans('syncle::SyncleCommand.LinuxSentByte', array('byte' => trim($parts[1])));
$this->output[] = \Lang::trans('syncle::SyncleCommand.LinuxRecievedByte', array('byte' => trim($parts[4])));
} elseif (starts_with($line, 'total size is ')) {
// Replace double spaces to single one.
$parts = explode(' ', str_replace(' ', ' ', $line));
$this->output[] = \Lang::trans('syncle::SyncleCommand.LinuxTotalTransferred', array('byte' => trim($parts[3])));
$this->output[] = \Lang::trans('syncle::SyncleCommand.LinuxFileTransferred', array('file' => $fileCnt));
} else {
if (!empty($line)) {
$fileCnt++;
}
if ($verbose) {
$this->output[] = $line;
}
}
}
$this->outputErrors($errorOutputs, $log);
return $result;
}
示例6: postReset
/**
* Handle a POST request to reset a user's password.
*
* @return Response
*/
public function postReset()
{
$credentials = Input::only('email', 'password', 'password_confirmation', 'token');
$response = Password::reset($credentials, function ($user, $password) {
$user->password = $password;
$user->save();
});
switch ($response) {
case Password::INVALID_PASSWORD:
case Password::INVALID_TOKEN:
case Password::INVALID_USER:
Flash::error(Lang::trans('messages.' . $response));
return Redirect::back();
case Password::PASSWORD_RESET:
Flash::message(Lang::trans('messages.' . $response));
return Redirect::to('auth/login');
}
}
示例7: deploy
/**
* Execute commands and format & colorize.
*
* @param mix $commands A command(string) or some commands(array)
* @param boolean $verbose Verbose mode flag.
* @param boolean $log Log output flag.
* @param string $message Commit message.
* @return int Execution code.
*/
public function deploy($commands, $verbose, $log, $message)
{
$commandArray = is_array($commands) ? $commands : (array) $commands;
// Get project base root for develop package on workbench.
$projectBasePath = realpath(__DIR__ . '/../../../../..');
// Get require-dev section from composer.json
$composerRepo = \App::make('Syncle\\Repositories\\ComposerJsonRepository');
$requireDevs = $composerRepo->get();
// Generate exclude options for require-dev packages.
$excludePackages = "";
foreach ($requireDevs as $package => $version) {
$excludePackages .= "--exclude=\"vendor/{$package}\" ";
}
foreach ($commandArray as $command) {
// Replace placeholders.
$helper = \App::make('Syncle\\Helpers');
$replacedToBase = str_replace(':root', $helper->base_path(), $command);
$replacedToProject = str_replace(':projectRoot', $projectBasePath, $replacedToBase);
$replacedMessage = str_replace(':message', $message, $replacedToProject);
$commandLine = str_replace(':excludeRequireDev', $excludePackages, $replacedMessage);
if ($verbose) {
$this->output = array_merge($this->output, array("<blue>=><blue><comment> {$commandLine}</comment>"));
}
// Get only execute command.
$command = head(explode(' ', $commandLine));
// Get each command's deployer instance.
// Class name started with command name.
try {
// First, try to instantiate command name + "Deployer" class.
$deployer = \App::make('Syncle\\Services\\Deployers\\' . studly_case($command) . 'Deployer');
} catch (\Exception $e) {
// Get fallback default deployer instance.
$deployer = \App::make('Syncle\\Services\\Deployers\\DefaultDeployer');
}
// Deploy this project and edit output.
$result = $deployer->run($commandLine, $verbose, $log);
$this->output = array_merge($this->output, $deployer->getOutput());
if ($result != 0) {
array_push($this->output, \Lang::trans('syncle::SyncleCommand.ExecutionError', array('command' => $commandLine)));
return $result;
}
}
return 0;
}
示例8: trans
/**
* Translates the string with Ajde_Lang::translate.
*
* @param string $ident
* @param string $module
*
* @return string
*/
function trans($ident, $module = null)
{
return Lang::trans($ident, $module);
}
示例9: postSpoilerAttachment
/**
* Delete a post's attachment.
*
* @param \App\FileAttachment $attachment
* @return Response
*/
public function postSpoilerAttachment(Board $board, FileAttachment $attachment)
{
if (!$attachment->exists) {
return abort(404);
}
$input = Input::all();
$validator = Validator::make($input, ['scope' => "required|string|in:other,self", 'confirm' => "boolean|required_if:scope,other", 'password' => "string|required_if:scope,self"]);
if (!$validator->passes()) {
return redirect()->back()->withInput($input)->withErrors($validator->errors());
}
if ($input['scope'] == "other") {
if ($this->user->canDeleteGlobally() || $this->user->canDeleteLocally($board)) {
$this->log(!$attachment->is_spoiler ? 'log.attachment.spoiler' : 'log.attachment.unspoiler', $attachment->post, ["board_uri" => $attachment->post->board_uri, "board_id" => $attachment->post->board_id, "post_id" => $attachment->post->post_id, "file" => $attachment->storage->hash]);
} else {
abort(403);
}
} else {
if ($input['scope'] == "self") {
if ($this->user->canDeletePostWithPassword($board)) {
if (!$attachment->post->checkPassword($input['password'])) {
return redirect()->back()->withInput($input)->withErrors(['password' => \Lang::trans('validation.password', ['attribute' => "password"])]);
}
}
}
}
$attachment->is_spoiler = !$attachment->is_spoiler;
$attachment->save();
Event::fire(new AttachmentWasModified($attachment));
return redirect($attachment->post->getURL());
}
示例10: function
|
| Below you will find the "before" and "after" events for the application
| which may be used to do any work before or after a request into your
| application. Here you may also register your custom route filters.
|
*/
App::before(function ($request) {
//
});
App::after(function ($request, $response) {
//
});
App::error(function (Exception $exception, $code) {
Log::error($exception);
if (!App::environment('local', 'staging')) {
return Response::view('errors.default', ['code' => $code, 'error' => Lang::trans('messages.error.' . $code)], $code);
}
});
/*
|--------------------------------------------------------------------------
| Authentication Filters
|--------------------------------------------------------------------------
|
| The following filters are used to verify that the user of the current
| session is logged into this application. The "basic" filter easily
| integrates HTTP Basic authentication for quick, simple checking.
|
*/
Route::filter('auth', function () {
if (Auth::guest()) {
if (Request::ajax()) {
示例11: array
if (Route::currentRouteNamed('putUser') && Sentry::getUser()->id == Request::segment(3) || Route::currentRouteNamed('showUser') && Sentry::getUser()->id == Request::segment(3)) {
} else {
if ($userPermission === null) {
$permissions = Config::get('usermanager::permissions');
$permission = $permissions[Route::current()->getName()];
} else {
$permission = $userPermission;
}
if (!Sentry::getUser()->hasAccess($permission)) {
return App::abort(403);
}
}
});
App::error(function (Exception $exception, $code) {
View::share('currentUser', Sentry::getUser());
$exceptionMessage = $exception->getMessage();
$message = !empty($exceptionMessage) ? $exceptionMessage : Lang::trans('usermanager::all.messages.error.403');
if (403 === $code) {
return Response::view(Config::get('usermanager::views.error'), array('message' => $message, 'code' => $code, 'title' => Lang::trans('usermanager::all.messages.error.403-title')));
}
if (App::environment('production') || !Config::get('app.debug')) {
switch ($code) {
case 404:
return Response::view(Config::get('usermanager::views.error'), array('message' => Lang::trans('usermanager::all.messages.error.404'), 'code' => $code, 'title' => Lang::trans('usermanager::all.messages.error.404-title')));
case 500:
return Response::view(Config::get('usermanager::views.error'), array('message' => Lang::trans('usermanager::all.messages.error.500'), 'code' => $code, 'title' => Lang::trans('usermanager::all.messages.error.500-title')));
default:
return Response::view(Config::get('usermanager::views.error'), array('message' => Lang::trans('usermanager::all.messages.error.default'), 'code' => $code, 'title' => Lang::trans('usermanager::all.messages.error.default-title')));
}
}
});
示例12: die
<?php
use WHMCS\View\Menu\Item as MenuItem;
if (!defined("WHMCS")) {
die("This file cannot be accessed directly");
}
add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $menu) {
if (!is_null($menu->getChild('My Account'))) {
$menu->getChild('My Account')->addChild('OATH', array('label' => Lang::trans('twofactorauth'), 'uri' => 'index.php?m=oath', 'order' => '51'));
}
});
add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $menu) {
if (!is_null($menu->getChild('Account')) && !is_null(Menu::context('client'))) {
$menu->getChild('Account')->addChild('OATH', array('label' => Lang::trans('twofactorauth'), 'uri' => 'index.php?m=oath', 'order' => '51'));
}
});
function oath_hook_client_login($vars)
{
if ($_SESSION['adminid']) {
return;
}
$userid = $vars['userid'];
if (!get_query_val('mod_oath_client', 'secret', "userid = '{$vars['userid']}'")) {
if (isset($_SESSION['twofactorverify'])) {
unset($_SESSION['twofactorverify']);
}
return;
}
if (!get_query_val('tbladdonmodules', 'value', "module = 'oath' AND setting = 'enable_clients'")) {
if (isset($_SESSION['twofactorverify'])) {
unset($_SESSION['twofactorverify']);
示例13: function
$replyText = Lang::trans('supportticketsreply');
$ticketClosed = $sirportlyTicket['status']['status_type'] == '1';
$showCloseButton = $closedStatusId;
$class = $showCloseButton ? 'col-xs-6 col-button-left' : 'col-xs-12';
$footer = '<div class="' . $class . '">
<button class="btn btn-success btn-sm btn-block" onclick="jQuery(\'#ticketReply\').click()">
<i class="fa fa-pencil"></i> ' . $replyText . '
</button>
</div>';
if ($showCloseButton) {
$footer .= '<div class="col-xs-6 col-button-right">
<button class="btn btn-danger btn-sm btn-block"';
if ($ticketClosed) {
$footer .= 'disabled="disabled"><i class="fa fa-times"></i> ' . Lang::trans('supportticketsstatusclosed');
} else {
$footer .= 'onclick="window.location=\'?tid=' . $sirportlyTicket['reference'] . '&c=' . $sirportlyTicket['id'] . '&closeticket=true\'"> <i class="fa fa-times"></i> ' . Lang::trans('supportticketsclose');
}
$footer .= '</button></div>';
}
$supportPanel->setFooterHtml($footer);
});
}
if (App::getCurrentFilename() == 'viewticket' || App::getCurrentFilename() == 'submitticket' || App::getCurrentFilename() == 'supporttickets') {
add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) {
## Check to ensure the Sirportly support module is in use
if (!Menu::Context('support_module') == 'sirportly') {
return;
}
$supportPanel = $secondarySidebar->addChild('Support', array('label' => 'Support', 'icon' => 'fa-support'));
$child = $supportPanel->addChild('Tickets', array('label' => 'My Support Tickets', 'icon' => 'fa-ticket', 'uri' => 'supporttickets.php', 'order' => 1));
$child->setClass(App::getCurrentFilename() == 'supporttickets' ? 'active' : '');
示例14: add_hook
<?php
/**
* My Licenses Menu Item
*
* Adds a 'My Licenses' link to the Services dropdown menu within the
* client area linking to a product/service listing filtered for
* licensing addon related products.
*
* @param WHMCS\Menu\Item $menu
*/
add_hook('ClientAreaPrimaryNavbar', 1, function ($menu) {
// check services menu exists
if (!is_null($menu->getChild('Services'))) {
// add my licenses link
$menu->getChild('Services')->addChild(Lang::trans('licensingaddon.mylicenses'), array('uri' => 'clientarea.php?action=products&module=licensing', 'order' => 11));
}
});