Legal Document Viewer
The PLANOVI Document Center (documentation.php) provides users, cooperative members, and regulators with instant in-browser access to legal terms, privacy policies, and GDPR agreements.
1. Storage Organization (documents/)
Legal documents are organized strictly by ISO language code within the documents/ root directory:
planovi-webpage/└── documents/ ├── pl/ │ ├── polityka_prywatnosci.pdf # Polish Privacy Policy (GDPR / RODO) │ └── regulamin.pdf # Polish Terms of Service └── en/ ├── privacy_policy.pdf # English Privacy Policy └── terms_and_conditions.pdf # English Terms & Conditions2. Server-Side Document Discovery
On page load, documentation.php scans the filesystem dynamically to discover available documents without hardcoded file lists:
$baseDir = __DIR__ . '/documents';$langs = ['pl', 'en'];$filesData = [];
foreach ($langs as $lang) { $dirPath = $baseDir . '/' . $lang; if (is_dir($dirPath)) { $files = array_diff(scandir($dirPath), ['.', '..', '.DS_Store']); $filesData[$lang] = array_values($files); } else { $filesData[$lang] = []; }}
$jsonFiles = json_encode($filesData);The resulting $jsonFiles payload is passed to the client script to populate the document selector dynamically.
3. Client-Side Iframe Rendering
When a visitor switches language or selects a document from the dropdown:
function loadFile() { const select = document.getElementById('fileSelect'); const viewer = document.getElementById('pdfViewer'); const placeholder = document.getElementById('docsPlaceholder');
if (select.value) { // Appending #toolbar=0 prevents browser PDF chrome from cluttering the glass card const filePath = `documents/${docsLang}/${select.value}#toolbar=0`; viewer.src = filePath; viewer.style.display = 'block'; placeholder.style.display = 'none'; }}Key UI Features:
- Clean Embedding: The
#toolbar=0hash suppresses extraneous browser controls for a sleek embedded experience. - Dynamic File Labeling: File names like
polityka_prywatnosci.pdfare automatically formatted into readable titles:POLITYKA PRYWATNOSCI. - Seamless Language Switching: Toggling between PL and EN automatically re-filters the dropdown to the active locale’s files.