本文整理汇总了PHP中language_default函数的典型用法代码示例。如果您正苦于以下问题:PHP language_default函数的具体用法?PHP language_default怎么用?PHP language_default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了language_default函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getManagedTargets
public function getManagedTargets($as_detailed_objects = FALSE)
{
lingotek_add_missing_locales();
// fills in any missing lingotek_locale values to the languages table
$targets_drupal = language_list();
$default_language = language_default();
$targets = array();
foreach ($targets_drupal as $key => $target) {
$is_source = $default_language->language == $target->language;
$is_lingotek_managed = $target->lingotek_enabled;
if ($is_source) {
continue;
// skip, since the source language is not a target
} else {
if (!$is_lingotek_managed) {
continue;
// skip, since lingotek is not managing the language
}
}
$target->active = $target->lingotek_enabled;
$targets[$key] = $target;
}
$result = $as_detailed_objects ? $targets : array_map(create_function('$obj', 'return $obj->lingotek_locale;'), $targets);
return $result;
}
示例2: setUp
protected function setUp()
{
parent::setUp();
// Set up an additional language.
$this->langcodes = array(language_default()->getId(), 'es');
ConfigurableLanguage::createFromLangcode('es')->save();
// Create a content type.
$this->bundle = $this->randomMachineName();
$this->contentType = $this->drupalCreateContentType(array('type' => $this->bundle));
// Enable translation for the current entity type and ensure the change is
// picked up.
content_translation_set_config('node', $this->bundle, 'enabled', TRUE);
drupal_static_reset();
\Drupal::entityManager()->clearCachedBundles();
\Drupal::service('router.builder')->rebuild();
// Add a translatable field to the content type.
entity_create('field_storage_config', array('field_name' => 'field_test_text', 'entity_type' => 'node', 'type' => 'text', 'cardinality' => 1, 'translatable' => TRUE))->save();
entity_create('field_config', array('entity_type' => 'node', 'field_name' => 'field_test_text', 'bundle' => $this->bundle, 'label' => 'Test text-field'))->save();
entity_get_form_display('node', $this->bundle, 'default')->setComponent('field_test_text', array('type' => 'text_textfield', 'weight' => 0))->save();
// Enable content translation.
$configuration = array('langcode' => language_default()->getId(), 'language_show' => TRUE);
language_save_default_configuration('node', $this->bundle, $configuration);
// Create a translator user.
$permissions = array('access contextual links', 'administer nodes', "edit any {$this->bundle} content", 'translate any entity');
$this->translator = $this->drupalCreateUser($permissions);
}
示例3: libya_cron_subscription_mail
function libya_cron_subscription_mail($data)
{
// subscription node
$mail = $data[0];
$nids = $data[1];
// watchdog('actions', 'Cron subscription vars', func_get_args());
global $siteName, $isMail, $base_url;
$isMail = TRUE;
$body = '<h1 style="font-size:1.25em;">Your alert subscription results from ' . $siteName . '</h1>
<p class="no-margin">The following results match your subscription alert.</p>';
foreach ($nids as $nid) {
$N = node_load($nid);
$content = strip_tags($N->body['und'][0]['value']);
if (strlen($content) > 200) {
$content = substr($content, 0, 200);
}
$CL = strrpos($content, ' ');
$content = substr($content, 0, $CL) . '...';
$body .= '<h2 style="font-size:1.25em;">' . l($N->title, 'node/' . $N->nid, array('attributes' => array('style' => array('text-decoration' => 'none')))) . '</h2><p>' . $content . '</p>
<p>' . t('read more: ') . l($base_url . '/' . drupal_lookup_path('alias', 'node/' . $N->nid), 'node/' . $N->nid, array('absolute' => TRUE)) . '</p>
<hr/>';
}
$data['message'] = 'Mail sent';
$to = $mail['mail'];
$from = variable_get('site_mail', 'mail@libyanwarthetruth.com');
$params = array('body' => $body, 'rand' => $mail['rand'], 'to' => $to);
$sent = drupal_mail('libya', 'subscription_alert_mail', $to, language_default(), $params, $from, TRUE);
}
示例4: emailCollaborators
function emailCollaborators($new_ids, $node)
{
$query = db_select('users', 'u')->condition('uid', $new_ids)->fields('u', array('name', 'mail'));
$result = $query->execute();
foreach ($result as $row) {
$options = array('absolute' => TRUE);
$jobPath = url('node/' . $node->nid, $options);
$jobTitle = $node->title;
global $user;
$inviter = $user->name;
$module = 'tap_job_invite';
$key = 'key';
$email = $row->mail;
$language = language_default();
$params = array();
$from = NULL;
$send = FALSE;
$message = drupal_mail($module, $key, $email, $language, $params, $from, $send);
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
$message['subject'] = "Collaborator invitation at Tap";
$message['body'] = array();
$message['body'][] = "You have invited as a Collaborator by {$inviter} to the job <a href=\"{$jobPath}\">{$jobTitle}</a>. ";
$message['body'][] = "Log in to join the workroom.";
// Retrieve the responsible implementation for this message.
$system = drupal_mail_system($module, $key);
// Format the message body.
$message = $system->format($message);
// Send e-mail.
$message['result'] = $system->mail($message);
}
}
示例5: deliver
/**
* Override parent deliver() function.
*/
public function deliver(array $output = array())
{
$plugin = $this->plugin;
$message = $this->message;
$options = $plugin['options'];
$account = user_load($message->uid);
$mail = !empty($options['mail']) ? $options['mail'] : $account->mail;
$languages = language_list();
if (!$options['language override']) {
$lang = !empty($account->language) && $account->language != LANGUAGE_NONE ? $languages[$account->language] : language_default();
} else {
$lang = $languages[$message->language];
}
// The subject in an email can't be with HTML, so strip it.
$output['message_notify_email_subject'] = strip_tags($output['message_notify_email_subject']);
// Allow for overriding the 'from' of the message.
$from = isset($options['from']) ? $options['from'] : NULL;
$from_account = !empty($message->user->uid) ? user_load($message->user->uid) : $account;
$mimemail_name = variable_get('mimemail_name', t('Atrium'));
$from = array('name' => oa_core_realname($from_account) . ' (' . $mimemail_name . ')', 'mail' => is_array($from) ? $from['mail'] : $from);
// Pass the message entity along to hook_drupal_mail().
$output['message_entity'] = $message;
if (!empty($message->email_attachments)) {
$output['attachments'] = isset($output['attachments']) ? $output['attachments'] : array();
$output['attachments'] = array_merge($message->email_attachments, $output['attachments']);
}
return drupal_mail('message_notify', $message->type, $mail, $lang, $output, $from);
}
示例6: mailStatusUpdate
public function mailStatusUpdate($status, $attached)
{
$mail = $this->node->field_email[0]['value'];
$v['subject'] = 'Ваше замечание обработано';
$v['body'] = "Добрый день!\n\n";
$v['body'] .= "Вы писали нам про ошибку в вопросе %1\$s. ";
if ($status == 'resolved') {
$v['body'] .= "Эта ошибка исправлена. В течение 24 часов изменения будут отображены.\n\n";
} elseif ($status == 'accepted') {
$v['body'] .= "Мы признаём эту ошибку. \n\n";
} elseif ($status == 'rejected') {
$v['body'] .= "\n\nНам кажется, что этой ошибки в вопросе нет (или ваше сообщение не было сообщением об ошибке).\n\n";
}
if ($attached) {
$v['body'] .= 'Ваше замечание прикреплено к вопросу.' . "\n\n";
}
$v['body'] .= "Постоянный адрес вашего сообщения -- %2\$s.";
if ($this->oldnode->comment_count) {
$v['body'] .= " По этому адресу вы можете прочитать комментарии";
}
$v['body'] .= "\n\nСпасибо!\n\n-- \nРоман Семизаров\n";
$q = $this->getQuestion();
$v['body'] = sprintf($v['body'], $q->getAbsoluteQuestionUrl(), url('node/' . $this->node->nid, array('absolute' => TRUE)));
drupal_mail('chgk_db', 'issue_status_updated', $mail, language_default(), $v);
}
示例7: getDefaultOperations
/**
* {@inheritdoc}
*/
public function getDefaultOperations(EntityInterface $entity)
{
$operations = parent::getDefaultOperations($entity);
$default = language_default();
// Deleting the site default language is not allowed.
if ($entity->id() == $default->id) {
unset($operations['delete']);
}
return $operations;
}
示例8: ListLanguages
/**
* verifica se a linguagem esta habilitada, se não retorna padrão (ingles)
* @param string $lang - Codigo de linguagem
* @return Ambiguous <multitype: array/object, boolean>
*/
function ListLanguages($lang)
{
$result = $this->SqlSelect("SELECT * From {languages} WHERE language = '{$lang}' AND enabled = '1' ORDER BY weight, name ASC");
if (mysql_numrows($result) < 1) {
return language_default();
}
$row = NULL;
while ($row = mysql_fetch_object($result)) {
$languages = $row;
}
return $languages;
}
示例9: __construct
/**
* Constructor.
*
* This is private since we want consumers to instantiate via the factory methods.
*
* @param $set_id
* A Config Set ID.
*/
private function __construct($set_id = NULL)
{
$this->sid = $set_id;
$this->set_size = LINGOTEK_CONFIG_SET_SIZE;
$this->source_data = self::getAllSegments($this->sid);
$this->source_meta = self::getSetMeta($this->sid);
$this->language = language_default();
if (!isset($this->language->lingotek_locale)) {
// if Drupal variable 'language_default' does not exist
$this->language->lingotek_locale = Lingotek::convertDrupal2Lingotek($this->language->language);
}
$this->language_targets = Lingotek::getLanguagesWithoutSource($this->language->lingotek_locale);
}
示例10: __construct
/**
* Constructor.
*
* This is private since we want consumers to instantiate via the factory methods.
*
* @param $chunk_id
* A Config Chunk ID.
*/
private function __construct($chunk_id = NULL)
{
$this->cid = $chunk_id;
$this->chunk_size = LINGOTEK_CONFIG_CHUNK_SIZE;
$this->source_data = self::getAllSegments($this->cid);
$this->source_meta = self::getChunkMeta($this->cid);
$this->language = language_default();
if (!isset($this->language->lingotek_locale)) {
// if Drupal variable 'language_default' does not exist
$this->language->lingotek_locale = Lingotek::convertDrupal2Lingotek($this->language->language);
}
$this->language_targets = Lingotek::getLanguagesWithoutSource($this->language->lingotek_locale);
$this->min_lid = $this->getMinLid();
$this->max_lid = $this->getMaxLid();
}
示例11: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, array &$form_state)
{
$langcode = $this->entity->id();
// Warn and redirect user when attempting to delete the default language.
if (language_default()->id == $langcode) {
drupal_set_message($this->t('The default language cannot be deleted.'));
$url = $this->urlGenerator->generateFromPath('admin/config/regional/language', array('absolute' => TRUE));
return new RedirectResponse($url);
}
// Throw a 404 when attempting to delete a non-existing language.
$languages = language_list();
if (!isset($languages[$langcode])) {
throw new NotFoundHttpException();
}
return parent::buildForm($form, $form_state);
}
示例12: renderLink
/**
* {@inheritdoc}
*/
protected function renderLink($data, ResultRow $values)
{
if (!empty($this->options['link_to_user'])) {
$uid = $this->getValue($values, 'uid');
if ($this->view->getUser()->hasPermission('access user profiles') && $uid) {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = 'user/' . $uid;
}
}
if (empty($data)) {
$lang = language_default();
} else {
$lang = language_list();
$lang = $lang[$data];
}
return $this->sanitizeValue($lang->getName());
}
示例13: alterItems
public function alterItems(array &$items)
{
// Prevent session information from being saved while indexing.
drupal_save_session(FALSE);
// Force the current user to anonymous to prevent access bypass in search
// indexes.
$original_user = $GLOBALS['user'];
$GLOBALS['user'] = drupal_anonymous_user();
$entity_type = $this->index->getEntityType();
$entity_handler = panelizer_entity_plugin_get_handler($entity_type);
foreach ($items as &$item) {
$entity_id = entity_id($entity_type, $item);
$item->search_api_panelizer_content = NULL;
$item->search_api_panelizer_title = NULL;
// If Search API specifies a language to view the item in, force the
// global language_content to be Search API item language. Fieldable
// panel panes will render in the correct language.
if (isset($item->search_api_language)) {
global $language_content;
$original_language_content = $language_content;
$languages = language_list();
if (isset($languages[$item->search_api_language])) {
$language_content = $languages[$item->search_api_language];
} else {
$language_content = language_default();
}
}
try {
if ($render_info = $entity_handler->render_entity($item, 'page_manager')) {
$item->search_api_panelizer_content = $render_info['content'];
$item->search_api_panelizer_title = !empty($render_info['title']) ? $render_info['title'] : NULL;
}
} catch (Exception $e) {
watchdog_exception('panelizer', $e, 'Error indexing Panelizer content for %entity_type with ID %entity_id', array('%entity_type' => $entity_type, '%entity_id' => $entity_id));
}
// Restore the language_content global if it was overridden.
if (isset($original_language_content)) {
$language_content = $original_language_content;
}
}
// Restore the user.
$GLOBALS['user'] = $original_user;
drupal_save_session(TRUE);
}
示例14: deliver
public function deliver(array $output = array())
{
$plugin = $this->plugin;
$message = $this->message;
$options = $plugin['options'];
$account = user_load($message->uid);
$mail = $options['mail'] ? $options['mail'] : $account->mail;
$languages = language_list();
if (!$options['language override']) {
$lang = !empty($account->language) && $account->language != LANGUAGE_NONE ? $languages[$account->language] : language_default();
} else {
$lang = $languages[$message->language];
}
// The subject in an email can't be with HTML, so strip it.
$output['message_notify_email_subject'] = strip_tags($output['message_notify_email_subject']);
// Pass the message entity along to hook_drupal_mail().
$output['message_entity'] = $message;
return drupal_mail('message_notify', $message->type, $mail, $lang, $output);
}
示例15: execute
/**
* {@inheritdoc}
*/
public function execute($entity = NULL)
{
if (empty($this->configuration['node'])) {
$this->configuration['node'] = $entity;
}
$recipient = $this->token->replace($this->configuration['recipient'], $this->configuration);
// If the recipient is a registered user with a language preference, use
// the recipient's preferred language. Otherwise, use the system default
// language.
$recipient_accounts = $this->storage->loadByProperties(array('mail' => $recipient));
$recipient_account = reset($recipient_accounts);
if ($recipient_account) {
$langcode = $recipient_account->getPreferredLangcode();
} else {
$langcode = language_default()->id;
}
$params = array('context' => $this->configuration);
if (drupal_mail('system', 'action_send_email', $recipient, $langcode, $params)) {
watchdog('action', 'Sent email to %recipient', array('%recipient' => $recipient));
} else {
watchdog('error', 'Unable to send email to %recipient', array('%recipient' => $recipient));
}
}