/** * Builds and returns the HTML representing a whole WikibaseEntity. * * @note: The HTML returned by this method may contain placeholders. Such placeholders can be * expanded with the help of TextInjector::inject() calling back to * EntityViewPlaceholderExpander::getExtraUserLanguages() * @note: In order to keep the list of placeholders small, this calls resetPlaceholders(). * * @since 0.1 * * @param EntityRevision $entityRevision the entity to render * * @return string HTML */ public function getHtml(EntityRevision $entityRevision) { $entity = $entityRevision->getEntity(); $entityId = $entity->getId() ?: 'new'; // if id is not set, use 'new' suffix for css classes $html = $this->templateFactory->render('wikibase-entityview', $entity->getType(), $entityId, $this->language->getCode(), $this->language->getDir(), $this->getMainHtml($entityRevision), $this->getSideHtml($entity)); return $html; }
/** * Generates the HTML for a single snak. * * @param Snak $snak * @param bool $showPropertyLink * * @return string */ public function getSnakHtml(Snak $snak, $showPropertyLink = false) { $snakViewVariation = $this->getSnakViewVariation($snak); $snakViewCssClass = 'wikibase-snakview-variation-' . $snakViewVariation; $formattedValue = $this->getFormattedSnakValue($snak); if ($formattedValue === '') { $formattedValue = ' '; } $propertyLink = $showPropertyLink ? $this->makePropertyLink($snak) : ''; $html = $this->templateFactory->render('wikibase-snakview', $propertyLink, $snakViewCssClass, $formattedValue); return $html; }
/** * @param string $cssClassSuffix * @param string $buttonLabel the message to show on the toolbar button link * @param string|null $editUrl The edit url * * @return string */ private function getToolbarButton($cssClassSuffix, $buttonLabel, $editUrl = null) { if ($editUrl === null) { return ''; } return $this->templateFactory->render('wikibase-toolbar-button', 'wikibase-toolbar-button-' . $cssClassSuffix, $editUrl, $buttonLabel); }
/** * @param Statement[] $statements * @param string $addStatementHtml * * @return string HTML */ private function getHtmlForStatementListView(array $statements, $addStatementHtml) { $statementViewsHtml = ''; foreach ($statements as $statement) { $statementViewsHtml .= $this->claimHtmlGenerator->getHtmlForClaim($statement, $this->editSectionGenerator->getStatementEditSection($statement instanceof Statement ? $statement : new Statement($statement))); } return $this->templateFactory->render('wikibase-statementlistview', $statementViewsHtml, $addStatementHtml); }
/** * Generates the HTML for a list of snaks. * * @param Snak[] $snaks * * @return string HTML */ private function getSnaklistviewHtml(array $snaks) { $snaksHtml = ''; $i = 0; foreach ($snaks as $snak) { $snaksHtml .= $this->snakHtmlGenerator->getSnakHtml($snak, $i++ === 0); } return $this->templateFactory->render('wikibase-snaklistview', $snaksHtml); }
/** * @param string $key * * @return string HTML */ private function getHtmlForSectionHeading($key) { /** * Message keys: * wikibase-statementsection-statements * wikibase-statementsection-identifiers */ $msg = wfMessage('wikibase-statementsection-' . strtolower($key)); $className = 'wikibase-statements'; if ($key === 'statements') { $id = 'claims'; } else { $id = $key; $className .= ' wikibase-statements-' . $key; } // TODO: Add link to SpecialPage that allows adding a new statement. return $this->templateFactory->render('wb-section-heading', $msg->escaped(), $id, $className); }
private function getHtmlForBadges(SiteLink $siteLink) { $html = ''; foreach ($siteLink->getBadges() as $badge) { $serialization = $badge->getSerialization(); $classes = Sanitizer::escapeClass($serialization); if (!empty($this->badgeItems[$serialization])) { $classes .= ' ' . Sanitizer::escapeClass($this->badgeItems[$serialization]); } $html .= $this->templateFactory->render('wb-badge', $classes, $this->entityIdFormatter->formatEntityId($badge), $badge); } return $this->templateFactory->render('wikibase-badgeselector', $html); }
/** * @param AliasGroupList $aliasGroups * @param string $languageCode * * @return string HTML */ private function getAliasesView(AliasGroupList $aliasGroups, $languageCode) { if (!$aliasGroups->hasGroupForLanguage($languageCode)) { return $this->templateFactory->render('wikibase-aliasesview', 'wb-empty', '', ''); } else { $aliasesHtml = ''; $aliases = $aliasGroups->getByLanguage($languageCode)->getAliases(); foreach ($aliases as $alias) { $aliasesHtml .= $this->templateFactory->render('wikibase-aliasesview-list-item', htmlspecialchars($alias)); } return $this->templateFactory->render('wikibase-aliasesview', '', $aliasesHtml, ''); } }