Fields::DATE, 'HIDDEN' => Fields::HIDDEN, 'PRIVATE' => Fields::PRIVATE, 'TAGS' => Fields::TAGS, 'TEMPLATE' => Fields::TEMPLATE, 'TEMPLATE_LEGACY' => Fields::TEMPLATE_LEGACY, 'THEME' => Fields::THEME, 'TIME_CREATED' => Fields::TIME_CREATED, 'TIME_LAST_MODIFIED' => Fields::TIME_LAST_MODIFIED, 'TITLE' => Fields::TITLE, 'SITENAME' => Fields::SITENAME, 'URL' => Fields::URL ); /** * Find all variable fields in the currently used template and all included snippets (and ignore those fields in $this->reserved). * * @param Page $Page * @param Theme|null $Theme * @return array fields in the currently used template (without reserved fields) */ public static function inCurrentTemplate(Page $Page, ?Theme $Theme = null): array { if (empty($Theme)) { return array(); } // Don't use $Page->getTemplate() to prevent exit on errors. $file = AM_BASE_DIR . AM_DIR_PACKAGES . '/' . $Page->get(Fields::THEME) . '/' . $Page->template . '.php'; $fields = self::inTemplate($file); return self::cleanUp($fields, $Theme->getMask('page')); } /** * Find all variable fields in a template and all included snippets (and ignore those fields in $this->reserved). * * @param string $file * @return array fields in a given template (without reserved fields) */ public static function inTemplate(string $file): array { $fields = array(); if (is_readable($file)) { // Find all variable fields in the template file. $content = file_get_contents($file); // Remove ~ characters to match includes correctly. $content = str_replace( array(Delimiters::STATEMENT_OPEN . '~', '~' . Delimiters::STATEMENT_CLOSE), array(Delimiters::STATEMENT_OPEN, Delimiters::STATEMENT_CLOSE), $content ); preg_match_all('/' . PatternAssembly::variableKeyUI() . '/is', $content, $matches); $fields = $matches['varName']; // Match markup to get includes recursively. preg_match_all('/' . PatternAssembly::template() . '/is', $content, $matches, PREG_SET_ORDER); foreach ($matches as $match) { // Recursive include. if (!empty($match['file'])) { $include = dirname($file) . '/' . $match['file']; if (file_exists($include)) { $fields = array_merge($fields, self::inTemplate($include)); } } } $fields = self::cleanUp($fields); } return $fields; } /** * Find all variable fields in templates of a given theme. * * @param Theme $Theme * @return array fields in all templates of the given Theme (without reserved fields) */ public static function inTheme(Theme $Theme): array { $fields = array(); foreach ($Theme->templates as $file) { $fields = array_merge($fields, self::inTemplate($file)); } return self::cleanUp($fields, $Theme->getMask('shared')); } /** * Cleans up an array of fields. All reserved and duplicate fields get removed * and the optional UI mask is applied. * * @param array $fields * @param array $mask * @return array The sorted and filtered fields array */ private static function cleanUp(array $fields, array $mask = array()): array { if (empty($fields)) { return array(); } if (!empty($mask)) { $fields = array_filter($fields, function ($key) use ($mask) { return !in_array($key, $mask); }); } return array_unique(array_diff($fields, array_values(self::$reserved))); } } __halt_compiler();----SIGNATURE:----LcBrX8TjTEgSaQW4iwAxiTuoJIDRTQQWU/rEw9P1AoDgIQ8nuD3b9Bop6iAI0HW5k4YSof82nLUqi86JYxzAd2g8SviyOzUMDPf0e5ecx84P/RuKgvaxgIBwON2e7jYgH4pABCiQ/iIRm6ztEEMO1/40UZGXHH3D5HEUKHmvwmU6YrH01HH6mDGpD7pQJMjkoIfnNeJcTpfsHzKddD2gwH0+5rLaM3lN8iwsOhIkgVNjn/uiqFgkPcmi9/BK6mQcIYxvSgGc3uLWY4OnCUY7e99GJuAr6DjrdA3QVTBwlYtgzclOF4JH56YsTOL641RnxBu4P1BpsH+E8NFClVy4x/oRWichmK1BofwRP7XPdNe8YFNNDpsKHym2xXEMYzdrYFOIpA/hvmErVtSLcbZbVqueh3OJKk55k9ln7e2u2UBsoH71hEcdURAsyse2aF76dUPZRjTajbgZgjbdky22hV1IXcM966NUEk30JjyaHxc/H5hzl1sQCkGJ/dHKR/iB0Y/e4JD47ZL4LmiF5mzcClf9YDSfBhhYOx0hPTSR/t1lugk3H8Zd12KMtamWgqj0X36qlKjSN+KZUPIp3DEBi5eVYHHni4NSnjtG8nG7E8EtwfeTC7vTPGihHToCodbxF5NpTzCUvgxJAjO0VdDHA31OXbp9/vfd4i8dydCZlBI=----ATTACHMENT:----Nzc1NTMwNTYyOTc3NTExMCA2Nzc4ODc5ODc3NjI5NiAxNzk1Nzg3MzAzNDQyNTAy