/**
  * @return array
  */
 protected function getFormFields()
 {
     $fields = ['title' => ['type' => 'text', 'cssclass' => 'mw-ck-title-input', 'label-message' => 'collaborationkit-createhub-title'], 'display_name' => ['type' => 'text', 'cssclass' => 'mw-ck-display-input', 'label-message' => 'collaborationkit-createhub-displayname'], 'icon' => ['type' => 'text', 'cssclass' => 'mw-ck-icon-input', 'label-message' => 'collaborationkit-createhub-image']];
     // Colours for the hub styles
     $colours = [];
     foreach (CollaborationHubContent::getThemeColours() as $colour) {
         $colours['collaborationkit-' . $colour] = $colour;
     }
     $fields['colour'] = ['type' => 'select', 'cssclass' => 'mw-ck-colour-input', 'id' => 'wpCollabHubColour', 'label-message' => 'collaborationkit-createhub-colour', 'options' => $this->getOptions($colours), 'default' => 'blue5'];
     /* Comment this out until it's actually implemented (T135408)
     		// Content source options
     		$fields['content_source'] = [
     			'type' => 'select',
     			'options' => $this->getOptions( [
     				'collaborationkit-createhub-new' => 'new',
     				'collaborationkit-createhub-import' => 'import',
     				'collaborationkit-createhub-clone' => 'clone',
     			] ),
     			'default' => 'new', // might want to change default to clone from the default? (TODO add a canned default as example and stuff: T136470)
     			'label-message' => 'collaborationkit-createhub-content',
     			'cssclass' => 'mw-ck-source-options-input'
     		];
     		$fields['source'] = [
     			'type' => 'text',
     			'label-message' => 'collaborationkit-createhub-source',
     			'hide-if' => [ '===', 'wpcontent_source', 'new' ],
     			'cssclass' => 'mw-ck-source-input'
     		];
     		*/
     $fields['introduction'] = ['type' => 'textarea', 'rows' => 5, 'label-message' => 'collaborationkit-createhub-introduction', 'cssclass' => 'mw-ck-introduction-input'];
     return $fields;
 }
 /**
  * Constructs a CollaborationHubContent object. Does not perform any validation,
  * as that is done at a later step (to allow for outputting of invalid content for
  * debugging purposes.)
  *
  * @param $text string
  * @param $format string|null
  * @return CollaborationHubContent
  */
 public function unserializeContent($text, $format = null)
 {
     $this->checkFormat($format);
     if ($format === self::FORMAT_WIKI) {
         $data = CollaborationHubContent::convertFromHumanEditable($text);
         $text = FormatJson::encode($data);
     }
     $content = new CollaborationHubContent($text);
     // Deliberately not validating at this step; validation is done later.
     return $content;
 }
 /**
  * For the table of contents on subpages of a CollaborationHub
  *
  * @param $out OutputPage
  * @param $text string the HTML text to be added
  * @return bool
  */
 public static function onOutputPageBeforeHTML(&$out, &$text)
 {
     $title = $out->getTitle();
     $parentHub = CollaborationHubContent::getParentHub($title);
     if ($parentHub && $out->getProperty('CollaborationHubSubpage') === 'in-progress' && count(Revision::newFromTitle($parentHub)->getContent()->getContent()) > 0) {
         $toc = new CollaborationHubTOC();
         $out->prependHtml($toc->renderSubpageToC($parentHub));
         $colour = Revision::newFromTitle($parentHub)->getContent()->getThemeColour();
         $text = Html::rawElement('div', ['class' => "mw-cklist-square-{$colour}"], $text);
         $out->addModuleStyles('ext.CollaborationKit.hubsubpage.styles');
         $out->addModules('ext.CollaborationKit.icons');
         $out->addModules('ext.CollaborationKit.blots');
         // Set this mostly just so we can make sure this entire thing hasn't already been done, because otherwise the ToC is added twice on edit for some reason
         $out->setProperty('CollaborationHubSubpage', true);
     }
     return true;
 }
 /**
  * @param $parts array
  * @return array
  */
 protected function getFormFields($parts)
 {
     $fields = ['display_name' => new OOUI\FieldLayout(new OOUI\TextInputWidget(['name' => 'wpCollabHubDisplayName', 'id' => 'wpCollabHubDisplayName', 'type' => 'text', 'cssclass' => 'mw-ck-displayinput', 'value' => $parts[0]]), ['label' => wfMessage('collaborationkit-hubedit-displayname')->text(), 'align' => 'top']), 'introduction' => new OOUI\FieldLayout(new OOUI\TextInputWidget(['multiline' => true, 'name' => 'wpCollabHubIntroduction', 'id' => 'wpCollabHubIntroduction', 'type' => 'textarea', 'rows' => 5, 'cssclass' => 'mw-ck-introductioninput', 'value' => $parts[1]]), ['label' => wfMessage('collaborationkit-hubedit-introduction')->text(), 'align' => 'top']), 'footer' => new OOUI\FieldLayout(new OOUI\TextInputWidget(['multiline' => true, 'name' => 'wpCollabHubFooter', 'id' => 'wpCollabHubFooter', 'type' => 'textarea', 'rows' => 5, 'cssclass' => 'mw-ck-introductioninput', 'value' => $parts[2]]), ['label' => wfMessage('collaborationkit-hubedit-footer')->text(), 'align' => 'top']), 'image' => new OOUI\FieldLayout(new OOUI\TextInputWidget(['name' => 'wpCollabHubImage', 'id' => 'wpCollabHubImage', 'type' => 'text', 'cssclass' => 'mw-ck-hubimageinput', 'value' => $parts[3]]), ['label' => wfMessage('collaborationkit-hubedit-image')->text(), 'align' => 'top'])];
     // Colours for the hub styles
     $colours = [];
     foreach (CollaborationHubContent::getThemeColours() as $colour) {
         $colours['collaborationkit-' . $colour] = $colour;
     }
     if ($parts[4] == '') {
         $selectedColour = 'blue5';
     } else {
         $selectedColour = $parts[4];
     }
     $fields['colour'] = new OOUI\FieldLayout(new OOUI\DropdownInputWidget(['name' => 'wpCollabHubColour', 'id' => 'wpCollabHubColour', 'type' => 'select', 'options' => $this->getOptions($colours), 'class' => 'mw-ck-colourinput', 'value' => $selectedColour]), ['label' => wfMessage('collaborationkit-hubedit-colour')->text(), 'align' => 'top']);
     if ($parts[5] == '') {
         $includedContent = '';
     } else {
         $includedContent = $parts[5];
     }
     $fields['content'] = new OOUI\FieldLayout(new OOUI\TextInputWidget(['multiline' => true, 'name' => 'wpCollabHubContent', 'id' => 'wpCollabHubContent', 'type' => 'textarea', 'rows' => 10, 'class' => 'mw-ck-introductioninput', 'value' => $includedContent]), ['label' => wfMessage('collaborationkit-hubedit-content')->text(), 'align' => 'top']);
     return $fields;
 }
 /**
  * @dataProvider provideContentObjs
  */
 public function testContent(CollaborationHubContent $content, $id)
 {
     $expected = [[["title" => "Me!", "image" => "cool.png", "displayTitle" => null]], [], []];
     $actual = $content->getContent();
     $this->assertEquals($expected[$id], $actual, $id);
 }