diff --git a/core/modules/project_browser/config/project_browser.settings.yml b/core/modules/project_browser/config/project_browser.settings.yml new file mode 100644 index 0000000..97af35a --- /dev/null +++ b/core/modules/project_browser/config/project_browser.settings.yml @@ -0,0 +1,6 @@ +cache_lifetime: "24 hours" +# @todo - Change the link once drupal.org is ready. +default_server: + "http://drupal:drupal@pbs-drupal_7.redesign.devdrupal.org/project_browser/server": + name: "Drupal.org" + method: "json" \ No newline at end of file diff --git a/core/modules/project_browser/images/arrow-asc.png b/core/modules/project_browser/images/arrow-asc.png index a3481c9..a3ccabc 100644 --- a/core/modules/project_browser/images/arrow-asc.png +++ b/core/modules/project_browser/images/arrow-asc.png @@ -1,5 +1,5 @@ -‰PNG - - IHDR H%v?PLTEÿÿÿ···kR%»tRNS@æØfIDATc`@L L¬ Œü…LL - -Li|q)í©IEND®B`‚ \ No newline at end of file +PNG + + IHDR H%v?PLTEkR%tRNS@fIDATc`@L L LL + +Li|q)IENDB` \ No newline at end of file diff --git a/core/modules/project_browser/images/arrow-desc.png b/core/modules/project_browser/images/arrow-desc.png index 9202d71..2edbb17 100644 --- a/core/modules/project_browser/images/arrow-desc.png +++ b/core/modules/project_browser/images/arrow-desc.png @@ -1,4 +1,4 @@ -‰PNG - - IHDR H%v?PLTEÿÿÿ···kR%»tRNS@æØfIDATxœc`@õì0È`ào``g``‚ -KzHƒ“ÏIEND®B`‚ \ No newline at end of file +PNG + + IHDR H%v?PLTEkR%tRNS@fIDATxc`@0`o``g`` +KzHIENDB` \ No newline at end of file diff --git a/core/modules/project_browser/images/circle.png b/core/modules/project_browser/images/circle.png index f6f3125..6b2d63f 100644 --- a/core/modules/project_browser/images/circle.png +++ b/core/modules/project_browser/images/circle.png @@ -1,3 +1,3 @@ -‰PNG - - IHDR6|JàPLTEÿÿÿ¿¿¿‹‹‹ÀÀÀE¾Ì<tRNS@æØfIDAT[c`cfe á( $•¡b ¾¯ýºšIEND®B`‚ \ No newline at end of file +PNG + + IHDR6|JPLTEE<tRNS@fIDAT[c`cfe ( $b IENDB` \ No newline at end of file diff --git a/core/modules/project_browser/images/red-x.png b/core/modules/project_browser/images/red-x.png index ce5cedc..486390c 100644 --- a/core/modules/project_browser/images/red-x.png +++ b/core/modules/project_browser/images/red-x.png @@ -1,7 +1,7 @@ -‰PNG - - IHDRóÿaÎIDATxÚ¥“?HBQÆ£¡ rŽÄ ÚÝ#§p(2hŠÊÁAk -Ü!G£±¢èßPд�¤¤õžï…½2ISiÑŠ -ú:ï¦W_O"èÂ�s¿ïw¹ïœÛ ^�¤àg©´ÕHê^ÅÃ3ºðƒ×›T(Púû¡Øí¸±Ùpcµ"31!ÿ„hÃ>_òaf�óó Epd¦¦®ë!µðô´H›¸ °»´„¬ß¯Ñ!Õ ÈLNj M•°p7<Œ”ǃµpÙl›¡2ããLû‹‹�’Ilo#6; òª×a°!÷öâvp²Ë…r4 -u -¬Rp�NE‘Õ>òyHn÷·×lÆG.·ÃRWR “B?ì%a�<ªa2#=4Ä}”©DƒrO×u_ž TW¹XT»¡ñP¦¸jm…ÐÑÁµáóA(`%Ðx®ZZj€KjFUëtÇ‹XŒßÏ''ì;GWXž›C�W83™p~zÊo©$£B{;ÊÇÇrètêAj‰X)² |�Ç!uws£ÐÖ†òÑhÐx-=2ÂÛØ©…�𛹱Q-íriIùMéÑQùç(ÿr?6¦{Lÿ~Î_Ýͧ±ãG¼IEND®B`‚ \ No newline at end of file +PNG + + IHDRaIDATxڥ?HBQƣr #p(2hAk +!GP2ISiъ +:W_O"sw^gH^3כT(Ppc"31!h>_af Epd!H ߯! LNj Mp7<ǃpl2LIlo#6; a!vp˅r4 +u +RpNE>yHnlG.RWR B?%a<a2#=4}DrOu_ TWXTPjmA(`%xZZjKjFUtNjX'';GWXCW83p~zo$B{;rtAjX) |!uwsֆhx-=2ةQ-riIMQ(r?6{L~_ͧGIENDB` \ No newline at end of file diff --git a/core/modules/project_browser/lib/Drupal/project_browser/Tests/ProjectBrowserTest.php b/core/modules/project_browser/lib/Drupal/project_browser/Tests/ProjectBrowserTest.php index 052155e..cab4a0e 100644 --- a/core/modules/project_browser/lib/Drupal/project_browser/Tests/ProjectBrowserTest.php +++ b/core/modules/project_browser/lib/Drupal/project_browser/Tests/ProjectBrowserTest.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\project_browser\Tests\ProjectBrowserTest. + * Contains Drupal\project_browser\Tests\ProjectBrowserTest. */ namespace Drupal\project_browser\Tests; @@ -11,8 +11,6 @@ /** * Administration tests for Project Browser. - * - * @todo - Create a test for the get releases HTML page. */ class ProjectBrowserTest extends WebTestBase { @@ -23,6 +21,9 @@ class ProjectBrowserTest extends WebTestBase { */ public static $modules = array('project_browser', 'project_browser_test'); + /** + * This is the user who will have access to use project browser. + */ protected $privilegedUser; public static function getInfo() { @@ -38,12 +39,14 @@ function setUp() { // Set the default server variable. $server_url = url('project_browser_test/query', array('absolute' => TRUE)); - variable_set('project_browser_default_server', array( + $config = config('project_browser.settings'); + $config->set('default_server', array( $server_url => array( 'name' => 'Test Server', 'method' => 'json', ), )); + $config->save(); // Create and log in our privileged user. $this->privilegedUser = $this->drupalCreateUser(array( @@ -64,7 +67,7 @@ public function testProjectBrowserSearchViews() { } /** - * Tests for errors on the Projects page with an empty search string. + * Tests that the Projects Listing displays properly with the default filters. */ public function testProjectBrowserGetProjects() { // Attempt to fetch the default projects. @@ -81,7 +84,7 @@ public function testProjectBrowserProjectEnabled() { // Make sure project enabled detection works. module_load_include('inc', 'project_browser', 'project_browser'); $this->assertTrue(_project_browser_is_project_enabled('module', 'project_browser'), - t('Make sure project enabled detection works.')); + 'Make sure project enabled detection works.'); } /** @@ -103,5 +106,21 @@ public function testProjectBrowserAddRemoveQueue() { $this->assertText('Install queue is empty.'); $this->assertNoText('Error: The project was not found.'); } + + /** + * Tests that the select releases page displays properly. + */ + public function testProjectBrowserSelectReleasesPage() { + // Refresh the page. + $this->drupalGet('admin/modules/project-browser/modules'); + + // Simulate adding a project to the install queue. + $this->drupalGet('project-browser/nojs/install-queue/add/views', + array('query' => array('destination' => 'admin/modules/project-browser'))); + $this->assertNoText('Install queue is empty.'); + $this->assertNoText('Error: The project was not found.'); + + + } } ?> diff --git a/core/modules/project_browser/project_browser.admin.inc b/core/modules/project_browser/project_browser.admin.inc index b492d06..9b9cad6 100644 --- a/core/modules/project_browser/project_browser.admin.inc +++ b/core/modules/project_browser/project_browser.admin.inc @@ -5,9 +5,8 @@ * Project Browser module admin pages. */ - /** - * Form constructor for the Admin Settings form. + * Page callback: Form constructor for admin settings. * * @see project_browser_menu() * @see system_settings_form() diff --git a/core/modules/project_browser/project_browser.inc b/core/modules/project_browser/project_browser.inc index 6e6111b..5ace2b4 100644 --- a/core/modules/project_browser/project_browser.inc +++ b/core/modules/project_browser/project_browser.inc @@ -100,7 +100,7 @@ function project_browser_filters_form($form, &$form_state, $type) { * @return string * A themed list of sort options. */ -function project_browser_get_sort_widget($sort_options, $current_sort_option, $current_sort_direction) { +function project_browser_get_sort_widget(array $sort_options, $current_sort_option, $current_sort_direction) { $sort_list = array(); $sort_list[] = array( '#markup' => t('Sort by:'), @@ -164,7 +164,7 @@ function project_browser_get_sort_widget($sort_options, $current_sort_option, $c * @return string * A themed server select widget. */ -function project_browser_get_server_widget($servers, $current_server) { +function project_browser_get_server_widget(array $servers, $current_server) { $list = array(); $list[] = array('data' => t('Repository:'), 'class' => array('server-header')); $current_path = drupal_get_path_alias($_GET['q']); @@ -206,7 +206,7 @@ function project_browser_get_server_widget($servers, $current_server) { * Builds and returns an array of sort options, keyed by method. * * @param bool $full - * (Optional) Set this to TRUE if you want to get all of the supported sort + * (optional) Set this to TRUE if you want to get all of the supported sort * methods. Defaults to FALSE. * * @return array @@ -300,7 +300,7 @@ function project_browser_get_categories($type) { * @return array * An array of server categories, keyed by server url. */ -function project_browser_prepare_categories($raw_cats, $type) { +function project_browser_prepare_categories(array $raw_cats, $type) { $categories = project_browser_fetch_categories($type); // Set the value of the categories to true if it is selected. @@ -368,7 +368,7 @@ function project_browser_get_listed_projects() { * Gets the currently queued projects from the $_SESSION variable. * * @param string|null $type - * (Optional) The type of project (module or theme). Defaults to NULL, which + * (optional) The type of project (module or theme). Defaults to NULL, which * will return projects of all types. * * @return array @@ -404,7 +404,7 @@ function project_browser_get_queued_projects($type = NULL) { * @return array|false * The release data array or FALSE if the release doesn't exist. */ -function project_browser_get_release($release_name, $project) { +function project_browser_get_release($release_name, array $project) { $release_data = project_browser_get_project_release_data($project); return isset($release_data['releases'][$release_name]) ? $release_data['releases'][$release_name] : FALSE; @@ -436,7 +436,7 @@ function project_browser_get_installed_projects() { * @param array $project * An array of $project data for a single project. */ -function project_browser_install_queue_add($project) { +function project_browser_install_queue_add(array $project) { $_SESSION['project_browser_install_list'][$project['name']] = $project; } @@ -477,40 +477,40 @@ function project_browser_get_queued_releases() { * * @param array $filters * An associative array of queries to use to filter results, containing: - * - 'version': The Major Version of Drupal that is running on the Client. + * - version: The Major Version of Drupal that is running on the Client. * Example: '7' or '8'. - * - 'text': The text that was entered as the search query, or '' if none. + * - text: The text that was entered as the search query, or '' if none. * Example: 'Link field'. - * - 'categories': An array of categories that were selected, if any. - * - 'type': The type of project being searched for. Example: 'module' or + * - categories: An array of categories that were selected, if any. + * - type: The type of project being searched for. Example: 'module' or * 'theme'. - * - 'page': The zero-based page number. - * - 'requested': How many results are requested per page. + * - page: The zero-based page number. + * - requested: How many results are requested per page. * * @return array - * Returns an array of results formatted like: - * - 'total': The total number of results found for the filters. - * - 'projects': An array of projects returned for this page request, + * An array of results formatted like: + * - total: The total number of results found for the filters. + * - projects: An array of projects returned for this page request, * containing: - * - 'KEY': A project array keyed by the machine name: - * - 'type': The type of project this is. Can be 'module' or 'theme'. - * - 'title': The title of the project. - * - 'name': The machine name of the project. - * - 'author': The author's name. - * - 'description': Long project description text. - * - 'image': Absolute url to the image, if any. - * - 'usage': How many sites are using module. - * - 'project url': Absolute url to the project page, if any. - * - 'project status url': The absolute url of the update checker, + * - KEY: A project array keyed by the machine name: + * - type: The type of project this is. Can be 'module' or 'theme'. + * - title: The title of the project. + * - name: The machine name of the project. + * - author: The author's name. + * - description: Long project description text. + * - image: Absolute url to the image, if any. + * - usage: How many sites are using module. + * - project url: Absolute url to the project page, if any. + * - project status url: The absolute url of the update checker, * formatted like how Drupal.org Update Status does it. - * - 'last updated': UNIX Timestamp of when the project was last updated. - * - 'maintenance status': Maintenance status. - * - 'development status': Development status. - * - 'rating': A rating on a scale of 1 to 10 of the project, if available - * - 'dependencies': An array of the dependencies of this module, by + * - last updated: UNIX Timestamp of when the project was last updated. + * - maintenance status: Maintenance status. + * - development status: Development status. + * - rating: A rating on a scale of 1 to 10 of the project, if available + * - dependencies: An array of the dependencies of this module, by * project shortname, if available. */ -function project_browser_fetch_results($filters) { +function project_browser_fetch_results(array $filters) { $servers = project_browser_get_servers($filters['server']); // Attempt to retrieve the cached version of this page. $cid = md5(serialize(array_merge($filters, $servers))); @@ -586,8 +586,7 @@ function project_browser_fetch_results($filters) { } } - // Set the cached version of the results. - cache()->set($cid, $results, strtotime("+24 hours")); + cache()->set($cid, $results, strtotime("+" . config('project_browser.settings')->get('cache_lifetime'))); return $results; } @@ -599,7 +598,7 @@ function project_browser_fetch_results($filters) { * The type of project we are getting categories for. Can be 'module' or * 'theme' * @param string $use_server - * (Optional) The server to use. Defaults to 'all'. + * (optional) The server to use. Defaults to 'all'. * * @return array * Returns an array of the categories. @@ -617,6 +616,7 @@ function project_browser_fetch_categories($type, $use_server = 'all') { $categories = array(); foreach ($servers as $url => $server) { + $categories_raw = array(); // Use xmlrpc if it is set. if ($server['method'] == 'xmlrpc') { $categories_raw = xmlrpc($url, array( @@ -664,20 +664,14 @@ function project_browser_fetch_categories($type, $use_server = 'all') { * Gets an array of servers to use for fetching results. * * @param string $use_server - * (Optional) The server to use. Defaults to 'all'. + * (optional) The server to use. Defaults to 'all'. * * @return array * 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') { - // @todo - Change the link once drupal.org is ready. - $servers = variable_get('project_browser_default_server', array( - 'http://drupal:drupal@pbs-drupal_7.redesign.devdrupal.org/project_browser/server' => array( - 'name' => 'Drupal.org', - 'method' => 'json', - ), - )); + $servers = config('project_browser.settings')->get('default_server'); if ($servers_raw = variable_get('project_browser_servers', '')) { // Process the variable and add the servers to the list. @@ -725,7 +719,7 @@ function project_browser_get_servers($use_server = 'all') { * @return array|false * An array of releases for this project, or FALSE if it can't be found. */ -function project_browser_get_project_release_data($project) { +function project_browser_get_project_release_data(array $project) { $releases = array(); $project['project_type'] = $project['type']; $project['includes'] = array(); @@ -751,7 +745,8 @@ function project_browser_get_project_release_data($project) { * 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, to reduce coupling and duplication. + * function, to reduce coupling and duplication. Issue is here: + * http://drupal.org/node/1846078 * * @param string $url * The url of the release download. @@ -884,7 +879,7 @@ function project_browser_download_project($url) { * @param array &$context * The context of the batch so that the results can be reported. */ -function _project_browser_batch_install_release($release_name, $project, &$context) { +function _project_browser_batch_install_release($release_name, array $project, array &$context) { module_load_include('inc', 'project_browser', 'project_browser.pages'); $release = project_browser_get_release($release_name, $project); @@ -925,7 +920,7 @@ function _project_browser_batch_install_release($release_name, $project, &$conte * @param array $operations * An array of operations that need to be performed. */ -function _project_browser_batch_install_releases_finished($success, $results, $operations) { +function _project_browser_batch_install_releases_finished($success, array $results, array $operations) { drupal_get_messages(); // Restore the maintenance mode to what it was at the start. @@ -965,7 +960,7 @@ function _project_browser_batch_install_releases_finished($success, $results, $o * @return array * An array of missing dependencies, if any were detected. */ -function project_browser_get_missing_dependencies($projects) { +function project_browser_get_missing_dependencies(array $projects) { $modules = system_rebuild_module_data(); $missing = array(); diff --git a/core/modules/project_browser/project_browser.info b/core/modules/project_browser/project_browser.info index 4456809..5fbdf19 100644 --- a/core/modules/project_browser/project_browser.info +++ b/core/modules/project_browser/project_browser.info @@ -4,3 +4,4 @@ dependencies[] = update package = Core version = VERSION core = 8.x +configure = admin/config/development/project_browser \ No newline at end of file diff --git a/core/modules/project_browser/project_browser.module b/core/modules/project_browser/project_browser.module index 59486ec..8c2672d 100644 --- a/core/modules/project_browser/project_browser.module +++ b/core/modules/project_browser/project_browser.module @@ -130,6 +130,7 @@ function project_browser_install_queue_callback($method, $op, $project_name) { case 'remove': project_browser_install_queue_remove($project_name); break; + } switch ($method) { @@ -139,6 +140,7 @@ function project_browser_install_queue_callback($method, $op, $project_name) { drupal_goto($redirect); break; + case 'ajax': $commands = array(); @@ -149,6 +151,7 @@ function project_browser_install_queue_callback($method, $op, $project_name) { return array('#type' => 'ajax', '#commands' => $commands); break; + } } @@ -174,6 +177,7 @@ function project_browser_menu_local_tasks_alter(&$data, $router_item, $root_path ); } break; + // This is used to include the old 'Install a module' link case 'admin/modules/project-browser': case 'admin/modules/project-browser/modules': @@ -187,6 +191,7 @@ function project_browser_menu_local_tasks_alter(&$data, $router_item, $root_path ); } break; + // This is used to put the 'Project Browser' action on the 'Appearance' // page. case 'admin/appearance': @@ -205,6 +210,7 @@ function project_browser_menu_local_tasks_alter(&$data, $router_item, $root_path ); } break; + } } @@ -257,7 +263,7 @@ function project_browser_theme($existing, $type, $theme, $path) { * * @ingroup themeable */ -function project_browser_preprocess_project_browser_install(&$variables) { +function project_browser_preprocess_project_browser_install(array &$variables) { module_load_include('inc', 'project_browser', 'project_browser.pages'); // Add the themed list $variables['task_list'] = project_browser_installation_task_list($variables['current_task']); @@ -274,7 +280,7 @@ function project_browser_preprocess_project_browser_install(&$variables) { * * @ingroup themeable */ -function project_browser_preprocess_project_browser_install_queue(&$variables) { +function project_browser_preprocess_project_browser_install_queue(array &$variables) { $build = array(); if (empty($variables['projects'])) { $build['empty_text'] = array( @@ -308,7 +314,7 @@ function project_browser_preprocess_project_browser_install_queue(&$variables) { * * @ingroup themeable */ -function project_browser_preprocess_project_browser_block(&$variables) { +function project_browser_preprocess_project_browser_block(array &$variables) { // Add the title and content variables. $variables['title'] = $variables['element']['#title']; $variables['content'] = $variables['element']['#content']; @@ -325,7 +331,7 @@ function project_browser_preprocess_project_browser_block(&$variables) { * * @ingroup themeable */ -function project_browser_preprocess_project_browser_list(&$variables) { +function project_browser_preprocess_project_browser_list(array &$variables) { module_load_include('inc', 'project_browser', 'project_browser'); drupal_add_library('project_browser', 'drupal.project_browser.css'); @@ -346,12 +352,15 @@ function project_browser_preprocess_project_browser_list(&$variables) { case 'module': $title = t('Most used Drupal modules'); break; + case 'theme': $title = t('Most used Drupal themes'); break; + default: $title = t('Projects'); break; + } // If any filters were selected, change the title to 'Search results'. @@ -401,7 +410,7 @@ function project_browser_preprocess_project_browser_list(&$variables) { * * @ingroup themeable */ -function project_browser_preprocess_project_browser_project(&$variables) { +function project_browser_preprocess_project_browser_project(array &$variables) { module_load_include('inc', 'project_browser', 'project_browser'); $project = $variables['project']; @@ -451,9 +460,9 @@ function project_browser_preprocess_project_browser_project(&$variables) { * @param string $project_name * The short name of the project, such as 'views'. * @param string|null $title - * (Optional) The title of the project. Defaults to NULL. + * (optional) The title of the project. Defaults to NULL. * @param string $id_prefix - * (Optional) The prefix that should be prepended to the id, to ensure unique + * (optional) The prefix that should be prepended to the id, to ensure unique * id names. Defaults to 'add-to-queue-link'. * * @return string diff --git a/core/modules/project_browser/project_browser.pages.inc b/core/modules/project_browser/project_browser.pages.inc index 065783c..f16cc5e 100644 --- a/core/modules/project_browser/project_browser.pages.inc +++ b/core/modules/project_browser/project_browser.pages.inc @@ -193,7 +193,7 @@ function project_browser_installation_select_versions_page() { * @see project_browser_installation_select_versions_form_submit() * @ingroup forms */ -function project_browser_installation_select_versions_form($form, &$form_state, $projects) { +function project_browser_installation_select_versions_form($form, &$form_state, array $projects) { module_load_include('inc', 'project_browser', 'project_browser'); drupal_add_library('project_browser', 'drupal.project_browser.select_releases'); @@ -313,7 +313,7 @@ function project_browser_installation_select_versions_form($form, &$form_state, } /** - * Form submission handler for project_browser_installation_select_versions_form() + * Form submission handler for project_browser_installation_select_versions_form(). * * This sets the batch to install the different selected releases one by one. */ @@ -430,7 +430,7 @@ function project_browser_installation_enable_page() { * @see project_browser_installation_enable_form_submit() * @ingroup forms */ -function project_browser_installation_enable_form($form, &$form_state, $projects) { +function project_browser_installation_enable_form($form, &$form_state, array $projects) { $modules = system_rebuild_module_data(); $form['instructions'] = array( '#type' => 'item', @@ -542,7 +542,7 @@ function project_browser_installation_enable_form_submit($form, &$form_state) { * This will need to be called from every page of the install process. * * @param string $active - * (Optional) Set the active task by key. Defaults to NULL. + * (optional) Set the active task by key. Defaults to NULL. * * @return array * The themed task list for the install projects process. diff --git a/core/modules/project_browser/theme/project-browser-project.tpl.php b/core/modules/project_browser/theme/project-browser-project.tpl.php new file mode 100644 index 0000000..d5eea5b --- /dev/null +++ b/core/modules/project_browser/theme/project-browser-project.tpl.php @@ -0,0 +1,59 @@ + +
+ +
+ +
+ + +
+

+ +

+ +
+ +
+ +
+ +
+ +
+ +
+
+ +
+ +
+ +
+ + +
+
+