$_VARS['imagesPDOStatement'] = File::getList(); $_JSON['images-list-html'] = TemplateEngine::parse('images-list.php', $_VARS); echo json_encode($_JSON); exit; break; case 'detail': $_JSON = array(); $GUID = $_REQUEST['GUID']; $stmt = DB::getConnection()->prepare("SELECT * FROM `file` WHERE file_guid = :file_guid"); $stmt->bindParam(':file_guid', $GUID); $stmt->execute(); $file_record = $stmt->fetch(); // refresh images $_VARS = array(); $_VARS['file_record'] = $file_record; $_JSON['image-view'] = TemplateEngine::parse('image-view.php', $_VARS); echo json_encode($_JSON); exit; break; default: case ACTION_DEFAULT: $_VARS = array(); $_VARS['imagesPDOStatement'] = File::getList(); $imagesListContent = TemplateEngine::parse('images-list.php', $_VARS); $_VARS = array(); $_VARS['imagesListContent'] = $imagesListContent; echo TemplateEngine::parse('index.php', $_VARS); break; } $content = ob_get_clean(); echo $content;