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


PHP drupal_html_to_text函数代码示例

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


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

示例1: view

 /**
  * {@inheritdoc}
  */
 public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL)
 {
     $build = parent::view($entity, $view_mode, $langcode);
     if ($view_mode == 'mail') {
         // Convert field labels into headings.
         // @todo Improve drupal_html_to_text() to convert DIVs correctly.
         foreach (Element::children($build) as $key) {
             if (isset($build[$key]['#label_display']) && $build[$key]['#label_display'] == 'above') {
                 $build[$key] += array('#prefix' => '');
                 $build[$key]['#prefix'] = $build[$key]['#title'] . ":\n";
                 $build[$key]['#label_display'] = 'hidden';
             }
         }
         $build = array('#markup' => drupal_html_to_text(drupal_render($build)));
     }
     return $build;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:20,代码来源:MessageViewBuilder.php

示例2: format

 /**
  * Concatenates and wraps the email body for plain-text mails.
  *
  * @param array $message
  *   A message array, as described in hook_mail_alter().
  *
  * @return array
  *   The formatted $message.
  */
 public function format(array $message)
 {
     // Join the body array into one string.
     $message['body'] = implode("\n\n", $message['body']);
     // Convert any HTML to plain-text.
     $message['body'] = drupal_html_to_text($message['body']);
     // Wrap the mail body for sending.
     $message['body'] = drupal_wrap_mail($message['body']);
     return $message;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:19,代码来源:PhpMail.php

示例3: format

 /**
  * Concatenate and wrap the e-mail body for either
  * plain-text or HTML emails.
  *
  * @param $message
  *   A message array, as described in hook_mail_alter().
  *
  * @return
  *   The formatted $message.
  */
 public function format(array $message)
 {
     $this->AllowHtml = $this->smtpConfig->get('smtp_allowhtml');
     // Join the body array into one string.
     $message['body'] = implode("\n\n", $message['body']);
     if ($this->AllowHtml == 0) {
         // Convert any HTML to plain-text.
         $message['body'] = drupal_html_to_text($message['body']);
         // Wrap the mail body for sending.
         $message['body'] = drupal_wrap_mail($message['body']);
     }
     return $message;
 }
开发者ID:ahmed3991,项目名称:Drupal8-SMTPAuthentication,代码行数:23,代码来源:SMTPMailSystem.php

示例4: hook_mail

/**
 * Prepare a message based on parameters; called from drupal_mail().
 *
 * Note that hook_mail(), unlike hook_mail_alter(), is only called on the
 * $module argument to drupal_mail(), not all modules.
 *
 * @param $key
 *   An identifier of the mail.
 * @param $message
 *   An array to be filled in. Elements in this array include:
 *   - id: An ID to identify the mail sent. Look at module source code
 *     or drupal_mail() for possible id values.
 *   - to: The address or addresses the message will be sent to. The formatting
 *     of this string will be validated with the
 *     @link http://php.net/manual/filter.filters.validate.php PHP e-mail validation filter. @endlink
 *   - subject: Subject of the e-mail to be sent. This must not contain any
 *     newline characters, or the mail may not be sent properly. drupal_mail()
 *     sets this to an empty string when the hook is invoked.
 *   - body: An array of lines containing the message to be sent. Drupal will
 *     format the correct line endings for you. drupal_mail() sets this to an
 *     empty array when the hook is invoked.
 *   - from: The address the message will be marked as being from, which is
 *     set by drupal_mail() to either a custom address or the site-wide
 *     default email address when the hook is invoked.
 *   - headers: Associative array containing mail headers, such as From,
 *     Sender, MIME-Version, Content-Type, etc. drupal_mail() pre-fills
 *     several headers in this array.
 * @param $params
 *   An array of parameters supplied by the caller of drupal_mail().
 */
function hook_mail($key, &$message, $params)
{
    $account = $params['account'];
    $context = $params['context'];
    $variables = array('%site_name' => variable_get('site_name', 'Drupal'), '%username' => format_username($account));
    if ($context['hook'] == 'taxonomy') {
        $entity = $params['entity'];
        $vocabulary = taxonomy_vocabulary_load($entity->vid);
        $variables += array('%term_name' => $entity->name, '%term_description' => $entity->description, '%term_id' => $entity->tid, '%vocabulary_name' => $vocabulary->name, '%vocabulary_description' => $vocabulary->description, '%vocabulary_id' => $vocabulary->vid);
    }
    // Node-based variable translation is only available if we have a node.
    if (isset($params['node'])) {
        $node = $params['node'];
        $variables += array('%uid' => $node->uid, '%node_url' => url('node/' . $node->nid, array('absolute' => TRUE)), '%node_type' => node_type_get_name($node), '%title' => $node->title, '%teaser' => $node->teaser, '%body' => $node->body);
    }
    $subject = strtr($context['subject'], $variables);
    $body = strtr($context['message'], $variables);
    $message['subject'] .= str_replace(array("\r", "\n"), '', $subject);
    $message['body'][] = drupal_html_to_text($body);
}
开发者ID:jayelless,项目名称:beehive,代码行数:50,代码来源:system.api.php

示例5: date_ical_escape_text

 /**
  * Escape #text elements for safe iCal use
  *
  * @param $text
  *   Text to escape
  *
  * @return
  *   Escaped text
  *
  */
 public static function date_ical_escape_text($text)
 {
     $text = drupal_html_to_text($text);
     $text = trim($text);
     // TODO Per #38130 the iCal specs don't want : and " escaped
     // but there was some reason for adding this in. Need to watch
     // this and see if anything breaks.
     //$text = str_replace('"', '\"', $text);
     //$text = str_replace(":", "\:", $text);
     $text = preg_replace("/\\\\b/", "\\\\", $text);
     $text = str_replace(",", "\\,", $text);
     $text = str_replace(";", "\\;", $text);
     $text = str_replace("\n", "\\n ", $text);
     return trim($text);
 }
开发者ID:BGCX262,项目名称:zukunftemail-svn-to-git,代码行数:25,代码来源:EDateiCal.php

示例6: foreach

 *   - field-label-[label_display]: The current label position. For example, if
 *     the label position is "above" it would result in "field-label-above".
 *
 * Other variables:
 * - $element['#object']: The entity to which the field is attached.
 * - $element['#view_mode']: View mode, e.g. 'full', 'teaser'...
 * - $element['#field_name']: The field name.
 * - $element['#field_type']: The field type.
 * - $element['#field_language']: The field language.
 * - $element['#field_translatable']: Whether the field is translatable or not.
 * - $element['#label_display']: Position of label display, inline, above, or
 *   hidden.
 * - $field_name_css: The css-compatible field name.
 * - $field_type_css: The css-compatible field type.
 * - $classes_array: Array of html class attribute values. It is flattened
 *   into a string within the variable $classes.
 *
 * @see template_preprocess_field()
 * @see theme_field()
 *
 * @ingroup themeable
 */
//all of the field-banner-xxx items have fieldgroups wrapped around them giving them the necessary <section> tag
//the title and text have another fieldgroup wrapped around them giving them the necessary <div> tag
foreach ($items as $delta => $item) {
    $theContent = render($item);
    //turn the field into htmp with drupal_html_to_text
    //use strip_tags to remove everything but a tags becasue the drupal function cannot do this (apparently)
    $theRevisedContent = strip_tags(drupal_html_to_text($theContent), '<a>');
    echo '<p>' . $theRevisedContent . '</p>';
}
开发者ID:10corp,项目名称:NMU-Zen,代码行数:31,代码来源:field--field-banner-text.tpl.php

示例7: testAutoReply

 /**
  * Tests auto-reply on the site-wide contact form.
  */
 function testAutoReply()
 {
     // Create and login administrative user.
     $admin_user = $this->drupalCreateUser(array('access site-wide contact form', 'administer contact forms', 'administer permissions', 'administer users'));
     $this->drupalLogin($admin_user);
     // Set up three categories, 2 with an auto-reply and one without.
     $foo_autoreply = $this->randomName(40);
     $bar_autoreply = $this->randomName(40);
     $this->addCategory('foo', 'foo', 'foo@example.com', $foo_autoreply, FALSE);
     $this->addCategory('bar', 'bar', 'bar@example.com', $bar_autoreply, FALSE);
     $this->addCategory('no_autoreply', 'no_autoreply', 'bar@example.com', '', FALSE);
     // Log the current user out in order to test the name and email fields.
     $this->drupalLogout();
     user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form'));
     // Test the auto-reply for category 'foo'.
     $email = $this->randomName(32) . '@example.com';
     $subject = $this->randomName(64);
     $this->submitContact($this->randomName(16), $email, $subject, 'foo', $this->randomString(128));
     // We are testing the auto-reply, so there should be one email going to the sender.
     $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email));
     $this->assertEqual(count($captured_emails), 1);
     $this->assertEqual(trim($captured_emails[0]['body']), trim(drupal_html_to_text($foo_autoreply)));
     // Test the auto-reply for category 'bar'.
     $email = $this->randomName(32) . '@example.com';
     $this->submitContact($this->randomName(16), $email, $this->randomString(64), 'bar', $this->randomString(128));
     // Auto-reply for category 'bar' should result in one auto-reply email to the sender.
     $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email));
     $this->assertEqual(count($captured_emails), 1);
     $this->assertEqual(trim($captured_emails[0]['body']), trim(drupal_html_to_text($bar_autoreply)));
     // Verify that no auto-reply is sent when the auto-reply field is left blank.
     $email = $this->randomName(32) . '@example.com';
     $this->submitContact($this->randomName(16), $email, $this->randomString(64), 'no_autoreply', $this->randomString(128));
     $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email));
     $this->assertEqual(count($captured_emails), 0);
 }
