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


PHP MBYTE_strlen函数代码示例

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


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

示例1: trackback_editor

/**
* Display trackback comment submission form.
*
* @param    string  $target     URL to send the trackback comment to
* @param    string  $url        URL of our entry
* @param    string  $title      title of our entry
* @param    string  $excerpt    excerpt of our entry
* @param    string  $blog       name of our site
* @return   string              HTML for the trackback comment editor
*
*/
function trackback_editor($target = '', $url = '', $title = '', $excerpt = '', $blog = '')
{
    global $_CONF, $LANG_TRB;
    $retval = '';
    // show preview if we have at least the URL
    if (!empty($url)) {
        // filter them for the preview
        $p_title = TRB_filterTitle($title);
        $p_excerpt = TRB_filterExcerpt($excerpt);
        $p_blog = TRB_filterBlogname($blog);
        // MT and other weblogs will shorten the excerpt like this
        if (MBYTE_strlen($p_excerpt) > 255) {
            $p_excerpt = MBYTE_substr($p_excerpt, 0, 252) . '...';
        }
        $retval .= COM_startBlock($LANG_TRB['preview']);
        $preview = COM_newTemplate($_CONF['path_layout'] . 'trackback');
        $preview->set_file(array('comment' => 'trackbackcomment.thtml'));
        $comment = TRB_formatComment($url, $p_title, $p_blog, $p_excerpt);
        $preview->set_var('formatted_comment', $comment);
        $preview->parse('output', 'comment');
        $retval .= $preview->finish($preview->get_var('output'));
        $retval .= COM_endBlock();
    }
    if (empty($url) && empty($blog)) {
        $blog = htmlspecialchars($_CONF['site_name']);
    }
    $title = htmlspecialchars($title);
    $excerpt = htmlspecialchars($excerpt, ENT_NOQUOTES);
    $retval .= COM_startBlock($LANG_TRB['editor_title'], getHelpUrl() . '#trackback', COM_getBlockTemplate('_admin_block', 'header'));
    $template = COM_newTemplate($_CONF['path_layout'] . 'admin/trackback');
    $template->set_file(array('editor' => 'trackbackeditor.thtml'));
    $template->set_var('php_self', $_CONF['site_admin_url'] . '/trackback.php');
    if (empty($url) || empty($title)) {
        $template->set_var('lang_explain', $LANG_TRB['editor_intro_none']);
    } else {
        $template->set_var('lang_explain', sprintf($LANG_TRB['editor_intro'], $url, $title));
    }
    $template->set_var('lang_trackback_url', $LANG_TRB['trackback_url']);
    $template->set_var('lang_entry_url', $LANG_TRB['entry_url']);
    $template->set_var('lang_title', $LANG_TRB['entry_title']);
    $template->set_var('lang_blog_name', $LANG_TRB['blog_name']);
    $template->set_var('lang_excerpt', $LANG_TRB['excerpt']);
    $template->set_var('lang_excerpt_truncated', $LANG_TRB['truncate_warning']);
    $template->set_var('lang_send', $LANG_TRB['button_send']);
    $template->set_var('lang_preview', $LANG_TRB['button_preview']);
    $template->set_var('max_url_length', 255);
    $template->set_var('target_url', $target);
    $template->set_var('url', $url);
    $template->set_var('title', $title);
    $template->set_var('blog_name', $blog);
    $template->set_var('excerpt', $excerpt);
    $template->set_var('gltoken_name', CSRF_TOKEN);
    $template->set_var('gltoken', SEC_createToken());
    $template->parse('output', 'editor');
    $retval .= $template->finish($template->get_var('output'));
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}
开发者ID:milk54,项目名称:geeklog-japan,代码行数:69,代码来源:trackback.php

示例2: _stripos

 function _stripos($haystack, $needle)
 {
     if ($this->_charset == 'utf-8') {
         if (MBYTE_strlen($needle) > 0) {
             $haystack = MBYTE_strtolower($haystack);
             return MBYTE_strpos($haystack, $needle);
         } else {
             return false;
         }
     }
     if (function_exists('stripos')) {
         return stripos($haystack, $needle);
     } else {
         return strpos(strtolower($haystack), strtolower($needle));
     }
 }
