You are here

function apps_server_local in Apps 7

Return all local apps for the specified server.

Parameters

string $server: A machine name for a server

Return value

array An array of apps

1 call to apps_server_local()
apps_request_manifest in ./apps.manifest.inc
Request manifest and media assets from the app server.

File

./apps.manifest.inc, line 17
Handles pulling and processing of app data from the server

Code

function apps_server_local($server) {
  $apps = array();
  $modules = system_rebuild_module_data();
  foreach ($modules as $module => $info) {

    // If an app is not limited to a specific server, or the limiting server
    // is this server.
    if (isset($info->info['apps']) && (!isset($info->info['apps']['server']) || $info->info['apps']['server'] == $server['name'])) {
      $manifest = $info->info['apps'];
      $app_path = drupal_get_path('module', $module, FALSE);

      // Set some defaults, if needed.
      $manifest['machine_name'] = $module;
      $manifest['local'] = TRUE;
      if (!isset($manifest['name'])) {
        $manifest['name'] = $info->info['name'];
      }
      if (!isset($manifest['description'])) {
        $manifest['description'] = $info->info['description'];
      }
      if (!isset($manifest['version'])) {
        $manifest['version'] = $info->info['version'];
      }
      if (isset($manifest['screenshots'])) {
        foreach ($manifest['screenshots'] as $id => $image) {
          $manifest['screenshots'][$id] = $app_path . '/' . $image;
        }
      }
      if (isset($manifest['logo'])) {
        $manifest['logo'] = $app_path . '/' . $manifest['logo'];
      }
      $apps[$module] = $manifest;
    }
  }

  // Add a parent apps key for any apps this app depends on.
  foreach ($apps as $module => $info) {
    $apps[$module]['parent_apps'] = isset($apps[$module]['parent_apps']) ? $apps[$module]['parent_apps'] : array();
    if (!empty($modules[$module]->info['dependencies']) && ($parent_apps = array_intersect($modules[$module]->info['dependencies'], array_keys($apps)))) {
      $apps[$module]['parent_apps'] = array_merge($apps[$module]['parent_apps'], $parent_apps);
    }
  }
  return $apps;
}