API Documentation
Table of Contents
Namespaces
Constants
- BREADCRUMB_ALIASES = ['Home' => "Domů", 'Event' => "Událost", 'Admin' => "Admin", 'Admin-users' => "Uživetelé", 'Admin-events' => "Události", 'Admin-users-update' => "Úprava", 'Admin-events-update' => "Událost"]
- Configuration constant mapping breadcrumb keys to their display labels.
- BREADCRUMB_MAP = ['Home' => \createLink("/index.php"), 'Event' => \createLink("/event.php"), 'Admin' => \createLink("/admin/index.php"), 'Admin-users' => \createLink("/admin/users.php"), 'Admin-events' => \createLink("/admin/events.php"), 'Admin-users-update' => \createLink("/admin/user.php"), 'Admin-events-update' => \createLink("/admin/events/update.php")]
- Configuration constant mapping breadcrumb keys to their corresponding URLs.
- DB_CHARSET = 'utf8mb4'
- The character set used for the database connection (utf8mb4 is recommended).
- DB_HOST = 'localhost'
- The hostname or IP address of the database server.
- DB_NAME = 'hroudmi5'
- The name of the specific database to connect to.
- DB_PASS = 'webove aplikace'
- The password used for database authentication.
- DB_USER = 'hroudmi5'
- The username used for database authentication.
- DELIMITER = ";"
- EVENTS_PER_PAGE = 6
- Defines the number of event cards displayed per pagination page.
- TIMEZONE = "Europe/Prague"
- The default timezone identifier used for date and time operations.
Functions
- create_user_link() : mixed
- create_user_updated_link() : mixed
- reload() : mixed
- generateBreadcrumbs() : string
- Generates the HTML for the breadcrumb navigation based on a list of keys.
- check_cookies() : bool
- Checks for the existence of authentication cookies.
- check_user_cred() : bool
- Validates the user credentials against the database.
- check_auth_user() : bool|void
- Enforces that a user is currently logged in.
- check_auth_admin() : bool|void
- Enforces that the current user has administrator privileges.
- hashSHA256() : string
- Generates a SHA-256 hash of the input string.
- convertStringToDateTime() : DateTime
- Converts a date string into a DateTime object.
- getDateTimeNow() : DateTime
- Retrieves the current date and time.
- createLink() : string
- Generates an absolute URL by appending the global application prefix.
- createPublicLink() : string
- Generates a URL pointing to the public assets directory.
- createScriptLink() : string
- Generates a URL for a JavaScript file located in the scripts directory.
- createStylesLink() : string
- Generates a URL for a CSS stylesheet located in the styles directory.
- create_error_link() : string
- Generates a URL for the 500 internal server error page with a custom message.
- redirect_to() : void
- Performs an HTTP redirect to the specified URL and terminates the script.
- create_large_image_link() : string
- Generates a URL for a large version of an event image.
- create_small_image_link() : string
- Generates a URL for a thumbnail version of an event image.
- redirectToDatabaseError() : void
- Redirects the user to the standard database error page.
- round_up() : float|int
- Rounds a number up to a specified precision.
- eventIsLocked() : bool
- Checks if the registration period for an event has closed.
- userIsRegistered() : bool
- Determines if a specific user is already registered for a specific event.
Constants
BREADCRUMB_ALIASES
Configuration constant mapping breadcrumb keys to their display labels.
public
mixed
BREADCRUMB_ALIASES
= ['Home' => "Domů", 'Event' => "Událost", 'Admin' => "Admin", 'Admin-users' => "Uživetelé", 'Admin-events' => "Události", 'Admin-users-update' => "Úprava", 'Admin-events-update' => "Událost"]
This array defines the human-readable text shown in the navigation UI. Key: The unique identifier for the page (matching BREADCRUMB_MAP). Value: The localized (Czech) label string.
BREADCRUMB_MAP
Configuration constant mapping breadcrumb keys to their corresponding URLs.
public
mixed
BREADCRUMB_MAP
= ['Home' => \createLink("/index.php"), 'Event' => \createLink("/event.php"), 'Admin' => \createLink("/admin/index.php"), 'Admin-users' => \createLink("/admin/users.php"), 'Admin-events' => \createLink("/admin/events.php"), 'Admin-users-update' => \createLink("/admin/user.php"), 'Admin-events-update' => \createLink("/admin/events/update.php")]
This array defines the navigation paths for the breadcrumb system. Key: The unique identifier for the page. Value: The absolute URL path generated by the createLink function.
DB_CHARSET
The character set used for the database connection (utf8mb4 is recommended).
public
mixed
DB_CHARSET
= 'utf8mb4'
DB_HOST
The hostname or IP address of the database server.
public
mixed
DB_HOST
= 'localhost'
DB_NAME
The name of the specific database to connect to.
public
mixed
DB_NAME
= 'hroudmi5'
DB_PASS
The password used for database authentication.
public
mixed
DB_PASS
= 'webove aplikace'
DB_USER
The username used for database authentication.
public
mixed
DB_USER
= 'hroudmi5'
DELIMITER
public
mixed
DELIMITER
= ";"
EVENTS_PER_PAGE
Defines the number of event cards displayed per pagination page.
public
mixed
EVENTS_PER_PAGE
= 6
TIMEZONE
The default timezone identifier used for date and time operations.
public
string
TIMEZONE
= "Europe/Prague"
Functions
create_user_link()
create_user_link() : mixed
create_user_updated_link()
create_user_updated_link() : mixed
reload()
reload() : mixed
generateBreadcrumbs()
Generates the HTML for the breadcrumb navigation based on a list of keys.
generateBreadcrumbs(array<string|int, string> $items) : string
This function takes an array of location keys, verifies them against the global configuration maps, and constructs an HTML unordered list. The final item in the list is rendered as plain text (indicating the current page), while all preceding items are rendered as clickable links.
Parameters
- $items : array<string|int, string>
-
An ordered array of breadcrumb keys (e.g., ['Home', 'Admin']).
Return values
string —The generated HTML markup for the breadcrumb navigation.
check_cookies()
Checks for the existence of authentication cookies.
check_cookies() : bool
Verifies if the 'username' and 'user_id' cookies are set in the current request.
Return values
bool —True if both cookies exist, false otherwise.
check_user_cred()
Validates the user credentials against the database.
check_user_cred(string $username, int|string $user_id) : bool
This function uses the User class to verify that the provided username matches the provided user ID in the system records.
Parameters
- $username : string
-
The username to verify.
- $user_id : int|string
-
The user ID to verify.
Tags
Return values
bool —True if the combination is valid, false otherwise.
check_auth_user()
Enforces that a user is currently logged in.
check_auth_user() : bool|void
This function checks for valid cookies and verifies the credentials. If authentication fails, the user is immediately redirected to the login page and script execution is terminated.
Return values
bool|void —Returns true if authenticated; otherwise redirects and exits.
check_auth_admin()
Enforces that the current user has administrator privileges.
check_auth_admin() : bool|void
First ensures the user is logged in via check_auth_user(). Then retrieves the user profile to check the admin status. If the user is not an admin, they are redirected to the home page.
Return values
bool|void —Returns true if the user is an admin; otherwise redirects and exits.
hashSHA256()
Generates a SHA-256 hash of the input string.
hashSHA256(string $input) : string
This function acts as a wrapper for the native PHP hash function, specifically using the SHA-256 algorithm to create a cryptographic representation of the data.
Parameters
- $input : string
-
The input string to be hashed.
Return values
string —The calculated SHA-256 hash as a hexadecimal string.
convertStringToDateTime()
Converts a date string into a DateTime object.
convertStringToDateTime(string $date) : DateTime
This function creates a new DateTime instance based on the provided string, explicitly setting the timezone to the global constant TIMEZONE.
Parameters
- $date : string
-
The string representation of the date (e.g., "2023-10-25" or "now").
Tags
Return values
DateTime —The resulting DateTime object set to the configured timezone.
getDateTimeNow()
Retrieves the current date and time.
getDateTimeNow() : DateTime
Creates a DateTime object representing the current moment, configured with the application's default timezone.
Tags
Return values
DateTime —The current date and time.
createLink()
Generates an absolute URL by appending the global application prefix.
createLink(string $link) : string
Parameters
- $link : string
-
The relative path (e.g., "/login.php").
Tags
Return values
string —The fully qualified URL.
createPublicLink()
Generates a URL pointing to the public assets directory.
createPublicLink(string $link) : string
Parameters
- $link : string
-
The relative path inside the public folder.
Return values
string —The full URL to the public resource.
createScriptLink()
Generates a URL for a JavaScript file located in the scripts directory.
createScriptLink(string $script) : string
Parameters
- $script : string
-
The filename of the script (e.g., "/app.js").
Return values
string —The full URL to the script file.
createStylesLink()
Generates a URL for a CSS stylesheet located in the styles directory.
createStylesLink(string $script) : string
Parameters
- $script : string
-
The filename of the stylesheet (e.g., "/main.css").
Return values
string —The full URL to the CSS file.
create_error_link()
Generates a URL for the 500 internal server error page with a custom message.
create_error_link(string $message) : string
Parameters
- $message : string
-
The error message to be passed in the query string.
Return values
string —The full URL to the error page.
redirect_to()
Performs an HTTP redirect to the specified URL and terminates the script.
redirect_to(string $link) : void
Parameters
- $link : string
-
The target URL for the redirection.
create_large_image_link()
Generates a URL for a large version of an event image.
create_large_image_link(string $imagname) : string
Parameters
- $imagname : string
-
The filename of the image.
Return values
string —The full URL to the large image.
create_small_image_link()
Generates a URL for a thumbnail version of an event image.
create_small_image_link(string $imagname) : string
Parameters
- $imagname : string
-
The filename of the image.
Return values
string —The full URL to the thumbnail image.
redirectToDatabaseError()
Redirects the user to the standard database error page.
redirectToDatabaseError() : void
This is a convenience wrapper around redirect_to() and create_error_link() specifically for handling database connection or query failures.
round_up()
Rounds a number up to a specified precision.
round_up(float|int $number[, int $precision = 2 ]) : float|int
This function calculates the ceiling of a number at a specific decimal place. Note: The precision parameter determines the length of the multiplier string. For example, a precision of 3 generates a multiplier of 100 (10^2), resulting in 2 decimal places.
Parameters
- $number : float|int
-
The numeric value to be rounded.
- $precision : int = 2
-
The length of the padding for the multiplier (determines decimal places). Default is 2 (which rounds to 1 decimal place: 10^1).
Return values
float|int —The rounded number.
eventIsLocked()
Checks if the registration period for an event has closed.
eventIsLocked(Event $event) : bool
Compares the current server time against the event's registration deadline.
Parameters
- $event : Event
-
The event object containing the deadline.
Return values
bool —True if the deadline has passed (locked), false otherwise.
userIsRegistered()
Determines if a specific user is already registered for a specific event.
userIsRegistered(int $user_id, int $event_id) : bool
Acts as a safe wrapper around the Registration::existsByUserIdAndEventId method, handling potential database exceptions by redirecting to an error page.
Parameters
- $user_id : int
-
The unique ID of the user.
- $event_id : int
-
The unique ID of the event.
Return values
bool —True if a registration record exists, false otherwise.