• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP truncate_utf8函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: jake_preprocess_page

/**
 * Preprocessor for theme('page').
 */
function jake_preprocess_page(&$vars)
{
    // Help link
    if (!empty($vars['help'])) {
        $vars['help_link'] = l('?', $_GET['q'], array('fragment' => 'help', 'attributes' => array('class' => 'help-link')));
    }
    // Admin link
    if (user_access('administer mn')) {
        $vars['admin_link'] = l(t('Admin'), 'admin/settings/site-information', array('attributes' => array('class' => 'admin-link')));
    }
    // Add body class for layout.
    $vars['attr']['class'] .= !empty($vars['template_files']) ? ' ' . end($vars['template_files']) : '';
    // Site name
    $vars['site_name'] = theme('site_name');
    // Display mission in a block
    if (!empty($vars['mission']) && drupal_is_front_page()) {
        $mission_block = new stdClass();
        $mission_block->content = $vars['mission'];
        $vars['mission_block'] = theme('block', $mission_block);
    }
    // Truncate the slogan so it doesn't break the header
    $vars['site_slogan'] = truncate_utf8($vars['site_slogan'], 35);
    // Determine stack height for fullscreen views.
    $class = array();
    if ($stackclass = context_get('theme', 'stackclass')) {
        $class[] = $stackclass;
    }
    if (!empty($vars['tabs'])) {
        $class[] = 'tabs';
    }
    if (!empty($class)) {
        $vars['attr']['class'] .= ' with-' . implode('-', $class);
    }
}
开发者ID:veriKami,项目名称:jake,代码行数:37,代码来源:template.php


