/** * get a list of all apps on apps.owncloud.com * @return array, multi-dimensional array of apps. * Keys: id, name, type, typename, personid, license, detailpage, preview, changed, description */ 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; $l = \OC::$server->getL10N('core'); foreach ($remoteApps as $app) { $potentialCleanId = self::getInternalAppIdByOcs($app['id']); // enhance app info (for example the description) $app1[$i] = OC_App::parseAppInfo($app); $app1[$i]['author'] = $app['personid']; $app1[$i]['ocs_id'] = $app['id']; $app1[$i]['internal'] = 0; $app1[$i]['active'] = $potentialCleanId !== false ? self::isEnabled($potentialCleanId) : false; $app1[$i]['update'] = false; $app1[$i]['groups'] = false; $app1[$i]['score'] = $app['score']; $app1[$i]['removable'] = false; if ($app['label'] == 'recommended') { $app1[$i]['internallabel'] = (string) $l->t('Recommended'); $app1[$i]['internalclass'] = 'recommendedapp'; } $i++; } if (empty($app1)) { return false; } else { return $app1; } }
/** * Get a list of all apps on the appstore * @param string $filter * @param string|null $category * @param OCSClient $ocsClient * @return array|bool multi-dimensional array of apps. * Keys: id, name, type, typename, personid, license, detailpage, preview, changed, description */ public static function getAppstoreApps($filter = 'approved', $category = null, OCSClient $ocsClient) { $categories = [$category]; if (is_null($category)) { $categoryNames = $ocsClient->getCategories(\OCP\Util::getVersion()); 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 = $ocsClient->getApplications($categories, $page, $filter, \OCP\Util::getVersion()); $apps = []; $i = 0; $l = \OC::$server->getL10N('core'); foreach ($remoteApps as $app) { $potentialCleanId = self::getInternalAppIdByOcs($app['id']); // enhance app info (for example the description) $apps[$i] = OC_App::parseAppInfo($app); $apps[$i]['author'] = $app['personid']; $apps[$i]['ocs_id'] = $app['id']; $apps[$i]['internal'] = 0; $apps[$i]['active'] = $potentialCleanId !== false ? self::isEnabled($potentialCleanId) : false; $apps[$i]['update'] = false; $apps[$i]['groups'] = false; $apps[$i]['score'] = $app['score']; $apps[$i]['removable'] = false; if ($app['label'] == 'recommended') { $apps[$i]['internallabel'] = (string) $l->t('Recommended'); $apps[$i]['internalclass'] = 'recommendedapp'; } // Apps from the appstore are always assumed to be compatible with the // the current release as the initial filtering is done on the appstore $apps[$i]['dependencies']['owncloud']['@attributes']['min-version'] = implode('.', \OCP\Util::getVersion()); $apps[$i]['dependencies']['owncloud']['@attributes']['max-version'] = implode('.', \OCP\Util::getVersion()); $i++; } if (empty($apps)) { return false; } else { return $apps; } }
/** * Test app info parser * * @dataProvider appDataProvider * @param array $data * @param array $expected */ public function testParseAppInfo(array $data, array $expected) { $this->assertSame($expected, \OC_App::parseAppInfo($data)); }
/** * Test app info parser * * @dataProvider appDataProvider */ public function testParseAppInfo($data, $expected) { $this->assertEquals($expected, \OC_App::parseAppInfo($data)); }