diff options
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/app.php | 118 | ||||
-rw-r--r-- | lib/private/installer.php | 3 | ||||
-rw-r--r-- | lib/private/ocsclient.php | 2 |
3 files changed, 58 insertions, 65 deletions
diff --git a/lib/private/app.php b/lib/private/app.php index a356139044c..95a8a7302d9 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -815,7 +815,7 @@ class OC_App { * Lists all apps, this is used in apps.php * @return array */ - public static function listAllApps() { + public static function listAllApps($onlyLocal = false) { $installedApps = OC_App::getAllApps(); //TODO which apps do we want to blacklist and how do we integrate @@ -823,6 +823,7 @@ class OC_App { $blacklist = array('files'); //we don't want to show configuration for these $appList = array(); + $l = \OC::$server->getL10N('core'); foreach ($installedApps as $app) { if (array_search($app, $blacklist) === false) { @@ -849,24 +850,36 @@ class OC_App { if(isset($info['shipped']) and ($info['shipped'] == 'true')) { $info['internal'] = true; - $info['internallabel'] = 'Internal App'; - $info['internalclass'] = ''; + $info['internallabel'] = $l->t('Recommended'); + $info['internalclass'] = 'recommendedapp'; $info['removable'] = false; } else { $info['internal'] = false; - $info['internallabel'] = '3rd Party'; - $info['internalclass'] = 'externalapp'; $info['removable'] = true; } $info['update'] = OC_Installer::isUpdateAvailable($app); - $info['preview'] = OC_Helper::imagePath('settings', 'trans.png'); + $appIcon = self::getAppPath($app) . '/img/' . $app.'.svg'; + if (file_exists($appIcon)) { + $info['preview'] = OC_Helper::imagePath($app, $app.'.svg'); + $info['previewAsIcon'] = true; + } else { + $appIcon = self::getAppPath($app) . '/img/app.svg'; + if (file_exists($appIcon)) { + $info['preview'] = OC_Helper::imagePath($app, 'app.svg'); + $info['previewAsIcon'] = true; + } + } $info['version'] = OC_App::getAppVersion($app); $appList[] = $info; } } - $remoteApps = OC_App::getAppstoreApps(); + if ($onlyLocal) { + $remoteApps = array(); + } else { + $remoteApps = OC_App::getAppstoreApps(); + } if ($remoteApps) { // Remove duplicates foreach ($appList as $app) { @@ -898,9 +911,11 @@ class OC_App { } // priority 3: recommended - if ($a['internalclass'] != $b['internalclass']) { - $aTemp = ($a['internalclass'] == 'recommendedapp' ? 1 : 0); - $bTemp = ($b['internalclass'] == 'recommendedapp' ? 1 : 0); + $internalClassA = isset($a['internalclass']) ? $a['internalclass'] : ''; + $internalClassB = isset($b['internalclass']) ? $b['internalclass'] : ''; + if ($internalClassA != $internalClassB) { + $aTemp = ($internalClassA == 'recommendedapp' ? 1 : 0); + $bTemp = ($internalClassB == 'recommendedapp' ? 1 : 0); return ($bTemp - $aTemp); } @@ -917,63 +932,40 @@ class OC_App { * @return array, multi-dimensional array of apps. * Keys: id, name, type, typename, personid, license, detailpage, preview, changed, description */ - public static function getAppstoreApps($filter = 'approved') { - $categoryNames = OC_OCSClient::getCategories(); - if (is_array($categoryNames)) { - // Check that categories of apps were retrieved correctly - if (!$categories = array_keys($categoryNames)) { + public static function getAppstoreApps($filter = 'approved', $category = null) { + $categories = array($category); + if (is_null($category)) { + $categoryNames = OC_OCSClient::getCategories(); + if (is_array($categoryNames)) { + // Check that categories of apps were retrieved correctly + if (!$categories = array_keys($categoryNames)) { + return false; + } + } else { return false; } + } - $page = 0; - $remoteApps = OC_OCSClient::getApplications($categories, $page, $filter); - $app1 = array(); - $i = 0; - foreach ($remoteApps as $app) { - $app1[$i] = $app; - $app1[$i]['author'] = $app['personid']; - $app1[$i]['ocs_id'] = $app['id']; - $app1[$i]['internal'] = $app1[$i]['active'] = 0; - $app1[$i]['update'] = false; - $app1[$i]['groups'] = false; - $app1[$i]['removable'] = false; - if ($app['label'] == 'recommended') { - $app1[$i]['internallabel'] = 'Recommended'; - $app1[$i]['internalclass'] = 'recommendedapp'; - } else { - $app1[$i]['internallabel'] = '3rd Party'; - $app1[$i]['internalclass'] = 'externalapp'; - } - - - // rating img - if ($app['score'] < 5) { - $img = OC_Helper::imagePath( "core", "rating/s1.png" ); - } elseif ($app['score'] < 15) { - $img = OC_Helper::imagePath( "core", "rating/s2.png" ); - } elseif($app['score'] < 25) { - $img = OC_Helper::imagePath( "core", "rating/s3.png" ); - } elseif($app['score'] < 35) { - $img = OC_Helper::imagePath( "core", "rating/s4.png" ); - } elseif($app['score'] < 45) { - $img = OC_Helper::imagePath( "core", "rating/s5.png" ); - } elseif($app['score'] < 55) { - $img = OC_Helper::imagePath( "core", "rating/s6.png" ); - } elseif($app['score'] < 65) { - $img = OC_Helper::imagePath( "core", "rating/s7.png" ); - } elseif($app['score'] < 75) { - $img = OC_Helper::imagePath( "core", "rating/s8.png" ); - } elseif($app['score'] < 85) { - $img = OC_Helper::imagePath( "core", "rating/s9.png" ); - } elseif($app['score'] < 95) { - $img = OC_Helper::imagePath( "core", "rating/s10.png" ); - } elseif($app['score'] < 100) { - $img = OC_Helper::imagePath( "core", "rating/s11.png" ); - } - - $app1[$i]['score'] = '<img src="' . $img . '"> Score: ' . $app['score'] . '%'; - $i++; + $page = 0; + $remoteApps = OC_OCSClient::getApplications($categories, $page, $filter); + $app1 = array(); + $i = 0; + $l = \OC::$server->getL10N('core'); + foreach ($remoteApps as $app) { + $app1[$i] = $app; + $app1[$i]['author'] = $app['personid']; + $app1[$i]['ocs_id'] = $app['id']; + $app1[$i]['internal'] = $app1[$i]['active'] = 0; + $app1[$i]['update'] = false; + $app1[$i]['groups'] = false; + $app1[$i]['score'] = $app['score']; + $app1[$i]['removable'] = false; + if ($app['label'] == 'recommended') { + $app1[$i]['internallabel'] = $l->t('Recommended'); + $app1[$i]['internalclass'] = 'recommendedapp'; } + + $i++; } if (empty($app1)) { diff --git a/lib/private/installer.php b/lib/private/installer.php index 02e2190aaf2..cd1d8ce392f 100644 --- a/lib/private/installer.php +++ b/lib/private/installer.php @@ -201,11 +201,10 @@ class OC_Installer{ /** * update an app by it's id * @param integer $ocsid - * @param bool $isShipped * @return bool * @throws Exception */ - public static function updateAppByOCSId($ocsid, $isShipped=false) { + public static function updateAppByOCSId($ocsid) { $appdata = OC_OCSClient::getApplication($ocsid); $download = OC_OCSClient::getApplicationDownload($ocsid, 1); diff --git a/lib/private/ocsclient.php b/lib/private/ocsclient.php index dc147dea0c9..8ceb43f4c1f 100644 --- a/lib/private/ocsclient.php +++ b/lib/private/ocsclient.php @@ -142,9 +142,11 @@ class OC_OCSClient{ $app['license']=(string)$tmp[$i]->license; $app['detailpage']=(string)$tmp[$i]->detailpage; $app['preview']=(string)$tmp[$i]->smallpreviewpic1; + $app['preview-full']=(string)$tmp[$i]->previewpic1; $app['changed']=strtotime($tmp[$i]->changed); $app['description']=(string)$tmp[$i]->description; $app['score']=(string)$tmp[$i]->score; + $app['downloads'] = $tmp[$i]->downloads; $apps[]=$app; } |