{if $object->status == "SUCCESSFUL"}
{if $object->isPlainUrl()}
- <a {anchorAttributes url=$object->url isUgc=true}>{$object->title}</a>
+ <a {anchorAttributes url=$object->url isUgc=$enableUgc}>{$object->title}</a>
{else}
<div class="
unfurlUrlCard
<div class="unfurlUrlDescription">{$object->description}</div>
<div class="unfurlUrlHost">{$object->getHost()}</div>
</div>
- <a class="unfurlUrlLinkShadow" {anchorAttributes url=$object->url appendClassname=false isUgc=true}></a>
+ <a class="unfurlUrlLinkShadow" {anchorAttributes url=$object->url appendClassname=false isUgc=$enableUgc}></a>
</div>
{/if}
{else}
- <a {anchorAttributes url=$object->url isUgc=true}>{$object->url}</a>
+ <a {anchorAttributes url=$object->url isUgc=$enableUgc}>{$object->url}</a>
{/if}
\ No newline at end of file
/**
* Renders the unfurl url card and returns the template.
*/
- public function render(): string
+ public function render(bool $enableUgc = true): string
{
return WCF::getTPL()->fetch('unfurlUrl', 'wcf', [
'object' => $this,
+ 'enableUgc' => $enableUgc,
]);
}
use wcf\system\html\node\AbstractHtmlNodeProcessor;
use wcf\system\html\node\HtmlNodeUnfurlLink;
+use wcf\system\html\output\HtmlOutputProcessor;
use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
use wcf\util\StringUtil;
&& !empty($attribute)
&& MessageEmbeddedObjectManager::getInstance()->getObject('com.woltlab.wcf.unfurlUrl', $attribute) !== null
) {
+ $enableUgc = true;
+ $processor = $htmlNodeProcessor->getHtmlProcessor();
+ if ($processor instanceof HtmlOutputProcessor) {
+ $enableUgc = $processor->enableUgc;
+ }
+
$nodeIdentifier = StringUtil::getRandomID();
- $htmlNodeProcessor->addNodeData($this, $nodeIdentifier, ['urlId' => $attribute]);
+ $htmlNodeProcessor->addNodeData($this, $nodeIdentifier, [
+ 'urlId' => $attribute,
+ 'enableUgc' => $enableUgc,
+ ]);
$htmlNodeProcessor->renameTag($element, 'wcfNode-' . $nodeIdentifier);
}
*/
public function replaceTag(array $data)
{
- return MessageEmbeddedObjectManager::getInstance()->getObject('com.woltlab.wcf.unfurlUrl', $data['urlId'])->render();
+ /** @var \wcf\data\unfurl\url\UnfurlUrl $object */
+ $object = MessageEmbeddedObjectManager::getInstance()->getObject('com.woltlab.wcf.unfurlUrl', $data['urlId']);
+ return $object->render($data['enableUgc']);
}
}