You are here

function _hosting_package_instances_load_languages in Hosting 7.4

Same name and namespace in other branches
  1. 6.2 package/hosting_package.instance.inc \_hosting_package_instances_load_languages()
  2. 7.3 package/hosting_package.instance.inc \_hosting_package_instances_load_languages()

Get the languages associated with an instance of a package.

2 calls to _hosting_package_instances_load_languages()
_hosting_package_instances_load in package/hosting_package.instance.inc
Internal function for hosting_package_instance(s)_load.
_hosting_package_instance_languages in package/hosting_package.instance.inc

File

package/hosting_package.instance.inc, line 226
API for mapping packages to various Hosting node types

Code

function _hosting_package_instances_load_languages($instance_id = NULL, $reset = FALSE) {
  static $instances = array();
  if (!empty($reset)) {
    $instances = array();
  }

  // Build the array of languages if requested and we need to.
  if (!is_null($instance_id) && !isset($instances[$instance_id])) {
    $languages = array(
      'en' => 'en',
    );

    // load language options: if argument is null, load all language options
    $lang_result = db_query("SELECT DISTINCT(language) FROM {hosting_package_languages} WHERE iid = :iid", array(
      ':iid' => $instance_id,
    ));
    while ($language = $lang_result
      ->fetch()) {
      $languages[$language->language] = _hosting_language_name($language->language);
    }
    $instances[$instance_id] = $languages;
  }

  // Return the array of languages if requested.
  return !is_null($instance_id) ? $instances[$instance_id] : NULL;
}