• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Translation\Translator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Bolt\Translation\Translator的典型用法代码示例。如果您正苦于以下问题:PHP Translator类的具体用法?PHP Translator怎么用?PHP Translator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Translator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: 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'];
 }
开发者ID:simnom,项目名称:Europeana-Professional,代码行数:32,代码来源:Extension.php


示例2: 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');
     }
 }
开发者ID:AnimalDesign,项目名称:bolt-imagecleanup,代码行数:8,代码来源:Extension.php


示例3: 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;
 }
开发者ID:robbert-vdh,项目名称:bolt,代码行数:39,代码来源:Frontend.php


示例4: 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));
     }
 }
开发者ID:robbert-vdh,项目名称:bolt,代码行数:10,代码来源:GeneralListener.php


示例5: 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');
 }
开发者ID:aleksabp,项目名称:bolt,代码行数:35,代码来源:Login.php


示例6: 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])]);
 }
开发者ID:jkaan,项目名称:timOnlineBolt,代码行数:36,代码来源:FilesystemManager.php


示例7: 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;
 }
开发者ID:nectd,项目名称:nectd-web,代码行数:36,代码来源:BoltExtendJson.php


示例8: 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;
 }
开发者ID:d-m-,项目名称:bolt,代码行数:36,代码来源:JsonManager.php


示例9: 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'))]);
 }
开发者ID:bolt,项目名称:Members,代码行数:11,代码来源:AbstractProfileRecoveryType.php


示例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'])]);
     });
 }
开发者ID:rossriley,项目名称:bolt-extension-formeditor,代码行数:9,代码来源:FormelementType.php


示例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));
     }
 }
开发者ID:d-m-,项目名称:bolt,代码行数:18,代码来源:GeneralListener.php


示例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));
     }
 }
开发者ID:zomars,项目名称:bolt,代码行数:21,代码来源:GeneralListener.php


示例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'];
     }
 }
开发者ID:Boorj,项目名称:bolt,代码行数:18,代码来源:BoltDataCollector.php


示例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'];
     }
 }
开发者ID:Johardmeier,项目名称:bolt,代码行数:18,代码来源:BoltDataCollector.php


示例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");
     }
 }
开发者ID:jeffpfoster,项目名称:GoogleAnalytics,代码行数:14,代码来源:Extension.php


示例16: signin

 public function signin(Request $request)
 {
     $login = new \Bolt\Extension\Blimp\Client\AccessControl\Login($this->app);
     $login->setRequest($request);
     $query = $request->query->all();
     $code = array_key_exists('code', $query) ? $query['code'] : null;
     $state = array_key_exists('state', $query) ? $query['state'] : null;
     $error = array_key_exists('error', $query) ? $query['error'] : null;
     $error_description = array_key_exists('error_description', $query) ? $query['error_description'] : null;
     $destination = $this->app['blimp_client.session_from_code']($code, $state, $error, $error_description);
     $access_token = $this->app['blimp_client.access_token']();
     $logged_in = !empty($access_token) ? $this->app['blimp_client.validate_access_token']($access_token, true, true) : false;
     if (!$logged_in) {
         $this->flashes()->error(Trans::__($error_description ?: $error));
         $response = new RedirectResponse($destination);
     } else {
         $user_id = $logged_in['profile_id'];
         if (!($userEntity = $this->getUser($user_id))) {
             $users_repo = $this->app['storage']->getRepository('Bolt\\Storage\\Entity\\Users');
             $userEntity = new \Bolt\Storage\Entity\Users();
             $userEntity->setUsername($user_id);
             $userEntity->setPassword('not_local_user');
             $userEntity->setEmail($logged_in['profile']['email']);
             $userEntity->setDisplayname($logged_in['profile']['name']);
             $userEntity->setEnabled(true);
             $userEntity->setRoles(explode(' ', $logged_in['scope']));
             $users_repo->save($userEntity);
         }
         if (!$userEntity->getEnabled()) {
             $this->flashLogger->error(Trans::__('Your account is disabled. Sorry about that.'));
             $url = $this->app['blimp_client.request_code'](['return_to' => $destination]);
             $response = new RedirectResponse($url);
         } else {
             $login->loginFinish($userEntity);
             // Authentication data is cached in the session and if we can't get it
             // now, everyone is going to have a bad day. Make that obvious.
             if (!($token = $this->session()->get('authentication'))) {
                 $this->flashes()->error(Trans::__("Unable to retrieve login session data. Please check your system's PHP session settings."));
                 $url = $this->app['blimp_client.request_code'](['return_to' => $destination]);
                 $response = new RedirectResponse($url);
             } else {
                 // Log in, if credentials are correct.
                 $this->app['logger.system']->info('Logged in: ' . $user_id, ['event' => 'authentication']);
                 $response = $this->setAuthenticationCookie(new RedirectResponse($destination), (string) $token);
             }
         }
     }
     return $response;
 }
开发者ID:blimp-php,项目名称:blimp-client-bolt,代码行数:49,代码来源:SignIn.php