示例2: viewElements

 /**
  * {@inheritdoc}
  */
 public function viewElements(FieldItemListInterface $items)
 {
     $element = array();
     $entity = $items->getEntity();
     $settings = $this->getSettings();
     foreach ($items as $delta => $item) {
         // By default use the full URL as the link text.
         $url = $this->buildUrl($item);
         $link_title = $url->toString();
         // If the link text field value is available, use it for the text.
         if (empty($settings['url_only']) && !empty($item->title)) {
             // Unsanitized token replacement here because $options['html'] is FALSE
             // by default in l().
             $link_title = \Drupal::token()->replace($item->title, array($entity->getEntityTypeId() => $entity), array('sanitize' => FALSE, 'clear' => TRUE));
         }
         // The link_separate formatter has two titles; the link text (as in the
         // field values) and the URL itself. If there is no link text value,
         // $link_title defaults to the URL, so it needs to be unset.
         // The URL version may need to be trimmed as well.
         if (empty($item->title)) {
             $link_title = NULL;
         }
         $url_title = $url->toString();
         if (!empty($settings['trim_length'])) {
             $link_title = truncate_utf8($link_title, $settings['trim_length'], FALSE, TRUE);
             $url_title = truncate_utf8($url_title, $settings['trim_length'], FALSE, TRUE);
         }
         $element[$delta] = array('#theme' => 'link_formatter_link_separate', '#title' => $link_title, '#url_title' => $url_title, '#url' => $url);
     }
     return $element;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:34,代码来源:LinkSeparateFormatter.php


示例3: file_utils_human_fileinfos

/**
 * Récupère les informations d'un fichier
 *
 * @param array $file       Tableau du fichier
 * @return array            Tableau avec 'type_orig' 'taille_orig' 'titre_format'
 */
function file_utils_human_fileinfos($file = '')
{
    $return = false;
    if (isset($file) && !empty($file)) {
        $output_main = array();
        $output_second = array();
        // Nom du fichier
        if (isset($file['filename']) && $file['filename'] != '') {
            $output_main[] = isset($file['description']) && $file['description'] != '' ? truncate_utf8($file['description'], 45) : truncate_utf8($file['filename'], 45);
        }
        // Type de fichier
        if (isset($file['filemime']) && $file['filemime'] != '') {
            $return['type_orig'] = $file['filemime'];
            $type = '';
            // Copie de code précédent -> TODO : à changer pour uniformiser sur tous les types de fichiers
            if (($i = strpos($file['filemime'], '/')) !== FALSE) {
                $type = substr($file['filemime'], $i + 1);
                if (!empty($type)) {
                    $type = strtoupper($type);
                }
            }
            $output_second[] = $type;
        }
        // Taille du fichier
        if (isset($file['filesize']) && $file['filesize'] != '') {
            $return['taille_orig'] = $file['filesize'];
            $output_second[] = file_utils_human_filesize($file['filesize']);
        }
        if (!empty($output_second)) {
            $output_main[] = '(' . implode(', ', $output_second) . ')';
        }
        $return['titre_format'] = implode(' ', $output_main);
    }
    return $return;
}
开发者ID:petitrole,项目名称:osteopathie,代码行数:41,代码来源:file_utils.php


示例4: textReduce

function textReduce($text, $max_len = 255)
{
    /*
    $dots = (strlen($text)>$max_len) ? '...' : '';
    $desc = str_replace('.','. ',$text);
    $desc = str_replace(',',', ',$desc);
    $desc = str_replace('-',' - ',$desc);
    $desc = str_replace('. ,','.,',$desc);
    return substr($desc,0,$max_len).$dots;
    */
    return truncate_utf8($text, $max_len, true, true);
}
开发者ID:alex731,项目名称:m12private,代码行数:12,代码来源:functions_general.php


示例5: render

 /**
  * Needed for this is Venue image / Event date / Venue name / Venue location / List of artists names
  * @param $results
  * @return array of event artist events
  */
 public function render($results)
 {
     $elements = array();
     foreach ($results as $event_delta => $event) {
         $artists = array();
         foreach ($event->artists as $artist_delta => $artist) {
             $artists[$artist_delta] = array('name' => $artist->name, 'url' => $artist->url);
         }
         $variables = array('event' => array('title' => $event->title, 'date' => $event->date, 'event_url' => $event->url, 'venue_url' => $event->venue->url, 'venue' => truncate_utf8($event->venue->name, 55, TRUE, TRUE, FALSE), 'location' => $event->venue->location, 'image' => $this->renderImage($event->venue->image), 'artists' => $artists));
         $elements[$event_delta] = theme('artists_event__item', $variables);
     }
     return $elements;
 }
开发者ID:adam-s,项目名称:954live,代码行数:18,代码来源:ArtistEventsStyle.php


示例6: mentor_breadcrumb

/**
 * Return a themed breadcrumb trail.
 *
 * @param $breadcrumb
 *   An array containing the breadcrumb links.
 * @return a string containing the breadcrumb output.
 */
function mentor_breadcrumb($variables)
{
    $breadcrumb = $variables['breadcrumb'];
    $breadcrumb_separator = theme_get_setting('breadcrumb-separator', 'mentor');
    if (!empty($breadcrumb) && theme_get_setting('breadcrumb-display')) {
        // Use CSS to hide titile .element-invisible.
        $output = '<h3 class="element-invisible">' . t('You are here') . '</h3>';
        if (theme_get_setting('breadcrumb-title') == 1) {
            // show the title setting
            $breadcrumb[] = truncate_utf8(drupal_get_title(), theme_get_setting('breadcrumb-title-length'), $wordsafe = TRUE, $dots = TRUE);
        }
        $output .= '<div class="breadcrumb">' . implode(' <span class="breadcrumb-separator">' . $breadcrumb_separator . '</span> ', $breadcrumb) . '</div>';
        return $output;
    }
}
开发者ID:saulelis,项目名称:mentor,代码行数:22,代码来源:template.php


示例7: zdigital_breadcrumb

function zdigital_breadcrumb($variables)
{
    $breadcrumb = $variables['breadcrumb'];
    if (!empty($breadcrumb)) {
        // Provide a navigational heading to give context for breadcrumb links to
        // screen-reader users. Make the heading invisible with .element-invisible.
        $output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';
        if (arg(0) == 'node' && arg(1) && ($node = node_load(arg(1)))) {
            if ('blog' == $node->type) {
                $breadcrumb = array(l(t('Home'), '<front>'), l(t('Opinión'), 'blog'));
            }
        }
        $breadcrumb[] = truncate_utf8(drupal_get_title(), 40, true, true);
        $output .= '<div class="breadcrumb hidden-xs hidden-sm">' . implode(' » ', $breadcrumb) . '</div>';
        return $output;
    }
}
开发者ID:arjun0819,项目名称:zdigital.com,代码行数:17,代码来源:template.php


示例8: adminOverview

 /**
  * Displays the path administration overview page.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The request object.
  *
  * @return array
  *   A render array as expected by drupal_render().
  */
 public function adminOverview(Request $request)
 {
     $keys = $request->query->get('search');
     // Add the filter form above the overview table.
     $build['path_admin_filter_form'] = $this->formBuilder()->getForm('Drupal\\path\\Form\\PathFilterForm', $keys);
     // Enable language column if language.module is enabled or if we have any
     // alias with a language.
     $multilanguage = $this->moduleHandler()->moduleExists('language') || $this->aliasStorage->languageAliasExists();
     $header = array();
     $header[] = array('data' => $this->t('Alias'), 'field' => 'alias', 'sort' => 'asc');
     $header[] = array('data' => $this->t('System'), 'field' => 'source');
     if ($multilanguage) {
         $header[] = array('data' => $this->t('Language'), 'field' => 'langcode');
     }
     $header[] = $this->t('Operations');
     $rows = array();
     $destination = drupal_get_destination();
     foreach ($this->aliasStorage->getAliasesForAdminListing($header, $keys) as $data) {
         $row = array();
         $row['data']['alias'] = _l(truncate_utf8($data->alias, 50, FALSE, TRUE), $data->source, array('attributes' => array('title' => $data->alias)));
         $row['data']['source'] = _l(truncate_utf8($data->source, 50, FALSE, TRUE), $data->source, array('alias' => TRUE, 'attributes' => array('title' => $data->source)));
         if ($multilanguage) {
             $row['data']['language_name'] = $this->languageManager()->getLanguageName($data->langcode);
         }
         $operations = array();
         $operations['edit'] = array('title' => $this->t('Edit'), 'url' => Url::fromRoute('path.admin_edit', ['pid' => $data->pid], ['query' => $destination]));
         $operations['delete'] = array('title' => $this->t('Delete'), 'url' => Url::fromRoute('path.delete', ['pid' => $data->pid], ['query' => $destination]));
         $row['data']['operations'] = array('data' => array('#type' => 'operations', '#links' => $operations));
         // If the system path maps to a different URL alias, highlight this table
         // row to let the user know of old aliases.
         if ($data->alias != $this->aliasManager->getAliasByPath($data->source, $data->langcode)) {
             $row['class'] = array('warning');
         }
         $rows[] = $row;
     }
     $build['path_table'] = array('#type' => 'table', '#header' => $header, '#rows' => $rows, '#empty' => $this->t('No URL aliases available. <a href="@link">Add URL alias</a>.', array('@link' => $this->url('path.admin_add'))));
     $build['path_pager'] = array('#theme' => 'pager');
     return $build;
 }
开发者ID:anyforsoft,项目名称:csua_d8,代码行数:48,代码来源:PathController.php


示例9: if

<div id="js-error">
  <?php if(!empty($errors)):?>
  <ul id="error-list">
    <?php foreach($errors as $error):?>
    <li class="js-error">
      <div class="row-count">
        <?php echo $error['row_count'];?>
        occurrences
      </div>
      <h3>
        <?php echo l($error['message'], 'admin/reports/jserror/' . $error['mid'], array('attributes' => array('title' => $error['message'])));?>
      </h3>
      <p>
        On line
        <?php echo $error['line'] . ':' . $error['col']?>
        of <span class="url"><?php echo l(truncate_utf8($error['file'], 100, FALSE, TRUE), $error['file'], array('attributes' => array('target' => 'blank', 'title' => $error['file'])))?> </span>
      </p>
      <p class="details">
        <span class="browser"></span> Last seen on
        <?php echo $error['browser'] . " " . $error['browser_version'] ?>
        for
        <?php echo $error['platform'] ?>
        ,
        <?php echo format_interval(time() - $error['timestamp'], 1); ?>
        ago. Occurred
        <?php echo $error['row_count']; ?>
        times so far. Occurred
        <?php echo $error['pageload'] ? t("after page load") : t("before page load") ?>
        .
      </p>
    </li>
开发者ID:EpisDiocAlb,项目名称:DrupalSite,代码行数:31,代码来源:jserror_list.tpl.php


示例10: base_path

        ?>
  <a href="<?php 
        print base_path() . drupal_get_path_alias('node/' . $post->nid);
        ?>
">
    <div class="date">
      <span class="month"><?php 
        print date('M', strtotime($post->field_post_date[LANGUAGE_NONE][0]['value']));
        ?>
</span>
      <span class="day"><?php 
        print date('j', strtotime($post->field_post_date[LANGUAGE_NONE][0]['value']));
        ?>
</span>
    </div>
    <p class="title"><?php 
        print $post->title;
        ?>
</p>
    <p><?php 
        print truncate_utf8(strip_tags($post->body[LANGUAGE_NONE][0]['value']), 60, TRUE, TRUE);
        ?>
</p>
  </a>
  <?php 
    }
    ?>
