Compiles the specified pages into HTML output.

@param  string $output
@return self
163909
public function compile($output)
    {
        file_exists($output) || mkdir($output);

        $this->clear((string) $output);

        $this->output = (string) $output;

        foreach ((array) $this->pages as $page) {
            $folder = $this->folder($output, $page->uris());

            $html = (string) $this->html($page);

            $path = $this->realpath($output . '/' . $folder);

            file_put_contents($path . 'index.html', $html);
        }

        return $this;
    }
41618
private function makeReplace($output){
		$replaced = $output;

		foreach($this->_direct_replace as $key => $val){
			$needle = '{' . strtoupper(trim($key, '{} ')) . '}';

			$replaced = str_replace($needle, $val, $replaced);
		}

		return $replaced;
	}
352491
public function finalize($output=null)
	{
	    $response = $this->getResponse();
	    if ($output instanceof ResponseInterface) {
	        $response = $output;
	    } elseif (is_string($output) && !empty($output) && $response->getBody()->isWritable()) {
	        if (Config::getCommon('response.outputBuffering') === 'prepend') {
	            // prepend output buffer content
	            $body = new Body(fopen('php://temp', 'r+'));
	            $body->write($output . $response->getBody());
	            $response = $response->withBody($body);
	        } else {
	            // append output buffer content
	            $response->getBody()->write($output);
	        }
	    }
	    
	    // stop PHP sending a Content-Type automatically
	    ini_set('default_mimetype', '');
	    
	    if ($this->isEmptyResponse($response)) {
	        return $response->withoutHeader('Content-Type')->withoutHeader('Content-Length');
	    }
	    
	    if (!$response->hasHeader('Content-Type')) {
	        $response = $response->withHeader('Content-Type', 'text/html; charset=UTF-8');
	    }
	    
	    // Add Content-Length header if `addContentLengthHeader` is set
	    if (Config::getCommon('response.addContentLengthHeader')) {
	        if (ob_get_length() > 0) {
	            throw new \RuntimeException("Unexpected data in output buffer. " .
	                "Maybe you have characters before an opening <?php tag?");
	        }
	        
	        $size = $response->getBody()->getSize();
	        if ($size !== null && !$response->hasHeader('Content-Length')) {
	            $response = $response->withHeader('Content-Length', (string) $size);
	        }
	    }
	    
	    return $response;
	}
1050439
public function export_for_template(\renderer_base $output) {
        $data = new \stdClass();
        $data->channellink = clean_param($this->channelurl, PARAM_URL);
        if ($this->manageurl) {
            $data->hasfailedfeeds = true;
            $data->manageurl = clean_param($this->manageurl, PARAM_URL);
        }

        return $data;
    }
153072
public function export_for_template(renderer_base $output) {
        if ($this->record->nextpageurl && $this->record->nextpageurl instanceof moodle_url) {
            $this->record->nextpageurl = $this->record->nextpageurl->out(false);
        }
        if ($this->record->prevpageurl && $this->record->prevpageurl instanceof moodle_url) {
            $this->record->prevpageurl = $this->record->prevpageurl->out(false);
        }
        if ($this->record->exclusiveurl && $this->record->exclusiveurl instanceof moodle_url) {
            $this->record->exclusiveurl = $this->record->exclusiveurl->out(false);
        }
        return $this->record;
    }
1275172
public function processOutput($output, $renderer)
    {
        $output = parent::processOutput($output, $renderer);

        $c = Kwf_Component_Data_Root::getInstance()->getComponentById($this->_componentId);
        $recipient = $c->getComponent()->getRecipient();
        $redirectComponent = $c->getChildComponent('_redirect');
        if ($redirectComponent && $recipient) {
            $redirectComponent = $redirectComponent->getComponent();
            $output = $redirectComponent->replaceLinks($output, $recipient, 'html');
        }
        return $output;
    }
