From 76ed5fe0fc473a37a38800a2e3747341e7f60373 Mon Sep 17 00:00:00 2001 From: garvinhicking <garvinhicking> Date: Wed, 22 Jun 2005 09:08:56 +0000 Subject: [PATCH] Make serendipity parse its permalinks before creating directories. This gets rid of a PATH_ARCHIVES directory created by the installer. Didn't hurt, but didn't look right. ;) --- include/functions_installer.inc.php | 2 + include/functions_permalinks.inc.php | 88 ++++++++++++++++++++++++++++ serendipity_config.inc.php | 82 +------------------------- 3 files changed, 91 insertions(+), 81 deletions(-) diff --git a/include/functions_installer.inc.php b/include/functions_installer.inc.php index 9f79805..49be3df 100644 --- a/include/functions_installer.inc.php +++ b/include/functions_installer.inc.php @@ -530,6 +530,8 @@ function serendipity_checkInstallation() { $errs = array(); + serendipity_initPermalinks(); + // Check dirs if (!is_dir($_POST['serendipityPath'])) { $errs[] = sprintf(DIRECTORY_NON_EXISTANT, $_POST['serendipityPath']); diff --git a/include/functions_permalinks.inc.php b/include/functions_permalinks.inc.php index c43f786..238bac9 100644 --- a/include/functions_permalinks.inc.php +++ b/include/functions_permalinks.inc.php @@ -104,6 +104,94 @@ function serendipity_makeFilename($str) { return $str; } +function serendipity_initPermalinks() { + global $serendipity; + + if (!isset($serendipity['permalinkStructure'])) { + $serendipity['permalinkStructure'] = 'archives/%id%-%title%.html'; + } + + if (!isset($serendipity['permalinkFeedCategoryStructure'])) { + $serendipity['permalinkFeedCategoryStructure'] = 'feeds/categories/%id%-%name%.rss'; + } + + if (!isset($serendipity['permalinkCategoryStructure'])) { + $serendipity['permalinkCategoryStructure'] = 'categories/%id%-%name%'; + } + + if (!isset($serendipity['permalinkAuthorStructure'])) { + $serendipity['permalinkAuthorStructure'] = 'authors/%id%-%realname%'; + } + + if (!isset($serendipity['permalinkArchivesPath'])) { + $serendipity['permalinkArchivesPath'] = 'archives'; + } + + if (!isset($serendipity['permalinkArchivePath'])) { + $serendipity['permalinkArchivePath'] = 'archive'; + } + + if (!isset($serendipity['permalinkCategoriesPath'])) { + $serendipity['permalinkCategoriesPath'] = 'categories'; + } + + if (!isset($serendipity['permalinkUnsubscribePath'])) { + $serendipity['permalinkUnsubscribePath'] = 'unsubscribe'; + } + + if (!isset($serendipity['permalinkDeletePath'])) { + $serendipity['permalinkDeletePath'] = 'delete'; + } + + if (!isset($serendipity['permalinkApprovePath'])) { + $serendipity['permalinkApprovePath'] = 'approve'; + } + + if (!isset($serendipity['permalinkFeedsPath'])) { + $serendipity['permalinkFeedsPath'] = 'feeds'; + } + + if (!isset($serendipity['permalinkPluginPath'])) { + $serendipity['permalinkPluginPath'] = 'plugin'; + } + + if (!isset($serendipity['permalinkAdminPath'])) { + $serendipity['permalinkAdminPath'] = 'admin'; + } + + if (!isset($serendipity['permalinkSearchPath'])) { + $serendipity['permalinkSearchPath'] = 'search'; + } + + /* URI paths + * These could be defined in the language headers, except that would break + * backwards URL compatibility + */ + @define('PATH_ARCHIVES', $serendipity['permalinkArchivesPath']); + @define('PATH_ARCHIVE', $serendipity['permalinkArchivePath']); + @define('PATH_CATEGORIES', $serendipity['permalinkCategoriesPath']); + @define('PATH_UNSUBSCRIBE', $serendipity['permalinkUnsubscribePath']); + @define('PATH_DELETE', $serendipity['permalinkDeletePath']); + @define('PATH_APPROVE', $serendipity['permalinkApprovePath']); + @define('PATH_FEEDS', $serendipity['permalinkFeedsPath']); + @define('PATH_PLUGIN', $serendipity['permalinkPluginPath']); + @define('PATH_ADMIN', $serendipity['permalinkAdminPath']); + @define('PATH_SEARCH', $serendipity['permalinkSearchPath']); + + /* URI patterns + * Note that it's important to use @ as the pattern delimiter. DO NOT use shortcuts + * like \d or \s, since mod_rewrite will use the regexps as well and chokes on them. + * If you add new patterns, remember to add the new rules to the *.tpl files and + * function serendipity_installFiles(). + */ + @define('PAT_FILENAME', '0-9a-z\.\_!;,\+\-'); + @define('PAT_CSS', '@/(serendipity\.css|serendipity_admin\.css)@'); + @define('PAT_FEED', '@/(index|atom|rss|b2rss|b2rdf).(rss|rdf|rss2|xml)$@'); + @define('PAT_COMMENTSUB', '@/([0-9]+)[_\-][' . PAT_FILENAME . ']*\.html@i'); + + return true; +} + function &serendipity_permalinkPatterns($return = false) { global $serendipity; diff --git a/serendipity_config.inc.php b/serendipity_config.inc.php index 9b679e9..abdc912 100644 --- a/serendipity_config.inc.php +++ b/serendipity_config.inc.php @@ -189,87 +189,7 @@ if (empty($serendipity['serendipityHTTPPath'])) { } /* Changing this is NOT recommended, rewrite rules does not take them into account - yet */ -if (!isset($serendipity['permalinkStructure'])) { - $serendipity['permalinkStructure'] = 'archives/%id%-%title%.html'; -} - -if (!isset($serendipity['permalinkFeedCategoryStructure'])) { - $serendipity['permalinkFeedCategoryStructure'] = 'feeds/categories/%id%-%name%.rss'; -} - -if (!isset($serendipity['permalinkCategoryStructure'])) { - $serendipity['permalinkCategoryStructure'] = 'categories/%id%-%name%'; -} - -if (!isset($serendipity['permalinkAuthorStructure'])) { - $serendipity['permalinkAuthorStructure'] = 'authors/%id%-%realname%'; -} - -if (!isset($serendipity['permalinkArchivesPath'])) { - $serendipity['permalinkArchivesPath'] = 'archives'; -} - -if (!isset($serendipity['permalinkArchivePath'])) { - $serendipity['permalinkArchivePath'] = 'archive'; -} - -if (!isset($serendipity['permalinkCategoriesPath'])) { - $serendipity['permalinkCategoriesPath'] = 'categories'; -} - -if (!isset($serendipity['permalinkUnsubscribePath'])) { - $serendipity['permalinkUnsubscribePath'] = 'unsubscribe'; -} - -if (!isset($serendipity['permalinkDeletePath'])) { - $serendipity['permalinkDeletePath'] = 'delete'; -} - -if (!isset($serendipity['permalinkApprovePath'])) { - $serendipity['permalinkApprovePath'] = 'approve'; -} - -if (!isset($serendipity['permalinkFeedsPath'])) { - $serendipity['permalinkFeedsPath'] = 'feeds'; -} - -if (!isset($serendipity['permalinkPluginPath'])) { - $serendipity['permalinkPluginPath'] = 'plugin'; -} - -if (!isset($serendipity['permalinkAdminPath'])) { - $serendipity['permalinkAdminPath'] = 'admin'; -} - -if (!isset($serendipity['permalinkSearchPath'])) { - $serendipity['permalinkSearchPath'] = 'search'; -} - -/* URI paths - * These could be defined in the language headers, except that would break - * backwards URL compatibility - */ -@define('PATH_ARCHIVES', $serendipity['permalinkArchivesPath']); -@define('PATH_ARCHIVE', $serendipity['permalinkArchivePath']); -@define('PATH_CATEGORIES', $serendipity['permalinkCategoriesPath']); -@define('PATH_UNSUBSCRIBE', $serendipity['permalinkUnsubscribePath']); -@define('PATH_DELETE', $serendipity['permalinkDeletePath']); -@define('PATH_APPROVE', $serendipity['permalinkApprovePath']); -@define('PATH_FEEDS', $serendipity['permalinkFeedsPath']); -@define('PATH_PLUGIN', $serendipity['permalinkPluginPath']); -@define('PATH_ADMIN', $serendipity['permalinkAdminPath']); -@define('PATH_SEARCH', $serendipity['permalinkSearchPath']); - -/* URI patterns - * Note that it's important to use @ as the pattern delimiter. DO NOT use shortcuts - * like \d or \s, since mod_rewrite will use the regexps as well and chokes on them. - * If you add new patterns, remember to add the new rules to the *.tpl files and - * function serendipity_installFiles(). - */ -@define('PAT_FILENAME', '0-9a-z\.\_!;,\+\-'); -@define('PAT_CSS', '@/(serendipity\.css|serendipity_admin\.css)@'); -@define('PAT_FEED', '@/(index|atom|rss|b2rss|b2rdf).(rss|rdf|rss2|xml)$@'); -@define('PAT_COMMENTSUB', '@/([0-9]+)[_\-][' . PAT_FILENAME . ']*\.html@i'); +serendipity_initPermalinks(); // Apply constants/definitions from custom permalinks serendipity_permalinkPatterns(); -- 2.39.5