Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 13
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 / 13
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 / 1
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     */
80    public function getNativeData() {
81        return $this->getWorkflowId();
82    }
83
84    /**
85     * Returns the content's nominal size in bogo-bytes.
86     *
87     * @return int
88     */
89    public function getSize() {
90        return 1;
91    }
92
93    /**
94     * Return a copy of this Content object. The following must be true for the
95     * object returned:
96     *
97     * if $copy = $original->copy()
98     *
99     * - get_class($original) === get_class($copy)
100     * - $original->getModel() === $copy->getModel()
101     * - $original->equals( $copy )
102     *
103     * If and only if the Content object is immutable, the copy() method can and
104     * should return $this. That is, $copy === $original may be true, but only
105     * for immutable content objects.
106     *
107     * @since 1.21
108     *
109     * @return Content A copy of this object
110     */
111    public function copy() {
112        return $this;
113    }
114
115    /**
116     * Returns true if this content is countable as a "real" wiki page, provided
117     * that it's also in a countable location (e.g. a current revision in the
118     * main namespace).
119     *
120     * @since 1.21
121     *
122     * @param bool|null $hasLinks If it is known whether this content contains
123     *    links, provide this information here, to avoid redundant parsing to
124     *    find out.
125     *
126     * @return bool
127     */
128    public function isCountable( $hasLinks = null ) {
129        return true;
130    }
131
132    /**
133     * @return UUID|null
134     */
135    public function getWorkflowId() {
136        return $this->workflowId;
137    }
138}