开发者ID:NewRoute,项目名称:glfusion,代码行数:16,代码来源:search.class.php

示例3: PLG_replaceTags

/**
* This function will allow plugins to support the use of custom autolinks
* in other site content. Plugins can now use this API when saving content
* and have the content checked for any autolinks before saving.
* The autolink would be like:  [story:20040101093000103 here]
*
* @param   string   $content   Content that should be parsed for autolinks
* @param   string   $plugin    Optional if you only want to parse using a specific plugin
* @param   string   $remove    Optional if you want to remove the autotag from the content
*
*/
function PLG_replaceTags($content, $plugin = '', $remove = false)
{
    global $_CONF, $_TABLES, $LANG32;
    if (isset($_CONF['disable_autolinks']) && $_CONF['disable_autolinks'] == 1) {
        // autolinks are disabled - return $content unchanged
        return $content;
    }
    if ($remove) {
        $autolinkModules = PLG_collectTags('nopermission');
        if (!is_array($autolinkModules)) {
            // a permission check may not return any data so no point parsing content
            return $content;
        }
    } else {
        $autolinkModules = PLG_collectTags();
    }
    for ($i = 1; $i <= 5; $i++) {
        // For each supported module, scan the content looking for any AutoLink tags
        $tags = array();
        $contentlen = MBYTE_strlen($content);
        $content_lower = MBYTE_strtolower($content);
        foreach ($autolinkModules as $moduletag => $module) {
            $autotag_prefix = '[' . $moduletag . ':';
            $offset = 0;
            $prev_offset = 0;
            while ($offset < $contentlen) {
                $start_pos = MBYTE_strpos($content_lower, $autotag_prefix, $offset);
                if ($start_pos === false) {
                    break;
                } else {
                    $end_pos = MBYTE_strpos($content_lower, ']', $start_pos);
                    $next_tag = MBYTE_strpos($content_lower, '[', $start_pos + 1);
                    if ($end_pos > $start_pos and ($next_tag === false or $end_pos < $next_tag)) {
                        $taglength = $end_pos - $start_pos + 1;
                        $tag = MBYTE_substr($content, $start_pos, $taglength);
                        $parms = explode(' ', $tag);
                        // Extra test to see if autotag was entered with a space
                        // after the module name
                        if (MBYTE_substr($parms[0], -1) == ':') {
                            $startpos = MBYTE_strlen($parms[0]) + MBYTE_strlen($parms[1]) + 2;
                            $label = str_replace(']', '', MBYTE_substr($tag, $startpos));
                            $tagid = $parms[1];
                        } else {
                            $label = str_replace(']', '', MBYTE_substr($tag, MBYTE_strlen($parms[0]) + 1));
                            $parms = explode(':', $parms[0]);
                            if (count($parms) > 2) {
                                // whoops, there was a ':' in the tag id ...
                                array_shift($parms);
                                $tagid = implode(':', $parms);
                            } else {
                                $tagid = $parms[1];
                            }
                        }
                        $newtag = array('module' => $module, 'tag' => $moduletag, 'tagstr' => $tag, 'startpos' => $start_pos, 'length' => $taglength, 'parm1' => str_replace(']', '', $tagid), 'parm2' => $label);
                        $tags[] = $newtag;
                    } else {
                        // Error: tags do not match - return with no changes
                        return $content . $LANG32[32];
                    }
                    $prev_offset = $offset;
                    $offset = $end_pos;
                }
            }
        }
        // If we have found 1 or more AutoLink tag
        if (count($tags) > 0) {
            // Found the [tag] - Now process them all
            foreach ($tags as $autotag) {
                if ($remove) {
                    $content = str_replace($autotag['tagstr'], '', $content);
                } else {
                    $function = 'plugin_autotags_' . $autotag['module'];
                    if (function_exists($function) and (empty($plugin) or $plugin == $autotag['module'])) {
                        $content = $function('parse', $content, $autotag);
                    }
                }
            }
        } else {
            break;
        }
    }
    return $content;
}
开发者ID:milk54,项目名称:geeklog-japan,代码行数:94,代码来源:lib-plugins.php

