Automad->Context; $url = $this->ContentProcessor->processVariables(trim($matches['with'], '\'"')); $TemplateProcessor = $this->initTemplateProcessor(); // Previous or next page. Use lowercase matches to be case insensitive. if (strtolower($matches['with']) == 'prev' || strtolower($matches['with']) == 'next') { // Cache the current pagelist config and temporary disable the excludeHidden parameter to also // get the neighbors of a hidden page. $pagelistConfigShelf = $this->Automad->getPagelist()->config(); $this->Automad->getPagelist()->config(array('excludeHidden' => false)); $Selection = new Selection($this->Automad->getPagelist()->getPages(true)); $Selection->filterPrevAndNextToUrl($Context->get()->url); $pages = $Selection->getSelection(); // Restore the original pagelist config. $this->Automad->getPagelist()->config($pagelistConfigShelf); if (array_key_exists(strtolower($matches['with']), $pages)) { $Page = $pages[strtolower($matches['with'])]; } } // Any existing page. // To avoid overriding $Page (next/prev), it has to be tested explicitly whether // the URL actually exists. if (array_key_exists($url, $this->Automad->getCollection())) { $Page = $this->Automad->getPage($url); } // Process snippet for $Page. if (!empty($Page)) { Debug::log($Page->url, 'With page'); // Save original context and pagelist. $contextShelf = $Context->get(); $pagelistConfigShelf = $this->Automad->getPagelist()->config(); // Set context to $url. $Context->set($Page); // Parse snippet. $html = $TemplateProcessor->process($matches['withSnippet'], $directory, $collectSnippetDefinitions); // Restore original context and pagelist. $Context->set($contextShelf); $this->Automad->getPagelist()->config($pagelistConfigShelf); return $html; } // If no matching page exists, check for a file. $files = FileUtils::fileDeclaration($url, $Context->get(), true); if (!empty($files)) { $file = $files[0]; Debug::log($file, 'With file'); return $this->ContentProcessor->processFileSnippet( $file, Parse::jsonOptions( $this->ContentProcessor->processVariables( $matches['withOptions'], true ) ), $matches['withSnippet'], $directory, $collectSnippetDefinitions ); } // In case $url is not a page and also not a file (no 'return' was called before), process the 'withElseSnippet'. Debug::log($url, 'With: No matching page or file found for'); if (!empty($matches['withElseSnippet'])) { return $TemplateProcessor->process($matches['withElseSnippet'], $directory, $collectSnippetDefinitions); } return ''; } /** * The pattern that is used to match context change statements in a template string. * * @return string the regex pattern for context change statements */ public static function syntaxPattern(): string { $statementOpen = preg_quote(Delimiters::STATEMENT_OPEN); $statementClose = preg_quote(Delimiters::STATEMENT_CLOSE); return $statementOpen . '\s*' . Delimiters::OUTER_STATEMENT_MARKER . '\s*' . 'with\s+(?P' . '"[^"]*"|' . "'[^']*'|" . PatternAssembly::variable() . '|prev|next' . ')' . '\s*(?P\{.*?\})?' . '\s*' . $statementClose . '(?P.*?)' . '(?:' . $statementOpen . Delimiters::OUTER_STATEMENT_MARKER . '\s*else\s*' . $statementClose . '(?P.*?)' . ')?' . $statementOpen . Delimiters::OUTER_STATEMENT_MARKER . '\s*end' . '\s*' . $statementClose; } } __halt_compiler();----SIGNATURE:----jdfHoGoocZfM7Y38LD9NipVFQ8bHyzrP/FhQvplzXEDwhRFvxpAk0+zV314lS2dn3AAb6/NUGbZw+l64fFH2EAE4rVdAKKRlt5THdYJyIwtjA9WHXYXWvzlQx0lM8U+NEqwETc/l1uIQO2Uu7U68+pTqR2hSHEpX8uzr7HIoJ3QGUZt3ZWx5xnAoev+9jfNMVw0w9cLWObiQcNhY33YKUEc+uH0AdlPFbbnlOTkWKSbKPnLcKhlM1TrSt/dN49UeBPq1yNesBi4Xm6VrGClOuuMslzcA5XgN6pjfkQGvEI2FOPHBf+2lH6wmN0zX1cA1aLiPFiO7yNps0zjJfF8Thn/4qBupj468iCDO68EWzSuqhAdKEr9cIFT5RIW3I2XzD+K0121AeifwlIE6DpMoJv0yfeJsJQYhwG3gGsc/anDc4knpm7yzey0mYpXpPcIx4xcvw7Sh2f/ev5vrdohlsssZgeud9wxtg2k5gK7gZn07cmMXLA/pi9SSF6RCE1aX77eiLNhI0tNfcgPlPeNQLaDpTeKlvmIEfYkIN71RBlYmV8Xw4yxu+aLtURRlWBgM7IXtt1cKtJfUgCSAc6wBKFuAtVwKZVEe20+U4FxVeJI0elHqPlXVslAy0bWOHulkuBjp1KgIX0zVvxGQ2Ls0pTyIU3mdLinGEX4VHYiMwx8=----ATTACHMENT:----Njc1NTM2MDIyMTMwMDU2NiAyMzIzMzQ0MjI4Mjk4Mjc0IDc1MjQxODM1NDEzNzE2NjA=