[Scummvm-git-logs] scummvm-web master -> 5de116ece917e50f27c092da4b2209226bc56838

Mataniko mataniko at gmail.com
Thu May 9 05:38:33 CEST 2019


This automated email contains information about 5 new commits which have been
pushed to the 'scummvm-web' repo located at https://github.com/scummvm/scummvm-web .

Summary:
6769084e98 WEB: Move recommended download detection to PHP
f48d95e174 WEB: Lint PHP files
5f6a9c94f0 TEMPLATES: Remove debug statement from Downloads template
67ecf5111a WEB: Remove unused JS and templates
5de116ece9 TEMPLATES: Use the right param to populate the recommended download


Commit: 6769084e987c54ffd3fdd90e53452fd341e785b4
    https://github.com/scummvm/scummvm-web/commit/6769084e987c54ffd3fdd90e53452fd341e785b4
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-05-08T23:26:05-04:00

Commit Message:
WEB: Move recommended download detection to PHP

Changed paths:
    composer.json
    composer.lock
    include/Pages/DownloadsPage.php
    templates/pages/downloads.tpl


diff --git a/composer.json b/composer.json
index 5c275d5..2f4611c 100644
--- a/composer.json
+++ b/composer.json
@@ -12,7 +12,8 @@
       "leafo/scssphp": "^0.7.6",
       "smarty/smarty": "^3.1",
       "ezyang/htmlpurifier": "^4.10",
