Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function summary()
 {
     $language_list = language_list(LanguageInterface::STATE_ALL);
     $selected = $this->configuration['langcodes'];
     // Reduce the language list to an array of language names.
     $language_names = array_reduce($language_list, function (&$result, $item) use($selected) {
         // If the current item of the $language_list array is one of the selected
         // languages, add it to the $results array.
         if (!empty($selected[$item->getId()])) {
             $result[$item->getId()] = $item->name;
         }
         return $result;
     }, array());
     // If we have more than one language selected, separate them by commas.
     if (count($this->configuration['langcodes']) > 1) {
         $languages = implode(', ', $language_names);
     } else {
         // If we have just one language just grab the only present value.
         $languages = array_pop($language_names);
     }
     if (!empty($this->configuration['negate'])) {
         return t('The language is not @languages.', array('@languages' => $languages));
     }
     return t('The language is @languages.', array('@languages' => $languages));
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = array();
     // Initialize a language list to the ones available, including English.
     $languages = language_list();
     $existing_languages = array();
     foreach ($languages as $langcode => $language) {
         $existing_languages[$langcode] = $language->name;
     }
     // If we have no languages available, present the list of predefined languages
     // only. If we do have already added languages, set up two option groups with
     // the list of existing and then predefined languages.
     if (empty($existing_languages)) {
         $language_options = $this->languageManager->getStandardLanguageListWithoutConfigured();
     } else {
         $language_options = array($this->t('Existing languages') => $existing_languages, $this->t('Languages not yet added') => $this->languageManager->getStandardLanguageListWithoutConfigured());
     }
     $form['mappings'] = array('#tree' => TRUE, '#theme' => 'language_negotiation_configure_browser_form_table');
     $mappings = $this->language_get_browser_drupal_langcode_mappings();
     foreach ($mappings as $browser_langcode => $drupal_langcode) {
         $form['mappings'][$browser_langcode] = array('browser_langcode' => array('#type' => 'textfield', '#default_value' => $browser_langcode, '#size' => 20, '#required' => TRUE), 'drupal_langcode' => array('#type' => 'select', '#options' => $language_options, '#default_value' => $drupal_langcode, '#required' => TRUE));
     }
     // Add empty row.
     $form['new_mapping'] = array('#type' => 'details', '#title' => $this->t('Add a new mapping'), '#tree' => TRUE);
     $form['new_mapping']['browser_langcode'] = array('#type' => 'textfield', '#title' => $this->t('Browser language code'), '#description' => $this->t('Use language codes as <a href="@w3ctags">defined by the W3C</a> for interoperability. <em>Examples: "en", "en-gb" and "zh-hant".</em>', array('@w3ctags' => 'http://www.w3.org/International/articles/language-tags/')), '#default_value' => '', '#size' => 20);
     $form['new_mapping']['drupal_langcode'] = array('#type' => 'select', '#title' => $this->t('Drupal language'), '#options' => $language_options, '#default_value' => '');
     return parent::buildForm($form, $form_state);
 }
Exemplo n.º 3
0
 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;
 }
 function __construct($path)
 {
     parent::__construct($path);
     $this->filename = 'sitemap_images';
     $this->node_image_loader = new NodeImagesLoader();
     $this->available_langs = language_list();
 }
 /**
  * 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);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $filter_values = $this->translateFilterValues();
     $langcode = $filter_values['langcode'];
     $this->languageManager->reset();
     $languages = language_list();
     $langname = isset($langcode) ? $languages[$langcode]->name : "- None -";
     $form['#attached']['library'][] = 'locale/drupal.locale.admin';
     $form['langcode'] = array('#type' => 'value', '#value' => $filter_values['langcode']);
     $form['strings'] = array('#type' => 'item', '#tree' => TRUE, '#language' => $langname, '#theme' => 'locale_translate_edit_form_strings');
     if (isset($langcode)) {
         $strings = $this->translateFilterLoadStrings();
         $plural_formulas = $this->state->get('locale.translation.plurals') ?: array();
         foreach ($strings as $string) {
             // Cast into source string, will do for our purposes.
             $source = new SourceString($string);
             // Split source to work with plural values.
             $source_array = $source->getPlurals();
             $translation_array = $string->getPlurals();
             if (count($source_array) == 1) {
                 // Add original string value and mark as non-plural.
                 $form['strings'][$string->lid]['plural'] = array('#type' => 'value', '#value' => 0);
                 $form['strings'][$string->lid]['original'] = array('#type' => 'item', '#title' => $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))), '#title_display' => 'invisible', '#markup' => '<span lang="en">' . String::checkPlain($source_array[0]) . '</span>');
             } else {
                 // Add original string value and mark as plural.
                 $form['strings'][$string->lid]['plural'] = array('#type' => 'value', '#value' => 1);
                 $form['strings'][$string->lid]['original_singular'] = array('#type' => 'item', '#title' => $this->t('Singular form'), '#markup' => '<span lang="en">' . String::checkPlain($source_array[0]) . '</span>', '#prefix' => '<span class="visually-hidden">' . $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))) . '</span>');
                 $form['strings'][$string->lid]['original_plural'] = array('#type' => 'item', '#title' => $this->t('Plural form'), '#markup' => '<span lang="en">' . String::checkPlain($source_array[1]) . '</span>');
             }
             if (!empty($string->context)) {
                 $form['strings'][$string->lid]['context'] = array('#type' => 'value', '#value' => '<span lang="en">' . String::checkPlain($string->context) . '</span>');
             }
             // Approximate the number of rows to use in the default textarea.
             $rows = min(ceil(str_word_count($source_array[0]) / 12), 10);
             if (empty($form['strings'][$string->lid]['plural']['#value'])) {
                 $form['strings'][$string->lid]['translations'][0] = array('#type' => 'textarea', '#title' => $this->t('Translated string (@language)', array('@language' => $langname)), '#title_display' => 'invisible', '#rows' => $rows, '#default_value' => $translation_array[0], '#attributes' => array('lang' => $langcode));
             } else {
                 // Dealing with plural strings.
                 if (isset($plural_formulas[$langcode]['plurals']) && $plural_formulas[$langcode]['plurals'] > 2) {
                     // Add a textarea for each plural variant.
                     for ($i = 0; $i < $plural_formulas[$langcode]['plurals']; $i++) {
                         $form['strings'][$string->lid]['translations'][$i] = array('#type' => 'textarea', '#title' => $i == 0 ? $this->t('Singular form') : format_plural($i, 'First plural form', '@count. plural form'), '#rows' => $rows, '#default_value' => isset($translation_array[$i]) ? $translation_array[$i] : '', '#attributes' => array('lang' => $langcode), '#prefix' => $i == 0 ? '<span class="visually-hidden">' . $this->t('Translated string (@language)', array('@language' => $langname)) . '</span>' : '');
                     }
                 } else {
                     // Fallback for unknown number of plurals.
                     $form['strings'][$string->lid]['translations'][0] = array('#type' => 'textarea', '#title' => $this->t('Singular form'), '#rows' => $rows, '#default_value' => $translation_array[0], '#attributes' => array('lang' => $langcode), '#prefix' => '<span class="visually-hidden">' . $this->t('Translated string (@language)', array('@language' => $langname)) . '</span>');
                     $form['strings'][$string->lid]['translations'][1] = array('#type' => 'textarea', '#title' => $this->t('Plural form'), '#rows' => $rows, '#default_value' => isset($translation_array[1]) ? $translation_array[1] : '', '#attributes' => array('lang' => $langcode));
                 }
             }
         }
         if (count(Element::children($form['strings']))) {
             $form['actions'] = array('#type' => 'actions');
             $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save translations'));
         }
     }
     return $form;
 }
 public function addFilterWidget(&$form, &$form_state, $form_id)
 {
     if ($this->active) {
         $options = array('' => t('-- Current (@lang) --', array('@lang' => t($GLOBALS['language']->name))), 'all' => t('-- All --'));
         foreach (language_list() as $key => $lang) {
             $options[$key] = t($lang->name);
         }
         $form['langselect'] = array('#type' => 'select', '#title' => t('Filter menu by language'), '#options' => $options, '#default_value' => $this->language, '#ajax' => array('callback' => '_content_menu_filter_elements_by_language'));
         $form['#content_menu_filter_widget'][] = 'langselect';
     }
 }
Exemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Prepare a language object for saving.
     $languages = language_list();
     $langcode = $form_state['values']['langcode'];
     $language = $languages[$langcode];
     $language->name = $form_state['values']['name'];
     $language->direction = $form_state['values']['direction'];
     language_save($language);
     $form_state->setRedirect('language.admin_overview');
 }
/**
 * Formulaire de config multilingue, drupal 7
 * @return mixed
 */
