Backend Overview
Relevant source files
The following files were used as context for generating this wiki page:
The backend of the Institute Itech website is a classic server-side rendered application built with PHP. It does not use a modern framework, instead relying on a simple, file-based routing and templating system. Its core responsibilities include handling page requests, managing a multi-language internationalization (i18n) system, and rendering HTML content by combining page-specific templates with a global layout.
The architecture is consistent across different sections of the site, with each primary URL path corresponding to a PHP file that acts as a controller. This controller is responsible for initializing sessions, handling language settings, and including the appropriate view template. State, primarily the user's selected language, is managed using PHP sessions.
Core Architecture & Request Lifecycle
The application follows a straightforward request-response cycle initiated by a user accessing a .php file directly. Each of these files acts as an entry point for a specific page or section.
The general flow for a page request is as follows:
- A user requests a specific URL (e.g.,
/,/iite/overview.php,/login.php). - The web server executes the corresponding PHP file (
index.php,iite/overview.php, etc.). - The script starts a session to persist state, primarily the language setting.
- It checks for a
langquery parameter to update the session language and redirects to a clean URL. - It determines the current page and language, loading an array of page titles from
apps/pages.php. - It defines a translation function
t()to retrieve localized strings. - Output buffering is started using
ob_start(). - A page-specific
.phtmlview file is included, which generates the main content of the page. - The generated content is captured from the buffer into a variable (
$output_page). - The master layout file,
themes/components/statics/layout.phtml, is included. This layout file then echoes the$output_pagevariable to render the final HTML document.
This diagram illustrates the standard request lifecycle.
Sources: index.php:1-22, iite/overview.php:1-22, login.php:1-29
Routing and Page Handling
The application employs a direct file-based routing system. There is no central router; instead, URLs map directly to PHP files on the server. For instance, a request to /departments/overview.php is handled by the departments/overview.php script.
Each of these "controller" files follows the same structural pattern, differing only in the specific .phtml template they include.
| Entry Point File | Page Identifier ($page) | Included View Template | Description |
|---|---|---|---|
index.php | index | themes/apps/index.phtml | Handles the homepage. |
iite/overview.php | iite_overview | themes/apps/iite/overview.phtml | Displays the main "Overview of Institute Itech" page. |
departments/overview.php | departments_overview | themes/apps/departments/overview.phtml | Displays the overview of the different departments. |
login.php | login | themes/apps/login.phtml | Renders the login page and contains logic to hide the main navigation. |
inside/interface.php | (Not set) | themes/apps/inside/interface.phtml | A simpler page structure that directly includes the template. |
iite/wep.php | iite_wep | themes/apps/iite/wep.phtml | Handles the WEP2025 Projects page. |
iite/relationship.php | iite_relationship | themes/apps/iite/relationship.phtml | Handles the Relationships page. |
Sources: index.php:13, iite/overview.php:13, departments/overview.php:13, login.php:14, inside/interface.php:5
A special case is login.php, which sets a $hideNavbar flag to true. This flag is presumably used within layout.phtml to conditionally hide the navigation bar on the login screen.
Sources: login.php:21-27
Internationalization (i18n)
The backend supports multiple languages (Italian, English, French, Spanish) through a session-based i18n system.
Language Switching
The language can be changed by adding a lang query parameter to any URL (e.g., /index.php?lang=en). The backend script detects this parameter, updates the $_SESSION['lang'] variable, and then performs a 302 redirect to the same URL without the query parameter to provide a clean user experience. If no language is set, it defaults to Italian (it).
This sequence diagram shows the language switching flow.
Sources: index.php:4-9, iite/overview.php:4-9
Translation Sources
Translations are managed through PHP arrays and a JSON file.
Page Titles
Page titles are defined in apps/pages.php. This file returns a multi-dimensional array where the first-level key is the page identifier (e.g., iite_overview) and the second-level keys are language codes (it, en, etc.).
<?php
// apps/pages.php
return [
'index' => [
'it' => 'Benvenuto in Institute Itech',
'en' => 'Welcome to Institute Itech',
// ...
],
'iite_overview' => [
'it' => 'Panoramica di Institute Itech',
'en' => 'Overview of Institute Itech',
// ...
],
// ...
];
Sources: apps/pages.php:1-35
UI Text
General UI text strings are stored in apps/translations.json. This file contains key-value pairs for various text elements across the site, with nested objects for each supported language. While the provided PHP files do not show this file being loaded server-side, it is a key part of the overall translation strategy, likely used by client-side JavaScript.
Sources: apps/translations.json
The t() Function
A global helper function named t() is defined in each entry-point script to retrieve translated strings. It takes a translation key as an argument and looks it up in the $translations array (loaded from apps/pages.php). It falls back to the English version (en) or a formatted version of the key itself if the translation is not found for the current language.
// Example from iite/overview.php
function t($key) {
global $translations, $lang;
return isset($translations[$key][$lang])
? str_replace('\n', '<br>', $translations[$key][$lang])
: ucfirst(str_replace('_', ' ', $key));
}
Sources: iite/overview.php:16-21, index.php:15-18
Templating System
The application uses a simple but effective templating system based on PHP's output buffering. This separates the main page logic (in the controller .php files) from the presentation (in the view .phtml files).
This diagram shows how content is captured and injected into the main layout.
This approach allows for a consistent site-wide layout (layout.phtml) while enabling each page to have unique content and structure (*.phtml).
Sources: iite/overview.php:23-25, research/overview.php:5-11, inside/interface.php:5-9