-      "altorouter/altorouter": "^1.2"
+      "altorouter/altorouter": "^1.2",
+    "piwik/device-detector": "^3.11"
   },
   "scripts": {
     "post-install-cmd": [
@@ -51,6 +52,9 @@
     "develop-win": [
       "@build-win",
       "@run"
+    ],
+    "lint": [
+      "phpcbf ./include"
     ]
   },
   "require-dev": {
diff --git a/composer.lock b/composer.lock
index 88b55d8..126a230 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": "14d3d7305a0d894696affd2ee62cc370",
+    "content-hash": "5c1ddb4d64b56a0573fc17b7c7649f3e",
     "packages": [
         {
             "name": "altorouter/altorouter",
@@ -161,6 +161,111 @@
             "time": "2018-07-22T01:22:08+00:00"
         },
         {
+            "name": "mustangostang/spyc",
+            "version": "0.6.2",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/mustangostang/spyc.git",
+                "reference": "23c35ae854d835f2d7bcc3e3ad743d7e57a8c14d"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/mustangostang/spyc/zipball/23c35ae854d835f2d7bcc3e3ad743d7e57a8c14d",
+                "reference": "23c35ae854d835f2d7bcc3e3ad743d7e57a8c14d",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.1"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "4.3.*@dev"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "0.5.x-dev"
+                }
+            },
+            "autoload": {
+                "files": [
+                    "Spyc.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "mustangostang",
+                    "email": "vlad.andersen at gmail.com"
+                }
+            ],
+            "description": "A simple YAML loader/dumper class for PHP",
+            "homepage": "https://github.com/mustangostang/spyc/",
+            "keywords": [
+                "spyc",
+                "yaml",
+                "yml"
+            ],
+            "time": "2017-02-24T16:06:33+00:00"
+        },
+        {
+            "name": "piwik/device-detector",
+            "version": "3.11.6",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/matomo-org/device-detector.git",
+                "reference": "96d35ccd3dacf973b9b24a52686018cc047d45ae"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/matomo-org/device-detector/zipball/96d35ccd3dacf973b9b24a52686018cc047d45ae",
+                "reference": "96d35ccd3dacf973b9b24a52686018cc047d45ae",
+                "shasum": ""
+            },
+            "require": {
+                "mustangostang/spyc": "*",
+                "php": ">=5.3.2"
+            },
+            "require-dev": {
+                "fabpot/php-cs-fixer": "~1.7",
+                "matthiasmullie/scrapbook": "@stable",
+                "phpunit/phpunit": "^4.8.36",
+                "psr/cache": "^1.0",
+                "psr/simple-cache": "^1.0"
+            },
+            "suggest": {
+                "doctrine/cache": "Can directly be used for caching purpose",
+                "ext-yaml": "Necessary for using the Pecl YAML parser"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "DeviceDetector\\": ""
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "LGPL-3.0-or-later"
+            ],
+            "authors": [
+                {
+                    "name": "The Matomo Team",
+                    "email": "hello at matomo.org",
+                    "homepage": "https://matomo.org/team/"
+                }
+            ],
+            "description": "The Universal Device Detection library, that parses User Agents and detects devices (desktop, tablet, mobile, tv, cars, console, etc.), clients (browsers, media players, mobile apps, feed readers, libraries, etc), operating systems, devices, brands and models.",
+            "homepage": "https://matomo.org",
+            "keywords": [
+                "devicedetection",
+                "parser",
+                "useragent"
+            ],
+            "time": "2019-03-24T11:37:05+00:00"
+        },
+        {
             "name": "smarty/smarty",
             "version": "v3.1.33",
             "source": {
diff --git a/include/Pages/DownloadsPage.php b/include/Pages/DownloadsPage.php
index 2adebd7..92126a6 100644
--- a/include/Pages/DownloadsPage.php
+++ b/include/Pages/DownloadsPage.php
@@ -3,6 +3,7 @@ namespace ScummVM\Pages;
 
 use ScummVM\Controller;
 use ScummVM\Models\DownloadsModel;
+use DeviceDetector\Parser\OperatingSystem AS OsParser;
 
 class DownloadsPage extends Controller
 {
@@ -15,43 +16,52 @@ class DownloadsPage extends Controller
         $this->template = 'pages/downloads.tpl';
     }
 
-    private function getRecommendedDownloadsJS(&$downloads)
+    private function getRecommendedDownload($downloads)
     {
-        $versions = new \stdClass();
+        if (!isset($_SERVER['HTTP_USER_AGENT']))
+          return false;
+
+        $osParser = new OsParser();
+        $osParser->setUserAgent($_SERVER['HTTP_USER_AGENT']);
+        $os = $osParser->parse();
+
         foreach ($downloads as $dsection) {
             foreach ($dsection->getSubSections() as $dsubsection) {
-                foreach ($dsubsection->getItems() as $curItem) {
-                    $userAgent = $curItem->getUserAgent();
+                $version = array_filter($dsubsection->getItems(), function($item) use ($os) {
+                  if ($item->getUserAgent() != "") {
+                    return preg_match("/({$item->getUserAgent()})/i", $os['name']);
+                  }
+                });
 
-                    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 ($version) {
+                  $curItem = $version[0];
+                  $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;
+                  }
 
-                        $versions->$userAgent = array(
-                            'os' => $name,
-                            'ver' => $version,
-                            'desc' => $extra_text,
-                            'url' => $url,
-                        );
-                    }
+                  return array(
+                    'os' => $name,
+                    'ver' => $version,
+                    'desc' => $extra_text,
+                    'url' => $url,
+                  );
                 }
             }
         }
 
-        return 'var versions = ' . JSON_ENCODE($versions);
+       return false;
     }
 
     /* Display the index page. */
@@ -59,7 +69,7 @@ class DownloadsPage extends Controller
     {
         $downloads = DownloadsModel::getAllDownloads();
         $sections = DownloadsModel::getAllSections();
-        $recommendedDownloadsJS = $this->getRecommendedDownloadsJS($downloads);
+        $recommendedDownload = $this->getRecommendedDownload($downloads);
         return $this->renderPage(
             array(
                 'title' => $this->getConfigVars('downloadsTitle'),
@@ -68,7 +78,7 @@ class DownloadsPage extends Controller
                 'sections' => $sections,
                 'release_tools' => RELEASE_TOOLS,
                 'release' => RELEASE,
-                'recommendedDownloadsJS' => $recommendedDownloadsJS
+                'recommendedDownload' => $recommendedDownload
             )
         );
     }
diff --git a/templates/pages/downloads.tpl b/templates/pages/downloads.tpl
index 2389329..7252d4f 100644
--- a/templates/pages/downloads.tpl
+++ b/templates/pages/downloads.tpl
@@ -22,21 +22,20 @@
 {/capture}
 
 {capture "recommendedDownload"}
-		<div id="recommended-download" class="hidden">
+{$recommendedDownload}
+		<div id="recommended-download" class="{($recommendedDownload) ? 'visible':'hidden'}">
 			<div class="subhead">{#downloadsBadge#}</div>
 			<div class="subhead-content">
 				<div id="downloadContainer">
-					<a id="downloadButton">
+					<a id="downloadButton" href={$recommendedDownload.url}>
 						<img src="images/scummvm.png" alt="Download ScummVM icon">
 						<div class="downloadText">Download ScummVM</div>
-						<div id="downloadDetails"></div>
+						<div id="downloadDetails">Version {$recommendedDownload.ver}  •  {$recommendedDownload.platform}  •  {$recommendedDownload.desc}</div>
 					</a>
 				</div>
 			</div>
 		</div>
 		<br>
-		<script>{$recommendedDownloadsJS}</script>
-		<script src="/js/recommended_dl.js"></script>
 {/capture}
 
 {foreach from=$downloads item=dsection name=downloads_loop}


Commit: f48d95e174622c23f60b6aa27f423cbfe662de18
    https://github.com/scummvm/scummvm-web/commit/f48d95e174622c23f60b6aa27f423cbfe662de18
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-05-08T23:28:05-04:00

Commit Message:
WEB: Lint PHP files

Changed paths:
    include/Controller.php
    include/ExceptionHandler.php
    include/I18N.php
    include/Models/ArticleModel.php
    include/Models/MenuModel.php
    include/Models/NewsModel.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
    include/Pages/DownloadsPage.php
    include/Pages/NewsPage.php
    include/Pages/ScreenshotsPage.php
    include/XMLParser.php


diff --git a/include/Controller.php b/include/Controller.php
index cf03e0e..8e6a8a7 100644
--- a/include/Controller.php
+++ b/include/Controller.php
@@ -34,12 +34,13 @@ class Controller
         $this->smarty->setTemplateDir(SMARTY_DIR_TEMPLATE);
         $this->smarty->compile_id = $lang;
 
-        # First we read English, so all defaults are there
+        // First we read English, so all defaults are there
         $this->smarty->configLoad(DIR_LANG . "/lang.en.ini");
 
-        # Now we try to read translations
+        // Now we try to read translations
         if (is_file(($fname = DIR_LANG . "/lang.$lang.ini"))
-            && is_readable($fname)) {
+            && is_readable($fname)
+        ) {
             $this->smarty->configLoad($fname);
         }
 
@@ -64,7 +65,7 @@ class Controller
             $menus = MenuModel::getAllMenus();
         }
 
-        # Construct lang URL
+        // Construct lang URL
         $pageurl = preg_replace('/\?lang=[a-z]*$/', '', $_SERVER['REQUEST_URI']);
 
         /* Set up the common variables before displaying. */
@@ -79,7 +80,9 @@ class Controller
         $this->smarty->assign($vars);
     }
 
