Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 9
CRAP
0.00% covered (danger)
0.00%
0 / 1
BoardContent
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 9
110
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getTextForSearchIndex
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getWikitextForTransclusion
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTextForSummary
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 getNativeData
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getSize
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 copy
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 isCountable
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getWorkflowId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Flow\Content;
4
5use Flow\Model\UUID;
6use MediaWiki\Content\AbstractContent;
7use MediaWiki\Content\Content;
8
9class BoardContent extends AbstractContent {
10    /** @var UUID|null */
11    protected $workflowId;
12
13    public function __construct( $contentModel = CONTENT_MODEL_FLOW_BOARD, ?UUID $workflowId = null ) {
14        parent::__construct( $contentModel );
15        $this->workflowId = $workflowId;
16    }
17
18    /**
19     * @since 1.21
20     *
21     * @return string A string representing the content in a way useful for
22     *   building a full text search index. If no useful representation exists,
23     *   this method returns an empty string.
24     *
25     * @todo Test that this actually works
26     * @todo Make sure this also works with LuceneSearch / WikiSearch
27     */
28    public function getTextForSearchIndex() {
29        return '';
30    }
31
32    /**
33     * @since 1.21
34     *
35     * @return string The wikitext to include when another page includes this
36     * content, or false if the content is not includable in a wikitext page.
37     *
38     * @todo Allow native handling, bypassing wikitext representation, like
39     *  for includable special pages.
40     * @todo Allow transclusion into other content models than Wikitext!
41     * @todo Used in WikiPage and MessageCache to get message text. Not so
42     *  nice. What should we use instead?!
43     */
44    public function getWikitextForTransclusion() {
45        return '<span class="error">' . wfMessage( 'flow-embedding-unsupported' )->plain() . '</span>';
46    }
47
48    /**
49     * Returns a textual representation of the content suitable for use in edit
50     * summaries and log messages.
51     *
52     * @since 1.21
53     *
54     * @param int $maxLength Maximum length of the summary text.
55     *
56     * @return string|false The summary text.
57     */
58    public function getTextForSummary( $maxLength = 250 ) {
59        $workflow = $this->getWorkflowId();
60        if ( !$workflow ) {
61            // This shouldn't happen but some Flow boards have no workflow
62            // due to ancient bugs, so don't crash
63            return '[Corrupt Flow board]';
64        }
65        return '[Flow board ' . $workflow->getAlphadecimal() . ']';
66    }
67
68    /**
69     * Returns native representation of the data. Interpretation depends on
70     * the data model used, as given by getDataModel().
71     *
72     * @since 1.21
73     *
74     * @return UUID|null The native representation of the content. Could be a
75     *    string, a nested array structure, an object, a binary blob...
76     *    anything, really.
77     *
78     * @note Caller must be aware of content model!
79     * @deprecated since 1.33; use ::getWorkflowId() instead.
80     */
81    public function getNativeData() {
82        wfDeprecated( __METHOD__, '1.33' );
83        return $this->getWorkflowId();
84    }
85
86    /**
87     * Returns the content's nominal size in bogo-bytes.
88     *
89     * @return int
90     */
91    public function getSize() {
92        return 1;
93    }
94
95    /**
96     * Return a copy of this Content object. The following must be true for the
97     * object returned:
98     *
99     * if $copy = $original->copy()
100     *
101     * - get_class($original) === get_class($copy)
102     * - $original->getModel() === $copy->getModel()
103     * - $original->equals( $copy )
104     *
105     * If and only if the Content object is immutable, the copy() method can and
106     * should return $this. That is, $copy === $original may be true, but only
107     * for immutable content objects.
108     *
109     * @since 1.21
110     *
111     * @return Content A copy of this object
112     */
113    public function copy() {
114        return $this;
115    }
116
117    /**
118     * Returns true if this content is countable as a "real" wiki page, provided
119     * that it's also in a countable location (e.g. a current revision in the
120     * main namespace).
121     *
122     * @since 1.21
123     *
124     * @param bool|null $hasLinks If it is known whether this content contains
125     *    links, provide this information here, to avoid redundant parsing to
126     *    find out.
127     *
128     * @return bool
129     */
130    public function isCountable( $hasLinks = null ) {
131        return true;
132    }
133
134    /**
135     * @return UUID|null
136     */
137    public function getWorkflowId() {
138        return $this->workflowId;
139    }
140}