Includes the configured JS dependencies and appData - should
be called from the layout

@return     string    HTML
426476
public function run(): string
    {
        $out = '';
        $this->_dependencies = array_unique($this->_dependencies);

        $out .= $this->getNamespaceDefinitions();
        $this->addCurrentController();

        foreach ($this->_dependencies as $dependency) {
            if (strpos($dependency, DS) !== false) {
                $dependency = str_replace(DS, '/', $dependency);
            }
            $jsFile = $this->Html->script($dependency);
            $out .= $jsFile . "\n";
        }
        $out .= $this->getAppDataJs($this->_frontendData);
        $out .= $this->Html->script('/frontend_bridge/js/bootstrap.js');

        return $out;
    }
493282
public function renderView() {
		$config = $this->getAppContextProperty("config");
		$globalUser = $this->getAppContextProperty("globalUser");
		$pages = $this->getAppContextProperty("pages");
		$page = $this->getAppContextProperty("page");
		$data = $this->getAppContextProperty("data");
		$app_http = $this->getAppContextProperty("app_http");
		$controllerName = $this->getAppContextProperty("controllerName");
		$systemMessages = $this->getAppContextProperty("systemMessages");
		
		include "{$this->getViewPath()}layouts/header.lo.php";
		if (!empty($this->getViewFile())) {
			$parameters = $this->getViewVariables();
			include $this->getViewFile();
		}
		include "{$this->getViewPath()}layouts/footer.lo.php";
	}
1020127
public function getLoaderJS()
    {
        if ($this->newFile) {
            return '';
        }

        $r = '';

        $r .= $this->getProjectProperties();

        // FIRST STEP: Load all modules and entities
        $r .= $this->getModules();
        $r .= $this->getClasses();
        $r .= $this->getAbstracts();
        $r .= $this->getInterfaces();

        // SECOND STEP: Add the attributes
        $r .= $this->getAttributes();

        // THIRD STEP: After attributes entity properties
        $r .= $this->getClassLikeAfterAttributesProperties();

        // FOURTH STEP: Relationships
        $r .= $this->getRelationships();

        $r .= $this->getAutocodeProperties();

        // Finalise
        $r .= 'for (var i in Connectable.prototype.connectables) Connectable.prototype.connectables[i].reDraw();' . PHP_EOL;
        $r .= 'Link.prototype.reDrawLinks();' . PHP_EOL;
        $r .= 'System.prototype.runtime = true;' . PHP_EOL;

        return $r;
    }
1138207
public function renderToolModulesContentAction()
    {
        $melisKey = $this->params()->fromRoute('melisKey', '');
        $zoneConfig = $this->params()->fromRoute('zoneconfig', array());

        $modulesInfo = $this->getModuleSvc()->getModulesAndVersions();
        $modules = $this->getModules();
        //exclude MelisDemoCms cause it is SiteModule
        // it will complicate some default layout/layout of the melis-core
        unset($modules['MelisDemoCms']);
        unset($modulesInfo['MelisDemoCms']);

        $view = new ViewModel();

        $view->melisKey    = $melisKey;
        $view->modules     = $modules;
        $view->modulesInfo = $modulesInfo;

        return $view;
    }
471604
public function usageAction()
    {
        $this->assign('version', Samurai::getVersion());
        $this->assign('state', Samurai::getState());
        $this->assign('script', './app');   // TODO: $this->request->getScript()
        return self::VIEW_TEMPLATE;
    }
