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


PHP format_text函数代码示例

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


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

示例1: format_message_text

 /**
  * The HTML version of the e-mail message.
  *
  * @param \stdClass $cm
  * @param \stdClass $post
  * @return string
  */
 public function format_message_text($cm, $post)
 {
     $message = file_rewrite_pluginfile_urls($post->message, 'pluginfile.php', \context_module::instance($cm->id)->id, 'mod_forum', 'post', $post->id);
     $options = new \stdClass();
     $options->para = true;
     return format_text($message, $post->messageformat, $options);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:14,代码来源:renderer.php

示例2: test_ampersands

 /**
  * Test ampersands.
  */
 public function test_ampersands()
 {
     global $CFG;
     $this->resetAfterTest(true);
     // Enable glossary filter at top level.
     filter_set_global_state('glossary', TEXTFILTER_ON);
     $CFG->glossary_linkentries = 1;
     // Create a test course.
     $course = $this->getDataGenerator()->create_course();
     $context = context_course::instance($course->id);
     // Create a glossary.
     $glossary = $this->getDataGenerator()->create_module('glossary', array('course' => $course->id, 'mainglossary' => 1));
     // Create two entries with ampersands and one normal entry.
     $generator = $this->getDataGenerator()->get_plugin_generator('mod_glossary');
     $normal = $generator->create_content($glossary, array('concept' => 'normal'));
     $amp1 = $generator->create_content($glossary, array('concept' => 'A&B'));
     $amp2 = $generator->create_content($glossary, array('concept' => 'C&D'));
     // Format text with all three entries in HTML.
     $html = '<p>A&amp;B C&amp;D normal</p>';
     $filtered = format_text($html, FORMAT_HTML, array('context' => $context));
     // Find all the glossary links in the result.
     $matches = array();
     preg_match_all('~courseid=' . $course->id . '&amp;eid=([0-9]+).*?title="(.*?)"~', $filtered, $matches);
     // There should be 3 glossary links.
     $this->assertEquals(3, count($matches[1]));
     $this->assertEquals($amp1->id, $matches[1][0]);
     $this->assertEquals($amp2->id, $matches[1][1]);
     $this->assertEquals($normal->id, $matches[1][2]);
     // Check text and escaping of title attribute.
     $this->assertEquals($glossary->name . ': A&amp;B', $matches[2][0]);
     $this->assertEquals($glossary->name . ': C&amp;D', $matches[2][1]);
     $this->assertEquals($glossary->name . ': normal', $matches[2][2]);
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:36,代码来源:filter_test.php

示例3: get_comments

 /**
  * Return comments by pages
  * @param int $page
  * @return mixed
  */
 function get_comments($page)
 {
     global $DB, $CFG, $USER;
     $params = array();
     if ($page == 0) {
         $start = 0;
     } else {
         $start = $page * $this->perpage;
     }
     $sql = "SELECT c.id, c.contextid, c.itemid, c.commentarea, c.userid, c.content, u.firstname, u.lastname, c.timecreated\n            FROM {comments} c, {user} u\n            WHERE u.id=c.userid ORDER BY c.timecreated ASC";
     $comments = array();
     $formatoptions = array('overflowdiv' => true);
     if ($records = $DB->get_records_sql($sql, array(), $start, $this->perpage)) {
         foreach ($records as $item) {
             $item->fullname = fullname($item);
             $item->time = userdate($item->timecreated);
             $item->content = format_text($item->content, FORMAT_MOODLE, $formatoptions);
             $comments[] = $item;
             unset($item->firstname);
             unset($item->lastname);
             unset($item->timecreated);
         }
     }
     return $comments;
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:30,代码来源:locallib.php

示例4: postprocess_data

 /**
  * If exists, this method can process local alternative values for
  * realizing the template, after all standard translations have been performed. 
  * Type information structure and application context dependant.
  */
 public function postprocess_data($course = null)
 {
     global $CFG, $COURSE, $DB;
     if (is_null($course)) {
         $course =& $COURSE;
     }
     // Get virtual fields from course title.
     $this->data->courseheading = format_string($course->fullname);
     $this->data->coursedesc = format_text($course->summary, $course->summaryformat);
     $this->data->idnumber = $course->idnumber;
     $this->data->shortname = $course->shortname;
     $storedimage = $this->get_file_url('image');
     $imageurl = !empty($storedimage) ? $storedimage : $this->fields['image']->default;
     if ($this->data->imagepositionoption == 'left') {
         $this->data->imageL = "<td width=\"100\" class=\"custombox-icon-left courseheading\" align=\"center\" style=\"background:url({$imageurl}) 50% 50% no-repeat transparent\">{$this->data->overimagetext}</td>";
         $this->data->imageR = '';
     } elseif ($this->data->imagepositionoption == 'right') {
         $this->data->imageL = '';
         $this->data->imageR = "<td width=\"100\" class=\"custombox-icon-right courseheading\" align=\"center\" style=\"background:url({$imageurl}) 50% 50% no-repeat transparent\">{$this->data->overimagetext}</td>";
     } else {
         $this->data->imageL = '';
         $this->data->imageR = '';
     }
     $cat = $DB->get_record('course_categories', array('id' => $course->category));
     $this->data->category = $cat->name;
 }
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:31,代码来源:customlabel.class.php

示例5: block_exabis_eportfolio_print_extcomments

function block_exabis_eportfolio_print_extcomments($itemid)
{
    $stredit = get_string('edit');
    $strdelete = get_string('delete');
    $comments = get_records("block_exabeporitemcomm", "itemid", $itemid, 'timemodified DESC');
    if (!$comments) {
        return;
    }
    foreach ($comments as $comment) {
        $user = get_record('user', 'id', $comment->userid);
        echo '<table cellspacing="0" class="forumpost blogpost blog" width="100%">';
        echo '<tr class="header"><td class="picture left">';
        print_user_picture($comment->userid, SITEID, $user->picture);
        echo '</td>';
        echo '<td class="topic starter"><div class="author">';
        $fullname = fullname($user, $comment->userid);
        $by = new object();
        $by->name = $fullname;
        $by->date = userdate($comment->timemodified);
        print_string('bynameondate', 'forum', $by);
        echo '</div></td></tr>';
        echo '<tr><td class="left side">';
        echo '</td><td class="content">' . "\n";
        echo format_text($comment->entry);
        echo '</td></tr></table>' . "\n\n";
    }
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:27,代码来源:externlib.php

示例6: get_content

 function get_content()
 {
     if ($this->content !== NULL) {
         return $this->content;
     }
     $search_string = $this->config->search_string;
     $search_string_enc = urlencode($search_string);
     $no_tweets = $this->config->no_tweets;
     $url = "http://search.twitter.com/search.atom?q={$search_string_enc}&rpp={$no_tweets}";
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $xml = curl_exec($ch);
     curl_close($ch);
     $dom = DOMDocument::loadXML($xml);
     $tweets = $dom->getElementsByTagName('entry');
     $output = "<ul class='list'>";
     foreach ($tweets as $tweet) {
         $output .= "<li style='border-top:1px dotted #aaa;padding:4px'>";
         $author = $tweet->getElementsByTagName('author')->item(0);
         $authorname = $author->getElementsByTagName('name')->item(0)->textContent;
         $authorlink = $author->getElementsByTagName('uri')->item(0)->textContent;
         $output .= "<a href='{$authorlink}'>{$authorname}</a>: ";
         $output .= format_text($tweet->getElementsByTagName('content')->item(0)->textContent, FORMAT_HTML);
         $output .= "</li>";
     }
     $output .= "</ul>";
     $this->title = $search_string . get_string('ontwitter', 'block_twitter_search');
     $this->content = new stdClass();
     $this->content->text = $output;
     $this->content->footer = '';
     return $this->content;
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:33,代码来源:block_twitter_search.php

示例7: contact

 /**
  * Render a single contact.
  *
  * @param \stdClass $contact
  *
  * @return string
  */
 public function contact(stdClass $contact)
 {
     $url = new moodle_url('/user/profile.php', array('id' => $contact->id));
     $userpic = $this->output->user_picture($contact, array('size' => '100', 'class' => 'profilepicture'));
     $description = format_text($contact->description, $contact->descriptionformat);
     return html_writer::start_tag('li', array('class' => 'contact')) . html_writer::start_tag('div', array('class' => 'contactpic')) . $userpic . html_writer::end_tag('div') . html_writer::start_tag('a', array('href' => $url)) . fullname($contact) . html_writer::end_tag('a') . html_writer::start_tag('div', array('class' => 'contactdetails')) . $description . html_writer::end_tag('div') . html_writer::end_tag('li');
 }
开发者ID:AVADOLearning,项目名称:moodle-block_mycontacts,代码行数:14,代码来源:renderer.php

示例8: generate_message

 /**
  * Generates the message object for a give subscription and event.
  *
  * @param int $subscriptionid Subscription instance
  * @param \stdClass $eventobj Event data
  *
  * @return false|\stdClass message object
  */
 protected function generate_message($subscriptionid, \stdClass $eventobj)
 {
     try {
         $subscription = subscription_manager::get_subscription($subscriptionid);
     } catch (\dml_exception $e) {
         // Race condition, someone deleted the subscription.
         return false;
     }
     $user = \core_user::get_user($subscription->userid);
     $context = \context_user::instance($user->id, IGNORE_MISSING);
     if ($context === false) {
         // User context doesn't exist. Should never happen, nothing to do return.
         return false;
     }
     $template = $subscription->template;
     $template = $this->replace_placeholders($template, $subscription, $eventobj, $context);
     $msgdata = new \stdClass();
     $msgdata->component = 'tool_monitor';
     // Your component name.
     $msgdata->name = 'notification';
     // This is the message name from messages.php.
     $msgdata->userfrom = \core_user::get_noreply_user();
     $msgdata->userto = $user;
     $msgdata->subject = $subscription->get_name($context);
     $msgdata->fullmessage = format_text($template, $subscription->templateformat, array('context' => $context));
     $msgdata->fullmessageformat = $subscription->templateformat;
     $msgdata->fullmessagehtml = format_text($template, $subscription->templateformat, array('context' => $context));
     $msgdata->smallmessage = '';
     $msgdata->notification = 1;
     // This is only set to 0 for personal messages between users.
     return $msgdata;
 }
开发者ID:HuiChangZhai,项目名称:moodle,代码行数:40,代码来源:notification_task.php

示例9: display_reported_images

 public function display_reported_images(Page $page, $reports)
 {
     global $config;
     $h_reportedimages = "";
     $n = 0;
     foreach ($reports as $report) {
         $image = $report['image'];
         $h_reason = format_text($report['reason']);
         if ($config->get_bool('report_image_show_thumbs')) {
             $image_link = $this->build_thumb_html($image);
         } else {
             $image_link = "<a href=\"" . make_link("post/view/{$image->id}") . "\">{$image->id}</a>";
         }
         $reporter_name = html_escape($report['reporter_name']);
         $userlink = "<a href='" . make_link("user/{$reporter_name}") . "'>{$reporter_name}</a>";
         global $user;
         $iabbe = new ImageAdminBlockBuildingEvent($image, $user);
         send_event($iabbe);
         ksort($iabbe->parts);
         $actions = join("<br>", $iabbe->parts);
         $oe = $n++ % 2 == 0 ? "even" : "odd";
         $h_reportedimages .= "\n\t\t\t\t<tr class='{$oe}'>\n\t\t\t\t\t<td>{$image_link}</td>\n\t\t\t\t\t<td>Report by {$userlink}: {$h_reason}</td>\n\t\t\t\t\t<td class='formstretch'>\n\t\t\t\t\t\t<form action='" . make_link("image_report/remove") . "' method='POST'>\n\t\t\t\t\t\t\t<input type='hidden' name='id' value='{$report['id']}'>\n\t\t\t\t\t\t\t<input type='submit' value='Remove Report'>\n\t\t\t\t\t\t</form>\n\n\t\t\t\t\t\t<br>{$actions}\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t";
     }
     $thumb_width = $config->get_int("thumb_width");
     $html = "\n\t\t\t<table id='reportedimage' class='zebra'>\n\t\t\t\t<thead><td width='{$thumb_width}'>Image</td><td>Reason</td><td width='128'>Action</td></thead>\n\t\t\t\t{$h_reportedimages}\n\t\t\t</table>\n\t\t";
     $page->set_title("Reported Images");
     $page->set_heading("Reported Images");
     $page->add_block(new NavBlock());
     $page->add_block(new Block("Reported Images", $html));
 }
开发者ID:jackrabbitjoey,项目名称:shimmie2,代码行数:30,代码来源:theme.php

示例10: get_content

 function get_content()
 {
     global $CFG;
     require_once $CFG->libdir . '/filelib.php';
     if ($this->content !== NULL) {
         return $this->content;
     }
     $filteropt = new stdClass();
     $filteropt->overflowdiv = true;
     if ($this->content_is_trusted()) {
         // fancy html allowed only on course, category and system blocks.
         $filteropt->noclean = true;
     }
     $this->content = new stdClass();
     $this->content->footer = '';
     if (isset($this->config->text)) {
         // rewrite url
         $this->config->text = file_rewrite_pluginfile_urls($this->config->text, 'pluginfile.php', $this->context->id, 'block_html', 'content', NULL);
         // Default to FORMAT_HTML which is what will have been used before the
         // editor was properly implemented for the block.
         $format = FORMAT_HTML;
         // Check to see if the format has been properly set on the config
         if (isset($this->config->format)) {
             $format = $this->config->format;
         }
         $this->content->text = format_text($this->config->text, $format, $filteropt);
     } else {
         $this->content->text = '';
     }
     unset($filteropt);
     // memory footprint
     return $this->content;
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:33,代码来源:block_html.php

示例11: definition

    function definition() {
        $mform =& $this->_form;
        $contextid = $this->_customdata['contextid'];

        $export = $mform->addElement('hidden', 'export', ''); // Will be overwritten below

        $table = new html_table();
        /* Styling done using HTML table and CSS */
        $table->attributes['class'] = 'export_form_table';
        $table->align = array('left', 'left', 'left', 'center');
        $table->wrap = array('nowrap', '', 'nowrap', 'nowrap');
        $table->data = array();

        $table->head = array(get_string('name'),
                            get_string('description'),
                            get_string('shortname'),
                            get_string('export', 'report_rolesmigration'));

        $roles = get_all_roles();
        foreach ($roles as $role) {
            $row = array();
            $roleurl = new moodle_url('/admin/roles/define.php', array('roleid' => $role->id, 'action' => 'view'));
            $row[0] = '<a href="'.$roleurl.'">'.format_string($role->name).'</a>';
            $row[1] = format_text($role->description, FORMAT_HTML);
            $row[2] = ($role->shortname);
            /* Export values are added from role checkboxes */
            $row[3] = '<input type="checkbox" name="export[]" value="'.$role->shortname.'" />';

            $table->data[] = $row;
        }

        $mform->addElement('html', html_writer::table($table));
        $mform->addElement('hidden', 'contextid', $contextid);
        $this->add_action_buttons(false, get_string('submitexport', 'report_rolesmigration'));
    }
开发者ID:ncsu-delta,项目名称:moodle-report_rolesmigration,代码行数:35,代码来源:exportroles_form.php

示例12: get_content

 function get_content()
 {
     global $CFG;
     require_once $CFG->libdir . '/filelib.php';
     if ($this->content !== NULL) {
         return $this->content;
     }
     $filteropt = new stdClass();
     $filteropt->overflowdiv = true;
     if ($this->content_is_trusted()) {
         // fancy html allowed only on course, category and system blocks.
         $filteropt->noclean = true;
     }
     $this->content = new stdClass();
     $this->content->footer = '';
     if (isset($this->config->text)) {
         // rewrite url
         $this->config->text = file_rewrite_pluginfile_urls($this->config->text, 'pluginfile.php', $this->context->id, 'block_html', 'content', NULL);
         $this->content->text = format_text($this->config->text, $this->config->format, $filteropt);
     } else {
         $this->content->text = '';
     }
     unset($filteropt);
     // memory footprint
     return $this->content;
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:26,代码来源:block_html.php

示例13: get_content

 function get_content()
 {
     global $CFG;
     if ($this->content !== NULL) {
         return $this->content;
     }
     if (empty($this->instance)) {
         return '';
     }
     $this->content = new object();
     $options = new object();
     $options->noclean = true;
     // Don't clean Javascripts etc
     $this->content->text = format_text($this->page->course->summary, FORMAT_HTML, $options);
     if ($this->page->user_is_editing()) {
         if ($this->page->course->id == SITEID) {
             $editpage = $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=frontpagesettings';
         } else {
             $editpage = $CFG->wwwroot . '/course/edit.php?id=' . $this->page->course->id;
         }
         $this->content->text .= "<div class=\"editbutton\"><a href=\"{$editpage}\"><img src=\"{$CFG->pixpath}/t/edit.gif\" alt=\"" . get_string('edit') . "\" /></a></div>";
     }
     $this->content->footer = '';
     return $this->content;
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:25,代码来源:block_course_summary.php

示例14: definition_inner

 /**
  * Define the elements to be displayed at the form
  *
  * Called by the parent::definition()
  *
  * @return void
  */
 protected function definition_inner(&$mform)
 {
     $fields = $this->_customdata['fields'];
     $current = $this->_customdata['current'];
     $nodims = $this->_customdata['nodims'];
     // number of assessment dimensions
     $mform->addElement('hidden', 'nodims', $nodims);
     $mform->setType('nodims', PARAM_INT);
     for ($i = 0; $i < $nodims; $i++) {
         // dimension header
         $dimtitle = get_string('dimensionnumber', 'workshopform_comments', $i + 1);
         $mform->addElement('header', 'dimensionhdr__idx_' . $i, $dimtitle);
         // dimension id
         $mform->addElement('hidden', 'dimensionid__idx_' . $i, $fields->{'dimensionid__idx_' . $i});
         $mform->setType('dimensionid__idx_' . $i, PARAM_INT);
         // grade id
         $mform->addElement('hidden', 'gradeid__idx_' . $i);
         // value set by set_data() later
         $mform->setType('gradeid__idx_' . $i, PARAM_INT);
         // dimension description
         $desc = '<div id="id_dim_' . $fields->{'dimensionid__idx_' . $i} . '_desc" class="fitem description comments">' . "\n";
         $desc .= format_text($fields->{'description__idx_' . $i}, $fields->{'description__idx_' . $i . 'format'});
         $desc .= "\n</div>";
         $mform->addElement('html', $desc);
         // comment
         $label = get_string('dimensioncomment', 'workshopform_comments');
         //$mform->addElement('editor', 'peercomment__idx_' . $i, $label, null, array('maxfiles' => 0));
         $mform->addElement('textarea', 'peercomment__idx_' . $i, $label, array('cols' => 60, 'rows' => 10));
         $mform->addRule('peercomment__idx_' . $i, null, 'required', null, 'client');
     }
     $this->set_data($current);
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:39,代码来源:assessment_form.php

示例15: get_content

 function get_content()
 {
     global $CFG, $OUTPUT;
     require_once $CFG->libdir . '/filelib.php';
     if ($this->content !== NULL) {
         return $this->content;
     }
     if (empty($this->instance)) {
         return '';
     }
     $this->content = new stdClass();
     $options = new stdClass();
     $options->noclean = true;
     // Don't clean Javascripts etc
     $options->overflowdiv = true;
     $context = context_course::instance($this->page->course->id);
     $this->page->course->summary = file_rewrite_pluginfile_urls($this->page->course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
     $this->content->text = format_text($this->page->course->summary, $this->page->course->summaryformat, $options);
     if ($this->page->user_is_editing()) {
         if ($this->page->course->id == SITEID) {
             $editpage = $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=frontpagesettings';
         } else {
             $editpage = $CFG->wwwroot . '/course/edit.php?id=' . $this->page->course->id;
         }
         $this->content->text .= "<div class=\"editbutton\"><a href=\"{$editpage}\"><img src=\"" . $OUTPUT->pix_url('t/edit') . "\" alt=\"" . get_string('edit') . "\" /></a></div>";
     }
     $this->content->footer = '';
     return $this->content;
 }
开发者ID:bobpuffer,项目名称:moodleUCLA-LUTH,代码行数:29,代码来源:block_course_summary.php


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