injectAssets($str); $str = $this->injectMarkup($str); $str = $this->processTemporaryEditButtons($str); } return $str; } /** * Inject a temporary markup for an edit button. * * @param string $value * @param string $key * @param Context $Context * @return string The processed $value */ public function injectTemporaryEditButton(string $value, string $key, Context $Context) { // Only inject button if $key is no runtime var and a user is logged in. if (preg_match('/^(\+|\w)/', $key) && Session::getUsername()) { $value .= Delimiters::INPAGE_BUTTON_OPEN . json_encode(array( 'context' => $Context->get()->origUrl, 'key' => $key ), JSON_UNESCAPED_SLASHES) . Delimiters::INPAGE_BUTTON_CLOSE; } return $value; } /** * Add all needed assets for inpage-editing to the
element. * * @param string $str * @return string The processed markup */ private function injectAssets(string $str) { $fn = function ($expression) { return $expression; }; $assets = <<< HTML {$fn(Asset::css('ui/dist/vendor.bundle.css'))} {$fn(Asset::css('ui/dist/ui.bundle.css'))} {$fn(Asset::js('ui/dist/vendor.bundle.js'))} {$fn(Asset::js('ui/dist/ui.bundle.js'))} HTML; // Check if there is already any other script tag and try to prepend all assets as first items. if (preg_match('/\<(script|link).*\<\/head\>/is', $str)) { return preg_replace('/(\<(script|link).*\<\/head\>)/is', $assets . "\n$1", $str); } else { return str_replace('', $assets . "\n", $str); } } /** * Inject UI markup like bottom menu and modal dialogs. * * @param string $str * @return string The processed $str */ private function injectMarkup(string $str) { $urlBase = AM_BASE_URL; $urlUI = AM_BASE_INDEX . AM_PAGE_DASHBOARD; $urlSys = $urlUI . '/System'; $attr = 'class="am-inpage-menu-button" data-uk-tooltip'; $request = AM_REQUEST; $logoSvg = file_get_contents(AM_BASE_DIR . '/automad/ui/svg/logo.svg'); $Text = Text::getObject(); //$modalSelectImage = SelectImage::render(); //$modalLink = Link::render(); $queryString = ''; if (!empty($_SERVER['QUERY_STRING'])) { $queryString = $_SERVER['QUERY_STRING']; } /* $html = <<< HTML