<?php
/*========================================================================*\
|| ###################################################################### ||
|| # vBulletin 6.2.3 - Licence Number L3138846
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2026 MH Sub I, LLC dba vBulletin. All Rights Reserved.  # ||
|| # This file may not be redistributed in whole or significant part.   # ||
|| # ----------------- VBULLETIN IS NOT FREE SOFTWARE ----------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html   # ||
|| ###################################################################### ||
\*========================================================================*/

class vB5_Template_BbCode_DelayedRenderQueue
{
	const PLACEHOLDER_PREFIX = '<!-- ##bbcode_';
	const PLACEHOLDER_SUFFIX = '## -->';

	/**
	 * Singleton instance of this class.
	 *
	 * @var	vB5_Template_BbCode_DelayedRenderQueue
	 */
	protected static $instance;

	private array $delayedRenderQueueByNodeid = [];

	/**
	 * Singleton instance getter
	 *
	 * @return vB5_Template_BbCode_DelayedRenderQueue
	 */
	public static function instance()
	{
		if (!isset(self::$instance))
		{
			$c = __CLASS__;
			self::$instance = new $c;
		}

		return self::$instance;
	}

	public function getBbcodePlaceholder(int $nodeId, string $bbcode, string $data, string $option, array $bbCodeOptions, ?int $contentPage = null) : string
	{
		ksort($bbCodeOptions);
		$prefix = $nodeId . '_' . $bbcode . '_' . md5($option) . '|' . md5($data) . '|' . md5(json_encode($bbCodeOptions));
		if (!is_null($contentPage))
		{
			$prefix .= '|' . $contentPage;
		}

		$result = self::PLACEHOLDER_PREFIX . $prefix . self::PLACEHOLDER_SUFFIX;

		return $result;
	}

	public function registerDelayedRender(int $nodeid, string $placeholder, array $renderData) : void
	{
		$this->delayedRenderQueueByNodeid[$nodeid][$placeholder] = $renderData;
	}

	public function getDelayedRenderQueueForNodeid(int $nodeid) : array
	{
		return $this->delayedRenderQueueByNodeid[$nodeid] ?? [];
	}

	public function clearDelayedRenderQueueForNodeid(int $nodeid) : void
	{
		unset($this->delayedRenderQueueByNodeid[$nodeid]);
	}

}

/*=========================================================================*\
|| #######################################################################
|| # Downloaded: 13:27, Sun Aug 30th 2026
|| # CVS: $RCSfile$ - $Revision: 105283 $
|| #######################################################################
\*=========================================================================*/