892808
public static function render() {
		$loaded_classes = \Application::get(['application', 'loaded_classes']);
		self::$data['session'] = [];
		if (!empty($_SESSION)) {
			self::$data['session'] = [$_SESSION];
		}
		$application = \Application::get();
		$result = '<div class="container" dir="ltr">';
			$result.= '<table cellpadding="2" cellspacing="2" width="100%">';
				$result.= '<tr>';
					$result.= '<td>';
						$result.= '<table width="100%" class="numbers_debug_links">';
							$result.= '<tr>';
								$result.= '<td nowrap>&nbsp;' . \HTML::a(['value' => 'Hide All', 'href' => 'javascript:void(0);', 'onclick' => "$('.debuging_toolbar_class').hide();"]) . '&nbsp;</td>';
								foreach (self::$data as $k => $v) {
									if ($k == 'errors') {
										$count = count(\Object\Error\Base::$errors);
									} else if ($k == 'classes') {
										$count = count($loaded_classes);
									} else if ($k == 'application') {
										$count = count($application);
									} else if ($k == 'phpinfo') {
										$count = 1;
									} else {
										$count = count($v);
									}
									$result.= '<td nowrap>&nbsp;' . \HTML::a(['value' => ucwords($k) . ' (' . $count . ')', 'id' => "debuging_toolbar_{$k}_a", 'href' => 'javascript:void(0);', 'onclick' => "$('#debuging_toolbar_{$k}').toggle();"]) . '&nbsp;</td>';
								}
								$result.= '<td width="50%" align="right">' . \HTML::a(['href' => '/Numbers/Backend/System/Modules/Controller/DevPortal', 'value' => 'Dev. Portal']) . '</td>';
							$result.= '</tr>';
						$result.= '</table>';
					$result.= '</td>';
				$result.= '</tr>';
				
				// errors
				$result.= '<tr id="debuging_toolbar_errors" class="debuging_toolbar_class" style="display: none;">';
					$result.= '<td>';
						$result.= '<h3>Errors (' . count(\Object\Error\Base::$errors) . ')</h3>';
						$result.= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
							foreach (\Object\Error\Base::$errors as $k => $v) {
								$result.= '<tr>';
									$result.= '<td><b>' . \Object\Error\Base::$error_codes[$v['errno']] . ' (' . $v['errno'] . ') - ' . implode('<br/>', $v['error']) . '</b></td>';
								$result.= '</tr>';
								$result.= '<tr>';
									$result.= '<td>File: ' . $v['file'] . ', Line: ' . $v['line'] . '</td>';
								$result.= '</tr>';
								$result.= '<tr>';
									$result.= '<td><pre>' . $v['code'] . '</pre></td>';
								$result.= '</tr>';
								$result.= '<tr>';
									$result.= '<td><pre>' . implode("\n", $v['backtrace']) . '</pre></td>';
								$result.= '</tr>';
							}
						$result.= '</table>';
					$result.= '</td>';
				$result.= '</tr>';

				// suppressed
				$result.= '<tr id="debuging_toolbar_suppressed" class="debuging_toolbar_class" style="display: none;">';
					$result.= '<td>';
						$result.= '<h3>Suppressed (' . count(self::$data['suppressed']) . ')</h3>';
						$result.= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
							foreach (self::$data['suppressed'] as $k => $v) {
								$result.= '<tr>';
									$result.= '<td><b>' . \Object\Error\Base::$error_codes[$v['errno']] . ' (' . $v['errno'] . ') - ' . implode('<br/>', $v['error']) . '</b></td>';
								$result.= '</tr>';
								$result.= '<tr>';
									$result.= '<td>File: ' . $v['file'] . ', Line: ' . $v['line'] . '</td>';
								$result.= '</tr>';
								$result.= '<tr>';
									$result.= '<td><pre>' . $v['code'] . '</pre></td>';
								$result.= '</tr>';
							}
						$result.= '</table>';
					$result.= '</td>';
				$result.= '</tr>';

				// javascript
				$result.= '<tr id="debuging_toolbar_js" class="debuging_toolbar_class" style="display: none;">';
					$result.= '<td>';
						$result.= '<h3>Javascript Errors (' . count(self::$data['js']) . ')</h3>';
						$result.= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
							foreach (self::$data['js'] as $k => $v) {
								$result.= '<tr>';
									$result.= '<td><b>' . implode('<br/>', $v['error']) . '</b></td>';
								$result.= '</tr>';
								$result.= '<tr>';
									$result.= '<td>File: ' . $v['file'] . ', Line: ' . $v['line'] . '</td>';
								$result.= '</tr>';
							}
						$result.= '</table>';
						$result.= '<div id="debuging_toolbar_js_data">';
							$result.= '&nbsp;';
						$result.= '</div>';
					$result.= '</td>';
				$result.= '</tr>';

				// benchmark
				$result.= '<tr id="debuging_toolbar_benchmark" class="debuging_toolbar_class" style="display: none;">';
					$result.= '<td>';
						$result.= '<h3>Benchmark (' . count(self::$data['benchmark']) . ')' . '</h3>';
						$result.= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
							$result.= '<tr>';
								$result.= '<th>Name</th>';
								$result.= '<th>Time</th>';
								$result.= '<th>Start</th>';
								$result.= '<th>Total</th>';
								$result.= '<th>Memory</th>';
							$result.= '</tr>';
							foreach (self::$data['benchmark'] as $k => $v) {
								$result.= '<tr>';
									$result.= '<td>' . $v['name'] . '</td>';
									$result.= '<td align="right">' . $v['time'] . '</td>';
									$result.= '<td align="right">' . $v['start'] . '</td>';
									$result.= '<td align="right">' . $v['total'] . '</td>';
									$result.= '<td align="right">' . Format::memory($v['memory'], 'm') . '</td>';
								$result.= '</tr>';
							}
						$result.= '</table>';
					$result.= '</td>';
				$result.= '</tr>';

				// sql
				$result.= '<tr id="debuging_toolbar_sql" class="debuging_toolbar_class" style="display: none;">';
					$result.= '<td>';
						$result.= '<h3>Sql (' . count(self::$data['sql']) . ')' . '</h3>';
						$result.= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
							foreach (self::$data['sql'] as $k => $v) {
								$temp = is_array($v['key']) ? implode('<br/>', $v['key']) : $v['key'];
								// header first
								$result.= '<tr>';
									$result.= '<th colspan="4" style="color: red;">Sql</th>';
								$result.= '</tr>';
								$result.= '<tr>';
									$result.= '<td valign="top" colspan="4"><pre style="width: 1130px;">' . $v['sql'] . '</pre></td>';
								$result.= '</tr>';
								$result.= '<tr>';
									$result.= '<th>Error</th>';
									$result.= '<th>Errno</th>';
									$result.= '<th>Num Rows</th>';
									$result.= '<th>Affected Rows</th>';
								$result.= '</tr>';
								$result.= '<tr>';
									$result.= '<td valign="top">' . implode('<br/>', $v['error']) . ' - ' . implode('<br/>', $v['error_original'] ?? []) . '</td>';
									$result.= '<td valign="top">' . $v['errno'] . '</td>';
									$result.= '<td valign="top">' . $v['num_rows'] . '</td>';
									$result.= '<td valign="top">' . $v['affected_rows'] . '</td>';
								$result.= '</tr>';
								$result.= '<tr>';
									$result.= '<th>Key</th>';
									$result.= '<th>Structure</th>';
									$result.= '<th>Cache</th>';
									$result.= '<th>Time</th>';
								$result.= '</tr>';
								$result.= '<tr>';
									$result.= '<td valign="top">' . $temp . '</td>';
									$result.= '<td valign="top">' . \HTML::table(['options' => $v['structure']]) . '</td>';
									$result.= '<td valign="top">' . (!empty($v['cache']) ? 'Yes' : 'No Cache') . '</td>';
									$result.= '<td valign="top">' . $v['time'] . '</td>';
								$result.= '</tr>';
								// cache tags
								if (!empty($v['cache_tags'])) {
									$result.= '<tr>';
										$result.= '<th>Cache Tags</th>';
										$result.= '<td valign="top" colspan="7" style="max-width: 1000px; overflow: scroll;">' . nl2br(implode("\n", $v['cache_tags']), true) . '</td>';
									$result.= '</tr>';
								}
								// results second
								if (!empty($v['rows'])) {
									$temp2 = current($v['rows']);
									if (!is_array($temp2)) {
										$result.= '<tr>';
												$result.= '<td valign="top" colspan="8" style="max-width: 1000px; overflow: scroll;">' . print_r2($v['rows'], '', true) . '</td>';
											$result.= '</tr>';
									} else {
										$temp = array_keys($temp2);
										$header = array_combine($temp, $temp);
										if (!empty($header)) {
											$result.= '<tr>';
												$result.= '<td valign="top" colspan="8" style="max-width: 1000px; overflow: scroll;">' . \HTML::table(['header' => $header, 'options' => $v['rows']]) . '</td>';
											$result.= '</tr>';
										}
									}
								}
								// backtrace
								if (!empty($v['backtrace'])) {
									$result.= '<tr>';
										$result.= '<td valign="top" colspan="4"><pre style="width: 1130px;">' . strip_tags($v['backtrace']) . '</pre></td>';
									$result.= '</tr>';
								}
								// empty separator
								$result.= '<tr>';
									$result.= '<td valign="top" colspan="4">&nbsp;</td>';
								$result.= '</tr>';
							}
						$result.= '</table>';
					$result.= '</td>';
				$result.= '</tr>';

				// cache
				$result.= '<tr id="debuging_toolbar_cache" class="debuging_toolbar_class" style="display: none;">';
					$result.= '<td>';
						$result.= '<h3>Cache (' . count(self::$data['cache']) . ')' . '</h3>';
						$result.= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
							$result.= '<tr>';
								$result.= '<th>Type</th>';
								$result.= '<th>Link</th>';
								$result.= '<th>Cache #</th>';
								$result.= '<th>Has Data</th>';
							$result.= '</tr>';
							foreach (self::$data['cache'] as $k => $v) {
								$result.= '<tr>';
									$result.= '<td valign="top">' . $v['type'] . '</td>';
									$result.= '<td valign="top">' . $v['link'] . '</td>';
									$result.= '<td valign="top">' . $v['cache_id'] . '</td>';
									$result.= '<td valign="top">' . ($v['have_data'] ? 'Yes' : 'No') . '</td>';
								$result.= '</tr>';
							}
						$result.= '</table>';
					$result.= '</td>';
				$result.= '</tr>';

				// dump
				$result.= '<tr id="debuging_toolbar_dump" class="debuging_toolbar_class" style="display: none;">';
					$result.= '<td>';
						$result.= '<h3>Dump (' . count(self::$data['dump']) . ')' . '</h3>';
						$result.= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
							$result.= '<tr>';
								$result.= '<th>Name</th>';
								$result.= '<th>Dump</th>';
							$result.= '</tr>';
							foreach (self::$data['dump'] as $k => $v) {
								$result.= '<tr>';
									$result.= '<td valign="top">' . $v['name'] . '</td>';
									$result.= '<td valign="top"><pre>' . print_r($v['value'], true) . '</pre></td>';
								$result.= '</tr>';
							}
						$result.= '</table>';
					$result.= '</td>';
				$result.= '</tr>';

				// input
				$result.= '<tr id="debuging_toolbar_input" class="debuging_toolbar_class" style="display: none;">';
					$result.= '<td>';
						$result.= '<h3>Input (' . count(self::$data['input']) . ')' . '</h3>';
						$result.= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
							$result.= '<tr>';
								$result.= '<th>Input</th>';
							$result.= '</tr>';
							foreach (self::$data['input'] as $k => $v) {
								$result.= '<tr>';
									$result.= '<td valign="top"><pre>' . print_r($v, true) . '</pre></td>';
								$result.= '</tr>';
							}
						$result.= '</table>';
					$result.= '</td>';
				$result.= '</tr>';

				// session
				$result.= '<tr id="debuging_toolbar_session" class="debuging_toolbar_class" style="display: none;">';
					$result.= '<td>';
						$result.= '<h3>Session (' . count(self::$data['session']) . ')' . '</h3>';
						$result.= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
							$result.= '<tr>';
								$result.= '<th>Session</th>';
							$result.= '</tr>';
							foreach (self::$data['session'] as $k => $v) {
								$result.= '<tr>';
									$result.= '<td valign="top"><pre>' . print_r($v, true) . '</pre></td>';
								$result.= '</tr>';
							}
						$result.= '</table>';
					$result.= '</td>';
				$result.= '</tr>';

				// autoloaded classes
				$result.= '<tr id="debuging_toolbar_classes" class="debuging_toolbar_class" style="display: none;">';
					$result.= '<td>';
						$result.= '<h3>Loaded Classes (' . count($loaded_classes) . ')</h3>';
						$result.= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
							$result.= '<tr>';
								$result.= '<th>Class Name</th>';
								$result.= '<th>File</th>';
								$result.= '<th>Media</th>';
							$result.= '</tr>';
							foreach ($loaded_classes as $k => $v) {
								$result.= '<tr>';
									$result.= '<td><b>' . $v['class'] . '</b></td>';
									$result.= '<td>' . $v['file'] . '</td>';
									$result.= '<td>' . \HTML::table(['options' => $v['media']]) . '</td>';
								$result.= '</tr>';
							}
						$result.= '</table>';
					$result.= '</td>';
				$result.= '</tr>';

				// application
				$result.= '<tr id="debuging_toolbar_application" class="debuging_toolbar_class" style="display: none;">';
					$result.= '<td>';
						$result.= '<h3>Application (' . count($application) . ')</h3>';
						$result.= print_r2($application, 'Application Variables:', true);
					$result.= '</td>';
				$result.= '</tr>';

				// phpinfo
				$result.= '<tr id="debuging_toolbar_phpinfo" class="debuging_toolbar_class" style="display: none;">';
					$result.= '<td>';
						$result.= '<h3>PHPInfo</h3>';
						\Helper\Ob::start();
						phpinfo();
						$str = \Helper\Ob::clean();
						$str = preg_replace( '%^.*<body>(.*)</body>.*$%ms', '$1', $str);
						$str.= <<<TTT
							<style type="text/css">
								#phpinfo table {
									border: 1px solid #000;
								}
								#phpinfo table tr {
									border-bottom: 1px solid #000;
								}
							</style>
