本文整理汇总了PHP中Bolt\Translation\Translator::__方法的典型用法代码示例。如果您正苦于以下问题:PHP Translator::__方法的具体用法?PHP Translator::__怎么用?PHP Translator::__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bolt\Translation\Translator
的用法示例。
在下文中一共展示了Translator::__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: before
/**
* The default before filter for the controllers in this file.
*
* Refer to the routing.yml config file for overridding.
*
* @param Request $request The Symfony Request
*
* @return null|BoltResponse|RedirectResponse
*/
public function before(Request $request)
{
// Start the 'stopwatch' for the profiler.
$this->app['stopwatch']->start('bolt.frontend.before');
// If there are no users in the users table, or the table doesn't exist.
// Repair the DB, and let's add a new user.
if (!$this->hasUsers()) {
$this->flashes()->info(Trans::__('general.phrase.users-none-create-first'));
return $this->redirectToRoute('userfirst');
}
// If we are in maintenance mode and current user is not logged in, show maintenance notice.
if ($this->getOption('general/maintenance_mode')) {
if (!$this->isAllowed('maintenance-mode')) {
$template = $this->templateChooser()->maintenance();
$response = $this->render($template);
$response->setStatusCode(Response::HTTP_SERVICE_UNAVAILABLE);
return $response;
}
}
// If we have a valid cache respose, return it.
if ($response = $this->app['render']->fetchCachedRequest()) {
// Stop the 'stopwatch' for the profiler.
$this->app['stopwatch']->stop('bolt.frontend.before');
// Short-circuit the request, return the HTML/response. YOLO.
return $response;
}
// Stop the 'stopwatch' for the profiler.
$this->app['stopwatch']->stop('bolt.frontend.before');
return null;
}
示例2: gdCheck
/**
* Check whether or not the GD-library can be used in PHP. Needed for making thumbnails.
*/
protected function gdCheck()
{
if (!function_exists('imagecreatetruecolor')) {
$notice = "The current version of PHP doesn't have the GD library enabled. Without this, Bolt will not be able to generate thumbnails. Please enable <tt>php-gd</tt>, or ask your system-administrator to do so.";
$this->app['logger.flash']->configuration(Trans::__($notice));
}
}
示例3: postLogin
/**
* Handle a login attempt.
*
* @param \Silex\Application $app The application/container
* @param Request $request The Symfony Request
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
public function postLogin(Silex\Application $app, Request $request)
{
switch ($request->get('action')) {
case 'login':
// Log in, if credentials are correct.
$result = $app['users']->login($request->get('username'), $request->get('password'));
if ($result) {
$app['logger.system']->info('Logged in: ' . $request->get('username'), array('event' => 'authentication'));
$retreat = $app['session']->get('retreat');
$redirect = !empty($retreat) && is_array($retreat) ? $retreat : array('route' => 'dashboard', 'params' => array());
return Lib::redirect($redirect['route'], $redirect['params']);
}
return $this->getLogin($app, $request);
case 'reset':
// Send a password request mail, if username exists.
$username = trim($request->get('username'));
if (empty($username)) {
$app['users']->session->getFlashBag()->add('error', Trans::__('Please provide a username', array()));
} else {
$app['users']->resetPasswordRequest($request->get('username'));
return Lib::redirect('login');
}
return $this->getLogin($app, $request);
}
// Let's not disclose any internal information.
$app->abort(Response::HTTP_BAD_REQUEST, 'Invalid request');
}
示例4: browse
/**
* List browse on the server, so we can insert them in the file input.
*
* @param Request $request
* @param string $namespace
* @param string $path
*
* @return \Bolt\Response\BoltResponse
*/
public function browse(Request $request, $namespace, $path)
{
// No trailing slashes in the path.
$path = rtrim($path, '/');
$filesystem = $this->filesystem()->getFilesystem($namespace);
// $key is linked to the fieldname of the original field, so we can
// Set the selected value in the proper field
$key = $request->query->get('key');
// Get the pathsegments, so we can show the path.
$pathsegments = [];
$cumulative = '';
if (!empty($path)) {
foreach (explode('/', $path) as $segment) {
$cumulative .= $segment . '/';
$pathsegments[$cumulative] = $segment;
}
}
try {
$filesystem->listContents($path);
} catch (\Exception $e) {
$msg = Trans::__("Folder '%s' could not be found, or is not readable.", ['%s' => $path]);
$this->flashes()->error($msg);
}
list($files, $folders) = $filesystem->browse($path, $this->app);
$context = ['namespace' => $namespace, 'files' => $files, 'folders' => $folders, 'pathsegments' => $pathsegments, 'key' => $key];
return $this->render('files_async/files_async.twig', ['context' => $context], ['title', Trans::__('Files in %s', ['%s' => $path])]);
}
示例5: updateJson
/**
* Set up Composer JSON file.
*
* @return array|null
*/
public function updateJson()
{
if (!is_file($this->getOption('composerjson'))) {
$this->initJson($this->getOption('composerjson'));
}
$jsonFile = new JsonFile($this->getOption('composerjson'));
if ($jsonFile->exists()) {
$json = $jsonorig = $jsonFile->read();
// Workaround Bolt 2.0 installs with "require": []
if (isset($json['require']) && empty($json['require'])) {
unset($json['require']);
}
$json = $this->setJsonDefaults($json);
} else {
// Error
$this->messages[] = Trans::__("The Bolt extensions file '%composerjson%' isn't readable.", ['%composerjson%' => $this->getOption('composerjson')]);
$this->app['extend.writeable'] = false;
$this->app['extend.online'] = false;
return null;
}
// Write out the file, but only if it's actually changed, and if it's writable.
if ($json != $jsonorig) {
try {
umask(00);
$jsonFile->write($json);
} catch (\Exception $e) {
$this->messages[] = Trans::__('The Bolt extensions Repo at %repository% is currently unavailable. Check your connection and try again shortly.', ['%repository%' => $this->app['extend.site']]);
}
}
return $json;
}
示例6: update
/**
* Set up Composer JSON file.
*
* @return array|null
*/
public function update()
{
/** @var \Bolt\Filesystem\Handler\JsonFile $jsonFile */
$jsonFile = $this->app['filesystem']->get('extensions://composer.json', new JsonFile());
if (!$jsonFile->exists()) {
try {
$this->init('extensions://composer.json');
} catch (IOException $e) {
$this->messages[] = Trans::__("The Bolt extensions composer.json isn't readable.");
$this->app['extend.writeable'] = false;
$this->app['extend.online'] = false;
return;
}
}
$json = $jsonOrig = $jsonFile->parse();
// Workaround Bolt 2.0 installs with "require": []
if (isset($json['require']) && empty($json['require'])) {
unset($json['require']);
}
$json = $this->setJsonDefaults($json);
$json = $this->setJsonLocal($json);
// Write out the file, but only if it's actually changed, and if it's writable.
if ($json != $jsonOrig) {
try {
$jsonFile->dump($json);
} catch (IOException $e) {
$this->messages[] = Trans::__("The Bolt extensions composer.json isn't writable.");
}
}
return $json;
}
示例7: initialize
public function initialize()
{
// For europeana, stupid hardcoded redirect for a domain:
if (strpos($_SERVER['HTTP_HOST'], "europeanacreative.eu") !== false) {
\Bolt\Library::simpleredirect('http://pro.europeana.eu/get-involved/projects/project-list/europeana-creative');
die;
}
// structure tree overview
$this->boltPath = $this->app['config']->get('general/branding/path');
// listings
if ($this->app['config']->getWhichEnd() === 'backend' || $this->app['config']->getWhichEnd() === 'cli') {
// back-end listings
$this->addMenuOption(\Bolt\Translation\Translator::__('Structure Tree'), "{$this->boltPath}/structure-tree/overview", "fa:sitemap");
$this->app->get("{$this->boltPath}/structure-tree/overview", array($this, 'structureTreeOverview'))->bind('structureTreeOverview');
// convert legacy relationships to column values in contenttypes.
$this->app->get("{$this->boltPath}/structure-tree/convert", array($this, 'structureTreeConvert'))->bind('structureTreeConvert');
} else {
// slug listing
$this->app->match("/{slug}", array($this, 'slugTreeRecord'))->assert('slug', '[a-zA-Z0-9_\\-]+[^(sitemap)^(search)]')->bind('slugTreeRecord');
// strucutureslug / slug listing
$this->app->match("/{structureSlugs}/{slug}", array($this, 'structureTreeRecord'))->assert('structureSlugs', '(?!(async|_profiler)).*')->assert('slug', '[a-zA-Z0-9_\\-]+')->bind('structureTreeRecord');
}
// twig functions
$this->addTwigFunction('structurelink', 'getStructureLink');
$this->addTwigFunction('structurecontenttype', 'getContenttypeByStructure');
$this->addTwigFunction('breadcrumb', 'breadCrumb');
$this->addTwigFunction('subsite', 'subSite');
$this->addTwigFunction('sortRecords', 'sortObject');
$this->addTwigFunction('getContenttype', 'getContenttype');
$this->addTwigFunction('getTreeChildren', 'getTreeChildren');
$this->contenttypeslugs = $this->config['contenttypes'];
}
示例8: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$passwordConstraints = [];
if ($this->requirePassword) {
$passwordConstraints = [new Assert\NotBlank(), new Assert\Length(['min' => 6])];
}
$builder->add('email', EmailType::class, ['label' => Trans::__($this->config->getLabel('email')), 'attr' => ['placeholder' => $this->config->getPlaceholder('email')], 'constraints' => [new Assert\Email(['message' => 'The address "{{ value }}" is not a valid email.', 'checkMX' => true])]])->add('password', RepeatedType::class, ['type' => PasswordType::class, 'first_options' => ['label' => Trans::__($this->config->getLabel('password_first')), 'attr' => ['placeholder' => $this->config->getPlaceholder('password_first')], 'constraints' => $passwordConstraints], 'second_options' => ['label' => Trans::__($this->config->getLabel('password_second')), 'attr' => ['placeholder' => $this->config->getPlaceholder('password_second')], 'constraints' => $passwordConstraints], 'empty_data' => null, 'required' => $this->requirePassword])->add('submit', SubmitType::class, ['label' => Trans::__($this->config->getLabel('profile_save'))]);
}
示例9: initialize
public function initialize()
{
if ($this->app['config']->getWhichEnd() === 'backend') {
$path = $this->app['config']->get('general/branding/path') . '/extensions/image-cleanup';
$this->app->mount($path, new Controller\ImageCleanupAdminController());
$this->app['extensions.Image cleanup for Bolt']->addMenuOption(Translator::__('Image Cleanup'), $this->app['resources']->getUrl('bolt') . 'extensions/image-cleanup', 'fa:pencil-square-o');
}
}
示例10: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('name', 'text', ['label' => Trans::__('Internal name for field'), 'read_only' => true, 'attr' => ['help' => Trans::__('Only letters, numbers and underscores allowed')]])->add('label', 'text', ['label' => Trans::__('Label for this form field'), 'attr' => ['help' => Trans::__('This is the user-visible label')]])->add('type', 'choice', ['label' => Trans::__('Type of form element'), 'choices' => ['text' => Trans::__('Text'), 'textarea' => Trans::__('Text Area'), 'choice' => Trans::__('Select Dropdown'), 'submit' => Trans::__('Submit Button')]])->add('required', 'checkbox', ['label' => Trans::__('Required Field'), 'required' => false]);
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$form = $event->getForm();
$data = $event->getData();
$form->add('choices', 'choice', ['label' => Trans::__('Options to show'), 'required' => false, 'multiple' => true, 'attr' => ['help' => Trans::__('Setup the available choices')], 'choices' => array_combine((array) $data['choices'], (array) $data['choices'])]);
});
}
示例11: mailConfigCheck
/**
* No mail transport has been set. We should gently nudge the user to set
* the mail configuration.
*
* @see https://github.com/bolt/bolt/issues/2908
*
* @param Request $request
*/
protected function mailConfigCheck(Request $request)
{
if (!$request->hasPreviousSession()) {
return;
}
if (!$this->app['config']->get('general/mailoptions') && $this->app['users']->getCurrentuser() && $this->app['users']->isAllowed('files:config')) {
$error = "The mail configuration parameters have not been set up. This may interfere with password resets, and extension functionality. Please set up the 'mailoptions' in config.yml.";
$this->app['logger.flash']->error(Trans::__($error));
}
}
示例12: mailConfigCheck
/**
* No Mail transport has been set. We should gently nudge the user to set
* the mail configuration.
*
* For now, we only pester the user, if an extension needs to be able to
* send mail, but it's not been set up.
*
* @see: the issue at https://github.com/bolt/bolt/issues/2908
*
* @param Request $request
*/
protected function mailConfigCheck(Request $request)
{
if (!$request->hasPreviousSession()) {
return;
}
if ($this->app['users']->getCurrentuser() && !$this->app['config']->get('general/mailoptions') && $this->app['extensions']->hasMailSenders()) {
$error = "One or more installed extensions need to be able to send email. Please set up the 'mailoptions' in config.yml.";
$this->app['logger.flash']->error(Trans::__($error));
}
}
示例13: collect
/**
* Collect the date for the Toolbar item.
*
* @param Request $request
* @param Response $response
* @param \Exception $exception
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
{
$this->data = ['version' => Bolt\Version::VERSION, 'payoff' => 'Sophisticated, lightweight & simple CMS', 'dashboardlink' => sprintf('<a href="%s">%s</a>', $this->app['url_generator']->generate('dashboard'), 'Dashboard'), 'branding' => null, 'editlink' => null, 'edittitle' => null];
if ($this->app['config']->get('general/branding/provided_by/0')) {
$this->data['branding'] = sprintf('%s <a href="mailto:%s">%s</a>', Trans::__('Provided by:'), $this->app['config']->get('general/branding/provided_by/0'), $this->app['config']->get('general/branding/provided_by/1'));
}
if (!empty($this->app['editlink'])) {
$this->data['editlink'] = $this->app['editlink'];
$this->data['edittitle'] = $this->app['edittitle'];
}
}
示例14: collect
/**
* Collect the date for the Toolbar item.
*
* @param Request $request
* @param Response $response
* @param \Exception $exception
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
{
$this->data = ['version' => $this->app->getVersion(false), 'name' => $this->app['bolt_name'], 'fullversion' => 'Version: ' . $this->app->getVersion(true), 'payoff' => 'Sophisticated, lightweight & simple CMS', 'aboutlink' => sprintf('<a href="%s">%s</a>', $this->app->generatePath('about'), 'About'), 'branding' => null, 'editlink' => null, 'edittitle' => null];
if ($this->app['config']->get('general/branding/provided_by/0')) {
$this->data['branding'] = sprintf('%s <a href="mailto:%s">%s</a>', Trans::__('Provided by:'), $this->app['config']->get('general/branding/provided_by/0'), $this->app['config']->get('general/branding/provided_by/1'));
}
if (!empty($this->app['editlink'])) {
$this->data['editlink'] = $this->app['editlink'];
$this->data['edittitle'] = $this->app['edittitle'];
}
}
示例15: initialize
function initialize()
{
$this->path = $this->app['config']->get('general/branding/path') . '/extensions/google-analytics';
$this->app->match($this->path, array($this, 'GoogleAnalytics'));
$this->app['htmlsnippets'] = true;
if ($this->app['config']->getWhichEnd() == 'frontend') {
$this->addSnippet('endofhead', 'insertAnalytics');
} else {
$this->app->before(array($this, 'before'));
}
if (isset($this->config['backend']) && $this->config['backend']) {
$this->addMenuOption(Trans::__('Statistics'), $this->app['paths']['bolt'] . 'extensions/google-analytics', "fa:area-chart");
}
}