-    /** Smarty outputfilter, run just before displaying. */
+    /**
+     * Smarty outputfilter, run just before displaying. 
+     */
     public function outputFilter($string, $smarty)
     {
         /* Properly encode all ampersands as "&". */
@@ -88,13 +91,17 @@ class Controller
         return $string;
     }
 
-    /** Formating of dates, registered as a modifier for Smarty templates. */
+    /**
+     * Formating of dates, registered as a modifier for Smarty templates. 
+     */
     public function dateFormatSmartyModifier($timestamp, $format)
     {
         return date($format, $timestamp);
     }
 
-    /** Formating of dateAs, registered as a modifier for Smarty templates. */
+    /**
+     * Formating of dateAs, registered as a modifier for Smarty templates. 
+     */
     public function dateLocalizedSmartyModifier($timestamp, $format)
     {
         if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
diff --git a/include/ExceptionHandler.php b/include/ExceptionHandler.php
index 4725db5..f14e0f1 100644
--- a/include/ExceptionHandler.php
+++ b/include/ExceptionHandler.php
@@ -1,7 +1,9 @@
 <?php
 namespace ScummVM;
 
-/** Handle uncaught exceptions. */
+/**
+ * Handle uncaught exceptions. 
+ */
 abstract class ExceptionHandler
 {
     private static $exception;
diff --git a/include/I18N.php b/include/I18N.php
index fa6fa0f..89bba8c 100644
--- a/include/I18N.php
+++ b/include/I18N.php
@@ -62,7 +62,7 @@ class I18N
                 );
             }
         } else {
-          // Update the base english i18n file
+            // Update the base english i18n file
             echo("Converting individual JSON files to I18N base file\n");
             $newsJson = new \stdClass();
             $news = $this->getAllNews($lang);
diff --git a/include/Models/ArticleModel.php b/include/Models/ArticleModel.php
index 9226047..9c9b00b 100644
--- a/include/Models/ArticleModel.php
+++ b/include/Models/ArticleModel.php
@@ -17,12 +17,14 @@ abstract class ArticleModel extends BasicModel
         $a = $parser->parseByFilename($fname);
         $entries = array();
         foreach ($a['articles']['article'] as $key => $value) {
-            $entries[] = new Article(array(
+            $entries[] = new Article(
+                array(
                 'name' => $value['name'],
                 'url' => $value['url'],
                 'language' => $value['language'],
                 'posted' => $value['posted'],
-            ));
+                )
+            );
         }
         return $entries;
     }
