<?php

namespace Modules\Admin\Config\Assistant;

/**
 * Setup Guide popup view
 */
class View_SetupGuide extends \App\Mvc\View_Popup_GeneralAbstract
{

    protected $renderingTemplate=null;

    /**
     * Converts markdown content to HTML
     * @param string $markdownStr
     * @return string
     */
    public function convertMarkdownToHtml($markdownStr): string
    {
        $converter = new \League\CommonMark\CommonMarkConverter([
            'html_input' =>         'escape',
            'allow_unsafe_links' => true,
        ]);
        return $converter->convert($markdownStr);
    }

    /**
     * Render the view
     * @return string
     */
    public function render(): string
    {
        // Get the raw Markdown content from the controller
        $markdownContent = $this->getInput('content');
        // Convert to HTML
        $htmlContent = $this->convertMarkdownToHtml($markdownContent);
        // Set output variables for the template
        $this->setOutputVar('content', $htmlContent);

        // Set the title
        $this->setOutputVar('title', $this->getInput('title'));

        // Use the render_smarty method with our template
        return $this->render_smarty('setupGuide.tpl');
    }
}
