+/**
+ * Get template page list.
+ */
+function get_template_page_list()
+{
+ global $whatsnew;
+ $tpage_names = array(); // Pages marked as template
+ $template_page = ':config/Templates';
+ $page_max = 100;
+ foreach(get_source($template_page) as $_templates) {
+ $m = array();
+ if (! preg_match('#\-\s*\[\[([^\[\]]+)\]\]#', $_templates, $m)) continue;
+ $tpage = preg_replace('#^./#', "$template_page/", $m[1]);
+ if (! is_page($tpage)) continue;
+ $tpage_names[] = $tpage;
+ }
+ $page_names = array();
+ $page_list = get_existpages();
+ if (count($page_list) > $page_max) {
+ // Extract only template name pages
+ $target_pages = array();
+ foreach ($page_list as $_page) {
+ if (preg_match('/template/i', $_page)) {
+ $target_pages[] = $_page;
+ }
+ }
+ } else {
+ $target_pages = $page_list;
+ }
+ foreach ($target_pages as $_page) {
+ if ($_page == $whatsnew || check_non_list($_page) ||
+ !is_page_readable($_page)) {
+ continue;
+ }
+ $tpage_names[] = $_page;
+ }
+ $tempalte_page_list = array_values(array_unique($tpage_names));
+ natcasesort($tempalte_page_list);
+ return $tempalte_page_list;
+}
+