示例17: publish

 public function publish(Content $content, $comment = null)
 {
     $contenttype = $content->contenttype;
     $fieldvalues = $content->values;
     // Test to see if this is a new record, or an update
     if (empty($fieldvalues['blimp_id'])) {
         $create = true;
     } else {
         $create = false;
     }
     // Update the content object
     $content->setValues($fieldvalues);
     $extra = [];
     if (!empty($contenttype['relations'])) {
         $relations = $content->related();
         if (!empty($relations)) {
             foreach ($relations as $related) {
                 if (!empty($related->values['blimp_id'])) {
                     if (!empty($contenttype['relations'][$related->contenttype['slug']])) {
                         $multiple = !empty($contenttype['relations'][$related->contenttype['slug']]['multiple']) && $contenttype['relations'][$related->contenttype['slug']]['multiple'];
                         if ($multiple) {
                             if (empty($extra[$related->contenttype['slug']])) {
                                 $extra[$related->contenttype['slug']] = [];
                             }
                             $extra[$related->contenttype['slug']][] = $related->values['blimp_id'];
                         } else {
                             $extra[$related->contenttype['singular_slug']] = $related->values['blimp_id'];
                         }
                     }
                 }
             }
         }
     }
     // Decide whether to insert a new record, or update an existing one.
     $ok = false;
     if ($create) {
         $ok = $this->insertContent($content, $comment, $extra);
     } else {
         $ok = $this->updateContent($content, $comment, $extra);
     }
     if ($ok !== true) {
         return $ok;
     }
     $content->setValue('status', 'published');
     $comment = Trans::__('The content has been published.');
     $result = $this->app['storage']->saveContent($content, $comment);
     return $result;
 }
开发者ID:blimp-php,项目名称:blimp-client-bolt,代码行数:48,代码来源:BlimpStorage.php


示例18: update

 /**
  * Check the database, create tables, add missing/new columns to tables.
  *
  * @param Request $request The Symfony Request
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function update(Request $request)
 {
     $output = $this->schemaManager()->repairTables()->getResponseStrings();
     // If 'return=edit' is passed, we should return to the edit screen.
     // We do redirect twice, yes, but that's because the newly saved
     // contenttype.yml needs to be re-read.
     $return = $request->get('return');
     if ($return === 'edit') {
         if (empty($output)) {
             $content = Trans::__('Your database is already up to date.');
         } else {
             $content = Trans::__('Your database is now up to date.');
         }
         $this->flashes()->success($content);
         return $this->redirectToRoute('fileedit', ['namespace' => 'config', 'file' => 'contenttypes.yml']);
     } else {
         $this->session()->set('dbupdate_result', $output);
         return $this->redirectToRoute('dbupdate_result');
     }
 }
开发者ID:nuffer,项目名称:bolt,代码行数:27,代码来源:Database.php


示例19: getTranslationAction

 public function getTranslationAction(Application $app, Request $request)
 {
     $default_locale = $app['config']->get('general/locale', 'en_GB');
     $prefix = $app['config']->get('general/database/prefix', 'bolt_');
     $translation_table_name = $prefix . 'translation';
     $locale = $request->query->get('locale');
     $content_type = $request->query->get('content_type');
     $content_type_id = $request->query->get('content_type_id');
     $content_type_config = $app['config']->get('contenttypes/' . $content_type);
     $translatable_fields = $this->getTranslatableFields($content_type_config['fields']);
     if (!$app['users']->isAllowed('contenttype:' . $content_type . ':edit')) {
         return new Response(Trans::__('Permission denied'), Response::HTTP_FORBIDDEN);
     }
     $response = array();
     // Return default record if default locale
     if ($locale === $default_locale) {
         $query = 'SELECT * FROM ' . $prefix . $content_type . ' WHERE id = :content_type_id';
         $default_content = $app['db']->fetchAssoc($query, array(':content_type_id' => $content_type_id));
         foreach ($translatable_fields as $translatable_field) {
             $element = new \stdClass();
             $element->field = $translatable_field;
             $element->value = $default_content[$translatable_field];
             $response[] = $element;
         }
         return $app->json($response);
     }
     $query = 'SELECT field, value FROM ' . $translation_table_name . ' WHERE locale = :locale AND content_type = :content_type AND content_type_id = :content_type_id';
     $translated_content = $app['db']->fetchAll($query, array(':locale' => $locale, ':content_type' => $content_type, ':content_type_id' => $content_type_id));
     foreach ($translatable_fields as $translatable_field) {
         $element = new \stdClass();
         $element->field = $translatable_field;
         $element->value = '';
         foreach ($translated_content as $content) {
             if ($content['field'] === $translatable_field) {
                 $element->value = $content['value'];
             }
         }
         $response[] = $element;
     }
     return $app->json($response);
 }
开发者ID:evertalbers,项目名称:bolt-translate,代码行数:41,代码来源:AsyncController.php


示例20: 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
  * @param Application $app     The application/container
  *
  * @return null|Response|RedirectResponse
  */
 public function before(Request $request, Application $app)
 {
     // Start the 'stopwatch' for the profiler.
     $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 (!$app['users']->getUsers()) {
         $app['session']->getFlashBag()->add('info', Trans::__('There are no users in the database. Please create the first user.'));
         return Lib::redirect('useredit', array('id' => ''));
     }
     $app['debugbar'] = true;
     $app['htmlsnippets'] = true;
     // If we are in maintenance mode and current user is not logged in, show maintenance notice.
     if ($app['config']->get('general/maintenance_mode')) {
         if (!$app['users']->isAllowed('maintenance-mode')) {
             $template = $app['templatechooser']->maintenance();
             $body = $app['render']->render($template)->getContent();
             return new Response($body, Response::HTTP_SERVICE_UNAVAILABLE);
         }
     }
     // Stop the 'stopwatch' for the profiler.
     $app['stopwatch']->stop('bolt.frontend.before');
     return null;
 }
开发者ID:aaleksu,项目名称:bolt_cm,代码行数:34,代码来源:Frontend.php



注:本文中的Bolt\Translation\Translator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP assert\assert函数代码示例发布时间:2022-05-23
下一篇:
PHP Helpers\Str类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap