本文整理汇总了PHP中OC_App::listAllApps方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_App::listAllApps方法的具体用法?PHP OC_App::listAllApps怎么用?PHP OC_App::listAllApps使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_App
的用法示例。
在下文中一共展示了OC_App::listAllApps方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listApps
/**
* Get all available categories
* @param int $category
* @return array
*/
public function listApps($category = 0)
{
$apps = array();
switch ($category) {
// installed apps
case 0:
$apps = \OC_App::listAllApps(true);
$apps = array_filter($apps, function ($app) {
return $app['active'];
});
break;
// not-installed apps
// not-installed apps
case 1:
$apps = \OC_App::listAllApps(true);
$apps = array_filter($apps, function ($app) {
return !$app['active'];
});
break;
default:
if ($category === 2) {
$apps = \OC_App::getAppstoreApps('approved');
$apps = array_filter($apps, function ($app) {
return isset($app['internalclass']) && $app['internalclass'] === 'recommendedapp';
});
} else {
$apps = \OC_App::getAppstoreApps('approved', $category);
}
if (!$apps) {
$apps = array();
}
usort($apps, function ($a, $b) {
$a = (int) $a['score'];
$b = (int) $b['score'];
if ($a === $b) {
return 0;
}
return $a > $b ? -1 : 1;
});
break;
}
// fix groups to be an array
$apps = array_map(function ($app) {
$groups = array();
if (is_string($app['groups'])) {
$groups = json_decode($app['groups']);
}
$app['groups'] = $groups;
$app['canUnInstall'] = !$app['active'] && $app['removable'];
return $app;
}, $apps);
return array('apps' => $apps, 'status' => 'success');
}
示例2: testGetAppsDisabled
public function testGetAppsDisabled()
{
$_GET['filter'] = 'disabled';
$result = \OCA\provisioning_API\Apps::getApps(array('filter' => 'disabled'));
$this->assertTrue($result->succeeded());
$data = $result->getData();
$apps = \OC_App::listAllApps();
$list = array();
foreach ($apps as $app) {
$list[] = $app['id'];
}
$disabled = array_diff($list, \OC_App::getEnabledApps());
$this->assertEquals(count($disabled), count($data['apps']));
}
示例3: getInactiveApps
/**
* @return array
*/
private function getInactiveApps()
{
$inactiveApps = \OC_App::listAllApps(true, false, $this->ocsClient);
$inactiveApps = array_filter($inactiveApps, function ($app) {
return !$app['active'];
});
$inactiveApps = array_map(function ($app) {
if (isset($app['ocsid'])) {
return $app['ocsid'];
}
return $app['id'];
}, $inactiveApps);
return $inactiveApps;
}
示例4: getInstalledApps
/**
* @return array
*/
private function getInstalledApps()
{
$apps = \OC_App::listAllApps(true);
$apps = array_filter($apps, function ($app) {
return $app['active'];
});
return $apps;
}
示例5: isset
*
* @author Frank Karlitschek
* @copyright 2012 Frank Karlitschek frank@owncloud.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
OC_Util::checkAdminUser();
// Load the files we need
OC_Util::addStyle("settings", "settings");
OC_Util::addScript("core", "multiselect");
OC_App::setActiveNavigationEntry("core_apps");
$combinedApps = OC_App::listAllApps();
$groups = \OC_Group::getGroups();
$tmpl = new OC_Template("settings", "apps", "user");
$tmpl->assign('apps', $combinedApps);
$tmpl->assign('groups', $groups);
$appid = isset($_GET['appid']) ? strip_tags($_GET['appid']) : '';
$tmpl->assign('appid', $appid);
$tmpl->printPage();
示例6: getInstalledApps
/**
* @param bool $includeUpdateInfo Should we check whether there is an update
* in the app store?
* @return array
*/
private function getInstalledApps($includeUpdateInfo = true)
{
$apps = \OC_App::listAllApps(true, $includeUpdateInfo);
$apps = array_filter($apps, function ($app) {
return $app['active'];
});
return $apps;
}
示例7: testGetAppsDisabled
public function testGetAppsDisabled()
{
$this->ocsClient->expects($this->any())->method($this->anything())->will($this->returnValue(null));
$_GET['filter'] = 'disabled';
$result = $this->api->getApps(['filter' => 'disabled']);
$this->assertTrue($result->succeeded());
$data = $result->getData();
$apps = \OC_App::listAllApps(false, true, $this->ocsClient);
$list = array();
foreach ($apps as $app) {
$list[] = $app['id'];
}
$disabled = array_diff($list, \OC_App::getEnabledApps());
$this->assertEquals(count($disabled), count($data['apps']));
}
示例8: listApps
/**
* Get all available categories
* @param int $category
* @return array
*/
public function listApps($category = 0)
{
if (!is_null($this->cache->get('listApps-' . $category))) {
$apps = $this->cache->get('listApps-' . $category);
} else {
switch ($category) {
// installed apps
case 0:
$apps = \OC_App::listAllApps(true);
$apps = array_filter($apps, function ($app) {
return $app['active'];
});
usort($apps, function ($a, $b) {
$a = (string) $a['name'];
$b = (string) $b['name'];
if ($a === $b) {
return 0;
}
return $a < $b ? -1 : 1;
});
break;
// not-installed apps
// not-installed apps
case 1:
$apps = \OC_App::listAllApps(true);
$apps = array_filter($apps, function ($app) {
return !$app['active'];
});
usort($apps, function ($a, $b) {
$a = (string) $a['name'];
$b = (string) $b['name'];
if ($a === $b) {
return 0;
}
return $a < $b ? -1 : 1;
});
break;
default:
if ($category === 2) {
$apps = \OC_App::getAppstoreApps('approved');
if ($apps) {
$apps = array_filter($apps, function ($app) {
return isset($app['internalclass']) && $app['internalclass'] === 'recommendedapp';
});
}
} else {
$apps = \OC_App::getAppstoreApps('approved', $category);
}
if (!$apps) {
$apps = array();
}
usort($apps, function ($a, $b) {
$a = (int) $a['score'];
$b = (int) $b['score'];
if ($a === $b) {
return 0;
}
return $a > $b ? -1 : 1;
});
break;
}
}
// fix groups to be an array
$dependencyAnalyzer = new DependencyAnalyzer(new Platform($this->config), $this->l10n);
$apps = array_map(function ($app) use($dependencyAnalyzer) {
// fix groups
$groups = array();
if (is_string($app['groups'])) {
$groups = json_decode($app['groups']);
}
$app['groups'] = $groups;
$app['canUnInstall'] = !$app['active'] && $app['removable'];
// fix licence vs license
if (isset($app['license']) && !isset($app['licence'])) {
$app['licence'] = $app['license'];
}
// analyse dependencies
$missing = $dependencyAnalyzer->analyze($app);
$app['canInstall'] = empty($missing);
$app['missingDependencies'] = $missing;
return $app;
}, $apps);
$this->cache->set('listApps-' . $category, $apps, 300);
return ['apps' => $apps, 'status' => 'success'];
}