开发者ID:shumer,项目名称:blog,代码行数:38,代码来源:ContactSitewideTest.php

示例8: foreach

 *     the label position is "above" it would result in "field-label-above".
 *
 * Other variables:
 * - $element['#object']: The entity to which the field is attached.
 * - $element['#view_mode']: View mode, e.g. 'full', 'teaser'...
 * - $element['#field_name']: The field name.
 * - $element['#field_type']: The field type.
 * - $element['#field_language']: The field language.
 * - $element['#field_translatable']: Whether the field is translatable or not.
 * - $element['#label_display']: Position of label display, inline, above, or
 *   hidden.
 * - $field_name_css: The css-compatible field name.
 * - $field_type_css: The css-compatible field type.
 * - $classes_array: Array of html class attribute values. It is flattened
 *   into a string within the variable $classes.
 *
 * @see template_preprocess_field()
 * @see theme_field()
 *
 * @ingroup themeable
 */
?>

<?php 
foreach ($items as $delta => $item) {
    $theContent = render($item);
    //turn the field into htmp with drupal_html_to_text
    //use strip_tags to remove everything but a tags becasue the drupal function cannot do this (apparently)
    $theRevisedContent = strip_tags(drupal_html_to_text($theContent), '<a><br><h4><p><ul><li>');
    echo '<p>' . $theRevisedContent . '</p>';
}
开发者ID:10corp,项目名称:NMU-Zen,代码行数:31,代码来源:field--field-closing-text.tpl.php