</div>
<!-- Recent Blog Posts | END -->
<?php 
}
开发者ID:focal55,项目名称:focal55_sample_code,代码行数:31,代码来源:recent-posts.tpl.php


示例11: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL, $bundle = NULL)
 {
     parent::buildForm($form, $form_state, $entity_type_id, $bundle);
     // Gather bundle information.
     $instances = array_filter(\Drupal::entityManager()->getFieldDefinitions($this->entity_type, $this->bundle), function ($field_definition) {
         return $field_definition instanceof FieldInstanceConfigInterface;
     });
     $field_types = $this->fieldTypeManager->getDefinitions();
     // Field prefix.
     $field_prefix = \Drupal::config('field_ui.settings')->get('field_prefix');
     $form += array('#entity_type' => $this->entity_type, '#bundle' => $this->bundle, '#fields' => array_keys($instances));
     $table = array('#type' => 'field_ui_table', '#tree' => TRUE, '#header' => array($this->t('Label'), array('data' => $this->t('Machine name'), 'class' => array(RESPONSIVE_PRIORITY_MEDIUM)), $this->t('Field type'), $this->t('Operations')), '#regions' => $this->getRegions(), '#attributes' => array('class' => array('field-ui-overview'), 'id' => 'field-overview'));
     // Fields.
     foreach ($instances as $name => $instance) {
         $field_storage = $instance->getFieldStorageDefinition();
         $route_parameters = array($this->bundleEntityType => $this->bundle, 'field_instance_config' => $instance->id());
         $table[$name] = array('#attributes' => array('id' => drupal_html_class($name)), 'label' => array('#markup' => String::checkPlain($instance->getLabel())), 'field_name' => array('#markup' => $instance->getName()), 'type' => array('#type' => 'link', '#title' => $field_types[$field_storage->getType()]['label'], '#route_name' => 'field_ui.storage_edit_' . $this->entity_type, '#route_parameters' => $route_parameters, '#options' => array('attributes' => array('title' => $this->t('Edit field settings.')))));
         $table[$name]['operations']['data'] = array('#type' => 'operations', '#links' => $this->entityManager->getListBuilder('field_instance_config')->getOperations($instance));
         if (!empty($field_storage->locked)) {
             $table[$name]['operations'] = array('#markup' => $this->t('Locked'));
             $table[$name]['#attributes']['class'][] = 'menu-disabled';
         }
     }
     // Gather valid field types.
     $field_type_options = array();
     foreach ($field_types as $name => $field_type) {
         // Skip field types which should not be added via user interface.
         if (empty($field_type['no_ui'])) {
             $field_type_options[$name] = $field_type['label'];
         }
     }
     asort($field_type_options);
     // Additional row: add new field.
     if ($field_type_options) {
         $name = '_add_new_field';
         $table[$name] = array('#attributes' => array('class' => array('add-new')), 'label' => array('#type' => 'textfield', '#title' => $this->t('New field label'), '#title_display' => 'invisible', '#size' => 15, '#description' => $this->t('Label'), '#prefix' => '<div class="label-input"><div class="add-new-placeholder">' . $this->t('Add new field') . '</div>', '#suffix' => '</div>'), 'field_name' => array('#type' => 'machine_name', '#title' => $this->t('New field name'), '#title_display' => 'invisible', '#field_prefix' => '<span dir="ltr">' . $field_prefix, '#field_suffix' => '</span>&lrm;', '#size' => 15, '#description' => $this->t('A unique machine-readable name containing letters, numbers, and underscores.'), '#maxlength' => FieldStorageConfig::NAME_MAX_LENGTH - strlen($field_prefix), '#prefix' => '<div class="add-new-placeholder">&nbsp;</div>', '#machine_name' => array('source' => array('fields', $name, 'label'), 'exists' => array($this, 'fieldNameExists'), 'standalone' => TRUE, 'label' => ''), '#required' => FALSE), 'type' => array('#type' => 'select', '#title' => $this->t('Type of new field'), '#title_display' => 'invisible', '#options' => $field_type_options, '#empty_option' => $this->t('- Select a field type -'), '#description' => $this->t('Type of data to store.'), '#attributes' => array('class' => array('field-type-select')), '#cell_attributes' => array('colspan' => 2), '#prefix' => '<div class="add-new-placeholder">&nbsp;</div>'), 'translatable' => array('#type' => 'value', '#value' => TRUE));
     }
     // Additional row: re-use existing field.
     $existing_fields = $this->getExistingFieldOptions();
     if ($existing_fields) {
         // Build list of options.
         $existing_field_options = array();
         foreach ($existing_fields as $field_name => $info) {
             $text = $this->t('@type: @field (@label)', array('@type' => $info['type_label'], '@label' => $info['label'], '@field' => $info['field']));
             $existing_field_options[$field_name] = truncate_utf8($text, 80, FALSE, TRUE);
         }
         asort($existing_field_options);
         $name = '_add_existing_field';
         $table[$name] = array('#attributes' => array('class' => array('add-new')), '#row_type' => 'add_new_field', '#region_callback' => array($this, 'getRowRegion'), 'label' => array('#type' => 'textfield', '#title' => $this->t('Existing field label'), '#title_display' => 'invisible', '#size' => 15, '#description' => $this->t('Label'), '#attributes' => array('class' => array('label-textfield')), '#prefix' => '<div class="label-input"><div class="add-new-placeholder">' . $this->t('Re-use existing field') . '</div>', '#suffix' => '</div>'), 'field_name' => array('#type' => 'select', '#title' => $this->t('Existing field to share'), '#title_display' => 'invisible', '#options' => $existing_field_options, '#empty_option' => $this->t('- Select an existing field -'), '#description' => $this->t('Field to share'), '#attributes' => array('class' => array('field-select')), '#cell_attributes' => array('colspan' => 3), '#prefix' => '<div class="add-new-placeholder">&nbsp;</div>'));
     }
     // We can set the 'rows_order' element, needed by theme_field_ui_table(),
     // here instead of a #pre_render callback because this form doesn't have the
     // tabledrag behavior anymore.
     $table['#regions']['content']['rows_order'] = array();
     foreach (Element::children($table) as $name) {
         $table['#regions']['content']['rows_order'][] = $name;
     }
     $form['fields'] = $table;
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#button_type' => 'primary', '#value' => $this->t('Save'));
     return $form;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:65,代码来源:FieldOverview.php


示例12: array

// Match Column numbers to Bootsrap class
$columns_classes = array(1 => 12, 2 => 6, 3 => 4, 4 => 3, 6 => 2, 12 => 1);
$bootsrap_class = isset($columns_classes[$view->style_plugin->options['columns']]) ? $columns_classes[$view->style_plugin->options['columns']] : 3;
?>
<div class="work-element <?php 
print implode(' ', $categories);
?>
 col-sm-3 col-xs-12 col-md-<?php 
print $bootsrap_class;
?>
">
  <a href="<?php 
print $fields['path']->content;
?>
" class="work">
    <?php 
print $fields['field_images']->content;
?>
    <span class="shadow"></span>
    <div class="bg-hover"></div>
    <div class="work-title">
      <?php 
print $fields['title']->content;
?>
      <div class="description"><?php 
print truncate_utf8(str_replace('/', ' / ', $fields['field_category']->content), 30, FALSE, TRUE);
?>
</div>
    </div>
  </a>
</div><!-- .work-element -->
开发者ID:ivanvincent,项目名称:imsv_fe,代码行数:31,代码来源:views-view-fields--project-hover.tpl.php


示例13: dgd7_preprocess_node

/**
 * Implements template_preprocess_node().
 * 
 * The changes made in this function affect the variables for the
 * templates/node.tpl.php template file. In this theme we have not overridden
 * this template, so the core default, located in modules/block/block.tpl.php
 * is being used. This example is covered on pages 319-320.
 */
function dgd7_preprocess_node(&$vars)
{
    // Give node titles decent classes.
    $vars['title_attributes_array']['class'][] = 'node-title';
    // Remove the "Add new comment" link when the form is below it.
    if (!empty($vars['content']['comments']['comment_form'])) {
        unset($vars['content']['links']['#links']['comment-add']);
    }
    // Make some changes when in teaser mode.
    if ($vars['teaser']) {
        // Don't display author or date information.
        $vars['display_submitted'] = FALSE;
        // Trim the node title and append an ellipsis.
        $vars['title'] = truncate_utf8($vars['title'], 70, TRUE, TRUE);
    }
}
开发者ID:patrickouc,项目名称:dgd7,代码行数:24,代码来源:template.php


示例14: node_teaser

/**
 * Generate a teaser for a node body.
 *
 * If the end of the teaser is not indicated using the <!--break--> delimiter
 * then we generate the teaser automatically, trying to end it at a sensible
 * place such as the end of a paragraph, a line break, or the end of a
 * sentence (in that order of preference).
 *
 * @param $body
 *   The content for which a teaser will be generated.
 * @param $format
 *   The format of the content. If the content contains PHP code, we do not
 *   split it up to prevent parse errors. If the line break filter is present
 *   then we treat newlines embedded in $body as line breaks.
 * @param $size
 *   The desired character length of the teaser. If omitted, the default
 *   value will be used. Ignored if the special delimiter is present
 *   in $body.
 * @return
 *   The generated teaser.
 */
function node_teaser($body, $format = NULL, $size = NULL) {

    /*
    if (!isset($size)) {
        $size = variable_get('teaser_length', 600);
    }
    */

    // Find where the delimiter is in the body
    $delimiter = strpos($body, '<!--break-->');

    // If the size is zero, and there is no delimiter, the entire body is the teaser.
    if ($size == 0 && $delimiter === FALSE) {
        return $body;
    }

    // If a valid delimiter has been specified, use it to chop off the teaser.
    if ($delimiter !== FALSE) {
        return substr($body, 0, $delimiter);
    }

    /*
    // We check for the presence of the PHP evaluator filter in the current
    // format. If the body contains PHP code, we do not split it up to prevent
    // parse errors.
    if (isset($format)) {
    $filters = filter_list_format($format);
    if (isset($filters['php/0']) && strpos($body, '<?') !== FALSE) {
    return $body;
    }
    }
    */

    // If we have a short body, the entire body is the teaser.
    if (drupal_strlen($body) <= $size) {
        return $body;
    }

    // If the delimiter has not been specified, try to split at paragraph or
    // sentence boundaries.

    // The teaser may not be longer than maximum length specified. Initial slice.
    $teaser = truncate_utf8($body, $size);

    // Store the actual length of the UTF8 string -- which might not be the same
    // as $size.
    $max_rpos = strlen($teaser);

    // How much to cut off the end of the teaser so that it doesn't end in the
    // middle of a paragraph, sentence, or word.
    // Initialize it to maximum in order to find the minimum.
    $min_rpos = $max_rpos;

    // Store the reverse of the teaser.  We use strpos on the reversed needle and
    // haystack for speed and convenience.
    $reversed = strrev($teaser);

    // Build an array of arrays of break points grouped by preference.
    $break_points = array();

    // A paragraph near the end of sliced teaser is most preferable.
    $break_points[] = array('</p>' => 0);

    // If no complete paragraph then treat line breaks as paragraphs.
    $line_breaks = array('<br />' => 6, '<br>' => 4);
    // Newline only indicates a line break if line break converter
    // filter is present.
    if (isset($filters['filter/1'])) {
        $line_breaks["\n"] = 1;
    }
    $break_points[] = $line_breaks;

    // If the first paragraph is too long, split at the end of a sentence.
    $break_points[] = array('. ' => 1, '! ' => 1, '? ' => 1, '。' => 0, '؟ ' => 1);

    // Iterate over the groups of break points until a break point is found.
    foreach ($break_points as $points) {
        // Look for each break point, starting at the end of the teaser.
        foreach ($points as $point => $offset) {
//.........这里部分代码省略.........
开发者ID:nistormihai,项目名称:Newscoop,代码行数:101,代码来源:modifier.teaser.php


示例15: testLinkSeparateFormatter

 /**
  * Tests the 'link_separate' formatter.
  *
  * This test is mostly the same as testLinkFormatter(), but they cannot be
  * merged, since they involve different configuration and output.
  */
 function testLinkSeparateFormatter()
 {
     $field_name = drupal_strtolower($this->randomMachineName());
     // Create a field with settings to validate.
     $this->fieldStorage = entity_create('field_storage_config', array('name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'link', 'cardinality' => 2));
     $this->fieldStorage->save();
     entity_create('field_instance_config', array('field_storage' => $this->fieldStorage, 'bundle' => 'entity_test', 'settings' => array('title' => DRUPAL_OPTIONAL, 'link_type' => LinkItemInterface::LINK_GENERIC)))->save();
     $display_options = array('type' => 'link_separate', 'label' => 'hidden');
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($field_name, array('type' => 'link_default'))->save();
     entity_get_display('entity_test', 'entity_test', 'full')->setComponent($field_name, $display_options)->save();
     // Create an entity with two link field values:
     // - The first field item uses a URL only.
     // - The second field item uses a URL and link text.
     // For consistency in assertion code below, the URL is assigned to the title
     // variable for the first field.
     $this->drupalGet('entity_test/add');
     $url1 = 'http://www.example.com/content/articles/archive?author=John&year=2012#com';
     $url2 = 'http://www.example.org/content/articles/archive?author=John&year=2012#org';
     // Intentionally contains an ampersand that needs sanitization on output.
     $title2 = 'A very long & strange example title that could break the nice layout of the site';
     $edit = array('user_id' => 1, 'name' => $this->randomMachineName(), "{$field_name}[0][url]" => $url1, "{$field_name}[1][url]" => $url2, "{$field_name}[1][title]" => $title2);
     $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 the link is output according to the formatter settings.
     $options = array('trim_length' => array(NULL, 6), 'rel' => array(NULL, 'nofollow'), 'target' => array(NULL, '_blank'));
     foreach ($options as $setting => $values) {
         foreach ($values as $new_value) {
             // Update the field formatter settings.
             $display_options['settings'] = array($setting => $new_value);
             entity_get_display('entity_test', 'entity_test', 'full')->setComponent($field_name, $display_options)->save();
             $this->renderTestEntity($id);
             switch ($setting) {
                 case 'trim_length':
                     $url = $url1;
                     $url_title = isset($new_value) ? truncate_utf8($url, $new_value, FALSE, TRUE) : $url;
                     $expected = '<div class="link-item">';
                     $expected .= '<div class="link-url"><a href="' . String::checkPlain($url) . '">' . String::checkPlain($url_title) . '</a></div>';
                     $expected .= '</div>';
                     $this->assertRaw($expected);
                     $url = $url2;
                     $url_title = isset($new_value) ? truncate_utf8($url, $new_value, FALSE, TRUE) : $url;
                     $title = isset($new_value) ? truncate_utf8($title2, $new_value, FALSE, TRUE) : $title2;
                     $expected = '<div class="link-item">';
                     $expected .= '<div class="link-title">' . String::checkPlain($title) . '</div>';
                     $expected .= '<div class="link-url"><a href="' . String::checkPlain($url) . '">' . String::checkPlain($url_title) . '</a></div>';
                     $expected .= '</div>';
                     $this->assertRaw($expected);
                     break;
                 case 'rel':
                     $rel = isset($new_value) ? ' rel="' . $new_value . '"' : '';
                     $this->assertRaw('<div class="link-url"><a href="' . String::checkPlain($url1) . '"' . $rel . '>' . String::checkPlain($url1) . '</a></div>');
                     $this->assertRaw('<div class="link-url"><a href="' . String::checkPlain($url2) . '"' . $rel . '>' . String::checkPlain($url2) . '</a></div>');
                     break;
                 case 'target':
                     $target = isset($new_value) ? ' target="' . $new_value . '"' : '';
                     $this->assertRaw('<div class="link-url"><a href="' . String::checkPlain($url1) . '"' . $target . '>' . String::checkPlain($url1) . '</a></div>');
                     $this->assertRaw('<div class="link-url"><a href="' . String::checkPlain($url2) . '"' . $target . '>' . String::checkPlain($url2) . '</a></div>');
                     break;
             }
         }
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:70,代码来源:LinkFieldTest.php


示例16: truncate_utf8

/**
 * @file
 * Template File for the Testimonials Block.
 */
?>

<?php 
if (isset($testimonial)) {
    ?>
<!-- Footer Testimonial | START -->
<div class="footertestimonial hidden-xs">
  <i class="fa fa-quote-left"></i>
  <p class="title"><?php 
    print $testimonial->title;
    ?>
</p>
  <p><?php 
    print truncate_utf8($testimonial->body[LANGUAGE_NONE][0]['value'], 600, TRUE);
    ?>
  <p class="name">&ndash; <strong><?php 
    print $testimonial->field_testimonial_author[LANGUAGE_NONE][0]['value'];
    ?>
</strong> <span>(<?php 
    print $testimonial->field_testimonial_location[LANGUAGE_NONE][0]['value'];
    ?>
)</span></p>
  <a href="/testimonials" class="button"><span data-hover="Read Our Testimonials">Read Our Testimonials</span></a>
</div>
<!-- Footer Testimonial | END -->
<?php 
}
开发者ID:focal55,项目名称:focal55_sample_code,代码行数:31,代码来源:testimonial.tpl.php


示例17: rubik_admin_drilldown_menu_item_link

/**
 * Override of theme('admin_drilldown_menu_item_link').
 */
function rubik_admin_drilldown_menu_item_link($link)
{
    $link['localized_options'] = empty($link['localized_options']) ? array() : $link['localized_options'];
    $link['localized_options']['html'] = TRUE;
    if (!isset($link['localized_options']['attributes']['class'])) {
        $link['localized_options']['attributes']['class'] = _rubik_icon_classes($link['href']);
    } else {
        $link['localized_options']['attributes']['class'] += _rubik_icon_classes($link['href']);
    }
    $link['description'] = check_plain(truncate_utf8(strip_tags($link['description']), 150, TRUE, TRUE));
    $link['description'] = "<span class='icon'></span>" . $link['description'];
    $link['title'] .= !empty($link['description']) ? "<span class='menu-description'>{$link['description']}</span>" : '';
    $link['title'] = filter_xss_admin($link['title']);
    return l($link['title'], $link['href'], $link['localized_options']);
}
开发者ID:netsensei,项目名称:netsensei,代码行数:18,代码来源:template.php


示例18: assertLogMessage

 /**
  * Confirms that a log message appears on the database log overview screen.
  *
  * This function should only be used for the admin/reports/dblog page, because
  * it checks for the message link text truncated to 56 characters. Other log
  * pages have no detail links so they contain the full message text.
  *
  * @param string $log_message
  *   The database log message to check.
  * @param string $message
  *   The message to pass to simpletest.
  */
 protected function assertLogMessage($log_message, $message)
 {
     $message_text = truncate_utf8(Xss::filter($log_message, array()), 56, TRUE, TRUE);
     // After \Drupal\Component\Utility\Xss::filter(), HTML entities should be
     // converted to their character equivalents because assertLink() uses this
     // string in xpath() to query the Document Object Model (DOM).
     $this->assertLink(html_entity_decode($message_text), 0, $message);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:20,代码来源:DbLogTest.php


示例19: l

<?php

// $Id: views-view-field.tpl.php,v 1.1 2008/05/16 22:22:32 merlinofchaos Exp $
/**
 * This template is used to print a single field in a view. It is not
 * actually used in default Views, as this is registered as a theme
 * function which has better performance. For single overrides, the
 * template is perfectly okay.
 *
 * Variables available:
 * - $view: The view object
 * - $field: The field handler object that can process the input
 * - $row: The raw SQL result that can be used
 * - $output: The processed output that will normally be used.
 *
 * When fetching output from the $row, this construct should be used:
 * $data = $row->{$field->field_alias}
 *
 * The above will guarantee that you'll always get the correct data,
 * regardless of any changes in the aliasing that might happen if
 * the view is modified.
 */
print l(truncate_utf8(strip_tags($row->node_title), '60', TRUE, TRUE), 'node/' . $row->nid);
开发者ID:justinlundy,项目名称:SenateDrupal,代码行数:23,代码来源:views-view-field--gallery--page-2--title.tpl.php


示例20: truncate_utf8

    ?>
    			<!-- <span class="btn-play"><?php 
    //echo $duration;
    ?>
</span> -->
 			 </a>
         <?php 
}
?>
	</div>
	<div class="video-info">
      <span class="author">
        <?php 
if (!empty($display_name)) {
    echo $display_name;
}
?>
      </span>
      <div class="title color">
        <a href="<?php 
echo $url;
?>
" class="title"><?php 
echo truncate_utf8($title, $title_max_length, true, true);
?>
</a>
      </div>
  </div>
</li>
  
开发者ID:johnedelatorre,项目名称:fusion,代码行

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP trusttext_active函数代码示例发布时间:2022-05-23
下一篇:
PHP truncate_userinfo函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap