From e33c245d910e55b8cab407a03e669470509a705d Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Fri, 10 Mar 2017 21:46:12 +0100 Subject: Several changes have been made in this commit, which together with the previous commits result in version 1.1: + The rules for the Apache and nginx configuration have been changed and redirects now all requests to the index.php. + A router class has been added which now handles all requests that arrives at the application on the index.php. + Short-hand functions "PAGE", "POST" and "USER" for use in templates added to get specific item data by ID. + More language variables have been added to the core language. --- core/functions.php | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'core/functions.php') diff --git a/core/functions.php b/core/functions.php index 726e96f..471c14f 100644 --- a/core/functions.php +++ b/core/functions.php @@ -308,9 +308,9 @@ function excerpt($string, $length = 500, $replace = ' […]') { return $string; } -#==================================================================================================== +#=============================================================================== # Generate a valid slug URL part from a string -#==================================================================================================== +#=============================================================================== function makeSlugURL($string) { $string = strtolower($string); $string = str_replace(['ä', 'ö', 'ü', 'ß'], ['ae', 'oe', 'ue', 'ss'], $string); @@ -319,4 +319,40 @@ function makeSlugURL($string) { return trim($string, '-'); } -?> + +#=============================================================================== +# Function to get data from specific page in templates +#=============================================================================== +function PAGE($id) { + try { + $Page = Page\Factory::build($id); + return generatePageItemData($Page); + } catch(Page\Exception $Exception) { + return NULL; + } +} + +#=============================================================================== +# Function to get data from specific post in templates +#=============================================================================== +function POST($id) { + try { + $Post = Post\Factory::build($id); + return generatePostItemData($Post); + } catch(Post\Exception $Exception) { + return NULL; + } +} + +#=============================================================================== +# Function to get data from specific user in templates +#=============================================================================== +function USER($id) { + try { + $User = User\Factory::build($id); + return generateUserItemData($User); + } catch(User\Exception $Exception) { + return NULL; + } +} +?> \ No newline at end of file -- cgit v1.2.3