function pdt_cookie_consent_form()
{
    $form = array();
    $languages = language_list();
    foreach ($languages as $language) {
        $lang = $language->language;
        $form[$lang] = array('#type' => "fieldset", '#title' => "Configuration pour le language " . $lang);
        $form[$lang]["pdt_cookie_consent_message_{$lang}"] = array('#title' => 'Message', '#type' => 'textfield', '#description' => '', '#default_value' => variable_get("pdt_cookie_consent_message_{$lang}", ""));
    }
    return system_settings_form($form);
}
Exemplo n.º 10
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, array &$form_state)
 {
     // Prepare a language object for saving.
     $languages = language_list();
     $langcode = $form_state['values']['langcode'];
     $language = $languages[$langcode];
     $language->name = $form_state['values']['name'];
     $language->direction = $form_state['values']['direction'];
     language_save($language);
     $form_state['redirect_route']['route_name'] = 'language.admin_overview';
 }
 /**
  * Implements \Drupal\Core\Form\FormInterface::validateForm().
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     $languages = language_list();
     // Count repeated values for uniqueness check.
     $count = array_count_values($form_state->getValue('prefix'));
     foreach ($languages as $langcode => $language) {
         $value = $form_state->getValue(array('prefix', $langcode));
         if ($value === '') {
             if (!$language->isDefault() && $form_state->getValue('language_negotiation_url_part') == LanguageNegotiationUrl::CONFIG_PATH_PREFIX) {
                 // Throw a form error if the prefix is blank for a non-default language,
                 // although it is required for selected negotiation type.
                 $form_state->setErrorByName("prefix][{$langcode}", $this->t('The prefix may only be left blank for the default language.'));
             }
         } elseif (strpos($value, '/') !== FALSE) {
             // Throw a form error if the string contains a slash,
             // which would not work.
             $form_state->setErrorByName("prefix][{$langcode}", $this->t('The prefix may not contain a slash.'));
         } elseif (isset($count[$value]) && $count[$value] > 1) {
             // Throw a form error if there are two languages with the same
             // domain/prefix.
             $form_state->setErrorByName("prefix][{$langcode}", $this->t('The prefix for %language, %value, is not unique.', array('%language' => $language->name, '%value' => $value)));
         }
     }
     // Count repeated values for uniqueness check.
     $count = array_count_values($form_state->getValue('domain'));
     foreach ($languages as $langcode => $language) {
         $value = $form_state->getValue(array('domain', $langcode));
         if ($value === '') {
             if ($form_state->getValue('language_negotiation_url_part') == LanguageNegotiationUrl::CONFIG_DOMAIN) {
                 // Throw a form error if the domain is blank for a non-default language,
                 // although it is required for selected negotiation type.
                 $form_state->setErrorByName("domain][{$langcode}", $this->t('The domain may not be left blank for %language.', array('%language' => $language->name)));
             }
         } elseif (isset($count[$value]) && $count[$value] > 1) {
             // Throw a form error if there are two languages with the same
             // domain/domain.
             $form_state->setErrorByName("domain][{$langcode}", $this->t('The domain for %language, %value, is not unique.', array('%language' => $language->name, '%value' => $value)));
         }
     }
     // Domain names should not contain protocol and/or ports.
     foreach ($languages as $langcode => $name) {
         $value = $form_state->getValue(array('domain', $langcode));
         if (!empty($value)) {
             // Ensure we have exactly one protocol when checking the hostname.
             $host = 'http://' . str_replace(array('http://', 'https://'), '', $value);
             if (parse_url($host, PHP_URL_HOST) != $value) {
                 $form_state->setErrorByName("domain][{$langcode}", $this->t('The domain for %language may only contain the domain name, not a protocol and/or port.', array('%language' => $name)));
             }
         }
     }
     parent::validateForm($form, $form_state);
 }
function simplemap_exclusions_form()
{
    $create_rows = function () {
        $loader = new ExcludedNodesLoader();
        $excluded = $loader->loadExcludedNodes();
        $available_langs = language_list();
        return array_map(function ($node) use($available_langs) {
            // The link must be created in the original node language, not in the
            // current user language.
            $node_link = l($node->title, "node/{$node->nid}", ['language' => $available_langs[$node->language]]);
            $delete_link = l(t('Delete from Exclusion'), "admin/settings/simplemap/exclusions/{$node->nid}/delete");
            return [$node->nid, $node_link, $delete_link];
        }, $excluded);
    };
    return ['new_exclusion' => ['#type' => 'fieldset', '#title' => t('Add a new node to the exclusion list'), 'nid' => ['#type' => 'textfield', '#title' => t('NID'), '#required' => true], 'submit' => ['#type' => 'submit', '#value' => t('Add to the Exclusion List')]], 'existing_exclusions' => ['#type' => 'fieldset', '#title' => t('Nodes Excluded from Sitemaps'), 'list' => ['#theme' => 'table', '#header' => [t('NID'), t('Title'), ''], '#rows' => $create_rows()]]];
}
Exemplo n.º 13
0
 /**
  * {@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());
 }
 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);
 }
Exemplo n.º 15
0
 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);
 }
Exemplo n.º 16
0
 /**
  * Prepares link to the node.
  *
  * @param string $data
  *   The XSS safe string for the link text.
  * @param \Drupal\views\ResultRow $values
  *   The values retrieved from a single row of a view's query result.
  *
  * @return string
  *   Returns a string for the link text.
  */
 protected function renderLink($data, ResultRow $values)
 {
     if (!empty($this->options['link_to_node']) && !empty($this->additional_fields['nid'])) {
         if ($data !== NULL && $data !== '') {
             $this->options['alter']['make_link'] = TRUE;
             $this->options['alter']['path'] = "node/" . $this->getValue($values, 'nid');
             if (isset($this->aliases['langcode'])) {
                 $languages = language_list();
                 $langcode = $this->getValue($values, 'langcode');
                 if (isset($languages[$langcode])) {
                     $this->options['alter']['language'] = $languages[$langcode];
                 } else {
                     unset($this->options['alter']['language']);
                 }
             }
         } else {
             $this->options['alter']['make_link'] = FALSE;
         }
     }
     return $data;
 }