TTT;
						$result.= '<div id="phpinfo">' . $str . '</div>';
					$result.= '</td>';
				$result.= '</tr>';

				// acls
				$result.= '<tr id="debuging_toolbar_acls" class="debuging_toolbar_class" style="display: none;">';
					$result.= '<td>';
						$result.= '<h3>Acls (' . count(\Debug::$data['acls']) . ')</h3>';
						$result.= print_r2(\Debug::$data['acls'], 'Acls', true);
					$result.= '</td>';
				$result.= '</tr>';

			$result.= '</table>';
		$result.= '</div>';
		return $result;
	}
3072
public function getEmbedHtml () : string
    {
        if (null === $this->assetHelper && null === $this->packages)
        {
            throw new AssetIntegrationFailedException("No asset integration extension found. Please either install `becklyn/assets-bundle` or `symfony/asset` to use this bundle.");
        }

        $trackJsToken = $this->hostingConfig->getTrackJsToken();

        // only embed if token is set, in production and not in debug
        if (null === $trackJsToken || $this->isDebug || "prod" !== $this->environment)
        {
            return "";
        }

        $assetUrl = null !== $this->assetHelper
            ? $this->assetHelper->getUrl("@hosting/js/trackjs.js")
            : $this->packages->getUrl("bundles/becklynhosting/js/trackjs.js");

        return \sprintf(
            '<script src="%s"></script><script>window.TrackJS && TrackJS.install(%s)</script>',
            $assetUrl,
            \json_encode([
                "token" => $trackJsToken,
                "application" => $this->hostingConfig->getProjectName(),
                "version" => $this->hostingConfig->getGitCommit(),
                "console" => [
                    "display" => false,
                ],
            ])
        );

    }