diff --git a/include/Models/MenuModel.php b/include/Models/MenuModel.php
index 54c893b..6c734a7 100644
--- a/include/Models/MenuModel.php
+++ b/include/Models/MenuModel.php
@@ -17,11 +17,13 @@ abstract class MenuModel extends BasicModel
         $a = $parser->parseByFilename($fname);
         $entries = array();
         foreach ($a['menus']['group'] as $key => $value) {
-            $entries[] = new MenuItem(array(
+            $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 aa67700..8eb8275 100644
--- a/include/Models/NewsModel.php
+++ b/include/Models/NewsModel.php
@@ -42,7 +42,8 @@ abstract class NewsModel extends BasicModel
                 continue;
             }
             if (!is_file(($fname = DIR_NEWS . "/$lang/" . basename($filename)))
-                || !is_readable($fname) || !($data = @file_get_contents($fname))) {
+                || !is_readable($fname) || !($data = @file_get_contents($fname))
+            ) {
                 if (!($data = @file_get_contents(DIR_NEWS . "/{$filename}"))) {
                     continue;
                 }
@@ -79,9 +80,11 @@ abstract class NewsModel extends BasicModel
         }
         global $lang;
         if (!is_file(($fname = DIR_NEWS . "/$lang/{$filename}.json"))
-            || !is_readable($fname) || !($data = @file_get_contents($fname))) {
+            || !is_readable($fname) || !($data = @file_get_contents($fname))
+        ) {
             if (!is_file(($fname = DIR_NEWS . "/{$filename}.json"))
-                || !is_readable($fname) || !($data = @file_get_contents($fname))) {
+                || !is_readable($fname) || !($data = @file_get_contents($fname))
+            ) {
                 throw new \ErrorException(self::FILE_NOT_FOUND);
             }
         }
diff --git a/include/Models/SubprojectsModel.php b/include/Models/SubprojectsModel.php
index 81bd72a..cea2e32 100644
--- a/include/Models/SubprojectsModel.php
+++ b/include/Models/SubprojectsModel.php
@@ -29,11 +29,13 @@ abstract class SubprojectsModel extends BasicModel
                     }
                 }
             }
-            $entries[] = new Subproject(array(
+            $entries[] = new Subproject(
+                array(
                 'name' => $value['name'],
                 'info' => $value['info'],
                 'downloads' => $downloads,
-            ));
+                )
+            );
         }
         return $entries;
     }
diff --git a/include/Objects/BasicSection.php b/include/Objects/BasicSection.php
index acf6834..7b09750 100644
--- a/include/Objects/BasicSection.php
+++ b/include/Objects/BasicSection.php
@@ -39,7 +39,7 @@ abstract class BasicSection extends BasicObject
         return $this->anchor;
     }
 