1079190
public function export_for_template(renderer_base $output) {
        $data = new stdClass();

        // Set tab URLs.
        $coursecaturl = new moodle_url('/admin/tool/dataprivacy/defaults.php', ['mode' => CONTEXT_COURSECAT]);
        $courseurl = new moodle_url('/admin/tool/dataprivacy/defaults.php', ['mode' => CONTEXT_COURSE]);
        $moduleurl = new moodle_url('/admin/tool/dataprivacy/defaults.php', ['mode' => CONTEXT_MODULE]);
        $blockurl = new moodle_url('/admin/tool/dataprivacy/defaults.php', ['mode' => CONTEXT_BLOCK]);
        $data->coursecaturl = $coursecaturl;
        $data->courseurl = $courseurl;
        $data->moduleurl = $moduleurl;
        $data->blockurl = $blockurl;

        // Set display mode.
        switch ($this->mode) {
            case CONTEXT_COURSECAT:
                $data->modecoursecat = true;
                break;
            case CONTEXT_COURSE:
                $data->modecourse = true;
                break;
            case CONTEXT_MODULE:
                $data->modemodule = true;
                break;
            case CONTEXT_BLOCK:
                $data->modeblock = true;
                break;
            default:
                $data->modecoursecat = true;
                break;
        }

        // Set config variables.
        $configname = \context_helper::get_class_for_level($this->mode);
        list($purposevar, $categoryvar) = data_registry::var_names_from_context($configname);
        $data->categoryvar = $categoryvar;
        $data->purposevar = $purposevar;

        // Set default category.
        $data->categoryid = $this->category;
        $data->category = category_exporter::get_name($this->category);

        // Set default purpose.
        $data->purposeid = $this->purpose;
        $data->purpose = purpose_exporter::get_name($this->purpose);

        // Set other defaults.
        $otherdefaults = [];
        $url = new moodle_url('#');
        foreach ($this->otherdefaults as $pluginname => $values) {
            $defaults = [
                'name' => $values->name,
                'category' => category_exporter::get_name($values->category),
                'purpose' => purpose_exporter::get_name($values->purpose),
            ];
            if ($this->canedit) {
                $actions = [];
                // Edit link.
                $editattrs = [
                    'data-action' => 'edit-activity-defaults',
                    'data-contextlevel' => $this->mode,
                    'data-activityname' => $pluginname,
                    'data-category' => $values->category,
                    'data-purpose' => $values->purpose,
                ];
                $editlink = new action_menu_link_primary($url, new \pix_icon('t/edit', get_string('edit')),
                    get_string('edit'), $editattrs);
                $actions[] = $editlink->export_for_template($output);

                // Delete link.
                $deleteattrs = [
                    'data-action' => 'delete-activity-defaults',
                    'data-contextlevel' => $this->mode,
                    'data-activityname' => $pluginname,
                    'data-activitydisplayname' => $values->name,
                ];
                $deletelink = new action_menu_link_primary($url, new \pix_icon('t/delete', get_string('delete')),
                    get_string('delete'), $deleteattrs);
                $actions[] = $deletelink->export_for_template($output);

                $defaults['actions'] = $actions;
            }
            $otherdefaults[] = (object)$defaults;
        }
        $data->otherdefaults = $otherdefaults;

        $data->canedit = $this->canedit;
        $data->contextlevel = $this->mode;

        return $data;
    }
444715
protected function injectDebugBar($output)
    {
        if (!($debugBarConfig = Lb::app()->getConfigByName('debugbar'))) {
            return $output;
        }
        if (empty($debugBarConfig['enabled'])) {
            return $output;
        }
        if (empty($debugBarConfig['baseUrl'])) {
            return $output;
        }
        if (empty($debugBarConfig['basePath'])) {
            return $output;
        }

        /**
         * @var StandardDebugBar $debugBar
         */
        $debugBar = DebugBar::getInstance();
        $debugBarRenderer = $debugBar->getJavascriptRenderer($debugBarConfig['baseUrl'], $debugBarConfig['basePath']);
        $debugBarComponent = $debugBarRenderer->renderHead() . $debugBarRenderer->render();
        $replace = <<<EOF
{$debugBarComponent}
</body>
EOF;
        return str_replace('</body>', $replace, $output);
    }
