diff --git a/core/modules/project_browser/css/project_browser.css b/core/modules/project_browser/css/project_browser.css index 68b9b75..0deb86a 100644 --- a/core/modules/project_browser/css/project_browser.css +++ b/core/modules/project_browser/css/project_browser.css @@ -33,19 +33,19 @@ cursor: pointer; } -div.item-list ul.project-browser-sort-list, +div.item-list ul.project-browser-sort-list, div.item-list ul.project-browser-servers-list { margin: 0; } -div.item-list ul.project-browser-sort-list li, +div.item-list ul.project-browser-sort-list li, div.item-list ul.project-browser-servers-list li { display: inline; list-style-image: none; margin-right: 10px; } -div.item-list ul.project-browser-sort-list li a, +div.item-list ul.project-browser-sort-list li a, div.item-list ul.project-browser-servers-list li a { color: #0074BD; } @@ -125,13 +125,13 @@ div.project-status { } div.project-information { - + } .project-browser-install-main { padding: 10px; float: right; - width: 76%; + width: 76%; } .install-disabled { @@ -163,7 +163,7 @@ div.install-item-prefix { } #project-browser-main div.form-item-install { - float: right; + float: right; } #project-browser div.project-browser-region { diff --git a/core/modules/project_browser/js/jquery.multiselect.min.js b/core/modules/project_browser/js/jquery.multiselect.min.js index 256d8c7..bac8630 100644 --- a/core/modules/project_browser/js/jquery.multiselect.min.js +++ b/core/modules/project_browser/js/jquery.multiselect.min.js @@ -2,9 +2,9 @@ * jQuery MultiSelect UI Widget 1.10a * Modified by Leighton Whiting for Drupal's Project Browser * Copyright (c) 2011 Eric Hynds - * + * * http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/ - * + * * Depends: * - jQuery 1.4.2+ * - jQuery UI 1.8 widget factory @@ -41,4 +41,4 @@ $container.scrollTop(0).height(o.height);if($.ui.position&&!$.isEmptyObject(o.po this.labels.eq(0).trigger('mouseover').trigger('mouseenter').find('input').trigger('focus');button.addClass('ui-state-active');this._isOpen=true;this._trigger('open');},close:function(){if(this._trigger('beforeclose')===false){return;} var o=this.options,effect=o.hide,speed=this.speed;if($.isArray(o.hide)){effect=o.hide[0];speed=o.hide[1]||this.speed;} this.menu.hide(effect,speed);this.button.removeClass('ui-state-active').trigger('blur').trigger('mouseleave');this._isOpen=false;this._trigger('close');},enable:function(){this._toggleDisabled(false);},disable:function(){this._toggleDisabled(true);},checkAll:function(e){this._toggleChecked(true);this._trigger('checkAll');},uncheckAll:function(){this._toggleChecked(false);this._trigger('uncheckAll');},getChecked:function(){return this.menu.find('input').filter(':checked');},destroy:function(){$.Widget.prototype.destroy.call(this);this.button.remove();this.menu.remove();this.element.show();return this;},isOpen:function(){return this._isOpen;},widget:function(){return this.menu;},_setOption:function(key,value){var menu=this.menu;switch(key){case'header':menu.find('div.ui-multiselect-header')[value?'show':'hide']();break;case'checkAllText':menu.find('a.ui-multiselect-all span').eq(-1).text(value);break;case'uncheckAllText':menu.find('a.ui-multiselect-none span').eq(-1).text(value);break;case'height':menu.find('ul:last').height(parseInt(value,10));break;case'minWidth':this.options[key]=parseInt(value,10);this._setButtonWidth();this._setMenuWidth();break;case'selectedText':case'selectedList':case'noneSelectedText':this.options[key]=value;this.update();break;case'classes':menu.add(this.button).removeClass(this.options.classes).addClass(value);break;} -$.Widget.prototype._setOption.apply(this,arguments);}});})(jQuery); \ No newline at end of file +$.Widget.prototype._setOption.apply(this,arguments);}});})(jQuery); diff --git a/core/modules/project_browser/js/project_browser_categories_widget.js b/core/modules/project_browser/js/project_browser_categories_widget.js index c28f738..cb91efb 100644 --- a/core/modules/project_browser/js/project_browser_categories_widget.js +++ b/core/modules/project_browser/js/project_browser_categories_widget.js @@ -8,4 +8,4 @@ at: 'right bottom' } }); -})(jQuery); \ No newline at end of file +})(jQuery); diff --git a/core/modules/project_browser/js/project_browser_more_link.js b/core/modules/project_browser/js/project_browser_more_link.js index df42ba9..b8cfb14 100644 --- a/core/modules/project_browser/js/project_browser_more_link.js +++ b/core/modules/project_browser/js/project_browser_more_link.js @@ -10,7 +10,7 @@ var moreText = Drupal.t('More'); // The "less" link text var lessText = Drupal.t('Less'); - + $(".project-information .project-description").each(function(index) { if ($(this).height() > adjustheight) { @@ -18,9 +18,9 @@ $(this).parents(".project-information").append(''); } }); - + $("a.show-more").text(moreText); - + $(".show-more").toggle(function() { $(this).parents("div:first").find(".project-description").css('height', 'auto').css('overflow', 'visible'); $(this).text(lessText); diff --git a/core/modules/project_browser/js/select_releases.js b/core/modules/project_browser/js/select_releases.js index a2bdc15..31ca0b7 100644 --- a/core/modules/project_browser/js/select_releases.js +++ b/core/modules/project_browser/js/select_releases.js @@ -6,7 +6,7 @@ */ $('.project-browser-releases-wrapper').hide(); $('.project-browser-selected-release').show(); - + $('.project-browser-show-releases-link').click(function() { var target = $(this).attr('rel'); $('.project-browser-release-' + target).show(); diff --git a/core/modules/project_browser/project_browser.admin.inc b/core/modules/project_browser/project_browser.admin.inc index b3e0d96..58991ad 100644 --- a/core/modules/project_browser/project_browser.admin.inc +++ b/core/modules/project_browser/project_browser.admin.inc @@ -10,7 +10,7 @@ /** * Builds the Admin Settings Form - * + * * @return * The $form array for the admin settings */ @@ -26,8 +26,8 @@ function project_browser_admin() { '#type' => 'textarea', '#title' => t('Repositories'), '#default_value' => variable_get('project_browser_servers', ''), - '#description' => t("Add new repositories to use for the Project Browser, one per line, in - the 'url|method|Site Name' format. Drupal.org is added by default, and doesn't need to be + '#description' => t("Add new repositories to use for the Project Browser, one per line, in + the 'url|method|Site Name' format. Drupal.org is added by default, and doesn't need to be set here."), '#required' => FALSE, ); diff --git a/core/modules/project_browser/project_browser.inc b/core/modules/project_browser/project_browser.inc index 73c6efb..dfabfae 100644 --- a/core/modules/project_browser/project_browser.inc +++ b/core/modules/project_browser/project_browser.inc @@ -1,4 +1,4 @@ - $queued_projects)); } /** * Builds the install button for the Install Queue block - * - * Since the selected projects are stored in the $_SESSION variable, + * + * Since the selected projects are stored in the $_SESSION variable, * no real processing is done, we just redirect to the install/select_versions page - * + * * @return * The $form array */ @@ -36,17 +36,17 @@ function project_browser_install_button_form($form, &$form_state) { '#type' => 'submit', '#value' => 'Install', ); - + $form['#action'] = url('admin/modules/project-browser/install/select_versions'); - + return $form; } /** * Builds the filters form - * + * * This includes categories and the string search box, and the $type is stored - * + * * @param $type * The type of project (module or theme) * @return @@ -59,7 +59,7 @@ function project_browser_filters_form($form, &$form_state, $type) { '#title' => t('Search String'), '#default_value' => isset($_SESSION['project_browser_text_filter_' . $type]) ? $_SESSION['project_browser_text_filter_' . $type] : '', ); - + // Add the categories filter if there are categories if ($categories = project_browser_get_categories($type)) { $form['categories'] = array( @@ -72,32 +72,32 @@ function project_browser_filters_form($form, &$form_state, $type) { '#default_value' => isset($_SESSION['project_browser_category_filter_' . $type]) ? $_SESSION['project_browser_category_filter_' . $type] : array(), ); } - + $form['project_type'] = array( '#type' => 'value', '#value' => $type, ); - + $form['submit'] = array( '#type' => 'submit', '#value' => t('Filter'), ); - + return $form; } /** * Builds a themed sort widget for the results - * + * * These are links which can be clicked/toggled to select and change direction - * + * * @param $sort_options * An array of sort options * @param $current_sort_option * The currently selected sort option * @param $current_sort_direction * The currently selected sort direction - * + * * @return * A themed list of sort options */ @@ -105,19 +105,19 @@ function project_browser_get_sort_widget($sort_options, $current_sort_option, $c $sort_list = array(); $sort_list[] = array('data' => t('Sort by:'), 'class' => array('sort-header')); $current_path = drupal_get_path_alias(current_path()); - + foreach ($sort_options as $sort_option) { $classes = array(); $query = array( 'order_by' => $sort_option['method'], 'sort' => $sort_option['default_sort'], ); - + // If the sort option is currently active, handle it differently if ($current_sort_option == $sort_option['method']) { $classes[] = 'sort-active'; $classes[] = 'sort-' . $current_sort_direction; - + // Set the direction of the sort link to the opposite of what it currently is if ($current_sort_direction == $query['sort']) { if ($query['sort'] == 'desc') { @@ -131,7 +131,7 @@ function project_browser_get_sort_widget($sort_options, $current_sort_option, $c else { $classes[] = 'sort-inactive'; } - + $sort_list[] = array( 'data' => l($sort_option['name'], $current_path, array('query' => $query, 'class' => array())), 'class' => $classes, @@ -139,21 +139,21 @@ function project_browser_get_sort_widget($sort_options, $current_sort_option, $c } return theme('item_list', array( - 'items' => $sort_list, + 'items' => $sort_list, 'type' => 'ul', 'attributes' => array('class' => array('project-browser-sort-list')))); } /** * Builds a themed widget to select the server - * + * * This is only called if there are more than one server enabled in the settings. - * + * * @param $server * An array of servers that should be available as options * @param $current_server * The currently selected server - * + * * @return * A themed server select widget */ @@ -161,15 +161,15 @@ function project_browser_get_server_widget($servers, $current_server) { $list = array(); $list[] = array('data' => t('Repository:'), 'class' => array('server-header')); $current_path = drupal_get_path_alias($_GET['q']); - + $i = 0; - + foreach ($servers as $url => $server) { $classes = array(); $query = array( 'repository' => $i, ); - + // If the sort option is currently active, handle it differently if ($current_server == $i) { $classes[] = 'server-active'; @@ -177,17 +177,17 @@ function project_browser_get_server_widget($servers, $current_server) { else { $classes[] = 'server-inactive'; } - + $list[] = array( 'data' => l($server['name'], $current_path, array('query' => $query, 'class' => array())), 'class' => $classes, ); - + $i += 1; } return theme('item_list', array( - 'items' => $list, + 'items' => $list, 'type' => 'ul', 'attributes' => array('class' => array('project-browser-servers-list')))); } @@ -195,10 +195,10 @@ function project_browser_get_server_widget($servers, $current_server) { /** * Builds and returns an array of sort options, keyed by method - * + * * @param $full * (Optional) Set this to TRUE if you want to get all of the supported sort methods. Defaults to FALSE - * + * * @return * An array of sort options, keyed by method */ @@ -210,19 +210,19 @@ function project_browser_get_sort_options($full = FALSE) { 'name' => array('method' => 'name', 'name' => t('Author'), 'default_sort' => 'asc'), 'latest_release' => array('method' => 'latest_release', 'name' => t('Latest release'), 'default_sort' => 'desc'), ); - + if ($full) { $sort_options['type'] = array('method' => 'type', 'name' => t('Type'), 'default_sort' => 'asc'); $sort_options['created'] = array('method' => 'created', 'name' => t('Date created'), 'default_sort' => 'asc'); $sort_options['latest_activity'] = array('method' => 'latest_activity', 'name' => t('Latest build'), 'default_sort' => 'desc'); } - + return $sort_options; } /** * Handles the filters form submit - * + * * All that we do here is store the selected categories and search string * in the $_SESSION variable. */ @@ -239,16 +239,16 @@ function project_browser_filters_form_submit($form, &$form_state) { /** * Returns all available categories for a project type - * + * * @param $type * The type of project to get the categories for. Example: 'module' or 'theme' - * + * * @return * Array containing all available categories or FALSE if no categories */ function project_browser_get_categories($type) { $categories = array(); - + // Get the server to use from SESSION if (isset($_SESSION['project_browser_server_filter'])) { $use_server = $_SESSION['project_browser_server_filter']; @@ -256,7 +256,7 @@ function project_browser_get_categories($type) { else { $use_server = 0; } - + $categories_raw = project_browser_fetch_categories($type, $use_server); if (is_array($categories_raw) AND !empty($categories_raw)) { @@ -268,10 +268,10 @@ function project_browser_get_categories($type) { } } } - + if (is_array($categories) AND !empty($categories)) { ksort($categories); - + return $categories; } return FALSE; @@ -279,18 +279,18 @@ function project_browser_get_categories($type) { /** * Prepares the categories for sending to the servers as filters - * + * * @param $raw_cats * An array of categories from $form_state['values'] * @param $type * The type of project to prepare the categories for, eg 'module' or 'theme' - * + * * @return * An array of server categories, keyed by server url */ function project_browser_prepare_categories($raw_cats, $type) { $categories = project_browser_fetch_categories($type); - + // Set the value of the categories to true if it is selected foreach ($categories as $url => $cats) { foreach ($cats as $key => $value) { @@ -302,24 +302,24 @@ function project_browser_prepare_categories($raw_cats, $type) { unset($categories[$url][$key]); } } - + // Unset the parent if there are no children if (empty($categories[$url])) { unset($categories[$url]); } } - + return $categories; } /** * Checks if a project is enabled - * + * * @param $type * The type of project. Could be 'theme' or 'module' * @param $name * The short name of the project - * + * * @return * TRUE if the project is enabled, FALSE otherwise */ @@ -338,7 +338,7 @@ function _project_browser_is_project_enabled($type, $name) { /** * Gets the currently listed projects from the session - * + * * @return * An array of listed projects from the $_SESSION variable */ @@ -346,23 +346,23 @@ function project_browser_get_listed_projects() { if (isset($_SESSION['project_browser_listed_projects'])) { return $_SESSION['project_browser_listed_projects']; } - + return array(); } /** * Gets the currently queued projects from the $_SESSION variable - * + * * @param $type * (Optional) The type of project (module or theme). Defaults to NULL, which * will return projects of all types - * + * * @return * An array of projects that are queued for install */ function project_browser_get_queued_projects($type = NULL) { $projects = array(); - + if (isset($_SESSION['project_browser_install_list'])) { foreach ($_SESSION['project_browser_install_list'] as $project) { if (is_array($project) AND !empty($project)) { @@ -375,36 +375,36 @@ function project_browser_get_queued_projects($type = NULL) { } } } - + return $projects; } /** * Gets a release from a project and a release_name - * + * * @param $release_name * The name of the release, such as '7.x-1.2' * @param $project * The $project data array - * + * * @return * The release data array or FALSE if the release doesn't exist */ function project_browser_get_release($release_name, $project) { $release_data = project_browser_get_project_release_data($project); - + return isset($release_data['releases'][$release_name]) ? $release_data['releases'][$release_name] : FALSE; } /** * Gets the newly installed projects from the session - * + * * @return * An array of all of the newly installed projects */ function project_browser_get_installed_projects() { $projects = array(); - + if (isset($_SESSION['project_browser_installed_projects'])) { foreach ($_SESSION['project_browser_installed_projects'] as $project) { if (is_array($project) AND !empty($project)) { @@ -412,13 +412,13 @@ function project_browser_get_installed_projects() { } } } - + return $projects; } /** * Adds a project to the install queue $_SESSION variable - * + * * @param $project * An array of $project data for a single project */ @@ -428,7 +428,7 @@ function project_browser_install_queue_add($project) { /** * Removes a project from the install queue $_SESSION variable - * + * * @param $project_name * The name of the project to remove, such as 'views' */ @@ -440,13 +440,13 @@ function project_browser_install_queue_remove($project_name) { /** * Gets the currently queued releases from the $_SESSION variable - * + * * @return * An array of the currently selected releases */ function project_browser_get_queued_releases() { $releases = array(); - + if (isset($_SESSION['project_browser_install_releases_list'])) { foreach ($_SESSION['project_browser_install_releases_list'] as $release_name => $project) { if (is_array($project) AND !empty($project)) { @@ -454,7 +454,7 @@ function project_browser_get_queued_releases() { } } } - + return $releases; } @@ -464,7 +464,7 @@ function project_browser_get_queued_releases() { /** * Fetches results from the servers based on the parameters passed in - * + * * $filters should be an associative array with the following keys: * array( * 'version' => '7', // The Major Version of Drupal that is running on the Client @@ -474,9 +474,9 @@ function project_browser_get_queued_releases() { * 'page' => 3, // The zero-based page number * 'requested' => 12, // How many results are requested per page * ) - * + * * The project_browser_fetch_results($filters) call returns an array like this: - * + * * array( * 'total' = 5, // The total number of results found for the filters * 'projects' => array( // An array of projects returned for this page request @@ -501,10 +501,10 @@ function project_browser_get_queued_releases() { * 'name_2 => array( ... ), * ), * ); - * + * * @param $filters * An associative array of queries to use to filter results - * + * * @return * Returns an array of results */ @@ -512,24 +512,24 @@ function project_browser_fetch_results($filters) { $servers = project_browser_get_servers($filters['server']); // Attempt to retrieve the cached version of this page $cid = md5(serialize(array_merge($filters, $servers))); - + if ($cache = cache()->get($cid)) { return $cache->data; } - + $results = array( 'projects' => array(), 'total' => 0, ); - + unset($filters['server']); - + foreach ($servers as $url => $server) { $local_filters = $filters; - + // We are not using this right now because we only expect to handle 1 server at a time currently // $local_filters['requested'] = floor($filters['requested'] / count($servers)); - + // Send only the relevant categories to the server if (isset($filters['categories'])) { if (!isset($filters['categories'][$url])) { @@ -538,13 +538,13 @@ function project_browser_fetch_results($filters) { } $local_filters['categories'] = $filters['categories'][$url]; } - + // Use XMLRPC if it is set if ($server['method'] == 'xmlrpc') { $results_raw = xmlrpc($url, array( 'project_browser_server.fetch_results' => array($local_filters), )); - + // Check for errors if ($error = xmlrpc_error() AND $error->is_error) { drupal_set_message(t("Encountered an error when trying to fetch results from @name. Error @code : @message", @@ -552,14 +552,14 @@ function project_browser_fetch_results($filters) { continue; } } - + // Use json if it is set if ($server['method'] == 'json') { $local_filters['method'] = 'query'; if (isset($local_filters['categories'])) { $local_filters['categories'] = serialize($local_filters['categories']); } - + $query_url = $url . '/query/' . $local_filters['type'] . '/8?' . http_build_query($local_filters, FALSE, '&'); $response = drupal_http_request($query_url); if ($response->code == '200') { @@ -571,11 +571,11 @@ function project_browser_fetch_results($filters) { continue; } } - + if (isset($results_raw['total'])) { $results['total'] += $results_raw['total']; } - + if (isset($results_raw['projects']) AND !empty($results_raw['projects'])) { // Merge the results $results['projects'] = array_merge($results['projects'], $results_raw['projects']); @@ -584,40 +584,40 @@ function project_browser_fetch_results($filters) { // Set the cached version of the results cache()->set($cid, $results, strtotime("+24 hours")); - + return $results; } /** * Fetches categories from the servers based on the type of project - * + * * @param $type * The type of project we are getting categories for * @param $use_server * (Optional) The server to use. Defaults to 'all' - * + * * @return * Returns an array of the categories */ function project_browser_fetch_categories($type, $use_server = 'all') { $servers = project_browser_get_servers($use_server); - + // Attempt to retrieve the cached version of this page $cid = md5('categories_' . $type . serialize($servers)); - + if ($cache = cache()->get($cid)) { return $cache->data; } else { $categories = array(); - + foreach ($servers as $url => $server) { // Use xmlrpc if it is set if ($server['method'] == 'xmlrpc') { $categories_raw = xmlrpc($url, array( 'project_browser_server.fetch_categories' => array($type), )); - + // Check for errors if ($error = xmlrpc_error() AND $error->is_error) { drupal_set_message(t("Encountered an error when trying to fetch categories from @name. Error @code : @message", @@ -625,7 +625,7 @@ function project_browser_fetch_categories($type, $use_server = 'all') { continue; } } - + // Use json if it is set if ($server['method'] == 'json') { $params = array( @@ -642,27 +642,27 @@ function project_browser_fetch_categories($type, $use_server = 'all') { continue; } } - + if (is_array($categories_raw) AND !empty($categories_raw)) { $categories[$url] = $categories_raw; } } - + // Cache this for 24 hours cache()->set($cid, $categories, strtotime("+24 hours")); } - + return $categories; } /** * Gets the servers to use for fetching results - * + * * @param $use_server * (Optional) The server to use. Defaults to 'all' - * + * * @return - * Returns an associative array of servers, populated from the project_browser_servers variable, + * Returns an associative array of servers, populated from the project_browser_servers variable, * in 'url => name' format */ function project_browser_get_servers($use_server = 'all') { @@ -673,7 +673,7 @@ function project_browser_get_servers($use_server = 'all') { 'method' => 'json', ), )); - + if ($servers_raw = variable_get('project_browser_servers', '')) { // Process the variable and add the servers to the list $custom_servers = array(); @@ -681,10 +681,10 @@ function project_browser_get_servers($use_server = 'all') { $list = explode("\n", $servers_raw); $list = array_map('trim', $list); $list = array_filter($list, 'strlen'); - + foreach ($list as $position => $text) { $method = $name = $url = FALSE; - + $matches = array(); if (preg_match('/(.*)\|(.*)\|(.*)/', $text, $matches)) { $url = $matches[1]; @@ -693,10 +693,10 @@ function project_browser_get_servers($use_server = 'all') { $custom_servers[$url] = array('name' => $name, 'method' => $method); } } - + $servers = array_merge($servers, $custom_servers); } - + // Filter out servers if necessary if ($use_server !== 'all') { $i = 0; @@ -707,16 +707,16 @@ function project_browser_get_servers($use_server = 'all') { $i += 1; } } - + return $servers; } /** * Uses the project status url to get the available releases for a project - * + * * @param $project * The project to get the releases for - * + * * @return * An array of releases for this project, or FALSE if it can't be found */ @@ -724,7 +724,7 @@ function project_browser_get_project_release_data($project) { $releases = array(); $project['project_type'] = $project['type']; $project['includes'] = array(); - + // Build the releases cache for this project module_load_include('inc', 'update', 'update.fetch'); if (_update_process_fetch_task($project)) { @@ -733,7 +733,7 @@ function project_browser_get_project_release_data($project) { return $data->data; } } - + return FALSE; } @@ -744,17 +744,17 @@ function project_browser_get_project_release_data($project) { /** * Helper function to download a project. This code is mostly copied and pasted from * modules/update/update.manager.inc - * - * There were no suitable functions that could be used besides + * + * There were no suitable functions that could be used besides * drupal_form_submit('update_manager_install_form', $form_state, $project['type']); * and it wouldn't work because this is being run from a Batch function - * - * @todo - Ideally, this should be in the update module as a standalone function, + * + * @todo - Ideally, this should be in the update module as a standalone function, * to reduce coupling and duplication - * + * * @param $url * The url of the release download - * + * * @return * An array indicating whether or not this was successful, and an error message * if applicable @@ -769,7 +769,7 @@ function project_browser_download_project($url) { 'message' => t('Unable to retrieve Drupal project from %url.', array('%url' => $url)), ); } - + // Try to extract it $directory = _update_manager_extract_directory(); try { @@ -788,7 +788,7 @@ function project_browser_download_project($url) { 'message' => t('Provided archive contains no files.'), ); } - + $project = strtok($files[0], '/\\'); $archive_errors = update_manager_archive_verify($project, $local_cache, $directory); @@ -803,7 +803,7 @@ function project_browser_download_project($url) { 'message' => array_shift($archive_errors), ); } - + // Make sure the Updater registry is loaded. drupal_get_updaters(); @@ -837,14 +837,14 @@ function project_browser_download_project($url) { $project_real_location = drupal_realpath($project_location); $updater_name = get_class($updater); - + if (fileowner($project_real_location) == fileowner(conf_path())) { module_load_include('inc', 'update', 'update.authorize'); $filetransfer = new Local(DRUPAL_ROOT); - + // Initialize some variables in the Batch API $context array. $updater = new $updater_name($project_real_location); - + try { if ($updater->isInstalled()) { // This is an update. @@ -867,7 +867,7 @@ function project_browser_download_project($url) { 'message' => t('Permissions are not set up properly.'), ); } - + return array( 'success' => TRUE, ); @@ -875,7 +875,7 @@ function project_browser_download_project($url) { /** * Installs a single release of a project during batch, for example - * + * * @param $release_name * The name of the release, such as '7.x-1.2' * @param $project @@ -886,36 +886,36 @@ function project_browser_download_project($url) { function _project_browser_batch_install_release($release_name, $project, &$context) { module_load_include('inc', 'project_browser', 'project_browser.pages'); $release = project_browser_get_release($release_name, $project); - + $result = project_browser_download_project($release['download_link']); - + if ($result['success']) { $context['results']['successes'][] = t('Successfully installed %project.', array('%project' => $project['title'])); $context['message'] = t('Installed %project...', array('%project' => $project['title'])); - + // Add this to the session variable and remove it from the install_queue variable $_SESSION['project_browser_installed_projects'][$project['name']] = $project; unset($_SESSION['project_browser_install_list'][$project['name']]); } else { - watchdog('project_browser', 'There was an error while installing %project. + watchdog('project_browser', 'There was an error while installing %project. !message', array('%project' => $project['title'], '!message' => $result['message']), WATCHDOG_ERROR); - $context['results']['failures'][] = t('Error installing %project. Errors have been logged.', + $context['results']['failures'][] = t('Error installing %project. Errors have been logged.', array('%project' => $project['title'])); - $context['message'] = t('Error installing %project. !message', + $context['message'] = t('Error installing %project. !message', array('%project' => $project['title'], '!message' => $result['message'])); } } /** * Shows a message and finishes up the batch - * + * * If there were any errors, they are reported here with drupal_set_message(). The * user is then redirected to the select versions page if there were errors, the * install dependencies page if there were any detected missing dependencies, or the * enable modules page if there were no errors. - * + * * @param $success * Whether or not the whole operation was successful * @param $results @@ -925,11 +925,11 @@ function _project_browser_batch_install_release($release_name, $project, &$conte */ function _project_browser_batch_install_releases_finished($success, $results, $operations) { drupal_get_messages(); - + // Restore the maintenance mode to what it was at the start variable_set('maintenance_mode', $_SESSION['maintenance_mode']); unset($_SESSION['maintenance_mode']); - + unset($_SESSION['project_browser_install_releases_list']); if ($success) { if (!empty($results)) { @@ -942,7 +942,7 @@ function _project_browser_batch_install_releases_finished($success, $results, $o drupal_set_message(t('Error installing projects.'), 'error'); drupal_goto('admin/modules/project-browser/install/select_versions'); } - + $projects = project_browser_get_installed_projects(); $missing = project_browser_get_missing_dependencies($projects); // If there are missing dependencies, go to install dependencies @@ -956,18 +956,18 @@ function _project_browser_batch_install_releases_finished($success, $results, $o /** * Gets the dependencies for installed projects - * + * * @param $projects * An array of projects to get the missing dependencies for - * + * * @return * An array of missing dependencies, if any were detected */ function project_browser_get_missing_dependencies($projects) { $modules = system_rebuild_module_data(); - + $missing = array(); - + foreach ($projects as $project) { if ($project['type'] == 'module') { $dependency_check = TRUE; @@ -988,6 +988,6 @@ function project_browser_get_missing_dependencies($projects) { } } } - + return $missing; } diff --git a/core/modules/project_browser/project_browser.info b/core/modules/project_browser/project_browser.info index c6510a8..8e3766c 100644 --- a/core/modules/project_browser/project_browser.info +++ b/core/modules/project_browser/project_browser.info @@ -4,4 +4,4 @@ dependencies[] = update package = Core version = VERSION core = 8.x -files[] = project_browser.test \ No newline at end of file +files[] = project_browser.test diff --git a/core/modules/project_browser/project_browser.module b/core/modules/project_browser/project_browser.module index 5319f6b..fb24a79 100644 --- a/core/modules/project_browser/project_browser.module +++ b/core/modules/project_browser/project_browser.module @@ -2,14 +2,14 @@ /** * @file * Project Browser module. - * + * * This module provides a new UI for admins to easily browse modules and themes from their * admin pages, and install them. */ /** * Implements hook_help(). - * + * * Displays help and module information */ function project_browser_help($path, $arg) { @@ -49,7 +49,7 @@ function project_browser_menu() { 'access arguments' => array('access administration pages'), 'file' => 'project_browser.admin.inc', ); - + $items['admin/modules/project-browser'] = array( 'title' => 'Project Browser', 'description' => 'Browse and search for new modules', @@ -58,7 +58,7 @@ function project_browser_menu() { 'access arguments' => array('use project browser'), 'file' => 'project_browser.pages.inc', ); - + $items['admin/modules/project-browser/modules'] = array( 'title' => 'Modules', 'description' => 'Browse and search for new modules', @@ -68,7 +68,7 @@ function project_browser_menu() { 'file' => 'project_browser.pages.inc', 'type' => MENU_DEFAULT_LOCAL_TASK, ); - + $items['admin/modules/project-browser/themes'] = array( 'title' => 'Themes', 'description' => 'Browse and search for new themes', @@ -78,7 +78,7 @@ function project_browser_menu() { 'file' => 'project_browser.pages.inc', 'type' => MENU_LOCAL_TASK, ); - + $items['admin/modules/project-browser/install/%'] = array( 'title' => 'Install', 'page callback' => 'project_browser_installation_page', @@ -87,7 +87,7 @@ function project_browser_menu() { 'type' => MENU_NORMAL_ITEM, 'file' => 'project_browser.pages.inc', ); - + $items['project-browser/%/install-queue/%/%'] = array( 'page callback' => 'project_browser_install_queue_callback', 'page arguments' => array(1, 3, 4), @@ -99,16 +99,16 @@ function project_browser_menu() { /** * Page callback that allows for adding to and removing from the install queue - * + * * This is invoked via AJAX most of the time */ function project_browser_install_queue_callback($method, $op, $project_name) { module_load_include('inc', 'project_browser', 'project_browser'); - + switch ($op) { case 'add': $projects = project_browser_get_listed_projects(); - + if (isset($projects[$project_name])) { $project = $projects[$project_name]; project_browser_install_queue_add($project); @@ -117,22 +117,22 @@ function project_browser_install_queue_callback($method, $op, $project_name) { drupal_set_message(t('Error: The project was not found.'), 'error'); } break; - - case 'remove': + + case 'remove': project_browser_install_queue_remove($project_name); break; } - + switch ($method) { case 'nojs': // Redirect to the page it came from $redirect = (isset($_GET['destination'])) ? $_GET['destination'] : 'admin/modules/project-browser'; - + drupal_goto($redirect); break; case 'ajax': $commands = array(); - + // Refresh the install queue $commands[] = ajax_command_replace('#project-browser-install-queue', project_browser_get_install_list()); // Refresh the add to queue link @@ -145,7 +145,7 @@ function project_browser_install_queue_callback($method, $op, $project_name) { /** * Implements hook_menu_local_tasks_alter(). - * + * * This is used to put the 'Project Browser' action on the 'Modules' page */ function project_browser_menu_local_tasks_alter(&$data, $router_item, $root_path) { @@ -202,7 +202,7 @@ function project_browser_menu_local_tasks_alter(&$data, $router_item, $root_path // ====================================== /** - * Implements hook_theme() + * Implements hook_theme() */ function project_browser_theme($existing, $type, $theme, $path) { return array( @@ -241,7 +241,7 @@ function project_browser_theme($existing, $type, $theme, $path) { /** * Adds some variables for the projects install theme - * + * * @param $variables * An associative array containing: * - current_task : the current task @@ -254,7 +254,7 @@ function project_browser_preprocess_project_browser_install(&$variables) { /** * Adds some variables for the projects install queue theme - * + * * @param $variables * An associative array containing: * - projects : an array of projects in the install queue @@ -276,14 +276,14 @@ function project_browser_preprocess_project_browser_install_queue(&$variables) { } $build['install-link'] = drupal_get_form('project_browser_install_button_form'); } - + // Add the install button $variables['queue_html'] = drupal_render($build); } /** * Add some variables for the project browser block theme - * + * * @param $variables * An associative array containing: * - element['#title'] : the title of the block @@ -297,7 +297,7 @@ function project_browser_preprocess_project_browser_block(&$variables) { /** * Add some variables for the projects list theme - * + * * @param $variables * An associative array containing: * - projects_list : array of all projects @@ -305,7 +305,7 @@ function project_browser_preprocess_project_browser_block(&$variables) { function project_browser_preprocess_project_browser_list(&$variables) { module_load_include('inc', 'project_browser', 'project_browser'); drupal_add_css(drupal_get_path('module', 'project_browser') . '/css/project_browser.css'); - + if (is_array($variables['projects_list']) AND !empty($variables['projects_list'])) { $content = ''; $first = TRUE; @@ -318,7 +318,7 @@ function project_browser_preprocess_project_browser_list(&$variables) { else { $content = t('No results found.'); } - + switch ($variables['type']) { case 'module': $title = t('Modules'); @@ -330,33 +330,33 @@ function project_browser_preprocess_project_browser_list(&$variables) { $title = t('Projects'); break; } - + $main_content['project_browser_main_block'] = array( '#theme' => 'project_browser_block', - '#title' => $title, + '#title' => $title, '#content' => $content, '#contextual_links' => array( 'project_browser' => array('admin/config/development/project_browser', array()), ), ); $variables['main_content'] = render($main_content); - + // Add the pager $variables['pager'] = theme('pager', array('tags' => NULL)); - + // Add the filters $filters_form = drupal_get_form('project_browser_filters_form', $variables['type']); $filters['project_browser_filters_block'] = array( '#theme' => 'project_browser_block', - '#title' => t('Filters'), + '#title' => t('Filters'), '#content' => drupal_render($filters_form), ); $variables['filters'] = render($filters); - + // Add the install list $install_list['project_browser_filters_block'] = array( '#theme' => 'project_browser_block', - '#title' => t('Install queue'), + '#title' => t('Install queue'), '#content' => project_browser_get_install_list(), ); $variables['install_list'] = render($install_list); @@ -364,7 +364,7 @@ function project_browser_preprocess_project_browser_list(&$variables) { /** * Add some variables for the project theme - * + * * @param $variables * An associative array containing: * - project : associative array of project variables @@ -372,16 +372,16 @@ function project_browser_preprocess_project_browser_list(&$variables) { function project_browser_preprocess_project_browser_project(&$variables) { module_load_include('inc', 'project_browser', 'project_browser'); $project = $variables['project']; - - $variables['title'] = l($project['title'], check_url($project['project url']), + + $variables['title'] = l($project['title'], check_url($project['project url']), array('attributes' => array('target' => '_blank'), 'html' => TRUE)); $variables['author'] = t('Author: @author', array('@author' => $project['author'])); $variables['description'] = _filter_htmlcorrector(filter_xss($project['description'])); $variables['image'] = $project['image']; $variables['last_updated'] = ($project['last updated']) ? t('Last Updated: @date', array('@date' => format_date($project['last updated'], 'long'))) : ''; - + $extras = array(); - + if ($project['maintenance status']) { $extras[] = check_plain($project['maintenance status']); } @@ -395,12 +395,12 @@ function project_browser_preprocess_project_browser_project(&$variables) { if ($project['rating']) { $extras[] = check_plain($project['rating']); } - + $variables['extras'] = implode(' | ', $extras); - + // Check if the project is installed if (_project_browser_is_project_enabled($project['type'], $project['name'])) { - $variables['status'] = '