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


PHP drupal_strtolower函数代码示例

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


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

示例1: isPaymentValid

 public static function isPaymentValid($oplataSettings, $response)
 {
     list($orderId, ) = explode(self::ORDER_SEPARATOR, $response['order_id']);
     $order = uc_order_load($orderId);
     if ($order === FALSE || uc_order_status_data($order->order_status, 'state') != 'in_checkout') {
         return t('An error has occurred during payment. Please contact us to ensure your order has submitted.');
     }
     if ($oplataSettings->merchant_id != $response['merchant_id']) {
         return t('An error has occurred during payment. Merchant data is incorrect.');
     }
     $originalResponse = $response;
     foreach ($response as $k => $v) {
         if (!in_array($k, self::$responseFields)) {
             unset($response[$k]);
         }
     }
     if (self::getSignature($response, $oplataSettings->secret_key) != $originalResponse['signature']) {
         return t('An error has occurred during payment. Signature is not valid.');
     }
     if (drupal_strtolower($originalResponse['sender_email']) !== drupal_strtolower($order->primary_email)) {
         uc_order_comment_save($order->order_id, 0, t('Customer used a different e-mail address during payment: !email', array('!email' => check_plain($originalResponse['sender_email']))), 'admin');
     }
     uc_order_comment_save($order->order_id, 0, "Order status: {$response['order_status']}", 'admin');
     return true;
 }
开发者ID:cloudipsp,项目名称:drupal,代码行数:25,代码来源:fondy.cls.php

示例2: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('taxonomy_term');
     // We want a taxonomy term reference field. It needs a vocabulary, terms,
     // a field storage and a field. First, create the vocabulary.
     $vocabulary = entity_create('taxonomy_vocabulary', array('vid' => drupal_strtolower($this->randomMachineName())));
     $vocabulary->save();
     // Second, create the field.
     $this->fieldName = strtolower($this->randomMachineName());
     entity_create('field_storage_config', array('field_name' => $this->fieldName, 'entity_type' => 'entity_test', 'type' => 'taxonomy_term_reference', 'settings' => array('allowed_values' => array('vocabulary' => $vocabulary->id()))))->save();
     entity_test_create_bundle('test_bundle');
     // Third, create the instance.
     entity_create('field_config', array('entity_type' => 'entity_test', 'field_name' => $this->fieldName, 'bundle' => 'test_bundle'))->save();
     // Create two terms and also two accounts.
     for ($i = 0; $i <= 1; $i++) {
         $term = entity_create('taxonomy_term', array('name' => $this->randomMachineName(), 'vid' => $vocabulary->id()));
         $term->save();
         $this->terms[] = $term;
         $this->accounts[] = $this->createUser();
     }
     // Create three entity_test entities, the 0th entity will point to the
     // 0th account and 0th term, the 1st and 2nd entity will point to the
     // 1st account and 1st term.
     for ($i = 0; $i <= 2; $i++) {
         $entity = entity_create('entity_test', array('type' => 'test_bundle'));
         $entity->name->value = $this->randomMachineName();
         $index = $i ? 1 : 0;
         $entity->user_id->target_id = $this->accounts[$index]->id();
         $entity->{$this->fieldName}->target_id = $this->terms[$index]->id();
         $entity->save();
         $this->entities[] = $entity;
     }
     $this->factory = \Drupal::service('entity.query');
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:35,代码来源:EntityQueryRelationshipTest.php

