protected function getThemeMetadata(IPieCrust $app, $sources, $pattern, $exact, $log) { $metadata = array(); foreach ($sources as $source) { $repository = PieCrustHelper::getRepository($app, $source); $repositoryClass = get_class($repository); if ($log) { $log->debug("Loading themes metadata from: " . $source); } $themes = $repository->getThemes($source); foreach ($themes as $theme) { // Make sure we have the required properties. if (!isset($theme['name'])) { $theme['name'] = 'UNNAMED THEME'; } if (!isset($theme['description'])) { $theme['description'] = 'NO DESCRIPTION AVAILABLE.'; } $theme['repository_class'] = $repositoryClass; // Find if the theme matches the query. $matches = true; if ($exact) { $matches = strcasecmp($theme['name'], $pattern) == 0; } elseif ($pattern) { $matchesName = stristr($theme['name'], $pattern) != false; $matchesDescription = stristr($theme['description'], $pattern) != false; $matches = ($matchesName or $matchesDescription); } if ($matches) { // Get the theme, and exit if we only want one. $metadata[] = $theme; if ($exact) { break; } } } } return $metadata; }
protected function getPluginMetadata(IPieCrust $app, $sources, $pattern, $exact, $log) { $metadata = array(); foreach ($sources as $source) { $repository = PieCrustHelper::getRepository($app, $source); $repositoryClass = get_class($repository); if ($log) { $log->debug("Loading plugins metadata from: " . $source); } $plugins = $repository->getPlugins($source); foreach ($plugins as $plugin) { // Make sure we have the required properties. if (!isset($plugin['name'])) { $plugin['name'] = 'UNNAMED PLUGIN'; } if (!isset($plugin['description'])) { $plugin['description'] = 'NO DESCRIPTION AVAILABLE.'; } $plugin['repository_class'] = $repositoryClass; // Find if the plugin matches the query. $matches = true; if ($exact) { $matches = strcasecmp($plugin['name'], $pattern) == 0; } elseif ($pattern) { $matchesName = stristr($plugin['name'], $pattern) != false; $matchesDescription = stristr($plugin['description'], $pattern) != false; $matches = ($matchesName or $matchesDescription); } if ($matches) { $metadata[] = $plugin; } } } return $metadata; }