Exemplo n.º 17
0
 /**
  * Give paths to all (or a subset) of the available translations
  */
 public function languageLinks($languages = NULL, $path = NULL)
 {
     if (!$languages) {
         $languages = \language_list();
     }
     if (!$path) {
         $path = \current_path();
     }
     $currentLanguage = $this->currentLanguage();
     $links = array();
     $switchLinks = $this->switchLinks($path);
     foreach ($languages as $code => $language) {
         if ($code == $currentLanguage) {
             continue;
         }
         if (isset($switchLinks[$code]) && isset($switchLinks[$code]['href']) && $this->checkAccess($switchLinks[$code]['href'], $code)) {
             $links[$code] = $switchLinks[$code];
         }
     }
     return $links;
 }
Exemplo n.º 18
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('image_captcha.settings');
     // Add CSS and JS for theming and added usability on admin form.
     $form['#attached']['library'][] = 'captcha_image/base';
     // First some error checking.
     $setup_status = _image_captcha_check_setup(FALSE);
     if ($setup_status & IMAGE_CAPTCHA_ERROR_NO_GDLIB) {
         drupal_set_message(t('The Image CAPTCHA module can not generate images because your PHP setup does not support it (no <a href="!gdlib" target="_blank">GD library</a> with JPEG support).', ['!gdlib' => 'http://php.net/manual/en/book.image.php']), 'error');
         // It is no use to continue building the rest of the settings form.
         return $form;
     }
     $form['image_captcha_example'] = ['#type' => 'details', '#title' => t('Example'), '#description' => t('Presolved image CAPTCHA example, generated with the current settings.')];
     $form['image_captcha_example']['image'] = ['#type' => 'captcha', '#captcha_type' => 'image_captcha/Image', '#captcha_admin_mode' => TRUE];
     // General code settings.
     $form['image_captcha_code_settings'] = ['#type' => 'details', '#title' => t('Code settings')];
     $form['image_captcha_code_settings']['image_captcha_image_allowed_chars'] = ['#type' => 'textfield', '#title' => t('Characters to use in the code'), '#default_value' => $config->get('image_captcha_image_allowed_chars')];
     $form['image_captcha_code_settings']['image_captcha_code_length'] = ['#type' => 'select', '#title' => t('Code length'), '#options' => [2 => 2, 3, 4, 5, 6, 7, 8, 9, 10], '#default_value' => $config->get('image_captcha_code_length'), '#description' => t('The code length influences the size of the image. Note that larger values make the image generation more CPU intensive.')];
     // RTL support option (only show this option when there are RTL languages).
     $languages = language_list('direction');
     if (isset($languages[Language::DIRECTION_RTL])) {
         $form['image_captcha_code_settings']['image_captcha_rtl_support'] = ['#title' => t('RTL support'), '#type' => 'checkbox', '#default_value' => $config->get('image_captcha_rtl_support'), '#description' => t('Enable this option to render the code from right to left for right to left languages.')];
     }
     // Font related stuff.
     $form['image_captcha_font_settings'] = $this->settingsDotSection();
     // Color and file format settings.
     $form['image_captcha_color_settings'] = ['#type' => 'details', '#title' => t('Color and image settings'), '#description' => t('Configuration of the background, text colors and file format of the image CAPTCHA.')];
     $form['image_captcha_color_settings']['image_captcha_background_color'] = ['#type' => 'textfield', '#title' => t('Background color'), '#description' => t('Enter the hexadecimal code for the background color (e.g. #FFF or #FFCE90). When using the PNG file format with transparent background, it is recommended to set this close to the underlying background color.'), '#default_value' => $config->get('image_captcha_background_color'), '#maxlength' => 7, '#size' => 8];
     $form['image_captcha_color_settings']['image_captcha_foreground_color'] = ['#type' => 'textfield', '#title' => t('Text color'), '#description' => t('Enter the hexadecimal code for the text color (e.g. #000 or #004283).'), '#default_value' => $config->get('image_captcha_foreground_color'), '#maxlength' => 7, '#size' => 8];
     $form['image_captcha_color_settings']['image_captcha_foreground_color_randomness'] = ['#type' => 'select', '#title' => t('Additional variation of text color'), '#options' => [0 => t('No variation'), 50 => t('Little variation'), 100 => t('Medium variation'), 150 => t('High variation'), 200 => t('Very high variation')], '#default_value' => $config->get('image_captcha_foreground_color_randomness'), '#description' => t('The different characters will have randomized colors in the specified range around the text color.')];
     $form['image_captcha_color_settings']['image_captcha_file_format'] = ['#type' => 'select', '#title' => t('File format'), '#description' => t('Select the file format for the image. JPEG usually results in smaller files, PNG allows tranparency.'), '#default_value' => $config->get('image_captcha_file_format'), '#options' => [IMAGE_CAPTCHA_FILE_FORMAT_JPG => t('JPEG'), IMAGE_CAPTCHA_FILE_FORMAT_PNG => t('PNG'), IMAGE_CAPTCHA_FILE_FORMAT_TRANSPARENT_PNG => t('PNG with transparent background')]];
     // Distortion and noise settings.
     $form['image_captcha_distortion_and_noise'] = ['#type' => 'details', '#title' => t('Distortion and noise'), '#description' => t('With these settings you can control the degree of obfuscation by distortion and added noise. Do not exaggerate the obfuscation and assure that the code in the image is reasonably readable. For example, do not combine high levels of distortion and noise.')];
     $form['image_captcha_distortion_and_noise']['image_captcha_distortion_amplitude'] = ['#type' => 'select', '#title' => t('Distortion level'), '#options' => [0 => t('@level - no distortion', ['@level' => '0']), 1 => t('@level - low', ['@level' => '1']), 2 => '2', 3 => '3', 4 => '4', 5 => t('@level - medium', ['@level' => '5']), 6 => '6', 7 => '7', 8 => '8', 9 => '9', 10 => t('@level - high', ['@level' => '10'])], '#default_value' => $config->get('image_captcha_distortion_amplitude'), '#description' => t('Set the degree of wave distortion in the image.')];
     $form['image_captcha_distortion_and_noise']['image_captcha_bilinear_interpolation'] = ['#type' => 'checkbox', '#title' => t('Smooth distortion'), '#default_value' => $config->get('image_captcha_bilinear_interpolation'), '#description' => t('This option enables bilinear interpolation of the distortion which makes the image look smoother, but it is more CPU intensive.')];
     $form['image_captcha_distortion_and_noise']['image_captcha_dot_noise'] = ['#type' => 'checkbox', '#title' => t('Add salt and pepper noise'), '#default_value' => $config->get('image_captcha_dot_noise'), '#description' => t('This option adds randomly colored point noise.')];
     $form['image_captcha_distortion_and_noise']['image_captcha_line_noise'] = ['#type' => 'checkbox', '#title' => t('Add line noise'), '#default_value' => $config->get('image_captcha_line_noise', 0), '#description' => t('This option enables lines randomly drawn on top of the text code.')];
     $form['image_captcha_distortion_and_noise']['image_captcha_noise_level'] = ['#type' => 'select', '#title' => t('Noise level'), '#options' => [1 => '1 - ' . t('low'), 2 => '2', 3 => '3 - ' . t('medium'), 4 => '4', 5 => '5 - ' . t('high'), 7 => '7', 10 => '10 - ' . t('severe')], '#default_value' => (int) $config->get('image_captcha_noise_level')];
     return parent::buildForm($form, $form_state);
 }
 /**
  * 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;
 }
Exemplo n.º 20
0
window.location='index.php?page=usercp&uid=<?php 
echo $CURUSER["uid"];
?>
&do=pm&action=list'
// -->
}
</script>
<?php 
if (isset($CURUSER) && $CURUSER && $CURUSER["uid"] > 1) {
    print "<form name=\"jump1\" action=\"index.php\" method=\"post\">\n";
    ?>
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<?php 
    $style = style_list();
    $langue = language_list();
    $block[0]["id"] = "yes";
    $block[0]["block"] = "side blocks";
    $block[1]["id"] = "nol";
    $block[1]["block"] = "no left";
    $block[2]["id"] = "nor";
    $block[2]["block"] = "no right";
    $block[3]["id"] = "no";
    $block[3]["block"] = "no blocks";
    // group image
    $rsr = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT picture FROM {$TABLE_PREFIX}users_level WHERE id_level=" . $CURUSER['id']);
    $rosr = mysqli_fetch_array($rsr);
    if ($rosr["picture"] == '') {
        $xx = '';
    } else {
        $xx = '<img src="images/ul/' . $rosr["picture"] . '">';
 /**
  * Adds a language
  * 
  * @param $langcode
  * @param $default
  *   Whether this is the default language
  * @param $load
  *   Whether to load available translations for that language
  */
 function addLanguage($langcode, $default = FALSE, $load = TRUE)
 {
     require_once './includes/locale.inc';
     // Enable installation language as default site language.
     locale_add_language($langcode, NULL, NULL, NULL, NULL, NULL, 1, $default);
     // Reset language list
     language_list('language', TRUE);
     // We may need to refresh default language
     drupal_init_language();
 }