示例4: testMBYTE_strlen

 public function testMBYTE_strlen()
 {
     $this->markTestSkipped();
     $this->assertEquals(9, MBYTE_strlen(utf8_encode('Användare')));
 }
开发者ID:mystralkk,项目名称:geeklog,代码行数:5,代码来源:lib-mbyteWithMBTest.php

示例5: STORY_whatsRelated

/**
 * Create "What's Related" links for a story
 * Creates an HTML-formatted list of links to be used for the What's Related
 * block next to a story (in article view).
 *
 * @param        string $related contents of gl_stories 'related' field
 * @param        int    $uid     user id of the author
 * @param        int    $sid     story id
 * @return       string      HTML-formatted list of links
 */
function STORY_whatsRelated($related, $uid, $sid)
{
    global $_CONF, $_TABLES, $LANG24;
    // Is it enabled?
    // Disabled' => 0, 'Enabled' => 1, 'Enabled (No Links)' => 2, 'Enabled (No Outbound Links)' => 3
    if ($_CONF['whats_related']) {
        // get the links from the story text
        if ($_CONF['whats_related'] != 2) {
            if (!empty($related)) {
                $rel = explode("\n", $related);
            } else {
                $rel = array();
            }
            // Used to hunt out duplicates. Stores urls that have already passed filters
            $urls = array();
            foreach ($rel as $key => &$value) {
                if (preg_match("/<a[^>]*href=[\"']([^\"']*)[\"'][^>]*>(.*?)<\\/a>/i", $value, $matches) === 1) {
                    // Go through array and remove links with no link text except link. Since a max of only 23 characters of link text showen then compare only this
                    if (substr($matches[1], 0, 23) != substr($matches[2], 0, 23)) {
                        // Check if outbound links (if needed)
                        $passd_check = false;
                        if ($_CONF['whats_related'] == 3) {
                            // no outbound links
                            if ($_CONF['site_url'] == substr($matches[1], 0, strlen($_CONF['site_url']))) {
                                $passd_check = true;
                            }
                        } else {
                            $passd_check = true;
                        }
                        if ($passd_check) {
                            // Go through array and remove any duplicates of this link
                            if (in_array($matches[1], $urls)) {
                                // remove it from the array
                                unset($rel[$key]);
                            } else {
                                $urls[] = $matches[1];
                                // Now Check Words
                                $value = '<a href="' . $matches[1] . '">' . COM_checkWords($matches[2], 'story') . '</a>';
                            }
                        } else {
                            // remove it from the array
                            unset($rel[$key]);
                        }
                    } else {
                        // remove it from the array
                        unset($rel[$key]);
                    }
                } else {
                    $value = COM_checkWords($value, 'story');
                }
            }
        }
        $topics = array();
        if (!COM_isAnonUser() || $_CONF['loginrequired'] == 0 && $_CONF['searchloginrequired'] == 0) {
            // add a link to "search by author"
            if ($_CONF['contributedbyline'] == 1) {
                $author = $LANG24[37] . ' ' . COM_getDisplayName($uid);
                if ($_CONF['whats_related_trim'] > 0 && MBYTE_strlen($author) > $_CONF['whats_related_trim']) {
                    $author = substr($author, 0, $_CONF['whats_related_trim'] - 3) . '...';
                }
                $topics[] = "<a href=\"{$_CONF['site_url']}/search.php?mode=search&amp;type=stories&amp;author={$uid}\">{$author}</a>";
            }
            // Retrieve topics
            $tids = TOPIC_getTopicIdsForObject('article', $sid, 0);
            foreach ($tids as $tid) {
                // add a link to "search by topic"
                $topic = $LANG24[38] . ' ' . stripslashes(DB_getItem($_TABLES['topics'], 'topic', "tid = '{$tid}'"));
                // trim topics if needed
                if ($_CONF['whats_related_trim'] > 0 && MBYTE_strlen($topic) > $_CONF['whats_related_trim']) {
                    $topic = substr($topic, 0, $_CONF['whats_related_trim'] - 3) . '...';
                }
                $topics[] = '<a href="' . $_CONF['site_url'] . '/search.php?mode=search&amp;type=stories&amp;topic=' . $tid . '">' . $topic . '</a>';
            }
        }
        // If line limit then split between related links and topics
        if ($_CONF['whats_related_max'] > 0) {
            if ($_CONF['whats_related_max'] < 3) {
                $rel = array();
                // Reset related links so at least user search and default topic search is displayed
                $topics = array_slice($topics, 0, 2);
            } else {
                $rel_max_num_items = intval($_CONF['whats_related_max'] / 2);
                $topic_max_num_items = $rel_max_num_items;
                if ($rel_max_num_items + $topic_max_num_items != $_CONF['whats_related_max']) {
                    $topic_max_num_items = $topic_max_num_items + 1;
                }
                // Now check if we have enough topics to display else give it to links
                $topic_num_items = count($topics);
                $rel_num_items = count($rel);
                $added_flag = false;
//.........这里部分代码省略.........
开发者ID:mystralkk,项目名称:geeklog,代码行数:101,代码来源:lib-story.php

示例6: TRB_sendTrackbackPing

/**
* Send a trackback ping
*
* Based on a code snippet by Jannis Hermanns,
* http://www.jannis.to/programming/trackback.html
*
* @param    string  $targeturl  URL to ping
* @param    string  $url        URL of our entry
* @param    string  $title      title of our entry
* @param    string  $excerpt    text excerpt from our entry
* @param    string  $blog       name of our Geeklog site
* @return   mixed               true = success, otherwise: error message
*
*/
function TRB_sendTrackbackPing($targeturl, $url, $title, $excerpt, $blog = '')
{
    global $_CONF, $LANG_TRB;
    if (empty($blog)) {
        $blog = $_CONF['site_name'];
    }
    $target = parse_url($targeturl);
    if (!isset($target['query'])) {
        $target['query'] = '';
    } else {
        if (!empty($target['query'])) {
            $target['query'] = '?' . $target['query'];
        }
    }
    if (!isset($target['port']) || !is_numeric($target['port'])) {
        $target['port'] = 80;
    }
    $sock = fsockopen($target['host'], $target['port']);
    if (!is_resource($sock)) {
        COM_errorLog('Trackback: Could not connect to ' . $targeturl);
        return $LANG_TRB['error_socket'];
    }
    $toSend = 'url=' . rawurlencode($url) . '&title=' . rawurlencode($title) . '&blog_name=' . rawurlencode($blog) . '&excerpt=' . rawurlencode($excerpt);
    $charset = COM_getCharset();
    fputs($sock, 'POST ' . $target['path'] . $target['query'] . " HTTP/1.0\r\n");
    fputs($sock, 'Host: ' . $target['host'] . "\r\n");
    fputs($sock, 'Content-type: application/x-www-form-urlencoded; charset=' . $charset . "\r\n");
    fputs($sock, 'Content-length: ' . MBYTE_strlen($toSend) . "\r\n");
    fputs($sock, 'User-Agent: Geeklog/' . VERSION . "\r\n");
    fputs($sock, "Connection: close\r\n\r\n");
    fputs($sock, $toSend);
    $res = '';
    while (!feof($sock)) {
        $res .= fgets($sock, 128);
    }
    fclose($sock);
    // firing up the XML parser for this would be overkill ...
    $r1 = strpos($res, '<error>');
    $r2 = strpos($res, '</error>');
    if ($r1 === false || $r2 === false) {
        return $LANG_TRB['error_response'];
    }
    $r1 += strlen('<error>');
    $e = trim(substr($res, $r1, $r2 - $r1));
    if ($e != 0) {
        $r1 = strpos($res, '<message>');
        $r2 = strpos($res, '</message>');
        $r1 += strlen('<message>');
        if ($r1 === false || $r2 === false) {
            return $LANG_TRB['error_unspecified'];
        }
        $m = trim(substr($res, $r1, $r2 - $r1));
        return $m;
    }
    return true;
}
开发者ID:milk54,项目名称:geeklog-japan,代码行数:70,代码来源:lib-trackback.php

示例7: COM_truncate

/**
* Truncate a string
*
* Truncates a string to a max. length and optionally adds a filler string,
* e.g. '...', to indicate the truncation.
* This function is multi-byte string aware, based on a patch by Yusuke Sakata.
*
* NOTE: The truncated string may be shorter but will never be longer than
*       $maxlen characters, i.e. the $filler string is taken into account.
*
* @param    string  $text       the text string to truncate
* @param    int     $maxlen     max. number of characters in the truncated string
* @param    string  $filler     optional filler string, e.g. '...'
* @param    int     $endchars   number of characters to show after the filler
* @return   string              truncated string
*
*/
function COM_truncate($text, $maxlen, $filler = '', $endchars = 0)
{
    $newlen = $maxlen - MBYTE_strlen($filler);
    $len = MBYTE_strlen($text);
    if ($len > $maxlen) {
        $text = MBYTE_substr($text, 0, $newlen - $endchars) . $filler . MBYTE_substr($text, $len - $endchars, $endchars);
    }
    return $text;
}
开发者ID:alxstuart,项目名称:ajfs.me,代码行数:26,代码来源:lib-common.php

示例8: maxLength

 /**
  * Checks whether the length of a string is smaller or equal to a maximal length..
  *
  * @param  string  $check The string to test
  * @param  integer $max   The maximal string length
  * @return boolean Success
  */
 public function maxLength($check, $max)
 {
     $length = MBYTE_strlen($check);
     return $length <= $max;
 }
开发者ID:Geeklog-Core,项目名称:geeklog,代码行数:12,代码来源:validator.class.php

示例9: PLG_replaceTags

/**
* This function will allow plugins to support the use of custom autolinks
* in other site content. Plugins can now use this API when saving content
* and have the content checked for any autolinks before saving.
* The autolink would be like:  [story:20040101093000103 here]
*
* @param   string   $content   Content that should be parsed for autolinks
* @param   string   $plugin    Optional if you only want to parse using a specific plugin
*
*/
function PLG_replaceTags($content, $plugin = '')
{
    global $_CONF, $_TABLES, $LANG32;
    if (isset($_CONF['disable_autolinks']) && $_CONF['disable_autolinks'] == 1) {
        // autolinks are disabled - return $content unchanged
        return $content;
    }
    $autolinkModules = PLG_collectTags();
    // For each supported module, scan the content looking for any AutoLink tags
    $tags = array();
    $contentlen = MBYTE_strlen($content);
    $content_lower = MBYTE_strtolower($content);
    foreach ($autolinkModules as $moduletag => $module) {
        $autotag_prefix = '[' . $moduletag . ':';
        $offset = 0;
        $prev_offset = 0;
        while ($offset < $contentlen) {
            $start_pos = MBYTE_strpos($content_lower, $autotag_prefix, $offset);
            if ($start_pos === false) {
                break;
            } else {
                $end_pos = MBYTE_strpos($content_lower, ']', $start_pos);
                $next_tag = MBYTE_strpos($content_lower, '[', $start_pos + 1);
                if ($end_pos > $start_pos and ($next_tag === false or $end_pos < $next_tag)) {
                    $taglength = $end_pos - $start_pos + 1;
                    $tag = MBYTE_substr($content, $start_pos, $taglength);
                    $parms = explode(' ', $tag);
                    // Extra test to see if autotag was entered with a space
                    // after the module name
                    if (MBYTE_substr($parms[0], -1) == ':') {
                        $startpos = MBYTE_strlen($parms[0]) + MBYTE_strlen($parms[1]) + 2;
                        $label = str_replace(']', '', MBYTE_substr($tag, $startpos));
                        $tagid = $parms[1];
                    } else {
                        $label = str_replace(']', '', MBYTE_substr($tag, MBYTE_strlen($parms[0]) + 1));
                        $parms = explode(':', $parms[0]);
                        if (count($parms) > 2) {
                            // whoops, there was a ':' in the tag id ...
                            array_shift($parms);
                            $tagid = implode(':', $parms);
                        } else {
                            $tagid = $parms[1];
                        }
                    }
                    $newtag = array('module' => $module, 'tag' => $moduletag, 'tagstr' => $tag, 'startpos' => $start_pos, 'length' => $taglength, 'parm1' => str_replace(']', '', $tagid), 'parm2' => $label);
                    $tags[] = $newtag;
                } else {
                    // Error: tags do not match - return with no changes
                    return $content . $LANG32[32];
                }
                $prev_offset = $offset;
                $offset = $end_pos;
            }
        }
    }
    // If we have found 1 or more AutoLink tag
    if (count($tags) > 0) {
        // Found the [tag] - Now process them all
        foreach ($tags as $autotag) {
            $function = 'plugin_autotags_' . $autotag['module'];
            if ($autotag['module'] == 'geeklog' and (empty($plugin) or $plugin == 'geeklog')) {
                $url = '';
                $linktext = $autotag['parm2'];
                if ($autotag['tag'] == 'story') {
                    $autotag['parm1'] = COM_applyFilter($autotag['parm1']);
                    if (!empty($autotag['parm1'])) {
                        $url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $autotag['parm1']);
                        if (empty($linktext)) {
                            $linktext = stripslashes(DB_getItem($_TABLES['stories'], 'title', "sid = '{$autotag['parm1']}'"));
                        }
                    }
                }
                if (!empty($url)) {
                    $filelink = COM_createLink($linktext, $url);
                    $content = str_replace($autotag['tagstr'], $filelink, $content);
                }
            } elseif (function_exists($function) and (empty($plugin) or $plugin == $autotag['module'])) {
                $content = $function('parse', $content, $autotag);
            }
        }
    }
    return $content;
}
开发者ID:Geeklog-Core,项目名称:test-framework,代码行数:93,代码来源:lib-plugins.php

示例10: STORY_extractLinks

/**
* Extract links from an HTML-formatted text.
*
* Collects all the links in a story and returns them in an array.
*
* @param    string  $fulltext   the text to search for links
* @param    int     $maxlength  max. length of text in a link (can be 0)
* @return   array   an array of strings of form <a href="...">link</a>
*
*/
function STORY_extractLinks($fulltext, $maxlength = 26)
{
    $rel = array();
    /* Only match anchor tags that contain 'href="<something>"'
     */
    preg_match_all("/<a[^>]*href=[\"']([^\"']*)[\"'][^>]*>(.*?)<\\/a>/i", $fulltext, $matches);
    for ($i = 0; $i < count($matches[0]); $i++) {
        $matches[2][$i] = strip_tags($matches[2][$i]);
        if (!MBYTE_strlen(trim($matches[2][$i]))) {
            $matches[2][$i] = strip_tags($matches[1][$i]);
        }
        // if link is too long, shorten it and add ... at the end
        if ($maxlength > 0 && MBYTE_strlen($matches[2][$i]) > $maxlength) {
            $matches[2][$i] = substr($matches[2][$i], 0, $maxlength - 3) . '...';
        }
        $rel[] = '<a href="' . $matches[1][$i] . '">' . str_replace(array("\r", "\n"), '', $matches[2][$i]) . '</a>';
    }
    return $rel;
}
开发者ID:hostellerie,项目名称:nexpro,代码行数:29,代码来源:lib-story.php

示例11: COM_truncate

/**
* Truncate a string
*
* Truncates a string to a max. length and optionally adds a filler string,
* e.g. '...', to indicate the truncation.
* This function is multi-byte string aware, based on a patch by Yusuke Sakata.
*
* NOTE: The truncated string may be shorter but will never be longer than
*       $maxlen characters, i.e. the $filler string is taken into account.
*
* @param    string  $text       the text string to truncate
* @param    int     $maxlen     max. number of characters in the truncated string
* @param    string  $filler     optional filler string, e.g. '...'
* @param    int     $endchars   number of characters to show after the filler
* @return   string              truncated string
*
*/
function COM_truncate($text, $maxlen, $filler = '', $endchars = 0)
{
    $newlen = $maxlen - MBYTE_strlen($filler);
    if ($newlen <= 0) {
        $text = MBYTE_substr($text, 0, $maxlen);
    }
    $len = MBYTE_strlen($text);
    if ($len > $maxlen) {
        $startchars = $newlen - $endchars;
        if ($startchars < $endchars) {
            $text = MBYTE_substr($text, 0, $newlen) . $filler;
        } else {
            $text = MBYTE_substr($text, 0, $newlen - $endchars) . $filler . MBYTE_substr($text, $len - $endchars, $endchars);
        }
    }
    return $text;
}
开发者ID:mistgrass,项目名称:geeklog-japan,代码行数:34,代码来源:lib-common.php

示例12: board_edit_forum_save

function board_edit_forum_save($id)
{
    global $_CONF, $_TABLES, $_USER, $_FF_CONF, $LANG_GF93;
    $retval = false;
    $statusText = array();
    $numErrors = 0;
    $category = isset($_POST['category']) ? COM_applyFilter($_POST['category'], true) : 0;
    $forum_order_id = isset($_POST['order']) ? COM_applyFilter($_POST['order'], true) : 0;
    $name = isset($_POST['name']) ? $_POST['name'] : '';
    $dscp = isset($_POST['dscp']) ? $_POST['dscp'] : '';
    $is_readonly = isset($_POST['is_readonly']) ? COM_applyFilter($_POST['is_readonly'], true) : 0;
    $is_hidden = isset($_POST['is_hidden']) ? COM_applyFilter($_POST['is_hidden'], true) : 0;
    $no_newposts = isset($_POST['no_newposts']) ? COM_applyFilter($_POST['no_newposts'], true) : 0;
    $privgroup = isset($_POST['privgroup']) ? COM_applyFilter($_POST['privgroup'], true) : 0;
    if ($privgroup == 0) {
        $privgroup = 2;
    }
    $attachmentgroup = COM_applyFilter($_POST['attachmentgroup'], true);
    if ($attachmentgroup == 0) {
        $privgroup = 1;
    }
    // data validation
    if (empty($name)) {
        $statusText[] = $LANG_GF93['name_blank'];
        $numErrors++;
    }
    if (MBYTE_strlen($name) > 70) {
        $name = MBYTE_substr($name, 0, 70);
    }
    if (empty($dscp)) {
        $statusText[] = $LANG_GF93['desc_blank'];
        $numErrors++;
    }
    if ($numErrors == 0) {
        if ($forum_order_id == 0) {
            $forum_order = 0;
        } else {
            $forum_order = DB_getItem($_TABLES['ff_forums'], 'forum_order', 'forum_id=' . (int) $forum_order_id);
        }
        $order = $forum_order++;
        $name = _ff_preparefordb($name, 'text');
        $dscp = _ff_preparefordb($dscp, 'text');
        $sql = "UPDATE {$_TABLES['ff_forums']} SET forum_name='" . DB_escapeString($name) . "',forum_order=" . (int) $order . ",forum_dscp='" . DB_escapeString($dscp) . "', grp_id=" . (int) $privgroup . ", ";
        $sql .= "is_hidden='" . DB_escapeString($is_hidden) . "', is_readonly='" . DB_escapeString($is_readonly) . "', no_newposts='" . DB_escapeString($no_newposts) . "',use_attachment_grpid=" . (int) $attachmentgroup . ",forum_cat=" . (int) $category . " ";
        $sql .= "WHERE forum_id=" . (int) $id;
        DB_query($sql);
        reorderForums($category);
        $retval = true;
        $statusText[] = $LANG_GF93['forumedited'];
    }
    return array($retval, $statusText);
}
开发者ID:NewRoute,项目名称:glfusion,代码行数:52,代码来源:boards.php

示例13: testMBYTE_strlen

 public function testMBYTE_strlen()
 {
     $this->assertEquals(6, MBYTE_strlen('string'));
 }
开发者ID:mystralkk,项目名称:geeklog,代码行数:4,代码来源:lib-mbyteNoMBTest.php

示例14: PNB_makeExcerpt

/**
* Create an excerpt from some piece of HTML containing a given URL
*
* This somewhat convoluted piece of code will extract the text around a
* given link located somewhere in the given piece of HTML. It returns
* the actual link text plus some of the text before and after the link.
*
* NOTE:     Returns an empty string when $url is not found in $html.
*
* @param    string  $html   The piece of HTML to search through
* @param    string  $url    URL that should be contained in $html somewhere
* @param    int     $xlen   Max. length of excerpt (default: 255 characters)
* @return   string          Extract: The link text and some surrounding text
*
*/
function PNB_makeExcerpt($html, $url, $xlen = 255)
{
    $retval = '';
    // the excerpt will come out as
    // [...] before linktext after [...]
    $fill_start = '[...] ';
    $fill_end = ' [...]';
    $f1len = MBYTE_strlen($fill_start);
    $f2len = MBYTE_strlen($fill_end);
    // extract all links
    preg_match_all("/<a[^>]*href=[\"']([^\"']*)[\"'][^>]*>(.*?)<\\/a>/i", $html, $matches);
    $before = '';
    $after = '';
    $linktext = '';
    $num_matches = count($matches[0]);
    for ($i = 0; $i < $num_matches; $i++) {
        if ($matches[1][$i] == $url) {
            $pos = MBYTE_strpos($html, $matches[0][$i]);
            $before = COM_getTextContent(MBYTE_substr($html, 0, $pos));
            $pos += MBYTE_strlen($matches[0][$i]);
            $after = COM_getTextContent(MBYTE_substr($html, $pos));
            $linktext = COM_getTextContent($matches[2][$i]);
            break;
        }
    }
    $tlen = MBYTE_strlen($linktext);
    if ($tlen >= $xlen) {
        // Special case: The actual link text is already longer (or as long) as
        // requested. We don't use the "fillers" here but only return the
        // (shortened) link text itself.
        if ($tlen > $xlen) {
            $retval = MBYTE_substr($linktext, 0, $xlen - 3) . '...';
        } else {
            $retval = $linktext;
        }
    } else {
        if (!empty($before)) {
            $tlen++;
        }
        if (!empty($after)) {
            $tlen++;
        }
        // make "before" and "after" text have equal length
        $rest = ($xlen - $tlen) / 2;
        // format "before" text
        $blen = MBYTE_strlen($before);
        if ($blen < $rest) {
            // if "before" text is too short, make "after" text longer
            $rest += $rest - $blen;
            $retval .= $before;
        } else {
            if ($blen > $rest) {
                $work = MBYTE_substr($before, -($rest * 2));
                $w = explode(' ', $work);
                array_shift($w);
                // drop first word, as it's probably truncated
                $w = array_reverse($w);
                $fill = $rest - $f1len;
                $b = '';
                foreach ($w as $word) {
                    if (MBYTE_strlen($b) + MBYTE_strlen($word) + 1 > $fill) {
                        break;
                    }
                    $b = $word . ' ' . $b;
                }
                $b = trim($b);
                $retval .= $fill_start . $b;
                $blen = MBYTE_strlen($b);
                if ($blen < $fill) {
                    $rest += $fill - $blen;
                }
            }
        }
        // actual link text
        if (!empty($before)) {
            $retval .= ' ';
        }
        $retval .= $linktext;
        if (!empty($after)) {
            $retval .= ' ';
        }
        // format "after" text
        if (!empty($after)) {
            $alen = MBYTE_strlen($after);
            if ($alen > $rest) {
//.........这里部分代码省略.........
开发者ID:milk54,项目名称:geeklog-japan,代码行数:101,代码来源:lib-pingback.php

示例15: SYND_truncateSummary

/**
* Truncate a feed item's text to a given max. length of characters
*
* @param    string  $text       the item's text
* @param    int     $length     max. length
* @return   string              truncated text
*
*/
function SYND_truncateSummary($text, $length)
{
    if ($length == 0) {
        return '';
    } else {
        $text = stripslashes($text);
        $text = trim($text);
        $text = str_replace(array("\r\n", "\r"), "\n", $text);
        if ($length > 3 && MBYTE_strlen($text) > $length) {
            $text = MBYTE_substr($text, 0, $length - 3) . '...';
        }
        // Check if we broke an html tag and storytext is now something
        // like "blah blah <a href= ...". Delete "<*" if so.
        if (MBYTE_strrpos($text, '<') > MBYTE_strrpos($text, '>')) {
            $text = MBYTE_substr($text, 0, MBYTE_strrpos($text, '<')) . ' ...';
        }
        return $text;
    }
}
开发者ID:hostellerie,项目名称:nexpro,代码行数:27,代码来源:lib-syndication.php


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