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
$modalSelectImage $modalLink HTML; return str_replace('', $html . '', $str); */ } /** * Process the temporary buttons to edit variable in the page. * All invalid buttons (within tags and in links) will be removed. * * @param string $str * @return string The processed markup */ private function processTemporaryEditButtons(string $str) { // Remove invalid buttons. // Within HTML tags. // Like
$str = preg_replace_callback('/\<[^>]+\>/is', function ($matches) { return preg_replace('/' . PatternAssembly::inPageEditButton() . '/is', '', $matches[0]); }, $str); // In head, script, links, buttons etc. // Like ... $str = preg_replace_callback('/\<(a|button|head|script|select|textarea)\b.+?\<\/\1\>/is', function ($matches) { return preg_replace('/' . PatternAssembly::inPageEditButton() . '/is', '', $matches[0]); }, $str); $open = preg_quote(Delimiters::INPAGE_BUTTON_OPEN); $close = preg_quote(Delimiters::INPAGE_BUTTON_CLOSE); $str = preg_replace_callback("/$open(.+?\"key\":\"([^\"]+)\".+?)$close/is", function ($matches) { $json = $matches[1]; $name = ucwords(str_replace('+', '', preg_replace('/([A-Z])/', ' $1', $matches[2]))); return <<< HTML   $name HTML; }, $str); return $str; } } __halt_compiler();----SIGNATURE:----Yc3cS186CtrX7qguTYo05sD7bTzSmxp0WED6wlMI9GcVfzxK7hErjJPmM8bQnmm+9EFrbBmegBux7K1He9zqzZcEqoxtDpRqjdqK6hdI7ymdl22YAp18mfixfByTssvpQRWZn8TfyTpekmWeS/jUNqPySxgVN896EKYP99fLI+1JyIcY2c5x3oOj4pFoAENZ5jQnVtXZhKzYNqlA1ZIs4NqgaxunYDs+p8m9OzE7Q45hbGlJWigjctlF662E/uZ1glXUe1dBGMeCh8E1UpoOO6du1prr0CiLVgBw0trcuL0mz+LP9lDK9zVmvIcdYDUaSCw3R9Tyb46ZW7cEjNHhsapx50lHSkBFDtenkvM2PdtJIaS9aPeMGWA2wWk1d9LfJODvFna79d1/8sTOz0m6BVSWq+SpexdNsrWQZom05IKn7Nkb5zF+CtVmzia8CLZTw3t1y/dfDQ3iSoKYptkq6vhtmG6uYfhivqVh/tj5hoLEFm2aroxmQWe7w4k0InT5ZTeslkRG42nUGufGL2gspbLXLt8w0XNqi2SFj/8qipP3IRJF7I1SnbFXDQR7ZilF5mqM5xI+JyO2dSLrma6g0U2UrMPgOA4jiIsLoJqYrFmB7Deq2zxQB+kGq2FgCAmDwz1bBT8uqUV24OxfsH9t+Yw7MrOEl36XQWpplOU1m4g=----ATTACHMENT:----MTk3NTg4MTAwOTU3MTkyNSAxMjI1MDc3NTA5MzQwNjUzIDQzNjY1MDA1MTY3NTk3NDE=