示例3: testEmailField

 /**
  * Tests email field.
  */
 function testEmailField()
 {
     // Create a field with settings to validate.
     $field_name = drupal_strtolower($this->randomMachineName());
     $this->fieldStorage = entity_create('field_storage_config', array('name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'email'));
     $this->fieldStorage->save();
     $this->instance = entity_create('field_instance_config', array('field_storage' => $this->fieldStorage, 'bundle' => 'entity_test'));
     $this->instance->save();
     // Create a form display for the default form mode.
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($field_name, array('type' => 'email_default', 'settings' => array('placeholder' => 'example@example.com')))->save();
     // Create a display for the full view mode.
     entity_get_display('entity_test', 'entity_test', 'full')->setComponent($field_name, array('type' => 'email_mailto'))->save();
     // Display creation form.
     $this->drupalGet('entity_test/add');
     $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget found.');
     $this->assertRaw('placeholder="example@example.com"');
     // Submit a valid email address and ensure it is accepted.
     $value = 'test@example.com';
     $edit = array('user_id' => 1, 'name' => $this->randomMachineName(), "{$field_name}[0][value]" => $value);
     $this->drupalPostForm(NULL, $edit, t('Save'));
     preg_match('|entity_test/manage/(\\d+)|', $this->url, $match);
     $id = $match[1];
     $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
     $this->assertRaw($value);
     // Verify that a mailto link is displayed.
     $entity = entity_load('entity_test', $id);
     $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
     $content = $display->build($entity);
     $this->drupalSetContent(drupal_render($content));
     $this->assertLinkByHref('mailto:test@example.com');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:34,代码来源:EmailFieldTest.php

示例4: testEntityReferenceDefaultValue

 /**
  * Tests that default values are correctly translated to UUIDs in config.
  */
 function testEntityReferenceDefaultValue()
 {
     // Create a node to be referenced.
     $referenced_node = $this->drupalCreateNode(array('type' => 'referenced_content'));
     $field_name = drupal_strtolower($this->randomMachineName());
     $field_storage = entity_create('field_storage_config', array('field_name' => $field_name, 'entity_type' => 'node', 'type' => 'entity_reference', 'settings' => array('target_type' => 'node')));
     $field_storage->save();
     $field = entity_create('field_config', array('field_storage' => $field_storage, 'bundle' => 'reference_content', 'settings' => array('handler' => 'default', 'handler_settings' => array('target_bundles' => array('referenced_content'), 'sort' => array('field' => '_none')))));
     $field->save();
     // Set created node as default_value.
     $field_edit = array('default_value_input[' . $field_name . '][0][target_id]' => $referenced_node->getTitle() . ' (' . $referenced_node->id() . ')');
     $this->drupalPostForm('admin/structure/types/manage/reference_content/fields/node.reference_content.' . $field_name, $field_edit, t('Save settings'));
     // Check that default value is selected in default value form.
     $this->drupalGet('admin/structure/types/manage/reference_content/fields/node.reference_content.' . $field_name);
     $this->assertRaw('name="default_value_input[' . $field_name . '][0][target_id]" value="' . $referenced_node->getTitle() . ' (' . $referenced_node->id() . ')', 'The default value is selected in instance settings page');
     // Check if the ID has been converted to UUID in config entity.
     $config_entity = $this->container->get('config.factory')->get('field.field.node.reference_content.' . $field_name)->get();
     $this->assertTrue(isset($config_entity['default_value'][0]['target_uuid']), 'Default value contains target_uuid property');
     $this->assertEqual($config_entity['default_value'][0]['target_uuid'], $referenced_node->uuid(), 'Content uuid and config entity uuid are the same');
     // Ensure the configuration has the expected dependency on the entity that
     // is being used a default value.
     $this->assertEqual(array($referenced_node->getConfigDependencyName()), $config_entity['dependencies']['content']);
     // Clear field definitions cache in order to avoid stale cache values.
     \Drupal::entityManager()->clearCachedFieldDefinitions();
     // Create a new node to check that UUID has been converted to numeric ID.
     $new_node = entity_create('node', array('type' => 'reference_content'));
     $this->assertEqual($new_node->get($field_name)->offsetGet(0)->target_id, $referenced_node->id());
 }
开发者ID:anyforsoft,项目名称:csua_d8,代码行数:31,代码来源:EntityReferenceFieldDefaultValueTest.php

示例5: createVocabulary

 /**
  * Returns a new vocabulary with random properties.
  */
 function createVocabulary()
 {
     // Create a vocabulary.
     $vocabulary = entity_create('taxonomy_vocabulary', array('name' => $this->randomMachineName(), 'description' => $this->randomMachineName(), 'vid' => drupal_strtolower($this->randomMachineName()), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'weight' => mt_rand(0, 10)));
     $vocabulary->save();
     return $vocabulary;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:TaxonomyTestBase.php

示例6: testTokenizer

 /**
  * Verifies that strings of CJK characters are tokenized.
  *
  * The search_simplify() function does special things with numbers, symbols,
  * and punctuation. So we only test that CJK characters that are not in these
  * character classes are tokenized properly. See PREG_CLASS_CKJ for more
  * information.
  */
 function testTokenizer()
 {
     // Set the minimum word size to 1 (to split all CJK characters) and make
     // sure CJK tokenizing is turned on.
     \Drupal::config('search.settings')->set('index.minimum_word_size', 1)->set('index.overlap_cjk', TRUE)->save();
     $this->refreshVariables();
     // Create a string of CJK characters from various character ranges in
     // the Unicode tables.
     // Beginnings of the character ranges.
     $starts = array('CJK unified' => 0x4e00, 'CJK Ext A' => 0x3400, 'CJK Compat' => 0xf900, 'Hangul Jamo' => 0x1100, 'Hangul Ext A' => 0xa960, 'Hangul Ext B' => 0xd7b0, 'Hangul Compat' => 0x3131, 'Half non-punct 1' => 0xff21, 'Half non-punct 2' => 0xff41, 'Half non-punct 3' => 0xff66, 'Hangul Syllables' => 0xac00, 'Hiragana' => 0x3040, 'Katakana' => 0x30a1, 'Katakana Ext' => 0x31f0, 'CJK Reserve 1' => 0x20000, 'CJK Reserve 2' => 0x30000, 'Bomofo' => 0x3100, 'Bomofo Ext' => 0x31a0, 'Lisu' => 0xa4d0, 'Yi' => 0xa000);
     // Ends of the character ranges.
     $ends = array('CJK unified' => 0x9fcf, 'CJK Ext A' => 0x4dbf, 'CJK Compat' => 0xfaff, 'Hangul Jamo' => 0x11ff, 'Hangul Ext A' => 0xa97f, 'Hangul Ext B' => 0xd7ff, 'Hangul Compat' => 0x318e, 'Half non-punct 1' => 0xff3a, 'Half non-punct 2' => 0xff5a, 'Half non-punct 3' => 0xffdc, 'Hangul Syllables' => 0xd7af, 'Hiragana' => 0x309f, 'Katakana' => 0x30ff, 'Katakana Ext' => 0x31ff, 'CJK Reserve 1' => 0x2fffd, 'CJK Reserve 2' => 0x3fffd, 'Bomofo' => 0x312f, 'Bomofo Ext' => 0x31b7, 'Lisu' => 0xa4fd, 'Yi' => 0xa48f);
     // Generate characters consisting of starts, midpoints, and ends.
     $chars = array();
     $charcodes = array();
     foreach ($starts as $key => $value) {
         $charcodes[] = $starts[$key];
         $chars[] = $this->code2utf($starts[$key]);
         $mid = round(0.5 * ($starts[$key] + $ends[$key]));
         $charcodes[] = $mid;
         $chars[] = $this->code2utf($mid);
         $charcodes[] = $ends[$key];
         $chars[] = $this->code2utf($ends[$key]);
     }
     // Merge into a string and tokenize.
     $string = implode('', $chars);
     $out = trim(search_simplify($string));
     $expected = drupal_strtolower(implode(' ', $chars));
     // Verify that the output matches what we expect.
     $this->assertEqual($out, $expected, 'CJK tokenizer worked on all supplied CJK characters');
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:39,代码来源:SearchTokenizerTest.php

示例7: setUp

 function setUp()
 {
     parent::setUp();
     // Configure the theme system.
     $this->installConfig(array('system', 'field'));
     $this->installEntitySchema('entity_test');
     // @todo Add helper methods for all of the following.
     $this->entity_type = 'entity_test';
     if (!isset($this->bundle)) {
         $this->bundle = $this->entity_type;
     }
     $this->field_name = drupal_strtolower($this->randomName());
     $this->field_type = 'text_long';
     $this->field_settings = array();
     $this->instance_settings = array('text_processing' => FALSE);
     $this->formatter_type = 'string';
     $this->formatter_settings = array();
     $this->fieldStorage = entity_create('field_storage_config', array('name' => $this->field_name, 'entity_type' => $this->entity_type, 'type' => $this->field_type, 'settings' => $this->field_settings));
     $this->fieldStorage->save();
     $this->instance = entity_create('field_instance_config', array('field_storage' => $this->fieldStorage, 'bundle' => $this->bundle, 'label' => $this->randomName(), 'settings' => $this->instance_settings));
     $this->instance->save();
     $this->view_mode = 'default';
     $this->display = entity_get_display($this->entity_type, $this->bundle, $this->view_mode)->setComponent($this->field_name, array('type' => $this->formatter_type, 'settings' => $this->formatter_settings));
     $this->display->save();
     $this->langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:26,代码来源:TextPlainUnitTest.php

示例8: testContactStorage

 /**
  * Tests configuration options and the site-wide contact form.
  */
 public function testContactStorage()
 {
     // Create and login administrative user.
     $admin_user = $this->drupalCreateUser(array('access site-wide contact form', 'administer contact forms', 'administer users', 'administer account settings', 'administer contact_message fields'));
     $this->drupalLogin($admin_user);
     // Create first valid category.
     $mail = 'simpletest@example.com';
     $this->addCategory($id = drupal_strtolower($this->randomName(16)), $label = $this->randomName(16), implode(',', array($mail)), '', TRUE);
     $this->assertRaw(t('Category %label has been added.', array('%label' => $label)));
     // Ensure that anonymous can submit site-wide contact form.
     user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form'));
     $this->drupalLogout();
     $this->drupalGet('contact');
     $this->assertText(t('Your email address'));
     $this->assertNoText(t('Category'));
     $this->submitContact($name = $this->randomName(16), $mail, $subject = $this->randomName(16), $id, $message = $this->randomName(64));
     $this->assertText(t('Your message has been sent.'));
     $messages = Message::loadMultiple();
     /** @var \Drupal\contact\Entity\Message $message */
     $message = reset($messages);
     $this->assertEqual($message->getCategory()->id(), $id);
     $this->assertEqual($message->getSenderName(), $name);
     $this->assertEqual($message->getSubject(), $subject);
     $this->assertEqual($message->getSenderMail(), $mail);
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:28,代码来源:ContactStorageTest.php

示例9: testBooleanField

 /**
  * Tests boolean field.
  */
 function testBooleanField()
 {
     $on = $this->randomMachineName();
     $off = $this->randomMachineName();
     $label = $this->randomMachineName();
     // Create a field with settings to validate.
     $field_name = drupal_strtolower($this->randomMachineName());
     $this->field_storage = FieldStorageConfig::create(array('field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'boolean', 'settings' => array('on_label' => $on, 'off_label' => $off)));
     $this->field_storage->save();
     $this->field = FieldConfig::create(array('field_name' => $field_name, 'entity_type' => 'entity_test', 'bundle' => 'entity_test', 'label' => $label, 'required' => TRUE));
     $this->field->save();
     // Create a form display for the default form mode.
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($field_name, array('type' => 'boolean_checkbox'))->save();
     // Create a display for the full view mode.
     entity_get_display('entity_test', 'entity_test', 'full')->setComponent($field_name, array('type' => 'boolean'))->save();
     // Display creation form.
     $this->drupalGet('entity_test/add');
     $this->assertFieldByName("{$field_name}[value]", '', 'Widget found.');
     $this->assertRaw($on);
     // Submit and ensure it is accepted.
     $edit = array("{$field_name}[value]" => 1);
     $this->drupalPostForm(NULL, $edit, t('Save'));
     preg_match('|entity_test/manage/(\\d+)|', $this->url, $match);
     $id = $match[1];
     $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
     // Verify that boolean value is displayed.
     $entity = entity_load('entity_test', $id);
     $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
     $content = $display->build($entity);
     $this->drupalSetContent(drupal_render($content));
     $this->assertRaw('<div class="field-item">' . $on . '</div>');
     // Test the display_label option.
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($field_name, array('type' => 'boolean_checkbox', 'settings' => array('display_label' => TRUE)))->save();
     $this->drupalGet('entity_test/add');
     $this->assertFieldByName("{$field_name}[value]", '', 'Widget found.');
     $this->assertNoRaw($on);
     $this->assertText($this->field->label());
     // Go to the form display page and check if the default settings works as
     // expected.
     $fieldEditUrl = 'entity_test/structure/entity_test/form-display';
     $this->drupalGet($fieldEditUrl);
     // Click on the widget settings button to open the widget settings form.
     $this->drupalPostAjaxForm(NULL, array(), $field_name . "_settings_edit");
     $this->assertText('Use field label instead of the "On label" as label', t('Display setting checkbox available.'));
     // Enable setting.
     $edit = array('fields[' . $field_name . '][settings_edit_form][settings][display_label]' => 1);
     $this->drupalPostAjaxForm(NULL, $edit, $field_name . "_plugin_settings_update");
     $this->drupalPostForm(NULL, NULL, 'Save');
     // Go again to the form display page and check if the setting
     // is stored and has the expected effect.
     $this->drupalGet($fieldEditUrl);
     $this->assertText('Use field label: Yes', 'Checking the display settings checkbox updated the value.');
     $this->drupalPostAjaxForm(NULL, array(), $field_name . "_settings_edit");
     $this->assertText('Use field label instead of the "On label" as label', t('Display setting checkbox is available'));
     $this->assertFieldByXPath('*//input[@id="edit-fields-' . $field_name . '-settings-edit-form-settings-display-label" and @value="1"]', TRUE, t('Display label changes label of the checkbox'));
     // Test the boolean field settings.
     $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.' . $field_name . '/storage');
     $this->assertFieldById('edit-field-storage-settings-on-label', $on);
     $this->assertFieldById('edit-field-storage-settings-off-label', $off);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:63,代码来源:BooleanFieldTest.php

示例10: testContactStorage

 /**
  * Tests configuration options and the site-wide contact form.
  */
 public function testContactStorage()
 {
     // Create and login administrative user.
     $admin_user = $this->drupalCreateUser(array('access site-wide contact form', 'administer contact forms', 'administer users', 'administer account settings', 'administer contact_message fields'));
     $this->drupalLogin($admin_user);
     // Create first valid contact form.
     $mail = 'simpletest@example.com';
     $this->addContactForm($id = drupal_strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($mail)), '', TRUE, ['send_a_pony' => 1]);
     $this->assertRaw(t('Contact form %label has been added.', array('%label' => $label)));
     // Ensure that anonymous can submit site-wide contact form.
     user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form'));
     $this->drupalLogout();
     $this->drupalGet('contact');
     $this->assertText(t('Your email address'));
     $this->assertNoText(t('Form'));
     $this->submitContact($name = $this->randomMachineName(16), $mail, $subject = $this->randomMachineName(16), $id, $message = $this->randomMachineName(64));
     $this->assertText(t('Your message has been sent.'));
     $messages = Message::loadMultiple();
     /** @var \Drupal\contact\Entity\Message $message */
     $message = reset($messages);
     $this->assertEqual($message->getContactForm()->id(), $id);
     $this->assertTrue($message->getContactForm()->getThirdPartySetting('contact_storage_test', 'send_a_pony', FALSE));
     $this->assertEqual($message->getSenderName(), $name);
     $this->assertEqual($message->getSubject(), $subject);
     $this->assertEqual($message->getSenderMail(), $mail);
     $config = \Drupal::config("contact.form.{$id}");
     $this->assertEqual($config->get('id'), $id);
     $this->assertConfigSchema(\Drupal::service('config.typed'), $config->getName(), $config->get());
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:32,代码来源:ContactStorageTest.php

示例11: testFieldUI

  /**
   * Tests that link field UI functionality does not generate warnings.
   */
  function testFieldUI() {
    // Add a content type.
    $type = $this->drupalCreateContentType();
    $type_path = 'admin/structure/types/manage/' . $type->type;

    // Add a link field to the newly-created type.
    $label = $this->randomName();
    $field_name = drupal_strtolower($label);
    $edit = array(
      'fields[_add_new_field][label]' => $label,
      'fields[_add_new_field][field_name]' => $field_name,
      'fields[_add_new_field][type]' => 'link',
      'fields[_add_new_field][widget_type]' => 'link_default',
    );
    $this->drupalPost("$type_path/fields", $edit, t('Save'));
    // Proceed to the Edit (field instance settings) page.
    $this->drupalPost(NULL, array(), t('Save field settings'));
    // Proceed to the Manage fields overview page.
    $this->drupalPost(NULL, array(), t('Save settings'));

    // Load the formatter page to check that the settings summary does not
    // generate warnings.
    // @todo Mess with the formatter settings a bit here.
    $this->drupalGet("$type_path/display");
    $this->assertText(t('Link text trimmed to @limit characters', array('@limit' => 80)));
  }
开发者ID:AshishNaik021,项目名称:iimisac-d8,代码行数:29,代码来源:LinkFieldUITest.php

示例12: boldy_preprocess_page

/**
 * Override or insert PHPTemplate variables into the templates.
 */
function boldy_preprocess_page(&$vars)
{
    $vars['tabs2'] = menu_secondary_local_tasks();
    // Hook into color.module
    if (module_exists('color')) {
        _color_page_alter($vars);
    }
    // Classes for body element. Allows advanced theming based on context
    // (home page, node of certain type, etc.)
    $classes = explode(' ', $vars['body_classes']);
    // Remove the mostly useless page-ARG0 class.
    if ($index = array_search(preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-_]+!s', '', 'page-' . drupal_strtolower(arg(0))), $classes)) {
        unset($classes[$index]);
    }
    if (!$vars['is_front']) {
        // Add unique class for each page.
        $path = drupal_get_path_alias($_GET['q']);
        $classes[] = boldy_id_safe('page-' . $path);
        // Add unique class for each website section.
        list($section, ) = explode('/', $path, 2);
        if (arg(0) == 'node') {
            if (arg(1) == 'add') {
                $section = 'node-add';
            } elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) {
                $section = 'node-' . arg(2);
            }
        }
        $classes[] = boldy_id_safe('section-' . $section);
    }
    $vars['body_classes_array'] = $classes;
    $vars['body_classes'] = implode(' ', $classes);
    // Concatenate with spaces.
}
开发者ID:rachellawson,项目名称:drupalsciencecamp,代码行数:36,代码来源:template.php

示例13: flickr_context_tags_settings

function flickr_context_tags_settings()
{
    $form = array();
    $mt_ns = variable_get('flickr_context_tags_mech_namespace', '');
    //Make a qualified guess
    if (empty($mt_ns)) {
        $matches = array();
        $site_name = variable_get('site_name', '');
        if (preg_match('/^\\s*([^\\s\\.]+)/', $site_name, $matches)) {
            $mt_ns = drupal_strtolower($matches[1]);
        }
    }
    $form['flickr_context_tags_mech_namespace'] = array('#type' => 'textfield', '#title' => t('Machine-tag namespace'), '#default_value' => $mt_ns);
    $form['flickr_context_tags_userid'] = array('#type' => 'textfield', '#title' => t('Flickr id'), '#description' => t('Can be used to get photos from a specified flickr user'), '#default_value' => variable_get('flickr_context_tags_userid', ''));
    $form['flickr_context_tags_default_place_id'] = array('#type' => 'textfield', '#title' => t('Default place id'), '#description' => t('The default place id can be used to keep the flickr pictures relevant'), '#default_value' => variable_get('flickr_context_tags_default_place_id', ''));
    $form['flickr_context_tags_force_default_place_id'] = array('#type' => 'checkbox', '#title' => t('Always use the default place id'), '#default_value' => variable_get('flickr_context_tags_force_default_place_id', FALSE));
    $sizes = array('s' => t('Square'), 't' => t('Thumbnail'), 'm' => t('Small'), '-' => t('Medium'), 'b' => t('Large'), 'o' => t('Orginal'));
    $form['flickr_context_tags_size'] = array('#type' => 'select', '#title' => t('Select the size you want your photos in'), '#default_value' => variable_get('flickr_context_tags_size', 'm'), '#options' => $sizes);
    // Tag configuration textarea
    $paths = variable_get('flickr_context_tags_contexts', array());
    $form['flickr_context_tags_contexts'] = array('#type' => 'textarea', '#title' => t('Context tags for paths'), '#default_value' => flickr_context_tags_pack_contexts($paths), '#description' => t('Enter the path expression followed by a list of comma-separated tags'));
    // Piggyback on the system settings form for buttons and so on
    $form = system_settings_form($form);
    // ...but replace the #submit function
    $form['#submit'] = array('flickr_context_tags_settings_submit');
    return $form;
}
开发者ID:hugowetterberg,项目名称:flickr_context_tags,代码行数:27,代码来源:flickr_context_tags_admin.inc.php

示例14: testVocabularyDefaultLanguageForTerms

 /**
  * Tests term language settings for vocabulary terms are saved and updated.
  */
 function testVocabularyDefaultLanguageForTerms()
 {
     // Add a new vocabulary and check that the default language settings are for
     // the terms are saved.
     $edit = array('name' => $this->randomMachineName(), 'vid' => drupal_strtolower($this->randomMachineName()), 'default_language[langcode]' => 'bb', 'default_language[language_show]' => TRUE);
     $vid = $edit['vid'];
     $this->drupalPostForm('admin/structure/taxonomy/add', $edit, t('Save'));
     // Check that the vocabulary was actually created.
     $this->drupalGet('admin/structure/taxonomy/manage/' . $edit['vid']);
     $this->assertResponse(200, 'The vocabulary has been created.');
     // Check that the language settings were saved.
     $language_settings = language_get_default_configuration('taxonomy_term', $edit['vid']);
     $this->assertEqual($language_settings['langcode'], 'bb', 'The langcode was saved.');
     $this->assertTrue($language_settings['language_show'], 'The visibility setting was saved.');
     // Check that the correct options are selected in the interface.
     $this->assertOptionSelected('edit-default-language-langcode', 'bb', 'The correct default language for the terms of this vocabulary is selected.');
     $this->assertFieldChecked('edit-default-language-language-show', 'Show language selection option is checked.');
     // Edit the vocabulary and check that the new settings are updated.
     $edit = array('default_language[langcode]' => 'aa', 'default_language[language_show]' => FALSE);
     $this->drupalPostForm('admin/structure/taxonomy/manage/' . $vid, $edit, t('Save'));
     // And check again the settings and also the interface.
     $language_settings = language_get_default_configuration('taxonomy_term', $vid);
     $this->assertEqual($language_settings['langcode'], 'aa', 'The langcode was saved.');
     $this->assertFalse($language_settings['language_show'], 'The visibility setting was saved.');
     $this->drupalGet('admin/structure/taxonomy/manage/' . $vid);
     $this->assertOptionSelected('edit-default-language-langcode', 'aa', 'The correct default language for the terms of this vocabulary is selected.');
     $this->assertNoFieldChecked('edit-default-language-language-show', 'Show language selection option is not checked.');
     // Check that language settings are changed after editing vocabulary.
     $edit = array('name' => $this->randomMachineName(), 'default_language[langcode]' => 'authors_default', 'default_language[language_show]' => FALSE);
     $this->drupalPostForm('admin/structure/taxonomy/manage/' . $vid, $edit, t('Save'));
     // Check that we have the new settings.
     $new_settings = language_get_default_configuration('taxonomy_term', $vid);
     $this->assertEqual($new_settings['langcode'], 'authors_default', 'The langcode was saved.');
     $this->assertFalse($new_settings['language_show'], 'The new visibility setting was saved.');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:38,代码来源:VocabularyLanguageTest.php

示例15: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->languageManager = $this->container->get('language_manager');
     $this->installEntitySchema('entity_test_rev');
     $this->installEntitySchema('entity_test_mul');
     $this->installEntitySchema('entity_test_mulrev');
     $this->installConfig(array('language'));
     // Create the test field.
     entity_test_install();
     // Enable translations for the test entity type.
     $this->state->set('entity_test.translation', TRUE);
     // Create a translatable test field.
     $this->field_name = drupal_strtolower($this->randomMachineName() . '_field_name');
     // Create an untranslatable test field.
     $this->untranslatable_field_name = drupal_strtolower($this->randomMachineName() . '_field_name');
     // Create field fields in all entity variations.
     foreach (entity_test_entity_types() as $entity_type) {
         entity_create('field_storage_config', array('field_name' => $this->field_name, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4))->save();
         entity_create('field_config', array('field_name' => $this->field_name, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'translatable' => TRUE))->save();
         $this->field[$entity_type] = entity_load('field_config', $entity_type . '.' . $entity_type . '.' . $this->field_name);
         entity_create('field_storage_config', array('field_name' => $this->untranslatable_field_name, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4))->save();
         entity_create('field_config', array('field_name' => $this->untranslatable_field_name, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'translatable' => FALSE))->save();
     }
     // Create the default languages.
     $this->installConfig(array('language'));
     // Create test languages.
     $this->langcodes = array();
     for ($i = 0; $i < 3; ++$i) {
         $language = ConfigurableLanguage::create(array('id' => 'l' . $i, 'label' => $this->randomString(), 'weight' => $i));
         $this->langcodes[$i] = $language->getId();
         $language->save();
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:34,代码来源:EntityLanguageTestBase.php


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