5 WoltLab Suite 3.0 finally made the transition from raw bbcode to bbcode-flavored HTML, with many new features related to message processing being added. This change impacts both message validation and storing, requiring slightly different APIs to get the job done.
7 ### Input Processing for Storage
9 The returned HTML is an intermediate representation with a maximum of meta data embedded into it, designed to be stored in the database. Some bbcodes are replaced during this process, for example `[b]…[/b]` becomes `<strong>…</strong>`, while others are converted into a metacode tag for later processing.
13 $processor = new \wcf\system\html\input\HtmlInputProcessor();
14 $processor->process($message, $messageObjectType, $messageObjectID);
15 $html = $processor->getHtml();
18 The `$messageObjectID` can be zero if the element did not exist before, but it should be non-zero when saving an edited message.
22 Embedded objects need to be registered after saving the message, but once again you can use the processor instance to do the job.
26 $processor = new \wcf\system\html\input\HtmlInputProcessor();
27 $processor->process($message, $messageObjectType, $messageObjectID);
28 $html = $processor->getHtml();
30 // at this point the message is saved to database and the created object
31 // `$example` is a `DatabaseObject` with the id column `$exampleID`
33 $processor->setObjectID($example->exampleID);
34 if (\wcf\system\message\embedded\object\MessageEmbeddedObjectManager::getInstance()->registerObjects($processor)) {
35 // there is at least one embedded object, this is also the point at which you
36 // would set `hasEmbeddedObjects` to true (if implemented by your type)
37 (new \wcf\data\example\ExampleEditor($example))->update(['hasEmbeddedObjects' => 1]);
41 ### Rendering the Message
43 The output processor will parse the intermediate HTML and finalize the output for display. This step is highly dynamic and allows for bbcode evaluation and contextual output based on the viewer's permissions.
47 $processor = new \wcf\system\html\output\HtmlOutputProcessor();
48 $processor->process($html, $messageObjectType, $messageObjectID);
49 $renderedHtml = $processor->getHtml();
52 #### Simplified Output
54 At some point there can be the need of a simplified output HTML that includes only basic HTML formatting and reduces more sophisticated bbcodes into a simpler representation.
58 $processor = new \wcf\system\html\output\HtmlOutputProcessor();
59 $processor->setOutputType('text/simplified-html');
60 $processor->process(…);
65 The `text/plain` output type will strip down the simplified HTML into pure text, suitable for text-only output such as the plaintext representation of an email.
69 $processor = new \wcf\system\html\output\HtmlOutputProcessor();
70 $processor->setOutputType('text/plain');
71 $processor->process(…);
76 #### Converting from BBCode
78 !!! warning "Enabling message conversion for HTML messages is undefined and yields unexpected results."
80 Legacy message that still use raw bbcodes must be converted to be properly parsed by the html processors. This process is enabled by setting the fourth parameter of `process()` to `true`.
84 $processor = new \wcf\system\html\input\HtmlInputProcessor();
85 $processor->process($html, $messageObjectType, $messageObjectID, true);
86 $renderedHtml = $processor->getHtml();
89 #### Extracting Embedded Objects
91 The `process()` method of the input processor is quite expensive, as it runs through the full message validation including the invocation of HTMLPurifier. This is perfectly fine when dealing with single messages, but when you're handling messages in bulk to extract their embedded objects, you're better of with `processEmbeddedContent()`. This method deconstructs the message, but skips all validation and expects the input to be perfectly valid, that is the output of a previous run of `process()` saved to storage.
95 $processor = new \wcf\system\html\input\HtmlInputProcessor();
96 $processor->processEmbeddedContent($html, $messageObjectType, $messageObjectID);
98 // invoke `MessageEmbeddedObjectManager::registerObjects` here
101 ## Breadcrumbs / Page Location
103 !!! warning "Breadcrumbs used to be added left to right, but parent locations are added from the bottom to the top, starting with the first ancestor and going upwards. In most cases you simply need to reverse the order."
105 Breadcrumbs used to be a lose collection of arbitrary links, but are now represented by actual page objects and the control has shifted over to the `PageLocationManager`.
110 \wcf\system\WCF::getBreadcrumbs()->add(new \wcf\system\breadcrumb\Breadcrumb('title', 'link'));
113 \wcf\system\page\PageLocationManager::getInstance()->addParentLocation($pageIdentifier, $pageObjectID, $object);
118 The property `$activeMenuItem` has been deprecated for the front end and is no longer evaluated at runtime. Recognition of the active item is entirely based around the invoked controller class name and its definition in the page table. You need to properly [register your pages](package_pip_page.md) for this feature to work.
122 ### ISearchableObjectType
124 Added the `setLocation()` method that is used to set the current page location based on the search result.
126 ### SearchIndexManager
128 The methods `SearchIndexManager::add()` and `SearchIndexManager::update()` have been deprecated and forward their call to the new method `SearchIndexManager::set()`.