303081
public function generateAndIncludeFormzConfigurationJavaScript()
    {
        $formzConfigurationJavaScriptAssetHandler = $this->getFormzConfigurationJavaScriptAssetHandler();
        $fileName = $formzConfigurationJavaScriptAssetHandler->getJavaScriptFileName();

        $this->assetHandlerConnectorManager->createFileInTemporaryDirectory(
            $fileName,
            function () use ($formzConfigurationJavaScriptAssetHandler) {
                return $formzConfigurationJavaScriptAssetHandler->getJavaScriptCode();
            }
        );

        $this->includeJsFile(StringService::get()->getResourceRelativePath($fileName));

        return $this;
    }
161349
public function getJs()
    {
        if(!$this->includeAssets())
        {
            return '';
        }
        $libraries = $this->getLibrariesInUse();
        $code = '';
        foreach($libraries as $library)
        {
            $code .= "\n" . $library->getJs() . "\n";
        }
        return $code;
    }
457265
public function index()
    {
        $this->loadJs('app/install.js');
        $this->publish('baseUrl', $this->data['baseUrl']);
        App::render('install/configure_db.twig', $this->data);
    }
156596
public function attachScripts()
    {
        if ($this->isScriptsAttached())
            return $this;

        $view = $this->getView();
        $view->inlineScript()
            // we can change target of js files with static_uri_helper config key
            ->appendFile($view->staticsUri('Yima.Widgetator.JS.Jquery.Json'))
            ->appendFile($view->staticsUri('Yima.Widgetator.JS.Jquery.Ajaxq'))
            ->appendFile($view->staticsUri('Yima.Widgetator.JS.Jquery.WidgetAjaxy'))

            /*
            ->appendScript(
                str_replace(
                    '{{url}}',
                    $view->url('yimaWidgetator_restLoadWidget'),
                    file_get_contents(__DIR__.DS.'WidgetAjaxy.js')
                )
            )
            */
        ;

        $this->isScriptAttached = true;

        return $this;
    }
