[Scummvm-git-logs] scummvm-web master -> d671d448644b0952f8493efc3658c4940671647f
Mataniko
mataniko at gmail.com
Wed Jan 23 01:50:15 CET 2019
This automated email contains information about 33 new commits which have been
pushed to the 'scummvm-web' repo located at https://github.com/scummvm/scummvm-web .
Summary:
9d06648394 BUILD: Add phpcs and phpstan dev deps
851bb41bb7 WEB: Auto-fix to PSR-2 standard
cfbeebb8dc WEB: Add namespaces to all PHP files
a7d87ddf58 WEB: format index.php for psr-2
85328f2997 WEB: Use PSR-4 autoloading
97262c4b2f WEB: Convert require statements to psr-4 style use statements
1e7815ec2e WEB: Fix namespace reference to ErrorException
df825b7878 WEB: Fix phpstan static errors
2eff11cbb3 WEB: Clean up most PSR2 style warnings
2725908348 WEB: Additional PSR2 cleanup
eb47e74aae WEB: Delete old poll site
e0f5656d84 WEB: Code format cloud page
7afd0daf3f WEB: Use OO for objects
8a51f21f0c WEB: Rename Section objects
6652331db9 WEB: Move file download base URLs to Config.php
8682a63731 WEB: Improve inheritance for Section classes
42d8516b65 WEB: Fix template warnings on subsections
5e079bf6fa WEB: Use PSR4 object references in templates
dcc281b2c2 WEB: Fix line endings
4c97bcbcaf WEB: Remove unused objects and methods in downloads/games
393959c39b WEB: Remove die() in CreditsSection
2d07e63028 WEB: Remove unused code in Controller
601465558f WEB: Resolve static analysis errors
b17e27cc80 WEB: Additional static analysis fixes on pages
573416873c WEB: Remove Smarty global
bf31e63af6 BUILD: Add phpstan config
7c90a6f7d6 WEB: Parse News JSON as an array instead of an object
93f5a043bb WEB: Rename Config.php
56fc8e6d4f WEB: Remove unused constant
67778e13ce WEB: Fix phpdoc errors
07f704f814 WEB: Remove unused Smarty parameters and update syntax
acfcb51c7e WEB: Syntax error in exception handler
d671d44864 BUILD: Increase static check levels
Commit: 9d06648394b8b7e9d817d6e7e79c217468dafb4c
https://github.com/scummvm/scummvm-web/commit/9d06648394b8b7e9d817d6e7e79c217468dafb4c
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
BUILD: Add phpcs and phpstan dev deps
Changed paths:
composer.json
composer.lock
diff --git a/composer.json b/composer.json
index 25fd42f..600a5a6 100644
--- a/composer.json
+++ b/composer.json
@@ -29,5 +29,9 @@
"@build",
"@run"
]
+ },
+ "require-dev": {
+ "phpstan/phpstan": "^0.11.1",
+ "squizlabs/php_codesniffer": "^3.4"
}
}
diff --git a/composer.lock b/composer.lock
index 7d2d114..74c9aae 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "1beee5bb97c81377cb2ad36811831e10",
+ "content-hash": "4c580db7ed458bec6deff0a071432aef",
"packages": [
{
"name": "ezyang/htmlpurifier",
@@ -159,7 +159,1142 @@
"time": "2018-04-24T14:53:33+00:00"
}
],
- "packages-dev": [],
+ "packages-dev": [
+ {
+ "name": "composer/xdebug-handler",
+ "version": "1.3.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/composer/xdebug-handler.git",
+ "reference": "dc523135366eb68f22268d069ea7749486458562"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/dc523135366eb68f22268d069ea7749486458562",
+ "reference": "dc523135366eb68f22268d069ea7749486458562",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^5.3.2 || ^7.0",
+ "psr/log": "^1.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Composer\\XdebugHandler\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "John Stevenson",
+ "email": "john-stevenson at blueyonder.co.uk"
+ }
+ ],
+ "description": "Restarts a process without xdebug.",
+ "keywords": [
+ "Xdebug",
+ "performance"
+ ],
+ "time": "2018-11-29T10:59:02+00:00"
+ },
+ {
+ "name": "jean85/pretty-package-versions",
+ "version": "1.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Jean85/pretty-package-versions.git",
+ "reference": "75c7effcf3f77501d0e0caa75111aff4daa0dd48"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/75c7effcf3f77501d0e0caa75111aff4daa0dd48",
+ "reference": "75c7effcf3f77501d0e0caa75111aff4daa0dd48",
+ "shasum": ""
+ },
+ "require": {
+ "ocramius/package-versions": "^1.2.0",
+ "php": "^7.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^6.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Jean85\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Alessandro Lai",
+ "email": "alessandro.lai85 at gmail.com"
+ }
+ ],
+ "description": "A wrapper for ocramius/package-versions to get pretty versions strings",
+ "keywords": [
+ "composer",
+ "package",
+ "release",
+ "versions"
+ ],
+ "time": "2018-06-13T13:22:40+00:00"
+ },
+ {
+ "name": "nette/bootstrap",
+ "version": "v2.4.6",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/nette/bootstrap.git",
+ "reference": "268816e3f1bb7426c3a4ceec2bd38a036b532543"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/nette/bootstrap/zipball/268816e3f1bb7426c3a4ceec2bd38a036b532543",
+ "reference": "268816e3f1bb7426c3a4ceec2bd38a036b532543",
+ "shasum": ""
+ },
+ "require": {
+ "nette/di": "~2.4.7",
+ "nette/utils": "~2.4",
+ "php": ">=5.6.0"
+ },
+ "conflict": {
+ "nette/nette": "<2.2"
+ },
+ "require-dev": {
+ "latte/latte": "~2.2",
+ "nette/application": "~2.3",
+ "nette/caching": "~2.3",
+ "nette/database": "~2.3",
+ "nette/forms": "~2.3",
+ "nette/http": "~2.4.0",
+ "nette/mail": "~2.3",
+ "nette/robot-loader": "^2.4.2 || ^3.0",
+ "nette/safe-stream": "~2.2",
+ "nette/security": "~2.3",
+ "nette/tester": "~2.0",
+ "tracy/tracy": "^2.4.1"
+ },
+ "suggest": {
+ "nette/robot-loader": "to use Configurator::createRobotLoader()",
+ "tracy/tracy": "to use Configurator::enableTracy()"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.4-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause",
+ "GPL-2.0",
+ "GPL-3.0"
+ ],
+ "authors": [
+ {
+ "name": "David Grudl",
+ "homepage": "https://davidgrudl.com"
+ },
+ {
+ "name": "Nette Community",
+ "homepage": "https://nette.org/contributors"
+ }
+ ],
+ "description": "🅱 Nette Bootstrap: the simple way to configure and bootstrap your Nette application.",
+ "homepage": "https://nette.org",
+ "keywords": [
+ "bootstrapping",
+ "configurator",
+ "nette"
+ ],
+ "time": "2018-05-17T12:52:20+00:00"
+ },
+ {
+ "name": "nette/di",
+ "version": "v2.4.14",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/nette/di.git",
+ "reference": "923da3e2c0aa53162ef455472c0ac7787b096c5a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/nette/di/zipball/923da3e2c0aa53162ef455472c0ac7787b096c5a",
+ "reference": "923da3e2c0aa53162ef455472c0ac7787b096c5a",
+ "shasum": ""
+ },
+ "require": {
+ "ext-tokenizer": "*",
+ "nette/neon": "^2.3.3 || ~3.0.0",
+ "nette/php-generator": "^2.6.1 || ~3.0.0",
+ "nette/utils": "^2.4.3 || ~3.0.0",
+ "php": ">=5.6.0"
+ },
+ "conflict": {
+ "nette/bootstrap": "<2.4",
+ "nette/nette": "<2.2"
+ },
+ "require-dev": {
+ "nette/tester": "^2.0",
+ "tracy/tracy": "^2.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.4-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause",
+ "GPL-2.0",
+ "GPL-3.0"
+ ],
+ "authors": [
+ {
+ "name": "David Grudl",
+ "homepage": "https://davidgrudl.com"
+ },
+ {
+ "name": "Nette Community",
+ "homepage": "https://nette.org/contributors"
+ }
+ ],
+ "description": "💎 Nette Dependency Injection Container: Flexible, compiled and full-featured DIC with perfectly usable autowiring and support for all new PHP 7.1 features.",
+ "homepage": "https://nette.org",
+ "keywords": [
+ "compiled",
+ "di",
+ "dic",
+ "factory",
+ "ioc",
+ "nette",
+ "static"
+ ],
+ "time": "2018-09-17T15:47:40+00:00"
+ },
+ {
+ "name": "nette/finder",
+ "version": "v2.4.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/nette/finder.git",
+ "reference": "ee951a656cb8ac622e5dd33474a01fd2470505a0"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/nette/finder/zipball/ee951a656cb8ac622e5dd33474a01fd2470505a0",
+ "reference": "ee951a656cb8ac622e5dd33474a01fd2470505a0",
+ "shasum": ""
+ },
+ "require": {
+ "nette/utils": "~2.4",
+ "php": ">=5.6.0"
+ },
+ "conflict": {
+ "nette/nette": "<2.2"
+ },
+ "require-dev": {
+ "nette/tester": "~2.0",
+ "tracy/tracy": "^2.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.4-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause",
+ "GPL-2.0",
+ "GPL-3.0"
+ ],
+ "authors": [
+ {
+ "name": "David Grudl",
+ "homepage": "https://davidgrudl.com"
+ },
+ {
+ "name": "Nette Community",
+ "homepage": "https://nette.org/contributors"
+ }
+ ],
+ "description": "🔍 Nette Finder: find files and directories with an intuitive API.",
+ "homepage": "https://nette.org",
+ "keywords": [
+ "filesystem",
+ "glob",
+ "iterator",
+ "nette"
+ ],
+ "time": "2018-06-28T11:49:23+00:00"
+ },
+ {
+ "name": "nette/neon",
+ "version": "v2.4.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/nette/neon.git",
+ "reference": "5e72b1dd3e2d34f0863c5561139a19df6a1ef398"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/nette/neon/zipball/5e72b1dd3e2d34f0863c5561139a19df6a1ef398",
+ "reference": "5e72b1dd3e2d34f0863c5561139a19df6a1ef398",
+ "shasum": ""
+ },
+ "require": {
+ "ext-iconv": "*",
+ "ext-json": "*",
+ "php": ">=5.6.0"
+ },
+ "require-dev": {
+ "nette/tester": "~2.0",
+ "tracy/tracy": "^2.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.4-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause",
+ "GPL-2.0",
+ "GPL-3.0"
+ ],
+ "authors": [
+ {
+ "name": "David Grudl",
+ "homepage": "https://davidgrudl.com"
+ },
+ {
+ "name": "Nette Community",
+ "homepage": "https://nette.org/contributors"
+ }
+ ],
+ "description": "🍸 Nette NEON: encodes and decodes NEON file format.",
+ "homepage": "http://ne-on.org",
+ "keywords": [
+ "export",
+ "import",
+ "neon",
+ "nette",
+ "yaml"
+ ],
+ "time": "2018-03-21T12:12:21+00:00"
+ },
+ {
+ "name": "nette/php-generator",
+ "version": "v3.0.5",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/nette/php-generator.git",
+ "reference": "ea90209c2e8a7cd087b2742ca553c047a8df5eff"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/nette/php-generator/zipball/ea90209c2e8a7cd087b2742ca553c047a8df5eff",
+ "reference": "ea90209c2e8a7cd087b2742ca553c047a8df5eff",
+ "shasum": ""
+ },
+ "require": {
+ "nette/utils": "^2.4.2 || ~3.0.0",
+ "php": ">=7.0"
+ },
+ "conflict": {
+ "nette/nette": "<2.2"
+ },
+ "require-dev": {
+ "nette/tester": "^2.0",
+ "tracy/tracy": "^2.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.0-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause",
+ "GPL-2.0",
+ "GPL-3.0"
+ ],
+ "authors": [
+ {
+ "name": "David Grudl",
+ "homepage": "https://davidgrudl.com"
+ },
+ {
+ "name": "Nette Community",
+ "homepage": "https://nette.org/contributors"
+ }
+ ],
+ "description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.2 features.",
+ "homepage": "https://nette.org",
+ "keywords": [
+ "code",
+ "nette",
+ "php",
+ "scaffolding"
+ ],
+ "time": "2018-08-09T14:32:27+00:00"
+ },
+ {
+ "name": "nette/robot-loader",
+ "version": "v3.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/nette/robot-loader.git",
+ "reference": "fc76c70e740b10f091e502b2e393d0be912f38d4"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/nette/robot-loader/zipball/fc76c70e740b10f091e502b2e393d0be912f38d4",
+ "reference": "fc76c70e740b10f091e502b2e393d0be912f38d4",
+ "shasum": ""
+ },
+ "require": {
+ "ext-tokenizer": "*",
+ "nette/finder": "^2.3 || ^3.0",
+ "nette/utils": "^2.4 || ^3.0",
+ "php": ">=5.6.0"
+ },
+ "conflict": {
+ "nette/nette": "<2.2"
+ },
+ "require-dev": {
+ "nette/tester": "^2.0",
+ "tracy/tracy": "^2.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.1-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause",
+ "GPL-2.0",
+ "GPL-3.0"
+ ],
+ "authors": [
+ {
+ "name": "David Grudl",
+ "homepage": "https://davidgrudl.com"
+ },
+ {
+ "name": "Nette Community",
+ "homepage": "https://nette.org/contributors"
+ }
+ ],
+ "description": "🍀 Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.",
+ "homepage": "https://nette.org",
+ "keywords": [
+ "autoload",
+ "class",
+ "interface",
+ "nette",
+ "trait"
+ ],
+ "time": "2018-08-13T14:19:06+00:00"
+ },
+ {
+ "name": "nette/utils",
+ "version": "v2.5.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/nette/utils.git",
+ "reference": "17b9f76f2abd0c943adfb556e56f2165460b15ce"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/nette/utils/zipball/17b9f76f2abd0c943adfb556e56f2165460b15ce",
+ "reference": "17b9f76f2abd0c943adfb556e56f2165460b15ce",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.6.0"
+ },
+ "conflict": {
+ "nette/nette": "<2.2"
+ },
+ "require-dev": {
+ "nette/tester": "~2.0",
+ "tracy/tracy": "^2.3"
+ },
+ "suggest": {
+ "ext-gd": "to use Image",
+ "ext-iconv": "to use Strings::webalize() and toAscii()",
+ "ext-intl": "for script transliteration in Strings::webalize() and toAscii()",
+ "ext-json": "to use Nette\\Utils\\Json",
+ "ext-mbstring": "to use Strings::lower() etc...",
+ "ext-xml": "to use Strings::length() etc. when mbstring is not available"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.5-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ],
+ "files": [
+ "src/loader.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause",
+ "GPL-2.0",
+ "GPL-3.0"
+ ],
+ "authors": [
+ {
+ "name": "David Grudl",
+ "homepage": "https://davidgrudl.com"
+ },
+ {
+ "name": "Nette Community",
+ "homepage": "https://nette.org/contributors"
+ }
+ ],
+ "description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.",
+ "homepage": "https://nette.org",
+ "keywords": [
+ "array",
+ "core",
+ "datetime",
+ "images",
+ "json",
+ "nette",
+ "paginator",
+ "password",
+ "slugify",
+ "string",
+ "unicode",
+ "utf-8",
+ "utility",
+ "validation"
+ ],
+ "time": "2018-09-18T10:22:16+00:00"
+ },
+ {
+ "name": "nikic/php-parser",
+ "version": "v4.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/nikic/PHP-Parser.git",
+ "reference": "594bcae1fc0bccd3993d2f0d61a018e26ac2865a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/594bcae1fc0bccd3993d2f0d61a018e26ac2865a",
+ "reference": "594bcae1fc0bccd3993d2f0d61a018e26ac2865a",
+ "shasum": ""
+ },
+ "require": {
+ "ext-tokenizer": "*",
+ "php": ">=7.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^6.5 || ^7.0"
+ },
+ "bin": [
+ "bin/php-parse"
+ ],
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.2-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "PhpParser\\": "lib/PhpParser"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Nikita Popov"
+ }
+ ],
+ "description": "A PHP parser written in PHP",
+ "keywords": [
+ "parser",
+ "php"
+ ],
+ "time": "2019-01-12T16:31:37+00:00"
+ },
+ {
+ "name": "ocramius/package-versions",
+ "version": "1.3.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Ocramius/PackageVersions.git",
+ "reference": "4489d5002c49d55576fa0ba786f42dbb009be46f"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/4489d5002c49d55576fa0ba786f42dbb009be46f",
+ "reference": "4489d5002c49d55576fa0ba786f42dbb009be46f",
+ "shasum": ""
+ },
+ "require": {
+ "composer-plugin-api": "^1.0.0",
+ "php": "^7.1.0"
+ },
+ "require-dev": {
+ "composer/composer": "^1.6.3",
+ "ext-zip": "*",
+ "infection/infection": "^0.7.1",
+ "phpunit/phpunit": "^7.0.0"
+ },
+ "type": "composer-plugin",
+ "extra": {
+ "class": "PackageVersions\\Installer",
+ "branch-alias": {
+ "dev-master": "2.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "PackageVersions\\": "src/PackageVersions"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Marco Pivetta",
+ "email": "ocramius at gmail.com"
+ }
+ ],
+ "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)",
+ "time": "2018-02-05T13:05:30+00:00"
+ },
+ {
+ "name": "phpstan/phpdoc-parser",
+ "version": "0.3.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpstan/phpdoc-parser.git",
+ "reference": "2cc49f47c69b023eaf05b48e6529389893b13d74"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/2cc49f47c69b023eaf05b48e6529389893b13d74",
+ "reference": "2cc49f47c69b023eaf05b48e6529389893b13d74",
+ "shasum": ""
+ },
+ "require": {
+ "php": "~7.1"
+ },
+ "require-dev": {
+ "consistence/coding-standard": "^2.0.0",
+ "jakub-onderka/php-parallel-lint": "^0.9.2",
+ "phing/phing": "^2.16.0",
+ "phpstan/phpstan": "^0.10",
+ "phpunit/phpunit": "^6.3",
+ "slevomat/coding-standard": "^3.3.0",
+ "symfony/process": "^3.4 || ^4.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "0.3-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "PHPStan\\PhpDocParser\\": [
+ "src/"
+ ]
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "PHPDoc parser with support for nullable, intersection and generic types",
+ "time": "2019-01-14T12:26:23+00:00"
+ },
+ {
+ "name": "phpstan/phpstan",
+ "version": "0.11.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpstan/phpstan.git",
+ "reference": "a138b8a2731b2c19f1dffa2f1411984a638fe977"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpstan/phpstan/zipball/a138b8a2731b2c19f1dffa2f1411984a638fe977",
+ "reference": "a138b8a2731b2c19f1dffa2f1411984a638fe977",
+ "shasum": ""
+ },
+ "require": {
+ "composer/xdebug-handler": "^1.3.0",
+ "jean85/pretty-package-versions": "^1.0.3",
+ "nette/bootstrap": "^2.4 || ^3.0",
+ "nette/di": "^2.4.7 || ^3.0",
+ "nette/robot-loader": "^3.0.1",
+ "nette/utils": "^2.4.5 || ^3.0",
+ "nikic/php-parser": "^4.0.2",
+ "php": "~7.1",
+ "phpstan/phpdoc-parser": "^0.3",
+ "symfony/console": "~3.2 || ~4.0",
+ "symfony/finder": "~3.2 || ~4.0"
+ },
+ "conflict": {
+ "symfony/console": "3.4.16 || 4.1.5"
+ },
+ "require-dev": {
+ "brianium/paratest": "^2.0",
+ "consistence/coding-standard": "^3.5",
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
+ "ext-intl": "*",
+ "ext-mysqli": "*",
+ "ext-soap": "*",
+ "ext-zip": "*",
+ "jakub-onderka/php-parallel-lint": "^1.0",
+ "localheinz/composer-normalize": "^1.1.0",
+ "phing/phing": "^2.16.0",
+ "phpstan/phpstan-deprecation-rules": "^0.11",
+ "phpstan/phpstan-php-parser": "^0.11",
+ "phpstan/phpstan-phpunit": "^0.11",
+ "phpstan/phpstan-strict-rules": "^0.11",
+ "phpunit/phpunit": "^7.0",
+ "slevomat/coding-standard": "^4.7.2",
+ "squizlabs/php_codesniffer": "^3.3.2"
+ },
+ "bin": [
+ "bin/phpstan"
+ ],
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "0.11-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "PHPStan\\": [
+ "src/",
+ "build/PHPStan"
+ ]
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "PHPStan - PHP Static Analysis Tool",
+ "time": "2019-01-19T20:23:08+00:00"
+ },
+ {
+ "name": "psr/log",
+ "version": "1.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/log.git",
+ "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
+ "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Log\\": "Psr/Log/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interface for logging libraries",
+ "homepage": "https://github.com/php-fig/log",
+ "keywords": [
+ "log",
+ "psr",
+ "psr-3"
+ ],
+ "time": "2018-11-20T15:27:04+00:00"
+ },
+ {
+ "name": "squizlabs/php_codesniffer",
+ "version": "3.4.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
+ "reference": "379deb987e26c7cd103a7b387aea178baec96e48"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/379deb987e26c7cd103a7b387aea178baec96e48",
+ "reference": "379deb987e26c7cd103a7b387aea178baec96e48",
+ "shasum": ""
+ },
+ "require": {
+ "ext-simplexml": "*",
+ "ext-tokenizer": "*",
+ "ext-xmlwriter": "*",
+ "php": ">=5.4.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
+ },
+ "bin": [
+ "bin/phpcs",
+ "bin/phpcbf"
+ ],
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.x-dev"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Greg Sherwood",
+ "role": "lead"
+ }
+ ],
+ "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
+ "homepage": "http://www.squizlabs.com/php-codesniffer",
+ "keywords": [
+ "phpcs",
+ "standards"
+ ],
+ "time": "2018-12-19T23:57:18+00:00"
+ },
+ {
+ "name": "symfony/console",
+ "version": "v4.2.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/console.git",
+ "reference": "b0a03c1bb0fcbe288629956cf2f1dd3f1dc97522"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/console/zipball/b0a03c1bb0fcbe288629956cf2f1dd3f1dc97522",
+ "reference": "b0a03c1bb0fcbe288629956cf2f1dd3f1dc97522",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1.3",
+ "symfony/contracts": "^1.0",
+ "symfony/polyfill-mbstring": "~1.0"
+ },
+ "conflict": {
+ "symfony/dependency-injection": "<3.4",
+ "symfony/process": "<3.3"
+ },
+ "require-dev": {
+ "psr/log": "~1.0",
+ "symfony/config": "~3.4|~4.0",
+ "symfony/dependency-injection": "~3.4|~4.0",
+ "symfony/event-dispatcher": "~3.4|~4.0",
+ "symfony/lock": "~3.4|~4.0",
+ "symfony/process": "~3.4|~4.0"
+ },
+ "suggest": {
+ "psr/log-implementation": "For using the console logger",
+ "symfony/event-dispatcher": "",
+ "symfony/lock": "",
+ "symfony/process": ""
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.2-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Console\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien at symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Console Component",
+ "homepage": "https://symfony.com",
+ "time": "2019-01-04T15:13:53+00:00"
+ },
+ {
+ "name": "symfony/contracts",
+ "version": "v1.0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/contracts.git",
+ "reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/contracts/zipball/1aa7ab2429c3d594dd70689604b5cf7421254cdf",
+ "reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1.3"
+ },
+ "require-dev": {
+ "psr/cache": "^1.0",
+ "psr/container": "^1.0"
+ },
+ "suggest": {
+ "psr/cache": "When using the Cache contracts",
+ "psr/container": "When using the Service contracts",
+ "symfony/cache-contracts-implementation": "",
+ "symfony/service-contracts-implementation": "",
+ "symfony/translation-contracts-implementation": ""
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Contracts\\": ""
+ },
+ "exclude-from-classmap": [
+ "**/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p at tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "A set of abstractions extracted out of the Symfony components",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "abstractions",
+ "contracts",
+ "decoupling",
+ "interfaces",
+ "interoperability",
+ "standards"
+ ],
+ "time": "2018-12-05T08:06:11+00:00"
+ },
+ {
+ "name": "symfony/finder",
+ "version": "v4.2.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/finder.git",
+ "reference": "9094d69e8c6ee3fe186a0ec5a4f1401e506071ce"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/finder/zipball/9094d69e8c6ee3fe186a0ec5a4f1401e506071ce",
+ "reference": "9094d69e8c6ee3fe186a0ec5a4f1401e506071ce",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.2-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Finder\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien at symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Finder Component",
+ "homepage": "https://symfony.com",
+ "time": "2019-01-03T09:07:35+00:00"
+ },
+ {
+ "name": "symfony/polyfill-mbstring",
+ "version": "v1.10.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-mbstring.git",
+ "reference": "c79c051f5b3a46be09205c73b80b346e4153e494"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494",
+ "reference": "c79c051f5b3a46be09205c73b80b346e4153e494",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "suggest": {
+ "ext-mbstring": "For best performance"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.9-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Polyfill\\Mbstring\\": ""
+ },
+ "files": [
+ "bootstrap.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p at tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill for the Mbstring extension",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "mbstring",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "time": "2018-09-21T13:07:52+00:00"
+ }
+ ],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
Commit: 851bb41bb72b01a4543ac9a098a11f6519fd1ee4
https://github.com/scummvm/scummvm-web/commit/851bb41bb72b01a4543ac9a098a11f6519fd1ee4
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Auto-fix to PSR-2 standard
Changed paths:
include/Controller.php
include/ExceptionHandler.php
include/I18N.php
include/Models/ArticleModel.php
include/Models/BasicModel.php
include/Models/CompatibilityModel.php
include/Models/CreditsModel.php
include/Models/DocumentationModel.php
include/Models/DownloadsModel.php
include/Models/FAQModel.php
include/Models/GameDemosModel.php
include/Models/GamesModel.php
include/Models/LinksModel.php
include/Models/MenuModel.php
include/Models/NewsModel.php
include/Models/ScreenshotsModel.php
include/Models/SubprojectsModel.php
include/Objects/Article.php
include/Objects/BasicObject.php
include/Objects/CSection.php
include/Objects/CompatGame.php
include/Objects/DSection.php
include/Objects/DSubSection.php
include/Objects/Document.php
include/Objects/File.php
include/Objects/GameDemo.php
include/Objects/MenuItem.php
include/Objects/News.php
include/Objects/Person.php
include/Objects/Project.php
include/Objects/QAEntry.php
include/Objects/QASection.php
include/Objects/Screenshot.php
include/Objects/WebLink.php
include/Pages/CompatibilityPage.php
include/Pages/ContactPage.php
include/Pages/CreditsPage.php
include/Pages/DemosPage.php
include/Pages/DocumentationPage.php
include/Pages/DownloadsPage.php
include/Pages/ExceptionsPage.php
include/Pages/FAQPage.php
include/Pages/FeedsPage.php
include/Pages/GamesPage.php
include/Pages/LinksPage.php
include/Pages/NewsPage.php
include/Pages/PressPage.php
include/Pages/PressSnowberryPage.php
include/Pages/ScreenshotsPage.php
include/Pages/SubprojectsPage.php
include/XMLParser.php
include/config.inc.php
diff --git a/include/Controller.php b/include/Controller.php
index 42aa86a..cff0a74 100644
--- a/include/Controller.php
+++ b/include/Controller.php
@@ -6,178 +6,188 @@ require_once('Models/MenuModel.php');
* as specified in config.inc. Should be subclassed by all webpages so they can
* take advantage of Smarty.
*/
-class Controller {
- private $_smarty;
- private $_template;
- private $_title;
- private $_css_files;
- private $_js_files;
- private $_show_intro;
- private $_content_title;
- private $_content;
-
- /**
- * Constructor that will create a Smarty object and configure it according
- * to what's been specified in config.inc.
- */
- public function __construct() {
- /* Create a Smarty object. */
- $this->_smarty = new Smarty();
-
- # Stick it globally so we could refer the translations
- global $Smarty;
- $Smarty = $this->_smarty;
-
- global $lang;
- global $available_languages;
-
- /* Configure smarty. */
- $this->_smarty->compile_dir = SMARTY_DIR_COMPILE;
- $this->_smarty->cache_dir = SMARTY_DIR_CACHE;
- $this->_smarty->config_dir = SMARTY_DIR_CONFIG;
- $this->_smarty->caching = SMARTY_CACHING_ENABLE;
- $this->_smarty->cache_lifetime = SMARTY_CACHING_LIFETIME;
- $this->_smarty->compile_check = SMARTY_CACHING_COMPILE_CHECK;
- $this->_smarty->force_compile = SMARTY_CACHING_FORCE_RECHECK;
- $this->_smarty->template_dir = array("templates_$lang", 'templates');
- $this->_smarty->compile_id = $lang;
- $this->_smarty->config_dir = ".";
-
- # First we read English, so all defaults are there
- $this->_smarty->configLoad(DIR_LANG . "/lang.en.ini");
-
- # Now we try to read translations
- if (is_file(($fname = DIR_LANG . "/lang.$lang.ini"))
- && is_readable($fname)) {
- $this->_smarty->configLoad($fname);
- }
+class Controller
+{
+ private $_smarty;
+ private $_template;
+ private $_title;
+ private $_css_files;
+ private $_js_files;
+ private $_show_intro;
+ private $_content_title;
+ private $_content;
+
+ /**
+ * Constructor that will create a Smarty object and configure it according
+ * to what's been specified in config.inc.
+ */
+ public function __construct()
+ {
+ /* Create a Smarty object. */
+ $this->_smarty = new Smarty();
+
+ # Stick it globally so we could refer the translations
+ global $Smarty;
+ $Smarty = $this->_smarty;
+
+ global $lang;
+ global $available_languages;
+
+ /* Configure smarty. */
+ $this->_smarty->compile_dir = SMARTY_DIR_COMPILE;
+ $this->_smarty->cache_dir = SMARTY_DIR_CACHE;
+ $this->_smarty->config_dir = SMARTY_DIR_CONFIG;
+ $this->_smarty->caching = SMARTY_CACHING_ENABLE;
+ $this->_smarty->cache_lifetime = SMARTY_CACHING_LIFETIME;
+ $this->_smarty->compile_check = SMARTY_CACHING_COMPILE_CHECK;
+ $this->_smarty->force_compile = SMARTY_CACHING_FORCE_RECHECK;
+ $this->_smarty->template_dir = array("templates_$lang", 'templates');
+ $this->_smarty->compile_id = $lang;
+ $this->_smarty->config_dir = ".";
+
+ # First we read English, so all defaults are there
+ $this->_smarty->configLoad(DIR_LANG . "/lang.en.ini");
+
+ # Now we try to read translations
+ if (is_file(($fname = DIR_LANG . "/lang.$lang.ini"))
+ && is_readable($fname)) {
+ $this->_smarty->configLoad($fname);
+ }
- setlocale(LC_TIME, $Smarty->getConfigVars('locale'));
-
- /**
- * Add a output-filter to make sure ampersands are properly encoded to
- * HTML-entities.
- */
- $this->_smarty->registerFilter('output', array($this, 'outputFilter'));
-
- /* Give Smarty-template access to date(). */
- $this->_smarty->registerPlugin('modifier', 'date_f', array(&$this, 'date_f'));
- $this->_smarty->registerPlugin('modifier', 'date_localized', array(&$this, 'date_localized'));
-
- /* Give Smarty-templates access to the ampersandEntity() function. */
- $this->_smarty->registerPlugin(
- 'modifier',
- 'escapeAmpersand',
- array(&$this, 'ampersandEntity')
- );
-
- $this->_title = '';
- $this->_css_files = array();
- $this->_js_files = array();
- $this->_show_intro = false;
- $this->_content_title = '';
- $this->_content = '';
-
- /* The menus have caused an exception, need to skip them. */
- if (!ExceptionHandler::skipMenus()) {
- $menus = MenuModel::getAllMenus();
- }
-
- # Construct lang URL
- $pageurl = preg_replace('/\?lang=[a-z]*$/', '', $_SERVER['REQUEST_URI']);
-
- /* Set up the common variables before displaying. */
- $vars = array(
- 'release' => RELEASE,
- 'baseurl' => URL_BASE,
- 'heroes_num' => HEROES_NUM,
- 'menus' => $menus,
- 'pageurl' => $pageurl,
- 'available_languages' => $available_languages,
- );
- $this->_smarty->assign($vars);
- }
-
- /** Smarty outputfilter, run just before displaying. */
- public function outputFilter($string, $smarty) {
- /* Properly encode all ampersands as "&". */
- $string = preg_replace('/&(?!([a-z]+|(#\d+));)/i', '&', $string);
- /* Replace weird characters that appears in some of the data. */
- return $string;
- }
-
- /** Escape ampersands to the HTML-entitiy '&'. */
- static public function ampersandEntity($string) {
- //return preg_replace('/&(?!amp|nbsp|lt|gt|quot;)/', '&', $string);
- //return preg_replace('/&(?![a-z];|#[0-9];)/', '&', $string);
- return $string;
- }
-
- /** Formating of dates, registered as a modifier for Smarty templates. */
- public function date_f($timestamp, $format) {
- return date($format, $timestamp);
- }
-
- /** Formating of dateAs, registered as a modifier for Smarty templates. */
- public function date_localized($timestamp, $format) {
- if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
- $format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format);
- }
- return strftime($format, $timestamp);
- }
-
- /* Render the HTML using the template and any set variables and displays it. */
- public function display($content) {
- if (!is_string($content) || strlen($content) == 0) {
- }
- $vars = array(
- 'css_files' => $this->_css_files,
- 'js_files' => $this->_js_files,
- 'content' => $content,
- );
- $this->_smarty->assign($vars);
- return $this->_smarty->display('pages/index.tpl');
- }
-
- /* Render the HTML using the template and any set variables and returns it. */
- public function fetch($template, $vars=Null) {
- if (!is_file(SMARTY_DIR_TEMPLATE . "/{$template}")) {
- }
- if (!is_null($vars)) {
- $this->_smarty->assign($vars);
- }
- return $this->_smarty->fetch($template);
- }
-
- /* Set up the variables used by the template and render the page. */
- public function renderPage($vars, $template) {
- if (!is_string($template)) {
- }
- return $this->display($this->fetch($template, $vars));
- }
-
- /* Assign extra CSS files needed by the different pages/templates. */
- public function addCSSFiles($extra_css) {
- if (is_array($extra_css)) {
- $this->_css_files = array_merge(
- $this->_css_files,
- $extra_css
- );
- } else if (is_string($extra_css) && strlen($extra_css) > 0) {
- $this->_css_files[] = $extra_css;
- }
- }
-
- /* Assign javascripts files needed by the different pages/templates. */
- public function addJSFiles($extra_js) {
- if (is_array($extra_js)) {
- $this->_js_files = array_merge(
- $this->_js_files,
- $extra_js
- );
- } else if (is_string($extra_js) && strlen($extra_js) > 0) {
- $this->_js_files[] = $extra_js;
- }
- }
+ setlocale(LC_TIME, $Smarty->getConfigVars('locale'));
+
+ /**
+ * Add a output-filter to make sure ampersands are properly encoded to
+ * HTML-entities.
+ */
+ $this->_smarty->registerFilter('output', array($this, 'outputFilter'));
+
+ /* Give Smarty-template access to date(). */
+ $this->_smarty->registerPlugin('modifier', 'date_f', array(&$this, 'date_f'));
+ $this->_smarty->registerPlugin('modifier', 'date_localized', array(&$this, 'date_localized'));
+
+ /* Give Smarty-templates access to the ampersandEntity() function. */
+ $this->_smarty->registerPlugin(
+ 'modifier',
+ 'escapeAmpersand',
+ array(&$this, 'ampersandEntity')
+ );
+
+ $this->_title = '';
+ $this->_css_files = array();
+ $this->_js_files = array();
+ $this->_show_intro = false;
+ $this->_content_title = '';
+ $this->_content = '';
+
+ /* The menus have caused an exception, need to skip them. */
+ if (!ExceptionHandler::skipMenus()) {
+ $menus = MenuModel::getAllMenus();
+ }
+
+ # Construct lang URL
+ $pageurl = preg_replace('/\?lang=[a-z]*$/', '', $_SERVER['REQUEST_URI']);
+
+ /* Set up the common variables before displaying. */
+ $vars = array(
+ 'release' => RELEASE,
+ 'baseurl' => URL_BASE,
+ 'heroes_num' => HEROES_NUM,
+ 'menus' => $menus,
+ 'pageurl' => $pageurl,
+ 'available_languages' => $available_languages,
+ );
+ $this->_smarty->assign($vars);
+ }
+
+ /** Smarty outputfilter, run just before displaying. */
+ public function outputFilter($string, $smarty)
+ {
+ /* Properly encode all ampersands as "&". */
+ $string = preg_replace('/&(?!([a-z]+|(#\d+));)/i', '&', $string);
+ /* Replace weird characters that appears in some of the data. */
+ return $string;
+ }
+
+ /** Escape ampersands to the HTML-entitiy '&'. */
+ public static function ampersandEntity($string)
+ {
+ //return preg_replace('/&(?!amp|nbsp|lt|gt|quot;)/', '&', $string);
+ //return preg_replace('/&(?![a-z];|#[0-9];)/', '&', $string);
+ return $string;
+ }
+
+ /** Formating of dates, registered as a modifier for Smarty templates. */
+ public function date_f($timestamp, $format)
+ {
+ return date($format, $timestamp);
+ }
+
+ /** Formating of dateAs, registered as a modifier for Smarty templates. */
+ public function date_localized($timestamp, $format)
+ {
+ if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
+ $format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format);
+ }
+ return strftime($format, $timestamp);
+ }
+
+ /* Render the HTML using the template and any set variables and displays it. */
+ public function display($content)
+ {
+ if (!is_string($content) || strlen($content) == 0) {
+ }
+ $vars = array(
+ 'css_files' => $this->_css_files,
+ 'js_files' => $this->_js_files,
+ 'content' => $content,
+ );
+ $this->_smarty->assign($vars);
+ return $this->_smarty->display('pages/index.tpl');
+ }
+
+ /* Render the HTML using the template and any set variables and returns it. */
+ public function fetch($template, $vars = null)
+ {
+ if (!is_file(SMARTY_DIR_TEMPLATE . "/{$template}")) {
+ }
+ if (!is_null($vars)) {
+ $this->_smarty->assign($vars);
+ }
+ return $this->_smarty->fetch($template);
+ }
+
+ /* Set up the variables used by the template and render the page. */
+ public function renderPage($vars, $template)
+ {
+ if (!is_string($template)) {
+ }
+ return $this->display($this->fetch($template, $vars));
+ }
+
+ /* Assign extra CSS files needed by the different pages/templates. */
+ public function addCSSFiles($extra_css)
+ {
+ if (is_array($extra_css)) {
+ $this->_css_files = array_merge(
+ $this->_css_files,
+ $extra_css
+ );
+ } elseif (is_string($extra_css) && strlen($extra_css) > 0) {
+ $this->_css_files[] = $extra_css;
+ }
+ }
+
+ /* Assign javascripts files needed by the different pages/templates. */
+ public function addJSFiles($extra_js)
+ {
+ if (is_array($extra_js)) {
+ $this->_js_files = array_merge(
+ $this->_js_files,
+ $extra_js
+ );
+ } elseif (is_string($extra_js) && strlen($extra_js) > 0) {
+ $this->_js_files[] = $extra_js;
+ }
+ }
}
-?>
diff --git a/include/ExceptionHandler.php b/include/ExceptionHandler.php
index 08e9dca..816762b 100644
--- a/include/ExceptionHandler.php
+++ b/include/ExceptionHandler.php
@@ -1,36 +1,38 @@
<?php
/** Handle uncaught exceptions. */
-abstract class ExceptionHandler {
- static private $_exception;
-
- /* If the MenuModel cause the exception we need to skip them. */
- static public function skipMenus() {
- $skip_menus = false;
- $e = self::$_exception;
+abstract class ExceptionHandler
+{
+ private static $_exception;
+
+ /* If the MenuModel cause the exception we need to skip them. */
+ public static function skipMenus()
+ {
+ $skip_menus = false;
+ $e = self::$_exception;
- if (!is_null($e)) {
- if (basename($e->getFile() == 'MenuModel.php')) {
- $skip_menus = true;
- } else {
- foreach ($e->getTrace() as $t) {
- if (basename($t['file']) == 'MenuModel.php') {
- $skip_menus = true;
- break;
- }
- }
- }
- }
-
- return $skip_menus;
- }
-
- /* Handle exceptions. */
- static public function handleException(Exception $e) {
- self::$_exception = $e;
+ if (!is_null($e)) {
+ if (basename($e->getFile() == 'MenuModel.php')) {
+ $skip_menus = true;
+ } else {
+ foreach ($e->getTrace() as $t) {
+ if (basename($t['file']) == 'MenuModel.php') {
+ $skip_menus = true;
+ break;
+ }
+ }
+ }
+ }
+
+ return $skip_menus;
+ }
+
+ /* Handle exceptions. */
+ public static function handleException(Exception $e)
+ {
+ self::$_exception = $e;
- require_once('Pages/ExceptionsPage.php');
- $ep = new ExceptionsPage();
- return $ep->index($e);
- }
+ require_once('Pages/ExceptionsPage.php');
+ $ep = new ExceptionsPage();
+ return $ep->index($e);
+ }
}
-?>
\ No newline at end of file
diff --git a/include/I18N.php b/include/I18N.php
index 9ac48ff..bbb4c83 100644
--- a/include/I18N.php
+++ b/include/I18N.php
@@ -6,91 +6,93 @@ require_once('Objects/News.php');
require_once('Models/NewsModel.php');
define('DIR_NEWS', 'data/news');
-class I18N {
-
- public function __construct() {
- $config = HTMLPurifier_Config::createDefault();
- $this->_purifier = new HTMLPurifier($config);
-
- $langs = ['en', 'it', 'fr', 'ru', 'de'];
- foreach ($langs as $key => $value) {
- $this->convertLanguageJsonToSmartyIni('lang.' . $value);
- $this->updateNewsI18n($value);
+class I18N
+{
+
+ public function __construct()
+ {
+ $config = HTMLPurifier_Config::createDefault();
+ $this->_purifier = new HTMLPurifier($config);
+
+ $langs = ['en', 'it', 'fr', 'ru', 'de'];
+ foreach ($langs as $key => $value) {
+ $this->convertLanguageJsonToSmartyIni('lang.' . $value);
+ $this->updateNewsI18n($value);
+ }
}
- }
-
- private function convertLanguageJsonToSmartyIni($lang) {
- $filename = "lang/i18n/{$lang}.json";
- echo("Converting {$filename} from JSON to INI\n");
- $jsonString = file_get_contents($filename);
- $json = json_decode($jsonString);
-
- $output = "";
- foreach ($json as $key => $value) {
- $output .= $key . " = " . $this->_purifier->purify( $value ). "\n";
- }
-
- file_put_contents("lang/{$lang}.ini", $output);
- }
+ private function convertLanguageJsonToSmartyIni($lang)
+ {
+ $filename = "lang/i18n/{$lang}.json";
+ echo("Converting {$filename} from JSON to INI\n");
+ $jsonString = file_get_contents($filename);
+ $json = json_decode($jsonString);
- private function updateNewsI18n($lang) {
+ $output = "";
+ foreach ($json as $key => $value) {
+ $output .= $key . " = " . $this->_purifier->purify($value). "\n";
+ }
- // For non-english, create/overwrite JSON files from our i18n file
- if ($lang != 'en') {
- echo("Converting " . DIR_NEWS . "/i18n/news.{$lang}.json to individual JSON files\n");
- $i18n = json_decode(file_get_contents(DIR_NEWS . "/i18n/news.{$lang}.json"));
-
- foreach ($i18n as $key => $value) {
- $originalJson = json_decode(file_get_contents(DIR_NEWS . "/{$key}.json"));
- $value->date = $this->_purifier->purify( $originalJson->date );
- $value->author = $this->_purifier->purify( $originalJson->author );
- $value->title = $this->_purifier->purify( $value->title );
- $value->content = $this->_purifier->purify( $value->content );
-
- file_put_contents(DIR_NEWS . "/{$lang}/{$key}.json", json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
- }
+ file_put_contents("lang/{$lang}.ini", $output);
}
- else {
- // Update the base english i18n file
- echo("Converting individual JSON files to I18N base file\n");
- $newsJson = new stdClass();
- $news = $this->getAllNews($lang);
- foreach ($news as $key => $value) {
- $newsJson->$key = array(
- "title" => $this->_purifier->purify( $value->title ),
- "content" => $this->_purifier->purify( $value->content )
- );
- }
- file_put_contents(DIR_NEWS . "/i18n/news.{$lang}.json", json_encode($newsJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . "\n");
+ private function updateNewsI18n($lang)
+ {
+
+ // For non-english, create/overwrite JSON files from our i18n file
+ if ($lang != 'en') {
+ echo("Converting " . DIR_NEWS . "/i18n/news.{$lang}.json to individual JSON files\n");
+ $i18n = json_decode(file_get_contents(DIR_NEWS . "/i18n/news.{$lang}.json"));
+
+ foreach ($i18n as $key => $value) {
+ $originalJson = json_decode(file_get_contents(DIR_NEWS . "/{$key}.json"));
+ $value->date = $this->_purifier->purify($originalJson->date);
+ $value->author = $this->_purifier->purify($originalJson->author);
+ $value->title = $this->_purifier->purify($value->title);
+ $value->content = $this->_purifier->purify($value->content);
+
+ file_put_contents(DIR_NEWS . "/{$lang}/{$key}.json", json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
+ }
+ } else {
+ // Update the base english i18n file
+ echo("Converting individual JSON files to I18N base file\n");
+ $newsJson = new stdClass();
+ $news = $this->getAllNews($lang);
+ foreach ($news as $key => $value) {
+ $newsJson->$key = array(
+ "title" => $this->_purifier->purify($value->title),
+ "content" => $this->_purifier->purify($value->content)
+ );
+ }
+
+ file_put_contents(DIR_NEWS . "/i18n/news.{$lang}.json", json_encode($newsJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . "\n");
+ }
}
- }
-
- private function getAllNews($lang) {
- if ($lang != 'en')
- $dir = DIR_NEWS . "/{$lang}";
- else
- $dir = DIR_NEWS;
-
- if (!($files = scandir($dir))) {
- throw new ErrorException(self::NO_FILES);
- }
- $news = new stdClass();
- foreach ($files as $filename) {
- if (substr($filename, -5) != '.json') {
- continue;
- }
- if (!($data = @file_get_contents($dir . "/{$filename}"))) {
- continue;
- }
- $key = rtrim($filename, ".json");
- $news->$key = json_decode($data);
- }
- return $news;
- }
+ private function getAllNews($lang)
+ {
+ if ($lang != 'en') {
+ $dir = DIR_NEWS . "/{$lang}";
+ } else {
+ $dir = DIR_NEWS;
+ }
+
+ if (!($files = scandir($dir))) {
+ throw new ErrorException(self::NO_FILES);
+ }
+ $news = new stdClass();
+ foreach ($files as $filename) {
+ if (substr($filename, -5) != '.json') {
+ continue;
+ }
+ if (!($data = @file_get_contents($dir . "/{$filename}"))) {
+ continue;
+ }
+ $key = rtrim($filename, ".json");
+ $news->$key = json_decode($data);
+ }
+ return $news;
+ }
}
new I18N();
-?>
diff --git a/include/Models/ArticleModel.php b/include/Models/ArticleModel.php
index 2373ada..eccf74e 100644
--- a/include/Models/ArticleModel.php
+++ b/include/Models/ArticleModel.php
@@ -4,22 +4,23 @@ require_once('Objects/Article.php');
/**
* The ArticleModel class will generate Article objects.
*/
-abstract class ArticleModel extends BasicModel {
- /* Get all articles. */
- static public function getAllArticles() {
- $fname = DIR_DATA . '/press_articles.xml';
- $parser = new XMLParser();
- $a = $parser->parseByFilename($fname);
- $entries = array();
- foreach ($a['articles']['article'] as $key => $value) {
- $entries[] = new Article(array(
- 'name' => $value['name'],
- 'url' => $value['url'],
- 'language' => $value['language'],
- 'posted' => $value['posted'],
- ));
- }
- return $entries;
- }
+abstract class ArticleModel extends BasicModel
+{
+ /* Get all articles. */
+ public static function getAllArticles()
+ {
+ $fname = DIR_DATA . '/press_articles.xml';
+ $parser = new XMLParser();
+ $a = $parser->parseByFilename($fname);
+ $entries = array();
+ foreach ($a['articles']['article'] as $key => $value) {
+ $entries[] = new Article(array(
+ 'name' => $value['name'],
+ 'url' => $value['url'],
+ 'language' => $value['language'],
+ 'posted' => $value['posted'],
+ ));
+ }
+ return $entries;
+ }
}
-?>
diff --git a/include/Models/BasicModel.php b/include/Models/BasicModel.php
index b756654..a20e82d 100644
--- a/include/Models/BasicModel.php
+++ b/include/Models/BasicModel.php
@@ -1,4 +1,4 @@
<?php
-abstract class BasicModel {
+abstract class BasicModel
+{
}
-?>
diff --git a/include/Models/CompatibilityModel.php b/include/Models/CompatibilityModel.php
index 6c24900..276b4b5 100644
--- a/include/Models/CompatibilityModel.php
+++ b/include/Models/CompatibilityModel.php
@@ -5,108 +5,114 @@ require_once('XMLParser.php');
/**
* The CompatibilityModel class will generate CompatGame objects.
*/
-abstract class CompatibilityModel extends BasicModel {
- const NO_VERSION = 'No version specified.';
- const NO_VERSION_TARGET = 'No version and/or target specified.';
- const NOT_FOUND = 'Did not find any games for the specified version.';
- const NO_FILES = 'No compatibility files found.';
+abstract class CompatibilityModel extends BasicModel
+{
+ const NO_VERSION = 'No version specified.';
+ const NO_VERSION_TARGET = 'No version and/or target specified.';
+ const NOT_FOUND = 'Did not find any games for the specified version.';
+ const NO_FILES = 'No compatibility files found.';
- /* Get all the groups and the respectively demos for the specified ScummVM version. */
- static public function getAllData($version) {
- if (!is_string($version)) {
- throw new ErrorException(self::NO_VERSION);
- }
- $fname = DIR_COMPAT . "/compat-{$version}.xml";
- if (!file_exists($fname)) {
- throw new ErrorException(self::NO_FILES);
- }
- $parser = new XMLParser();
- $a = $parser->parseByFilename($fname);
- $entries = array();
- foreach ($a['compatibility']['company'] as $key => $value) {
- $games = array();
- if (is_array($value['games'])) {
- foreach ($value['games']['game'] as $data) {
- $games[] = new CompatGame($data);
- }
- $entries[$value['name']] = $games;
- }
- }
- return $entries;
- }
+ /* Get all the groups and the respectively demos for the specified ScummVM version. */
+ public static function getAllData($version)
+ {
+ if (!is_string($version)) {
+ throw new ErrorException(self::NO_VERSION);
+ }
+ $fname = DIR_COMPAT . "/compat-{$version}.xml";
+ if (!file_exists($fname)) {
+ throw new ErrorException(self::NO_FILES);
+ }
+ $parser = new XMLParser();
+ $a = $parser->parseByFilename($fname);
+ $entries = array();
+ foreach ($a['compatibility']['company'] as $key => $value) {
+ $games = array();
+ if (is_array($value['games'])) {
+ foreach ($value['games']['game'] as $data) {
+ $games[] = new CompatGame($data);
+ }
+ $entries[$value['name']] = $games;
+ }
+ }
+ return $entries;
+ }
- /**
- * Compares two version strings and returns an integer less than, equal
- * to, or greater than zero if the first argument is considered to be
- * respectively less than, equal to, or greater than the second.
- */
- static public function compareVersions($version1, $version2) {
- /* Get the length of the numeric part of the version strings. */
- $lenNumber1 = strspn($version1, ".0123456789");
- $lenNumber2 = strspn($version2, ".0123456789");
- if (($lenNumber1 == $lenNumber2) && (substr($version1, 0, $lenNumber1) == substr($version2, 0, $lenNumber2))) {
- /* Same version number. Handle special cases. */
- $extraVersion1 = substr($version1, $lenNumber1);
- $extraVersion2 = substr($version2, $lenNumber2);
+ /**
+ * Compares two version strings and returns an integer less than, equal
+ * to, or greater than zero if the first argument is considered to be
+ * respectively less than, equal to, or greater than the second.
+ */
+ public static function compareVersions($version1, $version2)
+ {
+ /* Get the length of the numeric part of the version strings. */
+ $lenNumber1 = strspn($version1, ".0123456789");
+ $lenNumber2 = strspn($version2, ".0123456789");
+ if (($lenNumber1 == $lenNumber2) && (substr($version1, 0, $lenNumber1) == substr($version2, 0, $lenNumber2))) {
+ /* Same version number. Handle special cases. */
+ $extraVersion1 = substr($version1, $lenNumber1);
+ $extraVersion2 = substr($version2, $lenNumber2);
- /* Release candidates go before the final release. */
- $rc1 = substr($extraVersion1, 0, 2);
- $rc2 = substr($extraVersion2, 0, 2);
- if (($rc1 == "rc") && ($rc2 != "rc"))
- return -1;
- if (($rc2 == "rc") && ($rc1 != "rc"))
- return 1;
+ /* Release candidates go before the final release. */
+ $rc1 = substr($extraVersion1, 0, 2);
+ $rc2 = substr($extraVersion2, 0, 2);
+ if (($rc1 == "rc") && ($rc2 != "rc")) {
+ return -1;
+ }
+ if (($rc2 == "rc") && ($rc1 != "rc")) {
+ return 1;
+ }
- /* Break the tie with the standard comparison. */
- }
- return strnatcmp($version1, $version2);
- }
+ /* Break the tie with the standard comparison. */
+ }
+ return strnatcmp($version1, $version2);
+ }
- /* Get version numbers for all available compatibility charts, excluding the DEV charts. */
- static public function getAllVersions() {
- if (!($files = scandir(DIR_COMPAT))) {
- throw new ErrorException(self::NO_FILES);
- }
- $dates = array();
- foreach ($files as $file) {
- if (substr($file, -4) != '.xml') {
- continue;
- }
- /* Always exclude the DEV-chart. */
- if (strpos($file, 'DEV') === false) {
- $dates[] = substr($file, (strpos($file, '-') + 1), -4);
- }
- }
- usort($dates, "CompatibilityModel::compareVersions");
- $dates = array_reverse($dates);
- return $dates;
- }
+ /* Get version numbers for all available compatibility charts, excluding the DEV charts. */
+ public static function getAllVersions()
+ {
+ if (!($files = scandir(DIR_COMPAT))) {
+ throw new ErrorException(self::NO_FILES);
+ }
+ $dates = array();
+ foreach ($files as $file) {
+ if (substr($file, -4) != '.xml') {
+ continue;
+ }
+ /* Always exclude the DEV-chart. */
+ if (strpos($file, 'DEV') === false) {
+ $dates[] = substr($file, (strpos($file, '-') + 1), -4);
+ }
+ }
+ usort($dates, "CompatibilityModel::compareVersions");
+ $dates = array_reverse($dates);
+ return $dates;
+ }
- /* Get a specific CompatGame-object for the requested version. */
- static public function getGameData($version, $target) {
- if (!is_string($version) || !is_string($target)) {
- throw new ErrorException(self::NO_VERSION_TARGET);
- }
- if (!($all_games = self::getAllData($version))) {
- throw new ErrorException(self::NOT_FOUND);
- }
- $g = null;
- foreach ($all_games as $company => $games) {
- foreach ($games as $game) {
- if ($game->getTarget() == $target) {
- $g = $game;
- break;
- }
- }
- if ($g != null) {
- break;
- }
- }
- if (is_null($g)) {
- throw new ErrorException(self::NOT_FOUND);
- }
+ /* Get a specific CompatGame-object for the requested version. */
+ public static function getGameData($version, $target)
+ {
+ if (!is_string($version) || !is_string($target)) {
+ throw new ErrorException(self::NO_VERSION_TARGET);
+ }
+ if (!($all_games = self::getAllData($version))) {
+ throw new ErrorException(self::NOT_FOUND);
+ }
+ $g = null;
+ foreach ($all_games as $company => $games) {
+ foreach ($games as $game) {
+ if ($game->getTarget() == $target) {
+ $g = $game;
+ break;
+ }
+ }
+ if ($g != null) {
+ break;
+ }
+ }
+ if (is_null($g)) {
+ throw new ErrorException(self::NOT_FOUND);
+ }
- return $g;
- }
+ return $g;
+ }
}
-?>
diff --git a/include/Models/CreditsModel.php b/include/Models/CreditsModel.php
index bf925c6..c6ffb0d 100644
--- a/include/Models/CreditsModel.php
+++ b/include/Models/CreditsModel.php
@@ -5,17 +5,18 @@ require_once('XMLParser.php');
/**
* The CreditsModel will generate CSection objects.
*/
-abstract class CreditsModel extends BasicModel {
- /* Get all credit sections and their contents. */
- static public function getAllCredits() {
- $fname = DIR_DATA . '/credits.xml';
- $parser = new XMLParser();
- $a = $parser->parseByFilename($fname);
- $sections = array();
- foreach ($a['credits']['section'] as $key => $value) {
- $sections[] = new CSection($value);
- }
- return $sections;
- }
+abstract class CreditsModel extends BasicModel
+{
+ /* Get all credit sections and their contents. */
+ public static function getAllCredits()
+ {
+ $fname = DIR_DATA . '/credits.xml';
+ $parser = new XMLParser();
+ $a = $parser->parseByFilename($fname);
+ $sections = array();
+ foreach ($a['credits']['section'] as $key => $value) {
+ $sections[] = new CSection($value);
+ }
+ return $sections;
+ }
}
-?>
diff --git a/include/Models/DocumentationModel.php b/include/Models/DocumentationModel.php
index 24d20e3..96d89cf 100644
--- a/include/Models/DocumentationModel.php
+++ b/include/Models/DocumentationModel.php
@@ -4,17 +4,18 @@ require_once('Objects/Document.php');
/**
* The DocumentationModel class will generate Document objects.
*/
-abstract class DocumentationModel extends BasicModel {
- /* Get all the documents. */
- static public function getAllDocuments() {
- $fname = DIR_DATA . '/documentation.xml';
- $parser = new XMLParser();
- $a = $parser->parseByFilename($fname);
- $entries = array();
- foreach ($a['documentation']['document'] as $key => $value) {
- $entries[] = new Document($value);
- }
- return $entries;
- }
+abstract class DocumentationModel extends BasicModel
+{
+ /* Get all the documents. */
+ public static function getAllDocuments()
+ {
+ $fname = DIR_DATA . '/documentation.xml';
+ $parser = new XMLParser();
+ $a = $parser->parseByFilename($fname);
+ $entries = array();
+ foreach ($a['documentation']['document'] as $key => $value) {
+ $entries[] = new Document($value);
+ }
+ return $entries;
+ }
}
-?>
diff --git a/include/Models/DownloadsModel.php b/include/Models/DownloadsModel.php
index 98d7cf1..8a19841 100644
--- a/include/Models/DownloadsModel.php
+++ b/include/Models/DownloadsModel.php
@@ -5,51 +5,53 @@ require_once('XMLParser.php');
/**
* The DownloadsModel will produce DSection objects.
*/
-abstract class DownloadsModel {
- /* Get all download entries. */
- static public function getAllDownloads() {
- $fname = DIR_DATA . '/downloads.xml';
- /* Now parse the data. */
- $parser = new XMLParser();
- $a = $parser->parseByFilename($fname);
- $sections = array();
- foreach ($a['downloads']['section'] as $key => $value) {
- $sections[] = new DSection($value);
- }
- return $sections;
- }
+abstract class DownloadsModel
+{
+ /* Get all download entries. */
+ public static function getAllDownloads()
+ {
+ $fname = DIR_DATA . '/downloads.xml';
+ /* Now parse the data. */
+ $parser = new XMLParser();
+ $a = $parser->parseByFilename($fname);
+ $sections = array();
+ foreach ($a['downloads']['section'] as $key => $value) {
+ $sections[] = new DSection($value);
+ }
+ return $sections;
+ }
- /* Get all sections and their anchors. */
- static public function getAllSections() {
- /* Get the list with all downloads/sections. */
- $downloads = self::getAllDownloads();
- $sections = array();
- foreach ($downloads as $dsection) {
- if ($dsection->getAnchor() != '' && $dsection->getTitle() != '') {
- $sections[] = array(
- 'title' => $dsection->getTitle(),
- 'anchor' => $dsection->getAnchor(),
- );
- }
- foreach ($dsection->getSubSections() as $dsubsection) {
- $title = $dsubsection->getTitle();
- /**
- * If there is no title for this subsection, use the section
- * title instead.
- */
- if (empty($title)) {
- $title = $dsection->getTitle();
- }
- $anchor = $dsubsection->getAnchor();
- if (!empty($anchor)) {
- $sections[] = array(
- 'title' => $title,
- 'anchor' => $anchor,
- );
- }
- }
- }
- return $sections;
- }
+ /* Get all sections and their anchors. */
+ public static function getAllSections()
+ {
+ /* Get the list with all downloads/sections. */
+ $downloads = self::getAllDownloads();
+ $sections = array();
+ foreach ($downloads as $dsection) {
+ if ($dsection->getAnchor() != '' && $dsection->getTitle() != '') {
+ $sections[] = array(
+ 'title' => $dsection->getTitle(),
+ 'anchor' => $dsection->getAnchor(),
+ );
+ }
+ foreach ($dsection->getSubSections() as $dsubsection) {
+ $title = $dsubsection->getTitle();
+ /**
+ * If there is no title for this subsection, use the section
+ * title instead.
+ */
+ if (empty($title)) {
+ $title = $dsection->getTitle();
+ }
+ $anchor = $dsubsection->getAnchor();
+ if (!empty($anchor)) {
+ $sections[] = array(
+ 'title' => $title,
+ 'anchor' => $anchor,
+ );
+ }
+ }
+ }
+ return $sections;
+ }
}
-?>
diff --git a/include/Models/FAQModel.php b/include/Models/FAQModel.php
index 11d9398..e914eb6 100644
--- a/include/Models/FAQModel.php
+++ b/include/Models/FAQModel.php
@@ -9,89 +9,92 @@ require_once('XMLParser.php');
* QASection-objects representing the different sections on the F.A.Q.-page on
* the website.
*/
-abstract class FAQModel extends BasicModel{
- const ERROR_READING_FILE = 'Could not load the frequently asked questions.';
+abstract class FAQModel extends BasicModel
+{
+ const ERROR_READING_FILE = 'Could not load the frequently asked questions.';
- /* Get the full path and filename for the F.A.Q. XML-file. */
- static public function getFilename() {
- global $lang;
+ /* Get the full path and filename for the F.A.Q. XML-file. */
+ public static function getFilename()
+ {
+ global $lang;
- if ($lang != 'en') {
- $localized = DIR_DATA . "/faq-xml." . $lang . ".xml";
+ if ($lang != 'en') {
+ $localized = DIR_DATA . "/faq-xml." . $lang . ".xml";
- if (is_file($localized)) {
- if (!is_readable($localized)) {
- $file = "\n\nFilename: " . basename($localized) . "\n";
- throw new ErrorException(self::FILE_NOT_FOUND . $file);
- } else {
- return $localized;
- }
- }
- }
+ if (is_file($localized)) {
+ if (!is_readable($localized)) {
+ $file = "\n\nFilename: " . basename($localized) . "\n";
+ throw new ErrorException(self::FILE_NOT_FOUND . $file);
+ } else {
+ return $localized;
+ }
+ }
+ }
- return DIR_DATA . '/faq-xml.xml';
- }
+ return DIR_DATA . '/faq-xml.xml';
+ }
- /* Get last modification time. */
- static public function getLastUpdated() {
- return date('F d, Y', @filemtime(self::getFilename()));
- }
+ /* Get last modification time. */
+ public static function getLastUpdated()
+ {
+ return date('F d, Y', @filemtime(self::getFilename()));
+ }
- /* Get all question and answers. */
- static public function getFAQ() {
- if (!($data = @file_get_contents(self::getFilename()))) {
- throw new ErrorException(self::ERROR_READING_FILE);
- }
- /**
- * Let's replace some of the docbook tags and wrap some HTML-entities
- * inside CDATA containers.
- */
- $pattern = array(
- '/<ulink\s+url="(.+)">(.+)<\/ulink>/isU',
- '/<itemizedlist>(.+)<\/itemizedlist>/isU',
- '/<listitem><simpara>(.+)<\/simpara><\/listitem>/isU',
- '/<simpara>(.+)<\/simpara>/isU',
- '/<emphasis>(.+)<\/emphasis>/isU',
- '/<envar>(.+)<\/envar>/isU',
- '/<command(?:\s+[^>]+)?>(.+)<\/command>/isU',
- '/<blockquote>(.+)<\/blockquote>/isU',
- '/<programlisting(?:\s+[^>]+)?>(.+)<\/programlisting>/isU',
- '/<quote>(.+)<\/quote>/isU',
- '/<xref linkend="(.+)"\s+endterm=".+"\/>/isU',
- '/(&(?:lt|gt|quot);)/is',
- );
- $replace = array(
- '<h:a href="\\1">\\2</h:a>',
- '<h:ul>\\1</h:ul>',
- '<h:li>\\1</h:li>',
- '<h:p>\\1</h:p>',
- '<h:span class="italic">\\1</h:span>', // emphasis
- '<h:span class="envar">\\1</h:span>',
- '<h:span class="bold">\\1</h:span>', // command
- '<h:blockquote>\\1</h:blockquote>',
- '<h:pre>\\1</h:pre>', // programlisting
- '“<h:span class="quote">\\1</h:span>”',
- '<h:a xref="\\1"/>',
- '<![CDATA[\\1]]>',
- );
- $data = preg_replace($pattern, $replace, $data);
- /* Remove this weird character as it displays as À in Firefox. */
- $data = str_replace(chr(194), '', $data);
+ /* Get all question and answers. */
+ public static function getFAQ()
+ {
+ if (!($data = @file_get_contents(self::getFilename()))) {
+ throw new ErrorException(self::ERROR_READING_FILE);
+ }
+ /**
+ * Let's replace some of the docbook tags and wrap some HTML-entities
+ * inside CDATA containers.
+ */
+ $pattern = array(
+ '/<ulink\s+url="(.+)">(.+)<\/ulink>/isU',
+ '/<itemizedlist>(.+)<\/itemizedlist>/isU',
+ '/<listitem><simpara>(.+)<\/simpara><\/listitem>/isU',
+ '/<simpara>(.+)<\/simpara>/isU',
+ '/<emphasis>(.+)<\/emphasis>/isU',
+ '/<envar>(.+)<\/envar>/isU',
+ '/<command(?:\s+[^>]+)?>(.+)<\/command>/isU',
+ '/<blockquote>(.+)<\/blockquote>/isU',
+ '/<programlisting(?:\s+[^>]+)?>(.+)<\/programlisting>/isU',
+ '/<quote>(.+)<\/quote>/isU',
+ '/<xref linkend="(.+)"\s+endterm=".+"\/>/isU',
+ '/(&(?:lt|gt|quot);)/is',
+ );
+ $replace = array(
+ '<h:a href="\\1">\\2</h:a>',
+ '<h:ul>\\1</h:ul>',
+ '<h:li>\\1</h:li>',
+ '<h:p>\\1</h:p>',
+ '<h:span class="italic">\\1</h:span>', // emphasis
+ '<h:span class="envar">\\1</h:span>',
+ '<h:span class="bold">\\1</h:span>', // command
+ '<h:blockquote>\\1</h:blockquote>',
+ '<h:pre>\\1</h:pre>', // programlisting
+ '“<h:span class="quote">\\1</h:span>”',
+ '<h:a xref="\\1"/>',
+ '<![CDATA[\\1]]>',
+ );
+ $data = preg_replace($pattern, $replace, $data);
+ /* Remove this weird character as it displays as À in Firefox. */
+ $data = str_replace(chr(194), '', $data);
- /* Now parse the data. */
- $parser = new XMLParser();
- $a = $parser->parseByData($data);
- $sections = array();
- /**
- * Build a map of the defined hrefs so we can give the xrefs the correct
- * text.
- */
- $xref = array();
- $count = 1;
- foreach ($a['faq']['section'] as $data) {
- $sections[] = new QASection($data, $count++, $xref);
- }
- return $sections;
- }
+ /* Now parse the data. */
+ $parser = new XMLParser();
+ $a = $parser->parseByData($data);
+ $sections = array();
+ /**
+ * Build a map of the defined hrefs so we can give the xrefs the correct
+ * text.
+ */
+ $xref = array();
+ $count = 1;
+ foreach ($a['faq']['section'] as $data) {
+ $sections[] = new QASection($data, $count++, $xref);
+ }
+ return $sections;
+ }
}
-?>
diff --git a/include/Models/GameDemosModel.php b/include/Models/GameDemosModel.php
index 3a37531..de7f2eb 100644
--- a/include/Models/GameDemosModel.php
+++ b/include/Models/GameDemosModel.php
@@ -5,25 +5,26 @@ require_once('XMLParser.php');
/**
* The GameDemosModel class will generate GameDemo objects.
*/
-abstract class GameDemosModel extends BasicModel {
- /* Get all the groups and their respective demos. */
- static public function getAllGroupsAndDemos() {
- $fname = DIR_DATA . '/game_demos.xml';
- $parser = new XMLParser();
- $a = $parser->parseByFilename($fname);
- $entries = array();
- foreach ($a['game_demos']['group'] as $key => $value) {
- $demos = array();
- foreach ($value['demos']['demo'] as $data) {
- $demos[] = new GameDemo($data);
- }
- $entries[] = array(
- 'name' => $value['name'],
- 'href' => $value['href'],
- 'demos' => $demos,
- );
- }
- return $entries;
- }
+abstract class GameDemosModel extends BasicModel
+{
+ /* Get all the groups and their respective demos. */
+ public static function getAllGroupsAndDemos()
+ {
+ $fname = DIR_DATA . '/game_demos.xml';
+ $parser = new XMLParser();
+ $a = $parser->parseByFilename($fname);
+ $entries = array();
+ foreach ($a['game_demos']['group'] as $key => $value) {
+ $demos = array();
+ foreach ($value['demos']['demo'] as $data) {
+ $demos[] = new GameDemo($data);
+ }
+ $entries[] = array(
+ 'name' => $value['name'],
+ 'href' => $value['href'],
+ 'demos' => $demos,
+ );
+ }
+ return $entries;
+ }
}
-?>
diff --git a/include/Models/GamesModel.php b/include/Models/GamesModel.php
index 774d4cb..29ae30c 100644
--- a/include/Models/GamesModel.php
+++ b/include/Models/GamesModel.php
@@ -5,51 +5,53 @@ require_once('XMLParser.php');
/**
* The GamesModel will produce DSection objects.
*/
-abstract class GamesModel {
- /* Get all download entries. */
- static public function getAllDownloads() {
- $fname = DIR_DATA . '/games.xml';
- /* Now parse the data. */
- $parser = new XMLParser();
- $a = $parser->parseByFilename($fname);
- $sections = array();
- foreach ($a['downloads']['section'] as $key => $value) {
- $sections[] = new DSection($value);
- }
- return $sections;
- }
+abstract class GamesModel
+{
+ /* Get all download entries. */
+ public static function getAllDownloads()
+ {
+ $fname = DIR_DATA . '/games.xml';
+ /* Now parse the data. */
+ $parser = new XMLParser();
+ $a = $parser->parseByFilename($fname);
+ $sections = array();
+ foreach ($a['downloads']['section'] as $key => $value) {
+ $sections[] = new DSection($value);
+ }
+ return $sections;
+ }
- /* Get all sections and their anchors. */
- static public function getAllSections() {
- /* Get the list with all downloads/sections. */
- $downloads = self::getAllDownloads();
- $sections = array();
- foreach ($downloads as $dsection) {
- if ($dsection->getAnchor() != '' && $dsection->getTitle() != '') {
- $sections[] = array(
- 'title' => $dsection->getTitle(),
- 'anchor' => $dsection->getAnchor(),
- );
- }
- foreach ($dsection->getSubSections() as $dsubsection) {
- $title = $dsubsection->getTitle();
- /**
- * If there is no title for this subsection, use the section
- * title instead.
- */
- if (empty($title)) {
- $title = $dsection->getTitle();
- }
- $anchor = $dsubsection->getAnchor();
- if (!empty($anchor)) {
- $sections[] = array(
- 'title' => $title,
- 'anchor' => $anchor,
- );
- }
- }
- }
- return $sections;
- }
+ /* Get all sections and their anchors. */
+ public static function getAllSections()
+ {
+ /* Get the list with all downloads/sections. */
+ $downloads = self::getAllDownloads();
+ $sections = array();
+ foreach ($downloads as $dsection) {
+ if ($dsection->getAnchor() != '' && $dsection->getTitle() != '') {
+ $sections[] = array(
+ 'title' => $dsection->getTitle(),
+ 'anchor' => $dsection->getAnchor(),
+ );
+ }
+ foreach ($dsection->getSubSections() as $dsubsection) {
+ $title = $dsubsection->getTitle();
+ /**
+ * If there is no title for this subsection, use the section
+ * title instead.
+ */
+ if (empty($title)) {
+ $title = $dsection->getTitle();
+ }
+ $anchor = $dsubsection->getAnchor();
+ if (!empty($anchor)) {
+ $sections[] = array(
+ 'title' => $title,
+ 'anchor' => $anchor,
+ );
+ }
+ }
+ }
+ return $sections;
+ }
}
-?>
diff --git a/include/Models/LinksModel.php b/include/Models/LinksModel.php
index af73ef1..e1f9b75 100644
--- a/include/Models/LinksModel.php
+++ b/include/Models/LinksModel.php
@@ -6,26 +6,27 @@ require_once('XMLParser.php');
* The LinksModel class will generate WebLink objects.
* LinkGroup-objects representing a group of external links on the website.
*/
-abstract class LinksModel extends BasicModel {
- /* Get all the groups and the respectively demos. */
- static public function getAllGroupsAndLinks() {
- $fname = DIR_DATA . '/links.xml';
- $parser = new XMLParser();
- $a = $parser->parseByFilename($fname);
- $entries = array();
- foreach ($a['external_links']['group'] as $key => $value) {
- /* Get all links. */
- $links = array();
- foreach ($value['link'] as $data) {
- $links[] = new WebLink($data);
- }
- $entries[] = array(
- 'name' => $value['name'],
- 'description' => $value['description'],
- 'links' => $links,
- );
- }
- return $entries;
- }
+abstract class LinksModel extends BasicModel
+{
+ /* Get all the groups and the respectively demos. */
+ public static function getAllGroupsAndLinks()
+ {
+ $fname = DIR_DATA . '/links.xml';
+ $parser = new XMLParser();
+ $a = $parser->parseByFilename($fname);
+ $entries = array();
+ foreach ($a['external_links']['group'] as $key => $value) {
+ /* Get all links. */
+ $links = array();
+ foreach ($value['link'] as $data) {
+ $links[] = new WebLink($data);
+ }
+ $entries[] = array(
+ 'name' => $value['name'],
+ 'description' => $value['description'],
+ 'links' => $links,
+ );
+ }
+ return $entries;
+ }
}
-?>
diff --git a/include/Models/MenuModel.php b/include/Models/MenuModel.php
index a5c285f..bfcbfac 100644
--- a/include/Models/MenuModel.php
+++ b/include/Models/MenuModel.php
@@ -5,21 +5,22 @@ require_once('Objects/MenuItem.php');
/**
* The MenuModel class will generates MenuItme objects.
*/
-abstract class MenuModel extends BasicModel {
- /* Get all menu entries. */
- static public function getAllMenus() {
- $fname = DIR_DATA . '/menus.xml';
- $parser = new XMLParser();
- $a = $parser->parseByFilename($fname);
- $entries = array();
- foreach ($a['menus']['group'] as $key => $value) {
- $entries[] = new MenuItem(array(
- 'name' => $value['name'],
- 'class' => $value['class'],
- 'link' => $value['link'],
- ));
- }
- return $entries;
- }
+abstract class MenuModel extends BasicModel
+{
+ /* Get all menu entries. */
+ public static function getAllMenus()
+ {
+ $fname = DIR_DATA . '/menus.xml';
+ $parser = new XMLParser();
+ $a = $parser->parseByFilename($fname);
+ $entries = array();
+ foreach ($a['menus']['group'] as $key => $value) {
+ $entries[] = new MenuItem(array(
+ 'name' => $value['name'],
+ 'class' => $value['class'],
+ 'link' => $value['link'],
+ ));
+ }
+ return $entries;
+ }
}
-?>
diff --git a/include/Models/NewsModel.php b/include/Models/NewsModel.php
index 0e90c4c..8a6a1c1 100644
--- a/include/Models/NewsModel.php
+++ b/include/Models/NewsModel.php
@@ -4,81 +4,85 @@ require_once('Objects/News.php');
/**
* The NewsModel class will generate News objects
*/
-abstract class NewsModel extends BasicModel {
- const NO_FILES = 'No news files found.';
- const INVALID_DATE = 'Invalid date, use yyyyMMdd. or yyyyMMddHHmm';
- const FILE_NOT_FOUND = 'The requested news file doesn\'t exist.';
+abstract class NewsModel extends BasicModel
+{
+ const NO_FILES = 'No news files found.';
+ const INVALID_DATE = 'Invalid date, use yyyyMMdd. or yyyyMMddHHmm';
+ const FILE_NOT_FOUND = 'The requested news file doesn\'t exist.';
- /* Get a list of all the available news files. */
- static public function getListOfNewsFilenames() {
- if (!($files = scandir(DIR_NEWS))) {
- throw new ErrorException(self::NO_FILES);
- }
- $filenames = array();
- foreach ($files as $file) {
- if (substr($file, -5) != '.json') {
- continue;
- }
- $filenames[] = substr($file, 0, -5);
- }
- sort($filenames, SORT_STRING);
- return $filenames;
- }
+ /* Get a list of all the available news files. */
+ public static function getListOfNewsFilenames()
+ {
+ if (!($files = scandir(DIR_NEWS))) {
+ throw new ErrorException(self::NO_FILES);
+ }
+ $filenames = array();
+ foreach ($files as $file) {
+ if (substr($file, -5) != '.json') {
+ continue;
+ }
+ $filenames[] = substr($file, 0, -5);
+ }
+ sort($filenames, SORT_STRING);
+ return $filenames;
+ }
- /* Get all news items ordered by date, descending. */
- static public function getAllNews($processContent = false) {
- if (!($files = scandir(DIR_NEWS))) {
- throw new ErrorException(self::NO_FILES);
- }
- global $lang;
- $news = array();
- foreach ($files as $filename) {
- if (substr($filename, -5) != '.json') {
- continue;
- }
- if (!is_file(($fname = DIR_NEWS . "/$lang/" . basename($filename)))
- || !is_readable($fname) || !($data = @file_get_contents($fname))) {
- if (!($data = @file_get_contents(DIR_NEWS . "/{$filename}"))) {
- continue;
- }
- }
- $news[] = new News(json_decode($data), $filename, $processContent);
- }
- return array_reverse($news);
- }
+ /* Get all news items ordered by date, descending. */
+ public static function getAllNews($processContent = false)
+ {
+ if (!($files = scandir(DIR_NEWS))) {
+ throw new ErrorException(self::NO_FILES);
+ }
+ global $lang;
+ $news = array();
+ foreach ($files as $filename) {
+ if (substr($filename, -5) != '.json') {
+ continue;
+ }
+ if (!is_file(($fname = DIR_NEWS . "/$lang/" . basename($filename)))
+ || !is_readable($fname) || !($data = @file_get_contents($fname))) {
+ if (!($data = @file_get_contents(DIR_NEWS . "/{$filename}"))) {
+ continue;
+ }
+ }
+ $news[] = new News(json_decode($data), $filename, $processContent);
+ }
+ return array_reverse($news);
+ }
- /* Get the latest number of news items, or if no number is specified get all news items. */
- static public function getLatestNews($num=-1, $processContent = false) {
- if ($num == -1) {
- return NewsModel::getAllNews($processContent);
- } else {
- if (!($newslist = NewsModel::getListOfNewsFilenames())) {
- throw new ErrorException(self::NO_FILES);
- }
- rsort($newslist, SORT_STRING);
- $newslist = array_slice($newslist, 0, $num);
- $news = array();
- foreach ($newslist as $filename) {
- $news[] = NewsModel::getOneByFilename($filename, $processContent);
- }
- return $news;
- }
- }
+ /* Get the latest number of news items, or if no number is specified get all news items. */
+ public static function getLatestNews($num = -1, $processContent = false)
+ {
+ if ($num == -1) {
+ return NewsModel::getAllNews($processContent);
+ } else {
+ if (!($newslist = NewsModel::getListOfNewsFilenames())) {
+ throw new ErrorException(self::NO_FILES);
+ }
+ rsort($newslist, SORT_STRING);
+ $newslist = array_slice($newslist, 0, $num);
+ $news = array();
+ foreach ($newslist as $filename) {
+ $news[] = NewsModel::getOneByFilename($filename, $processContent);
+ }
+ return $news;
+ }
+ }
- /* Get the news item that was posted on a specific date. */
- static public function getOneByFilename($filename, $processContent = false) {
- if (is_null($filename) || !preg_match('/^\d{8,12}[a-z]?$/', $filename)) {
- throw new ErrorException(self::INVALID_DATE);
- }
- global $lang;
- if (!is_file(($fname = DIR_NEWS . "/$lang/{$filename}.json"))
- || !is_readable($fname) || !($data = @file_get_contents($fname))) {
- if (!is_file(($fname = DIR_NEWS . "/{$filename}.json"))
- || !is_readable($fname) || !($data = @file_get_contents($fname))) {
- throw new ErrorException(self::FILE_NOT_FOUND);
- }
- }
- return new News(json_decode($data), $fname, $processContent);
- }
+ /* Get the news item that was posted on a specific date. */
+ public static function getOneByFilename($filename, $processContent = false)
+ {
+ if (is_null($filename) || !preg_match('/^\d{8,12}[a-z]?$/', $filename)) {
+ throw new ErrorException(self::INVALID_DATE);
+ }
+ global $lang;
+ if (!is_file(($fname = DIR_NEWS . "/$lang/{$filename}.json"))
+ || !is_readable($fname) || !($data = @file_get_contents($fname))) {
+ if (!is_file(($fname = DIR_NEWS . "/{$filename}.json"))
+ || !is_readable($fname) || !($data = @file_get_contents($fname))) {
+ throw new ErrorException(self::FILE_NOT_FOUND);
+ }
+ }
+ return new News(json_decode($data), $fname, $processContent);
+ }
}
-?>
diff --git a/include/Models/ScreenshotsModel.php b/include/Models/ScreenshotsModel.php
index eb8bee4..9a7ba83 100644
--- a/include/Models/ScreenshotsModel.php
+++ b/include/Models/ScreenshotsModel.php
@@ -5,68 +5,72 @@ require_once('XMLParser.php');
/**
* The ScreenshotsModel will generate Screenshot objects.
*/
-abstract class ScreenshotsModel extends BasicModel {
- const INVALID_TARGET = 'Invalid target specified.';
- const INVALID_CATEGORY = 'Invalid category specified.';
+abstract class ScreenshotsModel extends BasicModel
+{
+ const INVALID_TARGET = 'Invalid target specified.';
+ const INVALID_CATEGORY = 'Invalid category specified.';
- /* Get all screenshots. */
- static public function getAllScreenshots() {
- $fname = DIR_DATA . '/screenshots.xml';
- $parser = new XMLParser();
- $a = $parser->parseByFilename($fname);
- $entries = array();
- BasicObject::toArray($a['screenshots']['group']);
- foreach ($a['screenshots']['group'] as $value) {
- BasicObject::toArray($value['game']);
- $games = array();
- foreach ($value['game'] as $data) {
- $games[] = new Screenshot($data);
- }
+ /* Get all screenshots. */
+ public static function getAllScreenshots()
+ {
+ $fname = DIR_DATA . '/screenshots.xml';
+ $parser = new XMLParser();
+ $a = $parser->parseByFilename($fname);
+ $entries = array();
+ BasicObject::toArray($a['screenshots']['group']);
+ foreach ($a['screenshots']['group'] as $value) {
+ BasicObject::toArray($value['game']);
+ $games = array();
+ foreach ($value['game'] as $data) {
+ $games[] = new Screenshot($data);
+ }
- $entries[] = array(
- 'title' => $value['title'],
- 'category' => $value['category'],
- 'games' => $games,
- );
- }
- return $entries;
- }
+ $entries[] = array(
+ 'title' => $value['title'],
+ 'category' => $value['category'],
+ 'games' => $games,
+ );
+ }
+ return $entries;
+ }
- /* Get all screenshots in one category. */
- static public function getCategoryScreenshots($category) {
- $sshots = self::getAllScreenshots();
- foreach ($sshots as $shots) {
- if ($shots['category'] == $category) {
- return $shots;
- }
- }
- throw new ErrorException(self::INVALID_CATEGORY);
- }
+ /* Get all screenshots in one category. */
+ public static function getCategoryScreenshots($category)
+ {
+ $sshots = self::getAllScreenshots();
+ foreach ($sshots as $shots) {
+ if ($shots['category'] == $category) {
+ return $shots;
+ }
+ }
+ throw new ErrorException(self::INVALID_CATEGORY);
+ }
- /* Get screenshots for a specific target. */
- static public function getTargetScreenshots($target) {
- $sshots = self::getAllScreenshots();
- foreach ($sshots as $shots) {
- foreach ($shots['games'] as $starget) {
- if ($starget->getCategory() == $target) {
- return $starget;
- }
- }
- }
- throw new ErrorException(self::INVALID_TARGET);
- }
+ /* Get screenshots for a specific target. */
+ public static function getTargetScreenshots($target)
+ {
+ $sshots = self::getAllScreenshots();
+ foreach ($sshots as $shots) {
+ foreach ($shots['games'] as $starget) {
+ if ($starget->getCategory() == $target) {
+ return $starget;
+ }
+ }
+ }
+ throw new ErrorException(self::INVALID_TARGET);
+ }
- /* Get a random screenshot (an object and not a filename) .*/
- static public function getRandomScreenshot() {
- $sshots = self::getAllScreenshots();
- $catpos = rand(0, count($sshots) - 1);
- $scrpos = rand(0, count($sshots[$catpos]['games']) - 1);
- $screenshot = array(
- 'category' => $sshots[$catpos]['category'],
- 'screenshot' => $sshots[$catpos]['games'][$scrpos],
- );
- unset ($sshots);
- return $screenshot;
- }
+ /* Get a random screenshot (an object and not a filename) .*/
+ public static function getRandomScreenshot()
+ {
+ $sshots = self::getAllScreenshots();
+ $catpos = rand(0, count($sshots) - 1);
+ $scrpos = rand(0, count($sshots[$catpos]['games']) - 1);
+ $screenshot = array(
+ 'category' => $sshots[$catpos]['category'],
+ 'screenshot' => $sshots[$catpos]['games'][$scrpos],
+ );
+ unset($sshots);
+ return $screenshot;
+ }
}
-?>
diff --git a/include/Models/SubprojectsModel.php b/include/Models/SubprojectsModel.php
index 3a5d7e6..58db17c 100644
--- a/include/Models/SubprojectsModel.php
+++ b/include/Models/SubprojectsModel.php
@@ -5,31 +5,32 @@ require_once('Objects/Project.php');
/**
* The SubprojectsModel will generate Project objects.
*/
-abstract class SubprojectsModel extends BasicModel {
- /* Get all the groups and the respectively demos. */
- static public function getAllSubprojects() {
- $fname = DIR_DATA . '/subprojects.xml';
- $parser = new XMLParser();
- $a = $parser->parseByFilename($fname);
- $entries = array();
- BasicObject::toArray($a['subprojects']['project']);
- foreach ($a['subprojects']['project'] as $key => $value) {
- $downloads = array();
- foreach ($value['entries'] as $type => $data) {
- if ($type == 'file') {
- BasicObject::toArray($data);
- foreach ($data as $file) {
- $downloads[] = new File($file);
- }
- }
- }
- $entries[] = new Project(array(
- 'name' => $value['name'],
- 'info' => $value['info'],
- 'downloads' => $downloads,
- ));
- }
- return $entries;
- }
+abstract class SubprojectsModel extends BasicModel
+{
+ /* Get all the groups and the respectively demos. */
+ public static function getAllSubprojects()
+ {
+ $fname = DIR_DATA . '/subprojects.xml';
+ $parser = new XMLParser();
+ $a = $parser->parseByFilename($fname);
+ $entries = array();
+ BasicObject::toArray($a['subprojects']['project']);
+ foreach ($a['subprojects']['project'] as $key => $value) {
+ $downloads = array();
+ foreach ($value['entries'] as $type => $data) {
+ if ($type == 'file') {
+ BasicObject::toArray($data);
+ foreach ($data as $file) {
+ $downloads[] = new File($file);
+ }
+ }
+ }
+ $entries[] = new Project(array(
+ 'name' => $value['name'],
+ 'info' => $value['info'],
+ 'downloads' => $downloads,
+ ));
+ }
+ return $entries;
+ }
}
-?>
diff --git a/include/Objects/Article.php b/include/Objects/Article.php
index c4bea18..38ebf19 100644
--- a/include/Objects/Article.php
+++ b/include/Objects/Article.php
@@ -4,38 +4,43 @@ require_once('Objects/BasicObject.php');
* The article class represents a link on the website to an article covering
* ScummVM in some way.
*/
-class Article extends BasicObject {
- private $_name;
- private $_url;
- private $_language;
- private $_posted;
+class Article extends BasicObject
+{
+ private $_name;
+ private $_url;
+ private $_language;
+ private $_posted;
- /* Article object constructor. */
- public function __construct($data) {
- $this->_name = $data['name'];
- $this->_url = $data['url'];
- $this->_language = $data['language'];
- $this->_posted = $data['posted'];
- }
+ /* Article object constructor. */
+ public function __construct($data)
+ {
+ $this->_name = $data['name'];
+ $this->_url = $data['url'];
+ $this->_language = $data['language'];
+ $this->_posted = $data['posted'];
+ }
- /* Get the name. */
- public function getName() {
- return $this->_name;
- }
+ /* Get the name. */
+ public function getName()
+ {
+ return $this->_name;
+ }
- /* Get the URL. */
- public function getURL() {
- return $this->_url;
- }
+ /* Get the URL. */
+ public function getURL()
+ {
+ return $this->_url;
+ }
- /* Get the language. */
- public function getLanguage() {
- return $this->_language;
- }
+ /* Get the language. */
+ public function getLanguage()
+ {
+ return $this->_language;
+ }
- /* Get the date it was posted. */
- public function getPosted() {
- return $this->_posted;
- }
+ /* Get the date it was posted. */
+ public function getPosted()
+ {
+ return $this->_posted;
+ }
}
-?>
diff --git a/include/Objects/BasicObject.php b/include/Objects/BasicObject.php
index 2d0abf1..7a2f757 100644
--- a/include/Objects/BasicObject.php
+++ b/include/Objects/BasicObject.php
@@ -3,17 +3,18 @@
* The BasicObject class is inherited by all other objects and houses all common
* functions.
*/
-abstract class BasicObject {
- /**
- * If the input array doesn't contain the numerical key 0, wrap it inside
- * an array. This functions operates on the data directly.
- *
- * @param mixed &$data the input
- */
- static public function toArray(&$data) {
- if (!is_array($data) || !array_key_exists(0, $data)) {
- $data = array($data);
- }
- }
+abstract class BasicObject
+{
+ /**
+ * If the input array doesn't contain the numerical key 0, wrap it inside
+ * an array. This functions operates on the data directly.
+ *
+ * @param mixed &$data the input
+ */
+ public static function toArray(&$data)
+ {
+ if (!is_array($data) || !array_key_exists(0, $data)) {
+ $data = array($data);
+ }
+ }
}
-?>
diff --git a/include/Objects/CSection.php b/include/Objects/CSection.php
index c847152..36cfb12 100644
--- a/include/Objects/CSection.php
+++ b/include/Objects/CSection.php
@@ -5,75 +5,81 @@ require_once('Objects/Person.php');
* The Section class represens a section (or a subsection) on the credits page
* on the website.
*/
-class CSection extends BasicObject {
- private $_title;
- private $_groups;
- private $_subsections;
- private $_paragraphs;
- private $_anchor;
+class CSection extends BasicObject
+{
+ private $_title;
+ private $_groups;
+ private $_subsections;
+ private $_paragraphs;
+ private $_anchor;
- /* CSection object constructor. */
- public function __construct($data) {
- $this->_title = $data['title'];
- $this->_anchor = $data['anchor'];
- $this->_groups = array();
- $this->_subsections = array();
- $this->_paragraphs = array();
+ /* CSection object constructor. */
+ public function __construct($data)
+ {
+ $this->_title = $data['title'];
+ $this->_anchor = $data['anchor'];
+ $this->_groups = array();
+ $this->_subsections = array();
+ $this->_paragraphs = array();
- if (isset ($data['subsection'])) {
- foreach ($data['subsection'] as $value) {
- $this->_subsections[] = new CSection($value);
- }
- }
- if (isset ($data['group'])) {
- parent::toArray($data['group']);
- foreach ($data['group'] as $value) {
- $persons = array();
-if (is_string($value['person'])) {
- var_dump($value);
- die();
-}
- parent::toArray($value['person']);
- foreach ($value['person'] as $args) {
- $persons[] = new Person($args);
- }
- if (count($persons) > 0) {
- $this->_groups[] = array(
- 'name' => $value['name'],
- 'persons' => $persons,
- );
- }
- }
- }
- if (isset ($data['paragraph'])) {
- parent::toArray($data['paragraph']);
- $this->_paragraphs = $data['paragraph'];
- }
- }
+ if (isset($data['subsection'])) {
+ foreach ($data['subsection'] as $value) {
+ $this->_subsections[] = new CSection($value);
+ }
+ }
+ if (isset($data['group'])) {
+ parent::toArray($data['group']);
+ foreach ($data['group'] as $value) {
+ $persons = array();
+ if (is_string($value['person'])) {
+ var_dump($value);
+ die();
+ }
+ parent::toArray($value['person']);
+ foreach ($value['person'] as $args) {
+ $persons[] = new Person($args);
+ }
+ if (count($persons) > 0) {
+ $this->_groups[] = array(
+ 'name' => $value['name'],
+ 'persons' => $persons,
+ );
+ }
+ }
+ }
+ if (isset($data['paragraph'])) {
+ parent::toArray($data['paragraph']);
+ $this->_paragraphs = $data['paragraph'];
+ }
+ }
- /* Get the title. */
- public function getTitle() {
- return $this->_title;
- }
+ /* Get the title. */
+ public function getTitle()
+ {
+ return $this->_title;
+ }
/* Get the anchor. */
- public function getAnchor() {
- return $this->_anchor;
- }
+ public function getAnchor()
+ {
+ return $this->_anchor;
+ }
- /* Get the optional list of groups. */
- public function getGroups() {
- return $this->_groups;
- }
+ /* Get the optional list of groups. */
+ public function getGroups()
+ {
+ return $this->_groups;
+ }
- /* Get the optional list of subsections. */
- public function getSubSections() {
- return $this->_subsections;
- }
+ /* Get the optional list of subsections. */
+ public function getSubSections()
+ {
+ return $this->_subsections;
+ }
- /* Get the optional list of paragraphs. */
- public function getParagraphs() {
- return $this->_paragraphs;
- }
+ /* Get the optional list of paragraphs. */
+ public function getParagraphs()
+ {
+ return $this->_paragraphs;
+ }
}
-?>
diff --git a/include/Objects/CompatGame.php b/include/Objects/CompatGame.php
index da41998..d5bf6f5 100644
--- a/include/Objects/CompatGame.php
+++ b/include/Objects/CompatGame.php
@@ -4,45 +4,50 @@ require_once('Objects/BasicObject.php');
* The CompatGame class represents a game on the compatibility charts on the
* website.
*/
-class CompatGame extends BasicObject {
- private $_name;
- private $_target;
- private $_supportLevel;
- private $_notes;
+class CompatGame extends BasicObject
+{
+ private $_name;
+ private $_target;
+ private $_supportLevel;
+ private $_notes;
- /* Project object constructor. */
- public function __construct($data) {
- $this->_name = $data['name'];
- $this->_target = $data['target'];
- // In old compat pages we used 'percent' instead of 'support_level'.
- // we still want to support those thus we check whether the old tag
- // is present here.
- if (array_key_exists('percent', $data)) {
- $this->_supportLevel = $data['percent'];
- } else {
- $this->_supportLevel = $data['support_level'];
- }
- $this->_notes = $data['notes'];
- }
+ /* Project object constructor. */
+ public function __construct($data)
+ {
+ $this->_name = $data['name'];
+ $this->_target = $data['target'];
+ // In old compat pages we used 'percent' instead of 'support_level'.
+ // we still want to support those thus we check whether the old tag
+ // is present here.
+ if (array_key_exists('percent', $data)) {
+ $this->_supportLevel = $data['percent'];
+ } else {
+ $this->_supportLevel = $data['support_level'];
+ }
+ $this->_notes = $data['notes'];
+ }
- /* Get the name. */
- public function getName() {
- return $this->_name;
- }
+ /* Get the name. */
+ public function getName()
+ {
+ return $this->_name;
+ }
- /* Get the target name. */
- public function getTarget() {
- return $this->_target;
- }
+ /* Get the target name. */
+ public function getTarget()
+ {
+ return $this->_target;
+ }
- /* Get the support level. */
- public function getSupportLevel() {
- return $this->_supportLevel;
- }
+ /* Get the support level. */
+ public function getSupportLevel()
+ {
+ return $this->_supportLevel;
+ }
- /* Get the notes. */
- public function getNotes() {
- return $this->_notes;
- }
+ /* Get the notes. */
+ public function getNotes()
+ {
+ return $this->_notes;
+ }
}
-?>
diff --git a/include/Objects/DSection.php b/include/Objects/DSection.php
index 9317e2a..e961603 100644
--- a/include/Objects/DSection.php
+++ b/include/Objects/DSection.php
@@ -4,44 +4,49 @@ require_once('Objects/DSubSection.php');
/**
* The DSection object represents a section on the downloads page.
*/
-class DSection extends BasicObject{
- private $_title;
- private $_anchor;
- private $_baseurl;
- private $_subsections;
+class DSection extends BasicObject
+{
+ private $_title;
+ private $_anchor;
+ private $_baseurl;
+ private $_subsections;
- /* DSection object constructor. */
- public function __construct($data) {
- $this->_title = $data['title'];
- $this->_anchor = $data['anchor'];
- $this->_baseurl = $data['baseurl'];
- $this->_baseturl = $data['baseturl'];
- $this->_subsections = array();
+ /* DSection object constructor. */
+ public function __construct($data)
+ {
+ $this->_title = $data['title'];
+ $this->_anchor = $data['anchor'];
+ $this->_baseurl = $data['baseurl'];
+ $this->_baseturl = $data['baseturl'];
+ $this->_subsections = array();
- parent::toArray($data['subsection']);
- foreach ($data['subsection'] as $key => $value) {
- $this->_subsections[] = new DSubSection($value, $this->_baseurl, $this->_baseturl);
- }
- }
+ parent::toArray($data['subsection']);
+ foreach ($data['subsection'] as $key => $value) {
+ $this->_subsections[] = new DSubSection($value, $this->_baseurl, $this->_baseturl);
+ }
+ }
- /* Get the title. */
- public function getTitle() {
- return $this->_title;
- }
+ /* Get the title. */
+ public function getTitle()
+ {
+ return $this->_title;
+ }
- /* Get the anchor name. */
- public function getAnchor() {
- return $this->_anchor;
- }
+ /* Get the anchor name. */
+ public function getAnchor()
+ {
+ return $this->_anchor;
+ }
- /* Get the base URL. */
- public function getBaseURL() {
- return $this->_baseurl;
- }
+ /* Get the base URL. */
+ public function getBaseURL()
+ {
+ return $this->_baseurl;
+ }
- /* Get the list of optional subsections. */
- public function getSubSections() {
- return $this->_subsections;
- }
+ /* Get the list of optional subsections. */
+ public function getSubSections()
+ {
+ return $this->_subsections;
+ }
}
-?>
diff --git a/include/Objects/DSubSection.php b/include/Objects/DSubSection.php
index 654fc43..d3edae0 100644
--- a/include/Objects/DSubSection.php
+++ b/include/Objects/DSubSection.php
@@ -5,71 +5,79 @@ require_once('Objects/WebLink.php');
/**
* The DSubSection object represents a subsection on the downloads page.
*/
-class DSubSection extends BasicObject {
- private $_title;
- private $_anchor;
- private $_notes;
- private $_footer;
- private $_files;
- private $_links;
+class DSubSection extends BasicObject
+{
+ private $_title;
+ private $_anchor;
+ private $_notes;
+ private $_footer;
+ private $_files;
+ private $_links;
- /* DSubSection constructor. */
- public function __construct($data, $baseurl, $baseturl) {
- $this->_title = $data['title'];
- $this->_anchor = $data['anchor'];
- $this->_notes = $data['notes'];
- $this->_footer = $data['footer'];
- $this->_files = array();
- $this->_links = array();
- $this->_items = array();
+ /* DSubSection constructor. */
+ public function __construct($data, $baseurl, $baseturl)
+ {
+ $this->_title = $data['title'];
+ $this->_anchor = $data['anchor'];
+ $this->_notes = $data['notes'];
+ $this->_footer = $data['footer'];
+ $this->_files = array();
+ $this->_links = array();
+ $this->_items = array();
- foreach ($data['entries'] as $type => $item) {
- parent::toArray($item);
- if ($type == 'file') {
- foreach ($item as $file) {
- $this->_items[] = new File($file, $baseurl, $baseturl);
- }
- } elseif ($type == 'link') {
- foreach ($item as $link) {
- $this->_items[] = new WebLink($link);
- }
- }
- }
- }
+ foreach ($data['entries'] as $type => $item) {
+ parent::toArray($item);
+ if ($type == 'file') {
+ foreach ($item as $file) {
+ $this->_items[] = new File($file, $baseurl, $baseturl);
+ }
+ } elseif ($type == 'link') {
+ foreach ($item as $link) {
+ $this->_items[] = new WebLink($link);
+ }
+ }
+ }
+ }
- /* Get the title. */
- public function getTitle() {
- return $this->_title;
- }
+ /* Get the title. */
+ public function getTitle()
+ {
+ return $this->_title;
+ }
- /* Get the anchor name. */
- public function getAnchor() {
- return $this->_anchor;
- }
+ /* Get the anchor name. */
+ public function getAnchor()
+ {
+ return $this->_anchor;
+ }
- /* Get the optional notes. */
- public function getNotes() {
- return $this->_notes;
- }
+ /* Get the optional notes. */
+ public function getNotes()
+ {
+ return $this->_notes;
+ }
- /* Get the optional footer. */
- public function getFooter() {
- return $this->_footer;
- }
+ /* Get the optional footer. */
+ public function getFooter()
+ {
+ return $this->_footer;
+ }
- /* Get the list of files. */
- public function getFiles() {
- return $this->_files;
- }
+ /* Get the list of files. */
+ public function getFiles()
+ {
+ return $this->_files;
+ }
- /* Get the list of links. */
- public function getLinks() {
- return $this->_links;
- }
+ /* Get the list of links. */
+ public function getLinks()
+ {
+ return $this->_links;
+ }
- /* Get the list of items. */
- public function getItems() {
- return $this->_items;
- }
+ /* Get the list of items. */
+ public function getItems()
+ {
+ return $this->_items;
+ }
}
-?>
diff --git a/include/Objects/Document.php b/include/Objects/Document.php
index 93f02ae..a68255b 100644
--- a/include/Objects/Document.php
+++ b/include/Objects/Document.php
@@ -3,31 +3,35 @@ require_once('Objects/BasicObject.php');
/**
* The Document class represents a Document on the website.
*/
-class Document extends BasicObject {
- private $_name;
- private $_url;
- private $_description;
+class Document extends BasicObject
+{
+ private $_name;
+ private $_url;
+ private $_description;
- /* Document object constructor. */
- public function __construct($data) {
- $this->_name = $data['name'];
- $this->_url = $data['url'];
- $this->_description = $data['description'];
- }
+ /* Document object constructor. */
+ public function __construct($data)
+ {
+ $this->_name = $data['name'];
+ $this->_url = $data['url'];
+ $this->_description = $data['description'];
+ }
- /* Get the name. */
- public function getName() {
- return $this->_name;
- }
+ /* Get the name. */
+ public function getName()
+ {
+ return $this->_name;
+ }
- /* Get the URL. */
- public function getURL() {
- return $this->_url;
- }
+ /* Get the URL. */
+ public function getURL()
+ {
+ return $this->_url;
+ }
- /* Get the description. */
- public function getDescription() {
- return $this->_description;
- }
+ /* Get the description. */
+ public function getDescription()
+ {
+ return $this->_description;
+ }
}
-?>
diff --git a/include/Objects/File.php b/include/Objects/File.php
index 9d440e3..7ef6557 100644
--- a/include/Objects/File.php
+++ b/include/Objects/File.php
@@ -3,125 +3,132 @@ require_once('Objects/BasicObject.php');
/**
* The File object represents a file on the website.
*/
-class File extends BasicObject {
- private $_category_icon;
- private $_url;
- private $_name;
- private $_type;
- private $_extra_info;
- private $_user_agent;
-
- public function __construct($data, $baseurl=null, $baseturl=null) {
- $this->_category_icon = $data['category_icon'];
- $this->_name = $data['name'];
- $this->_extra_info = $data['extra_info'];
- $this->_type = strtolower($data['type']);
- $this->_user_agent = isset($data["user_agent"]) ? $data["user_agent"] : "";
-
- $fname = "";
-
- /* If it's not an array, we didn't get any attributes. */
- if (!is_array($data['url'])) {
- $url = $data['url'];
- $attributes = array();
- } else {
- $url = $data['url'][0];
- $attributes = $data['url']['@attributes'];
- }
-
- if (!preg_match('/^((https?)|(ftp)):\/\//', $url)) {
- if ($attributes['type'] == 'downloads') {
- $url = DIR_DOWNLOADS . "/{$url}";
- } else if ($attributes['type'] == 'tools') {
- $url = $baseturl . $url;
- } else {
- $url = $baseurl . $url;
- }
-
- $fname = "." . $url;
- $fname = str_replace('{$release}', RELEASE, $fname);
- $fname = str_replace('{$release_tools}', RELEASE_TOOLS, $fname);
-
- if (is_file($fname) && is_readable($fname)) {
- $this->_extra_info = array();
- $sz = round((@filesize($fname) / 1024));
-
- if ($sz < 1024) {
- $sz = $sz . "K";
- } else {
- $sz /= 1024;
-
- if ($sz < 1024) {
- $sz = round($sz, 1) . "M";
- } else {
- $sz /= 1024;
- $sz = round($sz, 2) . "G";
- }
- }
- $this->_extra_info['size'] = $sz;
- $ext = substr($url, (strrpos($url, '.')));
-
- if ($ext == '.bz2' || $ext == '.gz' || $ext == '.xz' || $ext == '.7z')
- $ext = substr($url, strrpos($url, '.', -(strlen($url) - strrpos($url, '.') + 1)));
-
- if ( (is_file($fname . '.sha256') && is_readable($fname . '.sha256'))
- && (@filemtime($fname . '.sha256') > @filemtime($fname)) )
- {
- $this->_extra_info['sha256'] = file_get_contents($fname . '.sha256');
+class File extends BasicObject
+{
+ private $_category_icon;
+ private $_url;
+ private $_name;
+ private $_type;
+ private $_extra_info;
+ private $_user_agent;
+
+ public function __construct($data, $baseurl = null, $baseturl = null)
+ {
+ $this->_category_icon = $data['category_icon'];
+ $this->_name = $data['name'];
+ $this->_extra_info = $data['extra_info'];
+ $this->_type = strtolower($data['type']);
+ $this->_user_agent = isset($data["user_agent"]) ? $data["user_agent"] : "";
+
+ $fname = "";
+
+ /* If it's not an array, we didn't get any attributes. */
+ if (!is_array($data['url'])) {
+ $url = $data['url'];
+ $attributes = array();
} else {
- $hash = hash_file('sha256', $fname);
- $this->_extra_info['sha256'] = $hash;
- file_put_contents($fname . '.sha256', $hash);
+ $url = $data['url'][0];
+ $attributes = $data['url']['@attributes'];
}
- $this->_extra_info['ext'] = $ext;
- $this->_extra_info['msg'] = $data['extra_msg'];
- }
- }
- $this->_url = $url;
-
- /**
- * Get the filesize/last modified information and put it in
- * $this->_extra_info.
- */
- if ($attributes['extra_info'] == 'true') {
- if (is_file($fname) && is_readable($fname)) {
- $this->_extra_info['date'] = date('F j, Y, g:i a', @filemtime($fname));
- if (!is_null($data['extra_info'])) {
- $this->_extra_info['info'] = $data['extra_info'];
- }
- }
- }
- }
-
- /* Get the category icon. */
- public function getCategoryIcon() {
- return $this->_category_icon;
- }
-
- /* Get the URL. */
- public function getURL() {
- return $this->_url;
- }
-
- /* Get the name. */
- public function getName() {
- return $this->_name;
- }
-
- /* Get the type. */
- public function getType() {
- return $this->_type;
- }
-
- /* Get the extra information. */
- public function getExtraInfo() {
- return $this->_extra_info;
- }
-
- /* Get the user-agent. */
- public function getUserAgent() {
- return $this->_user_agent;
- }
+ if (!preg_match('/^((https?)|(ftp)):\/\//', $url)) {
+ if ($attributes['type'] == 'downloads') {
+ $url = DIR_DOWNLOADS . "/{$url}";
+ } elseif ($attributes['type'] == 'tools') {
+ $url = $baseturl . $url;
+ } else {
+ $url = $baseurl . $url;
+ }
+
+ $fname = "." . $url;
+ $fname = str_replace('{$release}', RELEASE, $fname);
+ $fname = str_replace('{$release_tools}', RELEASE_TOOLS, $fname);
+
+ if (is_file($fname) && is_readable($fname)) {
+ $this->_extra_info = array();
+ $sz = round((@filesize($fname) / 1024));
+
+ if ($sz < 1024) {
+ $sz = $sz . "K";
+ } else {
+ $sz /= 1024;
+
+ if ($sz < 1024) {
+ $sz = round($sz, 1) . "M";
+ } else {
+ $sz /= 1024;
+ $sz = round($sz, 2) . "G";
+ }
+ }
+ $this->_extra_info['size'] = $sz;
+ $ext = substr($url, (strrpos($url, '.')));
+
+ if ($ext == '.bz2' || $ext == '.gz' || $ext == '.xz' || $ext == '.7z') {
+ $ext = substr($url, strrpos($url, '.', -(strlen($url) - strrpos($url, '.') + 1)));
+ }
+
+ if ((is_file($fname . '.sha256') && is_readable($fname . '.sha256'))
+ && (@filemtime($fname . '.sha256') > @filemtime($fname)) ) {
+ $this->_extra_info['sha256'] = file_get_contents($fname . '.sha256');
+ } else {
+ $hash = hash_file('sha256', $fname);
+ $this->_extra_info['sha256'] = $hash;
+ file_put_contents($fname . '.sha256', $hash);
+ }
+
+ $this->_extra_info['ext'] = $ext;
+ $this->_extra_info['msg'] = $data['extra_msg'];
+ }
+ }
+ $this->_url = $url;
+
+ /**
+ * Get the filesize/last modified information and put it in
+ * $this->_extra_info.
+ */
+ if ($attributes['extra_info'] == 'true') {
+ if (is_file($fname) && is_readable($fname)) {
+ $this->_extra_info['date'] = date('F j, Y, g:i a', @filemtime($fname));
+ if (!is_null($data['extra_info'])) {
+ $this->_extra_info['info'] = $data['extra_info'];
+ }
+ }
+ }
+ }
+
+ /* Get the category icon. */
+ public function getCategoryIcon()
+ {
+ return $this->_category_icon;
+ }
+
+ /* Get the URL. */
+ public function getURL()
+ {
+ return $this->_url;
+ }
+
+ /* Get the name. */
+ public function getName()
+ {
+ return $this->_name;
+ }
+
+ /* Get the type. */
+ public function getType()
+ {
+ return $this->_type;
+ }
+
+ /* Get the extra information. */
+ public function getExtraInfo()
+ {
+ return $this->_extra_info;
+ }
+
+ /* Get the user-agent. */
+ public function getUserAgent()
+ {
+ return $this->_user_agent;
+ }
}
-?>
diff --git a/include/Objects/GameDemo.php b/include/Objects/GameDemo.php
index c5766ad..b702ded 100644
--- a/include/Objects/GameDemo.php
+++ b/include/Objects/GameDemo.php
@@ -3,38 +3,43 @@ require_once('Objects/BasicObject.php');
/**
* The GameDemo class represents a game demo item on the website.
*/
-class GameDemo extends BasicObject {
- private $_name;
- private $_url;
- private $_target;
- private $_category;
-
- /* GameDemo object constructor. */
- public function __construct($data) {
- $this->_name = $data['name'];
- $this->_url = $data['url'];
- $this->_target = $data['target'];
- $this->_category = isset($data['category']) ? $data['category'] : $data['target'];
- }
+class GameDemo extends BasicObject
+{
+ private $_name;
+ private $_url;
+ private $_target;
+ private $_category;
+
+ /* GameDemo object constructor. */
+ public function __construct($data)
+ {
+ $this->_name = $data['name'];
+ $this->_url = $data['url'];
+ $this->_target = $data['target'];
+ $this->_category = isset($data['category']) ? $data['category'] : $data['target'];
+ }
- /* Get the name of the demo. */
- public function getName() {
- return $this->_name;
- }
+ /* Get the name of the demo. */
+ public function getName()
+ {
+ return $this->_name;
+ }
- /* Get the download URL for the demo. */
- public function getURL() {
- return $this->_url;
- }
+ /* Get the download URL for the demo. */
+ public function getURL()
+ {
+ return $this->_url;
+ }
- /* Get the target name for the demo. */
- public function getTarget() {
- return $this->_target;
- }
-
- /* Get the category for the demo. */
- public function getCategory() {
- return $this->_category;
- }
+ /* Get the target name for the demo. */
+ public function getTarget()
+ {
+ return $this->_target;
+ }
+
+ /* Get the category for the demo. */
+ public function getCategory()
+ {
+ return $this->_category;
+ }
}
-?>
diff --git a/include/Objects/MenuItem.php b/include/Objects/MenuItem.php
index 700d210..c835e47 100644
--- a/include/Objects/MenuItem.php
+++ b/include/Objects/MenuItem.php
@@ -3,34 +3,38 @@ require_once('Objects/BasicObject.php');
/**
* The menu class represents a sidebar menu group on the website.
*/
-class MenuItem extends BasicObject {
- private $_name;
- private $_class;
- private $_entries;
+class MenuItem extends BasicObject
+{
+ private $_name;
+ private $_class;
+ private $_entries;
- /* Menu object constructor. */
- public function __construct($data) {
- $this->_name = $data['name'];
- $this->_class = $data['class'];
- $this->_entries = array();
- foreach ($data['link'] as $key => $value) {
- $this->_entries[$value['name']] = $value['href'];
- }
- }
+ /* Menu object constructor. */
+ public function __construct($data)
+ {
+ $this->_name = $data['name'];
+ $this->_class = $data['class'];
+ $this->_entries = array();
+ foreach ($data['link'] as $key => $value) {
+ $this->_entries[$value['name']] = $value['href'];
+ }
+ }
- /* Get the name. */
- public function getName() {
- return $this->_name;
- }
+ /* Get the name. */
+ public function getName()
+ {
+ return $this->_name;
+ }
- /* Get the CSS class. */
- public function getClass() {
- return $this->_class;
- }
+ /* Get the CSS class. */
+ public function getClass()
+ {
+ return $this->_class;
+ }
- /* Get the list of links, with the name as key and URL as value. */
- public function getEntries() {
- return $this->_entries;
- }
+ /* Get the list of links, with the name as key and URL as value. */
+ public function getEntries()
+ {
+ return $this->_entries;
+ }
}
-?>
diff --git a/include/Objects/News.php b/include/Objects/News.php
index 430d4a3..2aaae6a 100644
--- a/include/Objects/News.php
+++ b/include/Objects/News.php
@@ -3,76 +3,84 @@ require_once('Objects/BasicObject.php');
/**
* The news class represents a news item on the website.
*/
-class News extends BasicObject {
- private $_title;
- private $_date;
- private $_author;
- private $_image;
- private $_content;
- private $_filename;
+class News extends BasicObject
+{
+ private $_title;
+ private $_date;
+ private $_author;
+ private $_image;
+ private $_content;
+ private $_filename;
- /**
- * News object constructor that extracts the data from the JSON scheme
- * used. The format looks like this:
- *
+ /**
+ * News object constructor that extracts the data from the JSON scheme
+ * used. The format looks like this:
+ *
* {
* "title": "Article Title",
* "content": "Your article content goes here",
* "date": "UNIX timestamp",
* "author": "Name"
* }
- *
- *
- */
- public function __construct($data, $filename, $processContent = false) {
- $this->_title = $processContent ? $this->processText($data->title) : $data->title;
- $this->_date = $data->date;
- $this->_author = $data->author;
- $this->_content = $processContent ? $this->processText($data->content) : $data->content;
- $this->_filename = basename($filename);
- }
+ *
+ *
+ */
+ public function __construct($data, $filename, $processContent = false)
+ {
+ $this->_title = $processContent ? $this->processText($data->title) : $data->title;
+ $this->_date = $data->date;
+ $this->_author = $data->author;
+ $this->_content = $processContent ? $this->processText($data->content) : $data->content;
+ $this->_filename = basename($filename);
+ }
- /**
- * Search and replace specific text from the title and content of a news item.
- * Used to filter out entities from the RSS/atom feeds that are not in the XML
- * standard.
- *
- * Check:
- * http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
- * for a list of valid entities for both XML and HTML
- */
- function processText($text) {
- return html_entity_decode($text, ENT_COMPAT, 'UTF-8');
- }
+ /**
+ * Search and replace specific text from the title and content of a news item.
+ * Used to filter out entities from the RSS/atom feeds that are not in the XML
+ * standard.
+ *
+ * Check:
+ * http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
+ * for a list of valid entities for both XML and HTML
+ */
+ function processText($text)
+ {
+ return html_entity_decode($text, ENT_COMPAT, 'UTF-8');
+ }
- /* Get the title. */
- public function getTitle() {
- return $this->_title;
- }
+ /* Get the title. */
+ public function getTitle()
+ {
+ return $this->_title;
+ }
- /* Get the date. */
- public function getDate() {
- return $this->_date;
- }
+ /* Get the date. */
+ public function getDate()
+ {
+ return $this->_date;
+ }
- /* Get the author. */
- public function getAuthor() {
- return $this->_author;
- }
+ /* Get the author. */
+ public function getAuthor()
+ {
+ return $this->_author;
+ }
- /* Get the content. */
- public function getContent() {
- return $this->_content;
- }
+ /* Get the content. */
+ public function getContent()
+ {
+ return $this->_content;
+ }
- /* Get the filename. */
- public function getFilename() {
- return $this->_filename;
- }
+ /* Get the filename. */
+ public function getFilename()
+ {
+ return $this->_filename;
+ }
/* Get the News link. */
- public function getLink() {
- return URL_BASE . 'news/' . substr( $this->_filename, 0, -5);
- }
+ public function getLink()
+ {
+ return URL_BASE . 'news/' . substr($this->_filename, 0, -5);
+ }
}
-?>
diff --git a/include/Objects/Person.php b/include/Objects/Person.php
index f4bd2fe..b778683 100644
--- a/include/Objects/Person.php
+++ b/include/Objects/Person.php
@@ -4,31 +4,35 @@ require_once('Objects/BasicObject.php');
* The Person class represents a person entry on the credits page on the
* website.
*/
-class Person extends BasicObject {
- private $_name;
- private $_alias;
- private $_description;
+class Person extends BasicObject
+{
+ private $_name;
+ private $_alias;
+ private $_description;
- /* Person object constructor. */
- public function __construct($args) {
- $this->_name = $args['name'];
- $this->_alias = $args['alias'];
- $this->_description = $args['description'];
- }
+ /* Person object constructor. */
+ public function __construct($args)
+ {
+ $this->_name = $args['name'];
+ $this->_alias = $args['alias'];
+ $this->_description = $args['description'];
+ }
- /* Get the name. */
- public function getName() {
- return $this->_name;
- }
+ /* Get the name. */
+ public function getName()
+ {
+ return $this->_name;
+ }
- /* Get the alias. */
- public function getAlias() {
- return $this->_alias;
- }
+ /* Get the alias. */
+ public function getAlias()
+ {
+ return $this->_alias;
+ }
- /* Get the description. */
- public function getDescription() {
- return $this->_description;
- }
+ /* Get the description. */
+ public function getDescription()
+ {
+ return $this->_description;
+ }
}
-?>
diff --git a/include/Objects/Project.php b/include/Objects/Project.php
index 979af28..a95e1c2 100644
--- a/include/Objects/Project.php
+++ b/include/Objects/Project.php
@@ -3,50 +3,54 @@ require_once('Objects/BasicObject.php');
/**
* The Project class represents a subproject on the website.
*/
-class Project extends BasicObject {
- private $_name;
- private $_info;
- private $_downloads;
+class Project extends BasicObject
+{
+ private $_name;
+ private $_info;
+ private $_downloads;
- /* Project object constructor. */
- public function __construct($data) {
- $this->_name = $data['name'];
- $this->_info = $data['info'];
- $this->_downloads = $data['downloads'];
- /*$this->_downloads = array();
- parent::toArray($data['download']);
- foreach ($data['download'] as $ddata) {
- $download = array(
- 'name' => $ddata['name'],
- 'filename' => $ddata['filename'],
- 'type' => $ddata['type'],
- );
- # Add detailed information about daily builds.
- if ($ddata['type'] == 'SVN_DAILY') {
- $url = DIR_DOWNLOADS . "/{$ddata['filename']}";
- $download['info'] = array(
- 'url' => $url,
- 'filesize' => intval(@filesize($url) / 1024),
- 'modified' => date('F j, Y, g:i a', @filemtime($url)),
- );
- }
- $this->_downloads[] = $download;
- }*/
- }
+ /* Project object constructor. */
+ public function __construct($data)
+ {
+ $this->_name = $data['name'];
+ $this->_info = $data['info'];
+ $this->_downloads = $data['downloads'];
+ /*$this->_downloads = array();
+ parent::toArray($data['download']);
+ foreach ($data['download'] as $ddata) {
+ $download = array(
+ 'name' => $ddata['name'],
+ 'filename' => $ddata['filename'],
+ 'type' => $ddata['type'],
+ );
+ # Add detailed information about daily builds.
+ if ($ddata['type'] == 'SVN_DAILY') {
+ $url = DIR_DOWNLOADS . "/{$ddata['filename']}";
+ $download['info'] = array(
+ 'url' => $url,
+ 'filesize' => intval(@filesize($url) / 1024),
+ 'modified' => date('F j, Y, g:i a', @filemtime($url)),
+ );
+ }
+ $this->_downloads[] = $download;
+ }*/
+ }
- /* Get the name of the project. */
- public function getName() {
- return $this->_name;
- }
+ /* Get the name of the project. */
+ public function getName()
+ {
+ return $this->_name;
+ }
- /* Get the information text for this project. */
- public function getInfo() {
- return $this->_info;
- }
+ /* Get the information text for this project. */
+ public function getInfo()
+ {
+ return $this->_info;
+ }
- /* Get the list of downloads available for this project. */
- public function getDownloads() {
- return $this->_downloads;
- }
+ /* Get the list of downloads available for this project. */
+ public function getDownloads()
+ {
+ return $this->_downloads;
+ }
}
-?>
diff --git a/include/Objects/QAEntry.php b/include/Objects/QAEntry.php
index afd73d8..af0e793 100644
--- a/include/Objects/QAEntry.php
+++ b/include/Objects/QAEntry.php
@@ -4,71 +4,76 @@ require_once('Objects/BasicObject.php');
* The QAEntry class represents a question-answer pair on the website
* F.A.Q. page.
*/
-class QAEntry extends BasicObject {
- private $_hrefs;
- private $_question;
- private $_answer;
- private $_xref;
+class QAEntry extends BasicObject
+{
+ private $_hrefs;
+ private $_question;
+ private $_answer;
+ private $_xref;
- /**
- * QAEntry object constructor.
- *
- * @param array $data list containing all qaentry data
- * @param int $section_number the section this entry belongs too
- * @param int $entry_number part of the href value incase it's not set
- * @param array $xref reference to xref map
- */
- public function __construct($data, $section_number, $entry_number, &$xref) {
- $this->_hrefs = array();
- if (! empty($data['href'])) {
- array_push($this->_hrefs, $data['href']);
- $xref[$data['href']] = $data['question'];
- }
- array_push($this->_hrefs, "{$section_number}_{$entry_number}");
+ /**
+ * QAEntry object constructor.
+ *
+ * @param array $data list containing all qaentry data
+ * @param int $section_number the section this entry belongs too
+ * @param int $entry_number part of the href value incase it's not set
+ * @param array $xref reference to xref map
+ */
+ public function __construct($data, $section_number, $entry_number, &$xref)
+ {
+ $this->_hrefs = array();
+ if (! empty($data['href'])) {
+ array_push($this->_hrefs, $data['href']);
+ $xref[$data['href']] = $data['question'];
+ }
+ array_push($this->_hrefs, "{$section_number}_{$entry_number}");
- $this->_question = $data['question'];
- $this->_answer = $data['answer'];
- /* Save a reference to the xref table for later use. */
- $this->_xref = &$xref;
- }
+ $this->_question = $data['question'];
+ $this->_answer = $data['answer'];
+ /* Save a reference to the xref table for later use. */
+ $this->_xref = &$xref;
+ }
- /* Get the primary anchor name for this entry. */
- public function getHref() {
- return $this->_hrefs[0];
- }
+ /* Get the primary anchor name for this entry. */
+ public function getHref()
+ {
+ return $this->_hrefs[0];
+ }
- /* Get all anchor names for this entry. */
- public function getHrefs() {
- return $this->_hrefs;
- }
+ /* Get all anchor names for this entry. */
+ public function getHrefs()
+ {
+ return $this->_hrefs;
+ }
- /* Get the question for this entry. */
- public function getQuestion() {
- return $this->_question;
- }
+ /* Get the question for this entry. */
+ public function getQuestion()
+ {
+ return $this->_question;
+ }
- /* Get the answer for this entry. */
- public function getAnswer() {
- $answer = &$this->_answer;
- $xref = &$this->_xref;
- /* If we find a xref we need to make the final conversion to HTML. */
- if (strpos($answer, '<a xref') !== false) {
- /**
- * For each entry in our xref lookup table we need to build a list
- * of patterns that match the xrefs. We also need to build a list
- * with replacements for the xrefs. Only generate the lists once.
- */
- if (!isset($xref['pattern']) || !isset($xref['replace'])) {
- $pattern = array();
- $replace = array();
- foreach ($this->_xref as $anchor => $text) {
- $xref['pattern'][] = "/<a xref=\"{$anchor}\"><\/a>/";
- $xref['replace'][] = "<a href=\"faq/#{$anchor}\">{$text}</a>";
- }
- }
- $answer = preg_replace($xref['pattern'], $xref['replace'], $answer);
- }
- return $this->_answer;
- }
+ /* Get the answer for this entry. */
+ public function getAnswer()
+ {
+ $answer = &$this->_answer;
+ $xref = &$this->_xref;
+ /* If we find a xref we need to make the final conversion to HTML. */
+ if (strpos($answer, '<a xref') !== false) {
+ /**
+ * For each entry in our xref lookup table we need to build a list
+ * of patterns that match the xrefs. We also need to build a list
+ * with replacements for the xrefs. Only generate the lists once.
+ */
+ if (!isset($xref['pattern']) || !isset($xref['replace'])) {
+ $pattern = array();
+ $replace = array();
+ foreach ($this->_xref as $anchor => $text) {
+ $xref['pattern'][] = "/<a xref=\"{$anchor}\"><\/a>/";
+ $xref['replace'][] = "<a href=\"faq/#{$anchor}\">{$text}</a>";
+ }
+ }
+ $answer = preg_replace($xref['pattern'], $xref['replace'], $answer);
+ }
+ return $this->_answer;
+ }
}
-?>
diff --git a/include/Objects/QASection.php b/include/Objects/QASection.php
index 5aba60b..b5eefea 100644
--- a/include/Objects/QASection.php
+++ b/include/Objects/QASection.php
@@ -5,44 +5,48 @@ require_once('Objects/QAEntry.php');
* The QASection class represents a section with questions and answers on the
* website F.A.Q. page.
*/
-class QASection extends BasicObject {
- private $_title;
- private $_entries;
- private $_toc;
+class QASection extends BasicObject
+{
+ private $_title;
+ private $_entries;
+ private $_toc;
- /**
- * QASection object constructor.
- *
- * @param array $data list containing all qasection data
- * @param int $section_number used in the TOC
- * @param array $xref reference to xref map
- */
- public function __construct($data, $section_number, &$xref) {
- $this->_title = $data['title'];
- $this->_entries = array();
- $this->_toc = array();
- parent::toArray($data['entry']);
- $count = 1;
- foreach ($data['entry'] as $key => $value) {
- $qa = new QAEntry($value, $section_number, $count++, $xref);
- $this->_entries[] = $qa;
- $this->_toc[$qa->getHref()] = $qa->getQuestion();
- }
- }
+ /**
+ * QASection object constructor.
+ *
+ * @param array $data list containing all qasection data
+ * @param int $section_number used in the TOC
+ * @param array $xref reference to xref map
+ */
+ public function __construct($data, $section_number, &$xref)
+ {
+ $this->_title = $data['title'];
+ $this->_entries = array();
+ $this->_toc = array();
+ parent::toArray($data['entry']);
+ $count = 1;
+ foreach ($data['entry'] as $key => $value) {
+ $qa = new QAEntry($value, $section_number, $count++, $xref);
+ $this->_entries[] = $qa;
+ $this->_toc[$qa->getHref()] = $qa->getQuestion();
+ }
+ }
- /* Get the title of this section. */
- public function getTitle() {
- return $this->_title;
- }
+ /* Get the title of this section. */
+ public function getTitle()
+ {
+ return $this->_title;
+ }
- /* Get a list with all question-answer entries for this section. */
- public function getEntries() {
- return $this->_entries;
- }
+ /* Get a list with all question-answer entries for this section. */
+ public function getEntries()
+ {
+ return $this->_entries;
+ }
- /* Get the table of contents for this section. */
- public function getTOC() {
- return $this->_toc;
- }
+ /* Get the table of contents for this section. */
+ public function getTOC()
+ {
+ return $this->_toc;
+ }
}
-?>
diff --git a/include/Objects/Screenshot.php b/include/Objects/Screenshot.php
index c5672e8..f2dd70d 100644
--- a/include/Objects/Screenshot.php
+++ b/include/Objects/Screenshot.php
@@ -3,56 +3,61 @@ require_once('Objects/BasicObject.php');
/**
* The Screenshot object represents all screenshots for one game.
*/
-class Screenshot extends BasicObject {
- private $_name;
- private $_category;
- private $_files;
+class Screenshot extends BasicObject
+{
+ private $_name;
+ private $_category;
+ private $_files;
- /* The Screenshot object constructor. */
- public function __construct($data) {
- $this->_name = $data['name'];
- $this->_category = $data['category'];
- $this->_files = array();
- if (isset($data['image'])) {
- if (!isset($data['image'][0]))
- parent::toArray($data['image']);
+ /* The Screenshot object constructor. */
+ public function __construct($data)
+ {
+ $this->_name = $data['name'];
+ $this->_category = $data['category'];
+ $this->_files = array();
+ if (isset($data['image'])) {
+ if (!isset($data['image'][0])) {
+ parent::toArray($data['image']);
+ }
- foreach ($data['image'] as $value) {
- if (isset($value['range'])) {
- $attr = $value['range']['@attributes'];
- if (!isset($attr['from']) || !isset($attr['to']) || !isset($attr['format']) || !strstr($value['file'], '#n#')) {
- throw new ErrorException('Invalid range format for ' . $value['file']);
- }
- $pat = str_replace("#n#", $attr['format'], $value['file']);
- for ($num = $attr['from']; $num <= $attr['to']; $num++) {
- $this->_files[] = array(
- 'filename' => sprintf($pat, $num),
- 'caption' => $value['caption'],
- );
- }
- } else {
- $this->_files[] = array(
- 'filename' => $value['file'],
- 'caption' => $value['caption'],
- );
- }
- }
- }
- }
+ foreach ($data['image'] as $value) {
+ if (isset($value['range'])) {
+ $attr = $value['range']['@attributes'];
+ if (!isset($attr['from']) || !isset($attr['to']) || !isset($attr['format']) || !strstr($value['file'], '#n#')) {
+ throw new ErrorException('Invalid range format for ' . $value['file']);
+ }
+ $pat = str_replace("#n#", $attr['format'], $value['file']);
+ for ($num = $attr['from']; $num <= $attr['to']; $num++) {
+ $this->_files[] = array(
+ 'filename' => sprintf($pat, $num),
+ 'caption' => $value['caption'],
+ );
+ }
+ } else {
+ $this->_files[] = array(
+ 'filename' => $value['file'],
+ 'caption' => $value['caption'],
+ );
+ }
+ }
+ }
+ }
- /* Get the name. */
- public function getName() {
- return $this->_name;
- }
+ /* Get the name. */
+ public function getName()
+ {
+ return $this->_name;
+ }
- /* Get the category this screenshot belongs too. */
- public function getCategory() {
- return $this->_category;
- }
+ /* Get the category this screenshot belongs too. */
+ public function getCategory()
+ {
+ return $this->_category;
+ }
- /* Get the list of files, with the base filename as key and the caption as value. */
- public function getFiles() {
- return $this->_files;
- }
+ /* Get the list of files, with the base filename as key and the caption as value. */
+ public function getFiles()
+ {
+ return $this->_files;
+ }
}
-?>
diff --git a/include/Objects/WebLink.php b/include/Objects/WebLink.php
index 10026ba..2c2d0e1 100644
--- a/include/Objects/WebLink.php
+++ b/include/Objects/WebLink.php
@@ -3,36 +3,41 @@ require_once('Objects/BasicObject.php');
/**
* The WebLink class represents a link item on the website.
*/
-class WebLink extends BasicObject {
- private $_name;
- private $_url;
- private $_description;
+class WebLink extends BasicObject
+{
+ private $_name;
+ private $_url;
+ private $_description;
- /* WebLink object constructor. */
- public function __construct($data) {
- $this->_name = $data['name'];
- $this->_url = $data['url'];
- $this->_description = $data['description'];
- }
+ /* WebLink object constructor. */
+ public function __construct($data)
+ {
+ $this->_name = $data['name'];
+ $this->_url = $data['url'];
+ $this->_description = $data['description'];
+ }
- /* Get the name of the link. */
- public function getName() {
- return $this->_name;
- }
+ /* Get the name of the link. */
+ public function getName()
+ {
+ return $this->_name;
+ }
- /* Get the URL of the link. */
- public function getURL() {
- return $this->_url;
- }
+ /* Get the URL of the link. */
+ public function getURL()
+ {
+ return $this->_url;
+ }
- /* Get the description of the link. */
- public function getDescription() {
- return $this->_description;
- }
-
- /* Get the user-agent. */
- public function getUserAgent() {
- return "";
- }
+ /* Get the description of the link. */
+ public function getDescription()
+ {
+ return $this->_description;
+ }
+
+ /* Get the user-agent. */
+ public function getUserAgent()
+ {
+ return "";
+ }
}
-?>
diff --git a/include/Pages/CompatibilityPage.php b/include/Pages/CompatibilityPage.php
index 64f85e2..c1113f8 100644
--- a/include/Pages/CompatibilityPage.php
+++ b/include/Pages/CompatibilityPage.php
@@ -6,104 +6,108 @@ require_once('Models/CompatibilityModel.php');
* either displays the full list of games, or specific details about one
* game. It defaults to showing the compatibility list of the DEV-version.
*/
-class CompatibilityPage extends Controller {
- private $_template;
- private $_template_details;
- private $_supportLevelDesc;
- private $_supportLevelClass;
+class CompatibilityPage extends Controller
+{
+ private $_template;
+ private $_template_details;
+ private $_supportLevelDesc;
+ private $_supportLevelClass;
- /* Constructor. */
- public function __construct() {
- parent::__construct();
- global $Smarty;
- $this->_template = 'pages/compatibility.tpl';
- $this->_template_details = 'components/compatibility_details.tpl';
- $this->_supportLevelDesc = array(
- 'untested' => $Smarty->getConfigVars('compatibilityUntested'),
- 'broken' => $Smarty->getConfigVars('compatibilityBroken'),
- 'bugged' => $Smarty->getConfigVars('compatibilityBugged'),
- 'good' => $Smarty->getConfigVars('compatibilityGood'),
- 'excellent' => $Smarty->getConfigVars('compatibilityExcellent')
- );
- $this->_supportLevelClass = array(
- 'untested' => 'pctU',
- 'broken' => 'pct0',
- 'bugged' => 'pct50',
- 'good' => 'pct75',
- 'excellent' => 'pct100'
- );
- }
+ /* Constructor. */
+ public function __construct()
+ {
+ parent::__construct();
+ global $Smarty;
+ $this->_template = 'pages/compatibility.tpl';
+ $this->_template_details = 'components/compatibility_details.tpl';
+ $this->_supportLevelDesc = array(
+ 'untested' => $Smarty->getConfigVars('compatibilityUntested'),
+ 'broken' => $Smarty->getConfigVars('compatibilityBroken'),
+ 'bugged' => $Smarty->getConfigVars('compatibilityBugged'),
+ 'good' => $Smarty->getConfigVars('compatibilityGood'),
+ 'excellent' => $Smarty->getConfigVars('compatibilityExcellent')
+ );
+ $this->_supportLevelClass = array(
+ 'untested' => 'pctU',
+ 'broken' => 'pct0',
+ 'bugged' => 'pct50',
+ 'good' => 'pct75',
+ 'excellent' => 'pct100'
+ );
+ }
- /* Display the index page. */
- public function index() {
- $version = (!empty($_GET['v']) ? $_GET['v'] : 'DEV');
- $target = $_GET['t'];
+ /* Display the index page. */
+ public function index()
+ {
+ $version = (!empty($_GET['v']) ? $_GET['v'] : 'DEV');
+ $target = $_GET['t'];
- /* Default to DEV */
- $versions = CompatibilityModel::getAllVersions();
- if (!in_array($version, $versions)) {
- $version = 'DEV';
- }
+ /* Default to DEV */
+ $versions = CompatibilityModel::getAllVersions();
+ if (!in_array($version, $versions)) {
+ $version = 'DEV';
+ }
- if ($version === 'DEV' || (CompatibilityModel::compareVersions($version, COMPAT_LAYOUT_CHANGE) >= 0)) {
- $oldLayout = 'no';
- } else {
- $oldLayout = 'yes';
- }
+ if ($version === 'DEV' || (CompatibilityModel::compareVersions($version, COMPAT_LAYOUT_CHANGE) >= 0)) {
+ $oldLayout = 'no';
+ } else {
+ $oldLayout = 'yes';
+ }
- if (!empty($target)) {
- return $this->getGame($target, $version, $oldLayout);
- } else {
- return $this->getAll($version, $versions, $oldLayout);
- }
- }
+ if (!empty($target)) {
+ return $this->getGame($target, $version, $oldLayout);
+ } else {
+ return $this->getAll($version, $versions, $oldLayout);
+ }
+ }
- /* We should show detailed information for a specific target. */
- public function getGame($target, $version, $oldLayout) {
- $game = CompatibilityModel::getGameData($version, $target);
- global $Smarty;
-
- return $this->renderPage(
- array(
- 'title' => preg_replace('/{version}/', $version, $Smarty->getConfigVars('compatibilityTitle')),
- 'content_title' => preg_replace('/{version}/', $version, $Smarty->getConfigVars('compatibilityContentTitle')),
- 'version' => $version,
- 'game' => $game,
- 'old_layout' => $oldLayout,
- 'support_level_desc' => $this->_supportLevelDesc,
- 'support_level_class' => $this->_supportLevelClass
- ),
- $this->_template_details
- );
- }
+ /* We should show detailed information for a specific target. */
+ public function getGame($target, $version, $oldLayout)
+ {
+ $game = CompatibilityModel::getGameData($version, $target);
+ global $Smarty;
+
+ return $this->renderPage(
+ array(
+ 'title' => preg_replace('/{version}/', $version, $Smarty->getConfigVars('compatibilityTitle')),
+ 'content_title' => preg_replace('/{version}/', $version, $Smarty->getConfigVars('compatibilityContentTitle')),
+ 'version' => $version,
+ 'game' => $game,
+ 'old_layout' => $oldLayout,
+ 'support_level_desc' => $this->_supportLevelDesc,
+ 'support_level_class' => $this->_supportLevelClass
+ ),
+ $this->_template_details
+ );
+ }
- /* We should show all the compatibility stats for a specific version. */
- public function getAll($version, $versions, $oldLayout) {
- /* Remove the current version from the versions array. */
- if ($version != 'DEV') {
- $key = array_search($version, $versions);
- unset($versions[$key]);
- }
- $filename = DIR_COMPAT . "/compat-{$version}.xml";
- $last_updated = date("F d, Y", @filemtime($filename));
- $compat_data = CompatibilityModel::getAllData($version);
+ /* We should show all the compatibility stats for a specific version. */
+ public function getAll($version, $versions, $oldLayout)
+ {
+ /* Remove the current version from the versions array. */
+ if ($version != 'DEV') {
+ $key = array_search($version, $versions);
+ unset($versions[$key]);
+ }
+ $filename = DIR_COMPAT . "/compat-{$version}.xml";
+ $last_updated = date("F d, Y", @filemtime($filename));
+ $compat_data = CompatibilityModel::getAllData($version);
- global $Smarty;
-
- return $this->renderPage(
- array(
- 'title' => preg_replace('/{version}/', $version, $Smarty->getConfigVars('compatibilityTitle')),
- 'content_title' => preg_replace('/{version}/', $version, $Smarty->getConfigVars('compatibilityContentTitle')),
- 'version' => $version,
- 'compat_data' => $compat_data,
- 'last_updated' => $last_updated,
- 'versions' => $versions,
- 'old_layout' => $oldLayout,
- 'support_level_desc' => $this->_supportLevelDesc,
- 'support_level_class' => $this->_supportLevelClass
- ),
- $this->_template
- );
- }
+ global $Smarty;
+
+ return $this->renderPage(
+ array(
+ 'title' => preg_replace('/{version}/', $version, $Smarty->getConfigVars('compatibilityTitle')),
+ 'content_title' => preg_replace('/{version}/', $version, $Smarty->getConfigVars('compatibilityContentTitle')),
+ 'version' => $version,
+ 'compat_data' => $compat_data,
+ 'last_updated' => $last_updated,
+ 'versions' => $versions,
+ 'old_layout' => $oldLayout,
+ 'support_level_desc' => $this->_supportLevelDesc,
+ 'support_level_class' => $this->_supportLevelClass
+ ),
+ $this->_template
+ );
+ }
}
-?>
diff --git a/include/Pages/ContactPage.php b/include/Pages/ContactPage.php
index d76bb8c..2b9794c 100644
--- a/include/Pages/ContactPage.php
+++ b/include/Pages/ContactPage.php
@@ -1,26 +1,28 @@
<?php
require_once('Controller.php');
-class ContactPage extends Controller {
- private $_template;
+class ContactPage extends Controller
+{
+ private $_template;
- /* Constructor. */
- public function __construct() {
- parent::__construct();
- $this->_template = 'pages/contact.tpl';
- }
+ /* Constructor. */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->_template = 'pages/contact.tpl';
+ }
- /* Display the index page. */
- public function index() {
- global $Smarty;
+ /* Display the index page. */
+ public function index()
+ {
+ global $Smarty;
- return $this->renderPage(
- array(
- 'title' => $Smarty->getConfigVars('contactTitle'),
- 'content_title' => $Smarty->getConfigVars('contactContentTitle'),
- ),
- $this->_template
- );
- }
+ return $this->renderPage(
+ array(
+ 'title' => $Smarty->getConfigVars('contactTitle'),
+ 'content_title' => $Smarty->getConfigVars('contactContentTitle'),
+ ),
+ $this->_template
+ );
+ }
}
-?>
diff --git a/include/Pages/CreditsPage.php b/include/Pages/CreditsPage.php
index b1053a9..40134cc 100644
--- a/include/Pages/CreditsPage.php
+++ b/include/Pages/CreditsPage.php
@@ -2,28 +2,30 @@
require_once('Controller.php');
require_once('Models/CreditsModel.php');
-class CreditsPage extends Controller {
- private $template;
+class CreditsPage extends Controller
+{
+ private $template;
- /* Constructor. */
- public function __construct() {
- parent::__construct();
- $this->_template = 'pages/credits.tpl';
- }
+ /* Constructor. */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->_template = 'pages/credits.tpl';
+ }
- /* Display the index page. */
- public function index() {
- $credits = CreditsModel::getAllCredits();
- global $Smarty;
-
- return $this->renderPage(
- array(
- 'title' => $Smarty->getConfigVars('creditsTitle'),
- 'content_title' => $Smarty->getConfigVars('creditsContentTitle'),
- 'credits' => $credits,
- ),
- $this->_template
- );
- }
+ /* Display the index page. */
+ public function index()
+ {
+ $credits = CreditsModel::getAllCredits();
+ global $Smarty;
+
+ return $this->renderPage(
+ array(
+ 'title' => $Smarty->getConfigVars('creditsTitle'),
+ 'content_title' => $Smarty->getConfigVars('creditsContentTitle'),
+ 'credits' => $credits,
+ ),
+ $this->_template
+ );
+ }
}
-?>
diff --git a/include/Pages/DemosPage.php b/include/Pages/DemosPage.php
index 2d978a4..52e8ed9 100644
--- a/include/Pages/DemosPage.php
+++ b/include/Pages/DemosPage.php
@@ -2,28 +2,30 @@
require_once('Controller.php');
require_once('Models/GameDemosModel.php');
-class DemosPage extends Controller {
- private $_template;
+class DemosPage extends Controller
+{
+ private $_template;
- /* Constructor. */
- public function __construct() {
- parent::__construct();
- $this->_template = 'pages/game_demos.tpl';
- }
+ /* Constructor. */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->_template = 'pages/game_demos.tpl';
+ }
- /* Display the index page. */
- public function index() {
- $demos = GameDemosModel::getAllGroupsAndDemos();
- global $Smarty;
+ /* Display the index page. */
+ public function index()
+ {
+ $demos = GameDemosModel::getAllGroupsAndDemos();
+ global $Smarty;
- return $this->renderPage(
- array(
- 'title' => $Smarty->getConfigVars('demosTitle'),
- 'content_title' => $Smarty->getConfigVars('demosContentTitle'),
- 'demos' => $demos,
- ),
- $this->_template
- );
- }
+ return $this->renderPage(
+ array(
+ 'title' => $Smarty->getConfigVars('demosTitle'),
+ 'content_title' => $Smarty->getConfigVars('demosContentTitle'),
+ 'demos' => $demos,
+ ),
+ $this->_template
+ );
+ }
}
-?>
diff --git a/include/Pages/DocumentationPage.php b/include/Pages/DocumentationPage.php
index a7cbb9b..400a7ca 100644
--- a/include/Pages/DocumentationPage.php
+++ b/include/Pages/DocumentationPage.php
@@ -2,30 +2,32 @@
require_once('Controller.php');
require_once('Models/DocumentationModel.php');
-class DocumentationPage extends Controller {
- private $_template;
+class DocumentationPage extends Controller
+{
+ private $_template;
- /* Constructor. */
- public function __construct() {
- parent::__construct();
- $this->_template = 'pages/documentation.tpl';
- }
+ /* Constructor. */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->_template = 'pages/documentation.tpl';
+ }
- /* Display the index page. */
- public function index() {
- $document = $_GET['d'];
- global $Smarty;
+ /* Display the index page. */
+ public function index()
+ {
+ $document = $_GET['d'];
+ global $Smarty;
- $documents = DocumentationModel::getAllDocuments();
+ $documents = DocumentationModel::getAllDocuments();
- return $this->renderPage(
- array(
- 'title' => $Smarty->getConfigVars('documentationTitle'),
- 'content_title' => $Smarty->getConfigVars('documentationContentTitle'),
- 'documents' => $documents,
- ),
- $this->_template
- );
- }
+ return $this->renderPage(
+ array(
+ 'title' => $Smarty->getConfigVars('documentationTitle'),
+ 'content_title' => $Smarty->getConfigVars('documentationContentTitle'),
+ 'documents' => $documents,
+ ),
+ $this->_template
+ );
+ }
}
-?>
diff --git a/include/Pages/DownloadsPage.php b/include/Pages/DownloadsPage.php
index 1e1cb1f..d9172c6 100644
--- a/include/Pages/DownloadsPage.php
+++ b/include/Pages/DownloadsPage.php
@@ -2,68 +2,72 @@
require_once('Controller.php');
require_once('Models/DownloadsModel.php');
-class DownloadsPage extends Controller {
- private $_template;
+class DownloadsPage extends Controller
+{
+ private $_template;
- /* Constructor. */
- public function __construct() {
- parent::__construct();
- $this->_template = 'pages/downloads.tpl';
- }
+ /* Constructor. */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->_template = 'pages/downloads.tpl';
+ }
- function getRecommendedDownloadsJS(&$downloads) {
- $js = "var versions = {\n";
+ function getRecommendedDownloadsJS(&$downloads)
+ {
+ $js = "var versions = {\n";
- foreach ($downloads as $dsection) {
- foreach ($dsection->getSubSections() as $dsubsection) {
- foreach ($dsubsection->getItems() as $curItem) {
- $userAgent = $curItem->getUserAgent();
+ foreach ($downloads as $dsection) {
+ foreach ($dsection->getSubSections() as $dsubsection) {
+ foreach ($dsubsection->getItems() as $curItem) {
+ $userAgent = $curItem->getUserAgent();
- if ($userAgent != "") {
- $url = str_replace('{$release}', RELEASE, $curItem->getURL());
- sscanf($url, "/frs/scummvm/%s", $versionStr);
- $version = substr($versionStr, 0, strpos($versionStr, "/"));
- $name = strip_tags($curItem->getName());
- $data = $curItem->getExtraInfo();
- if (is_array($data)) {
- $extra_text = $data['size'] . " ";
- if ($data['ext'] == '.exe')
- $extra_text = $extra_text . 'Win32 ';
+ if ($userAgent != "") {
+ $url = str_replace('{$release}', RELEASE, $curItem->getURL());
+ sscanf($url, "/frs/scummvm/%s", $versionStr);
+ $version = substr($versionStr, 0, strpos($versionStr, "/"));
+ $name = strip_tags($curItem->getName());
+ $data = $curItem->getExtraInfo();
+ if (is_array($data)) {
+ $extra_text = $data['size'] . " ";
+ if ($data['ext'] == '.exe') {
+ $extra_text = $extra_text . 'Win32 ';
+ }
- $extra_text .= $data['ext'] . " " . $data['msg'];
- } else {
- $extra_text = $data;
- }
+ $extra_text .= $data['ext'] . " " . $data['msg'];
+ } else {
+ $extra_text = $data;
+ }
- $js .= "\t\t\t'{$userAgent}':\t{ 'os':\t'{$name}', 'ver':\t'{$version}', 'desc':\t'{$extra_text}', 'url':\t'{$url}'},\n";
- }
- }
- }
- }
- $js .= "};\n";
+ $js .= "\t\t\t'{$userAgent}':\t{ 'os':\t'{$name}', 'ver':\t'{$version}', 'desc':\t'{$extra_text}', 'url':\t'{$url}'},\n";
+ }
+ }
+ }
+ }
+ $js .= "};\n";
- return $js;
- }
+ return $js;
+ }
- /* Display the index page. */
- public function index() {
- $downloads = DownloadsModel::getAllDownloads();
- $sections = DownloadsModel::getAllSections();
- $recommendedDownloadsJS = $this->getRecommendedDownloadsJS($downloads);
- global $Smarty;
-
- return $this->renderPage(
- array(
- 'title' => $Smarty->getConfigVars('downloadsTitle'),
- 'content_title' => $Smarty->getConfigVars('downloadsContentTitle'),
- 'downloads' => $downloads,
- 'sections' => $sections,
- 'release_tools' => RELEASE_TOOLS,
- 'release_debian' => RELEASE_DEBIAN,
- 'recommendedDownloadsJS' => $recommendedDownloadsJS
- ),
- $this->_template
- );
- }
+ /* Display the index page. */
+ public function index()
+ {
+ $downloads = DownloadsModel::getAllDownloads();
+ $sections = DownloadsModel::getAllSections();
+ $recommendedDownloadsJS = $this->getRecommendedDownloadsJS($downloads);
+ global $Smarty;
+
+ return $this->renderPage(
+ array(
+ 'title' => $Smarty->getConfigVars('downloadsTitle'),
+ 'content_title' => $Smarty->getConfigVars('downloadsContentTitle'),
+ 'downloads' => $downloads,
+ 'sections' => $sections,
+ 'release_tools' => RELEASE_TOOLS,
+ 'release_debian' => RELEASE_DEBIAN,
+ 'recommendedDownloadsJS' => $recommendedDownloadsJS
+ ),
+ $this->_template
+ );
+ }
}
-?>
diff --git a/include/Pages/ExceptionsPage.php b/include/Pages/ExceptionsPage.php
index b5963fd..b917252 100644
--- a/include/Pages/ExceptionsPage.php
+++ b/include/Pages/ExceptionsPage.php
@@ -1,27 +1,29 @@
<?php
require_once('Controller.php');
-class ExceptionsPage extends Controller {
- private $_template;
+class ExceptionsPage extends Controller
+{
+ private $_template;
- /* Constructor. */
- public function __construct() {
- parent::__construct();
- $this->_template = 'components/exception.tpl';
- }
+ /* Constructor. */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->_template = 'components/exception.tpl';
+ }
- /* Display the index page. */
- public function index($exception) {
- global $Smarty;
+ /* Display the index page. */
+ public function index($exception)
+ {
+ global $Smarty;
- return $this->renderPage(
- array(
- 'title' => $Smarty->getConfigVars('exceptionsTitle'),
- 'content_title' => $Smarty->getConfigVars('exceptionsContentTitle'),
- 'exception' => $exception,
- ),
- $this->_template
- );
- }
+ return $this->renderPage(
+ array(
+ 'title' => $Smarty->getConfigVars('exceptionsTitle'),
+ 'content_title' => $Smarty->getConfigVars('exceptionsContentTitle'),
+ 'exception' => $exception,
+ ),
+ $this->_template
+ );
+ }
}
-?>
diff --git a/include/Pages/FAQPage.php b/include/Pages/FAQPage.php
index a4485e4..38b7e03 100644
--- a/include/Pages/FAQPage.php
+++ b/include/Pages/FAQPage.php
@@ -2,30 +2,32 @@
require_once('Controller.php');
require_once('Models/FAQModel.php');
-class FAQPage extends Controller {
- private $_template;
+class FAQPage extends Controller
+{
+ private $_template;
- /* Constructor. */
- public function __construct() {
- parent::__construct();
- $this->_template = 'pages/faq.tpl';
- }
+ /* Constructor. */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->_template = 'pages/faq.tpl';
+ }
- /* Display the index page. */
- public function index() {
- $contents = FAQModel::getFAQ();
- $modified = FAQModel::getLastUpdated();
- global $Smarty;
+ /* Display the index page. */
+ public function index()
+ {
+ $contents = FAQModel::getFAQ();
+ $modified = FAQModel::getLastUpdated();
+ global $Smarty;
- return $this->renderPage(
- array(
- 'title' => $Smarty->getConfigVars('faqTitle'),
- 'content_title' => $Smarty->getConfigVars('faqContentTitle'),
- 'contents' => $contents,
- 'modified' => $modified,
- ),
- $this->_template
- );
- }
+ return $this->renderPage(
+ array(
+ 'title' => $Smarty->getConfigVars('faqTitle'),
+ 'content_title' => $Smarty->getConfigVars('faqContentTitle'),
+ 'contents' => $contents,
+ 'modified' => $modified,
+ ),
+ $this->_template
+ );
+ }
}
-?>
diff --git a/include/Pages/FeedsPage.php b/include/Pages/FeedsPage.php
index 9edfaa5..38221e1 100644
--- a/include/Pages/FeedsPage.php
+++ b/include/Pages/FeedsPage.php
@@ -2,36 +2,38 @@
require_once('Controller.php');
require_once('Models/NewsModel.php');
-class FeedsPage extends Controller {
- private $_template_rss;
- private $_template_atom;
+class FeedsPage extends Controller
+{
+ private $_template_rss;
+ private $_template_atom;
- /* Constructor. */
- public function __construct() {
- parent::__construct();
- $this->_template_rss = 'pages/feed_rss.tpl';
- $this->_template_atom = 'pages/feed_atom.tpl';
- }
+ /* Constructor. */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->_template_rss = 'pages/feed_rss.tpl';
+ $this->_template_atom = 'pages/feed_atom.tpl';
+ }
- /* Display the index page. */
- public function index() {
- $feed = $_GET['f'];
- if ($feed == 'atom') {
- $template = $this->_template_atom;
- } else {
- $template = $this->_template_rss;
- }
+ /* Display the index page. */
+ public function index()
+ {
+ $feed = $_GET['f'];
+ if ($feed == 'atom') {
+ $template = $this->_template_atom;
+ } else {
+ $template = $this->_template_rss;
+ }
- $news_items = NewsModel::getLatestNews(NEWS_ITEMS, true);
+ $news_items = NewsModel::getLatestNews(NEWS_ITEMS, true);
- header('Content-Type: text/xml; charset=UTF-8');
- print $this->fetch(
- $template,
- array(
- 'news' => $news_items,
- )
- );
- return True;
- }
+ header('Content-Type: text/xml; charset=UTF-8');
+ print $this->fetch(
+ $template,
+ array(
+ 'news' => $news_items,
+ )
+ );
+ return true;
+ }
}
-?>
diff --git a/include/Pages/GamesPage.php b/include/Pages/GamesPage.php
index 2b18d51..a8df729 100644
--- a/include/Pages/GamesPage.php
+++ b/include/Pages/GamesPage.php
@@ -2,32 +2,34 @@
require_once('Controller.php');
require_once('Models/GamesModel.php');
-class GamesPage extends Controller {
- private $_template;
+class GamesPage extends Controller
+{
+ private $_template;
- /* Constructor. */
- public function __construct() {
- parent::__construct();
- $this->_template = 'pages/games.tpl';
- }
+ /* Constructor. */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->_template = 'pages/games.tpl';
+ }
- /* Display the index page. */
- public function index() {
- $downloads = GamesModel::getAllDownloads();
- $sections = GamesModel::getAllSections();
- global $Smarty;
+ /* Display the index page. */
+ public function index()
+ {
+ $downloads = GamesModel::getAllDownloads();
+ $sections = GamesModel::getAllSections();
+ global $Smarty;
- return $this->renderPage(
- array(
- 'title' => $Smarty->getConfigVars('gamesTitle'),
- 'content_title' => $Smarty->getConfigVars('gamesContentTitle'),
- 'downloads' => $downloads,
- 'sections' => $sections,
- 'release_tools' => RELEASE_TOOLS,
- 'release_debian' => RELEASE_DEBIAN,
- ),
- $this->_template
- );
- }
+ return $this->renderPage(
+ array(
+ 'title' => $Smarty->getConfigVars('gamesTitle'),
+ 'content_title' => $Smarty->getConfigVars('gamesContentTitle'),
+ 'downloads' => $downloads,
+ 'sections' => $sections,
+ 'release_tools' => RELEASE_TOOLS,
+ 'release_debian' => RELEASE_DEBIAN,
+ ),
+ $this->_template
+ );
+ }
}
-?>
diff --git a/include/Pages/LinksPage.php b/include/Pages/LinksPage.php
index de8b991..e838ad9 100644
--- a/include/Pages/LinksPage.php
+++ b/include/Pages/LinksPage.php
@@ -2,28 +2,30 @@
require_once('Controller.php');
require_once('Models/LinksModel.php');
-class LinksPage extends Controller {
- private $_template;
+class LinksPage extends Controller
+{
+ private $_template;
- /* Constructor. */
- public function __construct() {
- parent::__construct();
- $this->_template = 'pages/links.tpl';
- }
+ /* Constructor. */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->_template = 'pages/links.tpl';
+ }
- /* Display the index page. */
- public function index() {
- $links = LinksModel::getAllGroupsAndLinks();
- global $Smarty;
-
- return $this->renderPage(
- array(
- 'title' => $Smarty->getConfigVars('linksTitle'),
- 'content_title' => $Smarty->getConfigVars('linksContentTitle'),
- 'links' => $links,
- ),
- $this->_template
- );
- }
+ /* Display the index page. */
+ public function index()
+ {
+ $links = LinksModel::getAllGroupsAndLinks();
+ global $Smarty;
+
+ return $this->renderPage(
+ array(
+ 'title' => $Smarty->getConfigVars('linksTitle'),
+ 'content_title' => $Smarty->getConfigVars('linksContentTitle'),
+ 'links' => $links,
+ ),
+ $this->_template
+ );
+ }
}
-?>
diff --git a/include/Pages/NewsPage.php b/include/Pages/NewsPage.php
index e29fa65..2d864d8 100644
--- a/include/Pages/NewsPage.php
+++ b/include/Pages/NewsPage.php
@@ -3,73 +3,77 @@ require_once('Controller.php');
require_once('Models/NewsModel.php');
require_once('Models/ScreenshotsModel.php');
-class NewsPage extends Controller {
- private $_template;
+class NewsPage extends Controller
+{
+ private $_template;
- /* Constructor. */
- public function __construct() {
- parent::__construct();
- $this->_template = 'pages/news.tpl';
- }
+ /* Constructor. */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->_template = 'pages/news.tpl';
+ }
- /* Display the index page. */
- public function index() {
- $filename = isset($_GET['d']) ? $_GET['d'] : null;
+ /* Display the index page. */
+ public function index()
+ {
+ $filename = isset($_GET['d']) ? $_GET['d'] : null;
- if ($filename != null) {
- if (strtolower($filename) == 'archive' || $filename == '') {
- $filename = null;
- }
- return $this->getNews($filename);
- }
- return $this->getNewsIntro();
- }
+ if ($filename != null) {
+ if (strtolower($filename) == 'archive' || $filename == '') {
+ $filename = null;
+ }
+ return $this->getNews($filename);
+ }
+ return $this->getNewsIntro();
+ }
- /* Display a specific news item, or all news items. */
- public function getNews($filename = null) {
- global $Smarty;
+ /* Display a specific news item, or all news items. */
+ public function getNews($filename = null)
+ {
+ global $Smarty;
- if ($filename == null) {
- $news_items = NewsModel::getAllNews();
- $filename = 'archive';
- } else {
- $news_items = array(NewsModel::getOneByFilename($filename));
- }
+ if ($filename == null) {
+ $news_items = NewsModel::getAllNews();
+ $filename = 'archive';
+ } else {
+ $news_items = array(NewsModel::getOneByFilename($filename));
+ }
- return $this->renderPage(
- array(
- 'title' => $Smarty->getConfigVars('newsTitle'),
- 'content_title' => $Smarty->getConfigVars('newsContentTitle'),
- 'show_intro' => false,
- 'news_items' => $news_items,
- 'news_archive_link' => false,
- ),
- $this->_template
- );
- }
+ return $this->renderPage(
+ array(
+ 'title' => $Smarty->getConfigVars('newsTitle'),
+ 'content_title' => $Smarty->getConfigVars('newsContentTitle'),
+ 'show_intro' => false,
+ 'news_items' => $news_items,
+ 'news_archive_link' => false,
+ ),
+ $this->_template
+ );
+ }
- /* Display the main page with limited news items and intro text. */
- public function getNewsIntro() {
- global $Smarty;
+ /* Display the main page with limited news items and intro text. */
+ public function getNewsIntro()
+ {
+ global $Smarty;
- $news_items = NewsModel::getLatestNews(NEWS_ITEMS);
- $random_shot = ScreenshotsModel::getRandomScreenshot();
+ $news_items = NewsModel::getLatestNews(NEWS_ITEMS);
+ $random_shot = ScreenshotsModel::getRandomScreenshot();
- $this->addJSFiles(array(
- 'baguetteBox.min.js'
- ));
+ $this->addJSFiles(array(
+ 'baguetteBox.min.js'
+ ));
- return $this->renderPage(
- array(
- 'title' => $Smarty->getConfigVars('newsTitle'),
- 'content_title' => $Smarty->getConfigVars('newsContentTitle'),
- 'show_intro' => true,
- 'news_items' => $news_items,
- 'news_archive_link' => true,
- 'random_shot' => $random_shot,
- ),
- $this->_template
- );
- }
+ return $this->renderPage(
+ array(
+ 'title' => $Smarty->getConfigVars('newsTitle'),
+ 'content_title' => $Smarty->getConfigVars('newsContentTitle'),
+ 'show_intro' => true,
+ 'news_items' => $news_items,
+ 'news_archive_link' => true,
+ 'random_shot' => $random_shot,
+ ),
+ $this->_template
+ );
+ }
}
-?>
diff --git a/include/Pages/PressPage.php b/include/Pages/PressPage.php
index b6e0697..02200f9 100644
--- a/include/Pages/PressPage.php
+++ b/include/Pages/PressPage.php
@@ -2,28 +2,30 @@
require_once('Controller.php');
require_once('Models/ArticleModel.php');
-class PressPage extends Controller {
- private $_template;
+class PressPage extends Controller
+{
+ private $_template;
- /* Constructor. */
- public function __construct() {
- parent::__construct();
- $this->_template = 'pages/press.tpl';
- }
+ /* Constructor. */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->_template = 'pages/press.tpl';
+ }
- /* Display the index page. */
- public function index() {
- $articles = ArticleModel::getAllArticles();
- global $Smarty;
+ /* Display the index page. */
+ public function index()
+ {
+ $articles = ArticleModel::getAllArticles();
+ global $Smarty;
- return $this->renderPage(
- array(
- 'title' => $Smarty->getConfigVars('pressTitle'),
- 'content_title' => $Smarty->getConfigVars('pressContentTitle'),
- 'articles' => $articles,
- ),
- $this->_template
- );
- }
+ return $this->renderPage(
+ array(
+ 'title' => $Smarty->getConfigVars('pressTitle'),
+ 'content_title' => $Smarty->getConfigVars('pressContentTitle'),
+ 'articles' => $articles,
+ ),
+ $this->_template
+ );
+ }
}
-?>
diff --git a/include/Pages/PressSnowberryPage.php b/include/Pages/PressSnowberryPage.php
index f7129fe..12f9e84 100644
--- a/include/Pages/PressSnowberryPage.php
+++ b/include/Pages/PressSnowberryPage.php
@@ -2,28 +2,30 @@
require_once('Controller.php');
require_once('Models/ArticleModel.php');
-class PressSnowberryPage extends Controller {
- private $_template;
+class PressSnowberryPage extends Controller
+{
+ private $_template;
- /* Constructor. */
- public function __construct() {
- parent::__construct();
- $this->_template = 'pages/press_snowberry.tpl';
- }
+ /* Constructor. */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->_template = 'pages/press_snowberry.tpl';
+ }
- /* Display the index page. */
- public function index() {
- $articles = ArticleModel::getAllArticles();
- global $Smarty;
+ /* Display the index page. */
+ public function index()
+ {
+ $articles = ArticleModel::getAllArticles();
+ global $Smarty;
- return $this->renderPage(
- array(
- 'title' => $Smarty->getConfigVars('pressSnowberryTitle'),
- 'content_title' => $Smarty->getConfigVars('pressSnowberryContentTitle'),
- 'articles' => $articles,
- ),
- $this->_template
- );
- }
+ return $this->renderPage(
+ array(
+ 'title' => $Smarty->getConfigVars('pressSnowberryTitle'),
+ 'content_title' => $Smarty->getConfigVars('pressSnowberryContentTitle'),
+ 'articles' => $articles,
+ ),
+ $this->_template
+ );
+ }
}
-?>
diff --git a/include/Pages/ScreenshotsPage.php b/include/Pages/ScreenshotsPage.php
index ca2d166..528db1d 100644
--- a/include/Pages/ScreenshotsPage.php
+++ b/include/Pages/ScreenshotsPage.php
@@ -2,92 +2,96 @@
require_once('Controller.php');
require_once('Models/ScreenshotsModel.php');
-class ScreenshotsPage extends Controller {
- private $_template;
- private $_template_category;
+class ScreenshotsPage extends Controller
+{
+ private $_template;
+ private $_template_category;
- /* Constructor. */
- public function __construct() {
- parent::__construct();
- $this->_template = 'pages/screenshots.tpl';
- $this->_template_category = 'pages/screenshots_category.tpl';
- $this->_template_viewer = 'screenshots_viewer.tpl';
- }
+ /* Constructor. */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->_template = 'pages/screenshots.tpl';
+ $this->_template_category = 'pages/screenshots_category.tpl';
+ $this->_template_viewer = 'screenshots_viewer.tpl';
+ }
- /* Display the index page. */
- public function index() {
- $category = $_GET['cat'];
- $game = $_GET['game'];
- $json = $_POST['json'];
+ /* Display the index page. */
+ public function index()
+ {
+ $category = $_GET['cat'];
+ $game = $_GET['game'];
+ $json = $_POST['json'];
- if (!empty($json)) {
- return $this->getAllJSON();
- } else if (!empty($category)) {
- return $this->getCategory($category, $game);
- }
+ if (!empty($json)) {
+ return $this->getAllJSON();
+ } elseif (!empty($category)) {
+ return $this->getCategory($category, $game);
+ }
- $this->addJSFiles(array(
- 'baguetteBox.min.js'
- ));
+ $this->addJSFiles(array(
+ 'baguetteBox.min.js'
+ ));
- $screenshot = ScreenshotsModel::getAllScreenshots();
- $random_shot = ScreenshotsModel::getRandomScreenshot();
+ $screenshot = ScreenshotsModel::getAllScreenshots();
+ $random_shot = ScreenshotsModel::getRandomScreenshot();
- global $Smarty;
+ global $Smarty;
- return $this->renderPage(
- array(
- 'title' => $Smarty->getConfigVars('screenshotsTitle'),
- 'content_title' => $Smarty->getConfigVars('screenshotsContentTitle'),
- 'screenshots' => $screenshot,
- 'random_shot' => $random_shot,
- ),
- $this->_template
- );
- }
+ return $this->renderPage(
+ array(
+ 'title' => $Smarty->getConfigVars('screenshotsTitle'),
+ 'content_title' => $Smarty->getConfigVars('screenshotsContentTitle'),
+ 'screenshots' => $screenshot,
+ 'random_shot' => $random_shot,
+ ),
+ $this->_template
+ );
+ }
- /* Display the selected category. */
- public function getCategory($category, $game) {
- $this->addJSFiles(array(
- 'baguetteBox.min.js'
- ));
+ /* Display the selected category. */
+ public function getCategory($category, $game)
+ {
+ $this->addJSFiles(array(
+ 'baguetteBox.min.js'
+ ));
- if (empty($game)) {
- $screenshots = ScreenshotsModel::getCategoryScreenshots($category);
- } else {
- $screenshots = array(
- 'category' => $category,
- 'games' => array(ScreenshotsModel::getTargetScreenshots($game))
- );
- }
+ if (empty($game)) {
+ $screenshots = ScreenshotsModel::getCategoryScreenshots($category);
+ } else {
+ $screenshots = array(
+ 'category' => $category,
+ 'games' => array(ScreenshotsModel::getTargetScreenshots($game))
+ );
+ }
- global $Smarty;
+ global $Smarty;
- return $this->renderPage(
- array(
- 'title' => $Smarty->getConfigVars('screenshotsTitle'),
- 'content_title' => $Smarty->getConfigVars('screenshotsContentTitle'),
- 'screenshots' => $screenshots,
- 'category' => $category,
- 'game' => $game,
- ),
- $this->_template_category
- );
- }
+ return $this->renderPage(
+ array(
+ 'title' => $Smarty->getConfigVars('screenshotsTitle'),
+ 'content_title' => $Smarty->getConfigVars('screenshotsContentTitle'),
+ 'screenshots' => $screenshots,
+ 'category' => $category,
+ 'game' => $game,
+ ),
+ $this->_template_category
+ );
+ }
- /* Get a list with all screenshot filenames/captions as a JSON list. */
- public function getAllJSON() {
- $sshots = array();
- foreach (ScreenshotsModel::getAllScreenshots() as $category) {
- foreach ($category['games'] as $screenshot) {
- foreach ($screenshot->getFiles() as $files) {
- $files['filename'] = DIR_SCREENSHOTS . "/{$files['filename']}-full.png";
- $sshots[] = array_values($files);
- }
- }
- }
- print json_encode($sshots);
- return True;
- }
+ /* Get a list with all screenshot filenames/captions as a JSON list. */
+ public function getAllJSON()
+ {
+ $sshots = array();
+ foreach (ScreenshotsModel::getAllScreenshots() as $category) {
+ foreach ($category['games'] as $screenshot) {
+ foreach ($screenshot->getFiles() as $files) {
+ $files['filename'] = DIR_SCREENSHOTS . "/{$files['filename']}-full.png";
+ $sshots[] = array_values($files);
+ }
+ }
+ }
+ print json_encode($sshots);
+ return true;
+ }
}
-?>
diff --git a/include/Pages/SubprojectsPage.php b/include/Pages/SubprojectsPage.php
index fb0e03a..2719fa4 100644
--- a/include/Pages/SubprojectsPage.php
+++ b/include/Pages/SubprojectsPage.php
@@ -2,28 +2,30 @@
require_once('Controller.php');
require_once('Models/SubprojectsModel.php');
-class SubprojectsPage extends Controller {
- private $_template;
+class SubprojectsPage extends Controller
+{
+ private $_template;
- /* Constructor. */
- public function __construct() {
- parent::__construct();
- $this->_template = 'pages/subprojects.tpl';
- }
+ /* Constructor. */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->_template = 'pages/subprojects.tpl';
+ }
- /* Display the index page. */
- public function index() {
- $subprojects = SubprojectsModel::getAllSubprojects();
- global $Smarty;
+ /* Display the index page. */
+ public function index()
+ {
+ $subprojects = SubprojectsModel::getAllSubprojects();
+ global $Smarty;
- return $this->renderPage(
- array(
- 'title' => $Smarty->getConfigVars('subprojectsTitle'),
- 'content_title' => $Smarty->getConfigVars('subprojectsContentTitle'),
- 'subprojects' => $subprojects,
- ),
- $this->_template
- );
- }
+ return $this->renderPage(
+ array(
+ 'title' => $Smarty->getConfigVars('subprojectsTitle'),
+ 'content_title' => $Smarty->getConfigVars('subprojectsContentTitle'),
+ 'subprojects' => $subprojects,
+ ),
+ $this->_template
+ );
+ }
}
-?>
diff --git a/include/XMLParser.php b/include/XMLParser.php
index d1bb2eb..0e6b7bc 100644
--- a/include/XMLParser.php
+++ b/include/XMLParser.php
@@ -9,288 +9,295 @@
* @author Fredrik Wendel
* @version 1.0
*/
-class XMLParser {
- const FILE_NOT_FOUND = 'The filename specified doesn\'t point to an exiting file.';
- const FILE_NOT_READABLE = 'Unable to read the contents of the file.';
- const DATA_NOT_XML = 'The data provided is not XML.';
- const PARSER_ERROR = 'Error parsing XML.';
+class XMLParser
+{
+ const FILE_NOT_FOUND = 'The filename specified doesn\'t point to an exiting file.';
+ const FILE_NOT_READABLE = 'Unable to read the contents of the file.';
+ const DATA_NOT_XML = 'The data provided is not XML.';
+ const PARSER_ERROR = 'Error parsing XML.';
- const NS_HTML4 = 'http://www.w3.org/TR/html4/';
- const NS_XHTML = 'http://www.w3.org/TR/xhtml1/';
+ const NS_HTML4 = 'http://www.w3.org/TR/html4/';
+ const NS_XHTML = 'http://www.w3.org/TR/xhtml1/';
- static private $empty_elements = array('br', 'hr', 'img');
- private $_tree;
- private $_data;
- private $_ptr;
+ private static $empty_elements = array('br', 'hr', 'img');
+ private $_tree;
+ private $_data;
+ private $_ptr;
- /**
- * Constructor.
- *
- * @access public
- * @since 1.0
- */
- public function __construct() {
- $this->_tree = array();
- $this->_data = null;
- $this->_ptr = null;
- }
+ /**
+ * Constructor.
+ *
+ * @access public
+ * @since 1.0
+ */
+ public function __construct()
+ {
+ $this->_tree = array();
+ $this->_data = null;
+ $this->_ptr = null;
+ }
- /**
- * Parse XML by filename, will read the XML data from a file and then parse
- * it. Returns a multidimensional array (aka tree). Optionally it will also
- * clear the tree and remove nested single arrays and link the values to the
- * parent directly instead.
- *
- * @param string $filename full path the XML file to parse
- * @return bool|array
- * @access public
- * @since 1.0
- * @throws ErrorException
- */
- public function parseByFilename($filename) {
- global $lang;
+ /**
+ * Parse XML by filename, will read the XML data from a file and then parse
+ * it. Returns a multidimensional array (aka tree). Optionally it will also
+ * clear the tree and remove nested single arrays and link the values to the
+ * parent directly instead.
+ *
+ * @param string $filename full path the XML file to parse
+ * @return bool|array
+ * @access public
+ * @since 1.0
+ * @throws ErrorException
+ */
+ public function parseByFilename($filename)
+ {
+ global $lang;
- if ($lang != 'en') {
- $fname = substr($filename, 0, strrpos($filename, '.'));
- $fext = strrchr($filename, '.' );
+ if ($lang != 'en') {
+ $fname = substr($filename, 0, strrpos($filename, '.'));
+ $fext = strrchr($filename, '.');
- $localized = $fname . "." . $lang . $fext;
+ $localized = $fname . "." . $lang . $fext;
- if (is_file($localized)) {
- if (!is_readable($localized)) {
- $file = "\n\nFilename: " . basename($localized) . "\n";
- throw new ErrorException(self::FILE_NOT_FOUND . $file);
- } else {
- $filename = $localized;
- }
- }
- }
+ if (is_file($localized)) {
+ if (!is_readable($localized)) {
+ $file = "\n\nFilename: " . basename($localized) . "\n";
+ throw new ErrorException(self::FILE_NOT_FOUND . $file);
+ } else {
+ $filename = $localized;
+ }
+ }
+ }
- $file = "\n\nFilename: " . basename($filename) . "\n";
- /* If we can't read the file there is nothing we can do. */
- if (!is_file($filename) || !is_readable($filename)) {
- throw new ErrorException(self::FILE_NOT_FOUND . $file);
- }
- /* Read the file contents. */
- if (!($xml = @file_get_contents($filename))) {
- throw new ErrorException(self::FILE_NOT_READABLE . $file);
- }
+ $file = "\n\nFilename: " . basename($filename) . "\n";
+ /* If we can't read the file there is nothing we can do. */
+ if (!is_file($filename) || !is_readable($filename)) {
+ throw new ErrorException(self::FILE_NOT_FOUND . $file);
+ }
+ /* Read the file contents. */
+ if (!($xml = @file_get_contents($filename))) {
+ throw new ErrorException(self::FILE_NOT_READABLE . $file);
+ }
- /* Parse the XML. */
- try {
- return $this->parseByData($xml);
- } catch (ErrorException $e) {
- $msg = "{$e->getMessage()}{$file}";
- throw new ErrorException($msg);
- }
- }
+ /* Parse the XML. */
+ try {
+ return $this->parseByData($xml);
+ } catch (ErrorException $e) {
+ $msg = "{$e->getMessage()}{$file}";
+ throw new ErrorException($msg);
+ }
+ }
- /**
- * Parses the XML data and returns a multidimensional array (aka tree).
- * Optionally it will also clear the tree and remove nested single arrays
- * and link the values to the parent directly instead.
- *
- * @param string $xml the XML to parse
- * @param bool $destroy_single_arrays whether to keep nested single arrays or not
- * @return bool|array
- * @access public
- * @since 1.0
- * @throws ErrorException
- */
- public function parseByData($xml) {
- if (!is_string($xml) || strlen($xml) == 0) {
- throw new ErrorException(self::DATA_NOT_XML);
- }
- /* Create a parser and set the options */
- $parser = xml_parser_create_ns();
- xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
- xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
- xml_set_object($parser, $this);
- xml_set_element_handler($parser, 'startElement', 'endElement');
- xml_set_character_data_handler($parser, 'getElement');
+ /**
+ * Parses the XML data and returns a multidimensional array (aka tree).
+ * Optionally it will also clear the tree and remove nested single arrays
+ * and link the values to the parent directly instead.
+ *
+ * @param string $xml the XML to parse
+ * @param bool $destroy_single_arrays whether to keep nested single arrays or not
+ * @return bool|array
+ * @access public
+ * @since 1.0
+ * @throws ErrorException
+ */
+ public function parseByData($xml)
+ {
+ if (!is_string($xml) || strlen($xml) == 0) {
+ throw new ErrorException(self::DATA_NOT_XML);
+ }
+ /* Create a parser and set the options */
+ $parser = xml_parser_create_ns();
+ xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
+ xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
+ xml_set_object($parser, $this);
+ xml_set_element_handler($parser, 'startElement', 'endElement');
+ xml_set_character_data_handler($parser, 'getElement');
- /**
- * Workaround the XML-parser not being able to handle HTML-entities by
- * encapsulating them as CDATA.
- */
- $pattern = '/(&(?:(?!quot|amp|apos|lt|gt)([a-z]+)|(#\d+));)/iU';
- $replace = '<![CDATA[\\1]]>';
- $xml = preg_replace($pattern, $replace, $xml);
- /* Parse the data and free the parser resource. */
- if (!xml_parse($parser, $xml, true)) {
- $error = "\n\nError code: " . xml_get_error_code($parser) . "\n";
- $error .= "Line: " . xml_get_current_line_number($parser) . ", character: " . xml_get_current_column_number($parser) . "\n";
- $error .= "Error message: " . xml_error_string(xml_get_error_code($parser)) . "\n";
- xml_parser_free($parser);
- throw new ErrorException(self::PARSER_ERROR . $error);
- }
- xml_parser_free($parser);
- /**
- * The root element will contain an array with an empty key, so we can
- * skip that one right now.
- */
- $tree = $this->_tree[''];
- $this->simplifyArray($tree);
- return $tree;
- }
+ /**
+ * Workaround the XML-parser not being able to handle HTML-entities by
+ * encapsulating them as CDATA.
+ */
+ $pattern = '/(&(?:(?!quot|amp|apos|lt|gt)([a-z]+)|(#\d+));)/iU';
+ $replace = '<![CDATA[\\1]]>';
+ $xml = preg_replace($pattern, $replace, $xml);
+ /* Parse the data and free the parser resource. */
+ if (!xml_parse($parser, $xml, true)) {
+ $error = "\n\nError code: " . xml_get_error_code($parser) . "\n";
+ $error .= "Line: " . xml_get_current_line_number($parser) . ", character: " . xml_get_current_column_number($parser) . "\n";
+ $error .= "Error message: " . xml_error_string(xml_get_error_code($parser)) . "\n";
+ xml_parser_free($parser);
+ throw new ErrorException(self::PARSER_ERROR . $error);
+ }
+ xml_parser_free($parser);
+ /**
+ * The root element will contain an array with an empty key, so we can
+ * skip that one right now.
+ */
+ $tree = $this->_tree[''];
+ $this->simplifyArray($tree);
+ return $tree;
+ }
- /**
- * Handles new tags opening in the XML-document.
- *
- * @param resource $parser XML parser resource
- * @param string $name name of the tag
- * @param array $attrs list of all attributes for the tag (if any)
- * @access private
- * @since 1.0
- */
- private function startElement($parser, $name, $attrs) {
- /* If we find a colon in the name, we need to check the namespace. */
- if (strpos($name, ':') !== false) {
- $namespace = implode(':', explode(':', $name, -1));
- /* Got (X)HTML data. */
- if (in_array($namespace, array(self::NS_HTML4, self::NS_XHTML))) {
- $pos = strrpos($name, ':');
- $namespace = substr($name, 0, $pos);
- $name = substr($name, ($pos+1));
- $data = "<{$name}";
- foreach ($attrs as $key => $value) {
- $data .= " {$key}=\"{$value}\"";
- }
- /* Handle HTML "empty" elements (ie: <br>, <hr>) properly. */
- if ($namespace == self::NS_XHTML && in_array($name, self::$empty_elements)) {
- $data .= " /";
- }
- $data .= ">";
- $this->getElement($parser, $data);
- }
- /* If not we can just rock on. */
- } else {
- if (!is_array($attrs) || (is_array($attrs) && count($attrs) == 0)) {
- $element = null;
- } else {
- $element = $attrs;
- /*$element = array();
- foreach ($attrs as $key => $value) {
- $element[$key] = $value;
- }*/
- }
+ /**
+ * Handles new tags opening in the XML-document.
+ *
+ * @param resource $parser XML parser resource
+ * @param string $name name of the tag
+ * @param array $attrs list of all attributes for the tag (if any)
+ * @access private
+ * @since 1.0
+ */
+ private function startElement($parser, $name, $attrs)
+ {
+ /* If we find a colon in the name, we need to check the namespace. */
+ if (strpos($name, ':') !== false) {
+ $namespace = implode(':', explode(':', $name, -1));
+ /* Got (X)HTML data. */
+ if (in_array($namespace, array(self::NS_HTML4, self::NS_XHTML))) {
+ $pos = strrpos($name, ':');
+ $namespace = substr($name, 0, $pos);
+ $name = substr($name, ($pos+1));
+ $data = "<{$name}";
+ foreach ($attrs as $key => $value) {
+ $data .= " {$key}=\"{$value}\"";
+ }
+ /* Handle HTML "empty" elements (ie: <br>, <hr>) properly. */
+ if ($namespace == self::NS_XHTML && in_array($name, self::$empty_elements)) {
+ $data .= " /";
+ }
+ $data .= ">";
+ $this->getElement($parser, $data);
+ }
+ /* If not we can just rock on. */
+ } else {
+ if (!is_array($attrs) || (is_array($attrs) && count($attrs) == 0)) {
+ $element = null;
+ } else {
+ $element = $attrs;
+ /*$element = array();
+ foreach ($attrs as $key => $value) {
+ $element[$key] = $value;
+ }*/
+ }
- /* Get the key for the last node in the tree. */
- end($this->_tree);
- $key = key($this->_tree);
+ /* Get the key for the last node in the tree. */
+ end($this->_tree);
+ $key = key($this->_tree);
- /* Store the position so we can add the data later. */
- $this->_ptr = &$this->_tree[$key][$name];
- /* Store a reference the attributes. */
- if ($element != null) {
- $this->_ptr['@attributes'] = &$element;
- } else {
- /**
- * For one reason or another that escapes me, we must do this,
- * or the tree won't be properly built. We will work against it
- * in endElement() by overwriting the empty elements created
- * here.
- */
- $this->_ptr[] = &$element;
- }
- /**
- * Store the reference directly in the tree until this node (and
- * it's children) are done. Will get removed in endElement().
- */
- $this->_tree[$name] = &$element;
- }
- }
+ /* Store the position so we can add the data later. */
+ $this->_ptr = &$this->_tree[$key][$name];
+ /* Store a reference the attributes. */
+ if ($element != null) {
+ $this->_ptr['@attributes'] = &$element;
+ } else {
+ /**
+ * For one reason or another that escapes me, we must do this,
+ * or the tree won't be properly built. We will work against it
+ * in endElement() by overwriting the empty elements created
+ * here.
+ */
+ $this->_ptr[] = &$element;
+ }
+ /**
+ * Store the reference directly in the tree until this node (and
+ * it's children) are done. Will get removed in endElement().
+ */
+ $this->_tree[$name] = &$element;
+ }
+ }
- /**
- * Handles data between tags in the XML-document.
- *
- * @param resource $parser XML parser resource
- * @param mixed $data data found between tags
- * @access private
- * @since 1.0
- */
- private function getElement($parser, $data) {
- $this->_data .= $data;
- }
+ /**
+ * Handles data between tags in the XML-document.
+ *
+ * @param resource $parser XML parser resource
+ * @param mixed $data data found between tags
+ * @access private
+ * @since 1.0
+ */
+ private function getElement($parser, $data)
+ {
+ $this->_data .= $data;
+ }
- /**
- * Handles tags closing in the XML-document.
- *
- * @param resource $parser XML parser resource
- * @param string $name name of the tag
- * @access private
- * @since 1.0
- */
- private function endElement($parser, $name) {
- /* If we find a colon in the name, we need to check the namespace. */
- if (strpos($name, ':') !== false) {
- $namespace = implode(':', explode(':', $name, -1));
- /* Got (X)HTML data. */
- if (in_array($namespace, array(self::NS_HTML4, self::NS_XHTML))) {
- $pos = strrpos($name, ':');
- $namespace = substr($name, 0, $pos);
- $name = substr($name, ($pos+1));
- /* Handle HTML "empty" elements (ie: <br>, <hr>) properly. */
- if (!in_array($name, self::$empty_elements)) {
- $this->getElement($parser, "</{$name}>");
- }
- }
- /* Otherwise we can just add the data. */
- } else {
- $data = trim($this->_data);
- if (!empty($data)) {
- /* If we got an empty element in the array, overwrite it. */
- $pos = count($this->_ptr);
- if (is_null($this->_ptr[($pos-1)])) {
- $pos--;
- }
- $this->_ptr[$pos] = $data;
- }
+ /**
+ * Handles tags closing in the XML-document.
+ *
+ * @param resource $parser XML parser resource
+ * @param string $name name of the tag
+ * @access private
+ * @since 1.0
+ */
+ private function endElement($parser, $name)
+ {
+ /* If we find a colon in the name, we need to check the namespace. */
+ if (strpos($name, ':') !== false) {
+ $namespace = implode(':', explode(':', $name, -1));
+ /* Got (X)HTML data. */
+ if (in_array($namespace, array(self::NS_HTML4, self::NS_XHTML))) {
+ $pos = strrpos($name, ':');
+ $namespace = substr($name, 0, $pos);
+ $name = substr($name, ($pos+1));
+ /* Handle HTML "empty" elements (ie: <br>, <hr>) properly. */
+ if (!in_array($name, self::$empty_elements)) {
+ $this->getElement($parser, "</{$name}>");
+ }
+ }
+ /* Otherwise we can just add the data. */
+ } else {
+ $data = trim($this->_data);
+ if (!empty($data)) {
+ /* If we got an empty element in the array, overwrite it. */
+ $pos = count($this->_ptr);
+ if (is_null($this->_ptr[($pos-1)])) {
+ $pos--;
+ }
+ $this->_ptr[$pos] = $data;
+ }
- /* Reset the internal data holder. */
- $this->_data = null;
- /* Remove the reference. */
- $pop = array_pop($this->_tree);
- }
- }
+ /* Reset the internal data holder. */
+ $this->_data = null;
+ /* Remove the reference. */
+ $pop = array_pop($this->_tree);
+ }
+ }
- /**
- * Removes unnecessary arrays in an array tree, if an array contains an
- * array with just one element in it, the middle array will be removed.
- * It won't touch 'attributes' keys though.
- *
- * @param array $array reference to the array tree
- * @param string $parent name of the parent
- * @param boolean $all_singles remove named single arrays or just 0 ones
- * @access private
- * @since 1.0
- */
- private function simplifyArray(&$array, $parent='', $all_singles=false) {
- if (is_array($array) && count($array) > 0) {
- foreach ((array)$array as $key => $value) {
- if (is_array($value) && $key !== '@attributes') {
- $this->simplifyArray($array[$key], $key);
- }
- if (count($array) == 1) {
- if (array_key_exists(0, $array)) {
- // HACK: The compatibility page assumes that the entry
- // 'game' is always an array. In case only one 'game'
- // tag is specified in a 'games' tag this would result
- // in the array of 'game' being simplified (i.e.
- // replaced by its contents). This breaks the
- // compatibility page. We work around this issue by
- // simply not simplifying arrays when the parent is
- // named 'game'.
- if ($parent !== 'game') {
- $array = $array[0];
- }
- } else {
- $keys = array_keys($array);
- $this->simplifyArray($array[$keys[0]], $keys[0]);
- }
- }
- }
- }
- }
+ /**
+ * Removes unnecessary arrays in an array tree, if an array contains an
+ * array with just one element in it, the middle array will be removed.
+ * It won't touch 'attributes' keys though.
+ *
+ * @param array $array reference to the array tree
+ * @param string $parent name of the parent
+ * @param boolean $all_singles remove named single arrays or just 0 ones
+ * @access private
+ * @since 1.0
+ */
+ private function simplifyArray(&$array, $parent = '', $all_singles = false)
+ {
+ if (is_array($array) && count($array) > 0) {
+ foreach ((array)$array as $key => $value) {
+ if (is_array($value) && $key !== '@attributes') {
+ $this->simplifyArray($array[$key], $key);
+ }
+ if (count($array) == 1) {
+ if (array_key_exists(0, $array)) {
+ // HACK: The compatibility page assumes that the entry
+ // 'game' is always an array. In case only one 'game'
+ // tag is specified in a 'games' tag this would result
+ // in the array of 'game' being simplified (i.e.
+ // replaced by its contents). This breaks the
+ // compatibility page. We work around this issue by
+ // simply not simplifying arrays when the parent is
+ // named 'game'.
+ if ($parent !== 'game') {
+ $array = $array[0];
+ }
+ } else {
+ $keys = array_keys($array);
+ $this->simplifyArray($array[$keys[0]], $keys[0]);
+ }
+ }
+ }
+ }
+ }
}
-?>
diff --git a/include/config.inc.php b/include/config.inc.php
index c9d3b60..00ffc42 100644
--- a/include/config.inc.php
+++ b/include/config.inc.php
@@ -15,15 +15,15 @@ date_default_timezone_set("UTC");
/* Base URL to the website. */
if ($_SERVER['SERVER_PORT'] == '80') {
- $url = "http://{$_SERVER['SERVER_NAME']}";
-} else if ($_SERVER['SERVER_PORT'] == '443') {
- $url = "https://{$_SERVER['SERVER_NAME']}";
+ $url = "http://{$_SERVER['SERVER_NAME']}";
+} elseif ($_SERVER['SERVER_PORT'] == '443') {
+ $url = "https://{$_SERVER['SERVER_NAME']}";
} else {
- $url = "http://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}";
+ $url = "http://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}";
}
if (substr($url, -1) != '/') {
- $url .= '/';
+ $url .= '/';
}
define('URL_BASE', $url);
unset($url);
@@ -57,4 +57,3 @@ define('SMARTY_CACHING_ENABLE', 0);
define('SMARTY_CACHING_LIFETIME', (60 * 60));
define('SMARTY_CACHING_COMPILE_CHECK', true); # used when developing
define('SMARTY_CACHING_FORCE_RECHECK', true); # used when developing
-?>
Commit: cfbeebb8dc1dcddebb84124951b039f8cff880d1
https://github.com/scummvm/scummvm-web/commit/cfbeebb8dc1dcddebb84124951b039f8cff880d1
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Add namespaces to all PHP files
Changed paths:
include/Controller.php
include/ExceptionHandler.php
include/I18N.php
include/Models/ArticleModel.php
include/Models/BasicModel.php
include/Models/CompatibilityModel.php
include/Models/CreditsModel.php
include/Models/DocumentationModel.php
include/Models/DownloadsModel.php
include/Models/FAQModel.php
include/Models/GameDemosModel.php
include/Models/GamesModel.php
include/Models/LinksModel.php
include/Models/MenuModel.php
include/Models/NewsModel.php
include/Models/ScreenshotsModel.php
include/Models/SubprojectsModel.php
include/Objects/Article.php
include/Objects/BasicObject.php
include/Objects/CSection.php
include/Objects/CompatGame.php
include/Objects/DSection.php
include/Objects/DSubSection.php
include/Objects/Document.php
include/Objects/File.php
include/Objects/GameDemo.php
include/Objects/MenuItem.php
include/Objects/News.php
include/Objects/Person.php
include/Objects/Project.php
include/Objects/QAEntry.php
include/Objects/QASection.php
include/Objects/Screenshot.php
include/Objects/WebLink.php
include/Pages/CompatibilityPage.php
include/Pages/ContactPage.php
include/Pages/CreditsPage.php
include/Pages/DemosPage.php
include/Pages/DocumentationPage.php
include/Pages/DownloadsPage.php
include/Pages/ExceptionsPage.php
include/Pages/FAQPage.php
include/Pages/FeedsPage.php
include/Pages/GamesPage.php
include/Pages/LinksPage.php
include/Pages/NewsPage.php
include/Pages/PressPage.php
include/Pages/PressSnowberryPage.php
include/Pages/ScreenshotsPage.php
include/Pages/SubprojectsPage.php
include/XMLParser.php
include/config.inc.php
diff --git a/include/Controller.php b/include/Controller.php
index cff0a74..191c94c 100644
--- a/include/Controller.php
+++ b/include/Controller.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web;
+
require_once(SMARTY_DIR . '/Smarty.class.php');
require_once('Models/MenuModel.php');
/**
@@ -53,7 +55,7 @@ class Controller
&& is_readable($fname)) {
$this->_smarty->configLoad($fname);
}
-
+
setlocale(LC_TIME, $Smarty->getConfigVars('locale'));
/**
diff --git a/include/ExceptionHandler.php b/include/ExceptionHandler.php
index 816762b..f77b36f 100644
--- a/include/ExceptionHandler.php
+++ b/include/ExceptionHandler.php
@@ -1,9 +1,11 @@
<?php
+namespace ScummVM\Web;
+
/** Handle uncaught exceptions. */
abstract class ExceptionHandler
{
private static $_exception;
-
+
/* If the MenuModel cause the exception we need to skip them. */
public static function skipMenus()
{
@@ -22,10 +24,10 @@ abstract class ExceptionHandler
}
}
}
-
+
return $skip_menus;
}
-
+
/* Handle exceptions. */
public static function handleException(Exception $e)
{
diff --git a/include/I18N.php b/include/I18N.php
index bbb4c83..ca01e2a 100644
--- a/include/I18N.php
+++ b/include/I18N.php
@@ -1,4 +1,5 @@
<?php
+namespace ScummVM\Web;
require_once('vendor/ezyang/htmlpurifier/library/HTMLPurifier.auto.php');
set_include_path('include');
diff --git a/include/Models/ArticleModel.php b/include/Models/ArticleModel.php
index eccf74e..f573c21 100644
--- a/include/Models/ArticleModel.php
+++ b/include/Models/ArticleModel.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Models;
+
require_once('Models/BasicModel.php');
require_once('Objects/Article.php');
/**
diff --git a/include/Models/BasicModel.php b/include/Models/BasicModel.php
index a20e82d..b861519 100644
--- a/include/Models/BasicModel.php
+++ b/include/Models/BasicModel.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Models;
+
abstract class BasicModel
{
}
diff --git a/include/Models/CompatibilityModel.php b/include/Models/CompatibilityModel.php
index 276b4b5..2e81913 100644
--- a/include/Models/CompatibilityModel.php
+++ b/include/Models/CompatibilityModel.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Models;
+
require_once('Models/BasicModel.php');
require_once('Objects/CompatGame.php');
require_once('XMLParser.php');
diff --git a/include/Models/CreditsModel.php b/include/Models/CreditsModel.php
index c6ffb0d..a691e4c 100644
--- a/include/Models/CreditsModel.php
+++ b/include/Models/CreditsModel.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Models;
+
require_once('Models/BasicModel.php');
require_once('Objects/CSection.php');
require_once('XMLParser.php');
diff --git a/include/Models/DocumentationModel.php b/include/Models/DocumentationModel.php
index 96d89cf..0b4efbf 100644
--- a/include/Models/DocumentationModel.php
+++ b/include/Models/DocumentationModel.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Models;
+
require_once('Models/BasicModel.php');
require_once('Objects/Document.php');
/**
diff --git a/include/Models/DownloadsModel.php b/include/Models/DownloadsModel.php
index 8a19841..1bea5a3 100644
--- a/include/Models/DownloadsModel.php
+++ b/include/Models/DownloadsModel.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Models;
+
require_once('Models/BasicModel.php');
require_once('Objects/DSection.php');
require_once('XMLParser.php');
diff --git a/include/Models/FAQModel.php b/include/Models/FAQModel.php
index e914eb6..a6eafbf 100644
--- a/include/Models/FAQModel.php
+++ b/include/Models/FAQModel.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Models;
+
require_once('Models/BasicModel.php');
require_once('Objects/QAEntry.php');
require_once('Objects/QASection.php');
diff --git a/include/Models/GameDemosModel.php b/include/Models/GameDemosModel.php
index de7f2eb..90b1c22 100644
--- a/include/Models/GameDemosModel.php
+++ b/include/Models/GameDemosModel.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Models;
+
require_once('Models/BasicModel.php');
require_once('Objects/GameDemo.php');
require_once('XMLParser.php');
diff --git a/include/Models/GamesModel.php b/include/Models/GamesModel.php
index 29ae30c..1cd4d8d 100644
--- a/include/Models/GamesModel.php
+++ b/include/Models/GamesModel.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Models;
+
require_once('Models/BasicModel.php');
require_once('Objects/DSection.php');
require_once('XMLParser.php');
diff --git a/include/Models/LinksModel.php b/include/Models/LinksModel.php
index e1f9b75..ab6bf97 100644
--- a/include/Models/LinksModel.php
+++ b/include/Models/LinksModel.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Models;
+
require_once('Models/BasicModel.php');
require_once('Objects/WebLink.php');
require_once('XMLParser.php');
diff --git a/include/Models/MenuModel.php b/include/Models/MenuModel.php
index bfcbfac..d2a1978 100644
--- a/include/Models/MenuModel.php
+++ b/include/Models/MenuModel.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Models;
+
require_once('XMLParser.php');
require_once('Models/BasicModel.php');
require_once('Objects/MenuItem.php');
diff --git a/include/Models/NewsModel.php b/include/Models/NewsModel.php
index 8a6a1c1..d163b5a 100644
--- a/include/Models/NewsModel.php
+++ b/include/Models/NewsModel.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Models;
+
require_once('Models/BasicModel.php');
require_once('Objects/News.php');
/**
diff --git a/include/Models/ScreenshotsModel.php b/include/Models/ScreenshotsModel.php
index 9a7ba83..56b59e4 100644
--- a/include/Models/ScreenshotsModel.php
+++ b/include/Models/ScreenshotsModel.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Models;
+
require_once('Models/BasicModel.php');
require_once('Objects/Screenshot.php');
require_once('XMLParser.php');
diff --git a/include/Models/SubprojectsModel.php b/include/Models/SubprojectsModel.php
index 58db17c..d430b91 100644
--- a/include/Models/SubprojectsModel.php
+++ b/include/Models/SubprojectsModel.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Models;
+
require_once('Models/BasicModel.php');
require_once('Objects/File.php');
require_once('Objects/Project.php');
diff --git a/include/Objects/Article.php b/include/Objects/Article.php
index 38ebf19..0279618 100644
--- a/include/Objects/Article.php
+++ b/include/Objects/Article.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Objects;
+
require_once('Objects/BasicObject.php');
/**
* The article class represents a link on the website to an article covering
diff --git a/include/Objects/BasicObject.php b/include/Objects/BasicObject.php
index 7a2f757..d17ed2f 100644
--- a/include/Objects/BasicObject.php
+++ b/include/Objects/BasicObject.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Objects;
+
/**
* The BasicObject class is inherited by all other objects and houses all common
* functions.
diff --git a/include/Objects/CSection.php b/include/Objects/CSection.php
index 36cfb12..44ef121 100644
--- a/include/Objects/CSection.php
+++ b/include/Objects/CSection.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Objects;
+
require_once('Objects/BasicObject.php');
require_once('Objects/Person.php');
/**
@@ -58,7 +60,7 @@ class CSection extends BasicObject
{
return $this->_title;
}
-
+
/* Get the anchor. */
public function getAnchor()
{
diff --git a/include/Objects/CompatGame.php b/include/Objects/CompatGame.php
index d5bf6f5..b204f21 100644
--- a/include/Objects/CompatGame.php
+++ b/include/Objects/CompatGame.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Objects;
+
require_once('Objects/BasicObject.php');
/**
* The CompatGame class represents a game on the compatibility charts on the
diff --git a/include/Objects/DSection.php b/include/Objects/DSection.php
index e961603..85dc1f4 100644
--- a/include/Objects/DSection.php
+++ b/include/Objects/DSection.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Objects;
+
require_once('Objects/BasicObject.php');
require_once('Objects/DSubSection.php');
/**
diff --git a/include/Objects/DSubSection.php b/include/Objects/DSubSection.php
index d3edae0..5c8696e 100644
--- a/include/Objects/DSubSection.php
+++ b/include/Objects/DSubSection.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Objects;
+
require_once('Objects/BasicObject.php');
require_once('Objects/File.php');
require_once('Objects/WebLink.php');
diff --git a/include/Objects/Document.php b/include/Objects/Document.php
index a68255b..577f39b 100644
--- a/include/Objects/Document.php
+++ b/include/Objects/Document.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Objects;
+
require_once('Objects/BasicObject.php');
/**
* The Document class represents a Document on the website.
diff --git a/include/Objects/File.php b/include/Objects/File.php
index 7ef6557..a73b08c 100644
--- a/include/Objects/File.php
+++ b/include/Objects/File.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Objects;
+
require_once('Objects/BasicObject.php');
/**
* The File object represents a file on the website.
diff --git a/include/Objects/GameDemo.php b/include/Objects/GameDemo.php
index b702ded..15ab048 100644
--- a/include/Objects/GameDemo.php
+++ b/include/Objects/GameDemo.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Objects;
+
require_once('Objects/BasicObject.php');
/**
* The GameDemo class represents a game demo item on the website.
@@ -9,7 +11,7 @@ class GameDemo extends BasicObject
private $_url;
private $_target;
private $_category;
-
+
/* GameDemo object constructor. */
public function __construct($data)
{
@@ -36,7 +38,7 @@ class GameDemo extends BasicObject
{
return $this->_target;
}
-
+
/* Get the category for the demo. */
public function getCategory()
{
diff --git a/include/Objects/MenuItem.php b/include/Objects/MenuItem.php
index c835e47..2a40fa6 100644
--- a/include/Objects/MenuItem.php
+++ b/include/Objects/MenuItem.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Objects;
+
require_once('Objects/BasicObject.php');
/**
* The menu class represents a sidebar menu group on the website.
diff --git a/include/Objects/News.php b/include/Objects/News.php
index 2aaae6a..54f4821 100644
--- a/include/Objects/News.php
+++ b/include/Objects/News.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Objects;
+
require_once('Objects/BasicObject.php');
/**
* The news class represents a news item on the website.
diff --git a/include/Objects/Person.php b/include/Objects/Person.php
index b778683..6304448 100644
--- a/include/Objects/Person.php
+++ b/include/Objects/Person.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Objects;
+
require_once('Objects/BasicObject.php');
/**
* The Person class represents a person entry on the credits page on the
diff --git a/include/Objects/Project.php b/include/Objects/Project.php
index a95e1c2..b65ed34 100644
--- a/include/Objects/Project.php
+++ b/include/Objects/Project.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Objects;
+
require_once('Objects/BasicObject.php');
/**
* The Project class represents a subproject on the website.
diff --git a/include/Objects/QAEntry.php b/include/Objects/QAEntry.php
index af0e793..76edc79 100644
--- a/include/Objects/QAEntry.php
+++ b/include/Objects/QAEntry.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Objects;
+
require_once('Objects/BasicObject.php');
/**
* The QAEntry class represents a question-answer pair on the website
diff --git a/include/Objects/QASection.php b/include/Objects/QASection.php
index b5eefea..cd3a9a5 100644
--- a/include/Objects/QASection.php
+++ b/include/Objects/QASection.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Objects;
+
require_once('Objects/BasicObject.php');
require_once('Objects/QAEntry.php');
/**
diff --git a/include/Objects/Screenshot.php b/include/Objects/Screenshot.php
index f2dd70d..afd8782 100644
--- a/include/Objects/Screenshot.php
+++ b/include/Objects/Screenshot.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Objects;
+
require_once('Objects/BasicObject.php');
/**
* The Screenshot object represents all screenshots for one game.
diff --git a/include/Objects/WebLink.php b/include/Objects/WebLink.php
index 2c2d0e1..8f97d53 100644
--- a/include/Objects/WebLink.php
+++ b/include/Objects/WebLink.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Objects;
+
require_once('Objects/BasicObject.php');
/**
* The WebLink class represents a link item on the website.
@@ -34,7 +36,7 @@ class WebLink extends BasicObject
{
return $this->_description;
}
-
+
/* Get the user-agent. */
public function getUserAgent()
{
diff --git a/include/Pages/CompatibilityPage.php b/include/Pages/CompatibilityPage.php
index c1113f8..3eac48d 100644
--- a/include/Pages/CompatibilityPage.php
+++ b/include/Pages/CompatibilityPage.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Pages;
+
require_once('Controller.php');
require_once('Models/CompatibilityModel.php');
/**
@@ -66,7 +68,7 @@ class CompatibilityPage extends Controller
{
$game = CompatibilityModel::getGameData($version, $target);
global $Smarty;
-
+
return $this->renderPage(
array(
'title' => preg_replace('/{version}/', $version, $Smarty->getConfigVars('compatibilityTitle')),
@@ -94,7 +96,7 @@ class CompatibilityPage extends Controller
$compat_data = CompatibilityModel::getAllData($version);
global $Smarty;
-
+
return $this->renderPage(
array(
'title' => preg_replace('/{version}/', $version, $Smarty->getConfigVars('compatibilityTitle')),
diff --git a/include/Pages/ContactPage.php b/include/Pages/ContactPage.php
index 2b9794c..4495e21 100644
--- a/include/Pages/ContactPage.php
+++ b/include/Pages/ContactPage.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Pages;
+
require_once('Controller.php');
class ContactPage extends Controller
diff --git a/include/Pages/CreditsPage.php b/include/Pages/CreditsPage.php
index 40134cc..b385466 100644
--- a/include/Pages/CreditsPage.php
+++ b/include/Pages/CreditsPage.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Pages;
+
require_once('Controller.php');
require_once('Models/CreditsModel.php');
@@ -18,7 +20,7 @@ class CreditsPage extends Controller
{
$credits = CreditsModel::getAllCredits();
global $Smarty;
-
+
return $this->renderPage(
array(
'title' => $Smarty->getConfigVars('creditsTitle'),
diff --git a/include/Pages/DemosPage.php b/include/Pages/DemosPage.php
index 52e8ed9..9bd7758 100644
--- a/include/Pages/DemosPage.php
+++ b/include/Pages/DemosPage.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Pages;
+
require_once('Controller.php');
require_once('Models/GameDemosModel.php');
diff --git a/include/Pages/DocumentationPage.php b/include/Pages/DocumentationPage.php
index 400a7ca..36ea38c 100644
--- a/include/Pages/DocumentationPage.php
+++ b/include/Pages/DocumentationPage.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Pages;
+
require_once('Controller.php');
require_once('Models/DocumentationModel.php');
diff --git a/include/Pages/DownloadsPage.php b/include/Pages/DownloadsPage.php
index d9172c6..ad72188 100644
--- a/include/Pages/DownloadsPage.php
+++ b/include/Pages/DownloadsPage.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Pages;
+
require_once('Controller.php');
require_once('Models/DownloadsModel.php');
@@ -56,7 +58,7 @@ class DownloadsPage extends Controller
$sections = DownloadsModel::getAllSections();
$recommendedDownloadsJS = $this->getRecommendedDownloadsJS($downloads);
global $Smarty;
-
+
return $this->renderPage(
array(
'title' => $Smarty->getConfigVars('downloadsTitle'),
diff --git a/include/Pages/ExceptionsPage.php b/include/Pages/ExceptionsPage.php
index b917252..15bdfb0 100644
--- a/include/Pages/ExceptionsPage.php
+++ b/include/Pages/ExceptionsPage.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Pages;
+
require_once('Controller.php');
class ExceptionsPage extends Controller
diff --git a/include/Pages/FAQPage.php b/include/Pages/FAQPage.php
index 38b7e03..826074b 100644
--- a/include/Pages/FAQPage.php
+++ b/include/Pages/FAQPage.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Pages;
+
require_once('Controller.php');
require_once('Models/FAQModel.php');
diff --git a/include/Pages/FeedsPage.php b/include/Pages/FeedsPage.php
index 38221e1..26d7649 100644
--- a/include/Pages/FeedsPage.php
+++ b/include/Pages/FeedsPage.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Pages;
+
require_once('Controller.php');
require_once('Models/NewsModel.php');
diff --git a/include/Pages/GamesPage.php b/include/Pages/GamesPage.php
index a8df729..b2bb1cb 100644
--- a/include/Pages/GamesPage.php
+++ b/include/Pages/GamesPage.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Pages;
+
require_once('Controller.php');
require_once('Models/GamesModel.php');
diff --git a/include/Pages/LinksPage.php b/include/Pages/LinksPage.php
index e838ad9..844a5d2 100644
--- a/include/Pages/LinksPage.php
+++ b/include/Pages/LinksPage.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Pages;
+
require_once('Controller.php');
require_once('Models/LinksModel.php');
@@ -18,7 +20,7 @@ class LinksPage extends Controller
{
$links = LinksModel::getAllGroupsAndLinks();
global $Smarty;
-
+
return $this->renderPage(
array(
'title' => $Smarty->getConfigVars('linksTitle'),
diff --git a/include/Pages/NewsPage.php b/include/Pages/NewsPage.php
index 2d864d8..d48c02f 100644
--- a/include/Pages/NewsPage.php
+++ b/include/Pages/NewsPage.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Pages;
+
require_once('Controller.php');
require_once('Models/NewsModel.php');
require_once('Models/ScreenshotsModel.php');
diff --git a/include/Pages/PressPage.php b/include/Pages/PressPage.php
index 02200f9..8932e7a 100644
--- a/include/Pages/PressPage.php
+++ b/include/Pages/PressPage.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Pages;
+
require_once('Controller.php');
require_once('Models/ArticleModel.php');
diff --git a/include/Pages/PressSnowberryPage.php b/include/Pages/PressSnowberryPage.php
index 12f9e84..5fe0623 100644
--- a/include/Pages/PressSnowberryPage.php
+++ b/include/Pages/PressSnowberryPage.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Pages;
+
require_once('Controller.php');
require_once('Models/ArticleModel.php');
diff --git a/include/Pages/ScreenshotsPage.php b/include/Pages/ScreenshotsPage.php
index 528db1d..ce1d3da 100644
--- a/include/Pages/ScreenshotsPage.php
+++ b/include/Pages/ScreenshotsPage.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Pages;
+
require_once('Controller.php');
require_once('Models/ScreenshotsModel.php');
diff --git a/include/Pages/SubprojectsPage.php b/include/Pages/SubprojectsPage.php
index 2719fa4..59bd731 100644
--- a/include/Pages/SubprojectsPage.php
+++ b/include/Pages/SubprojectsPage.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web\Pages;
+
require_once('Controller.php');
require_once('Models/SubprojectsModel.php');
diff --git a/include/XMLParser.php b/include/XMLParser.php
index 0e6b7bc..141d952 100644
--- a/include/XMLParser.php
+++ b/include/XMLParser.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web;
+
/**
* An XML parser that will build a multidimensional array (aka a tree) from the
* given XML data, either by filename or by data. The parser is namespace aware,
diff --git a/include/config.inc.php b/include/config.inc.php
index 00ffc42..c7b3a35 100644
--- a/include/config.inc.php
+++ b/include/config.inc.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web;
+
/* Current version. */
define('RELEASE', '2.0.0');
define('RELEASE_TOOLS', '2.0.0');
Commit: a7d87ddf58ed77e9abd65ba8154f53b2da54d358
https://github.com/scummvm/scummvm-web/commit/a7d87ddf58ed77e9abd65ba8154f53b2da54d358
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: format index.php for psr-2
Changed paths:
index.php
diff --git a/index.php b/index.php
index 78514c6..8bfd7a9 100644
--- a/index.php
+++ b/index.php
@@ -1,4 +1,6 @@
<?php
+namespace ScummVM\Web;
+
/**
* Multilingual support
*/
@@ -12,56 +14,58 @@ $available_languages = array(
'ru' => 'Русский'
);
-function get_preferred_languages() {
- $lang_parse = array();
- preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse);
+function get_preferred_languages()
+{
+ $lang_parse = array();
+ preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse);
- if (count($lang_parse[1])) {
- $langs = array_combine($lang_parse[1], $lang_parse[4]);
- foreach ($langs as $candidate => $quality) {
- if ($quality === '') {
- $langs[$candidate] = 1;
- }
+ if (count($lang_parse[1])) {
+ $langs = array_combine($lang_parse[1], $lang_parse[4]);
+ foreach ($langs as $candidate => $quality) {
+ if ($quality === '') {
+ $langs[$candidate] = 1;
+ }
+ }
+ arsort($langs, SORT_NUMERIC);
+ return array_keys($langs);
}
- arsort($langs, SORT_NUMERIC);
- return array_keys($langs);
- }
- return array();
+ return array();
}
if (!empty($_REQUEST['lang'])) {
- $lang = $_REQUEST['lang'];
+ $lang = $_REQUEST['lang'];
} elseif (!empty($_COOKIE['lang'])) {
- $lang = $_COOKIE['lang'];
+ $lang = $_COOKIE['lang'];
} elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
- foreach (get_preferred_languages() as $candidate) {
- $candidate_major = current(explode('-', $candidate, 1));
- if (isset($available_languages[$candidate_major])) {
- $lang = $candidate_major;
- break;
+ foreach (get_preferred_languages() as $candidate) {
+ $candidate_major = current(explode('-', $candidate, 1));
+ if (isset($available_languages[$candidate_major])) {
+ $lang = $candidate_major;
+ break;
+ }
}
- }
}
-if (!array_key_exists($lang, $available_languages))
- $lang = 'en';
+if (!array_key_exists($lang, $available_languages)) {
+ $lang = 'en';
+}
/* We have to clean the mess introduced by double cookie at the wrong level */
if (empty($_COOKIE['clear_lang'])) {
- setcookie("lang", 'deleted', 1); // Setting it a current domain level, as it stays one level up
- setcookie("clear_lang", "deleted", 1456167472); // Hardcoded to 22-Feb-2016 when previous cookie expires
+ setcookie("lang", 'deleted', 1); // Setting it a current domain level, as it stays one level up
+ setcookie("clear_lang", "deleted", 1456167472); // Hardcoded to 22-Feb-2016 when previous cookie expires
}
/* Load the configuration. */
require_once('include/config.inc.php');
/* Set up the include path. */
set_include_path(get_include_path() . PATH_SEPARATOR . DIR_INCLUDE);
-error_reporting(E_ALL ^ E_NOTICE); // disable notices
+error_reporting(E_ALL ^ E_NOTICE); // disable notices
if (!is_writeable(SMARTY_DIR_COMPILE)) {
- print "Smarty compile dir (" . SMARTY_DIR_COMPILE . ") isn't writeable!<br>\n";
- die (1);
+ print "Smarty compile dir (" . SMARTY_DIR_COMPILE . ") isn't writeable!<br>\n";
+ die(1);
}
/* Exception handling. */
@@ -70,31 +74,29 @@ set_exception_handler(array('ExceptionHandler', 'handleException'));
/* Page mapping. */
$pages = array(
- 'compatibility' => 'CompatibilityPage',
- 'contact' => 'ContactPage',
- 'credits' => 'CreditsPage',
- 'demos' => 'DemosPage',
- 'documentation' => 'DocumentationPage',
- 'downloads' => 'DownloadsPage',
- 'games' => 'GamesPage',
- 'faq' => 'FAQPage',
- 'feeds' => 'FeedsPage',
- 'links' => 'LinksPage',
- 'news' => 'NewsPage',
- 'press' => 'PressPage',
- 'presssnowberry' => 'PressSnowberryPage',
- 'screenshots' => 'ScreenshotsPage',
- 'subprojects' => 'SubprojectsPage',
+ 'compatibility' => 'CompatibilityPage',
+ 'contact' => 'ContactPage',
+ 'credits' => 'CreditsPage',
+ 'demos' => 'DemosPage',
+ 'documentation' => 'DocumentationPage',
+ 'downloads' => 'DownloadsPage',
+ 'games' => 'GamesPage',
+ 'faq' => 'FAQPage',
+ 'feeds' => 'FeedsPage',
+ 'links' => 'LinksPage',
+ 'news' => 'NewsPage',
+ 'press' => 'PressPage',
+ 'presssnowberry' => 'PressSnowberryPage',
+ 'screenshots' => 'ScreenshotsPage',
+ 'subprojects' => 'SubprojectsPage',
);
/* Default to the news page. */
if (!array_key_exists(($page = isset($_GET['p']) ? $_GET['p'] : null), $pages)) {
- $page = 'news';
+ $page = 'news';
}
/* Switch to the requested page */
-require_once ("Pages/{$pages[$page]}.php");
+require_once("Pages/{$pages[$page]}.php");
$p = new $pages[$page]();
return $p->index();
-
-?>
Commit: 85328f29972a4bec88c7227a37d2b00314018c10
https://github.com/scummvm/scummvm-web/commit/85328f29972a4bec88c7227a37d2b00314018c10
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Use PSR-4 autoloading
Changed paths:
composer.json
include/Controller.php
include/ExceptionHandler.php
include/I18N.php
include/Models/ArticleModel.php
include/Models/BasicModel.php
include/Models/CompatibilityModel.php
include/Models/CreditsModel.php
include/Models/DocumentationModel.php
include/Models/DownloadsModel.php
include/Models/FAQModel.php
include/Models/GameDemosModel.php
include/Models/GamesModel.php
include/Models/LinksModel.php
include/Models/MenuModel.php
include/Models/NewsModel.php
include/Models/ScreenshotsModel.php
include/Models/SubprojectsModel.php
include/Objects/Article.php
include/Objects/BasicObject.php
include/Objects/CSection.php
include/Objects/CompatGame.php
include/Objects/DSection.php
include/Objects/DSubSection.php
include/Objects/Document.php
include/Objects/File.php
include/Objects/GameDemo.php
include/Objects/MenuItem.php
include/Objects/News.php
include/Objects/Person.php
include/Objects/Project.php
include/Objects/QAEntry.php
include/Objects/QASection.php
include/Objects/Screenshot.php
include/Objects/WebLink.php
include/Pages/CompatibilityPage.php
include/Pages/ContactPage.php
include/Pages/CreditsPage.php
include/Pages/DemosPage.php
include/Pages/DocumentationPage.php
include/Pages/DownloadsPage.php
include/Pages/ExceptionsPage.php
include/Pages/FAQPage.php
include/Pages/FeedsPage.php
include/Pages/GamesPage.php
include/Pages/LinksPage.php
include/Pages/NewsPage.php
include/Pages/PressPage.php
include/Pages/PressSnowberryPage.php
include/Pages/ScreenshotsPage.php
include/Pages/SubprojectsPage.php
include/XMLParser.php
include/config.inc.php
index.php
package-lock.json
diff --git a/composer.json b/composer.json
index 600a5a6..94cc0c8 100644
--- a/composer.json
+++ b/composer.json
@@ -33,5 +33,10 @@
"require-dev": {
"phpstan/phpstan": "^0.11.1",
"squizlabs/php_codesniffer": "^3.4"
+ },
+ "autoload": {
+ "psr-4": {
+ "ScummVM\\": [ "include/", "index.php"]
+ }
}
}
diff --git a/include/Controller.php b/include/Controller.php
index 191c94c..98284d4 100644
--- a/include/Controller.php
+++ b/include/Controller.php
@@ -1,8 +1,9 @@
<?php
-namespace ScummVM\Web;
+namespace ScummVM;
+
+use Smarty;
+use ScummVM\Models\MenuModel;
-require_once(SMARTY_DIR . '/Smarty.class.php');
-require_once('Models/MenuModel.php');
/**
* The Controller class will create an instance of the Smarty object configured
* as specified in config.inc. Should be subclassed by all webpages so they can
diff --git a/include/ExceptionHandler.php b/include/ExceptionHandler.php
index f77b36f..04e2b52 100644
--- a/include/ExceptionHandler.php
+++ b/include/ExceptionHandler.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web;
+namespace ScummVM;
/** Handle uncaught exceptions. */
abstract class ExceptionHandler
@@ -29,12 +29,11 @@ abstract class ExceptionHandler
}
/* Handle exceptions. */
- public static function handleException(Exception $e)
+ public static function handleException($e)
{
self::$_exception = $e;
- require_once('Pages/ExceptionsPage.php');
- $ep = new ExceptionsPage();
+ $ep = new \ScummVM\Pages\ExceptionsPage();
return $ep->index($e);
}
}
diff --git a/include/I18N.php b/include/I18N.php
index ca01e2a..e38bdcc 100644
--- a/include/I18N.php
+++ b/include/I18N.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web;
+namespace ScummVM;
require_once('vendor/ezyang/htmlpurifier/library/HTMLPurifier.auto.php');
set_include_path('include');
diff --git a/include/Models/ArticleModel.php b/include/Models/ArticleModel.php
index f573c21..a4b9681 100644
--- a/include/Models/ArticleModel.php
+++ b/include/Models/ArticleModel.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Models;
+namespace ScummVM\Models;
require_once('Models/BasicModel.php');
require_once('Objects/Article.php');
diff --git a/include/Models/BasicModel.php b/include/Models/BasicModel.php
index b861519..1a8d66f 100644
--- a/include/Models/BasicModel.php
+++ b/include/Models/BasicModel.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Models;
+namespace ScummVM\Models;
abstract class BasicModel
{
diff --git a/include/Models/CompatibilityModel.php b/include/Models/CompatibilityModel.php
index 2e81913..5f8e7a6 100644
--- a/include/Models/CompatibilityModel.php
+++ b/include/Models/CompatibilityModel.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Models;
+namespace ScummVM\Models;
require_once('Models/BasicModel.php');
require_once('Objects/CompatGame.php');
diff --git a/include/Models/CreditsModel.php b/include/Models/CreditsModel.php
index a691e4c..735c4af 100644
--- a/include/Models/CreditsModel.php
+++ b/include/Models/CreditsModel.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Models;
+namespace ScummVM\Models;
require_once('Models/BasicModel.php');
require_once('Objects/CSection.php');
diff --git a/include/Models/DocumentationModel.php b/include/Models/DocumentationModel.php
index 0b4efbf..23c61e3 100644
--- a/include/Models/DocumentationModel.php
+++ b/include/Models/DocumentationModel.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Models;
+namespace ScummVM\Models;
require_once('Models/BasicModel.php');
require_once('Objects/Document.php');
diff --git a/include/Models/DownloadsModel.php b/include/Models/DownloadsModel.php
index 1bea5a3..cf6db7b 100644
--- a/include/Models/DownloadsModel.php
+++ b/include/Models/DownloadsModel.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Models;
+namespace ScummVM\Models;
require_once('Models/BasicModel.php');
require_once('Objects/DSection.php');
diff --git a/include/Models/FAQModel.php b/include/Models/FAQModel.php
index a6eafbf..5adabac 100644
--- a/include/Models/FAQModel.php
+++ b/include/Models/FAQModel.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Models;
+namespace ScummVM\Models;
require_once('Models/BasicModel.php');
require_once('Objects/QAEntry.php');
diff --git a/include/Models/GameDemosModel.php b/include/Models/GameDemosModel.php
index 90b1c22..89ababd 100644
--- a/include/Models/GameDemosModel.php
+++ b/include/Models/GameDemosModel.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Models;
+namespace ScummVM\Models;
require_once('Models/BasicModel.php');
require_once('Objects/GameDemo.php');
diff --git a/include/Models/GamesModel.php b/include/Models/GamesModel.php
index 1cd4d8d..19070ad 100644
--- a/include/Models/GamesModel.php
+++ b/include/Models/GamesModel.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Models;
+namespace ScummVM\Models;
require_once('Models/BasicModel.php');
require_once('Objects/DSection.php');
diff --git a/include/Models/LinksModel.php b/include/Models/LinksModel.php
index ab6bf97..c7feca5 100644
--- a/include/Models/LinksModel.php
+++ b/include/Models/LinksModel.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Models;
+namespace ScummVM\Models;
require_once('Models/BasicModel.php');
require_once('Objects/WebLink.php');
diff --git a/include/Models/MenuModel.php b/include/Models/MenuModel.php
index d2a1978..6da6790 100644
--- a/include/Models/MenuModel.php
+++ b/include/Models/MenuModel.php
@@ -1,9 +1,10 @@
<?php
-namespace ScummVM\Web\Models;
+namespace ScummVM\Models;
+
+use ScummVM\XMLParser;
+use ScummVM\Models\BasicModel;
+use ScummVM\Objects\MenuItem;
-require_once('XMLParser.php');
-require_once('Models/BasicModel.php');
-require_once('Objects/MenuItem.php');
/**
* The MenuModel class will generates MenuItme objects.
*/
diff --git a/include/Models/NewsModel.php b/include/Models/NewsModel.php
index d163b5a..1ccdcc6 100644
--- a/include/Models/NewsModel.php
+++ b/include/Models/NewsModel.php
@@ -1,8 +1,8 @@
<?php
-namespace ScummVM\Web\Models;
+namespace ScummVM\Models;
+
+use ScummVM\Objects\News;
-require_once('Models/BasicModel.php');
-require_once('Objects/News.php');
/**
* The NewsModel class will generate News objects
*/
diff --git a/include/Models/ScreenshotsModel.php b/include/Models/ScreenshotsModel.php
index 56b59e4..6d3b896 100644
--- a/include/Models/ScreenshotsModel.php
+++ b/include/Models/ScreenshotsModel.php
@@ -1,9 +1,10 @@
<?php
-namespace ScummVM\Web\Models;
+namespace ScummVM\Models;
+
+use ScummVM\Objects\Screenshot;
+use ScummVM\Objects\BasicObject;
+use ScummVM\XMLParser;
-require_once('Models/BasicModel.php');
-require_once('Objects/Screenshot.php');
-require_once('XMLParser.php');
/**
* The ScreenshotsModel will generate Screenshot objects.
*/
diff --git a/include/Models/SubprojectsModel.php b/include/Models/SubprojectsModel.php
index d430b91..58ae359 100644
--- a/include/Models/SubprojectsModel.php
+++ b/include/Models/SubprojectsModel.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Models;
+namespace ScummVM\Models;
require_once('Models/BasicModel.php');
require_once('Objects/File.php');
diff --git a/include/Objects/Article.php b/include/Objects/Article.php
index 0279618..86ecf81 100644
--- a/include/Objects/Article.php
+++ b/include/Objects/Article.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Objects;
+namespace ScummVM\Objects;
require_once('Objects/BasicObject.php');
/**
diff --git a/include/Objects/BasicObject.php b/include/Objects/BasicObject.php
index d17ed2f..220e0d0 100644
--- a/include/Objects/BasicObject.php
+++ b/include/Objects/BasicObject.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Objects;
+namespace ScummVM\Objects;
/**
* The BasicObject class is inherited by all other objects and houses all common
diff --git a/include/Objects/CSection.php b/include/Objects/CSection.php
index 44ef121..183f097 100644
--- a/include/Objects/CSection.php
+++ b/include/Objects/CSection.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Objects;
+namespace ScummVM\Objects;
require_once('Objects/BasicObject.php');
require_once('Objects/Person.php');
diff --git a/include/Objects/CompatGame.php b/include/Objects/CompatGame.php
index b204f21..34c99e9 100644
--- a/include/Objects/CompatGame.php
+++ b/include/Objects/CompatGame.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Objects;
+namespace ScummVM\Objects;
require_once('Objects/BasicObject.php');
/**
diff --git a/include/Objects/DSection.php b/include/Objects/DSection.php
index 85dc1f4..7489c35 100644
--- a/include/Objects/DSection.php
+++ b/include/Objects/DSection.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Objects;
+namespace ScummVM\Objects;
require_once('Objects/BasicObject.php');
require_once('Objects/DSubSection.php');
diff --git a/include/Objects/DSubSection.php b/include/Objects/DSubSection.php
index 5c8696e..f673d15 100644
--- a/include/Objects/DSubSection.php
+++ b/include/Objects/DSubSection.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Objects;
+namespace ScummVM\Objects;
require_once('Objects/BasicObject.php');
require_once('Objects/File.php');
diff --git a/include/Objects/Document.php b/include/Objects/Document.php
index 577f39b..a20bfe2 100644
--- a/include/Objects/Document.php
+++ b/include/Objects/Document.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Objects;
+namespace ScummVM\Objects;
require_once('Objects/BasicObject.php');
/**
diff --git a/include/Objects/File.php b/include/Objects/File.php
index a73b08c..5e903c9 100644
--- a/include/Objects/File.php
+++ b/include/Objects/File.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Objects;
+namespace ScummVM\Objects;
require_once('Objects/BasicObject.php');
/**
diff --git a/include/Objects/GameDemo.php b/include/Objects/GameDemo.php
index 15ab048..556677b 100644
--- a/include/Objects/GameDemo.php
+++ b/include/Objects/GameDemo.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Objects;
+namespace ScummVM\Objects;
require_once('Objects/BasicObject.php');
/**
diff --git a/include/Objects/MenuItem.php b/include/Objects/MenuItem.php
index 2a40fa6..c575677 100644
--- a/include/Objects/MenuItem.php
+++ b/include/Objects/MenuItem.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Objects;
+namespace ScummVM\Objects;
require_once('Objects/BasicObject.php');
/**
diff --git a/include/Objects/News.php b/include/Objects/News.php
index 54f4821..3ff4441 100644
--- a/include/Objects/News.php
+++ b/include/Objects/News.php
@@ -1,7 +1,6 @@
<?php
-namespace ScummVM\Web\Objects;
+namespace ScummVM\Objects;
-require_once('Objects/BasicObject.php');
/**
* The news class represents a news item on the website.
*/
diff --git a/include/Objects/Person.php b/include/Objects/Person.php
index 6304448..5e999df 100644
--- a/include/Objects/Person.php
+++ b/include/Objects/Person.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Objects;
+namespace ScummVM\Objects;
require_once('Objects/BasicObject.php');
/**
diff --git a/include/Objects/Project.php b/include/Objects/Project.php
index b65ed34..569c3b3 100644
--- a/include/Objects/Project.php
+++ b/include/Objects/Project.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Objects;
+namespace ScummVM\Objects;
require_once('Objects/BasicObject.php');
/**
diff --git a/include/Objects/QAEntry.php b/include/Objects/QAEntry.php
index 76edc79..138b8a7 100644
--- a/include/Objects/QAEntry.php
+++ b/include/Objects/QAEntry.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Objects;
+namespace ScummVM\Objects;
require_once('Objects/BasicObject.php');
/**
diff --git a/include/Objects/QASection.php b/include/Objects/QASection.php
index cd3a9a5..59c03cd 100644
--- a/include/Objects/QASection.php
+++ b/include/Objects/QASection.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Objects;
+namespace ScummVM\Objects;
require_once('Objects/BasicObject.php');
require_once('Objects/QAEntry.php');
diff --git a/include/Objects/Screenshot.php b/include/Objects/Screenshot.php
index afd8782..13cd7fd 100644
--- a/include/Objects/Screenshot.php
+++ b/include/Objects/Screenshot.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Objects;
+namespace ScummVM\Objects;
require_once('Objects/BasicObject.php');
/**
diff --git a/include/Objects/WebLink.php b/include/Objects/WebLink.php
index 8f97d53..1a1d8ee 100644
--- a/include/Objects/WebLink.php
+++ b/include/Objects/WebLink.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Objects;
+namespace ScummVM\Objects;
require_once('Objects/BasicObject.php');
/**
diff --git a/include/Pages/CompatibilityPage.php b/include/Pages/CompatibilityPage.php
index 3eac48d..f068174 100644
--- a/include/Pages/CompatibilityPage.php
+++ b/include/Pages/CompatibilityPage.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Pages;
+namespace ScummVM\Pages;
require_once('Controller.php');
require_once('Models/CompatibilityModel.php');
diff --git a/include/Pages/ContactPage.php b/include/Pages/ContactPage.php
index 4495e21..949a731 100644
--- a/include/Pages/ContactPage.php
+++ b/include/Pages/ContactPage.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Pages;
+namespace ScummVM\Pages;
require_once('Controller.php');
diff --git a/include/Pages/CreditsPage.php b/include/Pages/CreditsPage.php
index b385466..7a3cd5a 100644
--- a/include/Pages/CreditsPage.php
+++ b/include/Pages/CreditsPage.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Pages;
+namespace ScummVM\Pages;
require_once('Controller.php');
require_once('Models/CreditsModel.php');
diff --git a/include/Pages/DemosPage.php b/include/Pages/DemosPage.php
index 9bd7758..c5e7461 100644
--- a/include/Pages/DemosPage.php
+++ b/include/Pages/DemosPage.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Pages;
+namespace ScummVM\Pages;
require_once('Controller.php');
require_once('Models/GameDemosModel.php');
diff --git a/include/Pages/DocumentationPage.php b/include/Pages/DocumentationPage.php
index 36ea38c..5d76ac3 100644
--- a/include/Pages/DocumentationPage.php
+++ b/include/Pages/DocumentationPage.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Pages;
+namespace ScummVM\Pages;
require_once('Controller.php');
require_once('Models/DocumentationModel.php');
diff --git a/include/Pages/DownloadsPage.php b/include/Pages/DownloadsPage.php
index ad72188..6ea291e 100644
--- a/include/Pages/DownloadsPage.php
+++ b/include/Pages/DownloadsPage.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Pages;
+namespace ScummVM\Pages;
require_once('Controller.php');
require_once('Models/DownloadsModel.php');
diff --git a/include/Pages/ExceptionsPage.php b/include/Pages/ExceptionsPage.php
index 15bdfb0..654298c 100644
--- a/include/Pages/ExceptionsPage.php
+++ b/include/Pages/ExceptionsPage.php
@@ -1,9 +1,7 @@
<?php
-namespace ScummVM\Web\Pages;
+namespace ScummVM\Pages;
-require_once('Controller.php');
-
-class ExceptionsPage extends Controller
+class ExceptionsPage extends \ScummVM\Controller
{
private $_template;
diff --git a/include/Pages/FAQPage.php b/include/Pages/FAQPage.php
index 826074b..6daf2f4 100644
--- a/include/Pages/FAQPage.php
+++ b/include/Pages/FAQPage.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Pages;
+namespace ScummVM\Pages;
require_once('Controller.php');
require_once('Models/FAQModel.php');
diff --git a/include/Pages/FeedsPage.php b/include/Pages/FeedsPage.php
index 26d7649..16c6497 100644
--- a/include/Pages/FeedsPage.php
+++ b/include/Pages/FeedsPage.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Pages;
+namespace ScummVM\Pages;
require_once('Controller.php');
require_once('Models/NewsModel.php');
diff --git a/include/Pages/GamesPage.php b/include/Pages/GamesPage.php
index b2bb1cb..0815148 100644
--- a/include/Pages/GamesPage.php
+++ b/include/Pages/GamesPage.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Pages;
+namespace ScummVM\Pages;
require_once('Controller.php');
require_once('Models/GamesModel.php');
diff --git a/include/Pages/LinksPage.php b/include/Pages/LinksPage.php
index 844a5d2..182035c 100644
--- a/include/Pages/LinksPage.php
+++ b/include/Pages/LinksPage.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Pages;
+namespace ScummVM\Pages;
require_once('Controller.php');
require_once('Models/LinksModel.php');
diff --git a/include/Pages/NewsPage.php b/include/Pages/NewsPage.php
index d48c02f..2667e49 100644
--- a/include/Pages/NewsPage.php
+++ b/include/Pages/NewsPage.php
@@ -1,9 +1,9 @@
<?php
-namespace ScummVM\Web\Pages;
+namespace ScummVM\Pages;
-require_once('Controller.php');
-require_once('Models/NewsModel.php');
-require_once('Models/ScreenshotsModel.php');
+use ScummVM\Controller;
+use ScummVM\Models\NewsModel;
+use ScummVM\Models\ScreenshotsModel;
class NewsPage extends Controller
{
diff --git a/include/Pages/PressPage.php b/include/Pages/PressPage.php
index 8932e7a..b047d0c 100644
--- a/include/Pages/PressPage.php
+++ b/include/Pages/PressPage.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Pages;
+namespace ScummVM\Pages;
require_once('Controller.php');
require_once('Models/ArticleModel.php');
diff --git a/include/Pages/PressSnowberryPage.php b/include/Pages/PressSnowberryPage.php
index 5fe0623..3a04c04 100644
--- a/include/Pages/PressSnowberryPage.php
+++ b/include/Pages/PressSnowberryPage.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Pages;
+namespace ScummVM\Pages;
require_once('Controller.php');
require_once('Models/ArticleModel.php');
diff --git a/include/Pages/ScreenshotsPage.php b/include/Pages/ScreenshotsPage.php
index ce1d3da..33702d0 100644
--- a/include/Pages/ScreenshotsPage.php
+++ b/include/Pages/ScreenshotsPage.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Pages;
+namespace ScummVM\Pages;
require_once('Controller.php');
require_once('Models/ScreenshotsModel.php');
diff --git a/include/Pages/SubprojectsPage.php b/include/Pages/SubprojectsPage.php
index 59bd731..940f918 100644
--- a/include/Pages/SubprojectsPage.php
+++ b/include/Pages/SubprojectsPage.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web\Pages;
+namespace ScummVM\Pages;
require_once('Controller.php');
require_once('Models/SubprojectsModel.php');
diff --git a/include/XMLParser.php b/include/XMLParser.php
index 141d952..79989f8 100644
--- a/include/XMLParser.php
+++ b/include/XMLParser.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web;
+namespace ScummVM;
/**
* An XML parser that will build a multidimensional array (aka a tree) from the
diff --git a/include/config.inc.php b/include/config.inc.php
index c7b3a35..323e21f 100644
--- a/include/config.inc.php
+++ b/include/config.inc.php
@@ -1,5 +1,5 @@
<?php
-namespace ScummVM\Web;
+namespace ScummVM;
/* Current version. */
define('RELEASE', '2.0.0');
diff --git a/index.php b/index.php
index 8bfd7a9..5686f59 100644
--- a/index.php
+++ b/index.php
@@ -1,5 +1,7 @@
<?php
-namespace ScummVM\Web;
+namespace ScummVM;
+
+require_once __DIR__ . '/vendor/autoload.php';
/**
* Multilingual support
@@ -69,8 +71,7 @@ if (!is_writeable(SMARTY_DIR_COMPILE)) {
}
/* Exception handling. */
-require_once('ExceptionHandler.php');
-set_exception_handler(array('ExceptionHandler', 'handleException'));
+set_exception_handler(array('ScummVM\ExceptionHandler', 'handleException'));
/* Page mapping. */
$pages = array(
@@ -84,7 +85,7 @@ $pages = array(
'faq' => 'FAQPage',
'feeds' => 'FeedsPage',
'links' => 'LinksPage',
- 'news' => 'NewsPage',
+ 'news' => 'ScummVM\Pages\NewsPage',
'press' => 'PressPage',
'presssnowberry' => 'PressSnowberryPage',
'screenshots' => 'ScreenshotsPage',
@@ -97,6 +98,5 @@ if (!array_key_exists(($page = isset($_GET['p']) ? $_GET['p'] : null), $pages))
}
/* Switch to the requested page */
-require_once("Pages/{$pages[$page]}.php");
$p = new $pages[$page]();
return $p->index();
diff --git a/package-lock.json b/package-lock.json
index 3155b40..749dce0 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -704,11 +704,13 @@
},
"balanced-match": {
"version": "1.0.0",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
+ "optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -721,15 +723,18 @@
},
"code-point-at": {
"version": "1.1.0",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"concat-map": {
"version": "0.0.1",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"console-control-strings": {
"version": "1.1.0",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"core-util-is": {
"version": "1.0.2",
@@ -832,7 +837,8 @@
},
"inherits": {
"version": "2.0.3",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"ini": {
"version": "1.3.5",
@@ -842,6 +848,7 @@
"is-fullwidth-code-point": {
"version": "1.0.0",
"bundled": true,
+ "optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@@ -854,17 +861,20 @@
"minimatch": {
"version": "3.0.4",
"bundled": true,
+ "optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
},
"minimist": {
"version": "0.0.8",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"minipass": {
"version": "2.2.4",
"bundled": true,
+ "optional": true,
"requires": {
"safe-buffer": "^5.1.1",
"yallist": "^3.0.0"
@@ -881,6 +891,7 @@
"mkdirp": {
"version": "0.5.1",
"bundled": true,
+ "optional": true,
"requires": {
"minimist": "0.0.8"
}
@@ -953,7 +964,8 @@
},
"number-is-nan": {
"version": "1.0.1",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"object-assign": {
"version": "4.1.1",
@@ -963,6 +975,7 @@
"once": {
"version": "1.4.0",
"bundled": true,
+ "optional": true,
"requires": {
"wrappy": "1"
}
@@ -1068,6 +1081,7 @@
"string-width": {
"version": "1.0.2",
"bundled": true,
+ "optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
Commit: 97262c4b2f140b289d92a985dffbb889f89b5e9b
https://github.com/scummvm/scummvm-web/commit/97262c4b2f140b289d92a985dffbb889f89b5e9b
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Convert require statements to psr-4 style use statements
Changed paths:
include/I18N.php
include/Models/ArticleModel.php
include/Models/CompatibilityModel.php
include/Models/CreditsModel.php
include/Models/DocumentationModel.php
include/Models/DownloadsModel.php
include/Models/FAQModel.php
include/Models/GameDemosModel.php
include/Models/GamesModel.php
include/Models/LinksModel.php
include/Models/MenuModel.php
include/Models/SubprojectsModel.php
include/Objects/Article.php
include/Objects/CSection.php
include/Objects/CompatGame.php
include/Objects/DSection.php
include/Objects/DSubSection.php
include/Objects/Document.php
include/Objects/File.php
include/Objects/GameDemo.php
include/Objects/MenuItem.php
include/Objects/Person.php
include/Objects/Project.php
include/Objects/QAEntry.php
include/Objects/QASection.php
include/Objects/Screenshot.php
include/Objects/WebLink.php
include/Pages/CompatibilityPage.php
include/Pages/ContactPage.php
include/Pages/CreditsPage.php
include/Pages/DemosPage.php
include/Pages/DocumentationPage.php
include/Pages/DownloadsPage.php
include/Pages/FAQPage.php
include/Pages/FeedsPage.php
include/Pages/GamesPage.php
include/Pages/LinksPage.php
include/Pages/PressPage.php
include/Pages/PressSnowberryPage.php
include/Pages/ScreenshotsPage.php
include/Pages/SubprojectsPage.php
index.php
diff --git a/include/I18N.php b/include/I18N.php
index e38bdcc..f31023f 100644
--- a/include/I18N.php
+++ b/include/I18N.php
@@ -1,10 +1,10 @@
<?php
namespace ScummVM;
-require_once('vendor/ezyang/htmlpurifier/library/HTMLPurifier.auto.php');
-set_include_path('include');
-require_once('Objects/News.php');
-require_once('Models/NewsModel.php');
+use HTMLPurifier;
+use ScummVM\Objects\News;
+use ScummVM\Models\NewsModel;
+
define('DIR_NEWS', 'data/news');
class I18N
diff --git a/include/Models/ArticleModel.php b/include/Models/ArticleModel.php
index a4b9681..9226047 100644
--- a/include/Models/ArticleModel.php
+++ b/include/Models/ArticleModel.php
@@ -1,8 +1,9 @@
<?php
namespace ScummVM\Models;
-require_once('Models/BasicModel.php');
-require_once('Objects/Article.php');
+use ScummVM\Objects\Article;
+use ScummVM\XMLParser;
+
/**
* The ArticleModel class will generate Article objects.
*/
diff --git a/include/Models/CompatibilityModel.php b/include/Models/CompatibilityModel.php
index 5f8e7a6..a18ecf0 100644
--- a/include/Models/CompatibilityModel.php
+++ b/include/Models/CompatibilityModel.php
@@ -1,9 +1,9 @@
<?php
namespace ScummVM\Models;
-require_once('Models/BasicModel.php');
-require_once('Objects/CompatGame.php');
-require_once('XMLParser.php');
+use ScummVM\Objects\CompatGame;
+use ScummVM\XMLParser;
+
/**
* The CompatibilityModel class will generate CompatGame objects.
*/
diff --git a/include/Models/CreditsModel.php b/include/Models/CreditsModel.php
index 735c4af..7620fc3 100644
--- a/include/Models/CreditsModel.php
+++ b/include/Models/CreditsModel.php
@@ -1,9 +1,9 @@
<?php
namespace ScummVM\Models;
-require_once('Models/BasicModel.php');
-require_once('Objects/CSection.php');
-require_once('XMLParser.php');
+use ScummVM\Objects\CSection;
+use ScummVM\XMLParser;
+
/**
* The CreditsModel will generate CSection objects.
*/
diff --git a/include/Models/DocumentationModel.php b/include/Models/DocumentationModel.php
index 23c61e3..d7030a4 100644
--- a/include/Models/DocumentationModel.php
+++ b/include/Models/DocumentationModel.php
@@ -1,8 +1,9 @@
<?php
namespace ScummVM\Models;
-require_once('Models/BasicModel.php');
-require_once('Objects/Document.php');
+use ScummVM\Objects\Document;
+use ScummVM\XMLParser;
+
/**
* The DocumentationModel class will generate Document objects.
*/
diff --git a/include/Models/DownloadsModel.php b/include/Models/DownloadsModel.php
index cf6db7b..b0f2ae2 100644
--- a/include/Models/DownloadsModel.php
+++ b/include/Models/DownloadsModel.php
@@ -1,9 +1,9 @@
<?php
namespace ScummVM\Models;
-require_once('Models/BasicModel.php');
-require_once('Objects/DSection.php');
-require_once('XMLParser.php');
+use ScummVM\Objects\DSection;
+use ScummVM\XMLParser;
+
/**
* The DownloadsModel will produce DSection objects.
*/
diff --git a/include/Models/FAQModel.php b/include/Models/FAQModel.php
index 5adabac..673481a 100644
--- a/include/Models/FAQModel.php
+++ b/include/Models/FAQModel.php
@@ -1,10 +1,11 @@
<?php
namespace ScummVM\Models;
-require_once('Models/BasicModel.php');
-require_once('Objects/QAEntry.php');
-require_once('Objects/QASection.php');
-require_once('XMLParser.php');
+use ScummVM\Objects\Article;
+use ScummVM\Objects\QAEntry;
+use ScummVM\Objects\QASection;
+use ScummVM\XMLParser;
+
/**
* The FAQModel class reads the docbook formated XML-file 'faq.xml' and does
* some changes to make it easier to parse. Returns an array with
diff --git a/include/Models/GameDemosModel.php b/include/Models/GameDemosModel.php
index 89ababd..1931bc3 100644
--- a/include/Models/GameDemosModel.php
+++ b/include/Models/GameDemosModel.php
@@ -1,9 +1,9 @@
<?php
namespace ScummVM\Models;
-require_once('Models/BasicModel.php');
-require_once('Objects/GameDemo.php');
-require_once('XMLParser.php');
+use ScummVM\Objects\GameDemo;
+use ScummVM\XMLParser;
+
/**
* The GameDemosModel class will generate GameDemo objects.
*/
diff --git a/include/Models/GamesModel.php b/include/Models/GamesModel.php
index 19070ad..b0e9ecf 100644
--- a/include/Models/GamesModel.php
+++ b/include/Models/GamesModel.php
@@ -1,9 +1,9 @@
<?php
namespace ScummVM\Models;
-require_once('Models/BasicModel.php');
-require_once('Objects/DSection.php');
-require_once('XMLParser.php');
+use ScummVM\Objects\DSection;
+use ScummVM\XMLParser;
+
/**
* The GamesModel will produce DSection objects.
*/
diff --git a/include/Models/LinksModel.php b/include/Models/LinksModel.php
index c7feca5..ba7d7e8 100644
--- a/include/Models/LinksModel.php
+++ b/include/Models/LinksModel.php
@@ -1,9 +1,9 @@
<?php
namespace ScummVM\Models;
-require_once('Models/BasicModel.php');
-require_once('Objects/WebLink.php');
-require_once('XMLParser.php');
+use ScummVM\Objects\WebLink;
+use ScummVM\XMLParser;
+
/**
* The LinksModel class will generate WebLink objects.
* LinkGroup-objects representing a group of external links on the website.
diff --git a/include/Models/MenuModel.php b/include/Models/MenuModel.php
index 6da6790..54c893b 100644
--- a/include/Models/MenuModel.php
+++ b/include/Models/MenuModel.php
@@ -2,7 +2,6 @@
namespace ScummVM\Models;
use ScummVM\XMLParser;
-use ScummVM\Models\BasicModel;
use ScummVM\Objects\MenuItem;
/**
diff --git a/include/Models/SubprojectsModel.php b/include/Models/SubprojectsModel.php
index 58ae359..c8c68b9 100644
--- a/include/Models/SubprojectsModel.php
+++ b/include/Models/SubprojectsModel.php
@@ -1,9 +1,10 @@
<?php
namespace ScummVM\Models;
-require_once('Models/BasicModel.php');
-require_once('Objects/File.php');
-require_once('Objects/Project.php');
+use ScummVM\Objects\Project;
+use ScummVM\Objects\File;
+use ScummVM\XMLParser;
+
/**
* The SubprojectsModel will generate Project objects.
*/
diff --git a/include/Objects/Article.php b/include/Objects/Article.php
index 86ecf81..eddec3e 100644
--- a/include/Objects/Article.php
+++ b/include/Objects/Article.php
@@ -1,7 +1,6 @@
<?php
namespace ScummVM\Objects;
-require_once('Objects/BasicObject.php');
/**
* The article class represents a link on the website to an article covering
* ScummVM in some way.
diff --git a/include/Objects/CSection.php b/include/Objects/CSection.php
index 183f097..00f4fdc 100644
--- a/include/Objects/CSection.php
+++ b/include/Objects/CSection.php
@@ -1,8 +1,6 @@
<?php
namespace ScummVM\Objects;
-require_once('Objects/BasicObject.php');
-require_once('Objects/Person.php');
/**
* The Section class represens a section (or a subsection) on the credits page
* on the website.
diff --git a/include/Objects/CompatGame.php b/include/Objects/CompatGame.php
index 34c99e9..daf46ed 100644
--- a/include/Objects/CompatGame.php
+++ b/include/Objects/CompatGame.php
@@ -1,7 +1,6 @@
<?php
namespace ScummVM\Objects;
-require_once('Objects/BasicObject.php');
/**
* The CompatGame class represents a game on the compatibility charts on the
* website.
diff --git a/include/Objects/DSection.php b/include/Objects/DSection.php
index 7489c35..4294d62 100644
--- a/include/Objects/DSection.php
+++ b/include/Objects/DSection.php
@@ -1,8 +1,6 @@
<?php
namespace ScummVM\Objects;
-require_once('Objects/BasicObject.php');
-require_once('Objects/DSubSection.php');
/**
* The DSection object represents a section on the downloads page.
*/
diff --git a/include/Objects/DSubSection.php b/include/Objects/DSubSection.php
index f673d15..ab4dad0 100644
--- a/include/Objects/DSubSection.php
+++ b/include/Objects/DSubSection.php
@@ -1,9 +1,6 @@
<?php
namespace ScummVM\Objects;
-require_once('Objects/BasicObject.php');
-require_once('Objects/File.php');
-require_once('Objects/WebLink.php');
/**
* The DSubSection object represents a subsection on the downloads page.
*/
diff --git a/include/Objects/Document.php b/include/Objects/Document.php
index a20bfe2..49c0d25 100644
--- a/include/Objects/Document.php
+++ b/include/Objects/Document.php
@@ -1,7 +1,6 @@
<?php
namespace ScummVM\Objects;
-require_once('Objects/BasicObject.php');
/**
* The Document class represents a Document on the website.
*/
diff --git a/include/Objects/File.php b/include/Objects/File.php
index 5e903c9..9f02744 100644
--- a/include/Objects/File.php
+++ b/include/Objects/File.php
@@ -1,7 +1,6 @@
<?php
namespace ScummVM\Objects;
-require_once('Objects/BasicObject.php');
/**
* The File object represents a file on the website.
*/
diff --git a/include/Objects/GameDemo.php b/include/Objects/GameDemo.php
index 556677b..f0daf9d 100644
--- a/include/Objects/GameDemo.php
+++ b/include/Objects/GameDemo.php
@@ -1,7 +1,6 @@
<?php
namespace ScummVM\Objects;
-require_once('Objects/BasicObject.php');
/**
* The GameDemo class represents a game demo item on the website.
*/
diff --git a/include/Objects/MenuItem.php b/include/Objects/MenuItem.php
index c575677..0efc92b 100644
--- a/include/Objects/MenuItem.php
+++ b/include/Objects/MenuItem.php
@@ -1,7 +1,6 @@
<?php
namespace ScummVM\Objects;
-require_once('Objects/BasicObject.php');
/**
* The menu class represents a sidebar menu group on the website.
*/
diff --git a/include/Objects/Person.php b/include/Objects/Person.php
index 5e999df..8e6e6db 100644
--- a/include/Objects/Person.php
+++ b/include/Objects/Person.php
@@ -1,7 +1,6 @@
<?php
namespace ScummVM\Objects;
-require_once('Objects/BasicObject.php');
/**
* The Person class represents a person entry on the credits page on the
* website.
diff --git a/include/Objects/Project.php b/include/Objects/Project.php
index 569c3b3..a937597 100644
--- a/include/Objects/Project.php
+++ b/include/Objects/Project.php
@@ -1,7 +1,6 @@
<?php
namespace ScummVM\Objects;
-require_once('Objects/BasicObject.php');
/**
* The Project class represents a subproject on the website.
*/
diff --git a/include/Objects/QAEntry.php b/include/Objects/QAEntry.php
index 138b8a7..8868cc5 100644
--- a/include/Objects/QAEntry.php
+++ b/include/Objects/QAEntry.php
@@ -1,7 +1,6 @@
<?php
namespace ScummVM\Objects;
-require_once('Objects/BasicObject.php');
/**
* The QAEntry class represents a question-answer pair on the website
* F.A.Q. page.
diff --git a/include/Objects/QASection.php b/include/Objects/QASection.php
index 59c03cd..9148e76 100644
--- a/include/Objects/QASection.php
+++ b/include/Objects/QASection.php
@@ -1,8 +1,6 @@
<?php
namespace ScummVM\Objects;
-require_once('Objects/BasicObject.php');
-require_once('Objects/QAEntry.php');
/**
* The QASection class represents a section with questions and answers on the
* website F.A.Q. page.
diff --git a/include/Objects/Screenshot.php b/include/Objects/Screenshot.php
index 13cd7fd..4d527ae 100644
--- a/include/Objects/Screenshot.php
+++ b/include/Objects/Screenshot.php
@@ -1,7 +1,6 @@
<?php
namespace ScummVM\Objects;
-require_once('Objects/BasicObject.php');
/**
* The Screenshot object represents all screenshots for one game.
*/
diff --git a/include/Objects/WebLink.php b/include/Objects/WebLink.php
index 1a1d8ee..4474c63 100644
--- a/include/Objects/WebLink.php
+++ b/include/Objects/WebLink.php
@@ -1,7 +1,6 @@
<?php
namespace ScummVM\Objects;
-require_once('Objects/BasicObject.php');
/**
* The WebLink class represents a link item on the website.
*/
diff --git a/include/Pages/CompatibilityPage.php b/include/Pages/CompatibilityPage.php
index f068174..780f48b 100644
--- a/include/Pages/CompatibilityPage.php
+++ b/include/Pages/CompatibilityPage.php
@@ -1,8 +1,9 @@
<?php
namespace ScummVM\Pages;
-require_once('Controller.php');
-require_once('Models/CompatibilityModel.php');
+use ScummVM\Controller;
+use ScummVM\Models\CompatabilityModel;
+
/**
* The Compatibility page gets all the data from the CompatibilityModel and
* either displays the full list of games, or specific details about one
diff --git a/include/Pages/ContactPage.php b/include/Pages/ContactPage.php
index 949a731..3b44ea6 100644
--- a/include/Pages/ContactPage.php
+++ b/include/Pages/ContactPage.php
@@ -1,7 +1,7 @@
<?php
namespace ScummVM\Pages;
-require_once('Controller.php');
+use ScummVM\Controller;
class ContactPage extends Controller
{
diff --git a/include/Pages/CreditsPage.php b/include/Pages/CreditsPage.php
index 7a3cd5a..5f4d4c8 100644
--- a/include/Pages/CreditsPage.php
+++ b/include/Pages/CreditsPage.php
@@ -1,8 +1,8 @@
<?php
namespace ScummVM\Pages;
-require_once('Controller.php');
-require_once('Models/CreditsModel.php');
+use ScummVM\Controller;
+use ScummVM\Models\CreditsModel;
class CreditsPage extends Controller
{
diff --git a/include/Pages/DemosPage.php b/include/Pages/DemosPage.php
index c5e7461..d72cded 100644
--- a/include/Pages/DemosPage.php
+++ b/include/Pages/DemosPage.php
@@ -1,8 +1,8 @@
<?php
namespace ScummVM\Pages;
-require_once('Controller.php');
-require_once('Models/GameDemosModel.php');
+use ScummVM\Controller;
+use ScummVM\Models\GameDemosModel;
class DemosPage extends Controller
{
diff --git a/include/Pages/DocumentationPage.php b/include/Pages/DocumentationPage.php
index 5d76ac3..e9fb38a 100644
--- a/include/Pages/DocumentationPage.php
+++ b/include/Pages/DocumentationPage.php
@@ -1,8 +1,8 @@
<?php
namespace ScummVM\Pages;
-require_once('Controller.php');
-require_once('Models/DocumentationModel.php');
+use ScummVM\Controller;
+use ScummVM\Models\DocumentationModel;
class DocumentationPage extends Controller
{
diff --git a/include/Pages/DownloadsPage.php b/include/Pages/DownloadsPage.php
index 6ea291e..38c7f4d 100644
--- a/include/Pages/DownloadsPage.php
+++ b/include/Pages/DownloadsPage.php
@@ -1,8 +1,8 @@
<?php
namespace ScummVM\Pages;
-require_once('Controller.php');
-require_once('Models/DownloadsModel.php');
+use ScummVM\Controller;
+use ScummVM\Models\DownloadsModel;
class DownloadsPage extends Controller
{
diff --git a/include/Pages/FAQPage.php b/include/Pages/FAQPage.php
index 6daf2f4..b996623 100644
--- a/include/Pages/FAQPage.php
+++ b/include/Pages/FAQPage.php
@@ -1,8 +1,8 @@
<?php
namespace ScummVM\Pages;
-require_once('Controller.php');
-require_once('Models/FAQModel.php');
+use ScummVM\Controller;
+use ScummVM\Models\FAQModel;
class FAQPage extends Controller
{
diff --git a/include/Pages/FeedsPage.php b/include/Pages/FeedsPage.php
index 16c6497..ef3733a 100644
--- a/include/Pages/FeedsPage.php
+++ b/include/Pages/FeedsPage.php
@@ -1,8 +1,8 @@
<?php
namespace ScummVM\Pages;
-require_once('Controller.php');
-require_once('Models/NewsModel.php');
+use ScummVM\Controller;
+use ScummVM\Models\NewsModel;
class FeedsPage extends Controller
{
diff --git a/include/Pages/GamesPage.php b/include/Pages/GamesPage.php
index 0815148..d6181c2 100644
--- a/include/Pages/GamesPage.php
+++ b/include/Pages/GamesPage.php
@@ -1,8 +1,8 @@
<?php
namespace ScummVM\Pages;
-require_once('Controller.php');
-require_once('Models/GamesModel.php');
+use ScummVM\Controller;
+use ScummVM\Models\GamesModel;
class GamesPage extends Controller
{
diff --git a/include/Pages/LinksPage.php b/include/Pages/LinksPage.php
index 182035c..219b39a 100644
--- a/include/Pages/LinksPage.php
+++ b/include/Pages/LinksPage.php
@@ -1,8 +1,8 @@
<?php
namespace ScummVM\Pages;
-require_once('Controller.php');
-require_once('Models/LinksModel.php');
+use ScummVM\Controller;
+use ScummVM\Models\LinksModel;
class LinksPage extends Controller
{
diff --git a/include/Pages/PressPage.php b/include/Pages/PressPage.php
index b047d0c..5b2371b 100644
--- a/include/Pages/PressPage.php
+++ b/include/Pages/PressPage.php
@@ -1,8 +1,8 @@
<?php
namespace ScummVM\Pages;
-require_once('Controller.php');
-require_once('Models/ArticleModel.php');
+use ScummVM\Controller;
+use ScummVM\Models\ArticleModel;
class PressPage extends Controller
{
diff --git a/include/Pages/PressSnowberryPage.php b/include/Pages/PressSnowberryPage.php
index 3a04c04..a2e7d06 100644
--- a/include/Pages/PressSnowberryPage.php
+++ b/include/Pages/PressSnowberryPage.php
@@ -1,8 +1,8 @@
<?php
namespace ScummVM\Pages;
-require_once('Controller.php');
-require_once('Models/ArticleModel.php');
+use ScummVM\Controller;
+use ScummVM\Models\ArticleModel;
class PressSnowberryPage extends Controller
{
diff --git a/include/Pages/ScreenshotsPage.php b/include/Pages/ScreenshotsPage.php
index 33702d0..68fb987 100644
--- a/include/Pages/ScreenshotsPage.php
+++ b/include/Pages/ScreenshotsPage.php
@@ -1,8 +1,8 @@
<?php
namespace ScummVM\Pages;
-require_once('Controller.php');
-require_once('Models/ScreenshotsModel.php');
+use ScummVM\Controller;
+use ScummVM\Models\ScreenshotModel;
class ScreenshotsPage extends Controller
{
diff --git a/include/Pages/SubprojectsPage.php b/include/Pages/SubprojectsPage.php
index 940f918..9c2d49c 100644
--- a/include/Pages/SubprojectsPage.php
+++ b/include/Pages/SubprojectsPage.php
@@ -1,8 +1,8 @@
<?php
namespace ScummVM\Pages;
-require_once('Controller.php');
-require_once('Models/SubprojectsModel.php');
+use ScummVM\Controller;
+use ScummVM\Models\SubprojectsModel;
class SubprojectsPage extends Controller
{
diff --git a/index.php b/index.php
index 5686f59..d46afeb 100644
--- a/index.php
+++ b/index.php
@@ -75,21 +75,21 @@ set_exception_handler(array('ScummVM\ExceptionHandler', 'handleException'));
/* Page mapping. */
$pages = array(
- 'compatibility' => 'CompatibilityPage',
- 'contact' => 'ContactPage',
- 'credits' => 'CreditsPage',
- 'demos' => 'DemosPage',
- 'documentation' => 'DocumentationPage',
- 'downloads' => 'DownloadsPage',
- 'games' => 'GamesPage',
- 'faq' => 'FAQPage',
- 'feeds' => 'FeedsPage',
- 'links' => 'LinksPage',
+ 'compatibility' => 'ScummVM\Pages\CompatibilityPage',
+ 'contact' => 'ScummVM\Pages\ContactPage',
+ 'credits' => 'ScummVM\Pages\CreditsPage',
+ 'demos' => 'ScummVM\Pages\DemosPage',
+ 'documentation' => 'ScummVM\Pages\DocumentationPage',
+ 'downloads' => 'ScummVM\Pages\DownloadsPage',
+ 'games' => 'ScummVM\Pages\GamesPage',
+ 'faq' => 'ScummVM\Pages\FAQPage',
+ 'feeds' => 'ScummVM\Pages\FeedsPage',
+ 'links' => 'ScummVM\Pages\LinksPage',
'news' => 'ScummVM\Pages\NewsPage',
- 'press' => 'PressPage',
- 'presssnowberry' => 'PressSnowberryPage',
- 'screenshots' => 'ScreenshotsPage',
- 'subprojects' => 'SubprojectsPage',
+ 'press' => 'ScummVM\Pages\PressPage',
+ 'presssnowberry' => 'ScummVM\Pages\PressSnowberryPage',
+ 'screenshots' => 'ScummVM\Pages\ScreenshotsPage',
+ 'subprojects' => 'ScummVM\Pages\SubprojectsPage',
);
/* Default to the news page. */
Commit: 1e7815ec2e3cc67c925d313dc9fabfc3840a7bbb
https://github.com/scummvm/scummvm-web/commit/1e7815ec2e3cc67c925d313dc9fabfc3840a7bbb
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Fix namespace reference to ErrorException
Changed paths:
include/I18N.php
include/Models/CompatibilityModel.php
include/Models/FAQModel.php
include/Models/NewsModel.php
include/Models/ScreenshotsModel.php
include/Objects/Screenshot.php
include/XMLParser.php
diff --git a/include/I18N.php b/include/I18N.php
index f31023f..2d0719a 100644
--- a/include/I18N.php
+++ b/include/I18N.php
@@ -79,7 +79,7 @@ class I18N
}
if (!($files = scandir($dir))) {
- throw new ErrorException(self::NO_FILES);
+ throw new \ErrorException(self::NO_FILES);
}
$news = new stdClass();
foreach ($files as $filename) {
diff --git a/include/Models/CompatibilityModel.php b/include/Models/CompatibilityModel.php
index a18ecf0..c23531a 100644
--- a/include/Models/CompatibilityModel.php
+++ b/include/Models/CompatibilityModel.php
@@ -18,11 +18,11 @@ abstract class CompatibilityModel extends BasicModel
public static function getAllData($version)
{
if (!is_string($version)) {
- throw new ErrorException(self::NO_VERSION);
+ throw new \ErrorException(self::NO_VERSION);
}
$fname = DIR_COMPAT . "/compat-{$version}.xml";
if (!file_exists($fname)) {
- throw new ErrorException(self::NO_FILES);
+ throw new \ErrorException(self::NO_FILES);
}
$parser = new XMLParser();
$a = $parser->parseByFilename($fname);
@@ -73,7 +73,7 @@ abstract class CompatibilityModel extends BasicModel
public static function getAllVersions()
{
if (!($files = scandir(DIR_COMPAT))) {
- throw new ErrorException(self::NO_FILES);
+ throw new \ErrorException(self::NO_FILES);
}
$dates = array();
foreach ($files as $file) {
@@ -94,10 +94,10 @@ abstract class CompatibilityModel extends BasicModel
public static function getGameData($version, $target)
{
if (!is_string($version) || !is_string($target)) {
- throw new ErrorException(self::NO_VERSION_TARGET);
+ throw new \ErrorException(self::NO_VERSION_TARGET);
}
if (!($all_games = self::getAllData($version))) {
- throw new ErrorException(self::NOT_FOUND);
+ throw new \ErrorException(self::NOT_FOUND);
}
$g = null;
foreach ($all_games as $company => $games) {
@@ -112,7 +112,7 @@ abstract class CompatibilityModel extends BasicModel
}
}
if (is_null($g)) {
- throw new ErrorException(self::NOT_FOUND);
+ throw new \ErrorException(self::NOT_FOUND);
}
return $g;
diff --git a/include/Models/FAQModel.php b/include/Models/FAQModel.php
index 673481a..84c7d41 100644
--- a/include/Models/FAQModel.php
+++ b/include/Models/FAQModel.php
@@ -27,7 +27,7 @@ abstract class FAQModel extends BasicModel
if (is_file($localized)) {
if (!is_readable($localized)) {
$file = "\n\nFilename: " . basename($localized) . "\n";
- throw new ErrorException(self::FILE_NOT_FOUND . $file);
+ throw new \ErrorException(self::FILE_NOT_FOUND . $file);
} else {
return $localized;
}
@@ -47,7 +47,7 @@ abstract class FAQModel extends BasicModel
public static function getFAQ()
{
if (!($data = @file_get_contents(self::getFilename()))) {
- throw new ErrorException(self::ERROR_READING_FILE);
+ throw new \ErrorException(self::ERROR_READING_FILE);
}
/**
* Let's replace some of the docbook tags and wrap some HTML-entities
diff --git a/include/Models/NewsModel.php b/include/Models/NewsModel.php
index 1ccdcc6..5902304 100644
--- a/include/Models/NewsModel.php
+++ b/include/Models/NewsModel.php
@@ -16,7 +16,7 @@ abstract class NewsModel extends BasicModel
public static function getListOfNewsFilenames()
{
if (!($files = scandir(DIR_NEWS))) {
- throw new ErrorException(self::NO_FILES);
+ throw new \ErrorException(self::NO_FILES);
}
$filenames = array();
foreach ($files as $file) {
@@ -33,7 +33,7 @@ abstract class NewsModel extends BasicModel
public static function getAllNews($processContent = false)
{
if (!($files = scandir(DIR_NEWS))) {
- throw new ErrorException(self::NO_FILES);
+ throw new \ErrorException(self::NO_FILES);
}
global $lang;
$news = array();
@@ -59,7 +59,7 @@ abstract class NewsModel extends BasicModel
return NewsModel::getAllNews($processContent);
} else {
if (!($newslist = NewsModel::getListOfNewsFilenames())) {
- throw new ErrorException(self::NO_FILES);
+ throw new \ErrorException(self::NO_FILES);
}
rsort($newslist, SORT_STRING);
$newslist = array_slice($newslist, 0, $num);
@@ -75,14 +75,14 @@ abstract class NewsModel extends BasicModel
public static function getOneByFilename($filename, $processContent = false)
{
if (is_null($filename) || !preg_match('/^\d{8,12}[a-z]?$/', $filename)) {
- throw new ErrorException(self::INVALID_DATE);
+ throw new \ErrorException(self::INVALID_DATE);
}
global $lang;
if (!is_file(($fname = DIR_NEWS . "/$lang/{$filename}.json"))
|| !is_readable($fname) || !($data = @file_get_contents($fname))) {
if (!is_file(($fname = DIR_NEWS . "/{$filename}.json"))
|| !is_readable($fname) || !($data = @file_get_contents($fname))) {
- throw new ErrorException(self::FILE_NOT_FOUND);
+ throw new \ErrorException(self::FILE_NOT_FOUND);
}
}
return new News(json_decode($data), $fname, $processContent);
diff --git a/include/Models/ScreenshotsModel.php b/include/Models/ScreenshotsModel.php
index 6d3b896..3f98e4a 100644
--- a/include/Models/ScreenshotsModel.php
+++ b/include/Models/ScreenshotsModel.php
@@ -46,7 +46,7 @@ abstract class ScreenshotsModel extends BasicModel
return $shots;
}
}
- throw new ErrorException(self::INVALID_CATEGORY);
+ throw new \ErrorException(self::INVALID_CATEGORY);
}
/* Get screenshots for a specific target. */
@@ -60,7 +60,7 @@ abstract class ScreenshotsModel extends BasicModel
}
}
}
- throw new ErrorException(self::INVALID_TARGET);
+ throw new \ErrorException(self::INVALID_TARGET);
}
/* Get a random screenshot (an object and not a filename) .*/
diff --git a/include/Objects/Screenshot.php b/include/Objects/Screenshot.php
index 4d527ae..5ffb060 100644
--- a/include/Objects/Screenshot.php
+++ b/include/Objects/Screenshot.php
@@ -25,7 +25,7 @@ class Screenshot extends BasicObject
if (isset($value['range'])) {
$attr = $value['range']['@attributes'];
if (!isset($attr['from']) || !isset($attr['to']) || !isset($attr['format']) || !strstr($value['file'], '#n#')) {
- throw new ErrorException('Invalid range format for ' . $value['file']);
+ throw new \ErrorException('Invalid range format for ' . $value['file']);
}
$pat = str_replace("#n#", $attr['format'], $value['file']);
for ($num = $attr['from']; $num <= $attr['to']; $num++) {
diff --git a/include/XMLParser.php b/include/XMLParser.php
index 79989f8..8f8be05 100644
--- a/include/XMLParser.php
+++ b/include/XMLParser.php
@@ -49,7 +49,7 @@ class XMLParser
* @return bool|array
* @access public
* @since 1.0
- * @throws ErrorException
+ * @throws \ErrorException
*/
public function parseByFilename($filename)
{
@@ -64,7 +64,7 @@ class XMLParser
if (is_file($localized)) {
if (!is_readable($localized)) {
$file = "\n\nFilename: " . basename($localized) . "\n";
- throw new ErrorException(self::FILE_NOT_FOUND . $file);
+ throw new \ErrorException(self::FILE_NOT_FOUND . $file);
} else {
$filename = $localized;
}
@@ -74,19 +74,19 @@ class XMLParser
$file = "\n\nFilename: " . basename($filename) . "\n";
/* If we can't read the file there is nothing we can do. */
if (!is_file($filename) || !is_readable($filename)) {
- throw new ErrorException(self::FILE_NOT_FOUND . $file);
+ throw new \ErrorException(self::FILE_NOT_FOUND . $file);
}
/* Read the file contents. */
if (!($xml = @file_get_contents($filename))) {
- throw new ErrorException(self::FILE_NOT_READABLE . $file);
+ throw new \ErrorException(self::FILE_NOT_READABLE . $file);
}
/* Parse the XML. */
try {
return $this->parseByData($xml);
- } catch (ErrorException $e) {
+ } catch (\ErrorException $e) {
$msg = "{$e->getMessage()}{$file}";
- throw new ErrorException($msg);
+ throw new \ErrorException($msg);
}
}
@@ -100,12 +100,12 @@ class XMLParser
* @return bool|array
* @access public
* @since 1.0
- * @throws ErrorException
+ * @throws \ErrorException
*/
public function parseByData($xml)
{
if (!is_string($xml) || strlen($xml) == 0) {
- throw new ErrorException(self::DATA_NOT_XML);
+ throw new \ErrorException(self::DATA_NOT_XML);
}
/* Create a parser and set the options */
$parser = xml_parser_create_ns();
@@ -128,7 +128,7 @@ class XMLParser
$error .= "Line: " . xml_get_current_line_number($parser) . ", character: " . xml_get_current_column_number($parser) . "\n";
$error .= "Error message: " . xml_error_string(xml_get_error_code($parser)) . "\n";
xml_parser_free($parser);
- throw new ErrorException(self::PARSER_ERROR . $error);
+ throw new \ErrorException(self::PARSER_ERROR . $error);
}
xml_parser_free($parser);
/**
Commit: df825b7878eafeaf50aa13c1eb937d66bc529793
https://github.com/scummvm/scummvm-web/commit/df825b7878eafeaf50aa13c1eb937d66bc529793
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Fix phpstan static errors
Changed paths:
include/Controller.php
include/I18N.php
include/Models/FAQModel.php
include/Models/SubprojectsModel.php
include/Objects/DSection.php
include/Objects/DSubSection.php
include/Pages/CompatibilityPage.php
include/Pages/ContactPage.php
include/Pages/DemosPage.php
include/Pages/DocumentationPage.php
include/Pages/DownloadsPage.php
include/Pages/ExceptionsPage.php
include/Pages/FAQPage.php
include/Pages/GamesPage.php
include/Pages/LinksPage.php
include/Pages/NewsPage.php
include/Pages/PressPage.php
include/Pages/PressSnowberryPage.php
include/Pages/ScreenshotsPage.php
include/Pages/SubprojectsPage.php
diff --git a/include/Controller.php b/include/Controller.php
index 98284d4..b01992c 100644
--- a/include/Controller.php
+++ b/include/Controller.php
@@ -12,7 +12,7 @@ use ScummVM\Models\MenuModel;
class Controller
{
private $_smarty;
- private $_template;
+ protected $_template;
private $_title;
private $_css_files;
private $_js_files;
diff --git a/include/I18N.php b/include/I18N.php
index 2d0719a..3c4b173 100644
--- a/include/I18N.php
+++ b/include/I18N.php
@@ -1,7 +1,6 @@
<?php
namespace ScummVM;
-use HTMLPurifier;
use ScummVM\Objects\News;
use ScummVM\Models\NewsModel;
@@ -9,11 +8,14 @@ define('DIR_NEWS', 'data/news');
class I18N
{
+ private $_purifier;
+
+ const NO_FILES = 'No I18N Files Found';
public function __construct()
{
- $config = HTMLPurifier_Config::createDefault();
- $this->_purifier = new HTMLPurifier($config);
+ $config = \HTMLPurifier_Config::createDefault();
+ $this->_purifier = new \HTMLPurifier($config);
$langs = ['en', 'it', 'fr', 'ru', 'de'];
foreach ($langs as $key => $value) {
@@ -57,7 +59,7 @@ class I18N
} else {
// Update the base english i18n file
echo("Converting individual JSON files to I18N base file\n");
- $newsJson = new stdClass();
+ $newsJson = new \stdClass();
$news = $this->getAllNews($lang);
foreach ($news as $key => $value) {
$newsJson->$key = array(
@@ -81,7 +83,7 @@ class I18N
if (!($files = scandir($dir))) {
throw new \ErrorException(self::NO_FILES);
}
- $news = new stdClass();
+ $news = new \stdClass();
foreach ($files as $filename) {
if (substr($filename, -5) != '.json') {
continue;
diff --git a/include/Models/FAQModel.php b/include/Models/FAQModel.php
index 84c7d41..e70c830 100644
--- a/include/Models/FAQModel.php
+++ b/include/Models/FAQModel.php
@@ -15,6 +15,7 @@ use ScummVM\XMLParser;
abstract class FAQModel extends BasicModel
{
const ERROR_READING_FILE = 'Could not load the frequently asked questions.';
+ const FILE_NOT_FOUND = 'The requested FAQ file doesn\'t exist.';
/* Get the full path and filename for the F.A.Q. XML-file. */
public static function getFilename()
diff --git a/include/Models/SubprojectsModel.php b/include/Models/SubprojectsModel.php
index c8c68b9..90e0fde 100644
--- a/include/Models/SubprojectsModel.php
+++ b/include/Models/SubprojectsModel.php
@@ -3,6 +3,7 @@ namespace ScummVM\Models;
use ScummVM\Objects\Project;
use ScummVM\Objects\File;
+use ScummVM\Objects\BasicObject;
use ScummVM\XMLParser;
/**
diff --git a/include/Objects/DSection.php b/include/Objects/DSection.php
index 4294d62..292c89a 100644
--- a/include/Objects/DSection.php
+++ b/include/Objects/DSection.php
@@ -9,6 +9,7 @@ class DSection extends BasicObject
private $_title;
private $_anchor;
private $_baseurl;
+ private $_baseturl;
private $_subsections;
/* DSection object constructor. */
diff --git a/include/Objects/DSubSection.php b/include/Objects/DSubSection.php
index ab4dad0..7edaf8b 100644
--- a/include/Objects/DSubSection.php
+++ b/include/Objects/DSubSection.php
@@ -12,6 +12,7 @@ class DSubSection extends BasicObject
private $_footer;
private $_files;
private $_links;
+ private $_items;
/* DSubSection constructor. */
public function __construct($data, $baseurl, $baseturl)
diff --git a/include/Pages/CompatibilityPage.php b/include/Pages/CompatibilityPage.php
index 780f48b..46f6af3 100644
--- a/include/Pages/CompatibilityPage.php
+++ b/include/Pages/CompatibilityPage.php
@@ -2,7 +2,7 @@
namespace ScummVM\Pages;
use ScummVM\Controller;
-use ScummVM\Models\CompatabilityModel;
+use ScummVM\Models\CompatibilityModel;
/**
* The Compatibility page gets all the data from the CompatibilityModel and
@@ -11,7 +11,7 @@ use ScummVM\Models\CompatabilityModel;
*/
class CompatibilityPage extends Controller
{
- private $_template;
+ protected $_template;
private $_template_details;
private $_supportLevelDesc;
private $_supportLevelClass;
diff --git a/include/Pages/ContactPage.php b/include/Pages/ContactPage.php
index 3b44ea6..5f18f4d 100644
--- a/include/Pages/ContactPage.php
+++ b/include/Pages/ContactPage.php
@@ -5,7 +5,7 @@ use ScummVM\Controller;
class ContactPage extends Controller
{
- private $_template;
+ protected $_template;
/* Constructor. */
public function __construct()
diff --git a/include/Pages/DemosPage.php b/include/Pages/DemosPage.php
index d72cded..9ec5a83 100644
--- a/include/Pages/DemosPage.php
+++ b/include/Pages/DemosPage.php
@@ -6,7 +6,7 @@ use ScummVM\Models\GameDemosModel;
class DemosPage extends Controller
{
- private $_template;
+ protected $_template;
/* Constructor. */
public function __construct()
diff --git a/include/Pages/DocumentationPage.php b/include/Pages/DocumentationPage.php
index e9fb38a..f907692 100644
--- a/include/Pages/DocumentationPage.php
+++ b/include/Pages/DocumentationPage.php
@@ -6,7 +6,7 @@ use ScummVM\Models\DocumentationModel;
class DocumentationPage extends Controller
{
- private $_template;
+ protected $_template;
/* Constructor. */
public function __construct()
diff --git a/include/Pages/DownloadsPage.php b/include/Pages/DownloadsPage.php
index 38c7f4d..99c2590 100644
--- a/include/Pages/DownloadsPage.php
+++ b/include/Pages/DownloadsPage.php
@@ -6,7 +6,7 @@ use ScummVM\Models\DownloadsModel;
class DownloadsPage extends Controller
{
- private $_template;
+ protected $_template;
/* Constructor. */
public function __construct()
diff --git a/include/Pages/ExceptionsPage.php b/include/Pages/ExceptionsPage.php
index 654298c..3f3db98 100644
--- a/include/Pages/ExceptionsPage.php
+++ b/include/Pages/ExceptionsPage.php
@@ -3,7 +3,7 @@ namespace ScummVM\Pages;
class ExceptionsPage extends \ScummVM\Controller
{
- private $_template;
+ protected $_template;
/* Constructor. */
public function __construct()
diff --git a/include/Pages/FAQPage.php b/include/Pages/FAQPage.php
index b996623..8e9ec66 100644
--- a/include/Pages/FAQPage.php
+++ b/include/Pages/FAQPage.php
@@ -6,7 +6,7 @@ use ScummVM\Models\FAQModel;
class FAQPage extends Controller
{
- private $_template;
+ protected $_template;
/* Constructor. */
public function __construct()
diff --git a/include/Pages/GamesPage.php b/include/Pages/GamesPage.php
index d6181c2..5fef48f 100644
--- a/include/Pages/GamesPage.php
+++ b/include/Pages/GamesPage.php
@@ -6,7 +6,7 @@ use ScummVM\Models\GamesModel;
class GamesPage extends Controller
{
- private $_template;
+ protected $_template;
/* Constructor. */
public function __construct()
diff --git a/include/Pages/LinksPage.php b/include/Pages/LinksPage.php
index 219b39a..4f4f95d 100644
--- a/include/Pages/LinksPage.php
+++ b/include/Pages/LinksPage.php
@@ -6,7 +6,7 @@ use ScummVM\Models\LinksModel;
class LinksPage extends Controller
{
- private $_template;
+ protected $_template;
/* Constructor. */
public function __construct()
diff --git a/include/Pages/NewsPage.php b/include/Pages/NewsPage.php
index 2667e49..3ec9c7f 100644
--- a/include/Pages/NewsPage.php
+++ b/include/Pages/NewsPage.php
@@ -7,7 +7,7 @@ use ScummVM\Models\ScreenshotsModel;
class NewsPage extends Controller
{
- private $_template;
+ protected $_template;
/* Constructor. */
public function __construct()
diff --git a/include/Pages/PressPage.php b/include/Pages/PressPage.php
index 5b2371b..7e3cd3f 100644
--- a/include/Pages/PressPage.php
+++ b/include/Pages/PressPage.php
@@ -6,7 +6,7 @@ use ScummVM\Models\ArticleModel;
class PressPage extends Controller
{
- private $_template;
+ protected $_template;
/* Constructor. */
public function __construct()
diff --git a/include/Pages/PressSnowberryPage.php b/include/Pages/PressSnowberryPage.php
index a2e7d06..96aa355 100644
--- a/include/Pages/PressSnowberryPage.php
+++ b/include/Pages/PressSnowberryPage.php
@@ -6,7 +6,7 @@ use ScummVM\Models\ArticleModel;
class PressSnowberryPage extends Controller
{
- private $_template;
+ protected $_template;
/* Constructor. */
public function __construct()
diff --git a/include/Pages/ScreenshotsPage.php b/include/Pages/ScreenshotsPage.php
index 68fb987..b72a1f4 100644
--- a/include/Pages/ScreenshotsPage.php
+++ b/include/Pages/ScreenshotsPage.php
@@ -2,11 +2,11 @@
namespace ScummVM\Pages;
use ScummVM\Controller;
-use ScummVM\Models\ScreenshotModel;
+use ScummVM\Models\ScreenshotsModel;
class ScreenshotsPage extends Controller
{
- private $_template;
+ protected $_template;
private $_template_category;
/* Constructor. */
@@ -15,7 +15,6 @@ class ScreenshotsPage extends Controller
parent::__construct();
$this->_template = 'pages/screenshots.tpl';
$this->_template_category = 'pages/screenshots_category.tpl';
- $this->_template_viewer = 'screenshots_viewer.tpl';
}
/* Display the index page. */
@@ -35,7 +34,7 @@ class ScreenshotsPage extends Controller
'baguetteBox.min.js'
));
- $screenshot = ScreenshotsModel::getAllScreenshots();
+ $screenshot = ScreenshotsModel::getAllScreenshots();
$random_shot = ScreenshotsModel::getRandomScreenshot();
global $Smarty;
diff --git a/include/Pages/SubprojectsPage.php b/include/Pages/SubprojectsPage.php
index 9c2d49c..7e462ed 100644
--- a/include/Pages/SubprojectsPage.php
+++ b/include/Pages/SubprojectsPage.php
@@ -6,7 +6,7 @@ use ScummVM\Models\SubprojectsModel;
class SubprojectsPage extends Controller
{
- private $_template;
+ protected $_template;
/* Constructor. */
public function __construct()
Commit: 2eff11cbb3cb230f798afacd5302173bd67e4cb8
https://github.com/scummvm/scummvm-web/commit/2eff11cbb3cb230f798afacd5302173bd67e4cb8
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Clean up most PSR2 style warnings
Changed paths:
include/Controller.php
include/ExceptionHandler.php
include/I18N.php
include/Objects/Article.php
include/Objects/BasicObject.php
include/Objects/CSection.php
include/Objects/CompatGame.php
include/Objects/DSection.php
include/Objects/DSubSection.php
include/Objects/Document.php
include/Objects/File.php
include/Objects/GameDemo.php
include/Objects/MenuItem.php
include/Objects/News.php
include/Objects/Person.php
include/Objects/Project.php
include/Objects/QAEntry.php
include/Objects/QASection.php
include/Objects/Screenshot.php
include/Objects/WebLink.php
include/Pages/CompatibilityPage.php
include/Pages/ContactPage.php
include/Pages/CreditsPage.php
include/Pages/DemosPage.php
include/Pages/DocumentationPage.php
include/Pages/DownloadsPage.php
include/Pages/ExceptionsPage.php
include/Pages/FAQPage.php
include/Pages/FeedsPage.php
include/Pages/GamesPage.php
include/Pages/LinksPage.php
include/Pages/NewsPage.php
include/Pages/PressPage.php
include/Pages/PressSnowberryPage.php
include/Pages/ScreenshotsPage.php
include/Pages/SubprojectsPage.php
include/XMLParser.php
diff --git a/include/Controller.php b/include/Controller.php
index b01992c..266bc31 100644
--- a/include/Controller.php
+++ b/include/Controller.php
@@ -11,14 +11,9 @@ use ScummVM\Models\MenuModel;
*/
class Controller
{
- private $_smarty;
- protected $_template;
- private $_title;
- private $_css_files;
- private $_js_files;
- private $_show_intro;
- private $_content_title;
- private $_content;
+ private $smarty;
+ private $css_files;
+ private $js_files;
/**
* Constructor that will create a Smarty object and configure it according
@@ -27,34 +22,34 @@ class Controller
public function __construct()
{
/* Create a Smarty object. */
- $this->_smarty = new Smarty();
+ $this->smarty = new Smarty();
# Stick it globally so we could refer the translations
global $Smarty;
- $Smarty = $this->_smarty;
+ $Smarty = $this->smarty;
global $lang;
global $available_languages;
/* Configure smarty. */
- $this->_smarty->compile_dir = SMARTY_DIR_COMPILE;
- $this->_smarty->cache_dir = SMARTY_DIR_CACHE;
- $this->_smarty->config_dir = SMARTY_DIR_CONFIG;
- $this->_smarty->caching = SMARTY_CACHING_ENABLE;
- $this->_smarty->cache_lifetime = SMARTY_CACHING_LIFETIME;
- $this->_smarty->compile_check = SMARTY_CACHING_COMPILE_CHECK;
- $this->_smarty->force_compile = SMARTY_CACHING_FORCE_RECHECK;
- $this->_smarty->template_dir = array("templates_$lang", 'templates');
- $this->_smarty->compile_id = $lang;
- $this->_smarty->config_dir = ".";
+ $this->smarty->compile_dir = SMARTY_DIR_COMPILE;
+ $this->smarty->cache_dir = SMARTY_DIR_CACHE;
+ $this->smarty->config_dir = SMARTY_DIR_CONFIG;
+ $this->smarty->caching = SMARTY_CACHING_ENABLE;
+ $this->smarty->cache_lifetime = SMARTY_CACHING_LIFETIME;
+ $this->smarty->compile_check = SMARTY_CACHING_COMPILE_CHECK;
+ $this->smarty->force_compile = SMARTY_CACHING_FORCE_RECHECK;
+ $this->smarty->template_dir = array("templates_$lang", 'templates');
+ $this->smarty->compile_id = $lang;
+ $this->smarty->config_dir = ".";
# First we read English, so all defaults are there
- $this->_smarty->configLoad(DIR_LANG . "/lang.en.ini");
+ $this->smarty->configLoad(DIR_LANG . "/lang.en.ini");
# Now we try to read translations
if (is_file(($fname = DIR_LANG . "/lang.$lang.ini"))
&& is_readable($fname)) {
- $this->_smarty->configLoad($fname);
+ $this->smarty->configLoad($fname);
}
setlocale(LC_TIME, $Smarty->getConfigVars('locale'));
@@ -63,25 +58,21 @@ class Controller
* Add a output-filter to make sure ampersands are properly encoded to
* HTML-entities.
*/
- $this->_smarty->registerFilter('output', array($this, 'outputFilter'));
+ $this->smarty->registerFilter('output', array($this, 'outputFilter'));
/* Give Smarty-template access to date(). */
- $this->_smarty->registerPlugin('modifier', 'date_f', array(&$this, 'date_f'));
- $this->_smarty->registerPlugin('modifier', 'date_localized', array(&$this, 'date_localized'));
+ $this->smarty->registerPlugin('modifier', 'date_f', array(&$this, 'dateFormatSmartyModifier'));
+ $this->smarty->registerPlugin('modifier', 'date_localized', array(&$this, 'dateLocalizedSmartyModifier'));
/* Give Smarty-templates access to the ampersandEntity() function. */
- $this->_smarty->registerPlugin(
+ $this->smarty->registerPlugin(
'modifier',
'escapeAmpersand',
array(&$this, 'ampersandEntity')
);
- $this->_title = '';
- $this->_css_files = array();
- $this->_js_files = array();
- $this->_show_intro = false;
- $this->_content_title = '';
- $this->_content = '';
+ $this->css_files = array();
+ $this->js_files = array();
/* The menus have caused an exception, need to skip them. */
if (!ExceptionHandler::skipMenus()) {
@@ -100,7 +91,7 @@ class Controller
'pageurl' => $pageurl,
'available_languages' => $available_languages,
);
- $this->_smarty->assign($vars);
+ $this->smarty->assign($vars);
}
/** Smarty outputfilter, run just before displaying. */
@@ -121,13 +112,13 @@ class Controller
}
/** Formating of dates, registered as a modifier for Smarty templates. */
- public function date_f($timestamp, $format)
+ public function dateFormatSmartyModifier($timestamp, $format)
{
return date($format, $timestamp);
}
/** Formating of dateAs, registered as a modifier for Smarty templates. */
- public function date_localized($timestamp, $format)
+ public function dateLocalizedSmartyModifier($timestamp, $format)
{
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
$format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format);
@@ -141,12 +132,12 @@ class Controller
if (!is_string($content) || strlen($content) == 0) {
}
$vars = array(
- 'css_files' => $this->_css_files,
- 'js_files' => $this->_js_files,
+ 'css_files' => $this->css_files,
+ 'js_files' => $this->js_files,
'content' => $content,
);
- $this->_smarty->assign($vars);
- return $this->_smarty->display('pages/index.tpl');
+ $this->smarty->assign($vars);
+ return $this->smarty->display('pages/index.tpl');
}
/* Render the HTML using the template and any set variables and returns it. */
@@ -155,9 +146,9 @@ class Controller
if (!is_file(SMARTY_DIR_TEMPLATE . "/{$template}")) {
}
if (!is_null($vars)) {
- $this->_smarty->assign($vars);
+ $this->smarty->assign($vars);
}
- return $this->_smarty->fetch($template);
+ return $this->smarty->fetch($template);
}
/* Set up the variables used by the template and render the page. */
@@ -172,12 +163,12 @@ class Controller
public function addCSSFiles($extra_css)
{
if (is_array($extra_css)) {
- $this->_css_files = array_merge(
- $this->_css_files,
+ $this->css_files = array_merge(
+ $this->css_files,
$extra_css
);
} elseif (is_string($extra_css) && strlen($extra_css) > 0) {
- $this->_css_files[] = $extra_css;
+ $this->css_files[] = $extra_css;
}
}
@@ -185,12 +176,12 @@ class Controller
public function addJSFiles($extra_js)
{
if (is_array($extra_js)) {
- $this->_js_files = array_merge(
- $this->_js_files,
+ $this->js_files = array_merge(
+ $this->js_files,
$extra_js
);
} elseif (is_string($extra_js) && strlen($extra_js) > 0) {
- $this->_js_files[] = $extra_js;
+ $this->js_files[] = $extra_js;
}
}
}
diff --git a/include/ExceptionHandler.php b/include/ExceptionHandler.php
index 04e2b52..d3e5a6f 100644
--- a/include/ExceptionHandler.php
+++ b/include/ExceptionHandler.php
@@ -4,13 +4,13 @@ namespace ScummVM;
/** Handle uncaught exceptions. */
abstract class ExceptionHandler
{
- private static $_exception;
+ private static $exception;
/* If the MenuModel cause the exception we need to skip them. */
public static function skipMenus()
{
$skip_menus = false;
- $e = self::$_exception;
+ $e = self::$exception;
if (!is_null($e)) {
if (basename($e->getFile() == 'MenuModel.php')) {
@@ -31,7 +31,7 @@ abstract class ExceptionHandler
/* Handle exceptions. */
public static function handleException($e)
{
- self::$_exception = $e;
+ self::$exception = $e;
$ep = new \ScummVM\Pages\ExceptionsPage();
return $ep->index($e);
diff --git a/include/I18N.php b/include/I18N.php
index 3c4b173..1e28d4b 100644
--- a/include/I18N.php
+++ b/include/I18N.php
@@ -8,14 +8,14 @@ define('DIR_NEWS', 'data/news');
class I18N
{
- private $_purifier;
+ private $purifier;
const NO_FILES = 'No I18N Files Found';
public function __construct()
{
$config = \HTMLPurifier_Config::createDefault();
- $this->_purifier = new \HTMLPurifier($config);
+ $this->purifier = new \HTMLPurifier($config);
$langs = ['en', 'it', 'fr', 'ru', 'de'];
foreach ($langs as $key => $value) {
@@ -33,7 +33,7 @@ class I18N
$output = "";
foreach ($json as $key => $value) {
- $output .= $key . " = " . $this->_purifier->purify($value). "\n";
+ $output .= $key . " = " . $this->purifier->purify($value). "\n";
}
file_put_contents("lang/{$lang}.ini", $output);
@@ -49,12 +49,15 @@ class I18N
foreach ($i18n as $key => $value) {
$originalJson = json_decode(file_get_contents(DIR_NEWS . "/{$key}.json"));
- $value->date = $this->_purifier->purify($originalJson->date);
- $value->author = $this->_purifier->purify($originalJson->author);
- $value->title = $this->_purifier->purify($value->title);
- $value->content = $this->_purifier->purify($value->content);
-
- file_put_contents(DIR_NEWS . "/{$lang}/{$key}.json", json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
+ $value->date = $this->purifier->purify($originalJson->date);
+ $value->author = $this->purifier->purify($originalJson->author);
+ $value->title = $this->purifier->purify($value->title);
+ $value->content = $this->purifier->purify($value->content);
+
+ file_put_contents(
+ DIR_NEWS . "/{$lang}/{$key}.json",
+ json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)
+ );
}
} else {
// Update the base english i18n file
@@ -63,12 +66,15 @@ class I18N
$news = $this->getAllNews($lang);
foreach ($news as $key => $value) {
$newsJson->$key = array(
- "title" => $this->_purifier->purify($value->title),
- "content" => $this->_purifier->purify($value->content)
+ "title" => $this->purifier->purify($value->title),
+ "content" => $this->purifier->purify($value->content)
);
}
- file_put_contents(DIR_NEWS . "/i18n/news.{$lang}.json", json_encode($newsJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . "\n");
+ file_put_contents(
+ DIR_NEWS . "/i18n/news.{$lang}.json",
+ json_encode($newsJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . "\n"
+ );
}
}
diff --git a/include/Objects/Article.php b/include/Objects/Article.php
index eddec3e..9aef327 100644
--- a/include/Objects/Article.php
+++ b/include/Objects/Article.php
@@ -7,41 +7,40 @@ namespace ScummVM\Objects;
*/
class Article extends BasicObject
{
- private $_name;
- private $_url;
- private $_language;
- private $_posted;
+ private $url;
+ private $language;
+ private $posted;
/* Article object constructor. */
public function __construct($data)
{
- $this->_name = $data['name'];
- $this->_url = $data['url'];
- $this->_language = $data['language'];
- $this->_posted = $data['posted'];
+ $this->name = $data['name'];
+ $this->url = $data['url'];
+ $this->language = $data['language'];
+ $this->posted = $data['posted'];
}
/* Get the name. */
public function getName()
{
- return $this->_name;
+ return $this->name;
}
/* Get the URL. */
public function getURL()
{
- return $this->_url;
+ return $this->url;
}
/* Get the language. */
public function getLanguage()
{
- return $this->_language;
+ return $this->language;
}
/* Get the date it was posted. */
public function getPosted()
{
- return $this->_posted;
+ return $this->posted;
}
}
diff --git a/include/Objects/BasicObject.php b/include/Objects/BasicObject.php
index 220e0d0..e207226 100644
--- a/include/Objects/BasicObject.php
+++ b/include/Objects/BasicObject.php
@@ -7,6 +7,7 @@ namespace ScummVM\Objects;
*/
abstract class BasicObject
{
+ protected $name;
/**
* If the input array doesn't contain the numerical key 0, wrap it inside
* an array. This functions operates on the data directly.
diff --git a/include/Objects/CSection.php b/include/Objects/CSection.php
index 00f4fdc..59203f8 100644
--- a/include/Objects/CSection.php
+++ b/include/Objects/CSection.php
@@ -7,24 +7,24 @@ namespace ScummVM\Objects;
*/
class CSection extends BasicObject
{
- private $_title;
- private $_groups;
- private $_subsections;
- private $_paragraphs;
- private $_anchor;
+ private $title;
+ private $groups;
+ private $subsections;
+ private $paragraphs;
+ private $anchor;
/* CSection object constructor. */
public function __construct($data)
{
- $this->_title = $data['title'];
- $this->_anchor = $data['anchor'];
- $this->_groups = array();
- $this->_subsections = array();
- $this->_paragraphs = array();
+ $this->title = $data['title'];
+ $this->anchor = $data['anchor'];
+ $this->groups = array();
+ $this->subsections = array();
+ $this->paragraphs = array();
if (isset($data['subsection'])) {
foreach ($data['subsection'] as $value) {
- $this->_subsections[] = new CSection($value);
+ $this->subsections[] = new CSection($value);
}
}
if (isset($data['group'])) {
@@ -40,7 +40,7 @@ class CSection extends BasicObject
$persons[] = new Person($args);
}
if (count($persons) > 0) {
- $this->_groups[] = array(
+ $this->groups[] = array(
'name' => $value['name'],
'persons' => $persons,
);
@@ -49,37 +49,37 @@ class CSection extends BasicObject
}
if (isset($data['paragraph'])) {
parent::toArray($data['paragraph']);
- $this->_paragraphs = $data['paragraph'];
+ $this->paragraphs = $data['paragraph'];
}
}
/* Get the title. */
public function getTitle()
{
- return $this->_title;
+ return $this->title;
}
/* Get the anchor. */
public function getAnchor()
{
- return $this->_anchor;
+ return $this->anchor;
}
/* Get the optional list of groups. */
public function getGroups()
{
- return $this->_groups;
+ return $this->groups;
}
/* Get the optional list of subsections. */
public function getSubSections()
{
- return $this->_subsections;
+ return $this->subsections;
}
/* Get the optional list of paragraphs. */
public function getParagraphs()
{
- return $this->_paragraphs;
+ return $this->paragraphs;
}
}
diff --git a/include/Objects/CompatGame.php b/include/Objects/CompatGame.php
index daf46ed..71fd0bd 100644
--- a/include/Objects/CompatGame.php
+++ b/include/Objects/CompatGame.php
@@ -7,48 +7,47 @@ namespace ScummVM\Objects;
*/
class CompatGame extends BasicObject
{
- private $_name;
- private $_target;
- private $_supportLevel;
- private $_notes;
+ private $target;
+ private $supportLevel;
+ private $notes;
/* Project object constructor. */
public function __construct($data)
{
- $this->_name = $data['name'];
- $this->_target = $data['target'];
+ $this->name = $data['name'];
+ $this->target = $data['target'];
// In old compat pages we used 'percent' instead of 'support_level'.
// we still want to support those thus we check whether the old tag
// is present here.
if (array_key_exists('percent', $data)) {
- $this->_supportLevel = $data['percent'];
+ $this->supportLevel = $data['percent'];
} else {
- $this->_supportLevel = $data['support_level'];
+ $this->supportLevel = $data['support_level'];
}
- $this->_notes = $data['notes'];
+ $this->notes = $data['notes'];
}
/* Get the name. */
public function getName()
{
- return $this->_name;
+ return $this->name;
}
/* Get the target name. */
public function getTarget()
{
- return $this->_target;
+ return $this->target;
}
/* Get the support level. */
public function getSupportLevel()
{
- return $this->_supportLevel;
+ return $this->supportLevel;
}
/* Get the notes. */
public function getNotes()
{
- return $this->_notes;
+ return $this->notes;
}
}
diff --git a/include/Objects/DSection.php b/include/Objects/DSection.php
index 292c89a..1d16072 100644
--- a/include/Objects/DSection.php
+++ b/include/Objects/DSection.php
@@ -6,48 +6,48 @@ namespace ScummVM\Objects;
*/
class DSection extends BasicObject
{
- private $_title;
- private $_anchor;
- private $_baseurl;
- private $_baseturl;
- private $_subsections;
+ private $title;
+ private $anchor;
+ private $baseurl;
+ private $baseturl;
+ private $subsections;
/* DSection object constructor. */
public function __construct($data)
{
- $this->_title = $data['title'];
- $this->_anchor = $data['anchor'];
- $this->_baseurl = $data['baseurl'];
- $this->_baseturl = $data['baseturl'];
- $this->_subsections = array();
+ $this->title = $data['title'];
+ $this->anchor = $data['anchor'];
+ $this->baseurl = $data['baseurl'];
+ $this->baseturl = $data['baseturl'];
+ $this->subsections = array();
parent::toArray($data['subsection']);
foreach ($data['subsection'] as $key => $value) {
- $this->_subsections[] = new DSubSection($value, $this->_baseurl, $this->_baseturl);
+ $this->subsections[] = new DSubSection($value, $this->baseurl, $this->baseturl);
}
}
/* Get the title. */
public function getTitle()
{
- return $this->_title;
+ return $this->title;
}
/* Get the anchor name. */
public function getAnchor()
{
- return $this->_anchor;
+ return $this->anchor;
}
/* Get the base URL. */
public function getBaseURL()
{
- return $this->_baseurl;
+ return $this->baseurl;
}
/* Get the list of optional subsections. */
public function getSubSections()
{
- return $this->_subsections;
+ return $this->subsections;
}
}
diff --git a/include/Objects/DSubSection.php b/include/Objects/DSubSection.php
index 7edaf8b..ea90bef 100644
--- a/include/Objects/DSubSection.php
+++ b/include/Objects/DSubSection.php
@@ -6,34 +6,34 @@ namespace ScummVM\Objects;
*/
class DSubSection extends BasicObject
{
- private $_title;
- private $_anchor;
- private $_notes;
- private $_footer;
- private $_files;
- private $_links;
- private $_items;
+ private $title;
+ private $anchor;
+ private $notes;
+ private $footer;
+ private $files;
+ private $links;
+ private $items;
/* DSubSection constructor. */
public function __construct($data, $baseurl, $baseturl)
{
- $this->_title = $data['title'];
- $this->_anchor = $data['anchor'];
- $this->_notes = $data['notes'];
- $this->_footer = $data['footer'];
- $this->_files = array();
- $this->_links = array();
- $this->_items = array();
+ $this->title = $data['title'];
+ $this->anchor = $data['anchor'];
+ $this->notes = $data['notes'];
+ $this->footer = $data['footer'];
+ $this->files = array();
+ $this->links = array();
+ $this->items = array();
foreach ($data['entries'] as $type => $item) {
parent::toArray($item);
if ($type == 'file') {
foreach ($item as $file) {
- $this->_items[] = new File($file, $baseurl, $baseturl);
+ $this->items[] = new File($file, $baseurl, $baseturl);
}
} elseif ($type == 'link') {
foreach ($item as $link) {
- $this->_items[] = new WebLink($link);
+ $this->items[] = new WebLink($link);
}
}
}
@@ -42,42 +42,42 @@ class DSubSection extends BasicObject
/* Get the title. */
public function getTitle()
{
- return $this->_title;
+ return $this->title;
}
/* Get the anchor name. */
public function getAnchor()
{
- return $this->_anchor;
+ return $this->anchor;
}
/* Get the optional notes. */
public function getNotes()
{
- return $this->_notes;
+ return $this->notes;
}
/* Get the optional footer. */
public function getFooter()
{
- return $this->_footer;
+ return $this->footer;
}
/* Get the list of files. */
public function getFiles()
{
- return $this->_files;
+ return $this->files;
}
/* Get the list of links. */
public function getLinks()
{
- return $this->_links;
+ return $this->links;
}
/* Get the list of items. */
public function getItems()
{
- return $this->_items;
+ return $this->items;
}
}
diff --git a/include/Objects/Document.php b/include/Objects/Document.php
index 49c0d25..37db502 100644
--- a/include/Objects/Document.php
+++ b/include/Objects/Document.php
@@ -6,33 +6,32 @@ namespace ScummVM\Objects;
*/
class Document extends BasicObject
{
- private $_name;
- private $_url;
- private $_description;
+ private $url;
+ private $description;
/* Document object constructor. */
public function __construct($data)
{
- $this->_name = $data['name'];
- $this->_url = $data['url'];
- $this->_description = $data['description'];
+ $this->name = $data['name'];
+ $this->url = $data['url'];
+ $this->description = $data['description'];
}
/* Get the name. */
public function getName()
{
- return $this->_name;
+ return $this->name;
}
/* Get the URL. */
public function getURL()
{
- return $this->_url;
+ return $this->url;
}
/* Get the description. */
public function getDescription()
{
- return $this->_description;
+ return $this->description;
}
}
diff --git a/include/Objects/File.php b/include/Objects/File.php
index 9f02744..6b91c70 100644
--- a/include/Objects/File.php
+++ b/include/Objects/File.php
@@ -6,20 +6,20 @@ namespace ScummVM\Objects;
*/
class File extends BasicObject
{
- private $_category_icon;
- private $_url;
- private $_name;
- private $_type;
- private $_extra_info;
- private $_user_agent;
+ private $category_icon;
+ private $url;
+
+ private $type;
+ private $extra_info;
+ private $user_agent;
public function __construct($data, $baseurl = null, $baseturl = null)
{
- $this->_category_icon = $data['category_icon'];
- $this->_name = $data['name'];
- $this->_extra_info = $data['extra_info'];
- $this->_type = strtolower($data['type']);
- $this->_user_agent = isset($data["user_agent"]) ? $data["user_agent"] : "";
+ $this->category_icon = $data['category_icon'];
+ $this->name = $data['name'];
+ $this->extra_info = $data['extra_info'];
+ $this->type = strtolower($data['type']);
+ $this->user_agent = isset($data["user_agent"]) ? $data["user_agent"] : "";
$fname = "";
@@ -46,7 +46,7 @@ class File extends BasicObject
$fname = str_replace('{$release_tools}', RELEASE_TOOLS, $fname);
if (is_file($fname) && is_readable($fname)) {
- $this->_extra_info = array();
+ $this->extra_info = array();
$sz = round((@filesize($fname) / 1024));
if ($sz < 1024) {
@@ -61,7 +61,7 @@ class File extends BasicObject
$sz = round($sz, 2) . "G";
}
}
- $this->_extra_info['size'] = $sz;
+ $this->extra_info['size'] = $sz;
$ext = substr($url, (strrpos($url, '.')));
if ($ext == '.bz2' || $ext == '.gz' || $ext == '.xz' || $ext == '.7z') {
@@ -70,28 +70,28 @@ class File extends BasicObject
if ((is_file($fname . '.sha256') && is_readable($fname . '.sha256'))
&& (@filemtime($fname . '.sha256') > @filemtime($fname)) ) {
- $this->_extra_info['sha256'] = file_get_contents($fname . '.sha256');
+ $this->extra_info['sha256'] = file_get_contents($fname . '.sha256');
} else {
$hash = hash_file('sha256', $fname);
- $this->_extra_info['sha256'] = $hash;
+ $this->extra_info['sha256'] = $hash;
file_put_contents($fname . '.sha256', $hash);
}
- $this->_extra_info['ext'] = $ext;
- $this->_extra_info['msg'] = $data['extra_msg'];
+ $this->extra_info['ext'] = $ext;
+ $this->extra_info['msg'] = $data['extra_msg'];
}
}
$this->_url = $url;
/**
* Get the filesize/last modified information and put it in
- * $this->_extra_info.
+ * $this->extra_info.
*/
if ($attributes['extra_info'] == 'true') {
if (is_file($fname) && is_readable($fname)) {
- $this->_extra_info['date'] = date('F j, Y, g:i a', @filemtime($fname));
+ $this->extra_info['date'] = date('F j, Y, g:i a', @filemtime($fname));
if (!is_null($data['extra_info'])) {
- $this->_extra_info['info'] = $data['extra_info'];
+ $this->extra_info['info'] = $data['extra_info'];
}
}
}
@@ -100,7 +100,7 @@ class File extends BasicObject
/* Get the category icon. */
public function getCategoryIcon()
{
- return $this->_category_icon;
+ return $this->category_icon;
}
/* Get the URL. */
@@ -112,24 +112,24 @@ class File extends BasicObject
/* Get the name. */
public function getName()
{
- return $this->_name;
+ return $this->name;
}
/* Get the type. */
public function getType()
{
- return $this->_type;
+ return $this->type;
}
/* Get the extra information. */
public function getExtraInfo()
{
- return $this->_extra_info;
+ return $this->extra_info;
}
/* Get the user-agent. */
public function getUserAgent()
{
- return $this->_user_agent;
+ return $this->user_agent;
}
}
diff --git a/include/Objects/GameDemo.php b/include/Objects/GameDemo.php
index f0daf9d..443b636 100644
--- a/include/Objects/GameDemo.php
+++ b/include/Objects/GameDemo.php
@@ -6,41 +6,41 @@ namespace ScummVM\Objects;
*/
class GameDemo extends BasicObject
{
- private $_name;
- private $_url;
- private $_target;
- private $_category;
+
+ private $url;
+ private $target;
+ private $category;
/* GameDemo object constructor. */
public function __construct($data)
{
- $this->_name = $data['name'];
- $this->_url = $data['url'];
- $this->_target = $data['target'];
- $this->_category = isset($data['category']) ? $data['category'] : $data['target'];
+ $this->name = $data['name'];
+ $this->url = $data['url'];
+ $this->target = $data['target'];
+ $this->category = isset($data['category']) ? $data['category'] : $data['target'];
}
/* Get the name of the demo. */
public function getName()
{
- return $this->_name;
+ return $this->name;
}
/* Get the download URL for the demo. */
public function getURL()
{
- return $this->_url;
+ return $this->url;
}
/* Get the target name for the demo. */
public function getTarget()
{
- return $this->_target;
+ return $this->target;
}
/* Get the category for the demo. */
public function getCategory()
{
- return $this->_category;
+ return $this->category;
}
}
diff --git a/include/Objects/MenuItem.php b/include/Objects/MenuItem.php
index 0efc92b..098c4a7 100644
--- a/include/Objects/MenuItem.php
+++ b/include/Objects/MenuItem.php
@@ -6,36 +6,36 @@ namespace ScummVM\Objects;
*/
class MenuItem extends BasicObject
{
- private $_name;
- private $_class;
- private $_entries;
+
+ private $class;
+ private $entries;
/* Menu object constructor. */
public function __construct($data)
{
- $this->_name = $data['name'];
- $this->_class = $data['class'];
- $this->_entries = array();
+ $this->name = $data['name'];
+ $this->class = $data['class'];
+ $this->entries = array();
foreach ($data['link'] as $key => $value) {
- $this->_entries[$value['name']] = $value['href'];
+ $this->entries[$value['name']] = $value['href'];
}
}
/* Get the name. */
public function getName()
{
- return $this->_name;
+ return $this->name;
}
/* Get the CSS class. */
public function getClass()
{
- return $this->_class;
+ return $this->class;
}
/* Get the list of links, with the name as key and URL as value. */
public function getEntries()
{
- return $this->_entries;
+ return $this->entries;
}
}
diff --git a/include/Objects/News.php b/include/Objects/News.php
index 3ff4441..cf8fc3e 100644
--- a/include/Objects/News.php
+++ b/include/Objects/News.php
@@ -6,12 +6,11 @@ namespace ScummVM\Objects;
*/
class News extends BasicObject
{
- private $_title;
- private $_date;
- private $_author;
- private $_image;
- private $_content;
- private $_filename;
+ private $title;
+ private $date;
+ private $author;
+ private $content;
+ private $filename;
/**
* News object constructor that extracts the data from the JSON scheme
@@ -28,11 +27,11 @@ class News extends BasicObject
*/
public function __construct($data, $filename, $processContent = false)
{
- $this->_title = $processContent ? $this->processText($data->title) : $data->title;
- $this->_date = $data->date;
- $this->_author = $data->author;
- $this->_content = $processContent ? $this->processText($data->content) : $data->content;
- $this->_filename = basename($filename);
+ $this->title = $processContent ? $this->processText($data->title) : $data->title;
+ $this->date = $data->date;
+ $this->author = $data->author;
+ $this->content = $processContent ? $this->processText($data->content) : $data->content;
+ $this->filename = basename($filename);
}
/**
@@ -44,7 +43,7 @@ class News extends BasicObject
* http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
* for a list of valid entities for both XML and HTML
*/
- function processText($text)
+ public function processText($text)
{
return html_entity_decode($text, ENT_COMPAT, 'UTF-8');
}
@@ -52,36 +51,36 @@ class News extends BasicObject
/* Get the title. */
public function getTitle()
{
- return $this->_title;
+ return $this->title;
}
/* Get the date. */
public function getDate()
{
- return $this->_date;
+ return $this->date;
}
/* Get the author. */
public function getAuthor()
{
- return $this->_author;
+ return $this->author;
}
/* Get the content. */
public function getContent()
{
- return $this->_content;
+ return $this->content;
}
/* Get the filename. */
public function getFilename()
{
- return $this->_filename;
+ return $this->filename;
}
/* Get the News link. */
public function getLink()
{
- return URL_BASE . 'news/' . substr($this->_filename, 0, -5);
+ return URL_BASE . 'news/' . substr($this->filename, 0, -5);
}
}
diff --git a/include/Objects/Person.php b/include/Objects/Person.php
index 8e6e6db..0a6e22d 100644
--- a/include/Objects/Person.php
+++ b/include/Objects/Person.php
@@ -7,33 +7,33 @@ namespace ScummVM\Objects;
*/
class Person extends BasicObject
{
- private $_name;
- private $_alias;
- private $_description;
+
+ private $alias;
+ private $description;
/* Person object constructor. */
public function __construct($args)
{
- $this->_name = $args['name'];
- $this->_alias = $args['alias'];
- $this->_description = $args['description'];
+ $this->name = $args['name'];
+ $this->alias = $args['alias'];
+ $this->description = $args['description'];
}
/* Get the name. */
public function getName()
{
- return $this->_name;
+ return $this->name;
}
/* Get the alias. */
public function getAlias()
{
- return $this->_alias;
+ return $this->alias;
}
/* Get the description. */
public function getDescription()
{
- return $this->_description;
+ return $this->description;
}
}
diff --git a/include/Objects/Project.php b/include/Objects/Project.php
index a937597..3797dbc 100644
--- a/include/Objects/Project.php
+++ b/include/Objects/Project.php
@@ -6,9 +6,9 @@ namespace ScummVM\Objects;
*/
class Project extends BasicObject
{
- private $_name;
- private $_info;
- private $_downloads;
+
+ private $info;
+ private $downloads;
/* Project object constructor. */
public function __construct($data)
diff --git a/include/Objects/QAEntry.php b/include/Objects/QAEntry.php
index 8868cc5..b022b2a 100644
--- a/include/Objects/QAEntry.php
+++ b/include/Objects/QAEntry.php
@@ -7,10 +7,10 @@ namespace ScummVM\Objects;
*/
class QAEntry extends BasicObject
{
- private $_hrefs;
- private $_question;
- private $_answer;
- private $_xref;
+ private $hrefs;
+ private $question;
+ private $answer;
+ private $xref;
/**
* QAEntry object constructor.
@@ -22,42 +22,42 @@ class QAEntry extends BasicObject
*/
public function __construct($data, $section_number, $entry_number, &$xref)
{
- $this->_hrefs = array();
+ $this->hrefs = array();
if (! empty($data['href'])) {
- array_push($this->_hrefs, $data['href']);
+ array_push($this->hrefs, $data['href']);
$xref[$data['href']] = $data['question'];
}
- array_push($this->_hrefs, "{$section_number}_{$entry_number}");
+ array_push($this->hrefs, "{$section_number}_{$entry_number}");
- $this->_question = $data['question'];
- $this->_answer = $data['answer'];
+ $this->question = $data['question'];
+ $this->answer = $data['answer'];
/* Save a reference to the xref table for later use. */
- $this->_xref = &$xref;
+ $this->xref = &$xref;
}
/* Get the primary anchor name for this entry. */
public function getHref()
{
- return $this->_hrefs[0];
+ return $this->hrefs[0];
}
/* Get all anchor names for this entry. */
public function getHrefs()
{
- return $this->_hrefs;
+ return $this->hrefs;
}
/* Get the question for this entry. */
public function getQuestion()
{
- return $this->_question;
+ return $this->question;
}
/* Get the answer for this entry. */
public function getAnswer()
{
- $answer = &$this->_answer;
- $xref = &$this->_xref;
+ $answer = &$this->answer;
+ $xref = &$this->xref;
/* If we find a xref we need to make the final conversion to HTML. */
if (strpos($answer, '<a xref') !== false) {
/**
@@ -68,13 +68,13 @@ class QAEntry extends BasicObject
if (!isset($xref['pattern']) || !isset($xref['replace'])) {
$pattern = array();
$replace = array();
- foreach ($this->_xref as $anchor => $text) {
+ foreach ($this->xref as $anchor => $text) {
$xref['pattern'][] = "/<a xref=\"{$anchor}\"><\/a>/";
$xref['replace'][] = "<a href=\"faq/#{$anchor}\">{$text}</a>";
}
}
$answer = preg_replace($xref['pattern'], $xref['replace'], $answer);
}
- return $this->_answer;
+ return $this->answer;
}
}
diff --git a/include/Objects/QASection.php b/include/Objects/QASection.php
index 9148e76..13de5e9 100644
--- a/include/Objects/QASection.php
+++ b/include/Objects/QASection.php
@@ -7,9 +7,9 @@ namespace ScummVM\Objects;
*/
class QASection extends BasicObject
{
- private $_title;
- private $_entries;
- private $_toc;
+ private $title;
+ private $entries;
+ private $toc;
/**
* QASection object constructor.
@@ -20,33 +20,33 @@ class QASection extends BasicObject
*/
public function __construct($data, $section_number, &$xref)
{
- $this->_title = $data['title'];
- $this->_entries = array();
- $this->_toc = array();
+ $this->title = $data['title'];
+ $this->entries = array();
+ $this->toc = array();
parent::toArray($data['entry']);
$count = 1;
foreach ($data['entry'] as $key => $value) {
$qa = new QAEntry($value, $section_number, $count++, $xref);
- $this->_entries[] = $qa;
- $this->_toc[$qa->getHref()] = $qa->getQuestion();
+ $this->entries[] = $qa;
+ $this->toc[$qa->getHref()] = $qa->getQuestion();
}
}
/* Get the title of this section. */
public function getTitle()
{
- return $this->_title;
+ return $this->title;
}
/* Get a list with all question-answer entries for this section. */
public function getEntries()
{
- return $this->_entries;
+ return $this->entries;
}
/* Get the table of contents for this section. */
public function getTOC()
{
- return $this->_toc;
+ return $this->toc;
}
}
diff --git a/include/Objects/Screenshot.php b/include/Objects/Screenshot.php
index 5ffb060..1bce16b 100644
--- a/include/Objects/Screenshot.php
+++ b/include/Objects/Screenshot.php
@@ -6,16 +6,16 @@ namespace ScummVM\Objects;
*/
class Screenshot extends BasicObject
{
- private $_name;
- private $_category;
- private $_files;
+
+ private $category;
+ private $files;
/* The Screenshot object constructor. */
public function __construct($data)
{
- $this->_name = $data['name'];
- $this->_category = $data['category'];
- $this->_files = array();
+ $this->name = $data['name'];
+ $this->category = $data['category'];
+ $this->files = array();
if (isset($data['image'])) {
if (!isset($data['image'][0])) {
parent::toArray($data['image']);
@@ -24,18 +24,21 @@ class Screenshot extends BasicObject
foreach ($data['image'] as $value) {
if (isset($value['range'])) {
$attr = $value['range']['@attributes'];
- if (!isset($attr['from']) || !isset($attr['to']) || !isset($attr['format']) || !strstr($value['file'], '#n#')) {
+ if (!isset($attr['from'])
+ || !isset($attr['to'])
+ || !isset($attr['format'])
+ || !strstr($value['file'], '#n#')) {
throw new \ErrorException('Invalid range format for ' . $value['file']);
}
$pat = str_replace("#n#", $attr['format'], $value['file']);
for ($num = $attr['from']; $num <= $attr['to']; $num++) {
- $this->_files[] = array(
+ $this->files[] = array(
'filename' => sprintf($pat, $num),
'caption' => $value['caption'],
);
}
} else {
- $this->_files[] = array(
+ $this->files[] = array(
'filename' => $value['file'],
'caption' => $value['caption'],
);
@@ -47,18 +50,18 @@ class Screenshot extends BasicObject
/* Get the name. */
public function getName()
{
- return $this->_name;
+ return $this->name;
}
/* Get the category this screenshot belongs too. */
public function getCategory()
{
- return $this->_category;
+ return $this->category;
}
/* Get the list of files, with the base filename as key and the caption as value. */
public function getFiles()
{
- return $this->_files;
+ return $this->files;
}
}
diff --git a/include/Objects/WebLink.php b/include/Objects/WebLink.php
index 4474c63..900e04f 100644
--- a/include/Objects/WebLink.php
+++ b/include/Objects/WebLink.php
@@ -6,34 +6,34 @@ namespace ScummVM\Objects;
*/
class WebLink extends BasicObject
{
- private $_name;
- private $_url;
- private $_description;
+
+ private $url;
+ private $description;
/* WebLink object constructor. */
public function __construct($data)
{
- $this->_name = $data['name'];
- $this->_url = $data['url'];
- $this->_description = $data['description'];
+ $this->name = $data['name'];
+ $this->url = $data['url'];
+ $this->description = $data['description'];
}
/* Get the name of the link. */
public function getName()
{
- return $this->_name;
+ return $this->name;
}
/* Get the URL of the link. */
public function getURL()
{
- return $this->_url;
+ return $this->url;
}
/* Get the description of the link. */
public function getDescription()
{
- return $this->_description;
+ return $this->description;
}
/* Get the user-agent. */
diff --git a/include/Pages/CompatibilityPage.php b/include/Pages/CompatibilityPage.php
index 46f6af3..90deb4b 100644
--- a/include/Pages/CompatibilityPage.php
+++ b/include/Pages/CompatibilityPage.php
@@ -11,26 +11,26 @@ use ScummVM\Models\CompatibilityModel;
*/
class CompatibilityPage extends Controller
{
- protected $_template;
- private $_template_details;
- private $_supportLevelDesc;
- private $_supportLevelClass;
+
+ private $template_details;
+ private $supportLevelDesc;
+ private $supportLevelClass;
/* Constructor. */
public function __construct()
{
parent::__construct();
global $Smarty;
- $this->_template = 'pages/compatibility.tpl';
- $this->_template_details = 'components/compatibility_details.tpl';
- $this->_supportLevelDesc = array(
+ $this->template = 'pages/compatibility.tpl';
+ $this->template_details = 'components/compatibility_details.tpl';
+ $this->supportLevelDesc = array(
'untested' => $Smarty->getConfigVars('compatibilityUntested'),
'broken' => $Smarty->getConfigVars('compatibilityBroken'),
'bugged' => $Smarty->getConfigVars('compatibilityBugged'),
'good' => $Smarty->getConfigVars('compatibilityGood'),
'excellent' => $Smarty->getConfigVars('compatibilityExcellent')
);
- $this->_supportLevelClass = array(
+ $this->supportLevelClass = array(
'untested' => 'pctU',
'broken' => 'pct0',
'bugged' => 'pct50',
@@ -73,14 +73,18 @@ class CompatibilityPage extends Controller
return $this->renderPage(
array(
'title' => preg_replace('/{version}/', $version, $Smarty->getConfigVars('compatibilityTitle')),
- 'content_title' => preg_replace('/{version}/', $version, $Smarty->getConfigVars('compatibilityContentTitle')),
+ 'content_title' => preg_replace(
+ '/{version}/',
+ $version,
+ $Smarty->getConfigVars('compatibilityContentTitle')
+ ),
'version' => $version,
'game' => $game,
'old_layout' => $oldLayout,
- 'support_level_desc' => $this->_supportLevelDesc,
- 'support_level_class' => $this->_supportLevelClass
+ 'support_level_desc' => $this->supportLevelDesc,
+ 'support_level_class' => $this->supportLevelClass
),
- $this->_template_details
+ $this->template_details
);
}
@@ -101,16 +105,20 @@ class CompatibilityPage extends Controller
return $this->renderPage(
array(
'title' => preg_replace('/{version}/', $version, $Smarty->getConfigVars('compatibilityTitle')),
- 'content_title' => preg_replace('/{version}/', $version, $Smarty->getConfigVars('compatibilityContentTitle')),
+ 'content_title' => preg_replace(
+ '/{version}/',
+ $version,
+ $Smarty->getConfigVars('compatibilityContentTitle')
+ ),
'version' => $version,
'compat_data' => $compat_data,
'last_updated' => $last_updated,
'versions' => $versions,
'old_layout' => $oldLayout,
- 'support_level_desc' => $this->_supportLevelDesc,
- 'support_level_class' => $this->_supportLevelClass
+ 'support_level_desc' => $this->supportLevelDesc,
+ 'support_level_class' => $this->supportLevelClass
),
- $this->_template
+ $this->template
);
}
}
diff --git a/include/Pages/ContactPage.php b/include/Pages/ContactPage.php
index 5f18f4d..0c76f54 100644
--- a/include/Pages/ContactPage.php
+++ b/include/Pages/ContactPage.php
@@ -5,13 +5,13 @@ use ScummVM\Controller;
class ContactPage extends Controller
{
- protected $_template;
+
/* Constructor. */
public function __construct()
{
parent::__construct();
- $this->_template = 'pages/contact.tpl';
+ $this->template = 'pages/contact.tpl';
}
/* Display the index page. */
@@ -24,7 +24,7 @@ class ContactPage extends Controller
'title' => $Smarty->getConfigVars('contactTitle'),
'content_title' => $Smarty->getConfigVars('contactContentTitle'),
),
- $this->_template
+ $this->template
);
}
}
diff --git a/include/Pages/CreditsPage.php b/include/Pages/CreditsPage.php
index 5f4d4c8..1abe0f7 100644
--- a/include/Pages/CreditsPage.php
+++ b/include/Pages/CreditsPage.php
@@ -12,7 +12,7 @@ class CreditsPage extends Controller
public function __construct()
{
parent::__construct();
- $this->_template = 'pages/credits.tpl';
+ $this->template = 'pages/credits.tpl';
}
/* Display the index page. */
@@ -27,7 +27,7 @@ class CreditsPage extends Controller
'content_title' => $Smarty->getConfigVars('creditsContentTitle'),
'credits' => $credits,
),
- $this->_template
+ $this->template
);
}
}
diff --git a/include/Pages/DemosPage.php b/include/Pages/DemosPage.php
index 9ec5a83..3cb2246 100644
--- a/include/Pages/DemosPage.php
+++ b/include/Pages/DemosPage.php
@@ -6,13 +6,13 @@ use ScummVM\Models\GameDemosModel;
class DemosPage extends Controller
{
- protected $_template;
+
/* Constructor. */
public function __construct()
{
parent::__construct();
- $this->_template = 'pages/game_demos.tpl';
+ $this->template = 'pages/game_demos.tpl';
}
/* Display the index page. */
@@ -27,7 +27,7 @@ class DemosPage extends Controller
'content_title' => $Smarty->getConfigVars('demosContentTitle'),
'demos' => $demos,
),
- $this->_template
+ $this->template
);
}
}
diff --git a/include/Pages/DocumentationPage.php b/include/Pages/DocumentationPage.php
index f907692..9e4d81f 100644
--- a/include/Pages/DocumentationPage.php
+++ b/include/Pages/DocumentationPage.php
@@ -6,13 +6,13 @@ use ScummVM\Models\DocumentationModel;
class DocumentationPage extends Controller
{
- protected $_template;
+
/* Constructor. */
public function __construct()
{
parent::__construct();
- $this->_template = 'pages/documentation.tpl';
+ $this->template = 'pages/documentation.tpl';
}
/* Display the index page. */
@@ -29,7 +29,7 @@ class DocumentationPage extends Controller
'content_title' => $Smarty->getConfigVars('documentationContentTitle'),
'documents' => $documents,
),
- $this->_template
+ $this->template
);
}
}
diff --git a/include/Pages/DownloadsPage.php b/include/Pages/DownloadsPage.php
index 99c2590..f4691ff 100644
--- a/include/Pages/DownloadsPage.php
+++ b/include/Pages/DownloadsPage.php
@@ -6,19 +6,18 @@ use ScummVM\Models\DownloadsModel;
class DownloadsPage extends Controller
{
- protected $_template;
+
/* Constructor. */
public function __construct()
{
parent::__construct();
- $this->_template = 'pages/downloads.tpl';
+ $this->template = 'pages/downloads.tpl';
}
- function getRecommendedDownloadsJS(&$downloads)
+ private function getRecommendedDownloadsJS(&$downloads)
{
- $js = "var versions = {\n";
-
+ $versions = new \stdClass();
foreach ($downloads as $dsection) {
foreach ($dsection->getSubSections() as $dsubsection) {
foreach ($dsubsection->getItems() as $curItem) {
@@ -41,14 +40,18 @@ class DownloadsPage extends Controller
$extra_text = $data;
}
- $js .= "\t\t\t'{$userAgent}':\t{ 'os':\t'{$name}', 'ver':\t'{$version}', 'desc':\t'{$extra_text}', 'url':\t'{$url}'},\n";
+ $versions->$userAgent = array(
+ 'os' => $name,
+ 'ver' => $version,
+ 'desc' => $extra_text,
+ 'url' => $url,
+ );
}
}
}
}
- $js .= "};\n";
- return $js;
+ return 'var versions = ' . JSON_ENCODE($versions);
}
/* Display the index page. */
@@ -69,7 +72,7 @@ class DownloadsPage extends Controller
'release_debian' => RELEASE_DEBIAN,
'recommendedDownloadsJS' => $recommendedDownloadsJS
),
- $this->_template
+ $this->template
);
}
}
diff --git a/include/Pages/ExceptionsPage.php b/include/Pages/ExceptionsPage.php
index 3f3db98..8598fe9 100644
--- a/include/Pages/ExceptionsPage.php
+++ b/include/Pages/ExceptionsPage.php
@@ -3,13 +3,13 @@ namespace ScummVM\Pages;
class ExceptionsPage extends \ScummVM\Controller
{
- protected $_template;
+
/* Constructor. */
public function __construct()
{
parent::__construct();
- $this->_template = 'components/exception.tpl';
+ $this->template = 'components/exception.tpl';
}
/* Display the index page. */
@@ -23,7 +23,7 @@ class ExceptionsPage extends \ScummVM\Controller
'content_title' => $Smarty->getConfigVars('exceptionsContentTitle'),
'exception' => $exception,
),
- $this->_template
+ $this->template
);
}
}
diff --git a/include/Pages/FAQPage.php b/include/Pages/FAQPage.php
index 8e9ec66..062fdb6 100644
--- a/include/Pages/FAQPage.php
+++ b/include/Pages/FAQPage.php
@@ -6,13 +6,13 @@ use ScummVM\Models\FAQModel;
class FAQPage extends Controller
{
- protected $_template;
+
/* Constructor. */
public function __construct()
{
parent::__construct();
- $this->_template = 'pages/faq.tpl';
+ $this->template = 'pages/faq.tpl';
}
/* Display the index page. */
@@ -29,7 +29,7 @@ class FAQPage extends Controller
'contents' => $contents,
'modified' => $modified,
),
- $this->_template
+ $this->template
);
}
}
diff --git a/include/Pages/FeedsPage.php b/include/Pages/FeedsPage.php
index ef3733a..c448348 100644
--- a/include/Pages/FeedsPage.php
+++ b/include/Pages/FeedsPage.php
@@ -6,15 +6,15 @@ use ScummVM\Models\NewsModel;
class FeedsPage extends Controller
{
- private $_template_rss;
- private $_template_atom;
+ private $template_rss;
+ private $template_atom;
/* Constructor. */
public function __construct()
{
parent::__construct();
- $this->_template_rss = 'pages/feed_rss.tpl';
- $this->_template_atom = 'pages/feed_atom.tpl';
+ $this->template_rss = 'pages/feed_rss.tpl';
+ $this->template_atom = 'pages/feed_atom.tpl';
}
/* Display the index page. */
@@ -22,9 +22,9 @@ class FeedsPage extends Controller
{
$feed = $_GET['f'];
if ($feed == 'atom') {
- $template = $this->_template_atom;
+ $template = $this->template_atom;
} else {
- $template = $this->_template_rss;
+ $template = $this->template_rss;
}
$news_items = NewsModel::getLatestNews(NEWS_ITEMS, true);
diff --git a/include/Pages/GamesPage.php b/include/Pages/GamesPage.php
index 5fef48f..5af6aca 100644
--- a/include/Pages/GamesPage.php
+++ b/include/Pages/GamesPage.php
@@ -6,13 +6,13 @@ use ScummVM\Models\GamesModel;
class GamesPage extends Controller
{
- protected $_template;
+
/* Constructor. */
public function __construct()
{
parent::__construct();
- $this->_template = 'pages/games.tpl';
+ $this->template = 'pages/games.tpl';
}
/* Display the index page. */
@@ -31,7 +31,7 @@ class GamesPage extends Controller
'release_tools' => RELEASE_TOOLS,
'release_debian' => RELEASE_DEBIAN,
),
- $this->_template
+ $this->template
);
}
}
diff --git a/include/Pages/LinksPage.php b/include/Pages/LinksPage.php
index 4f4f95d..1a96994 100644
--- a/include/Pages/LinksPage.php
+++ b/include/Pages/LinksPage.php
@@ -6,13 +6,13 @@ use ScummVM\Models\LinksModel;
class LinksPage extends Controller
{
- protected $_template;
+
/* Constructor. */
public function __construct()
{
parent::__construct();
- $this->_template = 'pages/links.tpl';
+ $this->template = 'pages/links.tpl';
}
/* Display the index page. */
@@ -27,7 +27,7 @@ class LinksPage extends Controller
'content_title' => $Smarty->getConfigVars('linksContentTitle'),
'links' => $links,
),
- $this->_template
+ $this->template
);
}
}
diff --git a/include/Pages/NewsPage.php b/include/Pages/NewsPage.php
index 3ec9c7f..5030577 100644
--- a/include/Pages/NewsPage.php
+++ b/include/Pages/NewsPage.php
@@ -7,13 +7,13 @@ use ScummVM\Models\ScreenshotsModel;
class NewsPage extends Controller
{
- protected $_template;
+
/* Constructor. */
public function __construct()
{
parent::__construct();
- $this->_template = 'pages/news.tpl';
+ $this->template = 'pages/news.tpl';
}
/* Display the index page. */
@@ -50,7 +50,7 @@ class NewsPage extends Controller
'news_items' => $news_items,
'news_archive_link' => false,
),
- $this->_template
+ $this->template
);
}
@@ -75,7 +75,7 @@ class NewsPage extends Controller
'news_archive_link' => true,
'random_shot' => $random_shot,
),
- $this->_template
+ $this->template
);
}
}
diff --git a/include/Pages/PressPage.php b/include/Pages/PressPage.php
index 7e3cd3f..c8dc3d1 100644
--- a/include/Pages/PressPage.php
+++ b/include/Pages/PressPage.php
@@ -6,13 +6,13 @@ use ScummVM\Models\ArticleModel;
class PressPage extends Controller
{
- protected $_template;
+
/* Constructor. */
public function __construct()
{
parent::__construct();
- $this->_template = 'pages/press.tpl';
+ $this->template = 'pages/press.tpl';
}
/* Display the index page. */
@@ -27,7 +27,7 @@ class PressPage extends Controller
'content_title' => $Smarty->getConfigVars('pressContentTitle'),
'articles' => $articles,
),
- $this->_template
+ $this->template
);
}
}
diff --git a/include/Pages/PressSnowberryPage.php b/include/Pages/PressSnowberryPage.php
index 96aa355..4457b9a 100644
--- a/include/Pages/PressSnowberryPage.php
+++ b/include/Pages/PressSnowberryPage.php
@@ -6,13 +6,13 @@ use ScummVM\Models\ArticleModel;
class PressSnowberryPage extends Controller
{
- protected $_template;
+
/* Constructor. */
public function __construct()
{
parent::__construct();
- $this->_template = 'pages/press_snowberry.tpl';
+ $this->template = 'pages/press_snowberry.tpl';
}
/* Display the index page. */
@@ -27,7 +27,7 @@ class PressSnowberryPage extends Controller
'content_title' => $Smarty->getConfigVars('pressSnowberryContentTitle'),
'articles' => $articles,
),
- $this->_template
+ $this->template
);
}
}
diff --git a/include/Pages/ScreenshotsPage.php b/include/Pages/ScreenshotsPage.php
index b72a1f4..e0ff2e1 100644
--- a/include/Pages/ScreenshotsPage.php
+++ b/include/Pages/ScreenshotsPage.php
@@ -6,15 +6,15 @@ use ScummVM\Models\ScreenshotsModel;
class ScreenshotsPage extends Controller
{
- protected $_template;
- private $_template_category;
+
+ private $template_category;
/* Constructor. */
public function __construct()
{
parent::__construct();
- $this->_template = 'pages/screenshots.tpl';
- $this->_template_category = 'pages/screenshots_category.tpl';
+ $this->template = 'pages/screenshots.tpl';
+ $this->template_category = 'pages/screenshots_category.tpl';
}
/* Display the index page. */
@@ -46,7 +46,7 @@ class ScreenshotsPage extends Controller
'screenshots' => $screenshot,
'random_shot' => $random_shot,
),
- $this->_template
+ $this->template
);
}
@@ -76,7 +76,7 @@ class ScreenshotsPage extends Controller
'category' => $category,
'game' => $game,
),
- $this->_template_category
+ $this->template_category
);
}
diff --git a/include/Pages/SubprojectsPage.php b/include/Pages/SubprojectsPage.php
index 7e462ed..a884207 100644
--- a/include/Pages/SubprojectsPage.php
+++ b/include/Pages/SubprojectsPage.php
@@ -6,13 +6,13 @@ use ScummVM\Models\SubprojectsModel;
class SubprojectsPage extends Controller
{
- protected $_template;
+
/* Constructor. */
public function __construct()
{
parent::__construct();
- $this->_template = 'pages/subprojects.tpl';
+ $this->template = 'pages/subprojects.tpl';
}
/* Display the index page. */
@@ -27,7 +27,7 @@ class SubprojectsPage extends Controller
'content_title' => $Smarty->getConfigVars('subprojectsContentTitle'),
'subprojects' => $subprojects,
),
- $this->_template
+ $this->template
);
}
}
diff --git a/include/XMLParser.php b/include/XMLParser.php
index 8f8be05..57046a5 100644
--- a/include/XMLParser.php
+++ b/include/XMLParser.php
@@ -22,9 +22,9 @@ class XMLParser
const NS_XHTML = 'http://www.w3.org/TR/xhtml1/';
private static $empty_elements = array('br', 'hr', 'img');
- private $_tree;
- private $_data;
- private $_ptr;
+ private $tree;
+ private $data;
+ private $ptr;
/**
* Constructor.
@@ -34,9 +34,9 @@ class XMLParser
*/
public function __construct()
{
- $this->_tree = array();
- $this->_data = null;
- $this->_ptr = null;
+ $this->tree = array();
+ $this->data = null;
+ $this->ptr = null;
}
/**
@@ -125,7 +125,8 @@ class XMLParser
/* Parse the data and free the parser resource. */
if (!xml_parse($parser, $xml, true)) {
$error = "\n\nError code: " . xml_get_error_code($parser) . "\n";
- $error .= "Line: " . xml_get_current_line_number($parser) . ", character: " . xml_get_current_column_number($parser) . "\n";
+ $error .= "Line: " . xml_get_current_line_number($parser)
+ . ", character: " . xml_get_current_column_number($parser) . "\n";
$error .= "Error message: " . xml_error_string(xml_get_error_code($parser)) . "\n";
xml_parser_free($parser);
throw new \ErrorException(self::PARSER_ERROR . $error);
@@ -135,7 +136,7 @@ class XMLParser
* The root element will contain an array with an empty key, so we can
* skip that one right now.
*/
- $tree = $this->_tree[''];
+ $tree = $this->tree[''];
$this->simplifyArray($tree);
return $tree;
}
@@ -183,14 +184,14 @@ class XMLParser
}
/* Get the key for the last node in the tree. */
- end($this->_tree);
- $key = key($this->_tree);
+ end($this->tree);
+ $key = key($this->tree);
/* Store the position so we can add the data later. */
- $this->_ptr = &$this->_tree[$key][$name];
+ $this->ptr = &$this->tree[$key][$name];
/* Store a reference the attributes. */
if ($element != null) {
- $this->_ptr['@attributes'] = &$element;
+ $this->ptr['@attributes'] = &$element;
} else {
/**
* For one reason or another that escapes me, we must do this,
@@ -198,13 +199,13 @@ class XMLParser
* in endElement() by overwriting the empty elements created
* here.
*/
- $this->_ptr[] = &$element;
+ $this->ptr[] = &$element;
}
/**
* Store the reference directly in the tree until this node (and
* it's children) are done. Will get removed in endElement().
*/
- $this->_tree[$name] = &$element;
+ $this->tree[$name] = &$element;
}
}
@@ -218,7 +219,7 @@ class XMLParser
*/
private function getElement($parser, $data)
{
- $this->_data .= $data;
+ $this->data .= $data;
}
/**
@@ -246,20 +247,20 @@ class XMLParser
}
/* Otherwise we can just add the data. */
} else {
- $data = trim($this->_data);
+ $data = trim($this->data);
if (!empty($data)) {
/* If we got an empty element in the array, overwrite it. */
- $pos = count($this->_ptr);
- if (is_null($this->_ptr[($pos-1)])) {
+ $pos = count($this->ptr);
+ if (is_null($this->ptr[($pos-1)])) {
$pos--;
}
- $this->_ptr[$pos] = $data;
+ $this->ptr[$pos] = $data;
}
/* Reset the internal data holder. */
- $this->_data = null;
+ $this->data = null;
/* Remove the reference. */
- $pop = array_pop($this->_tree);
+ $pop = array_pop($this->tree);
}
}
Commit: 2725908348910fa6debf08a13dc1cb4a9ce91e3f
https://github.com/scummvm/scummvm-web/commit/2725908348910fa6debf08a13dc1cb4a9ce91e3f
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Additional PSR2 cleanup
Changed paths:
A include/Config.php
R include/config.inc.php
include/I18N.php
index.php
diff --git a/include/Config.php b/include/Config.php
new file mode 100644
index 0000000..452a597
--- /dev/null
+++ b/include/Config.php
@@ -0,0 +1,65 @@
+<?php
+namespace ScummVM;
+
+class Config
+{
+ public function __construct()
+ {
+ /* Current version. */
+ define('RELEASE', '2.0.0');
+ define('RELEASE_TOOLS', '2.0.0');
+ define('RELEASE_DEBIAN', '2.0.0');
+
+ /* Version when the percentages on the compat page were removed */
+ define('COMPAT_LAYOUT_CHANGE', '1.7.0');
+
+ /* News items on the front page. */
+ define('NEWS_ITEMS', 5);
+
+ /* Number of heroes header files. */
+ define('HEROES_NUM', 6);
+
+ /* Base URL to the website. */
+ if ($_SERVER['SERVER_PORT'] == '80') {
+ $url = "http://{$_SERVER['SERVER_NAME']}";
+ } elseif ($_SERVER['SERVER_PORT'] == '443') {
+ $url = "https://{$_SERVER['SERVER_NAME']}";
+ } else {
+ $url = "http://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}";
+ }
+ if (substr($url, -1) != '/') {
+ $url .= '/';
+ }
+ define('URL_BASE', $url);
+
+ /* Paths. */
+ define('DIR_DATA', 'data');
+ define('DIR_NEWS', 'data/news');
+ define('DIR_LANG', 'lang');
+ define('DIR_COMPAT', 'data/compatibility');
+ define('DIR_DOWNLOADS', '/downloads');
+ define('DIR_SCREENSHOTS', '/data/screenshots');
+
+ /**
+ * Smarty configuration. The Smarty team does not recommend putting any of the
+ * directories used under the web server root. 'SMARTY_DIR_COMPILE' and
+ * 'SMARTY_DIR_CACHE' must be writable by the web server (chown).
+ */
+ define('SMARTY_DIR', 'vendor/smarty/smarty/libs/');
+ define('SMARTY_DIR_TEMPLATE', 'templates');
+ define('SMARTY_DIR_COMPILE', SMARTY_DIR . '/template_c');
+ define('SMARTY_DIR_CACHE', SMARTY_DIR . '/cache');
+ define('SMARTY_DIR_CONFIG', SMARTY_DIR . '/config');
+
+ /**
+ * Smarty caching options, makes it possible to cache the generated HTML to
+ * speed things up. More information is available at [1].
+ *
+ * [1] http://www.smarty.net/manual/en/caching.php
+ */
+ define('SMARTY_CACHING_ENABLE', 0);
+ define('SMARTY_CACHING_LIFETIME', (60 * 60));
+ define('SMARTY_CACHING_COMPILE_CHECK', true); # used when developing
+ define('SMARTY_CACHING_FORCE_RECHECK', true); # used when developing
+ }
+}
diff --git a/include/I18N.php b/include/I18N.php
index 1e28d4b..c4d6ae0 100644
--- a/include/I18N.php
+++ b/include/I18N.php
@@ -1,10 +1,12 @@
<?php
namespace ScummVM;
+require_once __DIR__ . '/../vendor/autoload.php';
+
use ScummVM\Objects\News;
use ScummVM\Models\NewsModel;
-define('DIR_NEWS', 'data/news');
+// define('DIR_NEWS', 'data/news');
class I18N
{
diff --git a/include/config.inc.php b/include/config.inc.php
deleted file mode 100644
index 323e21f..0000000
--- a/include/config.inc.php
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-namespace ScummVM;
-
-/* Current version. */
-define('RELEASE', '2.0.0');
-define('RELEASE_TOOLS', '2.0.0');
-define('RELEASE_DEBIAN', '2.0.0');
-/* Version when the percentages on the compat page were removed */
-define('COMPAT_LAYOUT_CHANGE', '1.7.0');
-
-/* News items on the front page. */
-define('NEWS_ITEMS', 5);
-/* Number of heroes header files. */
-define('HEROES_NUM', 6);
-/* Time zone to use for news items etc. */
-date_default_timezone_set("UTC");
-
-/* Base URL to the website. */
-if ($_SERVER['SERVER_PORT'] == '80') {
- $url = "http://{$_SERVER['SERVER_NAME']}";
-} elseif ($_SERVER['SERVER_PORT'] == '443') {
- $url = "https://{$_SERVER['SERVER_NAME']}";
-} else {
- $url = "http://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}";
-}
-
-if (substr($url, -1) != '/') {
- $url .= '/';
-}
-define('URL_BASE', $url);
-unset($url);
-
-/* Paths. */
-define('DIR_INCLUDE', 'include');
-define('DIR_DATA', 'data');
-define('DIR_NEWS', 'data/news');
-define('DIR_LANG', 'lang');
-define('DIR_COMPAT', 'data/compatibility');
-define('DIR_DOWNLOADS', '/downloads');
-define('DIR_SCREENSHOTS', '/data/screenshots');
-
-/**
- * Smarty configuration. The Smarty team does not recommend putting any of the
- * directories used under the web server root. 'SMARTY_DIR_COMPILE' and
- * 'SMARTY_DIR_CACHE' must be writable by the web server (chown).
- */
-define('SMARTY_DIR', 'vendor/smarty/smarty/libs/');
-define('SMARTY_DIR_TEMPLATE', 'templates');
-define('SMARTY_DIR_COMPILE', SMARTY_DIR . '/template_c');
-define('SMARTY_DIR_CACHE', SMARTY_DIR . '/cache');
-define('SMARTY_DIR_CONFIG', SMARTY_DIR . '/config');
-/**
- * Smarty caching options, makes it possible to cache the generated HTML to
- * speed things up. More information is available at [1].
- *
- * [1] http://www.smarty.net/manual/en/caching.php
- */
-define('SMARTY_CACHING_ENABLE', 0);
-define('SMARTY_CACHING_LIFETIME', (60 * 60));
-define('SMARTY_CACHING_COMPILE_CHECK', true); # used when developing
-define('SMARTY_CACHING_FORCE_RECHECK', true); # used when developing
diff --git a/index.php b/index.php
index d46afeb..244737f 100644
--- a/index.php
+++ b/index.php
@@ -60,9 +60,12 @@ if (empty($_COOKIE['clear_lang'])) {
}
/* Load the configuration. */
-require_once('include/config.inc.php');
-/* Set up the include path. */
-set_include_path(get_include_path() . PATH_SEPARATOR . DIR_INCLUDE);
+new Config();
+
+/* Time zone to use for news items etc. */
+date_default_timezone_set("UTC");
+
+// set_include_path(get_include_path() . PATH_SEPARATOR . DIR_INCLUDE);
error_reporting(E_ALL ^ E_NOTICE); // disable notices
if (!is_writeable(SMARTY_DIR_COMPILE)) {
Commit: eb47e74aae6fa7d027b753f5245c2b33b8d83afc
https://github.com/scummvm/scummvm-web/commit/eb47e74aae6fa7d027b753f5245c2b33b8d83afc
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Delete old poll site
Changed paths:
R data/poll/Greenbar.gif
R data/poll/Orangebar.gif
R data/poll/Redbar.gif
R data/poll/Yellowbar.gif
R data/poll/arturom-thumb.jpg
R data/poll/arturom.jpg
R data/poll/draven-thumb.jpg
R data/poll/draven.jpg
R data/poll/index.php
R data/poll/jeanm-thumb.png
R data/poll/jeanm.png
diff --git a/data/poll/Greenbar.gif b/data/poll/Greenbar.gif
deleted file mode 100644
index 02bdc9d..0000000
Binary files a/data/poll/Greenbar.gif and /dev/null differ
diff --git a/data/poll/Orangebar.gif b/data/poll/Orangebar.gif
deleted file mode 100644
index c8644c3..0000000
Binary files a/data/poll/Orangebar.gif and /dev/null differ
diff --git a/data/poll/Redbar.gif b/data/poll/Redbar.gif
deleted file mode 100644
index a617a72..0000000
Binary files a/data/poll/Redbar.gif and /dev/null differ
diff --git a/data/poll/Yellowbar.gif b/data/poll/Yellowbar.gif
deleted file mode 100644
index 25126a7..0000000
Binary files a/data/poll/Yellowbar.gif and /dev/null differ
diff --git a/data/poll/arturom-thumb.jpg b/data/poll/arturom-thumb.jpg
deleted file mode 100644
index 3d5b70c..0000000
Binary files a/data/poll/arturom-thumb.jpg and /dev/null differ
diff --git a/data/poll/arturom.jpg b/data/poll/arturom.jpg
deleted file mode 100644
index 6d8fce8..0000000
Binary files a/data/poll/arturom.jpg and /dev/null differ
diff --git a/data/poll/draven-thumb.jpg b/data/poll/draven-thumb.jpg
deleted file mode 100644
index 77a6727..0000000
Binary files a/data/poll/draven-thumb.jpg and /dev/null differ
diff --git a/data/poll/draven.jpg b/data/poll/draven.jpg
deleted file mode 100644
index 3683ca3..0000000
Binary files a/data/poll/draven.jpg and /dev/null differ
diff --git a/data/poll/index.php b/data/poll/index.php
deleted file mode 100644
index b770a49..0000000
--- a/data/poll/index.php
+++ /dev/null
@@ -1,109 +0,0 @@
-<?php
-
-/*
- * Downloads Page for ScummVM
- * by Jeremy Newman <jnewman at dracowulf.com>
- *
- */
-
-// set this for position of this file relative
-$file_root = "..";
-
-// load libraries
-require($file_root."/include/"."incl.php");
-
-// start of html
-html_page_header("ScummVM :: Website Revamp contest poll");
-
-//display welcome table
-html_content_begin('Website Revamp contest poll');
-
-?>
- <div class="par-item">
- <div class="par-head">
- Website Revamp contest poll
- </div>
-
- <div class="par-content">
- <h1>Website Revamp contest poll -- closed, draven declared winner</h1>
-
- <p>The three finalists of the website revamp contest can be seen here. The contest was won by draven, you can see the final standings below</p>
-
- <center>
- <table cellpadding="10" cellspacing="10">
- <tr>
- <td align="center"><a href="arturom.jpg" target="_blank"><img src="arturom-thumb.jpg" height="120" width="120" alt="arturom"><br>arturom</a></td>
- <td align="center"><a href="draven.jpg" target="_blank"><img src="draven-thumb.jpg" height="120" width="120" alt="draven"><br>draven</a></td>
- <td align="center"><a href="jeanm.png" target="_blank"><img src="jeanm-thumb.png" height="120" width="120" alt="jeanm"><br>jeanm</a></td>
- </tr>
-
-<tr><td colspan="3" align="center">
-<br>
-<table border="0" bgcolor="#EEEEEE" cellspacing="0" cellpadding="3">
- <tr>
- <td colspan="2"><b>Which design do you prefer for the new ScummVM website?</b></td>
- <td colspan="1"> </td>
- </tr>
- <tr>
- <td colspan="2"> </td>
- <td valign="bottom" align="center">
- <b>Votes</b></td>
- </tr>
- <tr>
- <td align="right">
- I just love arturom!</td>
- <td align="left">
- <small><img src="Redbar.gif" height="12" width="36"> 12%</small></td>
- <td align="right">
- 165</td>
- </tr>
- <tr>
- <td align="right">
- Oh, draven is *sooo* cool!</td>
- <td align="left">
- <small><img src="Orangebar.gif" height="12" width="166"> 55%</small></td>
- <td align="right">
- 769</td>
- </tr>
- <tr>
- <td align="right">
- The one and only choice is ... jeanm!</td>
- <td align="left">
- <small><img src="Yellowbar.gif" height="12" width="65"> 21%</small></td>
- <td align="right">
- 299</td>
- </tr>
- <tr>
- <td align="right">
- The old website is kinda cute... so ... green... and purple...</td>
- <td align="left">
- <small><img src="Greenbar.gif" height="12" width="37"> 12%</small></td>
- <td align="right">
- 166</td>
- </tr>
- <tr>
- <td colspan="3">
- </td>
- </tr>
- <tr>
- <td colspan="3" align="right">
- <b>1,399 votes total</b></td>
- </tr>
-</table>
-
-
-</td></tr>
- </table>
-</center>
-
-<br>
-
- </div>
-</div>
-
-<?php
-
-html_content_end();
-html_page_footer();
-
-?>
diff --git a/data/poll/jeanm-thumb.png b/data/poll/jeanm-thumb.png
deleted file mode 100644
index e475b12..0000000
Binary files a/data/poll/jeanm-thumb.png and /dev/null differ
diff --git a/data/poll/jeanm.png b/data/poll/jeanm.png
deleted file mode 100644
index 7337b8a..0000000
Binary files a/data/poll/jeanm.png and /dev/null differ
Commit: e0f5656d84c26fd95011dcde785eeb35f7981581
https://github.com/scummvm/scummvm-web/commit/e0f5656d84c26fd95011dcde785eeb35f7981581
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Code format cloud page
Changed paths:
c/index.php
diff --git a/c/index.php b/c/index.php
index 3445ea2..26000d6 100644
--- a/c/index.php
+++ b/c/index.php
@@ -1,59 +1,61 @@
<!doctype html>
<html>
- <head>
- <title>ScummVM</title>
- <meta charset="utf-8"/>
- <link rel="stylesheet" type="text/css" href="/css/cloud-style.css"/>
- </head>
- <body>
- <div class="container">
- <div class='header'>
- <center><img src="/images/big-logo.png"/></center>
- </div>
- <div class="content">
- <p>Now please enter this code in ScummVM:</p>
- <?php
- function crc16($data) { //"CRC16_CCITT_FALSE"
- $crc = 0xFFFF;
- for ($i = 0; $i < strlen($data); ++$i) {
- $x = (($crc >> 8) ^ ord($data[$i])) & 0xFF;
- $x ^= $x >> 4;
- $crc = (($crc << 8) ^ ($x << 12) ^ ($x << 5) ^ $x) & 0xFFFF;
- }
- return $crc;
- }
+ <head>
+ <title>ScummVM</title>
+ <meta charset="utf-8"/>
+ <link rel="stylesheet" type="text/css" href="/css/cloud-style.css"/>
+ </head>
+ <body>
+ <div class="container">
+ <div class='header'>
+ <center><img src="/images/big-logo.png"/></center>
+ </div>
+ <div class="content">
+ <p>Now please enter this code in ScummVM:</p>
+ <?php
+ function crc16($data)
+ {
+ //"CRC16_CCITT_FALSE"
+ $crc = 0xFFFF;
+ for ($i = 0; $i < strlen($data); ++$i) {
+ $x = (($crc >> 8) ^ ord($data[$i])) & 0xFF;
+ $x ^= $x >> 4;
+ $crc = (($crc << 8) ^ ($x << 12) ^ ($x << 5) ^ $x) & 0xFFFF;
+ }
+ return $crc;
+ }
- if (isset($_GET["code"])) {
- $hashchars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ?!";
+ if (isset($_GET["code"])) {
+ $hashchars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ?!";
- //remove "bad" characters from the given code:
- $code = preg_replace("/[^_\-\/\\a-z0-9]/i", "", $_GET["code"]);
+ //remove "bad" characters from the given code:
+ $code = preg_replace("/[^_\-\/\\a-z0-9]/i", "", $_GET["code"]);
- //append code's crc16 to the code
- $crc = crc16($code);
- $code .= $hashchars[($crc & 0x003F)];
- $code .= $hashchars[($crc & 0x0FC0) >> 6];
- $code .= $hashchars[($crc & 0xF000) >> 12];
+ //append code's crc16 to the code
+ $crc = crc16($code);
+ $code .= $hashchars[($crc & 0x003F)];
+ $code .= $hashchars[($crc & 0x0FC0) >> 6];
+ $code .= $hashchars[($crc & 0xF000) >> 12];
- //break the code into pieces of 6 chars
- //and calculate the checksum character for each piece
- $len = strlen($code);
- $new_code = "";
- for ($i = 0; $i < $len; $i+=6) {
- $bits = 0x2A;
- for ($j = 0; $j < 6 && $i + $j < $len; ++$j) {
- $byte = ord($code[$i + $j]);
- $bits = $bits ^ $byte;
- $new_code .= $code[$i + $j];
- }
- $new_code .= $hashchars[$bits % 64]." ";
- }
+ //break the code into pieces of 6 chars
+ //and calculate the checksum character for each piece
+ $len = strlen($code);
+ $new_code = "";
+ for ($i = 0; $i < $len; $i+=6) {
+ $bits = 0x2A;
+ for ($j = 0; $j < 6 && $i + $j < $len; ++$j) {
+ $byte = ord($code[$i + $j]);
+ $bits = $bits ^ $byte;
+ $new_code .= $code[$i + $j];
+ }
+ $new_code .= $hashchars[$bits % 64]." ";
+ }
- //show the "new code" - groups with checksums
- echo "<b class='code'>".$new_code."</b>";
- }
- ?>
- </div>
- </div>
- </body>
+ //show the "new code" - groups with checksums
+ echo "<b class='code'>".$new_code."</b>";
+ }
+ ?>
+ </div>
+ </div>
+ </body>
</html>
Commit: 7afd0daf3f2cbd4f0fa6201cc01579f050b03e75
https://github.com/scummvm/scummvm-web/commit/7afd0daf3f2cbd4f0fa6201cc01579f050b03e75
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Use OO for objects
Changed paths:
A include/Objects/Section.php
include/Objects/Article.php
include/Objects/BasicObject.php
include/Objects/CSection.php
include/Objects/CompatGame.php
include/Objects/DSection.php
include/Objects/Document.php
include/Objects/File.php
include/Objects/GameDemo.php
include/Objects/MenuItem.php
include/Objects/Person.php
include/Objects/WebLink.php
diff --git a/include/Objects/Article.php b/include/Objects/Article.php
index 9aef327..beeec14 100644
--- a/include/Objects/Article.php
+++ b/include/Objects/Article.php
@@ -14,18 +14,12 @@ class Article extends BasicObject
/* Article object constructor. */
public function __construct($data)
{
- $this->name = $data['name'];
+ parent::__construct($data);
$this->url = $data['url'];
$this->language = $data['language'];
$this->posted = $data['posted'];
}
- /* Get the name. */
- public function getName()
- {
- return $this->name;
- }
-
/* Get the URL. */
public function getURL()
{
diff --git a/include/Objects/BasicObject.php b/include/Objects/BasicObject.php
index e207226..b5e4077 100644
--- a/include/Objects/BasicObject.php
+++ b/include/Objects/BasicObject.php
@@ -8,6 +8,25 @@ namespace ScummVM\Objects;
abstract class BasicObject
{
protected $name;
+ protected $description;
+
+ public function __construct($data)
+ {
+ $this->description = $data['description'];
+ $this->name = $data['name'];
+ }
+
+ /* Get the name. */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
/**
* If the input array doesn't contain the numerical key 0, wrap it inside
* an array. This functions operates on the data directly.
diff --git a/include/Objects/CSection.php b/include/Objects/CSection.php
index 59203f8..7e7f666 100644
--- a/include/Objects/CSection.php
+++ b/include/Objects/CSection.php
@@ -5,19 +5,15 @@ namespace ScummVM\Objects;
* The Section class represens a section (or a subsection) on the credits page
* on the website.
*/
-class CSection extends BasicObject
+class CSection extends Section
{
- private $title;
private $groups;
- private $subsections;
private $paragraphs;
- private $anchor;
/* CSection object constructor. */
public function __construct($data)
{
- $this->title = $data['title'];
- $this->anchor = $data['anchor'];
+ parent::__construct($data);
$this->groups = array();
$this->subsections = array();
$this->paragraphs = array();
@@ -53,18 +49,6 @@ class CSection extends BasicObject
}
}
- /* Get the title. */
- public function getTitle()
- {
- return $this->title;
- }
-
- /* Get the anchor. */
- public function getAnchor()
- {
- return $this->anchor;
- }
-
/* Get the optional list of groups. */
public function getGroups()
{
diff --git a/include/Objects/CompatGame.php b/include/Objects/CompatGame.php
index 71fd0bd..1b251cc 100644
--- a/include/Objects/CompatGame.php
+++ b/include/Objects/CompatGame.php
@@ -14,7 +14,7 @@ class CompatGame extends BasicObject
/* Project object constructor. */
public function __construct($data)
{
- $this->name = $data['name'];
+ parent::__construct($data);
$this->target = $data['target'];
// In old compat pages we used 'percent' instead of 'support_level'.
// we still want to support those thus we check whether the old tag
@@ -27,12 +27,6 @@ class CompatGame extends BasicObject
$this->notes = $data['notes'];
}
- /* Get the name. */
- public function getName()
- {
- return $this->name;
- }
-
/* Get the target name. */
public function getTarget()
{
diff --git a/include/Objects/DSection.php b/include/Objects/DSection.php
index 1d16072..5780dfa 100644
--- a/include/Objects/DSection.php
+++ b/include/Objects/DSection.php
@@ -4,19 +4,15 @@ namespace ScummVM\Objects;
/**
* The DSection object represents a section on the downloads page.
*/
-class DSection extends BasicObject
+class DSection extends Section
{
- private $title;
- private $anchor;
private $baseurl;
private $baseturl;
- private $subsections;
/* DSection object constructor. */
public function __construct($data)
{
- $this->title = $data['title'];
- $this->anchor = $data['anchor'];
+ parent::__construct($data);
$this->baseurl = $data['baseurl'];
$this->baseturl = $data['baseturl'];
$this->subsections = array();
@@ -27,17 +23,6 @@ class DSection extends BasicObject
}
}
- /* Get the title. */
- public function getTitle()
- {
- return $this->title;
- }
-
- /* Get the anchor name. */
- public function getAnchor()
- {
- return $this->anchor;
- }
/* Get the base URL. */
public function getBaseURL()
diff --git a/include/Objects/Document.php b/include/Objects/Document.php
index 37db502..eda8503 100644
--- a/include/Objects/Document.php
+++ b/include/Objects/Document.php
@@ -7,20 +7,12 @@ namespace ScummVM\Objects;
class Document extends BasicObject
{
private $url;
- private $description;
/* Document object constructor. */
public function __construct($data)
{
- $this->name = $data['name'];
+ parent::__construct($data);
$this->url = $data['url'];
- $this->description = $data['description'];
- }
-
- /* Get the name. */
- public function getName()
- {
- return $this->name;
}
/* Get the URL. */
@@ -28,10 +20,4 @@ class Document extends BasicObject
{
return $this->url;
}
-
- /* Get the description. */
- public function getDescription()
- {
- return $this->description;
- }
}
diff --git a/include/Objects/File.php b/include/Objects/File.php
index 6b91c70..f68197e 100644
--- a/include/Objects/File.php
+++ b/include/Objects/File.php
@@ -15,8 +15,8 @@ class File extends BasicObject
public function __construct($data, $baseurl = null, $baseturl = null)
{
+ parent::__construct($data);
$this->category_icon = $data['category_icon'];
- $this->name = $data['name'];
$this->extra_info = $data['extra_info'];
$this->type = strtolower($data['type']);
$this->user_agent = isset($data["user_agent"]) ? $data["user_agent"] : "";
@@ -109,12 +109,6 @@ class File extends BasicObject
return $this->_url;
}
- /* Get the name. */
- public function getName()
- {
- return $this->name;
- }
-
/* Get the type. */
public function getType()
{
diff --git a/include/Objects/GameDemo.php b/include/Objects/GameDemo.php
index 443b636..53eb8bf 100644
--- a/include/Objects/GameDemo.php
+++ b/include/Objects/GameDemo.php
@@ -14,18 +14,12 @@ class GameDemo extends BasicObject
/* GameDemo object constructor. */
public function __construct($data)
{
- $this->name = $data['name'];
+ parent::__construct($data);
$this->url = $data['url'];
$this->target = $data['target'];
$this->category = isset($data['category']) ? $data['category'] : $data['target'];
}
- /* Get the name of the demo. */
- public function getName()
- {
- return $this->name;
- }
-
/* Get the download URL for the demo. */
public function getURL()
{
diff --git a/include/Objects/MenuItem.php b/include/Objects/MenuItem.php
index 098c4a7..03e66ad 100644
--- a/include/Objects/MenuItem.php
+++ b/include/Objects/MenuItem.php
@@ -13,7 +13,7 @@ class MenuItem extends BasicObject
/* Menu object constructor. */
public function __construct($data)
{
- $this->name = $data['name'];
+ parent::__construct($data);
$this->class = $data['class'];
$this->entries = array();
foreach ($data['link'] as $key => $value) {
@@ -21,12 +21,6 @@ class MenuItem extends BasicObject
}
}
- /* Get the name. */
- public function getName()
- {
- return $this->name;
- }
-
/* Get the CSS class. */
public function getClass()
{
diff --git a/include/Objects/Person.php b/include/Objects/Person.php
index 0a6e22d..c35a578 100644
--- a/include/Objects/Person.php
+++ b/include/Objects/Person.php
@@ -7,22 +7,13 @@ namespace ScummVM\Objects;
*/
class Person extends BasicObject
{
-
private $alias;
- private $description;
/* Person object constructor. */
- public function __construct($args)
- {
- $this->name = $args['name'];
- $this->alias = $args['alias'];
- $this->description = $args['description'];
- }
-
- /* Get the name. */
- public function getName()
+ public function __construct($data)
{
- return $this->name;
+ parent::__construct($data);
+ $this->alias = $data['alias'];
}
/* Get the alias. */
@@ -30,10 +21,4 @@ class Person extends BasicObject
{
return $this->alias;
}
-
- /* Get the description. */
- public function getDescription()
- {
- return $this->description;
- }
}
diff --git a/include/Objects/Section.php b/include/Objects/Section.php
new file mode 100644
index 0000000..e475859
--- /dev/null
+++ b/include/Objects/Section.php
@@ -0,0 +1,37 @@
+<?php
+namespace ScummVM\Objects;
+
+/**
+ * The Section class is inherited by all other Sections and houses all common
+ * functions.
+ */
+abstract class Section extends BasicObject
+{
+ protected $title;
+ protected $anchor;
+ protected $subsections;
+
+ public function __construct($data)
+ {
+ $this->title = $data['title'];
+ $this->anchor = $data['anchor'];
+ }
+
+ /* Get the title. */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /* Get the anchor. */
+ public function getAnchor()
+ {
+ return $this->anchor;
+ }
+
+ /* Get the optional list of subsections. */
+ public function getSubSections()
+ {
+ return $this->subsections;
+ }
+}
diff --git a/include/Objects/WebLink.php b/include/Objects/WebLink.php
index 900e04f..f44d283 100644
--- a/include/Objects/WebLink.php
+++ b/include/Objects/WebLink.php
@@ -6,22 +6,13 @@ namespace ScummVM\Objects;
*/
class WebLink extends BasicObject
{
-
private $url;
- private $description;
/* WebLink object constructor. */
public function __construct($data)
{
- $this->name = $data['name'];
+ parent::__construct($data);
$this->url = $data['url'];
- $this->description = $data['description'];
- }
-
- /* Get the name of the link. */
- public function getName()
- {
- return $this->name;
}
/* Get the URL of the link. */
@@ -30,12 +21,6 @@ class WebLink extends BasicObject
return $this->url;
}
- /* Get the description of the link. */
- public function getDescription()
- {
- return $this->description;
- }
-
/* Get the user-agent. */
public function getUserAgent()
{
Commit: 8a51f21f0c27ebc60b3da81620ab7b6cff842862
https://github.com/scummvm/scummvm-web/commit/8a51f21f0c27ebc60b3da81620ab7b6cff842862
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Rename Section objects
Changed paths:
A include/Objects/BasicSection.php
A include/Objects/CreditsSection.php
A include/Objects/DownloadsSection.php
A include/Objects/FaqEntry.php
A include/Objects/FaqSection.php
R include/Objects/CSection.php
R include/Objects/DSection.php
R include/Objects/QAEntry.php
R include/Objects/QASection.php
R include/Objects/Section.php
include/Models/CreditsModel.php
include/Models/DownloadsModel.php
include/Models/FAQModel.php
include/Models/GamesModel.php
diff --git a/include/Models/CreditsModel.php b/include/Models/CreditsModel.php
index 7620fc3..aa2f5fa 100644
--- a/include/Models/CreditsModel.php
+++ b/include/Models/CreditsModel.php
@@ -1,11 +1,11 @@
<?php
namespace ScummVM\Models;
-use ScummVM\Objects\CSection;
+use ScummVM\Objects\CreditsSection;
use ScummVM\XMLParser;
/**
- * The CreditsModel will generate CSection objects.
+ * The CreditsModel will generate CreditsSection objects.
*/
abstract class CreditsModel extends BasicModel
{
@@ -17,7 +17,7 @@ abstract class CreditsModel extends BasicModel
$a = $parser->parseByFilename($fname);
$sections = array();
foreach ($a['credits']['section'] as $key => $value) {
- $sections[] = new CSection($value);
+ $sections[] = new CreditsSection($value);
}
return $sections;
}
diff --git a/include/Models/DownloadsModel.php b/include/Models/DownloadsModel.php
index b0f2ae2..9e00737 100644
--- a/include/Models/DownloadsModel.php
+++ b/include/Models/DownloadsModel.php
@@ -1,11 +1,11 @@
<?php
namespace ScummVM\Models;
-use ScummVM\Objects\DSection;
+use ScummVM\Objects\DownloadsSection;
use ScummVM\XMLParser;
/**
- * The DownloadsModel will produce DSection objects.
+ * The DownloadsModel will produce DownloadsSection objects.
*/
abstract class DownloadsModel
{
@@ -18,7 +18,7 @@ abstract class DownloadsModel
$a = $parser->parseByFilename($fname);
$sections = array();
foreach ($a['downloads']['section'] as $key => $value) {
- $sections[] = new DSection($value);
+ $sections[] = new DownloadsSection($value);
}
return $sections;
}
diff --git a/include/Models/FAQModel.php b/include/Models/FAQModel.php
index e70c830..cfdb4d4 100644
--- a/include/Models/FAQModel.php
+++ b/include/Models/FAQModel.php
@@ -2,14 +2,14 @@
namespace ScummVM\Models;
use ScummVM\Objects\Article;
-use ScummVM\Objects\QAEntry;
-use ScummVM\Objects\QASection;
+use ScummVM\Objects\FaqEntry;
+use ScummVM\Objects\FaqSection;
use ScummVM\XMLParser;
/**
* The FAQModel class reads the docbook formated XML-file 'faq.xml' and does
* some changes to make it easier to parse. Returns an array with
- * QASection-objects representing the different sections on the F.A.Q.-page on
+ * FaqSection-objects representing the different sections on the F.A.Q.-page on
* the website.
*/
abstract class FAQModel extends BasicModel
@@ -97,7 +97,7 @@ abstract class FAQModel extends BasicModel
$xref = array();
$count = 1;
foreach ($a['faq']['section'] as $data) {
- $sections[] = new QASection($data, $count++, $xref);
+ $sections[] = new FaqSection($data, $count++, $xref);
}
return $sections;
}
diff --git a/include/Models/GamesModel.php b/include/Models/GamesModel.php
index b0e9ecf..65dccc7 100644
--- a/include/Models/GamesModel.php
+++ b/include/Models/GamesModel.php
@@ -1,11 +1,11 @@
<?php
namespace ScummVM\Models;
-use ScummVM\Objects\DSection;
+use ScummVM\Objects\DownloadsSection;
use ScummVM\XMLParser;
/**
- * The GamesModel will produce DSection objects.
+ * The GamesModel will produce DownloadsSection objects.
*/
abstract class GamesModel
{
@@ -18,7 +18,7 @@ abstract class GamesModel
$a = $parser->parseByFilename($fname);
$sections = array();
foreach ($a['downloads']['section'] as $key => $value) {
- $sections[] = new DSection($value);
+ $sections[] = new DownloadsSection($value);
}
return $sections;
}
diff --git a/include/Objects/BasicSection.php b/include/Objects/BasicSection.php
new file mode 100644
index 0000000..a7dff3b
--- /dev/null
+++ b/include/Objects/BasicSection.php
@@ -0,0 +1,37 @@
+<?php
+namespace ScummVM\Objects;
+
+/**
+ * The BasicSection class is inherited by all other Sections and houses all common
+ * functions.
+ */
+abstract class BasicSection extends BasicObject
+{
+ protected $title;
+ protected $anchor;
+ protected $subsections;
+
+ public function __construct($data)
+ {
+ $this->title = $data['title'];
+ $this->anchor = $data['anchor'];
+ }
+
+ /* Get the title. */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /* Get the anchor. */
+ public function getAnchor()
+ {
+ return $this->anchor;
+ }
+
+ /* Get the optional list of subsections. */
+ public function getSubSections()
+ {
+ return $this->subsections;
+ }
+}
diff --git a/include/Objects/CSection.php b/include/Objects/CSection.php
deleted file mode 100644
index 7e7f666..0000000
--- a/include/Objects/CSection.php
+++ /dev/null
@@ -1,69 +0,0 @@
-<?php
-namespace ScummVM\Objects;
-
-/**
- * The Section class represens a section (or a subsection) on the credits page
- * on the website.
- */
-class CSection extends Section
-{
- private $groups;
- private $paragraphs;
-
- /* CSection object constructor. */
- public function __construct($data)
- {
- parent::__construct($data);
- $this->groups = array();
- $this->subsections = array();
- $this->paragraphs = array();
-
- if (isset($data['subsection'])) {
- foreach ($data['subsection'] as $value) {
- $this->subsections[] = new CSection($value);
- }
- }
- if (isset($data['group'])) {
- parent::toArray($data['group']);
- foreach ($data['group'] as $value) {
- $persons = array();
- if (is_string($value['person'])) {
- var_dump($value);
- die();
- }
- parent::toArray($value['person']);
- foreach ($value['person'] as $args) {
- $persons[] = new Person($args);
- }
- if (count($persons) > 0) {
- $this->groups[] = array(
- 'name' => $value['name'],
- 'persons' => $persons,
- );
- }
- }
- }
- if (isset($data['paragraph'])) {
- parent::toArray($data['paragraph']);
- $this->paragraphs = $data['paragraph'];
- }
- }
-
- /* Get the optional list of groups. */
- public function getGroups()
- {
- return $this->groups;
- }
-
- /* Get the optional list of subsections. */
- public function getSubSections()
- {
- return $this->subsections;
- }
-
- /* Get the optional list of paragraphs. */
- public function getParagraphs()
- {
- return $this->paragraphs;
- }
-}
diff --git a/include/Objects/CreditsSection.php b/include/Objects/CreditsSection.php
new file mode 100644
index 0000000..df107bb
--- /dev/null
+++ b/include/Objects/CreditsSection.php
@@ -0,0 +1,69 @@
+<?php
+namespace ScummVM\Objects;
+
+/**
+ * The BasicSection class represens a section (or a subsection) on the credits page
+ * on the website.
+ */
+class CreditsSection extends BasicSection
+{
+ private $groups;
+ private $paragraphs;
+
+ /* CreditsSection object constructor. */
+ public function __construct($data)
+ {
+ parent::__construct($data);
+ $this->groups = array();
+ $this->subsections = array();
+ $this->paragraphs = array();
+
+ if (isset($data['subsection'])) {
+ foreach ($data['subsection'] as $value) {
+ $this->subsections[] = new CreditsSection($value);
+ }
+ }
+ if (isset($data['group'])) {
+ parent::toArray($data['group']);
+ foreach ($data['group'] as $value) {
+ $persons = array();
+ if (is_string($value['person'])) {
+ var_dump($value);
+ die();
+ }
+ parent::toArray($value['person']);
+ foreach ($value['person'] as $args) {
+ $persons[] = new Person($args);
+ }
+ if (count($persons) > 0) {
+ $this->groups[] = array(
+ 'name' => $value['name'],
+ 'persons' => $persons,
+ );
+ }
+ }
+ }
+ if (isset($data['paragraph'])) {
+ parent::toArray($data['paragraph']);
+ $this->paragraphs = $data['paragraph'];
+ }
+ }
+
+ /* Get the optional list of groups. */
+ public function getGroups()
+ {
+ return $this->groups;
+ }
+
+ /* Get the optional list of subsections. */
+ public function getSubSections()
+ {
+ return $this->subsections;
+ }
+
+ /* Get the optional list of paragraphs. */
+ public function getParagraphs()
+ {
+ return $this->paragraphs;
+ }
+}
diff --git a/include/Objects/DSection.php b/include/Objects/DSection.php
deleted file mode 100644
index 5780dfa..0000000
--- a/include/Objects/DSection.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-namespace ScummVM\Objects;
-
-/**
- * The DSection object represents a section on the downloads page.
- */
-class DSection extends Section
-{
- private $baseurl;
- private $baseturl;
-
- /* DSection object constructor. */
- public function __construct($data)
- {
- parent::__construct($data);
- $this->baseurl = $data['baseurl'];
- $this->baseturl = $data['baseturl'];
- $this->subsections = array();
-
- parent::toArray($data['subsection']);
- foreach ($data['subsection'] as $key => $value) {
- $this->subsections[] = new DSubSection($value, $this->baseurl, $this->baseturl);
- }
- }
-
-
- /* Get the base URL. */
- public function getBaseURL()
- {
- return $this->baseurl;
- }
-
- /* Get the list of optional subsections. */
- public function getSubSections()
- {
- return $this->subsections;
- }
-}
diff --git a/include/Objects/DownloadsSection.php b/include/Objects/DownloadsSection.php
new file mode 100644
index 0000000..a797a6b
--- /dev/null
+++ b/include/Objects/DownloadsSection.php
@@ -0,0 +1,38 @@
+<?php
+namespace ScummVM\Objects;
+
+/**
+ * The DownloadsSection object represents a section on the downloads page.
+ */
+class DownloadsSection extends BasicSection
+{
+ private $baseurl;
+ private $baseturl;
+
+ /* DownloadsSection object constructor. */
+ public function __construct($data)
+ {
+ parent::__construct($data);
+ $this->baseurl = $data['baseurl'];
+ $this->baseturl = $data['baseturl'];
+ $this->subsections = array();
+
+ parent::toArray($data['subsection']);
+ foreach ($data['subsection'] as $key => $value) {
+ $this->subsections[] = new DSubSection($value, $this->baseurl, $this->baseturl);
+ }
+ }
+
+
+ /* Get the base URL. */
+ public function getBaseURL()
+ {
+ return $this->baseurl;
+ }
+
+ /* Get the list of optional subsections. */
+ public function getSubSections()
+ {
+ return $this->subsections;
+ }
+}
diff --git a/include/Objects/FaqEntry.php b/include/Objects/FaqEntry.php
new file mode 100644
index 0000000..3b758bc
--- /dev/null
+++ b/include/Objects/FaqEntry.php
@@ -0,0 +1,80 @@
+<?php
+namespace ScummVM\Objects;
+
+/**
+ * The FaqEntry class represents a question-answer pair on the website
+ * F.A.Q. page.
+ */
+class FaqEntry extends BasicObject
+{
+ private $hrefs;
+ private $question;
+ private $answer;
+ private $xref;
+
+ /**
+ * FaqEntry object constructor.
+ *
+ * @param array $data list containing all qaentry data
+ * @param int $section_number the section this entry belongs too
+ * @param int $entry_number part of the href value incase it's not set
+ * @param array $xref reference to xref map
+ */
+ public function __construct($data, $section_number, $entry_number, &$xref)
+ {
+ $this->hrefs = array();
+ if (! empty($data['href'])) {
+ array_push($this->hrefs, $data['href']);
+ $xref[$data['href']] = $data['question'];
+ }
+ array_push($this->hrefs, "{$section_number}_{$entry_number}");
+
+ $this->question = $data['question'];
+ $this->answer = $data['answer'];
+ /* Save a reference to the xref table for later use. */
+ $this->xref = &$xref;
+ }
+
+ /* Get the primary anchor name for this entry. */
+ public function getHref()
+ {
+ return $this->hrefs[0];
+ }
+
+ /* Get all anchor names for this entry. */
+ public function getHrefs()
+ {
+ return $this->hrefs;
+ }
+
+ /* Get the question for this entry. */
+ public function getQuestion()
+ {
+ return $this->question;
+ }
+
+ /* Get the answer for this entry. */
+ public function getAnswer()
+ {
+ $answer = &$this->answer;
+ $xref = &$this->xref;
+ /* If we find a xref we need to make the final conversion to HTML. */
+ if (strpos($answer, '<a xref') !== false) {
+ /**
+ * For each entry in our xref lookup table we need to build a list
+ * of patterns that match the xrefs. We also need to build a list
+ * with replacements for the xrefs. Only generate the lists once.
+ */
+ if (!isset($xref['pattern']) || !isset($xref['replace'])) {
+ $pattern = array();
+ $replace = array();
+ foreach ($this->xref as $anchor => $text) {
+ $xref['pattern'][] = "/<a xref=\"{$anchor}\"><\/a>/";
+ $xref['replace'][] = "<a href=\"faq/#{$anchor}\">{$text}</a>";
+ }
+ }
+ $answer = preg_replace($xref['pattern'], $xref['replace'], $answer);
+ }
+ return $this->answer;
+ }
+}
diff --git a/include/Objects/FaqSection.php b/include/Objects/FaqSection.php
new file mode 100644
index 0000000..4d80819
--- /dev/null
+++ b/include/Objects/FaqSection.php
@@ -0,0 +1,52 @@
+<?php
+namespace ScummVM\Objects;
+
+/**
+ * The FaqSection class represents a section with questions and answers on the
+ * website F.A.Q. page.
+ */
+class FaqSection extends BasicObject
+{
+ private $title;
+ private $entries;
+ private $toc;
+
+ /**
+ * FaqSection object constructor.
+ *
+ * @param array $data list containing all qasection data
+ * @param int $section_number used in the TOC
+ * @param array $xref reference to xref map
+ */
+ public function __construct($data, $section_number, &$xref)
+ {
+ $this->title = $data['title'];
+ $this->entries = array();
+ $this->toc = array();
+ parent::toArray($data['entry']);
+ $count = 1;
+ foreach ($data['entry'] as $key => $value) {
+ $qa = new FaqEntry($value, $section_number, $count++, $xref);
+ $this->entries[] = $qa;
+ $this->toc[$qa->getHref()] = $qa->getQuestion();
+ }
+ }
+
+ /* Get the title of this section. */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /* Get a list with all question-answer entries for this section. */
+ public function getEntries()
+ {
+ return $this->entries;
+ }
+
+ /* Get the table of contents for this section. */
+ public function getTOC()
+ {
+ return $this->toc;
+ }
+}
diff --git a/include/Objects/QAEntry.php b/include/Objects/QAEntry.php
deleted file mode 100644
index b022b2a..0000000
--- a/include/Objects/QAEntry.php
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-namespace ScummVM\Objects;
-
-/**
- * The QAEntry class represents a question-answer pair on the website
- * F.A.Q. page.
- */
-class QAEntry extends BasicObject
-{
- private $hrefs;
- private $question;
- private $answer;
- private $xref;
-
- /**
- * QAEntry object constructor.
- *
- * @param array $data list containing all qaentry data
- * @param int $section_number the section this entry belongs too
- * @param int $entry_number part of the href value incase it's not set
- * @param array $xref reference to xref map
- */
- public function __construct($data, $section_number, $entry_number, &$xref)
- {
- $this->hrefs = array();
- if (! empty($data['href'])) {
- array_push($this->hrefs, $data['href']);
- $xref[$data['href']] = $data['question'];
- }
- array_push($this->hrefs, "{$section_number}_{$entry_number}");
-
- $this->question = $data['question'];
- $this->answer = $data['answer'];
- /* Save a reference to the xref table for later use. */
- $this->xref = &$xref;
- }
-
- /* Get the primary anchor name for this entry. */
- public function getHref()
- {
- return $this->hrefs[0];
- }
-
- /* Get all anchor names for this entry. */
- public function getHrefs()
- {
- return $this->hrefs;
- }
-
- /* Get the question for this entry. */
- public function getQuestion()
- {
- return $this->question;
- }
-
- /* Get the answer for this entry. */
- public function getAnswer()
- {
- $answer = &$this->answer;
- $xref = &$this->xref;
- /* If we find a xref we need to make the final conversion to HTML. */
- if (strpos($answer, '<a xref') !== false) {
- /**
- * For each entry in our xref lookup table we need to build a list
- * of patterns that match the xrefs. We also need to build a list
- * with replacements for the xrefs. Only generate the lists once.
- */
- if (!isset($xref['pattern']) || !isset($xref['replace'])) {
- $pattern = array();
- $replace = array();
- foreach ($this->xref as $anchor => $text) {
- $xref['pattern'][] = "/<a xref=\"{$anchor}\"><\/a>/";
- $xref['replace'][] = "<a href=\"faq/#{$anchor}\">{$text}</a>";
- }
- }
- $answer = preg_replace($xref['pattern'], $xref['replace'], $answer);
- }
- return $this->answer;
- }
-}
diff --git a/include/Objects/QASection.php b/include/Objects/QASection.php
deleted file mode 100644
index 13de5e9..0000000
--- a/include/Objects/QASection.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-namespace ScummVM\Objects;
-
-/**
- * The QASection class represents a section with questions and answers on the
- * website F.A.Q. page.
- */
-class QASection extends BasicObject
-{
- private $title;
- private $entries;
- private $toc;
-
- /**
- * QASection object constructor.
- *
- * @param array $data list containing all qasection data
- * @param int $section_number used in the TOC
- * @param array $xref reference to xref map
- */
- public function __construct($data, $section_number, &$xref)
- {
- $this->title = $data['title'];
- $this->entries = array();
- $this->toc = array();
- parent::toArray($data['entry']);
- $count = 1;
- foreach ($data['entry'] as $key => $value) {
- $qa = new QAEntry($value, $section_number, $count++, $xref);
- $this->entries[] = $qa;
- $this->toc[$qa->getHref()] = $qa->getQuestion();
- }
- }
-
- /* Get the title of this section. */
- public function getTitle()
- {
- return $this->title;
- }
-
- /* Get a list with all question-answer entries for this section. */
- public function getEntries()
- {
- return $this->entries;
- }
-
- /* Get the table of contents for this section. */
- public function getTOC()
- {
- return $this->toc;
- }
-}
diff --git a/include/Objects/Section.php b/include/Objects/Section.php
deleted file mode 100644
index e475859..0000000
--- a/include/Objects/Section.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-namespace ScummVM\Objects;
-
-/**
- * The Section class is inherited by all other Sections and houses all common
- * functions.
- */
-abstract class Section extends BasicObject
-{
- protected $title;
- protected $anchor;
- protected $subsections;
-
- public function __construct($data)
- {
- $this->title = $data['title'];
- $this->anchor = $data['anchor'];
- }
-
- /* Get the title. */
- public function getTitle()
- {
- return $this->title;
- }
-
- /* Get the anchor. */
- public function getAnchor()
- {
- return $this->anchor;
- }
-
- /* Get the optional list of subsections. */
- public function getSubSections()
- {
- return $this->subsections;
- }
-}
Commit: 6652331db9dcb78e4e65b6778e7a9f7c5addeaf0
https://github.com/scummvm/scummvm-web/commit/6652331db9dcb78e4e65b6778e7a9f7c5addeaf0
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Move file download base URLs to Config.php
Changed paths:
data/downloads.xml
include/Config.php
include/Objects/DSubSection.php
include/Objects/DownloadsSection.php
include/Objects/File.php
diff --git a/data/downloads.xml b/data/downloads.xml
index 2a56da3..08b95a2 100644
--- a/data/downloads.xml
+++ b/data/downloads.xml
@@ -4,8 +4,6 @@
<title>
{#downloadsXMLTitle#} <h:span style="color: rgb(170, 170, 170);">{'/\x7brelease\x7d/'|preg_replace:$release:#downloadsXMLVersion#}</h:span>
</title>
- <baseurl>/frs/scummvm/{$release}/</baseurl>
- <baseturl>/frs/scummvm-tools/{$release_tools}/</baseturl>
<subsection>
<title>{'/\x7brelease\x7d/'|preg_replace:$release:#downloadsBinaries#}</title>
<anchor>stable</anchor>
diff --git a/include/Config.php b/include/Config.php
index 452a597..891d762 100644
--- a/include/Config.php
+++ b/include/Config.php
@@ -40,6 +40,10 @@ class Config
define('DIR_DOWNLOADS', '/downloads');
define('DIR_SCREENSHOTS', '/data/screenshots');
+ /* Downloads */
+ define('DOWNLOADS_URL', '/frs/scummvm/{$release}/');
+ define('DOWNLOADS_TOOLS_URL', '/frs/scummvm-tools/{$release}/');
+
/**
* Smarty configuration. The Smarty team does not recommend putting any of the
* directories used under the web server root. 'SMARTY_DIR_COMPILE' and
diff --git a/include/Objects/DSubSection.php b/include/Objects/DSubSection.php
index ea90bef..0f1e80c 100644
--- a/include/Objects/DSubSection.php
+++ b/include/Objects/DSubSection.php
@@ -15,7 +15,7 @@ class DSubSection extends BasicObject
private $items;
/* DSubSection constructor. */
- public function __construct($data, $baseurl, $baseturl)
+ public function __construct($data)
{
$this->title = $data['title'];
$this->anchor = $data['anchor'];
@@ -29,7 +29,7 @@ class DSubSection extends BasicObject
parent::toArray($item);
if ($type == 'file') {
foreach ($item as $file) {
- $this->items[] = new File($file, $baseurl, $baseturl);
+ $this->items[] = new File($file);
}
} elseif ($type == 'link') {
foreach ($item as $link) {
diff --git a/include/Objects/DownloadsSection.php b/include/Objects/DownloadsSection.php
index a797a6b..fb3274b 100644
--- a/include/Objects/DownloadsSection.php
+++ b/include/Objects/DownloadsSection.php
@@ -6,20 +6,16 @@ namespace ScummVM\Objects;
*/
class DownloadsSection extends BasicSection
{
- private $baseurl;
- private $baseturl;
/* DownloadsSection object constructor. */
public function __construct($data)
{
parent::__construct($data);
- $this->baseurl = $data['baseurl'];
- $this->baseturl = $data['baseturl'];
$this->subsections = array();
parent::toArray($data['subsection']);
foreach ($data['subsection'] as $key => $value) {
- $this->subsections[] = new DSubSection($value, $this->baseurl, $this->baseturl);
+ $this->subsections[] = new DSubSection($value);
}
}
diff --git a/include/Objects/File.php b/include/Objects/File.php
index f68197e..071a66c 100644
--- a/include/Objects/File.php
+++ b/include/Objects/File.php
@@ -13,7 +13,7 @@ class File extends BasicObject
private $extra_info;
private $user_agent;
- public function __construct($data, $baseurl = null, $baseturl = null)
+ public function __construct($data)
{
parent::__construct($data);
$this->category_icon = $data['category_icon'];
@@ -36,9 +36,9 @@ class File extends BasicObject
if ($attributes['type'] == 'downloads') {
$url = DIR_DOWNLOADS . "/{$url}";
} elseif ($attributes['type'] == 'tools') {
- $url = $baseturl . $url;
+ $url = DOWNLOADS_TOOLS_URL . $url;
} else {
- $url = $baseurl . $url;
+ $url = DOWNLOADS_URL . $url;
}
$fname = "." . $url;
Commit: 8682a63731fd55a2958af4e001f4bfd6fc2d9209
https://github.com/scummvm/scummvm-web/commit/8682a63731fd55a2958af4e001f4bfd6fc2d9209
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Improve inheritance for Section classes
Changed paths:
R include/Objects/DSubSection.php
include/Objects/BasicSection.php
include/Objects/CreditsSection.php
include/Objects/DownloadsSection.php
diff --git a/include/Objects/BasicSection.php b/include/Objects/BasicSection.php
index a7dff3b..5791a53 100644
--- a/include/Objects/BasicSection.php
+++ b/include/Objects/BasicSection.php
@@ -10,11 +10,20 @@ abstract class BasicSection extends BasicObject
protected $title;
protected $anchor;
protected $subsections;
+ private $className;
public function __construct($data)
{
$this->title = $data['title'];
$this->anchor = $data['anchor'];
+ $this->className = static::class;
+ if (isset($data['subsection'])) {
+ parent::toArray($data['subsection']);
+ $this->subsections = array();
+ foreach ($data['subsection'] as $value) {
+ $this->subsections[] = new $this->className($value);
+ }
+ }
}
/* Get the title. */
diff --git a/include/Objects/CreditsSection.php b/include/Objects/CreditsSection.php
index df107bb..f33cbcd 100644
--- a/include/Objects/CreditsSection.php
+++ b/include/Objects/CreditsSection.php
@@ -15,14 +15,8 @@ class CreditsSection extends BasicSection
{
parent::__construct($data);
$this->groups = array();
- $this->subsections = array();
$this->paragraphs = array();
- if (isset($data['subsection'])) {
- foreach ($data['subsection'] as $value) {
- $this->subsections[] = new CreditsSection($value);
- }
- }
if (isset($data['group'])) {
parent::toArray($data['group']);
foreach ($data['group'] as $value) {
@@ -55,12 +49,6 @@ class CreditsSection extends BasicSection
return $this->groups;
}
- /* Get the optional list of subsections. */
- public function getSubSections()
- {
- return $this->subsections;
- }
-
/* Get the optional list of paragraphs. */
public function getParagraphs()
{
diff --git a/include/Objects/DSubSection.php b/include/Objects/DSubSection.php
deleted file mode 100644
index 0f1e80c..0000000
--- a/include/Objects/DSubSection.php
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php
-namespace ScummVM\Objects;
-
-/**
- * The DSubSection object represents a subsection on the downloads page.
- */
-class DSubSection extends BasicObject
-{
- private $title;
- private $anchor;
- private $notes;
- private $footer;
- private $files;
- private $links;
- private $items;
-
- /* DSubSection constructor. */
- public function __construct($data)
- {
- $this->title = $data['title'];
- $this->anchor = $data['anchor'];
- $this->notes = $data['notes'];
- $this->footer = $data['footer'];
- $this->files = array();
- $this->links = array();
- $this->items = array();
-
- foreach ($data['entries'] as $type => $item) {
- parent::toArray($item);
- if ($type == 'file') {
- foreach ($item as $file) {
- $this->items[] = new File($file);
- }
- } elseif ($type == 'link') {
- foreach ($item as $link) {
- $this->items[] = new WebLink($link);
- }
- }
- }
- }
-
- /* Get the title. */
- public function getTitle()
- {
- return $this->title;
- }
-
- /* Get the anchor name. */
- public function getAnchor()
- {
- return $this->anchor;
- }
-
- /* Get the optional notes. */
- public function getNotes()
- {
- return $this->notes;
- }
-
- /* Get the optional footer. */
- public function getFooter()
- {
- return $this->footer;
- }
-
- /* Get the list of files. */
- public function getFiles()
- {
- return $this->files;
- }
-
- /* Get the list of links. */
- public function getLinks()
- {
- return $this->links;
- }
-
- /* Get the list of items. */
- public function getItems()
- {
- return $this->items;
- }
-}
diff --git a/include/Objects/DownloadsSection.php b/include/Objects/DownloadsSection.php
index fb3274b..8ba9236 100644
--- a/include/Objects/DownloadsSection.php
+++ b/include/Objects/DownloadsSection.php
@@ -6,29 +6,64 @@ namespace ScummVM\Objects;
*/
class DownloadsSection extends BasicSection
{
+ private $notes;
+ private $footer;
+ private $files;
+ private $links;
+ private $items;
- /* DownloadsSection object constructor. */
public function __construct($data)
{
parent::__construct($data);
- $this->subsections = array();
+ $this->notes = $data['notes'];
+ $this->footer = $data['footer'];
+ $this->files = array();
+ $this->links = array();
+ $this->items = array();
- parent::toArray($data['subsection']);
- foreach ($data['subsection'] as $key => $value) {
- $this->subsections[] = new DSubSection($value);
+ if (isset($data['entries'])) {
+ foreach ($data['entries'] as $type => $item) {
+ parent::toArray($item);
+ if ($type == 'file') {
+ foreach ($item as $file) {
+ $this->items[] = new File($file);
+ }
+ } elseif ($type == 'link') {
+ foreach ($item as $link) {
+ $this->items[] = new WebLink($link);
+ }
+ }
+ }
}
}
+ /* Get the optional notes. */
+ public function getNotes()
+ {
+ return $this->notes;
+ }
+
+ /* Get the optional footer. */
+ public function getFooter()
+ {
+ return $this->footer;
+ }
+
+ /* Get the list of files. */
+ public function getFiles()
+ {
+ return $this->files;
+ }
- /* Get the base URL. */
- public function getBaseURL()
+ /* Get the list of links. */
+ public function getLinks()
{
- return $this->baseurl;
+ return $this->links;
}
- /* Get the list of optional subsections. */
- public function getSubSections()
+ /* Get the list of items. */
+ public function getItems()
{
- return $this->subsections;
+ return $this->items;
}
}
Commit: 42d8516b658c31863ee4c2d2c8a4415767e9b8e8
https://github.com/scummvm/scummvm-web/commit/42d8516b658c31863ee4c2d2c8a4415767e9b8e8
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Fix template warnings on subsections
Changed paths:
include/Objects/BasicSection.php
diff --git a/include/Objects/BasicSection.php b/include/Objects/BasicSection.php
index 5791a53..002eeb6 100644
--- a/include/Objects/BasicSection.php
+++ b/include/Objects/BasicSection.php
@@ -17,9 +17,9 @@ abstract class BasicSection extends BasicObject
$this->title = $data['title'];
$this->anchor = $data['anchor'];
$this->className = static::class;
+ $this->subsections = array();
if (isset($data['subsection'])) {
parent::toArray($data['subsection']);
- $this->subsections = array();
foreach ($data['subsection'] as $value) {
$this->subsections[] = new $this->className($value);
}
Commit: 5e079bf6fa29ddd5c3fb3de70fd2321219740260
https://github.com/scummvm/scummvm-web/commit/5e079bf6fa29ddd5c3fb3de70fd2321219740260
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Use PSR4 object references in templates
Changed paths:
templates/components/list_items.tpl
diff --git a/templates/components/list_items.tpl b/templates/components/list_items.tpl
index 7a506b7..6fe0b7f 100644
--- a/templates/components/list_items.tpl
+++ b/templates/components/list_items.tpl
@@ -1,7 +1,7 @@
{if is_array($list) && $list|@count > 0}
<ul class="downloads">
{foreach from=$list item=item}
- {if $item instanceof File}
+ {if $item instanceof ScummVM\Objects\File}
{assign var='data' value=$item->getExtraInfo()}
<li class="file">
<span class="sprite-{$type}-{$item->getCategoryIcon()} sprite"></span>
@@ -32,11 +32,11 @@
{/if}
{/strip}
</li>
- {elseif $item instanceof WebLink}
+ {elseif $item instanceof ScummVM\Objects\WebLink}
<li class="link">
<a href="{$item->getURL()}">{$item->getName()}</a>{$item->getDescription()}
</li>
- {elseif $item instanceof Screenshot}
+ {elseif $item instanceof ScummVM\Objects\Screenshot}
<li class="file">
<span class="sprite-games-{$item->getCategory()} sprite"></span>
<a href="/screenshots/{$arr.category}/{$item->getCategory()}/">{$item->getName()}</a>
Commit: dcc281b2c2427a0db46d0b73cb645a09df19b3e4
https://github.com/scummvm/scummvm-web/commit/dcc281b2c2427a0db46d0b73cb645a09df19b3e4
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Fix line endings
Changed paths:
include/Objects/File.php
diff --git a/include/Objects/File.php b/include/Objects/File.php
index 071a66c..5f1c4d9 100644
--- a/include/Objects/File.php
+++ b/include/Objects/File.php
@@ -8,7 +8,6 @@ class File extends BasicObject
{
private $category_icon;
private $url;
-
private $type;
private $extra_info;
private $user_agent;
Commit: 4c97bcbcafcdcc6835e5d8ee8d0fa75da2dab8b0
https://github.com/scummvm/scummvm-web/commit/4c97bcbcafcdcc6835e5d8ee8d0fa75da2dab8b0
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Remove unused objects and methods in downloads/games
Changed paths:
include/Objects/DownloadsSection.php
templates/pages/downloads.tpl
templates/pages/games.tpl
diff --git a/include/Objects/DownloadsSection.php b/include/Objects/DownloadsSection.php
index 8ba9236..7feb796 100644
--- a/include/Objects/DownloadsSection.php
+++ b/include/Objects/DownloadsSection.php
@@ -16,9 +16,6 @@ class DownloadsSection extends BasicSection
{
parent::__construct($data);
$this->notes = $data['notes'];
- $this->footer = $data['footer'];
- $this->files = array();
- $this->links = array();
$this->items = array();
if (isset($data['entries'])) {
@@ -43,24 +40,6 @@ class DownloadsSection extends BasicSection
return $this->notes;
}
- /* Get the optional footer. */
- public function getFooter()
- {
- return $this->footer;
- }
-
- /* Get the list of files. */
- public function getFiles()
- {
- return $this->files;
- }
-
- /* Get the list of links. */
- public function getLinks()
- {
- return $this->links;
- }
-
/* Get the list of items. */
public function getItems()
{
diff --git a/templates/pages/downloads.tpl b/templates/pages/downloads.tpl
index 3be46ae..a908627 100644
--- a/templates/pages/downloads.tpl
+++ b/templates/pages/downloads.tpl
@@ -53,27 +53,24 @@
<div class="subhead-content">
{if $dsubsection->getNotes() != ''} {eval var=$dsubsection->getNotes()} {/if} {include file='components/list_items.tpl' list=$dsubsection->getItems() type='platforms'}
- {if !is_null($dsubsection->getFooter())}
- <p>{$dsubsection->getFooter()}</p>
- {/if}
</div>
{/foreach}
{/capture}
{if $smarty.foreach.downloads_loop.first}
- {include
- file="components/box.tpl"
- head={eval var=$dsection->getTitle()}
- intro=$smarty.capture.intro
+ {include
+ file="components/box.tpl"
+ head={eval var=$dsection->getTitle()}
+ intro=$smarty.capture.intro
id=$dsection->getAnchor()
content=$smarty.capture.content
- }
+ }
{else}
- {include
- file="components/box.tpl"
- head={eval var=$dsection->getTitle()}
+ {include
+ file="components/box.tpl"
+ head={eval var=$dsection->getTitle()}
content=$smarty.capture.content
id=$dsection->getAnchor()
- }
+ }
{/if}
{/foreach}
diff --git a/templates/pages/games.tpl b/templates/pages/games.tpl
index 1f9bf7b..efd5b6f 100644
--- a/templates/pages/games.tpl
+++ b/templates/pages/games.tpl
@@ -31,25 +31,22 @@
{/if}
{include file='components/list_items.tpl' list=$dsubsection->getItems() type='games'}
- {if !is_null($dsubsection->getFooter())}
- <p>{$dsubsection->getFooter()}</p>
- {/if}
</div>
{/foreach}
{/capture}
-
- {if $smarty.foreach.downloads_loop.first}
- {include
- file="components/box.tpl"
- head={eval var=$dsection->getTitle()}
- intro=$smarty.capture.intro
+
+ {if $smarty.foreach.downloads_loop.first}
+ {include
+ file="components/box.tpl"
+ head={eval var=$dsection->getTitle()}
+ intro=$smarty.capture.intro
id=$dsection->getAnchor()
content=$smarty.capture.content
}
{else}
- {include
- file="components/box.tpl"
- head={eval var=$dsection->getTitle()}
+ {include
+ file="components/box.tpl"
+ head={eval var=$dsection->getTitle()}
id=$dsection->getAnchor()
content=$smarty.capture.content
}
Commit: 393959c39bc98a5f1c9799b9ea3e10f25c40d310
https://github.com/scummvm/scummvm-web/commit/393959c39bc98a5f1c9799b9ea3e10f25c40d310
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Remove die() in CreditsSection
Changed paths:
include/Objects/CreditsSection.php
diff --git a/include/Objects/CreditsSection.php b/include/Objects/CreditsSection.php
index f33cbcd..3fbd949 100644
--- a/include/Objects/CreditsSection.php
+++ b/include/Objects/CreditsSection.php
@@ -21,10 +21,6 @@ class CreditsSection extends BasicSection
parent::toArray($data['group']);
foreach ($data['group'] as $value) {
$persons = array();
- if (is_string($value['person'])) {
- var_dump($value);
- die();
- }
parent::toArray($value['person']);
foreach ($value['person'] as $args) {
$persons[] = new Person($args);
Commit: 2d07e63028d5f8292079d3a76475f71df0b53543
https://github.com/scummvm/scummvm-web/commit/2d07e63028d5f8292079d3a76475f71df0b53543
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Remove unused code in Controller
Changed paths:
include/Controller.php
diff --git a/include/Controller.php b/include/Controller.php
index 266bc31..ab8b1d0 100644
--- a/include/Controller.php
+++ b/include/Controller.php
@@ -64,13 +64,6 @@ class Controller
$this->smarty->registerPlugin('modifier', 'date_f', array(&$this, 'dateFormatSmartyModifier'));
$this->smarty->registerPlugin('modifier', 'date_localized', array(&$this, 'dateLocalizedSmartyModifier'));
- /* Give Smarty-templates access to the ampersandEntity() function. */
- $this->smarty->registerPlugin(
- 'modifier',
- 'escapeAmpersand',
- array(&$this, 'ampersandEntity')
- );
-
$this->css_files = array();
$this->js_files = array();
@@ -103,14 +96,6 @@ class Controller
return $string;
}
- /** Escape ampersands to the HTML-entitiy '&'. */
- public static function ampersandEntity($string)
- {
- //return preg_replace('/&(?!amp|nbsp|lt|gt|quot;)/', '&', $string);
- //return preg_replace('/&(?![a-z];|#[0-9];)/', '&', $string);
- return $string;
- }
-
/** Formating of dates, registered as a modifier for Smarty templates. */
public function dateFormatSmartyModifier($timestamp, $format)
{
@@ -129,8 +114,6 @@ class Controller
/* Render the HTML using the template and any set variables and displays it. */
public function display($content)
{
- if (!is_string($content) || strlen($content) == 0) {
- }
$vars = array(
'css_files' => $this->css_files,
'js_files' => $this->js_files,
@@ -143,8 +126,6 @@ class Controller
/* Render the HTML using the template and any set variables and returns it. */
public function fetch($template, $vars = null)
{
- if (!is_file(SMARTY_DIR_TEMPLATE . "/{$template}")) {
- }
if (!is_null($vars)) {
$this->smarty->assign($vars);
}
@@ -154,8 +135,6 @@ class Controller
/* Set up the variables used by the template and render the page. */
public function renderPage($vars, $template)
{
- if (!is_string($template)) {
- }
return $this->display($this->fetch($template, $vars));
}
Commit: 601465558fd73b99201af9c5638b7ee0a8f00841
https://github.com/scummvm/scummvm-web/commit/601465558fd73b99201af9c5638b7ee0a8f00841
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Resolve static analysis errors
Changed paths:
A include/Objects/Subproject.php
R include/Objects/Project.php
include/Models/SubprojectsModel.php
include/Objects/BasicSection.php
include/Objects/FaqEntry.php
include/Objects/FaqSection.php
include/Objects/File.php
include/Objects/News.php
include/Objects/Screenshot.php
diff --git a/include/Models/SubprojectsModel.php b/include/Models/SubprojectsModel.php
index 90e0fde..81bd72a 100644
--- a/include/Models/SubprojectsModel.php
+++ b/include/Models/SubprojectsModel.php
@@ -1,7 +1,7 @@
<?php
namespace ScummVM\Models;
-use ScummVM\Objects\Project;
+use ScummVM\Objects\Subproject;
use ScummVM\Objects\File;
use ScummVM\Objects\BasicObject;
use ScummVM\XMLParser;
@@ -29,7 +29,7 @@ abstract class SubprojectsModel extends BasicModel
}
}
}
- $entries[] = new Project(array(
+ $entries[] = new Subproject(array(
'name' => $value['name'],
'info' => $value['info'],
'downloads' => $downloads,
diff --git a/include/Objects/BasicSection.php b/include/Objects/BasicSection.php
index 002eeb6..acf6834 100644
--- a/include/Objects/BasicSection.php
+++ b/include/Objects/BasicSection.php
@@ -14,6 +14,7 @@ abstract class BasicSection extends BasicObject
public function __construct($data)
{
+ parent::__construct($data);
$this->title = $data['title'];
$this->anchor = $data['anchor'];
$this->className = static::class;
diff --git a/include/Objects/FaqEntry.php b/include/Objects/FaqEntry.php
index 3b758bc..50364bc 100644
--- a/include/Objects/FaqEntry.php
+++ b/include/Objects/FaqEntry.php
@@ -22,6 +22,7 @@ class FaqEntry extends BasicObject
*/
public function __construct($data, $section_number, $entry_number, &$xref)
{
+ parent::__construct($data);
$this->hrefs = array();
if (! empty($data['href'])) {
array_push($this->hrefs, $data['href']);
diff --git a/include/Objects/FaqSection.php b/include/Objects/FaqSection.php
index 4d80819..4611211 100644
--- a/include/Objects/FaqSection.php
+++ b/include/Objects/FaqSection.php
@@ -5,9 +5,8 @@ namespace ScummVM\Objects;
* The FaqSection class represents a section with questions and answers on the
* website F.A.Q. page.
*/
-class FaqSection extends BasicObject
+class FaqSection extends BasicSection
{
- private $title;
private $entries;
private $toc;
@@ -20,6 +19,7 @@ class FaqSection extends BasicObject
*/
public function __construct($data, $section_number, &$xref)
{
+ parent::__construct($data);
$this->title = $data['title'];
$this->entries = array();
$this->toc = array();
@@ -32,12 +32,6 @@ class FaqSection extends BasicObject
}
}
- /* Get the title of this section. */
- public function getTitle()
- {
- return $this->title;
- }
-
/* Get a list with all question-answer entries for this section. */
public function getEntries()
{
diff --git a/include/Objects/File.php b/include/Objects/File.php
index 5f1c4d9..f3de35f 100644
--- a/include/Objects/File.php
+++ b/include/Objects/File.php
@@ -80,7 +80,7 @@ class File extends BasicObject
$this->extra_info['msg'] = $data['extra_msg'];
}
}
- $this->_url = $url;
+ $this->url = $url;
/**
* Get the filesize/last modified information and put it in
@@ -105,7 +105,7 @@ class File extends BasicObject
/* Get the URL. */
public function getURL()
{
- return $this->_url;
+ return $this->url;
}
/* Get the type. */
diff --git a/include/Objects/News.php b/include/Objects/News.php
index cf8fc3e..689f791 100644
--- a/include/Objects/News.php
+++ b/include/Objects/News.php
@@ -27,6 +27,7 @@ class News extends BasicObject
*/
public function __construct($data, $filename, $processContent = false)
{
+ parent::__construct($data);
$this->title = $processContent ? $this->processText($data->title) : $data->title;
$this->date = $data->date;
$this->author = $data->author;
diff --git a/include/Objects/Project.php b/include/Objects/Project.php
deleted file mode 100644
index 3797dbc..0000000
--- a/include/Objects/Project.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-namespace ScummVM\Objects;
-
-/**
- * The Project class represents a subproject on the website.
- */
-class Project extends BasicObject
-{
-
- private $info;
- private $downloads;
-
- /* Project object constructor. */
- public function __construct($data)
- {
- $this->_name = $data['name'];
- $this->_info = $data['info'];
- $this->_downloads = $data['downloads'];
- /*$this->_downloads = array();
- parent::toArray($data['download']);
- foreach ($data['download'] as $ddata) {
- $download = array(
- 'name' => $ddata['name'],
- 'filename' => $ddata['filename'],
- 'type' => $ddata['type'],
- );
- # Add detailed information about daily builds.
- if ($ddata['type'] == 'SVN_DAILY') {
- $url = DIR_DOWNLOADS . "/{$ddata['filename']}";
- $download['info'] = array(
- 'url' => $url,
- 'filesize' => intval(@filesize($url) / 1024),
- 'modified' => date('F j, Y, g:i a', @filemtime($url)),
- );
- }
- $this->_downloads[] = $download;
- }*/
- }
-
- /* Get the name of the project. */
- public function getName()
- {
- return $this->_name;
- }
-
- /* Get the information text for this project. */
- public function getInfo()
- {
- return $this->_info;
- }
-
- /* Get the list of downloads available for this project. */
- public function getDownloads()
- {
- return $this->_downloads;
- }
-}
diff --git a/include/Objects/Screenshot.php b/include/Objects/Screenshot.php
index 1bce16b..64c2930 100644
--- a/include/Objects/Screenshot.php
+++ b/include/Objects/Screenshot.php
@@ -6,14 +6,13 @@ namespace ScummVM\Objects;
*/
class Screenshot extends BasicObject
{
-
private $category;
private $files;
/* The Screenshot object constructor. */
public function __construct($data)
{
- $this->name = $data['name'];
+ parent::__construct($data);
$this->category = $data['category'];
$this->files = array();
if (isset($data['image'])) {
@@ -47,12 +46,6 @@ class Screenshot extends BasicObject
}
}
- /* Get the name. */
- public function getName()
- {
- return $this->name;
- }
-
/* Get the category this screenshot belongs too. */
public function getCategory()
{
diff --git a/include/Objects/Subproject.php b/include/Objects/Subproject.php
new file mode 100644
index 0000000..b053c48
--- /dev/null
+++ b/include/Objects/Subproject.php
@@ -0,0 +1,32 @@
+<?php
+namespace ScummVM\Objects;
+
+/**
+ * The Subproject class represents a subproject on the website.
+ */
+class Subproject extends BasicObject
+{
+
+ private $info;
+ private $downloads;
+
+ /* Subproject object constructor. */
+ public function __construct($data)
+ {
+ parent::__construct($data);
+ $this->info = $data['info'];
+ $this->downloads = $data['downloads'];
+ }
+
+ /* Get the information text for this project. */
+ public function getInfo()
+ {
+ return $this->info;
+ }
+
+ /* Get the list of downloads available for this project. */
+ public function getDownloads()
+ {
+ return $this->downloads;
+ }
+}
Commit: b17e27cc80a1325aed0019ce33dbf6fc55237c20
https://github.com/scummvm/scummvm-web/commit/b17e27cc80a1325aed0019ce33dbf6fc55237c20
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Additional static analysis fixes on pages
Changed paths:
include/Pages/CompatibilityPage.php
include/Pages/ContactPage.php
include/Pages/CreditsPage.php
include/Pages/DemosPage.php
include/Pages/DocumentationPage.php
include/Pages/DownloadsPage.php
include/Pages/ExceptionsPage.php
include/Pages/FAQPage.php
include/Pages/GamesPage.php
include/Pages/LinksPage.php
include/Pages/NewsPage.php
include/Pages/PressPage.php
include/Pages/PressSnowberryPage.php
include/Pages/ScreenshotsPage.php
include/Pages/SubprojectsPage.php
diff --git a/include/Pages/CompatibilityPage.php b/include/Pages/CompatibilityPage.php
index 90deb4b..1dec6da 100644
--- a/include/Pages/CompatibilityPage.php
+++ b/include/Pages/CompatibilityPage.php
@@ -11,8 +11,6 @@ use ScummVM\Models\CompatibilityModel;
*/
class CompatibilityPage extends Controller
{
-
- private $template_details;
private $supportLevelDesc;
private $supportLevelClass;
@@ -20,15 +18,13 @@ class CompatibilityPage extends Controller
public function __construct()
{
parent::__construct();
- global $Smarty;
- $this->template = 'pages/compatibility.tpl';
- $this->template_details = 'components/compatibility_details.tpl';
+
$this->supportLevelDesc = array(
- 'untested' => $Smarty->getConfigVars('compatibilityUntested'),
- 'broken' => $Smarty->getConfigVars('compatibilityBroken'),
- 'bugged' => $Smarty->getConfigVars('compatibilityBugged'),
- 'good' => $Smarty->getConfigVars('compatibilityGood'),
- 'excellent' => $Smarty->getConfigVars('compatibilityExcellent')
+ 'untested' => $this->getConfigVars('compatibilityUntested'),
+ 'broken' => $this->getConfigVars('compatibilityBroken'),
+ 'bugged' => $this->getConfigVars('compatibilityBugged'),
+ 'good' => $this->getConfigVars('compatibilityGood'),
+ 'excellent' => $this->getConfigVars('compatibilityExcellent')
);
$this->supportLevelClass = array(
'untested' => 'pctU',
@@ -68,23 +64,22 @@ class CompatibilityPage extends Controller
public function getGame($target, $version, $oldLayout)
{
$game = CompatibilityModel::getGameData($version, $target);
- global $Smarty;
+ $this->template = 'components/compatibility_details.tpl';
return $this->renderPage(
array(
- 'title' => preg_replace('/{version}/', $version, $Smarty->getConfigVars('compatibilityTitle')),
+ 'title' => preg_replace('/{version}/', $version, $this->getConfigVars('compatibilityTitle')),
'content_title' => preg_replace(
'/{version}/',
$version,
- $Smarty->getConfigVars('compatibilityContentTitle')
+ $this->getConfigVars('compatibilityContentTitle')
),
'version' => $version,
'game' => $game,
'old_layout' => $oldLayout,
'support_level_desc' => $this->supportLevelDesc,
'support_level_class' => $this->supportLevelClass
- ),
- $this->template_details
+ )
);
}
@@ -100,15 +95,15 @@ class CompatibilityPage extends Controller
$last_updated = date("F d, Y", @filemtime($filename));
$compat_data = CompatibilityModel::getAllData($version);
- global $Smarty;
+ $this->template = 'pages/compatibility.tpl';
return $this->renderPage(
array(
- 'title' => preg_replace('/{version}/', $version, $Smarty->getConfigVars('compatibilityTitle')),
+ 'title' => preg_replace('/{version}/', $version, $this->getConfigVars('compatibilityTitle')),
'content_title' => preg_replace(
'/{version}/',
$version,
- $Smarty->getConfigVars('compatibilityContentTitle')
+ $this->getConfigVars('compatibilityContentTitle')
),
'version' => $version,
'compat_data' => $compat_data,
@@ -117,8 +112,7 @@ class CompatibilityPage extends Controller
'old_layout' => $oldLayout,
'support_level_desc' => $this->supportLevelDesc,
'support_level_class' => $this->supportLevelClass
- ),
- $this->template
+ )
);
}
}
diff --git a/include/Pages/ContactPage.php b/include/Pages/ContactPage.php
index 0c76f54..f9589b1 100644
--- a/include/Pages/ContactPage.php
+++ b/include/Pages/ContactPage.php
@@ -17,14 +17,11 @@ class ContactPage extends Controller
/* Display the index page. */
public function index()
{
- global $Smarty;
-
return $this->renderPage(
array(
- 'title' => $Smarty->getConfigVars('contactTitle'),
- 'content_title' => $Smarty->getConfigVars('contactContentTitle'),
- ),
- $this->template
+ 'title' => $this->getConfigVars('contactTitle'),
+ 'content_title' => $this->getConfigVars('contactContentTitle'),
+ )
);
}
}
diff --git a/include/Pages/CreditsPage.php b/include/Pages/CreditsPage.php
index 1abe0f7..ffbb4c7 100644
--- a/include/Pages/CreditsPage.php
+++ b/include/Pages/CreditsPage.php
@@ -6,8 +6,6 @@ use ScummVM\Models\CreditsModel;
class CreditsPage extends Controller
{
- private $template;
-
/* Constructor. */
public function __construct()
{
@@ -19,15 +17,12 @@ class CreditsPage extends Controller
public function index()
{
$credits = CreditsModel::getAllCredits();
- global $Smarty;
-
return $this->renderPage(
array(
- 'title' => $Smarty->getConfigVars('creditsTitle'),
- 'content_title' => $Smarty->getConfigVars('creditsContentTitle'),
+ 'title' => $this->getConfigVars('creditsTitle'),
+ 'content_title' => $this->getConfigVars('creditsContentTitle'),
'credits' => $credits,
- ),
- $this->template
+ )
);
}
}
diff --git a/include/Pages/DemosPage.php b/include/Pages/DemosPage.php
index 3cb2246..0948c3f 100644
--- a/include/Pages/DemosPage.php
+++ b/include/Pages/DemosPage.php
@@ -19,15 +19,12 @@ class DemosPage extends Controller
public function index()
{
$demos = GameDemosModel::getAllGroupsAndDemos();
- global $Smarty;
-
return $this->renderPage(
array(
- 'title' => $Smarty->getConfigVars('demosTitle'),
- 'content_title' => $Smarty->getConfigVars('demosContentTitle'),
+ 'title' => $this->getConfigVars('demosTitle'),
+ 'content_title' => $this->getConfigVars('demosContentTitle'),
'demos' => $demos,
- ),
- $this->template
+ )
);
}
}
diff --git a/include/Pages/DocumentationPage.php b/include/Pages/DocumentationPage.php
index 9e4d81f..0fe1e2a 100644
--- a/include/Pages/DocumentationPage.php
+++ b/include/Pages/DocumentationPage.php
@@ -19,17 +19,14 @@ class DocumentationPage extends Controller
public function index()
{
$document = $_GET['d'];
- global $Smarty;
-
$documents = DocumentationModel::getAllDocuments();
return $this->renderPage(
array(
- 'title' => $Smarty->getConfigVars('documentationTitle'),
- 'content_title' => $Smarty->getConfigVars('documentationContentTitle'),
+ 'title' => $this->getConfigVars('documentationTitle'),
+ 'content_title' => $this->getConfigVars('documentationContentTitle'),
'documents' => $documents,
- ),
- $this->template
+ )
);
}
}
diff --git a/include/Pages/DownloadsPage.php b/include/Pages/DownloadsPage.php
index f4691ff..1d98563 100644
--- a/include/Pages/DownloadsPage.php
+++ b/include/Pages/DownloadsPage.php
@@ -60,19 +60,16 @@ class DownloadsPage extends Controller
$downloads = DownloadsModel::getAllDownloads();
$sections = DownloadsModel::getAllSections();
$recommendedDownloadsJS = $this->getRecommendedDownloadsJS($downloads);
- global $Smarty;
-
return $this->renderPage(
array(
- 'title' => $Smarty->getConfigVars('downloadsTitle'),
- 'content_title' => $Smarty->getConfigVars('downloadsContentTitle'),
+ 'title' => $this->getConfigVars('downloadsTitle'),
+ 'content_title' => $this->getConfigVars('downloadsContentTitle'),
'downloads' => $downloads,
'sections' => $sections,
'release_tools' => RELEASE_TOOLS,
'release_debian' => RELEASE_DEBIAN,
'recommendedDownloadsJS' => $recommendedDownloadsJS
- ),
- $this->template
+ )
);
}
}
diff --git a/include/Pages/ExceptionsPage.php b/include/Pages/ExceptionsPage.php
index 8598fe9..eb3044c 100644
--- a/include/Pages/ExceptionsPage.php
+++ b/include/Pages/ExceptionsPage.php
@@ -3,9 +3,6 @@ namespace ScummVM\Pages;
class ExceptionsPage extends \ScummVM\Controller
{
-
-
- /* Constructor. */
public function __construct()
{
parent::__construct();
@@ -15,15 +12,12 @@ class ExceptionsPage extends \ScummVM\Controller
/* Display the index page. */
public function index($exception)
{
- global $Smarty;
-
return $this->renderPage(
array(
- 'title' => $Smarty->getConfigVars('exceptionsTitle'),
- 'content_title' => $Smarty->getConfigVars('exceptionsContentTitle'),
+ 'title' => $this->getConfigVars('exceptionsTitle'),
+ 'content_title' => $this->getConfigVars('exceptionsContentTitle'),
'exception' => $exception,
- ),
- $this->template
+ )
);
}
}
diff --git a/include/Pages/FAQPage.php b/include/Pages/FAQPage.php
index 062fdb6..8a71558 100644
--- a/include/Pages/FAQPage.php
+++ b/include/Pages/FAQPage.php
@@ -20,16 +20,13 @@ class FAQPage extends Controller
{
$contents = FAQModel::getFAQ();
$modified = FAQModel::getLastUpdated();
- global $Smarty;
-
return $this->renderPage(
array(
- 'title' => $Smarty->getConfigVars('faqTitle'),
- 'content_title' => $Smarty->getConfigVars('faqContentTitle'),
+ 'title' => $this->getConfigVars('faqTitle'),
+ 'content_title' => $this->getConfigVars('faqContentTitle'),
'contents' => $contents,
'modified' => $modified,
- ),
- $this->template
+ )
);
}
}
diff --git a/include/Pages/GamesPage.php b/include/Pages/GamesPage.php
index 5af6aca..53e9591 100644
--- a/include/Pages/GamesPage.php
+++ b/include/Pages/GamesPage.php
@@ -20,18 +20,15 @@ class GamesPage extends Controller
{
$downloads = GamesModel::getAllDownloads();
$sections = GamesModel::getAllSections();
- global $Smarty;
-
return $this->renderPage(
array(
- 'title' => $Smarty->getConfigVars('gamesTitle'),
- 'content_title' => $Smarty->getConfigVars('gamesContentTitle'),
+ 'title' => $this->getConfigVars('gamesTitle'),
+ 'content_title' => $this->getConfigVars('gamesContentTitle'),
'downloads' => $downloads,
'sections' => $sections,
'release_tools' => RELEASE_TOOLS,
'release_debian' => RELEASE_DEBIAN,
- ),
- $this->template
+ )
);
}
}
diff --git a/include/Pages/LinksPage.php b/include/Pages/LinksPage.php
index 1a96994..797cf47 100644
--- a/include/Pages/LinksPage.php
+++ b/include/Pages/LinksPage.php
@@ -19,15 +19,12 @@ class LinksPage extends Controller
public function index()
{
$links = LinksModel::getAllGroupsAndLinks();
- global $Smarty;
-
return $this->renderPage(
array(
- 'title' => $Smarty->getConfigVars('linksTitle'),
- 'content_title' => $Smarty->getConfigVars('linksContentTitle'),
+ 'title' => $this->getConfigVars('linksTitle'),
+ 'content_title' => $this->getConfigVars('linksContentTitle'),
'links' => $links,
- ),
- $this->template
+ )
);
}
}
diff --git a/include/Pages/NewsPage.php b/include/Pages/NewsPage.php
index 5030577..7196cbc 100644
--- a/include/Pages/NewsPage.php
+++ b/include/Pages/NewsPage.php
@@ -33,8 +33,6 @@ class NewsPage extends Controller
/* Display a specific news item, or all news items. */
public function getNews($filename = null)
{
- global $Smarty;
-
if ($filename == null) {
$news_items = NewsModel::getAllNews();
$filename = 'archive';
@@ -44,21 +42,18 @@ class NewsPage extends Controller
return $this->renderPage(
array(
- 'title' => $Smarty->getConfigVars('newsTitle'),
- 'content_title' => $Smarty->getConfigVars('newsContentTitle'),
+ 'title' => $this->getConfigVars('newsTitle'),
+ 'content_title' => $this->getConfigVars('newsContentTitle'),
'show_intro' => false,
'news_items' => $news_items,
'news_archive_link' => false,
- ),
- $this->template
+ )
);
}
/* Display the main page with limited news items and intro text. */
public function getNewsIntro()
{
- global $Smarty;
-
$news_items = NewsModel::getLatestNews(NEWS_ITEMS);
$random_shot = ScreenshotsModel::getRandomScreenshot();
@@ -68,14 +63,13 @@ class NewsPage extends Controller
return $this->renderPage(
array(
- 'title' => $Smarty->getConfigVars('newsTitle'),
- 'content_title' => $Smarty->getConfigVars('newsContentTitle'),
+ 'title' => $this->getConfigVars('newsTitle'),
+ 'content_title' => $this->getConfigVars('newsContentTitle'),
'show_intro' => true,
'news_items' => $news_items,
'news_archive_link' => true,
'random_shot' => $random_shot,
- ),
- $this->template
+ )
);
}
}
diff --git a/include/Pages/PressPage.php b/include/Pages/PressPage.php
index c8dc3d1..a81d5d7 100644
--- a/include/Pages/PressPage.php
+++ b/include/Pages/PressPage.php
@@ -19,15 +19,12 @@ class PressPage extends Controller
public function index()
{
$articles = ArticleModel::getAllArticles();
- global $Smarty;
-
return $this->renderPage(
array(
- 'title' => $Smarty->getConfigVars('pressTitle'),
- 'content_title' => $Smarty->getConfigVars('pressContentTitle'),
+ 'title' => $this->getConfigVars('pressTitle'),
+ 'content_title' => $this->getConfigVars('pressContentTitle'),
'articles' => $articles,
- ),
- $this->template
+ )
);
}
}
diff --git a/include/Pages/PressSnowberryPage.php b/include/Pages/PressSnowberryPage.php
index 4457b9a..a5a037f 100644
--- a/include/Pages/PressSnowberryPage.php
+++ b/include/Pages/PressSnowberryPage.php
@@ -19,15 +19,12 @@ class PressSnowberryPage extends Controller
public function index()
{
$articles = ArticleModel::getAllArticles();
- global $Smarty;
-
return $this->renderPage(
array(
- 'title' => $Smarty->getConfigVars('pressSnowberryTitle'),
- 'content_title' => $Smarty->getConfigVars('pressSnowberryContentTitle'),
+ 'title' => $this->getConfigVars('pressSnowberryTitle'),
+ 'content_title' => $this->getConfigVars('pressSnowberryContentTitle'),
'articles' => $articles,
- ),
- $this->template
+ )
);
}
}
diff --git a/include/Pages/ScreenshotsPage.php b/include/Pages/ScreenshotsPage.php
index e0ff2e1..cb0fd0e 100644
--- a/include/Pages/ScreenshotsPage.php
+++ b/include/Pages/ScreenshotsPage.php
@@ -13,8 +13,6 @@ class ScreenshotsPage extends Controller
public function __construct()
{
parent::__construct();
- $this->template = 'pages/screenshots.tpl';
- $this->template_category = 'pages/screenshots_category.tpl';
}
/* Display the index page. */
@@ -37,16 +35,15 @@ class ScreenshotsPage extends Controller
$screenshot = ScreenshotsModel::getAllScreenshots();
$random_shot = ScreenshotsModel::getRandomScreenshot();
- global $Smarty;
+ $this->template = 'pages/screenshots.tpl';
return $this->renderPage(
array(
- 'title' => $Smarty->getConfigVars('screenshotsTitle'),
- 'content_title' => $Smarty->getConfigVars('screenshotsContentTitle'),
+ 'title' => $this->getConfigVars('screenshotsTitle'),
+ 'content_title' => $this->getConfigVars('screenshotsContentTitle'),
'screenshots' => $screenshot,
'random_shot' => $random_shot,
- ),
- $this->template
+ )
);
}
@@ -66,17 +63,16 @@ class ScreenshotsPage extends Controller
);
}
- global $Smarty;
+ $this->template = 'pages/screenshots_category.tpl';
return $this->renderPage(
array(
- 'title' => $Smarty->getConfigVars('screenshotsTitle'),
- 'content_title' => $Smarty->getConfigVars('screenshotsContentTitle'),
+ 'title' => $this->getConfigVars('screenshotsTitle'),
+ 'content_title' => $this->getConfigVars('screenshotsContentTitle'),
'screenshots' => $screenshots,
'category' => $category,
'game' => $game,
- ),
- $this->template_category
+ )
);
}
diff --git a/include/Pages/SubprojectsPage.php b/include/Pages/SubprojectsPage.php
index a884207..ff0bd0e 100644
--- a/include/Pages/SubprojectsPage.php
+++ b/include/Pages/SubprojectsPage.php
@@ -19,15 +19,12 @@ class SubprojectsPage extends Controller
public function index()
{
$subprojects = SubprojectsModel::getAllSubprojects();
- global $Smarty;
-
return $this->renderPage(
array(
- 'title' => $Smarty->getConfigVars('subprojectsTitle'),
- 'content_title' => $Smarty->getConfigVars('subprojectsContentTitle'),
+ 'title' => $this->getConfigVars('subprojectsTitle'),
+ 'content_title' => $this->getConfigVars('subprojectsContentTitle'),
'subprojects' => $subprojects,
- ),
- $this->template
+ )
);
}
}
Commit: 573416873c1395639f02851c10ba0a7027d4469c
https://github.com/scummvm/scummvm-web/commit/573416873c1395639f02851c10ba0a7027d4469c
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Remove Smarty global
Changed paths:
include/Controller.php
diff --git a/include/Controller.php b/include/Controller.php
index ab8b1d0..e356992 100644
--- a/include/Controller.php
+++ b/include/Controller.php
@@ -11,6 +11,7 @@ use ScummVM\Models\MenuModel;
*/
class Controller
{
+ protected $template;
private $smarty;
private $css_files;
private $js_files;
@@ -24,10 +25,6 @@ class Controller
/* Create a Smarty object. */
$this->smarty = new Smarty();
- # Stick it globally so we could refer the translations
- global $Smarty;
- $Smarty = $this->smarty;
-
global $lang;
global $available_languages;
@@ -52,7 +49,7 @@ class Controller
$this->smarty->configLoad($fname);
}
- setlocale(LC_TIME, $Smarty->getConfigVars('locale'));
+ setlocale(LC_TIME, $this->getConfigVars('locale'));
/**
* Add a output-filter to make sure ampersands are properly encoded to
@@ -133,9 +130,9 @@ class Controller
}
/* Set up the variables used by the template and render the page. */
- public function renderPage($vars, $template)
+ public function renderPage($vars)
{
- return $this->display($this->fetch($template, $vars));
+ return $this->display($this->fetch($this->template, $vars));
}
/* Assign extra CSS files needed by the different pages/templates. */
@@ -163,4 +160,9 @@ class Controller
$this->js_files[] = $extra_js;
}
}
+
+ protected function getConfigVars($title)
+ {
+ return $this->smarty->getConfigVars($title);
+ }
}
Commit: bf31e63af66e6804622e576c68dc2d572fb925d0
https://github.com/scummvm/scummvm-web/commit/bf31e63af66e6804622e576c68dc2d572fb925d0
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
BUILD: Add phpstan config
Changed paths:
A phpstan.neon
diff --git a/phpstan.neon b/phpstan.neon
new file mode 100644
index 0000000..0876114
--- /dev/null
+++ b/phpstan.neon
@@ -0,0 +1,6 @@
+parameters:
+ level: 0
+ paths:
+ - include/
+ excludes_analyse:
+ - include/I18N.php
Commit: 7c90a6f7d64072b2af952544900d6c6347d1e140
https://github.com/scummvm/scummvm-web/commit/7c90a6f7d64072b2af952544900d6c6347d1e140
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Parse News JSON as an array instead of an object
Changed paths:
include/Models/NewsModel.php
include/Objects/News.php
diff --git a/include/Models/NewsModel.php b/include/Models/NewsModel.php
index 5902304..aa67700 100644
--- a/include/Models/NewsModel.php
+++ b/include/Models/NewsModel.php
@@ -47,7 +47,7 @@ abstract class NewsModel extends BasicModel
continue;
}
}
- $news[] = new News(json_decode($data), $filename, $processContent);
+ $news[] = new News(json_decode($data, true), $filename, $processContent);
}
return array_reverse($news);
}
@@ -85,6 +85,6 @@ abstract class NewsModel extends BasicModel
throw new \ErrorException(self::FILE_NOT_FOUND);
}
}
- return new News(json_decode($data), $fname, $processContent);
+ return new News(json_decode($data, true), $fname, $processContent);
}
}
diff --git a/include/Objects/News.php b/include/Objects/News.php
index 689f791..914690b 100644
--- a/include/Objects/News.php
+++ b/include/Objects/News.php
@@ -28,10 +28,10 @@ class News extends BasicObject
public function __construct($data, $filename, $processContent = false)
{
parent::__construct($data);
- $this->title = $processContent ? $this->processText($data->title) : $data->title;
- $this->date = $data->date;
- $this->author = $data->author;
- $this->content = $processContent ? $this->processText($data->content) : $data->content;
+ $this->title = $processContent ? $this->processText($data['title']) : $data['title'];
+ $this->date = $data['date'];
+ $this->author = $data['author'];
+ $this->content = $processContent ? $this->processText($data['content']) : $data['content'];
$this->filename = basename($filename);
}
Commit: 93f5a043bbbe68a94881ef230982a9948eb36362
https://github.com/scummvm/scummvm-web/commit/93f5a043bbbe68a94881ef230982a9948eb36362
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Rename Config.php
Changed paths:
A include/Constants.php
R include/Config.php
index.php
diff --git a/include/Config.php b/include/Config.php
deleted file mode 100644
index 891d762..0000000
--- a/include/Config.php
+++ /dev/null
@@ -1,69 +0,0 @@
-<?php
-namespace ScummVM;
-
-class Config
-{
- public function __construct()
- {
- /* Current version. */
- define('RELEASE', '2.0.0');
- define('RELEASE_TOOLS', '2.0.0');
- define('RELEASE_DEBIAN', '2.0.0');
-
- /* Version when the percentages on the compat page were removed */
- define('COMPAT_LAYOUT_CHANGE', '1.7.0');
-
- /* News items on the front page. */
- define('NEWS_ITEMS', 5);
-
- /* Number of heroes header files. */
- define('HEROES_NUM', 6);
-
- /* Base URL to the website. */
- if ($_SERVER['SERVER_PORT'] == '80') {
- $url = "http://{$_SERVER['SERVER_NAME']}";
- } elseif ($_SERVER['SERVER_PORT'] == '443') {
- $url = "https://{$_SERVER['SERVER_NAME']}";
- } else {
- $url = "http://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}";
- }
- if (substr($url, -1) != '/') {
- $url .= '/';
- }
- define('URL_BASE', $url);
-
- /* Paths. */
- define('DIR_DATA', 'data');
- define('DIR_NEWS', 'data/news');
- define('DIR_LANG', 'lang');
- define('DIR_COMPAT', 'data/compatibility');
- define('DIR_DOWNLOADS', '/downloads');
- define('DIR_SCREENSHOTS', '/data/screenshots');
-
- /* Downloads */
- define('DOWNLOADS_URL', '/frs/scummvm/{$release}/');
- define('DOWNLOADS_TOOLS_URL', '/frs/scummvm-tools/{$release}/');
-
- /**
- * Smarty configuration. The Smarty team does not recommend putting any of the
- * directories used under the web server root. 'SMARTY_DIR_COMPILE' and
- * 'SMARTY_DIR_CACHE' must be writable by the web server (chown).
- */
- define('SMARTY_DIR', 'vendor/smarty/smarty/libs/');
- define('SMARTY_DIR_TEMPLATE', 'templates');
- define('SMARTY_DIR_COMPILE', SMARTY_DIR . '/template_c');
- define('SMARTY_DIR_CACHE', SMARTY_DIR . '/cache');
- define('SMARTY_DIR_CONFIG', SMARTY_DIR . '/config');
-
- /**
- * Smarty caching options, makes it possible to cache the generated HTML to
- * speed things up. More information is available at [1].
- *
- * [1] http://www.smarty.net/manual/en/caching.php
- */
- define('SMARTY_CACHING_ENABLE', 0);
- define('SMARTY_CACHING_LIFETIME', (60 * 60));
- define('SMARTY_CACHING_COMPILE_CHECK', true); # used when developing
- define('SMARTY_CACHING_FORCE_RECHECK', true); # used when developing
- }
-}
diff --git a/include/Constants.php b/include/Constants.php
new file mode 100644
index 0000000..b960141
--- /dev/null
+++ b/include/Constants.php
@@ -0,0 +1,69 @@
+<?php
+namespace ScummVM;
+
+class Constants
+{
+ public function __construct()
+ {
+ /* Current version. */
+ define('RELEASE', '2.0.0');
+ define('RELEASE_TOOLS', '2.0.0');
+ define('RELEASE_DEBIAN', '2.0.0');
+
+ /* Version when the percentages on the compat page were removed */
+ define('COMPAT_LAYOUT_CHANGE', '1.7.0');
+
+ /* News items on the front page. */
+ define('NEWS_ITEMS', 5);
+
+ /* Number of heroes header files. */
+ define('HEROES_NUM', 6);
+
+ /* Base URL to the website. */
+ if ($_SERVER['SERVER_PORT'] == '80') {
+ $url = "http://{$_SERVER['SERVER_NAME']}";
+ } elseif ($_SERVER['SERVER_PORT'] == '443') {
+ $url = "https://{$_SERVER['SERVER_NAME']}";
+ } else {
+ $url = "http://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}";
+ }
+ if (substr($url, -1) != '/') {
+ $url .= '/';
+ }
+ define('URL_BASE', $url);
+
+ /* Paths. */
+ define('DIR_DATA', 'data');
+ define('DIR_NEWS', 'data/news');
+ define('DIR_LANG', 'lang');
+ define('DIR_COMPAT', 'data/compatibility');
+ define('DIR_DOWNLOADS', '/downloads');
+ define('DIR_SCREENSHOTS', '/data/screenshots');
+
+ /* Downloads */
+ define('DOWNLOADS_URL', '/frs/scummvm/{$release}/');
+ define('DOWNLOADS_TOOLS_URL', '/frs/scummvm-tools/{$release}/');
+
+ /**
+ * Smarty configuration. The Smarty team does not recommend putting any of the
+ * directories used under the web server root. 'SMARTY_DIR_COMPILE' and
+ * 'SMARTY_DIR_CACHE' must be writable by the web server (chown).
+ */
+ define('SMARTY_DIR', 'vendor/smarty/smarty/libs/');
+ define('SMARTY_DIR_TEMPLATE', 'templates');
+ define('SMARTY_DIR_COMPILE', SMARTY_DIR . '/template_c');
+ define('SMARTY_DIR_CACHE', SMARTY_DIR . '/cache');
+ define('SMARTY_DIR_CONFIG', SMARTY_DIR . '/config');
+
+ /**
+ * Smarty caching options, makes it possible to cache the generated HTML to
+ * speed things up. More information is available at [1].
+ *
+ * [1] http://www.smarty.net/manual/en/caching.php
+ */
+ define('SMARTY_CACHING_ENABLE', 0);
+ define('SMARTY_CACHING_LIFETIME', (60 * 60));
+ define('SMARTY_CACHING_COMPILE_CHECK', true); # used when developing
+ define('SMARTY_CACHING_FORCE_RECHECK', true); # used when developing
+ }
+}
diff --git a/index.php b/index.php
index 244737f..80e3327 100644
--- a/index.php
+++ b/index.php
@@ -59,8 +59,8 @@ if (empty($_COOKIE['clear_lang'])) {
setcookie("clear_lang", "deleted", 1456167472); // Hardcoded to 22-Feb-2016 when previous cookie expires
}
-/* Load the configuration. */
-new Config();
+/* Load the global constants. */
+new Constants();
/* Time zone to use for news items etc. */
date_default_timezone_set("UTC");
Commit: 56fc8e6d4f5822d9c9081e732fad1b6812039a9d
https://github.com/scummvm/scummvm-web/commit/56fc8e6d4f5822d9c9081e732fad1b6812039a9d
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Remove unused constant
Changed paths:
include/Constants.php
include/Controller.php
diff --git a/include/Constants.php b/include/Constants.php
index b960141..aebbe39 100644
--- a/include/Constants.php
+++ b/include/Constants.php
@@ -53,7 +53,6 @@ class Constants
define('SMARTY_DIR_TEMPLATE', 'templates');
define('SMARTY_DIR_COMPILE', SMARTY_DIR . '/template_c');
define('SMARTY_DIR_CACHE', SMARTY_DIR . '/cache');
- define('SMARTY_DIR_CONFIG', SMARTY_DIR . '/config');
/**
* Smarty caching options, makes it possible to cache the generated HTML to
diff --git a/include/Controller.php b/include/Controller.php
index e356992..eb34736 100644
--- a/include/Controller.php
+++ b/include/Controller.php
@@ -29,16 +29,14 @@ class Controller
global $available_languages;
/* Configure smarty. */
- $this->smarty->compile_dir = SMARTY_DIR_COMPILE;
- $this->smarty->cache_dir = SMARTY_DIR_CACHE;
- $this->smarty->config_dir = SMARTY_DIR_CONFIG;
+ $this->smarty->setCompileDir(SMARTY_DIR_COMPILE);
+ $this->smarty->setCacheDir(SMARTY_DIR_CACHE);
+ $this->smarty->setTemplateDir(array("templates_$lang", 'templates'));
$this->smarty->caching = SMARTY_CACHING_ENABLE;
$this->smarty->cache_lifetime = SMARTY_CACHING_LIFETIME;
$this->smarty->compile_check = SMARTY_CACHING_COMPILE_CHECK;
$this->smarty->force_compile = SMARTY_CACHING_FORCE_RECHECK;
- $this->smarty->template_dir = array("templates_$lang", 'templates');
$this->smarty->compile_id = $lang;
- $this->smarty->config_dir = ".";
# First we read English, so all defaults are there
$this->smarty->configLoad(DIR_LANG . "/lang.en.ini");
@@ -64,6 +62,7 @@ class Controller
$this->css_files = array();
$this->js_files = array();
+ $menus = array();
/* The menus have caused an exception, need to skip them. */
if (!ExceptionHandler::skipMenus()) {
$menus = MenuModel::getAllMenus();
Commit: 67778e13ce3485c065df591ff092285b916b24ce
https://github.com/scummvm/scummvm-web/commit/67778e13ce3485c065df591ff092285b916b24ce
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Fix phpdoc errors
Changed paths:
include/Objects/BasicObject.php
include/XMLParser.php
diff --git a/include/Objects/BasicObject.php b/include/Objects/BasicObject.php
index b5e4077..de57e88 100644
--- a/include/Objects/BasicObject.php
+++ b/include/Objects/BasicObject.php
@@ -31,7 +31,7 @@ abstract class BasicObject
* If the input array doesn't contain the numerical key 0, wrap it inside
* an array. This functions operates on the data directly.
*
- * @param mixed &$data the input
+ * @param mixed $data the input
*/
public static function toArray(&$data)
{
diff --git a/include/XMLParser.php b/include/XMLParser.php
index 57046a5..a790a1d 100644
--- a/include/XMLParser.php
+++ b/include/XMLParser.php
@@ -96,7 +96,6 @@ class XMLParser
* and link the values to the parent directly instead.
*
* @param string $xml the XML to parse
- * @param bool $destroy_single_arrays whether to keep nested single arrays or not
* @return bool|array
* @access public
* @since 1.0
Commit: 07f704f81418134419a8d6e047825dfc7ddd8460
https://github.com/scummvm/scummvm-web/commit/07f704f81418134419a8d6e047825dfc7ddd8460
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Remove unused Smarty parameters and update syntax
Changed paths:
include/Constants.php
include/Controller.php
diff --git a/include/Constants.php b/include/Constants.php
index aebbe39..ddfac61 100644
--- a/include/Constants.php
+++ b/include/Constants.php
@@ -53,16 +53,5 @@ class Constants
define('SMARTY_DIR_TEMPLATE', 'templates');
define('SMARTY_DIR_COMPILE', SMARTY_DIR . '/template_c');
define('SMARTY_DIR_CACHE', SMARTY_DIR . '/cache');
-
- /**
- * Smarty caching options, makes it possible to cache the generated HTML to
- * speed things up. More information is available at [1].
- *
- * [1] http://www.smarty.net/manual/en/caching.php
- */
- define('SMARTY_CACHING_ENABLE', 0);
- define('SMARTY_CACHING_LIFETIME', (60 * 60));
- define('SMARTY_CACHING_COMPILE_CHECK', true); # used when developing
- define('SMARTY_CACHING_FORCE_RECHECK', true); # used when developing
}
}
diff --git a/include/Controller.php b/include/Controller.php
index eb34736..be482cd 100644
--- a/include/Controller.php
+++ b/include/Controller.php
@@ -32,10 +32,6 @@ class Controller
$this->smarty->setCompileDir(SMARTY_DIR_COMPILE);
$this->smarty->setCacheDir(SMARTY_DIR_CACHE);
$this->smarty->setTemplateDir(array("templates_$lang", 'templates'));
- $this->smarty->caching = SMARTY_CACHING_ENABLE;
- $this->smarty->cache_lifetime = SMARTY_CACHING_LIFETIME;
- $this->smarty->compile_check = SMARTY_CACHING_COMPILE_CHECK;
- $this->smarty->force_compile = SMARTY_CACHING_FORCE_RECHECK;
$this->smarty->compile_id = $lang;
# First we read English, so all defaults are there
Commit: acfcb51c7ed3626959d48904161c31536522adb5
https://github.com/scummvm/scummvm-web/commit/acfcb51c7ed3626959d48904161c31536522adb5
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
WEB: Syntax error in exception handler
Changed paths:
include/ExceptionHandler.php
diff --git a/include/ExceptionHandler.php b/include/ExceptionHandler.php
index d3e5a6f..4725db5 100644
--- a/include/ExceptionHandler.php
+++ b/include/ExceptionHandler.php
@@ -13,7 +13,7 @@ abstract class ExceptionHandler
$e = self::$exception;
if (!is_null($e)) {
- if (basename($e->getFile() == 'MenuModel.php')) {
+ if (basename($e->getFile()) == 'MenuModel.php') {
$skip_menus = true;
} else {
foreach ($e->getTrace() as $t) {
Commit: d671d448644b0952f8493efc3658c4940671647f
https://github.com/scummvm/scummvm-web/commit/d671d448644b0952f8493efc3658c4940671647f
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-01-22T19:49:58-05:00
Commit Message:
BUILD: Increase static check levels
Changed paths:
A bootstrap.php
phpstan.neon
diff --git a/bootstrap.php b/bootstrap.php
new file mode 100644
index 0000000..b303b96
--- /dev/null
+++ b/bootstrap.php
@@ -0,0 +1,4 @@
+<?php
+use ScummVM\Constants;
+
+new Constants();
diff --git a/phpstan.neon b/phpstan.neon
index 0876114..ad85b35 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -1,6 +1,7 @@
parameters:
- level: 0
+ level: 5
paths:
- include/
excludes_analyse:
- include/I18N.php
+ bootstrap: bootstrap.php
More information about the Scummvm-git-logs
mailing list