-   /* Get the optional list of subsections. */
+    /* Get the optional list of subsections. */
     public function getSubSections()
     {
         return $this->subsections;
diff --git a/include/Objects/FaqEntry.php b/include/Objects/FaqEntry.php
index 50364bc..d753251 100644
--- a/include/Objects/FaqEntry.php
+++ b/include/Objects/FaqEntry.php
@@ -15,10 +15,10 @@ class FaqEntry extends BasicObject
     /**
      * 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
+     * @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)
     {
diff --git a/include/Objects/FaqSection.php b/include/Objects/FaqSection.php
index 4611211..3a42871 100644
--- a/include/Objects/FaqSection.php
+++ b/include/Objects/FaqSection.php
@@ -13,9 +13,9 @@ class FaqSection extends BasicSection
     /**
      * 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
+     * @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)
     {
diff --git a/include/Objects/File.php b/include/Objects/File.php
index 348fcd8..6fd27f1 100644
--- a/include/Objects/File.php
+++ b/include/Objects/File.php
@@ -74,7 +74,8 @@ class File extends BasicObject
                 }
 
                 if ((is_file($fname . '.sha256') && is_readable($fname . '.sha256'))
-                && (@filemtime($fname . '.sha256') > @filemtime($fname)) ) {
+                    && (@filemtime($fname . '.sha256') > @filemtime($fname)) 
+                ) {
                     $this->extra_info['sha256'] = file_get_contents($fname . '.sha256');
                 } else {
                     $hash = hash_file('sha256', $fname);
diff --git a/include/Objects/News.php b/include/Objects/News.php
index 914690b..7e54228 100644
--- a/include/Objects/News.php
+++ b/include/Objects/News.php
@@ -16,14 +16,12 @@ class News extends BasicObject
      * 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"
-   * }
-     *
-     *
+     * {
+     *    "title": "Article Title",
+     *    "content": "Your article content goes here",
+     *    "date": "UNIX timestamp",
+     *    "author": "Name"
+     * }
      */
     public function __construct($data, $filename, $processContent = false)
     {
@@ -79,7 +77,7 @@ class News extends BasicObject
         return $this->filename;
     }
 
-  /* Get the News link. */
+    /* Get the News link. */
     public function getLink()
     {
         return URL_BASE . 'news/' . substr($this->filename, 0, -5);
diff --git a/include/Objects/Screenshot.php b/include/Objects/Screenshot.php
index 64c2930..c5682a2 100644
--- a/include/Objects/Screenshot.php
+++ b/include/Objects/Screenshot.php
@@ -26,7 +26,8 @@ class Screenshot extends BasicObject
                     if (!isset($attr['from'])
                         || !isset($attr['to'])
                         || !isset($attr['format'])
-                        || !strstr($value['file'], '#n#')) {
+                        || !strstr($value['file'], '#n#')
+                    ) {
                         throw new \ErrorException('Invalid range format for ' . $value['file']);
                     }
                     $pat = str_replace("#n#", $attr['format'], $value['file']);
diff --git a/include/Pages/DownloadsPage.php b/include/Pages/DownloadsPage.php
index 92126a6..0386143 100644
--- a/include/Pages/DownloadsPage.php
+++ b/include/Pages/DownloadsPage.php
@@ -18,8 +18,9 @@ class DownloadsPage extends Controller
 
     private function getRecommendedDownload($downloads)
     {
-        if (!isset($_SERVER['HTTP_USER_AGENT']))
-          return false;
+        if (!isset($_SERVER['HTTP_USER_AGENT'])) {
+            return false;
+        }
 
         $osParser = new OsParser();
         $osParser->setUserAgent($_SERVER['HTTP_USER_AGENT']);
@@ -27,41 +28,43 @@ class DownloadsPage extends Controller
 
         foreach ($downloads as $dsection) {
             foreach ($dsection->getSubSections() as $dsubsection) {
-                $version = array_filter($dsubsection->getItems(), function($item) use ($os) {
-                  if ($item->getUserAgent() != "") {
-                    return preg_match("/({$item->getUserAgent()})/i", $os['name']);
-                  }
-                });
+                $version = array_filter(
+                    $dsubsection->getItems(), function ($item) use ($os) {
+                        if ($item->getUserAgent() != "") {
+                            return preg_match("/({$item->getUserAgent()})/i", $os['name']);
+                        }
+                    }
+                );
 
                 if ($version) {
-                  $curItem = $version[0];
-                  $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 ';
-                    }
+                    $curItem = $version[0];
+                    $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;
+                    }
 
-                  return array(
+                    return array(
                     'os' => $name,
                     'ver' => $version,
                     'desc' => $extra_text,
                     'url' => $url,
-                  );
+                    );
                 }
             }
         }
 
-       return false;
+        return false;
     }
 
     /* Display the index page. */
