Skip to content

Commit

Permalink
WEB: Support for translated news
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Jan 16, 2016
1 parent 1e5b429 commit 71fba34
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions include/Models/NewsModel.php
Expand Up @@ -66,9 +66,14 @@ static public function getOneByDate($date, $processContent = false) {
if (is_null($date) || !preg_match('/^\d{8}[a-z]?$/', $date)) {
throw new ErrorException(self::INVALID_DATE);
}
if (!is_file(($fname = DIR_NEWS . "/{$date}.xml"))
global $lang;
if (!is_file(($fname = DIR_NEWS . "$lang/{$date}.xml"))
|| !is_readable($fname) || !($data = @file_get_contents($fname))) {
throw new ErrorException(self::FILE_NOT_FOUND);

if (!is_file(($fname = DIR_NEWS . "/{$date}.xml"))
|| !is_readable($fname) || !($data = @file_get_contents($fname))) {
throw new ErrorException(self::FILE_NOT_FOUND);
}
}
return new News($data, $fname, $processContent);
}
Expand All @@ -86,8 +91,13 @@ static public function getAllByDate($date, $processContent = false) {
$files = array_reverse($files);
$news = array();
foreach ($files as $filename) {
if (($data = @file_get_contents($filename))) {
$news[] = new News($data, $filename, $processContent);
if (!is_file(($fname = DIR_NEWS . "$lang/" . basename($file)))
|| !is_readable($fname) || !($data = @file_get_contents($fname))) {
if (($data = @file_get_contents($filename))) {
$news[] = new News($data, $filename, $processContent);
}
} else {
$news[] = new News($data, $fname, $processContent);
}
}
return $news;
Expand Down

0 comments on commit 71fba34

Please sign in to comment.