1052720
public function render()
    {
        $this->hook('pre-js-collection');
        if (isset($this->app->jquery) && $this->app->jquery) {
            $this->app->jquery->getJS($this);
        }

        if (!($this->template)) {
            throw new BaseException('You should specify template for APP object');
        }

        $this->hook('pre-render-output');
        if (headers_sent($file, $line)) {
            echo "<br />Direct output (echo or print) detected on $file:$line. <a target='_blank' "
                ."href='http://agiletoolkit.org/error/direct_output'>Use \$this->add('Text') instead</a>.<br />";
        }
        echo $this->template->render();
        $this->hook('post-render-output');
    }
1060203
protected function getInlineJavaScript()
    {
        $javascript = '';

        foreach ($this->fields as $field) {
            $field_javascript = $field->getRendererInlineJavaScript();
            if ($field_javascript != '') {
                $javascript .= "\n" . $field_javascript;
            }
        }

        foreach ($this->fields as $field) {
            $field_javascript = $field->getInlineJavaScript();
            if ($field_javascript != '') {
                $javascript .= "\n" . $field_javascript;
            }
        }

        return $javascript;
    }
1150686
public function appAction() {
        $name = ucfirst($this->getFirstParamOrAsk('Enter application\'s name'));;
        FSService::makeWritable(DC::getEnvironment()->getApplicationRoot() . $name);
        $this->createCV(array(
            'name' => 'Index',
            'app'  => $name,
        ));
        $appPath = DC::getEnvironment()->getApplicationRoot() . $name . '/';
        $this->safeCreateFromTemplate($appPath . 'Views/_layout.slot', '_view_layout', array('app'=>$name));
        $this->safeCreateFromTemplate($appPath . 'config.yml', '_app_config', array('app'=>$name));
        $config = DC::getProjectConfig();
        if (!$config->has('applications/'.strtolower($name))) {
            $config->set('applications/'.strtolower($name), strtolower($name));
            $this->notify('added information to project.yml', '+ config');
            $config->save();
        }
    }
