diff --git a/include/Controller.php b/include/Controller.php index cf03e0e9..8e6a8a78 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 4725db5a..f14e0f1a 100644 --- a/include/ExceptionHandler.php +++ b/include/ExceptionHandler.php @@ -1,7 +1,9 @@ getAllNews($lang); diff --git a/include/Models/ArticleModel.php b/include/Models/ArticleModel.php index 92260477..9c9b00b2 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 54c893b1..6c734a7f 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 aa677007..8eb82754 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 81bd72a0..cea2e324 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 acf6834a..7b097500 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 50364bcf..d753251e 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 46112112..3a42871d 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 348fcd89..6fd27f1d 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 914690be..7e54228f 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 64c2930e..c5682a2c 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 92126a63..03861439 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 98f46fd5..d3e5d864 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 ec1e49a8..2e65d43b 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 a790a1d2..91e3e182 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, ""); } } - /* 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) {