/**
 * Gets information about all optional installed components.
 * The function is recursive to find files in all directory levels.
 *
 * TODO: Path must be provided as AOC_PATH is only for community plugin.
 * @since 0.7
 *
 * @param string $path Absolute path where to search for components.
 * @param boolean $core If we want to include the core components or not.
 * @param array $files An array with filenames to seach information in. If empty will search on $path.
 * @return array Array with all found components information.
 */
function ak_get_installed_components($path, $core = false, $files = array())
{
    if (empty($files)) {
        $files = ak_dir_content($path, 'extensions=php');
    }
    $components = array();
    foreach ($files as $subdir => $file) {
        if (is_array($file)) {
            $newdir = $path . '/' . $subdir;
            $data = ak_get_installed_components($newdir, $core, $file);
            if (is_array($data)) {
                $components = array_merge($components, $data);
            }
        } else {
            $data = ak_component_data($path . '/' . $file, $core);
            if (is_array($data)) {
                $components[$data['Component']] = $data;
            }
        }
    }
    return $components;
}
Пример #2
0
/**
 * Returns a list of templates found in an array of directories
 *
 * @param array|string $folders Array of folders to search in.
 * @param string $prefix Templates prefix filter.
 * @return array Found templates (all found php files).
 */
function ak_get_templates($folders, $prefix = '')
{
    // Compatibility with a bug in Sideposts 3.0 and 3.0.1
    if (strpos($prefix, '&')) {
        $prefix = '';
    }
    $list = array();
    foreach ((array) $folders as $folder) {
        $found = ak_dir_content($folder, "tree=0&extensions=php&with_ext=0&prefix={$prefix}");
        $list = array_merge($found, $list);
    }
    $start = strlen($prefix);
    foreach ($list as $item) {
        $name = substr($item, $start);
        $templates[$name] = ucfirst(str_replace('_', ' ', $name));
    }
    return $templates;
}