示例9: array

			</tr>
			<tr>
			</tr>

			<tr>
				<td>&nbsp;</td>
				<td colspan="2"><table width="100%" border="0" style="border-collapse:collapse;">
					<tr>
						<td valign="top">
									<?php 
$i = 1;
$others = array();
foreach ($nodes as $node) {
    $node = is_array($node) ? $node[0] : $node;
    $content = is_array($node) ? $node[0]->content : isset($node->body) ? $node->body['und'][0]['value'] : $node->content;
    $content = count((array) $nodes) == 1 ? $content : substr(drupal_html_to_text($content), 0, 170);
    if ($i < 3) {
        print '<table border="0" cellpadding="3" class="boxNews">';
    } else {
        if ($i < 5) {
            $style = $i % 2 != 0 ? 'float:left' : 'float:right';
            print '<table border="0" style="' . $style . ';" cellpadding="3" class="boxNews">';
        } elseif ($i >= 5) {
            $others[$i][] = $node->nid;
            $others[$i][] = $node->title;
            $others[$i][] = $content;
        }
    }
    if ($i < 5) {
        print '       <tr>';
        print $i < 3 ? '<td colspan="2">' : '<td colspan="3" valign="top">';
开发者ID:urbr,项目名称:gabinetevirtual-modules,代码行数:31,代码来源:newsletters_page_edit.tpl.php

示例10: hook_mail

/**
 * Prepare a message based on parameters; called from drupal_mail().
 *
 * Note that hook_mail(), unlike hook_mail_alter(), is only called on the
 * $module argument to drupal_mail(), not all modules.
 *
 * @param $key
 *   An identifier of the mail.
 * @param $message
 *   An array to be filled in. Elements in this array include:
 *   - id: An ID to identify the mail sent. Look at module source code
 *     or drupal_mail() for possible id values.
 *   - to: The address or addresses the message will be sent to. The
 *     formatting of this string must comply with RFC 2822.
 *   - subject: Subject of the email to be sent. This must not contain any
 *     newline characters, or the mail may not be sent properly. drupal_mail()
 *     sets this to an empty string when the hook is invoked.
 *   - body: An array of lines containing the message to be sent. Drupal will
 *     format the correct line endings for you. drupal_mail() sets this to an
 *     empty array when the hook is invoked.
 *   - from: The address the message will be marked as being from, which is
 *     set by drupal_mail() to either a custom address or the site-wide
 *     default email address when the hook is invoked.
 *   - headers: Associative array containing mail headers, such as From,
 *     Sender, MIME-Version, Content-Type, etc. drupal_mail() pre-fills
 *     several headers in this array.
 * @param $params
 *   An array of parameters supplied by the caller of drupal_mail().
 */
function hook_mail($key, &$message, $params)
{
    $account = $params['account'];
    $context = $params['context'];
    $variables = array('%site_name' => \Drupal::config('system.site')->get('name'), '%username' => user_format_name($account));
    if ($context['hook'] == 'taxonomy') {
        $entity = $params['entity'];
        $vocabulary = entity_load('taxonomy_vocabulary', $entity->id());
        $variables += array('%term_name' => $entity->name, '%term_description' => $entity->description, '%term_id' => $entity->id(), '%vocabulary_name' => $vocabulary->name, '%vocabulary_description' => $vocabulary->description, '%vocabulary_id' => $vocabulary->id());
    }
    // Node-based variable translation is only available if we have a node.
    if (isset($params['node'])) {
        /** @var \Drupal\node\NodeInterface $node */
        $node = $params['node'];
        $variables += array('%uid' => $node->getOwnerId(), '%url' => url('node/' . $node->id(), array('absolute' => TRUE)), '%node_type' => node_get_type_label($node), '%title' => $node->getTitle(), '%teaser' => $node->teaser, '%body' => $node->body);
    }
    $subject = strtr($context['subject'], $variables);
    $body = strtr($context['message'], $variables);
    $message['subject'] .= str_replace(array("\r", "\n"), '', $subject);
    $message['body'][] = drupal_html_to_text($body);
}
开发者ID:alnutile,项目名称:drunatra,代码行数:50,代码来源:system.api.php

示例11: substr

 if ($wikiTitleLength > 75) {
     $wikiTitle = substr($wikiTitle, 0, 75) . "...";
 } else {
     $wikiTitle = $wikiTitle;
 }
 $node_title = '<a href="/node/' . $results->nid . '">' . $wikiTitle . '</a>';
 $node_title = trim($node_title);
 if (!empty($node_title)) {
     $exploded_title = explode(">", $node_title);
     if (isset($exploded_title)) {
         $node_nid_cuwa_array = explode('/', $exploded_title[0]);
         if (isset($node_nid_cuwa_array[2])) {
             $node_nid_cuwa_value = substr($node_nid_cuwa_array[2], 0, -1);
         }
         if (!empty($exploded_title[1])) {
             $node_title_cuwa = drupal_html_to_text($exploded_title[1], $allowed_tags = NULL);
         }
         $node_title_cuwa = rawurlencode(rawurldecode($node_title_cuwa));
     }
     ?>
     <?php 
     //cuwa page
     $im_cuwa_x1 = '';
     $im_cuwa_x2 = '';
     $im_cuwa_x3 = '';
     if (isset($_SESSION['ldap_user_role'])) {
         if ($_SESSION['ldap_user_role'] == 'store_director') {
             $im_cuwa_x1 = 1;
             $im_cuwa_x2 = 1;
         }
         if ($_SESSION['ldap_user_role'] == 'store_manager') {
开发者ID:singhneeraj,项目名称:im-portal,代码行数:31,代码来源:node--operational_model.tpl.php

示例12: get_summary

 /**
  * Generates a summary up to ${char_count} characters in length.
  * 
  * @access public
  * @param int $char_count
  * @return string
  */
 public function get_summary($char_count)
 {
     if ($this->body) {
         return drupal_html_to_text(text_summary($this->body, NULL, $char_count), array('p'));
     }
 }
开发者ID:rybosome,项目名称:doodal,代码行数:13,代码来源:class.Node.php

示例13: testVeryLongLineWrap

 /**
  * Tests that drupal_html_to_text() wraps before 1000 characters.
  *
  * RFC 3676 says, "The Text/Plain media type is the lowest common
  * denominator of Internet email, with lines of no more than 998 characters."
  *
  * RFC 2046 says, "SMTP [RFC-821] allows a maximum of 998 octets before the
  * next CRLF sequence."
  *
  * RFC 821 says, "The maximum total length of a text line including the
  * <CRLF> is 1000 characters."
  */
 public function testVeryLongLineWrap()
 {
     $input = 'Drupal<br /><p>' . str_repeat('x', 2100) . '</><br />Drupal';
     $output = drupal_html_to_text($input);
     $eol = Settings::get('mail_line_endings', PHP_EOL);
     $maximum_line_length = 0;
     foreach (explode($eol, $output) as $line) {
         // We must use strlen() rather than drupal_strlen() in order to count
         // octets rather than characters.
         $maximum_line_length = max($maximum_line_length, strlen($line . $eol));
     }
     $verbose = 'Maximum line length found was ' . $maximum_line_length . ' octets.';
     // @todo This should assert that $maximum_line_length <= 1000.
     $this->pass($verbose);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:27,代码来源:HtmlToTextTest.php

示例14: rssSummaryOrTrimmed

 /**
  * Return the summary or the trimmed body.
  */
 private function rssSummaryOrTrimmed($body, $summary)
 {
     if (!empty($summary)) {
         return drupal_html_to_text($summary);
     }
     return text_summary($body, 'plain_text');
 }
开发者ID:Global-Shelter-Cluster,项目名称:website,代码行数:10,代码来源:GroupContentManager.php


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