/** * Prepare JSON description of the UI Styleguide component * * @param \Wikia\UI\Component $component * @param \Wikia\UI\Factory $factory * @return dictionary describing the component */ private function getComponentConfig($component, $factory) { $componentResult = []; $componentResult['templateVarsConfig'] = $component->getTemplateVarsConfig(); $componentResult['templates'] = []; $componentResult['name'] = $component->getName(); $componentResult['dependencies'] = $component->getComponentDependencies(); foreach (array_keys($componentResult['templateVarsConfig']) as $type) { $componentResult['templates'][$type] = $factory->loadComponentTemplateContent($component, $type); } $componentResult['assets'] = $factory->getComponentAssetsUrls($component); $jsModule = $component->getJSWrapperModule(); if (!empty($jsModule)) { $componentResult['jsWrapperModule'] = $jsModule; } return $componentResult; }
public function WikiWelcomeModal() { wfProfileIn(__METHOD__); $buttonParams = ['type' => 'button', 'vars' => ['type' => 'button', 'classes' => ['wikia-button', 'big', 'createpage'], 'value' => wfMessage('button-createpage')->text(), 'imageClass' => 'new', 'data' => ['key' => 'event', 'value' => 'createpage']]]; $this->title = wfMessage('cnw-welcome-headline', $this->app->wg->Sitename)->text(); $this->instruction1 = wfMessage('cnw-welcome-instruction1')->text(); $this->button = \Wikia\UI\Factory::getInstance()->init('button')->render($buttonParams); $this->help = wfMessage('cnw-welcome-help')->text(); $this->response->setTemplateEngine(WikiaResponse::TEMPLATE_ENGINE_MUSTACHE); wfProfileOut(__METHOD__); }
public function testRenderingMoreThanOneComponent() { list($a, $b, $c) = \Wikia\UI\Factory::getInstance()->init(['button', 'button', 'button']); /** @var \Wikia\UI\Component $a */ $aMarkup = $a->render(['type' => 'link', 'vars' => ['href' => 'http://www.wikia.com', 'classes' => ['small'], 'value' => 'Just a button in form of a link', 'title' => 'Link which looks like a button!']]); /** @var \Wikia\UI\Component $b */ $bMarkup = $b->render(['type' => 'button', 'vars' => ['type' => 'submit', 'classes' => ['small', 'blue'], 'value' => 'Just a button in form of a link', 'id' => ['uniqueButton'], 'disabled' => 'disabled', 'data' => [['key' => 'id', 'value' => 123], ['key' => 'name', 'value' => 'button']]]]); /** @var \Wikia\UI\Component $c */ $cMarkup = $c->render(['type' => 'input', 'vars' => ['type' => 'submit', 'name' => 'just-a-button', 'classes' => ['small', 'blue'], 'value' => 'Just a button in form of a link', 'id' => ['uniqueButton'], 'disabled' => 'disabled', 'data' => [['key' => 'id', 'value' => 123], ['key' => 'name', 'value' => 'button']]]]); $this->assertEquals('<a href="http://www.wikia.com" class="button small " title="Link which looks like a button!" target="" >Just a button in form of a link</a>', trim($aMarkup)); $this->assertEquals('<button type="submit" id="uniqueButton " class="button small blue " disabled data-id="123" data-name="button">Just a button in form of a link</button>', trim($bMarkup)); $this->assertEquals('<input type="submit" id="uniqueButton" class="button small blue " name="just-a-button" value="Just a button in form of a link" disabled data-id="123"data-name="button"/>', trim($cMarkup)); }
/** * Render Component Section TOC * * @param Array $components - array of components * @return String - HTML markup for Component Section TOC */ private function renderTOC($components) { $data = ["type" => "default", "vars" => ["id" => "styleguideTOC", "sections" => []]]; $sections =& $data["vars"]["sections"]; foreach ($components as $component) { $section = ["id" => $component["id"], "title" => $component["name"]]; $sections[] = $section; } // set first element as active if (isset($sections[0])) { $sections[0]["active"] = true; } return \Wikia\UI\Factory::getInstance()->init('toc')->render($data); }
/** * Get alert badge for AdminDashboard extension * @return string */ public function getAlertBadge() { $badge = ''; $newVideos = $this->getTotalNewVideos(); if (!empty($newVideos)) { $badgeParams = array('type' => 'default', 'vars' => array('number' => $newVideos)); $badge = \Wikia\UI\Factory::getInstance()->init('alert_badge')->render($badgeParams); } return $badge; }
/** * Entry point for requesting that an account is reactivated * * This is the form users will be taken to after successfully attempting * to login to an account that has requested closure. * * @responseParam boolean showForm - Whether or not to show the request form * @responseParam string error - Whether or not an error occurred * @responseParam string introText - The introductory text that explains the * reactivation process * @responseParam string submitButton - The HTML for the submit button * @return void */ public function reactivateRequest() { wfProfileIn(__METHOD__); $this->response->setTemplateEngine(WikiaResponse::TEMPLATE_ENGINE_MUSTACHE); $userId = $this->request->getSessionData('closeAccountSessionId'); $this->showForm = false; // Paranoia, if they got here, this shouldn't happen if ($userId === null) { $this->error = $this->msg('closemyaccount-reactivate-error-id')->escaped(); wfProfileOut(__METHOD__); return; } elseif ($this->getUser()->isLoggedIn()) { $this->error = $this->msg('closemyaccount-reactivate-error-logged-in')->escaped(); wfProfileOut(__METHOD__); return; } $helper = new CloseMyAccountHelper(); $userObj = User::newFromId($userId); if ($helper->isClosed($userObj)) { $this->error = $this->msg('closemyaccount-reactivate-error-disabled')->parse(); wfProfileOut(__METHOD__); return; } // Paranoia, shouldn't happen, but just in case... if (!$helper->isScheduledForClosure($userObj)) { $this->error = $this->msg('closemyaccount-reactivate-error-not-scheduled')->escaped(); wfProfileOut(__METHOD__); return; } if (!$userObj->isEmailConfirmed()) { $this->error = $this->msg('closemyaccount-reactivate-error-email')->parse(); wfProfileOut(__METHOD__); return; } $this->getOutput()->setPageTitle($this->msg('closemyaccount-reactivate-page-title')->plain()); if ($this->request->wasPosted()) { $result = $helper->requestReactivation($userObj, $this->app); if ($result) { $this->introText = $this->msg('closemyaccount-reactivate-requested')->parseAsBlock(); } else { $this->error = $this->msg('closemyaccount-reactivate-error-failed')->parse(); } } else { $this->showForm = true; // Show how many days they have before their account is permanently closed $daysUntilClosure = $helper->getDaysUntilClosure($userObj); $this->introText = $this->msg('closemyaccount-reactivate-intro', $this->getLanguage()->formatNum($daysUntilClosure), $userObj->getName())->parseAsBlock(); $buttonParams = ['type' => 'button', 'vars' => ['type' => 'submit', 'classes' => ['wikia-button', 'big', 'closemyaccount'], 'value' => $this->msg('closemyaccount-reactivate-button-text')->text(), 'data' => []]]; $this->submitButton = \Wikia\UI\Factory::getInstance()->init('button')->render($buttonParams); } wfProfileOut(__METHOD__); }
/** * @param $components */ private function initComponents($components) { foreach ($components as $component) { \Wikia\UI\Factory::getInstance()->init($component['id']); } }