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


PHP content_to_text函数代码示例

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


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

示例1: get_document

 /**
  * Returns the document associated with this course.
  *
  * @param stdClass $record
  * @param array    $options
  * @return \core_search\document
  */
 public function get_document($record, $options = array())
 {
     try {
         $context = \context_course::instance($record->id);
     } catch (\moodle_exception $ex) {
         // Notify it as we run here as admin, we should see everything.
         debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document, not all required data is available: ' . $ex->getMessage(), DEBUG_DEVELOPER);
         return false;
     }
     // Prepare associative array with data from DB.
     $doc = \core_search\document_factory::instance($record->id, $this->componentname, $this->areaname);
     $doc->set('title', content_to_text($record->fullname, false));
     $doc->set('content', content_to_text($record->summary, $record->summaryformat));
     $doc->set('contextid', $context->id);
     $doc->set('courseid', $record->id);
     $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
     $doc->set('modified', $record->timemodified);
     $doc->set('description1', $record->shortname);
     // Check if this document should be considered new.
     if (isset($options['lastindexedtime']) && $options['lastindexedtime'] < $record->timecreated) {
         // If the document was created after the last index time, it must be new.
         $doc->set_is_new(true);
     }
     return $doc;
 }
开发者ID:sirromas,项目名称:lms,代码行数:32,代码来源:mycourse.php

