1
0
This commit is contained in:
2020-01-17 01:28:34 +01:00
parent 85f107e8bd
commit b2e90d2f42
11 changed files with 282 additions and 323 deletions

View File

@@ -44,7 +44,7 @@ class Modules
public function Books(): Books
{
if ($this->books === null) { require_once 'modules/books.php'; $this->books = new Books(); }
if ($this->books === null) { require_once 'modules/books.php'; $this->books = new Books($this->site); }
return $this->books;
}

View File

@@ -2,11 +2,15 @@
class Books
{
/** @var Website */
private $site;
/** @var array */
private $staticData;
public function __construct()
public function __construct(Website $site)
{
$this->site = $site;
$this->load();
}
@@ -104,12 +108,10 @@ class Books
public function createPreview($prog)
{
global $CONFIG;
$src = $prog['imgfront_path'];
$dst = $prog['preview_path'];
if ($CONFIG['use_magick'])
if ($this->site->config['use_magick'])
magick_resize_image($src, 200, 0, $dst);
else
smart_resize_image($src, 200, 0, true, $dst);

View File

@@ -223,7 +223,7 @@ class Programs
if (strpos($prog['internal_name'], ' ') !== FALSE) return ['result'=>'err', 'message' => 'Internal name contains spaces ' . $prog['name']];
foreach (explode('|', $prog['ui_language']) as $lang) if (convertLanguageToFlag($lang) === null) return ['result'=>'err', 'message' => 'Unknown ui-lang ' . $prog['name']];;
foreach (explode('|', $prog['ui_language']) as $lang) if ($this->convertLanguageToFlag($lang) === null) return ['result'=>'err', 'message' => 'Unknown ui-lang ' . $prog['name']];;
if (!in_array($prog['prog_language'], self::PROG_LANGS)) return ['result'=>'err', 'message' => 'Unknown prog-lang ' . $prog['name']];
@@ -232,11 +232,11 @@ class Programs
if ($prog['license'] !== null && !array_key_exists($prog['license'], self::LICENSES)) return ['result'=>'err', 'message' => 'Unknown license ' . $prog['name']];
$isdl = false;
foreach (self::getURLs($prog) as $xurl)
foreach ($this->getURLs($prog) as $xurl)
{
if (!in_array($xurl['type'], self::URL_ORDER)) return ['result'=>'err', 'message' => 'Unknown url ' . $xurl['type']];
if ($xurl['type']==='download' && $xurl['isdirect'] && !file_exists(self::getDirectDownloadPath($prog))) return ['result'=>'err', 'message' => 'Direct download not found ' . $prog['name']];
if ($xurl['type']==='download' && $xurl['isdirect'] && !file_exists($this->getDirectDownloadPath($prog))) return ['result'=>'err', 'message' => 'Direct download not found ' . $prog['name']];
if ($xurl['type']==='download' || $xurl['type']==='playstore' || $xurl['type']==='itunesstore') $isdl = true;
}

View File

@@ -63,11 +63,6 @@ function formatMilliseconds($millis)
}
}
function isProd() {
global $CONFIG;
return $CONFIG['prod'];
}
/**
* easy image resize function
* @author http://www.nimrodstech.com/php-image-resize/