516416
function appendOutput($output) {
		if ($this->finalOutput == '') {
			$this->finalOutput = $output;
		} else {
			$this->finalOutput .= $output;
		}
		
		return $this;
	}
67789
public function export_for_template(renderer_base $output) {
        $data = new stdClass();

        $keyhelp = new help_icon('resourcekey', 'mod_lti');
        $secrethelp = new help_icon('password', 'mod_lti');

        $url = new moodle_url('/mod/lti/typessettings.php', array('sesskey' => sesskey(), 'returnto' => 'toolconfigure'));
        $data->configuremanualurl = $url->out();
        $url = new moodle_url('/admin/settings.php?section=modsettinglti');
        $data->managetoolsurl = $url->out();
        $url = new moodle_url('/mod/lti/toolproxies.php');
        $data->managetoolproxiesurl = $url->out();
        $data->keyhelp = $keyhelp->export_for_template($output);
        $data->secrethelp = $secrethelp->export_for_template($output);
        return $data;
    }
1239096
public function setOutput(\Parable\Http\Output\OutputInterface $output)
    {
        $this->output = $output;
        $this->output->init($this);
        return $this;
    }
386661
public function setOutput($output, ? string $wrapper = null)
    {
        if ($wrapper) {
            $this->setOutputWrapper($wrapper);
        }

        return tap($this, function ($instance) use ($output) {
            $instance->output = $output;
        });
    }
112288
public function export_for_template(renderer_base $output) {
        $data = parent::export_for_template($output);
        $data->courseid = $this->course->id;
        return $data;
    }
640860
public function write($output)
    {
        $resource = fopen('php://temp', 'r+');

        ! $resource && $resource = null;

        $stream = new Stream($resource);

        $stream->write((string) $output);

        $this->stream = $stream;

        return $this;
    }
60242
public function output($output) {
		return fwrite($this->output, Text::insert($output, $this->styles()));
	}
290108
private function writeToOutputNow($output)
    {
        if ($this->sendHttpCode() && \Whoops\Util\Misc::canSendHeaders()) {
            $httpCode   = $this->sendHttpCode();

            if (function_exists('http_response_code')) {
                http_response_code($httpCode);
            } else {
                // http_response_code is added in 5.4.
                // For compatibility with 5.3 we use the third argument in header call
                // First argument must be a real header.
                // If it is empty, PHP will ignore the third argument.
                // If it is invalid, such as a single space, Apache will handle it well,
                // but the PHP development server will hang.
                // Setting a full status line would require us to hardcode
                // string values for all different status code, and detect the protocol.
                // which is an extra error-prone complexity.
                header('X-Ignore-This: 1', true, $httpCode);
            }
        }

        echo $output;

        return $this;
    }
490739
public function export_for_template(renderer_base $output) {
        global $PAGE;

        $context = \context_system::instance();

        $PAGE->requires->js_call_amd('tool_dataprivacy/categoriesactions', 'init');
        $PAGE->requires->js_call_amd('tool_dataprivacy/add_category', 'getInstance', [$context->id]);

        $data = new stdClass();

        // Navigation links.
        $data->navigation = [];
        $navigationlinks = $this->get_navigation();
        foreach ($navigationlinks as $navlink) {
            $data->navigation[] = $navlink->export_for_template($output);
        }

        $data->categories = [];
        foreach ($this->categories as $category) {
            $exporter = new category_exporter($category, ['context' => \context_system::instance()]);
            $exportedcategory = $exporter->export($output);

            $actionmenu = $this->action_menu('category', $exportedcategory, $category);
            $exportedcategory->actions = $actionmenu->export_for_template($output);
            $data->categories[] = $exportedcategory;
        }

        return $data;
    }