示例2: get_document

 /**
  * Returns the document associated with this activity.
  *
  * Overwriting base_activity method as page contents field is required,
  * description field is not.
  *
  * @param stdClass $record
  * @param array    $options
  * @return \core_search\document
  */
 public function get_document($record, $options = array())
 {
     try {
         $cm = $this->get_cm($this->get_module_name(), $record->id, $record->course);
         $context = \context_module::instance($cm->id);
     } catch (\dml_missing_record_exception $ex) {
         // Notify it as we run here as admin, we should see everything.
         debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document, not all required data is available: ' . $ex->getMessage(), DEBUG_DEVELOPER);
         return false;
     } catch (\dml_exception $ex) {
         // Notify it as we run here as admin, we should see everything.
         debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document: ' . $ex->getMessage(), DEBUG_DEVELOPER);
         return false;
     }
     // Prepare associative array with data from DB.
     $doc = \core_search\document_factory::instance($record->id, $this->componentname, $this->areaname);
     $doc->set('title', content_to_text($record->name, false));
     $doc->set('content', content_to_text($record->content, $record->contentformat));
     $doc->set('contextid', $context->id);
     $doc->set('courseid', $record->course);
     $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
     $doc->set('modified', $record->timemodified);
     $doc->set('description1', content_to_text($record->intro, $record->introformat));
     return $doc;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:35,代码来源:activity.php

示例3: get_document

 /**
  * Returns the documents associated with this glossary entry id.
  *
  * @param stdClass $entry glossary entry.
  * @param array    $options
  * @return \core_search\document
  */
 public function get_document($entry, $options = array())
 {
     global $DB;
     $keywords = array();
     if ($aliases = $DB->get_records('glossary_alias', array('entryid' => $entry->id))) {
         foreach ($aliases as $alias) {
             $keywords[] = $alias->alias;
         }
     }
     try {
         $cm = $this->get_cm('glossary', $entry->glossaryid, $entry->course);
         $context = \context_module::instance($cm->id);
     } catch (\dml_missing_record_exception $ex) {
         // Notify it as we run here as admin, we should see everything.
         debugging('Error retrieving mod_glossary ' . $entry->id . ' document, not all required data is available: ' . $ex->getMessage(), DEBUG_DEVELOPER);
         return false;
     } catch (\dml_exception $ex) {
         // Notify it as we run here as admin, we should see everything.
         debugging('Error retrieving mod_glossary' . $entry->id . ' document: ' . $ex->getMessage(), DEBUG_DEVELOPER);
         return false;
     }
     // Prepare associative array with data from DB.
     $doc = \core_search\document_factory::instance($entry->id, $this->componentname, $this->areaname);
     $doc->set('title', content_to_text($entry->concept, false));
     $doc->set('content', content_to_text($entry->definition, $entry->definitionformat));
     $doc->set('contextid', $context->id);
     $doc->set('courseid', $entry->course);
     $doc->set('userid', $entry->userid);
     $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
     $doc->set('modified', $entry->timemodified);
     // Check if this document should be considered new.
     if (isset($options['lastindexedtime']) && $options['lastindexedtime'] < $entry->timecreated) {
         // If the document was created after the last index time, it must be new.
         $doc->set_is_new(true);
     }
     // Adding keywords as extra info.
     if ($keywords) {
         // No need to pass through content_to_text here as this is just a list of keywords.
         $doc->set('description1', implode(' ', $keywords));
     }
     return $doc;
 }
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:49,代码来源:entry.php

示例4: get_document

 /**
  * Returns document instances for each record in the recordset.
  *
  * @param StdClass $record
  * @param array $options
  * @return core_search/document
  */
 public function get_document($record, $options = array())
 {
     $context = \context_system::instance();
     // Prepare associative array with data from DB.
     $doc = \core_search\document_factory::instance($record->id, $this->componentname, $this->areaname);
     // Assigning properties to our document.
     $doc->set('title', content_to_text(fullname($record), false));
     $doc->set('contextid', $context->id);
     $doc->set('courseid', SITEID);
     $doc->set('itemid', $record->id);
     $doc->set('modified', $record->timemodified);
     $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
     $doc->set('content', content_to_text($record->description, $record->descriptionformat));
     // Check if this document should be considered new.
     if (isset($options['lastindexedtime']) && $options['lastindexedtime'] < $record->timecreated) {
         // If the document was created after the last index time, it must be new.
         $doc->set_is_new(true);
     }
     return $doc;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:27,代码来源:user.php

示例5: get_document

 /**
  * Returns the documents associated with this glossary entry id.
  *
  * @param stdClass $entry glossary entry.
  * @return \core_search\document
  */
 public function get_document($entry)
 {
     global $DB;
     $keywords = array();
     if ($aliases = $DB->get_records('glossary_alias', array('entryid' => $entry->id))) {
         foreach ($aliases as $alias) {
             $keywords[] = $alias->alias;
         }
     }
     try {
         $cm = $this->get_cm('glossary', $entry->glossaryid, $entry->course);
         $context = \context_module::instance($cm->id);
     } catch (\dml_missing_record_exception $ex) {
         // Notify it as we run here as admin, we should see everything.
         debugging('Error retrieving mod_glossary ' . $entry->id . ' document, not all required data is available: ' . $ex->getMessage(), DEBUG_DEVELOPER);
         return false;
     } catch (\dml_exception $ex) {
         // Notify it as we run here as admin, we should see everything.
         debugging('Error retrieving mod_glossary' . $entry->id . ' document: ' . $ex->getMessage(), DEBUG_DEVELOPER);
         return false;
     }
     // Prepare associative array with data from DB.
     $doc = \core_search\document_factory::instance($entry->id, $this->componentname, $this->areaname);
     $doc->set('title', $entry->concept);
     $doc->set('content', content_to_text($entry->definition, $entry->definitionformat));
     $doc->set('contextid', $context->id);
     $doc->set('type', \core_search\manager::TYPE_TEXT);
     $doc->set('courseid', $entry->course);
     $doc->set('userid', $entry->userid);
     $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
     $doc->set('modified', $entry->timemodified);
     // Adding keywords as extra info.
     if ($keywords) {
         $doc->set('description1', implode(' ', $keywords));
     }
     return $doc;
 }
开发者ID:rushi963,项目名称:moodle,代码行数:43,代码来源:entry.php

示例6: get_document

 /**
  * Returns the document associated with this post id.
  *
  * @param stdClass $record Post info.
  * @return \core_search\document
  */
 public function get_document($record)
 {
     try {
         $cm = $this->get_cm('forum', $record->forumid, $record->courseid);
         $context = \context_module::instance($cm->id);
     } catch (\dml_missing_record_exception $ex) {
         // Notify it as we run here as admin, we should see everything.
         debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document, not all required data is available: ' . $ex->getMessage(), DEBUG_DEVELOPER);
         return false;
     } catch (\dml_exception $ex) {
         // Notify it as we run here as admin, we should see everything.
         debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document: ' . $ex->getMessage(), DEBUG_DEVELOPER);
         return false;
     }
     // Prepare associative array with data from DB.
     $doc = \core_search\document_factory::instance($record->id, $this->componentname, $this->areaname);
     $doc->set('title', $record->subject);
     $doc->set('content', content_to_text($record->message, $record->messageformat));
     $doc->set('contextid', $context->id);
     $doc->set('type', \core_search\manager::TYPE_TEXT);
     $doc->set('courseid', $record->courseid);
     $doc->set('userid', $record->userid);
     $doc->set('modified', $record->modified);
     return $doc;
 }
开发者ID:kevin-bruton,项目名称:moodle,代码行数:31,代码来源:post.php

示例7: get_content_value

 /**
  * Returns the presentable string value for a field content.
  *
  * The returned string should be plain text.
  *
  * @param stdClass $content
  * @return string
  */
 public static function get_content_value($content) {
     return content_to_text($content->content, $content->content1);
 }
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:11,代码来源:field.class.php

示例8: test_message_sent_document

 /**
  * Document contents.
  *
  * @return void
  */
 public function test_message_sent_document()
 {
     // Returns the instance as long as the area is supported.
     $searcharea = \core_search\manager::get_search_area($this->messagesentareaid);
     $this->assertInstanceOf('\\core_message\\search\\message_sent', $searcharea);
     $user1 = self::getDataGenerator()->create_user();
     $user2 = self::getDataGenerator()->create_user();
     $this->preventResetByRollback();
     $sink = $this->redirectMessages();
     $message = new \core\message\message();
     $message->courseid = SITEID;
     $message->userfrom = $user1;
     $message->userto = $user2;
     $message->subject = "Test Subject";
     $message->smallmessage = "Test small messsage";
     $message->fullmessage = "Test full messsage";
     $message->fullmessageformat = 0;
     $message->fullmessagehtml = null;
     $message->notification = 0;
     $message->component = "moodle";
     $message->name = "instantmessage";
     message_send($message);
     $messages = $sink->get_messages();
     $message = $messages[0];
     $doc = $searcharea->get_document($message);
     $this->assertInstanceOf('\\core_search\\document', $doc);
     $this->assertEquals($message->id, $doc->get('itemid'));
     $this->assertEquals($this->messagesentareaid . '-' . $message->id, $doc->get('id'));
     $this->assertEquals(SITEID, $doc->get('courseid'));
     $this->assertEquals($message->useridfrom, $doc->get('owneruserid'));
     $this->assertEquals($message->useridto, $doc->get('userid'));
     $this->assertEquals(content_to_text($message->subject, false), $doc->get('title'));
     $this->assertEquals(content_to_text($message->smallmessage, false), $doc->get('content'));
 }
开发者ID:lucaboesch,项目名称:moodle,代码行数:39,代码来源:search_test_sent.php

示例9: get_document

 /**
  * Returns the document for a particular page.
  *
  * @param \stdClass $record A record containing, at least, the indexed document id and a modified timestamp
  * @param array     $options Options for document creation
  * @return \core_search\document
  */
 public function get_document($record, $options = array())
 {
     try {
         $cm = $this->get_cm('wiki', $record->wikiid, $record->courseid);
         $context = \context_module::instance($cm->id);
     } catch (\dml_missing_record_exception $ex) {
         // Notify it as we run here as admin, we should see everything.
         debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document, not all required data is available: ' . $ex->getMessage(), DEBUG_DEVELOPER);
         return false;
     } catch (\dml_exception $ex) {
         // Notify it as we run here as admin, we should see everything.
         debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document: ' . $ex->getMessage(), DEBUG_DEVELOPER);
         return false;
     }
     // Make a page object without extra fields.
     $page = clone $record;
     unset($page->courseid);
     unset($page->wikiid);
     // Conversion based wiki_print_page_content().
     // Check if we have passed the cache time.
     if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
         $content = wiki_refresh_cachedcontent($page);
         $page = $content['page'];
     }
     // Convert to text.
     $content = content_to_text($page->cachedcontent, FORMAT_MOODLE);
     // Prepare associative array with data from DB.
     $doc = \core_search\document_factory::instance($record->id, $this->componentname, $this->areaname);
     $doc->set('title', content_to_text($record->title, false));
     $doc->set('content', $content);
     $doc->set('contextid', $context->id);
     $doc->set('courseid', $record->courseid);
     $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
     $doc->set('modified', $record->timemodified);
     // Check if this document should be considered new.
     if (isset($options['lastindexedtime']) && $options['lastindexedtime'] < $record->timecreated) {
         // If the document was created after the last index time, it must be new.
         $doc->set_is_new(true);
     }
     return $doc;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:48,代码来源:collaborative_page.php

示例10: test_content_to_text

 /**
  * Tests for content_to_text.
  *
  * @param string    $content   The content
  * @param int|false $format    The content format
  * @param string    $expected  Expected value
  * @dataProvider provider_content_to_text
  */
 public function test_content_to_text($content, $format, $expected)
 {
     $content = content_to_text($content, $format);
     $this->assertEquals($expected, $content);
 }
开发者ID:sirromas,项目名称:lms,代码行数:13,代码来源:weblib_test.php

示例11: test_users_document

 /**
  * Document contents.
  *
  * @return void
  */
 public function test_users_document()
 {
     // Returns the instance as long as the area is supported.
     $searcharea = \core_search\manager::get_search_area($this->userareaid);
     $this->assertInstanceOf('\\core_user\\search\\user', $searcharea);
     $user = self::getDataGenerator()->create_user();
     $doc = $searcharea->get_document($user);
     $this->assertInstanceOf('\\core_search\\document', $doc);
     $this->assertEquals($user->id, $doc->get('itemid'));
     $this->assertEquals($this->userareaid . '-' . $user->id, $doc->get('id'));
     $this->assertEquals(SITEID, $doc->get('courseid'));
     $this->assertFalse($doc->is_set('userid'));
     $this->assertEquals(\core_search\manager::NO_OWNER_ID, $doc->get('owneruserid'));
     $this->assertEquals(content_to_text(fullname($user), false), $doc->get('title'));
     $this->assertEquals(content_to_text($user->description, $user->descriptionformat), $doc->get('content'));
 }
开发者ID:gabrielrosset,项目名称:moodle,代码行数:21,代码来源:search_test.php

示例12: test_mycourses_document

 /**
  * Document contents.
  *
  * @return void
  */
 public function test_mycourses_document()
 {
     // Returns the instance as long as the area is supported.
     $searcharea = \core_search\manager::get_search_area($this->mycoursesareaid);
     $this->assertInstanceOf('\\core_course\\search\\mycourse', $searcharea);
     $user = self::getDataGenerator()->create_user();
     $course = self::getDataGenerator()->create_course();
     $this->getDataGenerator()->enrol_user($user->id, $course->id, 'teacher');
     $doc = $searcharea->get_document($course);
     $this->assertInstanceOf('\\core_search\\document', $doc);
     $this->assertEquals($course->id, $doc->get('itemid'));
     $this->assertEquals($this->mycoursesareaid . '-' . $course->id, $doc->get('id'));
     $this->assertEquals($course->id, $doc->get('courseid'));
     $this->assertFalse($doc->is_set('userid'));
     $this->assertEquals(\core_search\manager::NO_OWNER_ID, $doc->get('owneruserid'));
     $this->assertEquals($course->fullname, $doc->get('title'));
     // Not nice. Applying \core_search\document::set line breaks clean up.
     $summary = preg_replace("/\\s+/u", " ", content_to_text($course->summary, $course->summaryformat));
     $this->assertEquals($summary, $doc->get('content'));
     $this->assertEquals($course->shortname, $doc->get('description1'));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:26,代码来源:search_test.php

示例13: get_document

 /**
  * Returns the document associated with this activity.
  *
  * This default implementation for activities sets the activity name to title and the activity intro to
  * content. Any activity can overwrite this function if it is interested in setting other fields than the
  * default ones, or to fill description optional fields with extra stuff.
  *
  * @param stdClass $record
  * @param array    $options
  * @return \core_search\document
  */
 public function get_document($record, $options = array())
 {
     try {
         $cm = $this->get_cm($this->get_module_name(), $record->id, $record->course);
         $context = \context_module::instance($cm->id);
     } catch (\dml_missing_record_exception $ex) {
         // Notify it as we run here as admin, we should see everything.
         debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document, not all required data is available: ' . $ex->getMessage(), DEBUG_DEVELOPER);
         return false;
     } catch (\dml_exception $ex) {
         // Notify it as we run here as admin, we should see everything.
         debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document: ' . $ex->getMessage(), DEBUG_DEVELOPER);
         return false;
     }
     // Prepare associative array with data from DB.
     $doc = \core_search\document_factory::instance($record->id, $this->componentname, $this->areaname);
     $doc->set('title', content_to_text($record->name, false));
     $doc->set('content', content_to_text($record->intro, $record->introformat));
     $doc->set('contextid', $context->id);
     $doc->set('courseid', $record->course);
     $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
     $doc->set('modified', $record->{static::MODIFIED_FIELD_NAME});
     // Check if this document should be considered new.
     if (isset($options['lastindexedtime'])) {
         $createdfield = static::CREATED_FIELD_NAME;
         if (!empty($createdfield) && $options['lastindexedtime'] < $record->{$createdfield}) {
             // If the document was created after the last index time, it must be new.
             $doc->set_is_new(true);
         }
     }
     return $doc;
 }
开发者ID:sirromas,项目名称:lms,代码行数:43,代码来源:base_activity.php


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