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


PHP filter_default_format函数代码示例

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


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

示例1: testNodeRevisionDoubleEscapeFix

 /**
  * Checks HTML double escaping of revision logs.
  */
 public function testNodeRevisionDoubleEscapeFix()
 {
     $this->drupalLogin($this->editor);
     $nodes = [];
     // Create the node.
     $node = $this->drupalCreateNode();
     $username = ['#theme' => 'username', '#account' => $this->editor];
     $editor = \Drupal::service('renderer')->renderPlain($username);
     // Get original node.
     $nodes[] = clone $node;
     // Create revision with a random title and body and update variables.
     $node->title = $this->randomMachineName();
     $node->body = ['value' => $this->randomMachineName(32), 'format' => filter_default_format()];
     $node->setNewRevision();
     $revision_log = 'Revision <em>message</em> with markup.';
     $node->revision_log->value = $revision_log;
     $node->save();
     // Make sure we get revision information.
     $node = Node::load($node->id());
     $nodes[] = clone $node;
     $this->drupalGet('node/' . $node->id() . '/revisions');
     // Assert the old revision message.
     $date = format_date($nodes[0]->revision_timestamp->value, 'short');
     $url = new Url('entity.node.revision', ['node' => $nodes[0]->id(), 'node_revision' => $nodes[0]->getRevisionId()]);
     $old_revision_message = t('!date by !username', ['!date' => \Drupal::l($date, $url), '!username' => $editor]);
     $this->assertRaw($old_revision_message);
     // Assert the current revision message.
     $date = format_date($nodes[1]->revision_timestamp->value, 'short');
     $current_revision_message = t('!date by !username', ['!date' => $nodes[1]->link($date), '!username' => $editor]);
     $current_revision_message .= '<p class="revision-log">' . $revision_log . '</p>';
     $this->assertRaw($current_revision_message);
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:35,代码来源:NodeRevisionsUiTest.php

示例2: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     ConfigurableLanguage::createFromLangcode('it')->save();
     /** @var \Drupal\content_translation\ContentTranslationManagerInterface $manager */
     $manager = \Drupal::service('content_translation.manager');
     $manager->setEnabled('node', 'article', TRUE);
     // Create and log in user.
     $web_user = $this->drupalCreateUser(array('view page revisions', 'revert page revisions', 'delete page revisions', 'edit any page content', 'delete any page content', 'translate any entity'));
     $this->drupalLogin($web_user);
     // Create initial node.
     $node = $this->drupalCreateNode();
     $settings = get_object_vars($node);
     $settings['revision'] = 1;
     $settings['isDefaultRevision'] = TRUE;
     $nodes = array();
     $logs = array();
     // Get original node.
     $nodes[] = clone $node;
     // Create three revisions.
     $revision_count = 3;
     for ($i = 0; $i < $revision_count; $i++) {
         $logs[] = $node->revision_log = $this->randomMachineName(32);
         // Create revision with a random title and body and update variables.
         $node->title = $this->randomMachineName();
         $node->body = array('value' => $this->randomMachineName(32), 'format' => filter_default_format());
         $node->setNewRevision();
         $node->save();
         $node = Node::load($node->id());
         // Make sure we get revision information.
         $nodes[] = clone $node;
     }
     $this->nodes = $nodes;
     $this->revisionLogs = $logs;
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:38,代码来源:NodeRevisionsTest.php

示例3: setUp

 function setUp()
 {
     parent::setUp();
     // Create and login user.
     $test_user = $this->drupalCreateUser(array('access content', 'search content', 'use advanced search', 'administer nodes', 'administer languages', 'access administration pages', 'administer site configuration'));
     $this->drupalLogin($test_user);
     // Add a new language.
     $language = new Language(array('id' => 'es', 'name' => 'Spanish'));
     language_save($language);
     // Make the body field translatable. The title is already translatable by
     // definition. The parent class has already created the article and page
     // content types.
     $field_storage = FieldStorageConfig::loadByName('node', 'body');
     $field_storage->translatable = TRUE;
     $field_storage->save();
     // Create a few page nodes with multilingual body values.
     $default_format = filter_default_format();
     $nodes = array(array('title' => 'First node en', 'type' => 'page', 'body' => array(array('value' => $this->randomMachineName(32), 'format' => $default_format)), 'langcode' => 'en'), array('title' => 'Second node this is the Spanish title', 'type' => 'page', 'body' => array(array('value' => $this->randomMachineName(32), 'format' => $default_format)), 'langcode' => 'es'), array('title' => 'Third node en', 'type' => 'page', 'body' => array(array('value' => $this->randomMachineName(32), 'format' => $default_format)), 'langcode' => 'en'));
     $this->searchable_nodes = array();
     foreach ($nodes as $setting) {
         $this->searchable_nodes[] = $this->drupalCreateNode($setting);
     }
     // Add English translation to the second node.
     $translation = $this->searchable_nodes[1]->addTranslation('en', array('title' => 'Second node en'));
     $translation->body->value = $this->randomMachineName(32);
     $this->searchable_nodes[1]->save();
     // Add Spanish translation to the third node.
     $translation = $this->searchable_nodes[2]->addTranslation('es', array('title' => 'Third node es'));
     $translation->body->value = $this->randomMachineName(32);
     $this->searchable_nodes[2]->save();
     // Update the index and then run the shutdown method.
     $plugin = $this->container->get('plugin.manager.search')->createInstance('node_search');
     $plugin->updateIndex();
     search_update_totals();
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:35,代码来源:SearchLanguageTest.php

示例4: setUp

 protected function setUp()
 {
     parent::setUp();
     // Create and log in user.
     $web_user = $this->drupalCreateUser(array('view page revisions', 'revert page revisions', 'delete page revisions', 'edit any page content', 'delete any page content'));
     $this->drupalLogin($web_user);
     // Create initial node.
     $node = $this->drupalCreateNode();
     $settings = get_object_vars($node);
     $settings['revision'] = 1;
     $settings['isDefaultRevision'] = TRUE;
     $nodes = array();
     $logs = array();
     // Get original node.
     $nodes[] = clone $node;
     // Create three revisions.
     $revision_count = 3;
     for ($i = 0; $i < $revision_count; $i++) {
         $logs[] = $node->revision_log = $this->randomMachineName(32);
         // Create revision with a random title and body and update variables.
         $node->title = $this->randomMachineName();
         $node->body = array('value' => $this->randomMachineName(32), 'format' => filter_default_format());
         $node->setNewRevision();
         $node->save();
         $node = node_load($node->id());
         // Make sure we get revision information.
         $nodes[] = clone $node;
     }
     $this->nodes = $nodes;
     $this->revisionLogs = $logs;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:31,代码来源:NodeRevisionsTest.php

示例5: setUp

 protected function setUp()
 {
     parent::setUp();
     // Create and log in user.
     $test_user = $this->drupalCreateUser(['access content', 'search content', 'use advanced search', 'administer nodes', 'administer languages', 'access administration pages', 'administer site configuration']);
     $this->drupalLogin($test_user);
     // Add a new language.
     ConfigurableLanguage::createFromLangcode('es')->save();
     // Set up times to be applied to the English and Spanish translations of the
     // node create time, so that they are filtered in/out in the
     // search_date_query_alter test module.
     $created_time_en = new \DateTime('February 10 2016 10PM');
     $created_time_es = new \DateTime('March 19 2016 10PM');
     $default_format = filter_default_format();
     $node = $this->drupalCreateNode(['title' => 'Node EN', 'type' => 'page', 'body' => ['value' => $this->randomMachineName(32), 'format' => $default_format], 'langcode' => 'en', 'created' => $created_time_en->format('U')]);
     // Add Spanish translation to the node.
     $translation = $node->addTranslation('es', ['title' => 'Node ES']);
     $translation->body->value = $this->randomMachineName(32);
     $translation->created->value = $created_time_es->format('U');
     $node->save();
     // Update the index.
     $plugin = $this->container->get('plugin.manager.search')->createInstance('node_search');
     $plugin->updateIndex();
     search_update_totals();
 }
开发者ID:systemick3,项目名称:systemick.co.uk,代码行数:25,代码来源:SearchDateIntervalTest.php

示例6: createNode

 /**
  * Creates a node based on default settings.
  *
  * @param array $settings
  *   (optional) An associative array of settings for the node, as used in
  *   entity_create(). Override the defaults by specifying the key and value
  *   in the array, for example:
  *   @code
  *     $this->drupalCreateNode(array(
  *       'title' => t('Hello, world!'),
  *       'type' => 'article',
  *     ));
  *   @endcode
  *   The following defaults are provided:
  *   - body: Random string using the default filter format:
  *     @code
  *       $settings['body'][0] = array(
  *         'value' => $this->randomMachineName(32),
  *         'format' => filter_default_format(),
  *       );
  *     @endcode
  *   - title: Random string.
  *   - type: 'page'.
  *   - uid: The currently logged in user, or anonymous.
  *
  * @return \Drupal\node\NodeInterface
  *   The created node entity.
  */
 protected function createNode(array $settings = array())
 {
     // Populate defaults array.
     $settings += array('body' => array(array('value' => $this->randomMachineName(32), 'format' => filter_default_format())), 'title' => $this->randomMachineName(8), 'type' => 'page', 'uid' => \Drupal::currentUser()->id());
     $node = Node::create($settings);
     $node->save();
     return $node;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:36,代码来源:NodeCreationTrait.php

示例7: render

 /**
  * {@inheritdoc}
  */
 public function render($empty = FALSE)
 {
     $format = isset($this->options['format']) ? $this->options['format'] : filter_default_format();
     if (!$empty || !empty($this->options['empty'])) {
         return array('#type' => 'processed_text', '#text' => $this->tokenizeValue($this->options['content']), '#format' => $format);
     }
     return array();
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:11,代码来源:Text.php

示例8: platon_form_system_theme_settings_alter

/**
 * Implements hook_form_FORM_ID_alter() for system_theme_settings().
 */
function platon_form_system_theme_settings_alter(&$form, $form_state)
{
    $path = drupal_get_path('theme', 'platon');
    // If using a different Admin theme, we get a Fatal Error. Include the
    // template.php file.
    require_once DRUPAL_ROOT . "/{$path}/template.php";
    $form['#attached'] = array('js' => array('//cdnjs.cloudflare.com/ajax/libs/ace/1.1.01/ace.js' => array('type' => 'file', 'cache' => FALSE), "{$path}/js/platon.theme-settings.js" => array('type' => 'file', 'cache' => FALSE)));
    // Deactivate irrelevant settings.
    foreach (array('toggle_name', 'toggle_slogan', 'toggle_favicon', 'toggle_main_menu', 'toggle_secondary_menu') as $option) {
        $form['theme_settings'][$option]['#access'] = FALSE;
    }
    if (module_exists('color')) {
        // Add some descriptions to clarify what each color is used for.
        foreach (array('white' => t("e.g. main menu active menu link background"), 'very_light_gray' => t("e.g. body background color"), 'light_gray' => t('e.g content background color'), 'medium_gray' => t('e.g. title background color, table background color'), 'dark_gray' => t('e.g. forum tools background'), 'light_blue' => t('e.g. link hover color, tabs background, fieldset titles'), 'dark_blue' => t('e.g. link color, tabs active/hover background color'), 'deep_blue' => t('e.g. header background color, footer background color'), 'leaf_green' => t('e.g. form submit buttons, local actions'), 'blood_red' => t('e.g. form delete buttons')) as $color => $description) {
            $form['color']['palette'][$color]['#description'] = $description;
        }
        // Hide the base and link ones. They're just there to prevent Notices.
        $form['color']['palette']['base']['#type'] = 'hidden';
        $form['color']['palette']['link']['#type'] = 'hidden';
        // Make color section collapsible.
        $form['color']['#collapsible'] = TRUE;
        $form['color']['#collapsed'] = TRUE;
        if (isset($form['#submit']) && !in_array('platon_form_system_theme_settings_alter_color_submit', $form['#submit'])) {
            $form['#submit'][] = 'platon_form_system_theme_settings_alter_color_submit';
        }
    }
    // Header image settings.
    $form['platon_header_settings'] = array('#type' => 'fieldset', '#title' => t("Header background"));
    $form['platon_header_settings']['platon_use_header_background'] = array('#type' => 'checkbox', '#title' => t("Use another image for the header background"), '#description' => t("Check here if you want the theme to use a custom image for the header background."), '#default_value' => theme_get_setting('platon_use_header_background'));
    $form['platon_header_settings']['platon_header_image_path'] = array('#type' => 'textfield', '#title' => t("The path to the header background image."), '#description' => t("The path to the image file you would like to use as your custom header background (relative to sites/default/files). The suggested size for the header background is 3000x134."), '#default_value' => theme_get_setting('platon_header_image_path'), '#states' => array('invisible' => array('input[name="platon_use_header_background"]' => array('checked' => FALSE))));
    $form['platon_header_settings']['platon_header_image_upload'] = array('#type' => 'file', '#title' => t("Upload an image"), '#description' => t("If you don't have direct file access to the server, use this field to upload your header background image."), '#states' => array('invisible' => array('input[name="platon_use_header_background"]' => array('checked' => FALSE))));
    // Home page settings.
    $form['platon_home_page_settings'] = array('#type' => 'fieldset', '#title' => t("Homepage settings"));
    $form['platon_home_page_settings']['platon_use_home_page_markup'] = array('#type' => 'checkbox', '#title' => t("Use a different homepage for anonymous users."), '#description' => t("Check here if you want the theme to use a custom page for users that are not logged in."), '#default_value' => theme_get_setting('platon_use_home_page_markup'));
    $settings = theme_get_setting('platon_home_page_markup');
    $form['platon_home_page_settings']['platon_home_page_markup_wrapper'] = array('#type' => 'fieldset', '#states' => array('invisible' => array('input[name="platon_use_home_page_markup"]' => array('checked' => FALSE))), 'platon_home_page_markup' => array('#type' => 'text_format', '#base_type' => 'textarea', '#title' => t("Home page content"), '#description' => t("Set the content for the home page. This will be used for users that are not logged in."), '#format' => !empty($settings['format']) ? $settings['format'] : filter_default_format(), '#default_value' => !empty($settings['value']) ? $settings['value'] : ''));
    $form['platon_home_page_settings']['platon_use_home_page_background'] = array('#type' => 'checkbox', '#title' => t("Use an image for the home page background"), '#description' => t("Check here if you want the theme to use a custom image for the homepage background."), '#default_value' => theme_get_setting('platon_use_home_page_background'));
    $form['platon_home_page_settings']['platon_home_page_image_path'] = array('#type' => 'textfield', '#title' => t("The path to the home page background image."), '#description' => t("The path to the image file you would like to use as your custom home page background (relative to sites/default/files)."), '#default_value' => theme_get_setting('platon_home_page_image_path'), '#states' => array('invisible' => array('input[name="platon_use_home_page_background"]' => array('checked' => FALSE))));
    $form['platon_home_page_settings']['platon_home_page_image_upload'] = array('#type' => 'file', '#title' => t("Upload an image"), '#description' => t("If you don't have direct file access to the server, use this field to upload your background image."), '#states' => array('invisible' => array('input[name="platon_use_home_page_background"]' => array('checked' => FALSE))));
    // Main menu settings.
    if (module_exists('menu')) {
        $form['platon_menu_settings'] = array('#type' => 'fieldset', '#title' => t("Menu settings"));
        $form['platon_menu_settings']['platon_menu_source'] = array('#type' => 'select', '#title' => t("Main menu source"), '#options' => array(0 => t("None")) + menu_get_menus(), '#description' => t("The menu source to use for the tile navigation. If 'none', Platon will use a default list of tiles."), '#default_value' => theme_get_setting('platon_menu_source'));
        $form['platon_menu_settings']['platon_menu_show_for_anonymous'] = array('#type' => 'checkbox', '#title' => t("Show menu for anonymous users"), '#description' => t("Show the main menu for users that are not logged in. Only links that users have access to will show up."), '#default_value' => theme_get_setting('platon_menu_show_for_anonymous'));
    }
    // CSS overrides.
    $form['platon_css_settings'] = array('#type' => 'fieldset', '#title' => t("CSS overrides"), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $css_content = _platon_get_css_override_file_content();
    $form['platon_css_settings']['platon_css_override_content'] = array('#type' => 'textarea', '#title' => t("CSS overrides"), '#description' => t("You can write CSS rules here. They will be stored in a CSS file in your public files directory. Change it's content to alter the display of your site."), '#default_value' => $css_content);
    $form['platon_css_settings']['platon_css_override_fid'] = array('#type' => 'value', '#value' => _platon_get_css_override_file());
    if (isset($form['#validate']) && !in_array('platon_form_system_theme_settings_alter_validate', $form['#validate'])) {
        $form['#validate'][] = 'platon_form_system_theme_settings_alter_validate';
    }
    if (isset($form['#submit']) && !in_array('platon_form_system_theme_settings_alter_submit', $form['#submit'])) {
        array_unshift($form['#submit'], 'platon_form_system_theme_settings_alter_submit');
    }
    $form['platon_group_style'] = array('#type' => 'checkbox', '#title' => t("Platon group style"), '#description' => t("Check here if you want the new group style, left block with lessons"), '#default_value' => variable_get('platon_group_style', 1));
}
开发者ID:sirusdas,项目名称:opigno,代码行数:61,代码来源:theme-settings.php

示例9: createNodeRevision

 /**
  * Creates a new revision for a given node.
  *
  * @param \Drupal\node\NodeInterface $node
  *   A node object.
  *
  * @return \Drupal\node\NodeInterface
  *   A node object with up to date revision information.
  */
 protected function createNodeRevision(NodeInterface $node)
 {
     // Create revision with a random title and body and update variables.
     $node->title = $this->randomMachineName();
     $node->body = array('value' => $this->randomMachineName(32), 'format' => filter_default_format());
     $node->setNewRevision();
     $node->save();
     return $node;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:18,代码来源:NodeRevisionsAllTest.php

示例10: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->drupalCreateContentType(array('type' => 'article'));
     // Create two nodes.
     for ($i = 0; $i < 2; $i++) {
         $this->nodes[] = $this->drupalCreateNode(array('type' => 'article', 'body' => array(array('value' => $this->randomMachineName(42), 'format' => filter_default_format(), 'summary' => $this->randomMachineName()))));
     }
 }
开发者ID:DrupalCamp-NYC,项目名称:dcnyc16,代码行数:9,代码来源:PathPluginTest.php

示例11: edit_form

  /**
   * @see ctools_export_ui::edit_form()
   */
  function edit_form(&$form, &$form_state) {
    parent::edit_form($form, $form_state);
    $form['#attached']['js'] = array(
      drupal_get_path('module', 'uc_custom_payment') . '/plugins/export_ui/uc_custom_payment_ui.js',
    );
    $form['info']['admin_title']['#title'] = t('Name');
    $form['info']['admin_title']['#required'] = TRUE;
    $form['info']['admin_title']['#description'] = t('The name of this payment method as it will appear in administrative lists');
    $form['info']['name']['#machine_name']['exists'] = 'uc_custom_payment_name_exists';
    $form['title'] = array(
      '#type' => 'textfield',
      '#title' => t('Title'),
      '#default_value' => empty($form_state['item']->title) ? '' : $form_state['item']->title,
      '#description' => t('The title of this payment method as it will appear to the customer.'),
      '#required' => TRUE,
    );
    $form['instructions'] = array(
      '#type' => 'text_format',
      '#title' => t('Instructions'),
      '#default_value' => empty($form_state['item']->instructions) ? '' : $form_state['item']->instructions['value'],
      '#format' => empty($form_state['item']->instructions) ? filter_default_format() : $form_state['item']->instructions['format'],
      '#description' => t('The instructions for this payment method which will appear when the method is selected.'),
    );
    if (module_exists('token')) {
      $form['instructions']['#description'] .= ' ' . t('You may use any of the following replacement patterns.');
      $form['instructions']['#suffix'] = theme('token_tree', array('token_types' => array('uc_order')));
    }

    $default = '';
    if (!empty($form_state['item']->data['service_charge'])) {
      $default = $form_state['item']->data['service_charge'];
      if ($form_state['item']->data['service_charge_type'] === 'percentage') {
        $default .= '%';
      }
    }
    $form['service_charge'] = array(
      '#type' => 'textfield',
      '#title' => t('Service Charge'),
      '#field_prefix' => variable_get('uc_sign_after_amount', FALSE) ? '' : variable_get('uc_currency_sign', '$'),
      '#field_suffix' => variable_get('uc_sign_after_amount', FALSE) ? variable_get('uc_currency_sign', '$') : '',
      '#default_value' => $default,
      '#description' => t('The service charge to be applied to the order when this payment method is selected.
        May be an absolute price or percent of order total (e.g. enter "15%"). Leave blank for no service charge.'),
    );
    $form['service_charge_title'] = array(
      '#type' => 'textfield',
      '#title' => t('Service Charge Title'),
      '#default_value' => empty($form_state['item']->data['service_charge_title']) ? t('Service charge') : $form_state['item']->data['service_charge_title'],
      '#description' => t('The line item title to use for the service charge.'),
      '#states' => array(
        'visible' => array(
          'input[name="service_charge"]' => array('filled' => TRUE),
        ),
      ),
    );
  }
开发者ID:HamzaBendidane,项目名称:prel,代码行数:59,代码来源:uc_custom_payment_ui.class.php

示例12: testFeedFieldOutput

 /**
  * Tests the rendered output for fields display.
  */
 public function testFeedFieldOutput()
 {
     $this->drupalCreateContentType(['type' => 'page']);
     // Verify a title with HTML entities is properly escaped.
     $node_title = 'This "cool" & "neat" article\'s title';
     $this->drupalCreateNode(array('title' => $node_title, 'body' => [0 => ['value' => 'A paragraph', 'format' => filter_default_format()]]));
     $this->drupalGet('test-feed-display-fields.xml');
     $result = $this->xpath('//title/a');
     $this->assertEqual($result[0], $node_title, 'Node title with HTML entities displays correctly.');
     // Verify HTML is properly escaped in the description field.
     $this->assertRaw('&lt;p&gt;A paragraph&lt;/p&gt;');
 }
开发者ID:318io,项目名称:318-io,代码行数:15,代码来源:DisplayFeedTest.php

示例13: handleDocumentInfo

 function handleDocumentInfo($DocInfo)
 {
     $this->urls_processed[$DocInfo->http_status_code][] = $DocInfo->url;
     if (200 != $DocInfo->http_status_code) {
         return;
     }
     $nid = db_select('field_data_field_sitecrawler_url', 'fdfsu')->fields('fdfsu', array('entity_id'))->condition('fdfsu.field_sitecrawler_url_url', $DocInfo->url)->execute()->fetchField();
     if (!!$nid) {
         $node = node_load($nid);
         $this->nodes_updated++;
     } else {
         $node = new stdClass();
         $node->type = 'sitecrawler_page';
         node_object_prepare($node);
         $this->nodes_created++;
     }
     $node->title = preg_match('#<head.*?<title>(.*?)</title>.*?</head>#is', $DocInfo->source, $matches) ? $matches[1] : $DocInfo->url;
     $node->language = LANGUAGE_NONE;
     $node->field_sitecrawler_url[$node->language][0]['title'] = $node->title;
     $node->field_sitecrawler_url[$node->language][0]['url'] = $DocInfo->url;
     //     $node->field_sitecrawler_summary[$node->language][0]['value'] =
     // drupal_set_message('<pre style="border: 1px solid red;">body_xpaths: ' . print_r($this->body_xpaths,1) . '</pre>');
     $doc = new DOMDocument();
     $doc->loadHTML($DocInfo->source);
     foreach ($this->body_xpaths as $body_xpath) {
         $xpath = new DOMXpath($doc);
         // $body = $xpath->query('/html/body');
         // $body = $xpath->query('//div[@id="layout"]');
         $body = $xpath->query($body_xpath);
         if (!is_null($body)) {
             foreach ($body as $i => $element) {
                 $node_body = $element->nodeValue;
                 if (!empty($node_body)) {
                     break 2;
                 }
             }
         }
     }
     if (empty($node_body)) {
         $node_body = preg_match('#<body.*?>(.*?)</body>#is', $DocInfo->source, $matches) && !empty($matches[1]) ? $matches[1] : $DocInfo->source;
     }
     $node_body = mb_check_encoding($node_body, 'UTF-8') ? $node_body : utf8_encode($node_body);
     $node->body[$node->language][0]['value'] = $node_body;
     $node->body[$node->language][0]['summary'] = text_summary($node_body);
     $node->body[$node->language][0]['format'] = filter_default_format();
     // store the Drupal crawler ID from the opensanmateo_sitecrawler_sites table
     $node->field_sitecrawler_id[$node->language][0]['value'] = $this->crawler_id;
     // store the PHPCrawler ID for this pull of the site
     $node->field_sitecrawler_instance_id[$node->language][0]['value'] = $this->getCrawlerId();
     node_save($node);
     $this->{'nodes_' . (!!$nid ? 'updated' : 'created')}[$node->nid] = $node->title . ' :: ' . $DocInfo->url;
 }
开发者ID:anselmbradford,项目名称:OpenSanMateo,代码行数:52,代码来源:SiteCrawler.class.php

示例14: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Enable additional languages.
     ConfigurableLanguage::createFromLangcode('de')->save();
     ConfigurableLanguage::createFromLangcode('it')->save();
     $field_storage_definition = array('field_name' => 'untranslatable_string_field', 'entity_type' => 'node', 'type' => 'string', 'cardinality' => 1, 'translatable' => FALSE);
     $field_storage = FieldStorageConfig::create($field_storage_definition);
     $field_storage->save();
     $field_definition = array('field_storage' => $field_storage, 'bundle' => 'page');
     $field = FieldConfig::create($field_definition);
     $field->save();
     // Create and log in user.
     $web_user = $this->drupalCreateUser(array('view page revisions', 'revert page revisions', 'delete page revisions', 'edit any page content', 'delete any page content', 'access contextual links', 'translate any entity', 'administer content types'));
     $this->drupalLogin($web_user);
     // Create initial node.
     $node = $this->drupalCreateNode();
     $settings = get_object_vars($node);
     $settings['revision'] = 1;
     $settings['isDefaultRevision'] = TRUE;
     $nodes = array();
     $logs = array();
     // Get original node.
     $nodes[] = clone $node;
     // Create three revisions.
     $revision_count = 3;
     for ($i = 0; $i < $revision_count; $i++) {
         $logs[] = $node->revision_log = $this->randomMachineName(32);
         // Create revision with a random title and body and update variables.
         $node->title = $this->randomMachineName();
         $node->body = array('value' => $this->randomMachineName(32), 'format' => filter_default_format());
         $node->untranslatable_string_field->value = $this->randomString();
         $node->setNewRevision();
         // Edit the 2nd revision with a different user.
         if ($i == 1) {
             $editor = $this->drupalCreateUser();
             $node->setRevisionUserId($editor->id());
         } else {
             $node->setRevisionUserId($web_user->id());
         }
         $node->save();
         $node = Node::load($node->id());
         // Make sure we get revision information.
         $nodes[] = clone $node;
     }
     $this->nodes = $nodes;
     $this->revisionLogs = $logs;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:51,代码来源:NodeRevisionsTest.php

示例15: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->drupalCreateContentType(array('type' => 'article'));
     // Create comment field on article.
     $this->container->get('comment.manager')->addDefaultField('node', 'article');
     // Create two nodes, with 5 comments on all of them.
     for ($i = 0; $i < 2; $i++) {
         $this->nodes[] = $this->drupalCreateNode(array('type' => 'article', 'body' => array(array('value' => $this->randomMachineName(42), 'format' => filter_default_format(), 'summary' => $this->randomMachineName()))));
     }
     foreach ($this->nodes as $node) {
         for ($i = 0; $i < 5; $i++) {
             $this->comments[$node->id()][] = $this->drupalCreateComment(array('entity_id' => $node->id()));
         }
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:16,代码来源:RowPluginTest.php


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