Exemplo n.º 22
0
function tabella($action, $dati = array())
{
    global $idflag, $link, $idlangue, $idstyle, $CURUSER, $USE_IMAGECODE, $TABLE_PREFIX, $language, $tpl_account, $THIS_BASEPATH;
    if ($action == "signup") {
        $dati["username"] = "";
        $dati["email"] = "";
        $dati["language"] = $idlangue;
    }
    // avoid error with js
    $language["DIF_PASSWORDS"] = AddSlashes($language["DIF_PASSWORDS"]);
    $language["INSERT_PASSWORD"] = AddSlashes($language["INSERT_PASSWORD"]);
    $language["USER_PWD_AGAIN"] = AddSlashes($language["USER_PWD_AGAIN"]);
    $language["INSERT_USERNAME"] = AddSlashes($language["INSERT_USERNAME"]);
    $language["ERR_NO_EMAIL"] = AddSlashes($language["ERR_NO_EMAIL"]);
    $language["ERR_NO_EMAIL_AGAIN"] = AddSlashes($language["ERR_NO_EMAIL_AGAIN"]);
    $language["DIF_EMAIL"] = AddSlashes($language["DIF_EMAIL"]);
    $tpl_account->set("language", $language);
    $tpl_account->set("account_action", $action);
    $tpl_account->set("account_form_actionlink", htmlspecialchars("index.php?page=signup&act={$action}&returnto={$link}"));
    $tpl_account->set("account_uid", $dati["id"]);
    $tpl_account->set("account_returnto", urlencode($link));
    $tpl_account->set("account_IDlanguage", $idlang);
    $tpl_account->set("account_IDstyle", $idstyle);
    $tpl_account->set("account_IDcountry", $idflag);
    $tpl_account->set("account_username", $dati["username"]);
    $tpl_account->set("dati", $dati);
    $tpl_account->set("DEL", $action == "delete", true);
    $tpl_account->set("DISPLAY_FULL", $action == "signup", true);
    if ($action == "del") {
        $tpl_account->set("account_from_delete_confirm", "<input type=\"submit\" name=\"elimina\" value=\"" . $language["FRM_DELETE"] . "\" />&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"submit\" name=\"elimina\" value=\"" . $language["FRM_CANCEL"] . "\" />");
    } else {
        $tpl_account->set("account_from_delete_confirm", "<input type=\"submit\" name=\"conferma\" value=\"" . $language["FRM_CONFIRM"] . "\" />&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"reset\" name=\"annulla\" value=\"" . $language["FRM_CANCEL"] . "\" />");
    }
    $lres = language_list();
    $option = "\n<select name=\"language\" size=\"1\">";
    foreach ($lres as $langue) {
        $option .= "\n<option ";
        if ($langue["id"] == $dati["language"]) {
            $option .= "\"selected\" ";
        }
        $option .= "value=\"" . $langue["id"] . "\">" . $langue["language"] . "</option>";
    }
    $option .= "\n</select>";
    $tpl_account->set("account_combo_language", $option);
    $sres = style_list();
    $option = "\n<select name=\"style\" size=\"1\">";
    foreach ($sres as $style) {
        $option .= "\n<option ";
        if ($style["id"] == $dati["style"]) {
            $option .= "\"selected\" ";
        }
        $option .= "value=\"" . $style["id"] . "\">" . $style["style"] . "</option>";
    }
    $option .= "\n</select>";
    $tpl_account->set("account_combo_style", $option);
    $fres = flag_list();
    $option = "\n<select name=\"flag\" size=\"1\">\n<option value='0'>---</option>";
    $thisip = $_SERVER["REMOTE_ADDR"];
    $remotedns = gethostbyaddr($thisip);
    if ($remotedns != $thisip) {
        $remotedns = strtoupper($remotedns);
        preg_match('/^(.+)\\.([A-Z]{2,3})$/', $remotedns, $tldm);
        if (isset($tldm[2])) {
            $remotedns = mysql_escape_string($tldm[2]);
        }
    }
    foreach ($fres as $flag) {
        $option .= "\n<option ";
        if ($flag["id"] == $dati["flag"] || $flag["domain"] == $remotedns && $action == "signup") {
            $option .= "\"selected\" ";
        }
        $option .= "value=\"" . $flag["id"] . "\">" . $flag["name"] . "</option>";
    }
    $option .= "\n</select>";
    $tpl_account->set("account_combo_country", $option);
    $zone = date('Z', time());
    $daylight = date('I', time()) * 3600;
    $os = $zone - $daylight;
    if ($os != 0) {
        $timeoff = $os / 3600;
    } else {
        $timeoff = 0;
    }
    if (!$CURUSER || $CURUSER["uid"] == 1) {
        $dati["time_offset"] = $timeoff;
    }
    $tres = timezone_list();
    $option = "<select name=\"timezone\">";
    foreach ($tres as $timezone) {
        $option .= "\n<option ";
        if ($timezone["difference"] == $dati["time_offset"]) {
            $option .= "selected=\"selected\" ";
        }
        $option .= "value=\"" . $timezone["difference"] . "\">" . unesc($timezone["timezone"]) . "</option>";
    }
    $option .= "\n</select>";
    $tpl_account->set("account_combo_timezone", $option);
    // -----------------------------
    // Captcha hack
    // -----------------------------
    // if set to use secure code: try to display imagecode
    if ($USE_IMAGECODE && $action != "mod") {
        if (extension_loaded('gd')) {
            $arr = gd_info();
            if ($arr['FreeType Support'] == 1) {
                $p = new ocr_captcha();
                $tpl_account->set("CAPTCHA", true, true);
                $tpl_account->set("account_captcha", $p->display_captcha(true));
                $private = $p->generate_private();
            } else {
                include "{$THIS_BASEPATH}/include/security_code.php";
                $scode_index = rand(0, count($security_code) - 1);
                $scode = "<input type=\"hidden\" name=\"security_index\" value=\"{$scode_index}\" />\n";
                $scode .= $security_code[$scode_index]["question"];
                $tpl_account->set("scode_question", $scode);
                $tpl_account->set("CAPTCHA", false, true);
            }
        } else {
            include "{$THIS_BASEPATH}/include/security_code.php";
            $scode_index = rand(0, count($security_code) - 1);
            $scode = "<input type=\"hidden\" name=\"security_index\" value=\"{$scode_index}\" />\n";
            $scode .= $security_code[$scode_index]["question"];
            $tpl_account->set("scode_question", $scode);
            $tpl_account->set("CAPTCHA", false, true);
        }
    } elseif ($action != "mod") {
        include "{$THIS_BASEPATH}/include/security_code.php";
        $scode_index = rand(0, count($security_code) - 1);
        $scode = "<input type=\"hidden\" name=\"security_index\" value=\"{$scode_index}\" />\n";
        $scode .= $security_code[$scode_index]["question"];
        $tpl_account->set("scode_question", $scode);
        // we will request simple operation to user
        $tpl_account->set("CAPTCHA", false, true);
    }
    // -----------------------------
    // Captcha hack
    // -----------------------------
}
/**
 * Displays a language switcher. Translation links may be provided by other modules.
 */
