You are here

function _potx_component_list in Translation template extractor 7.3

Same name and namespace in other branches
  1. 6.3 potx.admin.inc \_potx_component_list()
  2. 6.2 potx.module \_potx_component_list()
  3. 7 potx.module \_potx_component_list()
  4. 7.2 potx.admin.inc \_potx_component_list()

Generate a hierarchical structured list of components.

Return value

array Array in the directory structure identified.

  • 'normal' keyed elements being subfolders
  • '#name' elements being component objects for the 'name' component
  • '#-count' being the file count of all components in the directory
1 call to _potx_component_list()
potx_select_component_form in ./potx.admin.inc
Component selection interface.

File

./potx.admin.inc, line 252
Administrative interface for the module.

Code

function _potx_component_list() {
  $components = array();

  // Get a list of all enabled modules and themes.
  $result = db_query("SELECT name, filename, type, status FROM {system} WHERE type IN ('module', 'theme') ORDER BY filename ASC");
  foreach ($result as $component) {

    // Build directory tree structure.
    $path_parts = explode('/', dirname($component->filename));
    $dir =& $components;
    foreach ($path_parts as $dirname) {
      if (!isset($dir[$dirname])) {
        $dir[$dirname] = array();
      }
      $dir =& $dir[$dirname];
    }

    // Information about components in this directory.
    $component->basename = basename($component->filename);
    $dir['#' . $component->basename] = $component;
    $dir['#-count'] = isset($dir['#-count']) ? $dir['#-count'] + 1 : 1;
  }
  return $components;
}