664797
protected function compile()
    {
        $config  = StringUtil::deserialize($this->bs_navbarModules, true);
        $modules = [];
        $models  = $this->prefetchModules($config);

        foreach ($config as $module) {
            $id = $module['module'];

            if ($id != '' && !$module['inactive'] && array_key_exists($id, $models)) {
                $modules[] = $this->generateModule($module, $models[$id]);
            }
        }

        $cssID = $this->cssID;

        if ($this->cssID[1] == '') {
            $cssID[1] = 'navbar-light bg-light';
        }

        if ($this->bs_isResponsive && $this->bs_toggleableSize) {
            $cssID[1] = trim($cssID[1] . ' navbar-expand-' . $this->bs_toggleableSize);
        }

        $this->cssID             = $cssID;
        $this->Template->modules = $modules;
    }
1164723
public function renderJavascript()
	{
		if (!$this->isEnabled()) {
			return;
		}

		return $this->view->make('googlmapper::javascript')
			->withView($this->view)
			->withOptions($this->generateRenderOptions())
			->render();
	}
473447
public function get_js_data() {
        global $CFG;

        $ret = new stdClass;

        // Sort the types by priority.
        uasort($this->types, array($this, 'type_compare'));

        $ret->types = array();
        if (!empty($CFG->dndallowtextandlinks)) {
            foreach ($this->types as $type) {
                if (empty($type->handlers)) {
                    continue; // Skip any types without registered handlers.
                }
                $ret->types[] = $type;
            }
        }

        $ret->filehandlers = $this->filehandlers;
        $uploadrepo = repository::get_instances(array('type' => 'upload', 'currentcontext' => $this->context));
        if (empty($uploadrepo)) {
            $ret->filehandlers = array(); // No upload repo => no file handlers.
        }

        return $ret;
    }