function languagelink($currentlang)
{
    // Get the current page.  This code is preferred, but not 100%. Fix later
    $path = drupal_is_front_page() ? '<front>' : $_GET['q'];
    $languages = language_list('enabled');
    $links = array();
    foreach ($languages[1] as $language) {
        if ($language->language != $currentlang) {
            $links[$language->language] = array('href' => $path, 'title' => $language->native, 'language' => $language, 'attributes' => array('class' => 'language-link'));
            drupal_alter('translation_link', $links, $path);
            $options["language"] = $links[$language->language]['language'];
            $options["attributes"] = $links[$language->language]['attributes'];
            return l($links[$language->language]['title'], $links[$language->language]['href'], $options);
        }
    }
}
Exemplo n.º 24
0
/**
 * Implements template_preprocess_block().
 */
function ec_resp_preprocess_block(&$variables)
{
    global $user, $language;
    $block_no_panel = array('search' => 'form', 'print' => 'print-links', 'print_ui' => 'print-links', 'workbench' => 'block', 'social_bookmark' => 'social-bookmark', 'views' => 'view_ec_content_slider-block', 'om_maximenu' => array('om-maximenu-1', 'om-maximenu-2'), 'menu' => 'menu-service-tools', 'cce_basic_config' => 'footer_ipg');
    // List of all blocks that don't need their title to be displayed.
    $block_no_title = array('fat_footer' => 'fat-footer', 'om_maximenu' => array('om-maximenu-1', 'om-maximenu-2'), 'menu' => 'menu-service-tools', 'cce_basic_config' => 'footer_ipg');
    $block_no_body_class = array();
    $panel = TRUE;
    foreach ($block_no_panel as $key => $value) {
        if ($variables['block']->module == $key) {
            if (is_array($value)) {
                foreach ($value as $delta) {
                    if ($variables['block']->delta == $delta) {
                        $panel = FALSE;
                        break;
                    }
                }
            } else {
                if ($variables['block']->delta == $value) {
                    $panel = FALSE;
                    break;
                }
            }
        }
    }
    $title = TRUE;
    foreach ($block_no_title as $key => $value) {
        if ($variables['block']->module == $key) {
            if (is_array($value)) {
                foreach ($value as $delta) {
                    if ($variables['block']->delta == $delta) {
                        $title = FALSE;
                        break;
                    }
                }
            } else {
                if ($variables['block']->delta == $value) {
                    $title = FALSE;
                    break;
                }
            }
        }
    }
    $body_class = TRUE;
    foreach ($block_no_body_class as $key => $value) {
        if ($variables['block']->module == $key && $variables['block']->delta == $value) {
            $body_class = FALSE;
        }
    }
    $variables['panel'] = $panel;
    $variables['title'] = $title;
    $variables['body_class'] = $body_class;
    if (isset($variables['block']->bid)) {
        switch ($variables['block']->bid) {
            case 'locale-language':
                $languages = language_list();
                $items = array();
                $items[] = array('data' => '<span class="off-screen">' . t("Current language") . ':</span> ' . $language->language, 'class' => array('selected'), 'title' => $language->native, 'lang' => $language->language);
                // Get path of translated content.
                $translations = translation_path_get_translations(current_path());
                $language_default = language_default();
                foreach ($languages as $language_object) {
                    $prefix = $language_object->language;
                    $language_name = $language_object->name;
                    if (isset($translations[$prefix])) {
                        $path = $translations[$prefix];
                    } else {
                        $path = current_path();
                    }
                    // Get the related url alias
                    // Check if the multisite language negotiation
                    // with suffix url is enabled.
                    $language_negociation = variable_get('language_negotiation_language');
                    if (isset($language_negociation['locale-url-suffix'])) {
                        $delimiter = variable_get('language_suffix_delimiter', '_');
                        $alias = drupal_get_path_alias($path, $prefix);
                        if ($alias == variable_get('site_frontpage', 'node')) {
                            $path = $prefix == 'en' ? '' : 'index';
                        } else {
                            if ($alias != $path) {
                                $path = $alias;
                            } else {
                                $path = drupal_get_path_alias(isset($translations[$language_name]) ? $translations[$language_name] : $path, $language_name);
                            }
                        }
                    } else {
                        $path = drupal_get_path_alias($path, $prefix);
                    }
                    // Add enabled languages.
                    if ($language_name != $language->name) {
                        $items[] = array('data' => l($language_name, filter_xss($path), array('attributes' => array('hreflang' => $prefix, 'lang' => $prefix, 'title' => $language_name), 'language' => $language_object)));
                    }
                }
                $variables['language_list'] = theme('item_list', array('items' => $items));
                break;
            case 'system-user-menu':
                if ($user->uid) {
                    $name = theme('username', array('account' => $user, 'nolink' => TRUE));
                    $variables['welcome_message'] = "<div class='username'>" . t('Welcome,') . ' <strong>' . $name . '</strong></div>';
                }
                $menu = menu_navigation_links("user-menu");
                $items = array();
                // Manage redirection after login.
                $status = drupal_get_http_header('status');
                if (strpos($status, '404') !== FALSE) {
                    $dest = 'home';
                } elseif (strpos(current_path(), 'user/register') !== FALSE) {
                    $dest = 'home';
                } elseif (strpos(current_path(), 'user/login') !== FALSE) {
                    $dest = 'home';
                } else {
                    $dest = drupal_get_path_alias();
                }
                foreach ($menu as $item_id) {
                    // Get icon links to menu item.
                    $icon = isset($item_id['attributes']['data-image']) ? $item_id['attributes']['data-image'] : '';
                    // Get display title option.
                    $display_title = isset($item_id['attributes']['data-display-title']) ? $item_id['attributes']['data-display-title'] : 1;
                    // Add the icon.
                    if ($icon) {
                        if ($display_title) {
                            $item_id['title'] = '<span class="glyphicon glyphicon-' . $icon . '" aria-hidden="true"></span> ' . $item_id['title'];
                        } else {
                            // If the title is not supposed to be displayed, add a visually
                            // hidden title that is accessible for screen readers.
                            $item_id['title'] = '<span class="glyphicon glyphicon-' . $icon . ' menu-no-title" aria-hidden="true"></span><span class="sr-only">' . $item_id['title'] . '</span>';
                        }
                    }
                    // Add redirection for login, logout and register.
                    if ($item_id['href'] == 'user/login' || $item_id['href'] == 'user/register') {
                        $item_id['query']['destination'] = $dest;
                    }
                    if ($item_id['href'] == 'user/logout') {
                        $item_id['query']['destination'] = '<front>';
                    }
                    // Add icon before menu item
                    // TODO: make it editable in administration.
                    switch ($item_id['href']) {
                        case 'user':
                            $item_id['attributes']['type'] = 'user';
                            break;
                        case 'user/login':
                            $item_id['attributes']['type'] = 'login';
                            break;
                        case 'user/logout':
                            $item_id['attributes']['type'] = 'logout';
                            break;
                        case 'admin/workbench':
                            $item_id['attributes']['type'] = 'workbench';
                            break;
                    }
                    $item_id['html'] = TRUE;
                    $items[] = l($item_id['title'], $item_id['href'], $item_id);
                }
                $variables['menu_items'] = implode('', $items);
                break;
            case 'easy_breadcrumb-easy_breadcrumb':
                $variables['menu_breadcrumb'] = menu_tree('menu-breadcrumb-menu');
                break;
        }
    }
}
Exemplo n.º 25
0
}
/* ajout */
if (isset($_GET['action']) && $_GET['action'] == "Ajouter" && isset($_GET['nom'])) {
    append_error('inserting language: ' . $_GET['nom']);
    if (language_new($_GET['nom']) == -1) {
        append_error('error');
    }
}
/* suppression */
if (isset($_GET['action']) && $_GET['action'] == "Effacer" && isset($_GET['idLang'])) {
    append_error('deleting language: ' . $_GET['idLang']);
    $lang = language_get_by_id($_GET['idLang']);
    $lang->delete();
}
/* recuperation de la liste */
$list = language_list();
$select = "<select name='idLang'>\n";
while (list(, $tuple) = each($list)) {
    $select .= "<option value='" . $tuple[0] . "'>" . $tuple[0] . " " . $tuple[1] . "</option>\n";
}
?>
<h2>Gestion des langages de prog</h2>

