/** * @return array */ protected function getFormFields() { // Allow the collaboration hub to be passed via parameter (full page title) ?collaborationhub= // Allow the feature name to be passed via parameter (subpage title) ?feature= if ($this->getRequest()->getVal('collaborationhub')) { $defaultCollabHub = $this->getRequest()->getVal('collaborationhub'); } else { $defaultCollabHub = ''; } if ($this->getRequest()->getVal('feature')) { $defaultFeatureName = $this->getRequest()->getVal('feature'); } else { $defaultFeatureName = ''; } $icons = CollaborationKitIcon::getCannedIcons(); $iconChoices = array_combine($icons, $icons); $fields = ['collaborationhub' => ['type' => 'title', 'cssclass' => 'mw-ck-title-input', 'label-message' => 'collaborationkit-createhubfeature-collaborationhub', 'default' => $defaultCollabHub], 'featurename' => ['type' => 'text', 'cssclass' => 'mw-ck-display-input', 'label-message' => 'collaborationkit-createhubfeature-featurename', 'default' => $defaultFeatureName], 'icon' => ['type' => 'combobox', 'cssclass' => 'mw-ck-icon-input', 'label-message' => 'collaborationkit-createhubfeature-icon', 'options' => $iconChoices], 'contenttype' => ['type' => 'radio', 'cssclass' => 'mw-ck-content-type-input', 'label-message' => 'collaborationkit-createhubfeature-contenttype', 'options' => [$this->msg('collaborationkit-createhubfeature-freetext')->text() => 'wikitext', $this->msg('collaborationkit-createhubfeature-articlelist')->text() => 'CollaborationListContent']]]; // If either of these fields is set, that means the user came to the special page // by way of a special workflow, meaning that the name of the hub and/or the feature // is already known. Changing it would cause problems (e.g. the hub saying the feature // is called one thing and then the user changes their mind) so we disable further edits // in the middle of the workflow. if ($defaultCollabHub != '') { $fields['collaborationhub']['readonly'] = true; } if ($defaultFeatureName != '') { $fields['featurename']['readonly'] = true; } return $fields; }
/** * Generate an in icon using a canned CK icon * @param $icon string icon id or random seed * @param $size int intended height/width for rendered icon in px * @param $fallback string what to do for no icon; allowed values are 'random', 'none', or a valid icon id * @return string html */ public static function makeIcon($icon, $size = 50, $colour, $background = 'transparent') { $iconsPreset = CollaborationKitIcon::getCannedIcons(); if (in_array($icon, $iconsPreset)) { $iconClass = Sanitizer::escapeClass($icon); } else { // Random time // Choose class name using $icon value as seed $iconClass = $iconsPreset[hexdec(sha1($icon)[0]) % 27]; } if (!isset($colour) || $colour == 'black') { $colorSuffix = ''; } else { $colorSuffix = '-' . $colour; } return Html::element('div', ['class' => ['mw-ck-icon', 'mw-ck-icon-' . $iconClass . $colorSuffix], 'css' => "height: {$size}px; width: {$size}px; background-color: {$background};"]); }