Skip to content

Commit

Permalink
WEB: Upgrade to Smarty 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Mataniko committed Jul 26, 2018
1 parent 5b48af2 commit ab1ded4
Show file tree
Hide file tree
Showing 91 changed files with 124 additions and 9,884 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
/include/smarty/template_c
/vendor
/templates_c
.DS_Store
/css
Expand Down
13 changes: 10 additions & 3 deletions composer.json
@@ -1,9 +1,16 @@
{
"name": "scummvm/web",
"description": "ScummVM.org main site",
"type": "project",
"description": "Scummvm.org main site",
"type": "project",
"authors": [
{
"name": "Matan Bareket",
"email": "mataniko@gmail.com"
}
],
"require": {
"leafo/scssphp": "^0.7.6"
"leafo/scssphp": "^0.7.6",
"smarty/smarty": "^3.1"
},
"scripts": {
"post-install-cmd": [
Expand Down
55 changes: 54 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions include/Controller.php
@@ -1,5 +1,5 @@
<?php
require_once(SMARTY_DIR_BASE . '/Smarty.class.php');
require_once(SMARTY_DIR . '/Smarty.class.php');
require_once('Models/MenuModel.php');
/**
* The Controller class will create an instance of the Smarty object configured
Expand Down Expand Up @@ -35,38 +35,38 @@ public function __construct() {
$this->_smarty->compile_dir = SMARTY_DIR_COMPILE;
$this->_smarty->cache_dir = SMARTY_DIR_CACHE;
$this->_smarty->config_dir = SMARTY_DIR_CONFIG;
$this->_smarty->request_use_auto_globals = SMARTY_USE_GLOBALS;
$this->_smarty->caching = SMARTY_CACHING_ENABLE;
$this->_smarty->cache_lifetime = SMARTY_CACHING_LIFETIME;
$this->_smarty->compile_check = SMARTY_CACHING_COMPILE_CHECK;
$this->_smarty->force_recheck = SMARTY_CACHING_FORCE_RECHECK;
$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 al defaults are there
$this->_smarty->config_load(DIR_LANG . "/lang.ini");
# First we read English, so all defaults are there
$this->_smarty->configLoad(DIR_LANG . "/lang.ini");

# Now we try to read translations
if (is_file(($fname = DIR_LANG . "/lang.$lang.ini"))
&& is_readable($fname)) {
$this->_smarty->config_load($fname);
$this->_smarty->configLoad($fname);
}

setlocale(LC_TIME, $Smarty->_config[0]['vars']['locale']);
setlocale(LC_TIME, $Smarty->getConfigVars('locale'));

/**
* Add a output-filter to make sure ampersands are properly encoded to
* HTML-entities.
*/
$this->_smarty->register_outputfilter(array(&$this, 'outputFilter'));
$this->_smarty->registerFilter('output', array($this, 'outputFilter'));

/* Give Smarty-template access to date(). */
$this->_smarty->register_modifier('date_f', array(&$this, 'date_f'));
$this->_smarty->register_modifier('date_localized', array(&$this, 'date_localized'));
$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->register_modifier(
$this->_smarty->registerPlugin(
'modifier',
'escapeAmpersand',
array(&$this, 'ampersandEntity')
);
Expand Down Expand Up @@ -99,7 +99,7 @@ public function __construct() {
}

/** Smarty outputfilter, run just before displaying. */
public function outputFilter($string, &$smarty) {
public function outputFilter($string, $smarty) {
/* Properly encode all ampersands as "&amp;". */
$string = preg_replace('/&(?!([a-z]+|(#\d+));)/i', '&amp;', $string);
/* Replace weird characters that appears in some of the data. */
Expand Down
18 changes: 9 additions & 9 deletions include/Pages/CompatibilityPage.php
Expand Up @@ -19,11 +19,11 @@ public function __construct() {
$this->_template = 'compatibility.tpl';
$this->_template_details = 'compatibility_details.tpl';
$this->_supportLevelDesc = array(
'untested' => $Smarty->_config[0]['vars']['compatibilityUntested'],
'broken' => $Smarty->_config[0]['vars']['compatibilityBroken'],
'bugged' => $Smarty->_config[0]['vars']['compatibilityBugged'],
'good' => $Smarty->_config[0]['vars']['compatibilityGood'],
'excellent' => $Smarty->_config[0]['vars']['compatibilityExcellent']
'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',
Expand Down Expand Up @@ -65,8 +65,8 @@ public function getGame($target, $version, $oldLayout) {

return $this->renderPage(
array(
'title' => preg_replace('/{version}/', $version, $Smarty->_config[0]['vars']['compatibilityTitle']),
'content_title' => preg_replace('/{version}/', $version, $Smarty->_config[0]['vars']['compatibilityContentTitle']),
'title' => preg_replace('/{version}/', $version, $Smarty->getConfigVars('compatibilityTitle')),
'content_title' => preg_replace('/{version}/', $version, $Smarty->getConfigVars('compatibilityContentTitle')),
'version' => $version,
'game' => $game,
'old_layout' => $oldLayout,
Expand All @@ -92,8 +92,8 @@ public function getAll($version, $versions, $oldLayout) {

return $this->renderPage(
array(
'title' => preg_replace('/{version}/', $version, $Smarty->_config[0]['vars']['compatibilityTitle']),
'content_title' => preg_replace('/{version}/', $version, $Smarty->_config[0]['vars']['compatibilityContentTitle']),
'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,
Expand Down
4 changes: 2 additions & 2 deletions include/Pages/ContactPage.php
Expand Up @@ -16,8 +16,8 @@ public function index() {

return $this->renderPage(
array(
'title' => $Smarty->_config[0]['vars']['contactTitle'],
'content_title' => $Smarty->_config[0]['vars']['contactContentTitle'],
'title' => $Smarty->getConfigVars('contactTitle'),
'content_title' => $Smarty->getConfigVars('contactContentTitle'),
),
$this->_template
);
Expand Down
4 changes: 2 additions & 2 deletions include/Pages/CreditsPage.php
Expand Up @@ -18,8 +18,8 @@ public function index() {

return $this->renderPage(
array(
'title' => $Smarty->_config[0]['vars']['creditsTitle'],
'content_title' => $Smarty->_config[0]['vars']['creditsContentTitle'],
'title' => $Smarty->getConfigVars('creditsTitle'),
'content_title' => $Smarty->getConfigVars('creditsContentTitle'),
'credits' => $credits,
),
$this->_template
Expand Down
4 changes: 2 additions & 2 deletions include/Pages/DemosPage.php
Expand Up @@ -18,8 +18,8 @@ public function index() {

return $this->renderPage(
array(
'title' => $Smarty->_config[0]['vars']['demosTitle'],
'content_title' => $Smarty->_config[0]['vars']['demosContentTitle'],
'title' => $Smarty->getConfigVars('demosTitle'),
'content_title' => $Smarty->getConfigVars('demosContentTitle'),
'demos' => $demos,
),
$this->_template
Expand Down
4 changes: 2 additions & 2 deletions include/Pages/DocumentationPage.php
Expand Up @@ -20,8 +20,8 @@ public function index() {

return $this->renderPage(
array(
'title' => $Smarty->_config[0]['vars']['documentationTitle'],
'content_title' => $Smarty->_config[0]['vars']['documentationContentTitle'],
'title' => $Smarty->getConfigVars('documentationTitle'),
'content_title' => $Smarty->getConfigVars('documentationContentTitle'),
'documents' => $documents,
),
$this->_template
Expand Down
4 changes: 2 additions & 2 deletions include/Pages/DownloadsPage.php
Expand Up @@ -54,8 +54,8 @@ public function index() {

return $this->renderPage(
array(
'title' => $Smarty->_config[0]['vars']['downloadsTitle'],
'content_title' => $Smarty->_config[0]['vars']['downloadsContentTitle'],
'title' => $Smarty->getConfigVars('downloadsTitle'),
'content_title' => $Smarty->getConfigVars('downloadsContentTitle'),
'downloads' => $downloads,
'sections' => $sections,
'release_tools' => RELEASE_TOOLS,
Expand Down
4 changes: 2 additions & 2 deletions include/Pages/ExceptionsPage.php
Expand Up @@ -16,8 +16,8 @@ public function index($exception) {

return $this->renderPage(
array(
'title' => $Smarty->_config[0]['vars']['exceptionsTitle'],
'content_title' => $Smarty->_config[0]['vars']['exceptionsContentTitle'],
'title' => $Smarty->getConfigVars('exceptionsTitle'),
'content_title' => $Smarty->getConfigVars('exceptionsContentTitle'),
'exception' => $exception,
),
'exception.tpl'
Expand Down
4 changes: 2 additions & 2 deletions include/Pages/FAQPage.php
Expand Up @@ -19,8 +19,8 @@ public function index() {

return $this->renderPage(
array(
'title' => $Smarty->_config[0]['vars']['faqTitle'],
'content_title' => $Smarty->_config[0]['vars']['faqContentTitle'],
'title' => $Smarty->getConfigVars('faqTitle'),
'content_title' => $Smarty->getConfigVars('faqContentTitle'),
'contents' => $contents,
'modified' => $modified,
),
Expand Down
4 changes: 2 additions & 2 deletions include/Pages/GamesPage.php
Expand Up @@ -19,8 +19,8 @@ public function index() {

return $this->renderPage(
array(
'title' => $Smarty->_config[0]['vars']['gamesTitle'],
'content_title' => $Smarty->_config[0]['vars']['gamesContentTitle'],
'title' => $Smarty->getConfigVars('gamesTitle'),
'content_title' => $Smarty->getConfigVars('gamesContentTitle'),
'downloads' => $downloads,
'sections' => $sections,
'release_tools' => RELEASE_TOOLS,
Expand Down
4 changes: 2 additions & 2 deletions include/Pages/LinksPage.php
Expand Up @@ -18,8 +18,8 @@ public function index() {

return $this->renderPage(
array(
'title' => $Smarty->_config[0]['vars']['linksTitle'],
'content_title' => $Smarty->_config[0]['vars']['linksContentTitle'],
'title' => $Smarty->getConfigVars('linksTitle'),
'content_title' => $Smarty->getConfigVars('linksContentTitle'),
'links' => $links,
),
$this->_template
Expand Down
10 changes: 5 additions & 5 deletions include/Pages/NewsPage.php
Expand Up @@ -39,11 +39,11 @@ public function getNews($date = null) {
$news_items = array(NewsModel::getOneByDate($date));
}
}

return $this->renderPage(
array(
'title' => $Smarty->_config[0]['vars']['newsTitle'],
'content_title' => $Smarty->_config[0]['vars']['newsContentTitle'],
'title' => $Smarty->getConfigVars('newsTitle'),
'content_title' => $Smarty->getConfigVars('newsContentTitle'),
'show_intro' => false,
'news_items' => $news_items,
'news_archive_link' => false,
Expand All @@ -66,8 +66,8 @@ public function getNewsIntro() {

return $this->renderPage(
array(
'title' => $Smarty->_config[0]['vars']['newsTitle'],
'content_title' => $Smarty->_config[0]['vars']['newsContentTitle'],
'title' => $Smarty->getConfigVars('newsTitle'),
'content_title' => $Smarty->getConfigVars('newsContentTitle'),
'show_intro' => true,
'news_items' => $news_items,
'news_archive_link' => true,
Expand Down
4 changes: 2 additions & 2 deletions include/Pages/PressPage.php
Expand Up @@ -18,8 +18,8 @@ public function index() {

return $this->renderPage(
array(
'title' => $Smarty->_config[0]['vars']['pressTitle'],
'content_title' => $Smarty->_config[0]['vars']['pressContentTitle'],
'title' => $Smarty->getConfigVars('pressTitle'),
'content_title' => $Smarty->getConfigVars('pressContentTitle'),
'articles' => $articles,
),
$this->_template
Expand Down
4 changes: 2 additions & 2 deletions include/Pages/PressSnowberryPage.php
Expand Up @@ -18,8 +18,8 @@ public function index() {

return $this->renderPage(
array(
'title' => $Smarty->_config[0]['vars']['pressSnowberryTitle'],
'content_title' => $Smarty->_config[0]['vars']['pressSnowberryContentTitle'],
'title' => $Smarty->getConfigVars('pressSnowberryTitle'),
'content_title' => $Smarty->getConfigVars('pressSnowberryContentTitle'),
'articles' => $articles,
),
$this->_template
Expand Down
8 changes: 4 additions & 4 deletions include/Pages/ScreenshotsPage.php
Expand Up @@ -37,8 +37,8 @@ public function index() {

return $this->renderPage(
array(
'title' => $Smarty->_config[0]['vars']['screenshotsTitle'],
'content_title' => $Smarty->_config[0]['vars']['screenshotsContentTitle'],
'title' => $Smarty->getConfigVars('screenshotsTitle'),
'content_title' => $Smarty->getConfigVars('screenshotsContentTitle'),
'screenshots' => $screenshot,
'random_shot' => $random_shot,
),
Expand All @@ -65,8 +65,8 @@ public function getCategory($category, $game) {

return $this->renderPage(
array(
'title' => $Smarty->_config[0]['vars']['screenshotsTitle'],
'content_title' => $Smarty->_config[0]['vars']['screenshotsContentTitle'],
'title' => $Smarty->getConfigVars('screenshotsTitle'),
'content_title' => $Smarty->getConfigVars('screenshotsContentTitle'),
'screenshots' => $screenshots,
'category' => $category,
'game' => $game,
Expand Down
4 changes: 2 additions & 2 deletions include/Pages/SubprojectsPage.php
Expand Up @@ -18,8 +18,8 @@ public function index() {

return $this->renderPage(
array(
'title' => $Smarty->_config[0]['vars']['subprojectsTitle'],
'content_title' => $Smarty->_config[0]['vars']['subprojectsContentTitle'],
'title' => $Smarty->getConfigVars('subprojectsTitle'),
'content_title' => $Smarty->getConfigVars('subprojectsContentTitle'),
'subprojects' => $subprojects,
),
$this->_template
Expand Down
9 changes: 4 additions & 5 deletions include/config.inc.php
Expand Up @@ -42,12 +42,11 @@
* 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_BASE', 'include/smarty');
define('SMARTY_DIR', 'vendor/smarty/smarty/libs/');
define('SMARTY_DIR_TEMPLATE', 'templates');
define('SMARTY_DIR_COMPILE', SMARTY_DIR_BASE . '/template_c');
define('SMARTY_DIR_CACHE', SMARTY_DIR_BASE . '/cache');
define('SMARTY_DIR_CONFIG', SMARTY_DIR_BASE . '/config');
define('SMARTY_USE_GLOBALS', false);
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].
Expand Down

0 comments on commit ab1ded4

Please sign in to comment.