<?php 
flush_errors();
?>

<h3>Ajout d'un langage</h3>

<form>
Nom : <input type="text" name="nom" /><br />
 /**
  * Loads values of configurable fields for a group of entities.
  *
  * Loads all fields for each entity object in a group of a single entity type.
  * The loaded field values are added directly to the entity objects.
  *
  * @param \Drupal\Core\Entity\ContentEntityInterface[] $entities
  *   An array of entities keyed by entity ID.
  */
 protected function loadFieldItems(array $entities)
 {
     if (empty($entities) || !$this->entityType->isFieldable()) {
         return;
     }
     $age = static::FIELD_LOAD_CURRENT;
     foreach ($entities as $entity) {
         if (!$entity->isDefaultRevision()) {
             $age = static::FIELD_LOAD_REVISION;
             break;
         }
     }
     $load_current = $age == static::FIELD_LOAD_CURRENT;
     // Collect entities ids, bundles and languages.
     $bundles = array();
     $ids = array();
     $default_langcodes = array();
     foreach ($entities as $key => $entity) {
         $bundles[$entity->bundle()] = TRUE;
         $ids[] = $load_current ? $key : $entity->getRevisionId();
         $default_langcodes[$key] = $entity->getUntranslated()->language()->id;
     }
     // Collect impacted fields.
     $storage_definitions = array();
     $definitions = array();
     foreach ($bundles as $bundle => $v) {
         $definitions[$bundle] = $this->entityManager->getFieldDefinitions($this->entityTypeId, $bundle);
         foreach ($definitions[$bundle] as $field_name => $field_definition) {
             $storage_definition = $field_definition->getFieldStorageDefinition();
             if ($this->usesDedicatedTable($storage_definition)) {
                 $storage_definitions[$field_name] = $storage_definition;
             }
         }
     }
     // Load field data.
     $langcodes = array_keys(language_list(LanguageInterface::STATE_ALL));
     foreach ($storage_definitions as $field_name => $storage_definition) {
         $table = $load_current ? static::_fieldTableName($storage_definition) : static::_fieldRevisionTableName($storage_definition);
         // Ensure that only values having valid languages are retrieved. Since we
         // are loading values for multiple entities, we cannot limit the query to
         // the available translations.
         $results = $this->database->select($table, 't')->fields('t')->condition($load_current ? 'entity_id' : 'revision_id', $ids, 'IN')->condition('deleted', 0)->condition('langcode', $langcodes, 'IN')->orderBy('delta')->execute();
         $delta_count = array();
         foreach ($results as $row) {
             $bundle = $entities[$row->entity_id]->bundle();
             // Ensure that records for non-translatable fields having invalid
             // languages are skipped.
             if ($row->langcode == $default_langcodes[$row->entity_id] || $definitions[$bundle][$field_name]->isTranslatable()) {
                 if (!isset($delta_count[$row->entity_id][$row->langcode])) {
                     $delta_count[$row->entity_id][$row->langcode] = 0;
                 }
                 if ($storage_definition->getCardinality() == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED || $delta_count[$row->entity_id][$row->langcode] < $storage_definition->getCardinality()) {
                     $item = array();
                     // For each column declared by the field, populate the item from the
                     // prefixed database column.
                     foreach ($storage_definition->getColumns() as $column => $attributes) {
                         $column_name = static::_fieldColumnName($storage_definition, $column);
                         // Unserialize the value if specified in the column schema.
                         $item[$column] = !empty($attributes['serialize']) ? unserialize($row->{$column_name}) : $row->{$column_name};
                     }
                     // Add the item to the field values for the entity.
                     $entities[$row->entity_id]->getTranslation($row->langcode)->{$field_name}[$delta_count[$row->entity_id][$row->langcode]] = $item;
                     $delta_count[$row->entity_id][$row->langcode]++;
                 }
             }
         }
     }
 }
