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


PHP textlib::substr方法代码示例

本文整理汇总了PHP中textlib::substr方法的典型用法代码示例。如果您正苦于以下问题:PHP textlib::substr方法的具体用法?PHP textlib::substr怎么用?PHP textlib::substr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在textlib的用法示例。


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

示例1: get_label_name

/**
 * @uses LABEL_MAX_NAME_LENGTH
 * @param object $label
 * @return string
 */
function get_label_name($label) {
    $name = strip_tags(format_string($label->intro,true));
    if (textlib::strlen($name) > LABEL_MAX_NAME_LENGTH) {
        $name = textlib::substr($name, 0, LABEL_MAX_NAME_LENGTH)."...";
    }

    if (empty($name)) {
        // arbitrary name
        $name = get_string('modulename','label');
    }

    return $name;
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:18,代码来源:lib.php

示例2: action

 protected function action($message, $level, $options = null)
 {
     $columns = $this->columns;
     if ($this->datecol) {
         $columns[$this->datecol] = time();
     }
     if ($this->levelcol) {
         $columns[$this->levelcol] = $level;
     }
     $message = clean_param($message, PARAM_NOTAGS);
     // Check if the message exceeds the 255 character limit in the database,
     // if it does, shorten it so that it can be inserted successfully.
     if (textlib::strlen($message) > 255) {
         $message = textlib::substr($message, 0, 252) . '...';
     }
     $columns[$this->messagecol] = $message;
     return $this->insert_log_record($this->logtable, $columns);
 }
开发者ID:verbazend,项目名称:AWFA,代码行数:18,代码来源:database_logger.class.php

示例3: validation

 public function validation($data, $files)
 {
     global $DB, $CFG;
     $errors = parent::validation($data, $files);
     $instance = $this->instance;
     if ($instance->password !== '') {
         if ($data['guestpassword'] !== $instance->password) {
             $plugin = enrol_get_plugin('guest');
             if ($plugin->get_config('showhint')) {
                 $hint = textlib::substr($instance->password, 0, 1);
                 $errors['guestpassword'] = get_string('passwordinvalidhint', 'enrol_guest', $hint);
             } else {
                 $errors['guestpassword'] = get_string('passwordinvalid', 'enrol_guest');
             }
         }
     }
     return $errors;
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:18,代码来源:locallib.php

示例4: rfc2445_fold

function rfc2445_fold($string)
{
    if (textlib::strlen($string, 'utf-8') <= RFC2445_FOLDED_LINE_LENGTH) {
        return $string;
    }
    $retval = '';
    $i = 0;
    $len_count = 0;
    //multi-byte string, get the correct length
    $section_len = textlib::strlen($string, 'utf-8');
    while ($len_count < $section_len) {
        //get the current portion of the line
        $section = textlib::substr($string, $i * RFC2445_FOLDED_LINE_LENGTH, RFC2445_FOLDED_LINE_LENGTH, 'utf-8');
        //increment the length we've processed by the length of the new portion
        $len_count += textlib::strlen($section, 'utf-8');
        /* Add the portion to the return value, terminating with CRLF.HTAB
           As per RFC 2445, CRLF.HTAB will be replaced by the processor of the 
           data */
        $retval .= $section . RFC2445_CRLF . RFC2445_WSP;
        $i++;
    }
    return $retval;
}
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:23,代码来源:iCalendar_rfc2445.php

示例5: print_page_list_content

    /**
     * Prints the page list tab content
     *
     *
     */
    private function print_page_list_content() {
        global $OUTPUT;
        $page = $this->page;

        if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
            $fresh = wiki_refresh_cachedcontent($page);
            $page = $fresh['page'];
        }

        $pages = wiki_get_page_list($this->subwiki->id);

        $stdaux = new stdClass();
        $strspecial = get_string('special', 'wiki');

        foreach ($pages as $page) {
            // We need to format the title here to account for any filtering
            $letter = format_string($page->title, true, array('context' => $this->modcontext));
            $letter = textlib::substr($letter, 0, 1);
            if (preg_match('/^[a-zA-Z]$/', $letter)) {
                $letter = textlib::strtoupper($letter);
                $stdaux->{$letter}[] = wiki_parser_link($page);
            } else {
                $stdaux->{$strspecial}[] = wiki_parser_link($page);
            }
        }

        $table = new html_table();
        $table->head = array(get_string('pagelist', 'wiki') . $OUTPUT->help_icon('pagelist', 'wiki'));
        $table->attributes['class'] = 'wiki_editor generalbox';
        $table->align = array('center');
        foreach ($stdaux as $key => $elem) {
            $table->data[] = array($key);
            foreach ($elem as $e) {
                $table->data[] = array(html_writer::link($e['url'], format_string($e['content'], true, array('context' => $this->modcontext))));
            }
        }
        echo html_writer::table($table);
    }
开发者ID:Burick,项目名称:moodle,代码行数:43,代码来源:pagelib.php

示例6: trim_center

 /**
  * Truncate a string in the center
  * @param string $string The string to truncate
  * @param int $length The length to truncate to
  * @return string The truncated string
  */
 protected function trim_center($string, $length)
 {
     $trimlength = ceil($length / 2);
     $start = textlib::substr($string, 0, $trimlength);
     $end = textlib::substr($string, textlib::strlen($string) - $trimlength);
     $string = $start . '...' . $end;
     return $string;
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:14,代码来源:block_navigation.php

示例7: tag_print_user_box

/**
 * Prints an individual user box
 *
 * @param user_object  $user  (contains the following fields: id, firstname, lastname and picture)
 * @param bool         $return if true return html string
 * @return string|null a HTML string or null if this function does the output
 */
function tag_print_user_box($user, $return = false)
{
    global $CFG, $OUTPUT;
    $usercontext = get_context_instance(CONTEXT_USER, $user->id);
    $profilelink = '';
    if ($usercontext and has_capability('moodle/user:viewdetails', $usercontext) || has_coursecontact_role($user->id)) {
        $profilelink = $CFG->wwwroot . '/user/view.php?id=' . $user->id;
    }
    $output = $OUTPUT->box_start('user-box', 'user' . $user->id);
    $fullname = fullname($user);
    $alt = '';
    if (!empty($profilelink)) {
        $output .= '<a href="' . $profilelink . '">';
        $alt = $fullname;
    }
    $output .= $OUTPUT->user_picture($user, array('size' => 100));
    $output .= '<br />';
    if (!empty($profilelink)) {
        $output .= '</a>';
    }
    //truncate name if it's too big
    if (textlib::strlen($fullname) > 26) {
        $fullname = textlib::substr($fullname, 0, 26) . '...';
    }
    $output .= '<strong>' . $fullname . '</strong>';
    $output .= $OUTPUT->box_end();
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:39,代码来源:locallib.php

示例8: display_name_from_file

 /**
  * Generate the name of the mod instance from the name of the file
  * (remove the extension and convert underscore => space
  *
  * @param string $filename the filename of the uploaded file
  * @return string the display name to use
  */
 protected function display_name_from_file($filename)
 {
     $pos = textlib::strrpos($filename, '.');
     if ($pos) {
         // Want to skip if $pos === 0 OR $pos === false.
         $filename = textlib::substr($filename, 0, $pos);
     }
     return str_replace('_', ' ', $filename);
 }
开发者ID:vinoth4891,项目名称:clinique,代码行数:16,代码来源:dnduploadlib.php

示例9: blog_sync_external_entries

/**
 * Given a record in the {blog_external} table, checks the blog's URL
 * for new entries not yet copied into Moodle.
 * Also attempts to identify and remove deleted blog entries
 *
 * @param object $externalblog
 * @return boolean False if the Feed is invalid
 */
function blog_sync_external_entries($externalblog)
{
    global $CFG, $DB;
    require_once $CFG->libdir . '/simplepie/moodle_simplepie.php';
    $rssfile = new moodle_simplepie_file($externalblog->url);
    $filetest = new SimplePie_Locator($rssfile);
    if (!$filetest->is_feed($rssfile)) {
        $externalblog->failedlastsync = 1;
        $DB->update_record('blog_external', $externalblog);
        return false;
    } else {
        if (!empty($externalblog->failedlastsync)) {
            $externalblog->failedlastsync = 0;
            $DB->update_record('blog_external', $externalblog);
        }
    }
    $rss = new moodle_simplepie($externalblog->url);
    if (empty($rss->data)) {
        return null;
    }
    //used to identify blog posts that have been deleted from the source feed
    $oldesttimestamp = null;
    $uniquehashes = array();
    foreach ($rss->get_items() as $entry) {
        // If filtertags are defined, use them to filter the entries by RSS category
        if (!empty($externalblog->filtertags)) {
            $containsfiltertag = false;
            $categories = $entry->get_categories();
            $filtertags = explode(',', $externalblog->filtertags);
            $filtertags = array_map('trim', $filtertags);
            $filtertags = array_map('strtolower', $filtertags);
            foreach ($categories as $category) {
                if (in_array(trim(strtolower($category->term)), $filtertags)) {
                    $containsfiltertag = true;
                }
            }
            if (!$containsfiltertag) {
                continue;
            }
        }
        $uniquehashes[] = $entry->get_permalink();
        $newentry = new stdClass();
        $newentry->userid = $externalblog->userid;
        $newentry->module = 'blog_external';
        $newentry->content = $externalblog->id;
        $newentry->uniquehash = $entry->get_permalink();
        $newentry->publishstate = 'site';
        $newentry->format = FORMAT_HTML;
        // Clean subject of html, just in case
        $newentry->subject = clean_param($entry->get_title(), PARAM_TEXT);
        // Observe 128 max chars in DB
        // TODO: +1 to raise this to 255
        if (textlib::strlen($newentry->subject) > 128) {
            $newentry->subject = textlib::substr($newentry->subject, 0, 125) . '...';
        }
        $newentry->summary = $entry->get_description();
        //used to decide whether to insert or update
        //uses enty permalink plus creation date if available
        $existingpostconditions = array('uniquehash' => $entry->get_permalink());
        //our DB doesnt allow null creation or modified timestamps so check the external blog supplied one
        $entrydate = $entry->get_date('U');
        if (!empty($entrydate)) {
            $existingpostconditions['created'] = $entrydate;
        }
        //the post ID or false if post not found in DB
        $postid = $DB->get_field('post', 'id', $existingpostconditions);
        $timestamp = null;
        if (empty($entrydate)) {
            $timestamp = time();
        } else {
            $timestamp = $entrydate;
        }
        //only set created if its a new post so we retain the original creation timestamp if the post is edited
        if ($postid === false) {
            $newentry->created = $timestamp;
        }
        $newentry->lastmodified = $timestamp;
        if (empty($oldesttimestamp) || $timestamp < $oldesttimestamp) {
            //found an older post
            $oldesttimestamp = $timestamp;
        }
        if (textlib::strlen($newentry->uniquehash) > 255) {
            // The URL for this item is too long for the field. Rather than add
            // the entry without the link we will skip straight over it.
            // RSS spec says recommended length 500, we use 255.
            debugging('External blog entry skipped because of oversized URL', DEBUG_DEVELOPER);
            continue;
        }
        if ($postid === false) {
            $id = $DB->insert_record('post', $newentry);
            // Set tags
            if ($tags = tag_get_tags_array('blog_external', $externalblog->id)) {
//.........这里部分代码省略.........
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:101,代码来源:lib.php

示例10: get_short_filename

 /**
  * Create a shorten filename
  *
  * @param string $str filename
  * @param int $maxlength max file name length
  * @return string short filename
  */
 public function get_short_filename($str, $maxlength)
 {
     if (textlib::strlen($str) >= $maxlength) {
         return trim(textlib::substr($str, 0, $maxlength)) . '...';
     } else {
         return $str;
     }
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:15,代码来源:lib.php

示例11: save_usage

    public function save_usage($preferredbehaviour, $attempt, $qas, $quizlayout) {
        $missing = array();

        $layout = explode(',', $attempt->layout);
        $questionkeys = array_combine(array_values($layout), array_keys($layout));

        $this->set_quba_preferred_behaviour($attempt->uniqueid, $preferredbehaviour);

        $i = 0;
        foreach (explode(',', $quizlayout) as $questionid) {
            if ($questionid == 0) {
                continue;
            }
            $i++;

            if (!array_key_exists($questionid, $qas)) {
                $missing[] = $questionid;
                $layout[$questionkeys[$questionid]] = $questionid;
                continue;
            }

            $qa = $qas[$questionid];
            $qa->questionusageid = $attempt->uniqueid;
            $qa->slot = $i;
            if (textlib::strlen($qa->questionsummary) > question_bank::MAX_SUMMARY_LENGTH) {
                // It seems some people write very long quesions! MDL-30760
                $qa->questionsummary = textlib::substr($qa->questionsummary,
                        0, question_bank::MAX_SUMMARY_LENGTH - 3) . '...';
            }
            $this->insert_record('question_attempts', $qa);
            $layout[$questionkeys[$questionid]] = $qa->slot;

            foreach ($qa->steps as $step) {
                $step->questionattemptid = $qa->id;
                $this->insert_record('question_attempt_steps', $step);

                foreach ($step->data as $name => $value) {
                    $datum = new stdClass();
                    $datum->attemptstepid = $step->id;
                    $datum->name = $name;
                    $datum->value = $value;
                    $this->insert_record('question_attempt_step_data', $datum, false);
                }
            }
        }

        $this->set_quiz_attempt_layout($attempt->uniqueid, implode(',', $layout));

        if ($missing) {
            notify("Question sessions for questions " .
                    implode(', ', $missing) .
                    " were missing when upgrading question usage {$attempt->uniqueid}.");
        }
    }
开发者ID:JP-Git,项目名称:moodle,代码行数:54,代码来源:upgradelib.php

示例12: require_once

    exit;
}

// Output the file as a valid Excel spreadsheet if required

if ($type == "xls") {
    require_once("$CFG->libdir/excellib.class.php");

/// Calculate file name
    $downloadfilename = clean_filename(strip_tags($courseshortname.' '.format_string($survey->name,true))).'.xls';
/// Creating a workbook
    $workbook = new MoodleExcelWorkbook("-");
/// Sending HTTP headers
    $workbook->send($downloadfilename);
/// Creating the first worksheet
    $myxls = $workbook->add_worksheet(textlib::substr(strip_tags(format_string($survey->name,true)), 0, 31));

    $header = array("surveyid","surveyname","userid","firstname","lastname","email","idnumber","time", "notes");
    $col=0;
    foreach ($header as $item) {
        $myxls->write_string(0,$col++,$item);
    }

    foreach ($nestedorder as $key => $nestedquestions) {
        foreach ($nestedquestions as $key2 => $qid) {
            $question = $questions[$qid];

            if ($question->type == "0" || $question->type == "1" || $question->type == "3" || $question->type == "-1")  {
                $myxls->write_string(0,$col++,"$question->text");
            }
            if ($question->type == "2" || $question->type == "3")  {
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:31,代码来源:download.php

示例13: array

$site = $DB->get_record("course", array("id"=>1));
echo '<p style="text-align:right"><span style="font-size:0.75em">' . userdate(time()) . '</span></p>';
echo get_string("site") . ': <strong>' . format_string($site->fullname) . '</strong><br />';
echo get_string("course") . ': <strong>' . format_string($course->fullname) . ' ('. format_string($course->shortname) . ')</strong><br />';
echo get_string("modulename","glossary") . ': <strong>' . format_string($glossary->name, true) . '</strong>';
if ( $allentries ) {
    foreach ($allentries as $entry) {

        // Setting the pivot for the current entry
        $pivot = $entry->glossarypivot;
        $upperpivot = textlib::strtoupper($pivot);
        $pivottoshow = textlib::strtoupper(format_string($pivot, true, $fmtoptions));
        // Reduce pivot to 1cc if necessary
        if ( !$fullpivot ) {
            $upperpivot = textlib::substr($upperpivot, 0, 1);
            $pivottoshow = textlib::substr($pivottoshow, 0, 1);
        }

        // If there's  group break
        if ( $currentpivot != $upperpivot ) {

            // print the group break if apply
            if ( $printpivot )  {
                $currentpivot = $upperpivot;

                if ( isset($entry->userispivot) ) {
                    // printing the user icon if defined (only when browsing authors)
                    $user = $DB->get_record("user", array("id"=>$entry->userid));
                    $pivottoshow = fullname($user);
                }
开发者ID:JP-Git,项目名称:moodle,代码行数:30,代码来源:print.php

示例14: navmenulist

/**
 * Returns a popup menu with course activity modules
 *
 * Given a course
 * This function returns a small popup menu with all the
 * course activity modules in it, as a navigation menu
 * outputs a simple list structure in XHTML
 * The data is taken from the serialised array stored in
 * the course record
 *
 * @todo Finish documenting this function
 *
 * @global object
 * @uses CONTEXT_COURSE
 * @param course $course A {@link $COURSE} object.
 * @param string $sections
 * @param string $modinfo
 * @param string $strsection
 * @param string $strjumpto
 * @param int $width
 * @param string $cmid
 * @return string The HTML block
 */
function navmenulist($course, $sections, $modinfo, $strsection, $strjumpto, $width=50, $cmid=0) {

    global $CFG, $OUTPUT;

    $section = -1;
    $url = '';
    $menu = array();
    $doneheading = false;

    $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);

    $menu[] = '<ul class="navmenulist"><li class="jumpto section"><span>'.$strjumpto.'</span><ul>';
    foreach ($modinfo->cms as $mod) {
        if (!$mod->has_view()) {
            // Don't show modules which you can't link to!
            continue;
        }

        if ($mod->sectionnum > $course->numsections) {   /// Don't show excess hidden sections
            break;
        }

        if (!$mod->uservisible) { // do not icnlude empty sections at all
            continue;
        }

        if ($mod->sectionnum >= 0 and $section != $mod->sectionnum) {
            $thissection = $sections[$mod->sectionnum];

            if ($thissection->visible or !$course->hiddensections or
                      has_capability('moodle/course:viewhiddensections', $coursecontext)) {
                $thissection->summary = strip_tags(format_string($thissection->summary,true));
                if (!$doneheading) {
                    $menu[] = '</ul></li>';
                }
                if ($course->format == 'weeks' or empty($thissection->summary)) {
                    $item = $strsection ." ". $mod->sectionnum;
                } else {
                    if (textlib::strlen($thissection->summary) < ($width-3)) {
                        $item = $thissection->summary;
                    } else {
                        $item = textlib::substr($thissection->summary, 0, $width).'...';
                    }
                }
                $menu[] = '<li class="section"><span>'.$item.'</span>';
                $menu[] = '<ul>';
                $doneheading = true;

                $section = $mod->sectionnum;
            } else {
                // no activities from this hidden section shown
                continue;
            }
        }

        $url = $mod->modname .'/view.php?id='. $mod->id;
        $mod->name = strip_tags(format_string($mod->name ,true));
        if (textlib::strlen($mod->name) > ($width+5)) {
            $mod->name = textlib::substr($mod->name, 0, $width).'...';
        }
        if (!$mod->visible) {
            $mod->name = '('.$mod->name.')';
        }
        $class = 'activity '.$mod->modname;
        $class .= ($cmid == $mod->id) ? ' selected' : '';
        $menu[] = '<li class="'.$class.'">'.
                  '<img src="'.$OUTPUT->pix_url('icon', $mod->modname) . '" alt="" />'.
                  '<a href="'.$CFG->wwwroot.'/mod/'.$url.'">'.$mod->name.'</a></li>';
    }

    if ($doneheading) {
        $menu[] = '</ul></li>';
    }
    $menu[] = '</ul></li></ul>';

    return implode("\n", $menu);
}
开发者ID:numbas,项目名称:moodle,代码行数:100,代码来源:weblib.php

示例15: shorten_text

/**
 * Given some text (which may contain HTML) and an ideal length,
 * this function truncates the text neatly on a word boundary if possible
 *
 * @category string
 * @global stdClass $CFG
 * @param string $text text to be shortened
 * @param int $ideal ideal string length
 * @param boolean $exact if false, $text will not be cut mid-word
 * @param string $ending The string to append if the passed string is truncated
 * @return string $truncate shortened string
 */
function shorten_text($text, $ideal = 30, $exact = false, $ending = '...')
{
    global $CFG;
    // If the plain text is shorter than the maximum length, return the whole text.
    if (textlib::strlen(preg_replace('/<.*?>/', '', $text)) <= $ideal) {
        return $text;
    }
    // Splits on HTML tags. Each open/close/empty tag will be the first thing
    // and only tag in its 'line'.
    preg_match_all('/(<.+?>)?([^<>]*)/s', $text, $lines, PREG_SET_ORDER);
    $total_length = textlib::strlen($ending);
    $truncate = '';
    // This array stores information about open and close tags and their position
    // in the truncated string. Each item in the array is an object with fields
    // ->open (true if open), ->tag (tag name in lower case), and ->pos
    // (byte position in truncated text).
    $tagdetails = array();
    foreach ($lines as $line_matchings) {
        // If there is any html-tag in this line, handle it and add it (uncounted) to the output.
        if (!empty($line_matchings[1])) {
            // If it's an "empty element" with or without xhtml-conform closing slash (f.e. <br/>).
            if (preg_match('/^<(\\s*.+?\\/\\s*|\\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\\s.+?)?)>$/is', $line_matchings[1])) {
                // Do nothing.
            } else {
                if (preg_match('/^<\\s*\\/([^\\s]+?)\\s*>$/s', $line_matchings[1], $tag_matchings)) {
                    // Record closing tag.
                    $tagdetails[] = (object) array('open' => false, 'tag' => textlib::strtolower($tag_matchings[1]), 'pos' => textlib::strlen($truncate));
                } else {
                    if (preg_match('/^<\\s*([^\\s>!]+).*?>$/s', $line_matchings[1], $tag_matchings)) {
                        // Record opening tag.
                        $tagdetails[] = (object) array('open' => true, 'tag' => textlib::strtolower($tag_matchings[1]), 'pos' => textlib::strlen($truncate));
                    }
                }
            }
            // Add html-tag to $truncate'd text.
            $truncate .= $line_matchings[1];
        }
        // Calculate the length of the plain text part of the line; handle entities as one character.
        $content_length = textlib::strlen(preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i', ' ', $line_matchings[2]));
        if ($total_length + $content_length > $ideal) {
            // The number of characters which are left.
            $left = $ideal - $total_length;
            $entities_length = 0;
            // Search for html entities.
            if (preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i', $line_matchings[2], $entities, PREG_OFFSET_CAPTURE)) {
                // calculate the real length of all entities in the legal range
                foreach ($entities[0] as $entity) {
                    if ($entity[1] + 1 - $entities_length <= $left) {
                        $left--;
                        $entities_length += textlib::strlen($entity[0]);
                    } else {
                        // no more characters left
                        break;
                    }
                }
            }
            $breakpos = $left + $entities_length;
            // if the words shouldn't be cut in the middle...
            if (!$exact) {
                // ...search the last occurence of a space...
                for (; $breakpos > 0; $breakpos--) {
                    if ($char = textlib::substr($line_matchings[2], $breakpos, 1)) {
                        if ($char === '.' or $char === ' ') {
                            $breakpos += 1;
                            break;
                        } else {
                            if (strlen($char) > 2) {
                                // Chinese/Japanese/Korean text
                                $breakpos += 1;
                                // can be truncated at any UTF-8
                                break;
                                // character boundary.
                            }
                        }
                    }
                }
            }
            if ($breakpos == 0) {
                // This deals with the test_shorten_text_no_spaces case.
                $breakpos = $left + $entities_length;
            } else {
                if ($breakpos > $left + $entities_length) {
                    // This deals with the previous for loop breaking on the first char.
                    $breakpos = $left + $entities_length;
                }
            }
            $truncate .= textlib::substr($line_matchings[2], 0, $breakpos);
            // maximum length is reached, so get off the loop
//.........这里部分代码省略.........
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:101,代码来源:moodlelib.php


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