diff --git a/include/Pages/NewsPage.php b/include/Pages/NewsPage.php
index 98f46fd..d3e5d86 100644
--- a/include/Pages/NewsPage.php
+++ b/include/Pages/NewsPage.php
@@ -57,9 +57,11 @@ class NewsPage extends Controller
         $news_items = NewsModel::getLatestNews(NEWS_ITEMS);
         $random_shot = ScreenshotsModel::getRandomScreenshot();
 
-        $this->addJSFiles(array(
+        $this->addJSFiles(
+            array(
             'baguetteBox.min.js'
-        ));
+            )
+        );
 
         return $this->renderPage(
             array(
diff --git a/include/Pages/ScreenshotsPage.php b/include/Pages/ScreenshotsPage.php
index ec1e49a..2e65d43 100644
--- a/include/Pages/ScreenshotsPage.php
+++ b/include/Pages/ScreenshotsPage.php
@@ -21,9 +21,11 @@ class ScreenshotsPage extends Controller
         $category = $args['category'];
         $game = $args['game'];
 
-        $this->addJSFiles(array(
-          'baguetteBox.min.js'
-      ));
+        $this->addJSFiles(
+            array(
+            'baguetteBox.min.js'
+            )
+        );
 
         if (!empty($category)) {
             return $this->getCategory($category, $game);
diff --git a/include/XMLParser.php b/include/XMLParser.php
index a790a1d..91e3e18 100644
--- a/include/XMLParser.php
+++ b/include/XMLParser.php
@@ -7,8 +7,8 @@ namespace ScummVM;
  * and will add anything found in a namespace as data to the current open
  * element.
  *
- * @access public
- * @author Fredrik Wendel
+ * @access  public
+ * @author  Fredrik Wendel
  * @version 1.0
  */
 class XMLParser
@@ -30,7 +30,7 @@ class XMLParser
      * Constructor.
      *
      * @access public
-     * @since 1.0
+     * @since  1.0
      */
     public function __construct()
     {
@@ -45,10 +45,10 @@ class XMLParser
      * 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
+     * @param  string $filename full path the XML file to parse
      * @return bool|array
      * @access public
-     * @since 1.0
+     * @since  1.0
      * @throws \ErrorException
      */
     public function parseByFilename($filename)
@@ -95,10 +95,10 @@ class XMLParser
      * 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  string $xml the XML to parse
      * @return bool|array
      * @access public
-     * @since 1.0
+     * @since  1.0
      * @throws \ErrorException
      */
     public function parseByData($xml)
@@ -143,11 +143,11 @@ class XMLParser
     /**
      * 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)
+     * @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
+     * @since  1.0
      */
     private function startElement($parser, $name, $attrs)
     {
@@ -170,7 +170,7 @@ class XMLParser
                 $data .= ">";
                 $this->getElement($parser, $data);
             }
-        /* If not we can just rock on. */
+            /* If not we can just rock on. */
         } else {
             if (!is_array($attrs) || (is_array($attrs) && count($attrs) == 0)) {
                 $element = null;
@@ -211,10 +211,10 @@ class XMLParser
     /**
      * Handles data between tags in the XML-document.
      *
-     * @param resource $parser XML parser resource
-     * @param mixed $data data found between tags
+     * @param  resource $parser XML parser resource
+     * @param  mixed    $data   data found between tags
      * @access private
-     * @since 1.0
+     * @since  1.0
      */
     private function getElement($parser, $data)
     {
@@ -224,10 +224,10 @@ class XMLParser
     /**
      * Handles tags closing in the XML-document.
      *
-     * @param resource $parser XML parser resource
-     * @param string $name name of the tag
+     * @param  resource $parser XML parser resource
+     * @param  string   $name   name of the tag
      * @access private
-     * @since 1.0
+     * @since  1.0
      */
     private function endElement($parser, $name)
     {
@@ -244,7 +244,7 @@ class XMLParser
                     $this->getElement($parser, "</{$name}>");
                 }
             }
-        /* Otherwise we can just add the data. */
+            /* Otherwise we can just add the data. */
         } else {
             $data = trim($this->data);
             if (!empty($data)) {
@@ -268,11 +268,11 @@ class XMLParser
      * 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
+     * @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
+     * @since  1.0
      */
     private function simplifyArray(&$array, $parent = '', $all_singles = false)
     {


Commit: 5f6a9c94f079655f705c8c2742b258f2c15c927c
    https://github.com/scummvm/scummvm-web/commit/5f6a9c94f079655f705c8c2742b258f2c15c927c
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-05-08T23:32:53-04:00

Commit Message:
TEMPLATES: Remove debug statement from Downloads template

Changed paths:
    templates/pages/downloads.tpl


diff --git a/templates/pages/downloads.tpl b/templates/pages/downloads.tpl
index 7252d4f..61d00ce 100644
--- a/templates/pages/downloads.tpl
+++ b/templates/pages/downloads.tpl
@@ -22,7 +22,6 @@
 {/capture}
 
 {capture "recommendedDownload"}
-{$recommendedDownload}
 		<div id="recommended-download" class="{($recommendedDownload) ? 'visible':'hidden'}">
 			<div class="subhead">{#downloadsBadge#}</div>
 			<div class="subhead-content">
@@ -30,7 +29,7 @@
 					<a id="downloadButton" href={$recommendedDownload.url}>
 						<img src="images/scummvm.png" alt="Download ScummVM icon">
 						<div class="downloadText">Download ScummVM</div>
-						<div id="downloadDetails">Version {$recommendedDownload.ver}  •  {$recommendedDownload.platform}  •  {$recommendedDownload.desc}</div>
+						<div id="downloadDetails">Version {$recommendedDownload.ver} • {$recommendedDownload.platform} • {$recommendedDownload.desc}</div>
 					</a>
 				</div>
 			</div>


Commit: 67ecf5111ae01a609a69a3d950b94f91913ad0cd
    https://github.com/scummvm/scummvm-web/commit/67ecf5111ae01a609a69a3d950b94f91913ad0cd
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-05-08T23:34:35-04:00

Commit Message:
WEB: Remove unused JS and templates

Changed paths:
  R public_html/js/introduction.js
  R public_html/js/recommended_dl.js
  R templates/pages/_index.tpl


diff --git a/public_html/js/introduction.js b/public_html/js/introduction.js
deleted file mode 100644
index bf798f2..0000000
--- a/public_html/js/introduction.js
+++ /dev/null
@@ -1,78 +0,0 @@
-var base_href = $('base').attr('href');
-var rand_img = $('a#screenshots_random img');
-var image_regexp = /(data\/screenshots\/(?:.+)-full\.png)/;
-var screenshots = [];
-var position = 0;
-
-/* Change screenshot. */
-function changeScreenshot (pos) {
-	position += pos;
-	if (position < 0) {
-		position = screenshots.length-1;
-	} else if (position >= screenshots.length) {
-		position = 0;
-	}
-	rand_img.attr('src', screenshots[position][0].replace('-full.png', '.jpg'));
-	rand_img.get(0).parentNode.title = screenshots[position][1];
-}
-
-/* Find the position for the random screenshot. */
-function findPosition () {
-	var rand_url = rand_img.attr('src').replace('.jpg', '-full.png');
-	rand_url = rand_url.replace(base_href, '');
-	for (var i=0, i_max=screenshots.length; i < i_max; i++) {
-		if (screenshots[i][0] == rand_url) {
-			position = i;
-			break;
-		}
-	}
-	
-	changeScreenshot(0);
-}
-
-/* Update the preview when closing slimbox. */
-function handleClosure () {
-	var cur_img = $('#lbImage').css('background-image');
-	rand_img.attr('src', image_regexp.exec(cur_img)[0]);
-	findPosition();
-}
-
-$(document).ready(function () {
-	/* Fetch the screenshots. */
-	$.post(
-		'?p=screenshots',
-		'json=1',
-		function (data) {
-			screenshots = data;
-			findPosition();
-		},
-		'json'
-	);
-
-	/* Next screenshot. */
-	$('a#screenshots_next').click(function (evt) {
-		evt.preventDefault();
-		changeScreenshot(1);
-	});
-
-	/* Previous screenshot. */
-	$('a#screenshots_prev').click(function (evt) {
-		evt.preventDefault();
-		changeScreenshot(-1);
-	});
-
-	/* Clicking the image. */
-	rand_img.click(function (evt) {
-		evt.preventDefault();
-		$.slimbox(screenshots, position);
-	});
-
-	/* Update the random screenshot box on closure. */
-	$('a#lbCloseLink').click(handleClosure);
-	/* Piggyback on the slimbox overlay. */
-	$('div#lbOverlay').bind('mouseleave', function (evt) {
-		if ($('div#lbOverlay:visible').length == 0) {
-			handleClosure();
-		}
-	});
-});
diff --git a/public_html/js/recommended_dl.js b/public_html/js/recommended_dl.js
deleted file mode 100644
index 77c5f90..0000000
--- a/public_html/js/recommended_dl.js
+++ /dev/null
@@ -1,21 +0,0 @@
-var OS = "";
-var userAgent = navigator.appVersion;
-
-for (var version in versions) {
-	if (userAgent.indexOf(version) != -1) {
-		OS = version;
-		break;
-	}
-}
-
-if (OS != "") {
-	var ver = versions[OS]['ver'];
-	var url = versions[OS]['url'];
-	var img = versions[OS]['img'];
-	var desc = versions[OS]['desc'];
-	var platform = versions[OS]['os'];
-	document.querySelector('#downloadButton').href = url;
-	document.querySelector('#downloadDetails').innerHTML = "Version " + ver + "  •  " + platform + "  •  " + desc;
-
-	document.querySelector("#recommended-download").className = "visible"
-}
diff --git a/templates/pages/_index.tpl b/templates/pages/_index.tpl
deleted file mode 100644
index 32daed1..0000000
--- a/templates/pages/_index.tpl
+++ /dev/null
@@ -1,18 +0,0 @@
-<div class="content">
-  {* Introduction text and screenshot viewer. *}
-  {if isset($show_intro) && $show_intro}
-    {include file='intro_header.tpl'}
-  {/if}
-
-  {* The actual content. *}
-  <div class="round-box">
-    <div class="header">
-      {$content_title}
-    </div>
-    <div class="content">
-      {$content}
-    </div>
-
-    {include file='banners.tpl'}
-  </div>
-</div>


Commit: 5de116ece917e50f27c092da4b2209226bc56838
    https://github.com/scummvm/scummvm-web/commit/5de116ece917e50f27c092da4b2209226bc56838
Author: Matan Bareket (mataniko at gmail.com)
Date: 2019-05-08T23:38:22-04:00

Commit Message:
TEMPLATES: Use the right param to populate the recommended download

Changed paths:
    templates/pages/downloads.tpl


diff --git a/templates/pages/downloads.tpl b/templates/pages/downloads.tpl
index 61d00ce..55e6010 100644
--- a/templates/pages/downloads.tpl
+++ b/templates/pages/downloads.tpl
@@ -29,7 +29,7 @@
 					<a id="downloadButton" href={$recommendedDownload.url}>
 						<img src="images/scummvm.png" alt="Download ScummVM icon">
 						<div class="downloadText">Download ScummVM</div>
-						<div id="downloadDetails">Version {$recommendedDownload.ver} • {$recommendedDownload.platform} • {$recommendedDownload.desc}</div>
+						<div id="downloadDetails">Version {$recommendedDownload.ver} • {$recommendedDownload.os} • {$recommendedDownload.desc}</div>
 					</a>
 				</div>
 			</div>





More information about the Scummvm-git-logs mailing list