Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #947: Installer get all projects #984

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion www/core/modules/installer/installer.browser.inc
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,15 @@ function installer_browser_get_queued_releases() {
* @return
* Returns an array of results.
*/
function installer_browser_fetch_results($filters) {
function installer_browser_fetch_results($filters = array()) {
$filters += array(
'version' => '1',
'text' => '',
'type' => 'all',
'page' => 0,
'items_per_page' => 'all',
);

$server = installer_browser_get_server();
// Attempt to retrieve the cached version of this page.
$cid = 'installer:results:' . md5(serialize(array_merge($filters, $server)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function _project_browser_server_return($results) {
* Validate a Project Browser request.
*/
function _project_browser_server_validate($type) {
if ($type != 'module' && $type != 'theme' && $type != 'layout') {
if ($type != 'all' && $type != 'module' && $type != 'theme' && $type != 'layout') {
backdrop_add_http_header('Status', '404 Not Found');

_project_browser_server_return(t('You must specify a project type to be either "module" or "theme" or "layout".'));
Expand Down
17 changes: 11 additions & 6 deletions www/modules/custom/borg_pbs/borg_pbs.module
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function borg_pbs_project_browser_server_query($filters) {
->fields('n');

// Filter out projects based on type.
if (isset($filters['type'])) {
if (isset($filters['type']) && $filters['type'] != 'all') {
$query->condition('n.type', 'project_' . $filters['type']);
}

Expand Down Expand Up @@ -104,10 +104,12 @@ function borg_pbs_project_browser_server_query($filters) {
}

// Only send back the requested amount.
$start = $filters['page'] * $filters['items_per_page'];
$count_query = $query;
$count_result = $count_query->execute();
$query->range($start, $filters['items_per_page']);
if ($filters['items_per_page'] != 'all') {
$start = $filters['page'] * $filters['items_per_page'];
$count_query = $query;
$count_result = $count_query->execute();
$query->range($start, $filters['items_per_page']);
}

// Add the sorting.
if (!empty($filters['order'])) {
Expand Down Expand Up @@ -143,6 +145,9 @@ function borg_pbs_project_browser_server_query($filters) {
}

$result = $query->execute();
if ($filters['items_per_page'] == 'all') {
$count_result = $result;
}

$load = array();
foreach ($result as $row) {
Expand All @@ -168,7 +173,7 @@ function borg_pbs_project_browser_server_query($filters) {
$image_url = str_replace('https://projects.backdropcms.org','https://backdropcms.org', $image_url);

$projects[$node->project['name']] = array(
'type' => $filters['type'],
'type' => $node->type,
'title' => $node->title,
'name' => $node->project['name'],
'backdrop version' => $filters['version'] . '.x',
Expand Down