Exemplo n.º 27
0
<?php

global $language;
global $base_url;
$q = $_GET['q'];
$lang_name = $language->language;
$lang_list = language_list($field = 'language');
?>

<?php 
if ($block->delta != 'main') {
    ?>
<section class="<?php 
    print $classes;
    ?>
"<?php 
    print $attributes;
    ?>
>
  <?php 
}
?>
  <div class="block-inner">
 <div class="language-switcher">
	<button href="#" data-dropdown="drop1" aria-controls="drop1" aria-expanded="false" class="button tiny dropdown"><?php 
print strtoupper($lang_name);
?>
</button><br>
	<ul id="drop1" data-dropdown-content class="f-dropdown" aria-hidden="true">
	  	<?php 
foreach ($lang_list as $lang) {
Exemplo n.º 28
0
 if ($x == 0) {
     $profiletpl["gender"] .= "<input name=\"gen\" type=\"radio\" value=\"0\" checked=\"checked\" />\n\t\t\t  " . $language["MALE"] . "   \n\t\t\t  <input name=\"gen\" type=\"radio\" value=\"1\" />\n\t\t\t" . $language["FEMALE"] . "  </label>";
 } else {
     $profiletpl["gender"] .= "<input name=\"gen\" type=\"radio\" value=\"0\" />\n\t\t\t  " . $language["MALE"] . "   </label>\n\t\t\t  <input name=\"gen\" type=\"radio\" value=\"1\" checked=\"checked\"/>\n\t\t\t" . $language["FEMALE"] . " </label>";
     $profiletpl["gender"] .= $option;
 }
 //Reverify Mail Hack by Petr1fied - Start
 if ($VALIDATION == "user") {
     //Display a message informing users that they will have
     //to verify their e-mail address if they attempt to change it
     $usercptpl->set("USER_VALIDATION", true, true);
 }
 //Reverify Mail Hack by Petr1fied - End
 if ($btit_settings["hide_language_visible"] != "visible") {
     //language list
     $lres = language_list();
     $langtpl = array();
     foreach ($lres as $langue) {
         $langtpl["language_combo"] .= "\n<option ";
         if ($langue["id"] == $CURUSER["language"]) {
             $langtpl["language_combo"] .= "selected=\"selected\" ";
         }
         $langtpl["language_combo"] .= "value=\"" . $langue["id"] . "\">" . unesc($langue["language"]) . "</option>";
         $langtpl["language_combo"] .= $option;
     }
     unset($lres);
     $usercptpl->set("lang", $langtpl);
 }
 if ($btit_settings["hide_style_visible"] != "visible") {
     //style list
     $sres = style_list();
Exemplo n.º 29
0
 /**
  * Form submission handler for ContentTranslationHandler::entityFormAlter().
  *
  * Takes care of the source language change.
  */
 public function entityFormSourceChange($form, &$form_state)
 {
     $form_controller = content_translation_form_controller($form_state);
     $entity = $form_controller->getEntity();
     $source = $form_state['values']['source_langcode']['source'];
     $path = $entity->getSystemPath('drupal:content-translation-overview');
     $form_state['redirect'] = $path . '/add/' . $source . '/' . $form_controller->getFormLangcode($form_state);
     $languages = language_list();
     drupal_set_message(t('Source language set to: %language', array('%language' => $languages[$source]->name)));
 }
    <?php 
    include "include/sidebar.php";
    ?>

    <div id="main">
        <div class="header">
            <h2>Please select options and download list of sentances accordingly.</h2>
        </div>
        <div class="content">
					<form class="pure-form pure-form-stacked" method="post">
						<fieldset>
    <div class="pure-u-1-2" style="width:49%;">
        							<label for="language">Language</label>
							<select name="lang" class="pure-u-1">
								<?php 
    language_list();
    ?>
							</select>
    </div>
	<label for="uwords">Count of words (Empty to ignore a field)</label>				
    <div class="pure-u-1-2" style="width:49%;">
        <input class="pure-input-1" type="text" placeholder="Minimum words" name="minl">
    </div>
    <div class="pure-u-1-2">
        <input class="pure-input-1" type="text" placeholder="Maximum words" name="maxl">
    </div>
	<label for="uwords">Exclude words</label>	
	<textarea rows="4" cols="125" placeholder="Comma Seperated words which you wish to exclude..." name="words"></textarea>
	<label for="uwords">Exclude words of sentances</label>	
	<textarea rows="4" cols="125" placeholder="Comma Seperated sentances whose words you wish to exclude..."></textarea>
		<input type="text" name="search" hidden value="1">