3 * Base content handler class for flat text contents.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
27 * Content handler implementation for unknown content.
29 * This can be used to handle content for which no ContentHandler exists on the system,
30 * perhaps because the extension that provided it has been removed.
34 class UnknownContentHandler
extends ContentHandler
{
37 * Constructs an UnknownContentHandler. Since UnknownContentHandler can be registered
38 * for multiple model IDs on a system, multiple instances of UnknownContentHandler may
41 * To preserve the serialization format of the original content model, it must be supplied
42 * to the constructor via the $formats parameter. If not given, the default format is
43 * reported as 'application/octet-stream'.
45 * @param string $modelId
46 * @param string[]|null $formats
48 public function __construct( $modelId, $formats = null ) {
52 'application/octet-stream',
53 'application/unknown',
54 'application/x-binary',
62 * Returns the content's data as-is.
64 * @param Content $content
65 * @param string|null $format The serialization format to check
69 public function serializeContent( Content
$content, $format = null ) {
70 /** @var UnknownContent $content */
71 return $content->getData();
75 * Constructs an UnknownContent instance wrapping the given data.
79 * @param string $blob serialized content in an unknown format
80 * @param string|null $format ignored
82 * @return Content The UnknownContent object wrapping $data
84 public function unserializeContent( $blob, $format = null ) {
85 return new UnknownContent( $blob, $this->getModelID() );
89 * Creates an empty UnknownContent object.
93 * @return Content A new UnknownContent object with empty text.
95 public function makeEmptyContent() {
96 return $this->unserializeContent( '' );
102 public function supportsDirectEditing() {
107 * @param IContextSource $context
109 * @return SlotDiffRenderer
111 protected function getSlotDiffRendererInternal( IContextSource
$context ) {
112 return new UnsupportedSlotDiffRenderer( $context );