当前位置: 首页>>代码示例>>PHP>>正文


PHP language_load函数代码示例

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


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

示例1: edit

 /**
  * @todo Remove content_translation_edit_page().
  */
 public function edit(Request $request, $language)
 {
     $entity = $request->attributes->get($request->attributes->get('_entity_type_id'));
     module_load_include('pages.inc', 'content_translation');
     $language = language_load($language);
     return content_translation_edit_page($entity, $language);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:ContentTranslationController.php

示例2: render

 /**
  * {@inheritdoc}
  */
 public function render(ResultRow $values)
 {
     $value = $this->getValue($values);
     $language = language_load($value);
     $value = $language ? $language->name : '';
     return $this->renderLink($this->sanitizeValue($value), $values);
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:10,代码来源:Language.php

示例3: getValue

 /**
  * Overrides TypedData::getValue().
  *
  * @return \Drupal\Core\Language\LanguageInterface|null
  */
 public function getValue()
 {
     if (!isset($this->language) && $this->id) {
         $this->language = language_load($this->id);
     }
     return $this->language;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:12,代码来源:Language.php

示例4: render

 /**
  * {@inheritdoc}
  */
 public function render(ResultRow $values)
 {
     // @todo: Drupal Core dropped native language until config translation is
     // ready, see http://drupal.org/node/1616594.
     $value = $this->getValue($values);
     $language = language_load($value);
     return $language ? $language->name : '';
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:11,代码来源:LanguageField.php

示例5: testMenuRouterRebuildContext

 /**
  * Tests configuration context when rebuilding the menu router table.
  */
 public function testMenuRouterRebuildContext()
 {
     // Enter a language context before rebuilding the menu router tables.
     \Drupal::languageManager()->setConfigOverrideLanguage(language_load('nl'));
     \Drupal::service('router.builder')->rebuild();
     // Check that the language context was not used for building the menu item.
     $menu_items = \Drupal::entityManager()->getStorage('menu_link')->loadByProperties(array('route_name' => 'menu_test.context'));
     $menu_item = reset($menu_items);
     $this->assertTrue($menu_item['link_title'] == 'English', 'Config context overrides are ignored when rebuilding menu router items.');
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:13,代码来源:MenuRouterRebuildTest.php

示例6: setUp

 public function setUp()
 {
     parent::setUp();
     // Create test languages.
     $this->langcodes = array(language_load('en'));
     for ($i = 1; $i < 3; ++$i) {
         $language = new Language(array('id' => 'l' . $i, 'name' => $this->randomString()));
         language_save($language);
         $this->langcodes[$i] = $language;
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:11,代码来源:FeedLanguageTest.php

示例7: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm()
 {
     global $user;
     $output = array();
     // Show which users can access this node.
     $menu_item = menu_get_item();
     $map = $menu_item['original_map'];
     if ($map[0] != 'node' || !isset($map[1]) || !is_numeric($map[1]) || isset($map[2])) {
         // Ignore anything but node/%.
         return NULL;
     }
     if (isset($menu_item['map'][1]) && is_object($node = $menu_item['map'][1])) {
         // We have the node.
     } elseif (is_numeric($menu_item['original_map'][1])) {
         $node = node_load($menu_item['original_map'][1]);
     }
     if (isset($node)) {
         $nid = $node->id();
         $langcode = $node->langcode->value;
         $language = language_load($langcode);
         $node_type = node_type_load($node->bundle());
         $headers = array(t('username'), '<span title="' . t("Create '@langname'-language nodes of the '@Node_type' type.", array('@langname' => $language->name, '@Node_type' => $node_type->name)) . '">' . t('create') . '</span>', t('view'), t('update'), t('delete'));
         $rows = array();
         // Determine whether to use Ajax or pre-populate the tables.
         if ($ajax = \Drupal::config('devel_node_access.settings')->get('user_ajax')) {
             $output['#attached']['library'][] = 'devel_node_access/node_access';
         }
         // Find all users. The following operations are very inefficient, so we
         // limit the number of users returned.  It would be better to make a
         // pager query, or at least make the number of users configurable.  If
         // anyone is up for that please submit a patch.
         $query = db_select('users', 'u')->fields('u', array('uid'))->orderBy('u.access', 'DESC')->range(0, 9);
         $uids = $query->execute()->fetchCol();
         array_unshift($uids, 0);
         $accounts = user_load_multiple($uids);
         foreach ($accounts as $account) {
             $username = theme('username', array('account' => $account));
             $uid = $account->id();
             if ($uid == $user->id()) {
                 $username = '<strong>' . $username . '</strong>';
             }
             $rows[] = array($username, array('id' => 'create-' . $nid . '-' . $uid, 'class' => 'dna-permission', 'data' => $ajax ? NULL : theme('dna_permission', array('permission' => self::explain_access('create', $node, $account, $langcode)))), array('id' => 'view-' . $nid . '-' . $uid, 'class' => 'dna-permission', 'data' => $ajax ? NULL : theme('dna_permission', array('permission' => self::explain_access('view', $node, $account, $langcode)))), array('id' => 'update-' . $nid . '-' . $uid, 'class' => 'dna-permission', 'data' => $ajax ? NULL : theme('dna_permission', array('permission' => self::explain_access('update', $node, $account, $langcode)))), array('id' => 'delete-' . $nid . '-' . $uid, 'class' => 'dna-permission', 'data' => $ajax ? NULL : theme('dna_permission', array('permission' => self::explain_access('delete', $node, $account, $langcode)))));
         }
         if (count($rows)) {
             $output['title'] = array('#prefix' => '<h2>', '#markup' => t('Access permissions by user for the %langname language', array('%langname' => $language->name)), '#postfix' => '</h2>');
             $output[] = array('#theme' => 'table', '#header' => $headers, '#rows' => $rows, '#attributes' => array('style' => 'text-align: left'));
             $output[] = array('#theme' => 'form_element', '#description' => t('(This table lists the most-recently active users. Hover your mouse over each result for more details.)'));
         }
     }
     return $output;
 }
开发者ID:ABaldwinHunter,项目名称:durhamatletico-cms,代码行数:54,代码来源:DnaUser.php

示例8: access

 /**
  * {@inheritdoc}
  */
 public function access(Route $route, Request $request, AccountInterface $account)
 {
     // For the translation forms we have a target language, so we need some
     // checks in addition to the checks performed for the translation overview.
     $base_access = parent::access($route, $request, $account);
     if ($base_access === static::ALLOW) {
         $target_language = language_load($request->attributes->get('langcode'));
         // Make sure that the target language is not locked, and that the target
         // language is not the original submission language. Although technically
         // configuration can be overlaid with translations in the same language,
         // that is logically not a good idea.
         $access = !empty($target_language) && !$target_language->locked && $target_language->id != $this->sourceLanguage->id;
         return $access ? static::ALLOW : static::DENY;
     }
     return static::DENY;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:19,代码来源:ConfigTranslationFormAccess.php

示例9: access

 /**
  * Checks translation access for the entity and operation on the given route.
  *
  * @param \Symfony\Component\Routing\Route $route
  *   The route to check against.
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The request object.
  * @param \Drupal\Core\Session\AccountInterface $account
  *   The currently logged in account.
  * @param string $source
  *   (optional) For a create operation, the language code of the source.
  * @param string $target
  *   (optional) For a create operation, the language code of the translation.
  * @param string $language
  *   (optional) For an update or delete operation, the language code of the
  *   translation being updated or deleted.
  *
  * @return string
  *   A \Drupal\Core\Access\AccessInterface constant value.
  */
 public function access(Route $route, Request $request, AccountInterface $account, $source = NULL, $target = NULL, $language = NULL)
 {
     $entity_type = $request->attributes->get('_entity_type_id');
     /** @var $entity \Drupal\Core\Entity\EntityInterface */
     if ($entity = $request->attributes->get($entity_type)) {
         $operation = $route->getRequirement('_access_content_translation_manage');
         $controller = content_translation_controller($entity_type, $account);
         // Load translation.
         $translations = $entity->getTranslationLanguages();
         $languages = language_list();
         switch ($operation) {
             case 'create':
                 $source = language_load($source) ?: $entity->language();
                 $target = language_load($target) ?: \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT);
                 return $source->id != $target->id && isset($languages[$source->id]) && isset($languages[$target->id]) && !isset($translations[$target->id]) && $controller->getTranslationAccess($entity, $operation) ? static::ALLOW : static::DENY;
             case 'update':
             case 'delete':
                 $language = language_load($language) ?: \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT);
                 return isset($languages[$language->id]) && $language->id != $entity->getUntranslated()->language()->id && isset($translations[$language->id]) && $controller->getTranslationAccess($entity, $operation) ? static::ALLOW : static::DENY;
         }
     }
     return static::DENY;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:43,代码来源:ContentTranslationManageAccessCheck.php

示例10: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state, Request $request = NULL, $plugin_id = NULL, $langcode = NULL)
 {
     /** @var \Drupal\config_translation\ConfigMapperInterface $mapper */
     $mapper = $this->configMapperManager->createInstance($plugin_id);
     $mapper->populateFromRequest($request);
     $language = language_load($langcode);
     if (!$language) {
         throw new NotFoundHttpException();
     }
     $this->mapper = $mapper;
     $this->language = $language;
     return parent::buildForm($form, $form_state);
 }
开发者ID:shumer,项目名称:blog,代码行数:16,代码来源:ConfigTranslationDeleteForm.php

示例11: testContactConfigEntityTranslation

 /**
  * Tests the contact category translation.
  */
 public function testContactConfigEntityTranslation()
 {
     $this->drupalLogin($this->admin_user);
     $this->drupalGet('admin/structure/contact');
     // Check for default contact form configuration entity from Contact module.
     $this->assertLinkByHref('admin/structure/contact/manage/feedback');
     // Save default language configuration.
     $label = 'Send your feedback';
     $edit = array('label' => $label, 'recipients' => 'sales@example.com,support@example.com', 'reply' => 'Thank you for your mail');
     $this->drupalPostForm('admin/structure/contact/manage/feedback', $edit, t('Save'));
     // Ensure translation link is present.
     $translation_base_url = 'admin/structure/contact/manage/feedback/translate';
     $this->assertLinkByHref($translation_base_url);
     // Visit the form to confirm the changes.
     $this->drupalGet('contact/feedback');
     $this->assertText($label);
     foreach ($this->langcodes as $langcode) {
         $this->drupalGet($translation_base_url);
         // 'Add' link should be present for $langcode translation.
         $translation_page_url = "{$translation_base_url}/{$langcode}/add";
         $this->assertLinkByHref($translation_page_url);
         // Make sure original text is present on this page.
         $this->drupalGet($translation_page_url);
         $this->assertText($label);
         // Update translatable fields.
         $edit = array('config_names[contact.category.feedback][label][translation]' => 'Website feedback - ' . $langcode, 'config_names[contact.category.feedback][reply][translation]' => 'Thank you for your mail - ' . $langcode);
         // Save language specific version of form.
         $this->drupalPostForm($translation_page_url, $edit, t('Save translation'));
         // Expect translated values in language specific file.
         $override = \Drupal::languageManager()->getLanguageConfigOverride($langcode, 'contact.category.feedback');
         $expected = array('label' => 'Website feedback - ' . $langcode, 'reply' => 'Thank you for your mail - ' . $langcode);
         $this->assertEqual($expected, $override->get());
         // Check for edit, delete links (and no 'add' link) for $langcode.
         $this->assertNoLinkByHref("{$translation_base_url}/{$langcode}/add");
         $this->assertLinkByHref("{$translation_base_url}/{$langcode}/edit");
         $this->assertLinkByHref("{$translation_base_url}/{$langcode}/delete");
         // Visit language specific version of form to check label.
         $this->drupalGet($langcode . '/contact/feedback');
         $this->assertText('Website feedback - ' . $langcode);
         // Submit feedback.
         $edit = array('subject[0][value]' => 'Test subject', 'message[0][value]' => 'Test message');
         $this->drupalPostForm(NULL, $edit, t('Send message'));
     }
     // Now that all language translations are present, check translation and
     // original text all appear in any translated page on the translation
     // forms.
     foreach ($this->langcodes as $langcode) {
         $langcode_prefixes = array_merge(array(''), $this->langcodes);
         foreach ($langcode_prefixes as $langcode_prefix) {
             $this->drupalGet(ltrim("{$langcode_prefix}/{$translation_base_url}/{$langcode}/edit"));
             $this->assertFieldByName('config_names[contact.category.feedback][label][translation]', 'Website feedback - ' . $langcode);
             $this->assertText($label);
         }
     }
     // We get all emails so no need to check inside the loop.
     $captured_emails = $this->drupalGetMails();
     // Check language specific auto reply text in email body.
     foreach ($captured_emails as $email) {
         if ($email['id'] == 'contact_page_autoreply') {
             // Trim because we get an added newline for the body.
             $this->assertEqual(trim($email['body']), 'Thank you for your mail - ' . $email['langcode']);
         }
     }
     // Test that delete links work and operations perform properly.
     foreach ($this->langcodes as $langcode) {
         $replacements = array('%label' => t('!label !entity_type', array('!label' => $label, '!entity_type' => Unicode::strtolower(t('Contact category')))), '@language' => language_load($langcode)->name);
         $this->drupalGet("{$translation_base_url}/{$langcode}/delete");
         $this->assertRaw(t('Are you sure you want to delete the @language translation of %label?', $replacements));
         // Assert link back to list page to cancel delete is present.
         $this->assertLinkByHref($translation_base_url);
         $this->drupalPostForm(NULL, array(), t('Delete'));
         $this->assertRaw(t('@language translation of %label was deleted', $replacements));
         $this->assertLinkByHref("{$translation_base_url}/{$langcode}/add");
         $this->assertNoLinkByHref("translation_base_url/{$langcode}/edit");
         $this->assertNoLinkByHref("{$translation_base_url}/{$langcode}/delete");
         // Expect no language specific file present anymore.
         $override = \Drupal::languageManager()->getLanguageConfigOverride($langcode, 'contact.category.feedback');
         $this->assertTrue($override->isNew());
     }
     // Check configuration page with translator user. Should have no access.
     $this->drupalLogout();
     $this->drupalLogin($this->translator_user);
     $this->drupalGet('admin/structure/contact/manage/feedback');
     $this->assertResponse(403);
     // While translator can access the translation page, the edit link is not
     // present due to lack of permissions.
     $this->drupalGet($translation_base_url);
     $this->assertNoLink(t('Edit'));
     // Check 'Add' link for French.
     $this->assertLinkByHref("{$translation_base_url}/fr/add");
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:94,代码来源:ConfigTranslationUiTest.php

示例12: testMenuLanguageRemovedEnglish

 /**
  * Tests menu configuration is still English after English has been deleted.
  */
 function testMenuLanguageRemovedEnglish()
 {
     // Create a test menu to test language settings.
     // Machine name has to be lowercase.
     $menu_name = Unicode::strtolower($this->randomMachineName(16));
     $edit = array('id' => $menu_name, 'description' => '', 'label' => $this->randomString(), 'langcode' => 'en');
     $this->drupalPostForm('admin/structure/menu/add', $edit, t('Save'));
     // Check that the language settings were saved.
     $menu = Menu::load($menu_name);
     $this->assertEqual($menu->language()->getId(), 'en');
     // Remove English language. To do that another language has to be set as
     // default.
     $language = language_load('cs');
     $language->default = TRUE;
     language_save($language);
     language_delete('en');
     // Save the menu again and check if the language is still the same.
     $this->drupalPostForm("admin/structure/menu/manage/{$menu_name}", array(), t('Save'));
     $menu = Menu::load($menu_name);
     $this->assertEqual($menu->language()->getId(), 'en');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:24,代码来源:MenuLanguageTest.php

示例13: write

 /**
  * {@inheritdoc}
  */
 public function write(NodeInterface $node, array $grants, $realm = NULL, $delete = TRUE)
 {
     if ($delete) {
         $query = $this->database->delete('node_access')->condition('nid', $node->id());
         if ($realm) {
             $query->condition('realm', array($realm, 'all'), 'IN');
         }
         $query->execute();
     }
     // Only perform work when node_access modules are active.
     if (!empty($grants) && count($this->moduleHandler->getImplementations('node_grants'))) {
         $query = $this->database->insert('node_access')->fields(array('nid', 'langcode', 'fallback', 'realm', 'gid', 'grant_view', 'grant_update', 'grant_delete'));
         // If we have defined a granted langcode, use it. But if not, add a grant
         // for every language this node is translated to.
         foreach ($grants as $grant) {
             if ($realm && $realm != $grant['realm']) {
                 continue;
             }
             if (isset($grant['langcode'])) {
                 $grant_languages = array($grant['langcode'] => language_load($grant['langcode']));
             } else {
                 $grant_languages = $node->getTranslationLanguages(TRUE);
             }
             foreach ($grant_languages as $grant_langcode => $grant_language) {
                 // Only write grants; denies are implicit.
                 if ($grant['grant_view'] || $grant['grant_update'] || $grant['grant_delete']) {
                     $grant['nid'] = $node->id();
                     $grant['langcode'] = $grant_langcode;
                     // The record with the original langcode is used as the fallback.
                     if ($grant['langcode'] == $node->language()->getId()) {
                         $grant['fallback'] = 1;
                     } else {
                         $grant['fallback'] = 0;
                     }
                     $query->values($grant);
                 }
             }
         }
         $query->execute();
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:44,代码来源:NodeGrantDatabaseStorage.php

示例14: language

 /**
  * {@inheritdoc}
  */
 public function language()
 {
     return language_load($this->langcode);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:7,代码来源:LocaleTypedConfig.php

示例15: testConfigLanguageOverride

 /**
  * Tests locale override based on language.
  */
 function testConfigLanguageOverride()
 {
     // The language module implements a config factory override object that
     // overrides configuration when the Language module is enabled. This test ensures that
     // English overrides work.
     \Drupal::languageManager()->setConfigOverrideLanguage(language_load('en'));
     $config = \Drupal::config('config_test.system');
     $this->assertIdentical($config->get('foo'), 'en bar');
     // Ensure that the raw data is not translated.
     $raw = $config->getRawData();
     $this->assertIdentical($raw['foo'], 'bar');
     ConfigurableLanguage::createFromLangcode('fr')->save();
     ConfigurableLanguage::createFromLangcode('de')->save();
     \Drupal::languageManager()->setConfigOverrideLanguage(language_load('fr'));
     $config = \Drupal::config('config_test.system');
     $this->assertIdentical($config->get('foo'), 'fr bar');
     \Drupal::languageManager()->setConfigOverrideLanguage(language_load('de'));
     $config = \Drupal::config('config_test.system');
     $this->assertIdentical($config->get('foo'), 'de bar');
     // Test overrides of completely new configuration objects. In normal runtime
     // this should only happen for configuration entities as we should not be
     // creating simple configuration objects on the fly.
     \Drupal::languageManager()->getLanguageConfigOverride('de', 'config_test.new')->set('language', 'override')->save();
     $config = \Drupal::config('config_test.new');
     $this->assertTrue($config->isNew(), 'The configuration object config_test.new is new');
     $this->assertIdentical($config->get('language'), 'override');
     $old_state = \Drupal::configFactory()->getOverrideState();
     \Drupal::configFactory()->setOverrideState(FALSE);
     $config = \Drupal::config('config_test.new');
     $this->assertIdentical($config->get('language'), NULL);
     \Drupal::configFactory()->setOverrideState($old_state);
     // Test how overrides react to base configuration changes. Set up some base
     // values.
     \Drupal::config('config_test.foo')->set('value', array('key' => 'original'))->set('label', 'Original')->save();
     \Drupal::languageManager()->getLanguageConfigOverride('de', 'config_test.foo')->set('value', array('key' => 'override'))->set('label', 'Override')->save();
     \Drupal::languageManager()->getLanguageConfigOverride('fr', 'config_test.foo')->set('value', array('key' => 'override'))->save();
     \Drupal::configFactory()->clearStaticCache();
     $config = \Drupal::config('config_test.foo');
     $this->assertIdentical($config->get('value'), array('key' => 'override'));
     // Ensure renaming the config will rename the override.
     \Drupal::configFactory()->rename('config_test.foo', 'config_test.bar');
     $config = \Drupal::config('config_test.bar');
     $this->assertEqual($config->get('value'), array('key' => 'original'));
     $override = \Drupal::languageManager()->getLanguageConfigOverride('de', 'config_test.foo');
     $this->assertTrue($override->isNew());
     $this->assertEqual($override->get('value'), NULL);
     $override = \Drupal::languageManager()->getLanguageConfigOverride('de', 'config_test.bar');
     $this->assertFalse($override->isNew());
     $this->assertEqual($override->get('value'), array('key' => 'override'));
     $override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'config_test.bar');
     $this->assertFalse($override->isNew());
     $this->assertEqual($override->get('value'), array('key' => 'override'));
     // Ensure changing data in the config will update the overrides.
     $config = \Drupal::config('config_test.bar')->clear('value.key')->save();
     $this->assertEqual($config->get('value'), array());
     $override = \Drupal::languageManager()->getLanguageConfigOverride('de', 'config_test.bar');
     $this->assertFalse($override->isNew());
     $this->assertEqual($override->get('value'), NULL);
     // The French override will become empty and therefore removed.
     $override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'config_test.bar');
     $this->assertTrue($override->isNew());
     $this->assertEqual($override->get('value'), NULL);
     // Ensure deleting the config will delete the override.
     \Drupal::configFactory()->get('config_test.bar')->delete();
     $override = \Drupal::languageManager()->getLanguageConfigOverride('de', 'config_test.bar');
     $this->assertTrue($override->isNew());
     $this->assertEqual($override->get('value'), NULL);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:71,代码来源:ConfigLanguageOverrideTest.php


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