GitHub PullRequestReviewCommentEvent at 2014-10-01 18:32:36
Repository: islandora_solr_search
Actor: jordandukart
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/Islandora/islandora_solr_search/pulls/comments/18298434","id":18298434,"diff_hunk":"@@ -81,6 +89,232 @@ function islandora_solr_block_info() {\n   return $blocks;\n }\n \n+/**\n+ * Implements hook_form_FORM_ID_alter().\n+ *\n+ * Currently checks for delta of explore and modifies the form to add custom\n+ * configuration options to setup facet display filters to be rendered.\n+ */\n+function islandora_solr_form_BLOCK_ADMIN_CONFIGURE_alter(&$form, &$form_state) {\n+  if ($form['delta']['#value'] == 'explore') {\n+    // Get the variables for the form display facets.\n+    $expore_config = (isset($form_state['islandora_solr_facet_filters']) ? $form_state['islandora_solr_facet_filters'] : variable_get('islandora_solr_explore_config', array()));\n+\n+    // Check if remove was clicked and removed the label and filter from the\n+    // values and the table.\n+    if (isset($form_state['triggering_element']) && $form_state['triggering_element']['#value'] == t('Remove selected')) {\n+      foreach ($form_state['values']['table'] as $row) {\n+        if (!empty($row)) {\n+          // Get selected row index.\n+          $row_index = str_replace(\"facet-row-\", \"\", $row);\n+          // Unset the index to keep the other keys the same.\n+          unset($expore_config[$row_index]);\n+        }\n+      }\n+      // Reindex array to remove empty unused indexes and keep the array clean.\n+      $expore_config = array_values($expore_config);\n+      $form_state['islandora_solr_facet_filters'] = $expore_config;\n+    }\n+\n+    // Check if weights are being updated.\n+    if (isset($form_state['triggering_element']) && $form_state['triggering_element']['#value'] == t('Update weights')) {\n+      // Note: select_weight is only in the $form_state['input'] and doesn't\n+      // exist in $form_state['values'].\n+      $selected_weights = $form_state['input']['select_weight'];\n+      foreach ($selected_weights as $index => $weight) {\n+        $expore_config[$index]['weight'] = $weight;\n+      }\n+      // Sort config array by weight and update drupal variable.\n+      uasort($expore_config, 'drupal_sort_weight');\n+      $form_state['islandora_solr_facet_filters'] = $expore_config;\n+    }\n+\n+    // Check if new display facet is being added to the table.\n+    if (isset($form_state['triggering_element']) && $form_state['triggering_element']['#id'] == 'facet-filter-add-more') {\n+      $facet_label = $form_state['values']['label'];\n+      $facet_filter = $form_state['values']['filter'];\n+      $facet_weight = $form_state['values']['facet_weight'];\n+\n+      if (empty($facet_filter)) {\n+        form_set_error('Filter', 'Facet Filter is required to add a display facet.');\n+      }\n+\n+      if (empty($facet_label)) {\n+        form_set_error('Label', 'Display Label is required to add a display facet.');\n+      }\n+\n+      if (!empty($facet_label) && !empty($facet_filter)) {\n+        // Before it's added try to run the facet query and see if it's valid.\n+        $facet_is_valid = TRUE;\n+\n+        if (!empty($facet_filter)) {\n+          // Store current messages.\n+          $old_msg = drupal_get_messages();\n+\n+          // Run a facet query on the supplied filter.\n+          module_load_include('inc', 'islandora_solr', 'includes/explore');\n+          islandora_solr_explore_test_facet_query($facet_filter);\n+\n+          // Check the get messages for solr index errors to see if the filter\n+          // is invalid, if so do not add it and trigger form error.\n+          $error_msgs = drupal_get_messages('error');\n+          if (isset($error_msgs['error'])) {\n+            foreach ($error_msgs['error'] as $error_msg) {\n+              if (preg_match('/Error searching Solr index/', $error_msg)) {\n+                $facet_is_valid = FALSE;\n+              }\n+            }\n+          }\n+          // Restore the original messages.\n+          $_SESSION['messages'] = $old_msg;\n+          if (!$facet_is_valid) {\n+            form_set_error('Filter', 'Invalid Facet Query Filter.');\n+          }\n+        }\n+\n+        if ($facet_is_valid) {\n+          // Put values into config array.\n+          $expore_config[$facet_filter] = array(\n+            'label' => $facet_label,\n+            'filter' => $facet_filter,\n+            'weight' => $facet_weight,\n+          );\n+\n+          // Sort config array by weight and update drupal variable.\n+          uasort($expore_config, 'drupal_sort_weight');\n+\n+          // Reset input values on successful add.\n+          $form_state['input']['label'] = '';\n+          $form_state['input']['filter'] = '';\n+          $form_state['input']['facet_weight'] = 0;\n+          $form_state['islandora_solr_facet_filters'] = $expore_config;\n+        }\n+      }\n+    }\n+\n+    // Set table row data to be rendered.\n+    $rows = array();\n+    if (!empty($expore_config)) {\n+      foreach ($expore_config as $row_index => $row) {\n+        $rows[\"facet-row-$row_index\"] = array(\n+          'display_label' => htmlentities($row['label']),\n+          'facet_filter' => htmlentities($row['filter']),\n+          'facet_weight' => array(","path":"includes/blocks.inc","position":129,"original_position":129,"commit_id":"7feaba9f39bec694345bc5f2fd68b07f41c7a3a1","original_commit_id":"7feaba9f39bec694345bc5f2fd68b07f41c7a3a1","user":{"login":"jordandukart","id":1337738,"avatar_url":"https://avatars.githubusercontent.com/u/1337738?v=2","gravatar_id":"","url":"https://api.github.com/users/jordandukart","html_url":"https://github.com/jordandukart","followers_url":"https://api.github.com/users/jordandukart/followers","following_url":"https://api.github.com/users/jordandukart/following{/other_user}","gists_url":"https://api.github.com/users/jordandukart/gists{/gist_id}","starred_url":"https://api.github.com/users/jordandukart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jordandukart/subscriptions","organizations_url":"https://api.github.com/users/jordandukart/orgs","repos_url":"https://api.github.com/users/jordandukart/repos","events_url":"https://api.github.com/users/jordandukart/events{/privacy}","received_events_url":"https://api.github.com/users/jordandukart/received_events","type":"User","site_admin":false},"body":"Any reason why this isn't being implemented as a draggable table (https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_add_tabledrag/7)?","created_at":"2014-10-01T18:32:36Z","updated_at":"2014-10-01T18:32:36Z","html_url":"https://github.com/Islandora/islandora_solr_search/pull/195#discussion_r18298434","pull_request_url":"https://api.github.com/repos/Islandora/islandora_solr_search/pulls/195","_links":{"self":{"href":"https://api.github.com/repos/Islandora/islandora_solr_search/pulls/comments/18298434"},"html":{"href":"https://github.com/Islandora/islandora_solr_search/pull/195#discussion_r18298434"},"pull_request":{"href":"https://api.github.com/repos/Islandora/islandora_solr_search/pulls/195"}}},"pull_request":{"url":"https://api.github.com/repos/Islandora/islandora_solr_search/pulls/195","id":22089426,"html_url":"https://github.com/Islandora/islandora_solr_search/pull/195","diff_url":"https://github.com/Islandora/islandora_solr_search/pull/195.diff","patch_url":"https://github.com/Islandora/islandora_solr_search/pull/195.patch","issue_url":"https://api.github.com/repos/Islandora/islandora_solr_search/issues/195","number":195,"state":"open","locked":false,"title":"WRLC-32: Implement a generic Islandora explore block in islandora solr...","user":{"login":"matthewperry","id":8352593,"avatar_url":"https://avatars.githubusercontent.com/u/8352593?v=2","gravatar_id":"","url":"https://api.github.com/users/matthewperry","html_url":"https://github.com/matthewperry","followers_url":"https://api.github.com/users/matthewperry/followers","following_url":"https://api.github.com/users/matthewperry/following{/other_user}","gists_url":"https://api.github.com/users/matthewperry/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewperry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewperry/subscriptions","organizations_url":"https://api.github.com/users/matthewperry/orgs","repos_url":"https://api.github.com/users/matthewperry/repos","events_url":"https://api.github.com/users/matthewperry/events{/privacy}","received_events_url":"https://api.github.com/users/matthewperry/received_events","type":"User","site_admin":false},"body":"...search module.","created_at":"2014-10-01T17:29:40Z","updated_at":"2014-10-01T18:32:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0268dc7e2b50dfd0f708723405528047515ccf53","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Islandora/islandora_solr_search/pulls/195/commits","review_comments_url":"https://api.github.com/repos/Islandora/islandora_solr_search/pulls/195/comments","review_comment_url":"https://api.github.com/repos/Islandora/islandora_solr_search/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Islandora/islandora_solr_search/issues/195/comments","statuses_url":"https://api.github.com/repos/Islandora/islandora_solr_search/statuses/7feaba9f39bec694345bc5f2fd68b07f41c7a3a1","head":{"label":"matthewperry:7.x-WRLC-32","ref":"7.x-WRLC-32","sha":"7feaba9f39bec694345bc5f2fd68b07f41c7a3a1","user":{"login":"matthewperry","id":8352593,"avatar_url":"https://avatars.githubusercontent.com/u/8352593?v=2","gravatar_id":"","url":"https://api.github.com/users/matthewperry","html_url":"https://github.com/matthewperry","followers_url":"https://api.github.com/users/matthewperry/followers","following_url":"https://api.github.com/users/matthewperry/following{/other_user}","gists_url":"https://api.github.com/users/matthewperry/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewperry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewperry/subscriptions","organizations_url":"https://api.github.com/users/matthewperry/orgs","repos_url":"https://api.github.com/users/matthewperry/repos","events_url":"https://api.github.com/users/matthewperry/events{/privacy}","received_events_url":"https://api.github.com/users/matthewperry/received_events","type":"User","site_admin":false},"repo":{"id":24683257,"name":"islandora_solr_search","full_name":"matthewperry/islandora_solr_search","owner":{"login":"matthewperry","id":8352593,"avatar_url":"https://avatars.githubusercontent.com/u/8352593?v=2","gravatar_id":"","url":"https://api.github.com/users/matthewperry","html_url":"https://github.com/matthewperry","followers_url":"https://api.github.com/users/matthewperry/followers","following_url":"https://api.github.com/users/matthewperry/following{/other_user}","gists_url":"https://api.github.com/users/matthewperry/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewperry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewperry/subscriptions","organizations_url":"https://api.github.com/users/matthewperry/orgs","repos_url":"https://api.github.com/users/matthewperry/repos","events_url":"https://api.github.com/users/matthewperry/events{/privacy}","received_events_url":"https://api.github.com/users/matthewperry/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/matthewperry/islandora_solr_search","description":"Islandora Solr Search module","fork":true,"url":"https://api.github.com/repos/matthewperry/islandora_solr_search","forks_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/forks","keys_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/teams","hooks_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/hooks","issue_events_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/issues/events{/number}","events_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/events","assignees_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/assignees{/user}","branches_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/branches{/branch}","tags_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/tags","blobs_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/git/refs{/sha}","trees_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/statuses/{sha}","languages_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/languages","stargazers_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/stargazers","contributors_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/contributors","subscribers_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/subscribers","subscription_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/subscription","commits_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/commits{/sha}","git_commits_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/git/commits{/sha}","comments_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/comments{/number}","issue_comment_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/issues/comments/{number}","contents_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/contents/{+path}","compare_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/merges","archive_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/downloads","issues_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/issues{/number}","pulls_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/pulls{/number}","milestones_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/milestones{/number}","notifications_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/labels{/name}","releases_url":"https://api.github.com/repos/matthewperry/islandora_solr_search/releases{/id}","created_at":"2014-10-01T15:16:05Z","updated_at":"2014-09-08T13:29:36Z","pushed_at":"2014-10-01T17:28:57Z","git_url":"git://github.com/matthewperry/islandora_solr_search.git","ssh_url":"git@github.com:matthewperry/islandora_solr_search.git","clone_url":"https://github.com/matthewperry/islandora_solr_search.git","svn_url":"https://github.com/matthewperry/islandora_solr_search","homepage":"","size":2925,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"7.x"}},"base":{"label":"Islandora:7.x","ref":"7.x","sha":"b4392b2a1d2d25f3c1c14aa6a2442951aa1d864b","user":{"login":"Islandora","id":494054,"avatar_url":"https://avatars.githubusercontent.com/u/494054?v=2","gravatar_id":"","url":"https://api.github.com/users/Islandora","html_url":"https://github.com/Islandora","followers_url":"https://api.github.com/users/Islandora/followers","following_url":"https://api.github.com/users/Islandora/following{/other_user}","gists_url":"https://api.github.com/users/Islandora/gists{/gist_id}","starred_url":"https://api.github.com/users/Islandora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Islandora/subscriptions","organizations_url":"https://api.github.com/users/Islandora/orgs","repos_url":"https://api.github.com/users/Islandora/repos","events_url":"https://api.github.com/users/Islandora/events{/privacy}","received_events_url":"https://api.github.com/users/Islandora/received_events","type":"Organization","site_admin":false},"repo":{"id":1115245,"name":"islandora_solr_search","full_name":"Islandora/islandora_solr_search","owner":{"login":"Islandora","id":494054,"avatar_url":"https://avatars.githubusercontent.com/u/494054?v=2","gravatar_id":"","url":"https://api.github.com/users/Islandora","html_url":"https://github.com/Islandora","followers_url":"https://api.github.com/users/Islandora/followers","following_url":"https://api.github.com/users/Islandora/following{/other_user}","gists_url":"https://api.github.com/users/Islandora/gists{/gist_id}","starred_url":"https://api.github.com/users/Islandora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Islandora/subscriptions","organizations_url":"https://api.github.com/users/Islandora/orgs","repos_url":"https://api.github.com/users/Islandora/repos","events_url":"https://api.github.com/users/Islandora/events{/privacy}","received_events_url":"https://api.github.com/users/Islandora/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Islandora/islandora_solr_search","description":"Islandora Solr Search module","fork":true,"url":"https://api.github.com/repos/Islandora/islandora_solr_search","forks_url":"https://api.github.com/repos/Islandora/islandora_solr_search/forks","keys_url":"https://api.github.com/repos/Islandora/islandora_solr_search/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Islandora/islandora_solr_search/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Islandora/islandora_solr_search/teams","hooks_url":"https://api.github.com/repos/Islandora/islandora_solr_search/hooks","issue_events_url":"https://api.github.com/repos/Islandora/islandora_solr_search/issues/events{/number}","events_url":"https://api.github.com/repos/Islandora/islandora_solr_search/events","assignees_url":"https://api.github.com/repos/Islandora/islandora_solr_search/assignees{/user}","branches_url":"https://api.github.com/repos/Islandora/islandora_solr_search/branches{/branch}","tags_url":"https://api.github.com/repos/Islandora/islandora_solr_search/tags","blobs_url":"https://api.github.com/repos/Islandora/islandora_solr_search/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Islandora/islandora_solr_search/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Islandora/islandora_solr_search/git/refs{/sha}","trees_url":"https://api.github.com/repos/Islandora/islandora_solr_search/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Islandora/islandora_solr_search/statuses/{sha}","languages_url":"https://api.github.com/repos/Islandora/islandora_solr_search/languages","stargazers_url":"https://api.github.com/repos/Islandora/islandora_solr_search/stargazers","contributors_url":"https://api.github.com/repos/Islandora/islandora_solr_search/contributors","subscribers_url":"https://api.github.com/repos/Islandora/islandora_solr_search/subscribers","subscription_url":"https://api.github.com/repos/Islandora/islandora_solr_search/subscription","commits_url":"https://api.github.com/repos/Islandora/islandora_solr_search/commits{/sha}","git_commits_url":"https://api.github.com/repos/Islandora/islandora_solr_search/git/commits{/sha}","comments_url":"https://api.github.com/repos/Islandora/islandora_solr_search/comments{/number}","issue_comment_url":"https://api.github.com/repos/Islandora/islandora_solr_search/issues/comments/{number}","contents_url":"https://api.github.com/repos/Islandora/islandora_solr_search/contents/{+path}","compare_url":"https://api.github.com/repos/Islandora/islandora_solr_search/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Islandora/islandora_solr_search/merges","archive_url":"https://api.github.com/repos/Islandora/islandora_solr_search/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Islandora/islandora_solr_search/downloads","issues_url":"https://api.github.com/repos/Islandora/islandora_solr_search/issues{/number}","pulls_url":"https://api.github.com/repos/Islandora/islandora_solr_search/pulls{/number}","milestones_url":"https://api.github.com/repos/Islandora/islandora_solr_search/milestones{/number}","notifications_url":"https://api.github.com/repos/Islandora/islandora_solr_search/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Islandora/islandora_solr_search/labels{/name}","releases_url":"https://api.github.com/repos/Islandora/islandora_solr_search/releases{/id}","created_at":"2010-11-26T18:20:30Z","updated_at":"2014-09-08T13:29:36Z","pushed_at":"2014-09-26T13:47:40Z","git_url":"git://github.com/Islandora/islandora_solr_search.git","ssh_url":"git@github.com:Islandora/islandora_solr_search.git","clone_url":"https://github.com/Islandora/islandora_solr_search.git","svn_url":"https://github.com/Islandora/islandora_solr_search","homepage":"","size":2925,"stargazers_count":19,"watchers_count":19,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":36,"mirror_url":null,"open_issues_count":2,"forks":36,"open_issues":2,"watchers":19,"default_branch":"7.x"}},"_links":{"self":{"href":"https://api.github.com/repos/Islandora/islandora_solr_search/pulls/195"},"html":{"href":"https://github.com/Islandora/islandora_solr_search/pull/195"},"issue":{"href":"https://api.github.com/repos/Islandora/islandora_solr_search/issues/195"},"comments":{"href":"https://api.github.com/repos/Islandora/islandora_solr_search/issues/195/comments"},"review_comments":{"href":"https://api.github.com/repos/Islandora/islandora_solr_search/pulls/195/comments"},"review_comment":{"href":"https://api.github.com/repos/Islandora/islandora_solr_search/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Islandora/islandora_solr_search/pulls/195/commits"},"statuses":{"href":"https://api.github.com/repos/Islandora/islandora_solr_search/statuses/7feaba9f39bec694345bc5f2fd68b07f41c7a3a1"}}}}