diff --git a/.travis.yml b/.travis.yml index 6de86efb..8655ac0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,30 +7,30 @@ matrix: #5.3.3 Ubuntu Precise exceptions - php: 5.3.3 dist: precise - env: FEDORA_VERSION="3.5" + env: FEDORA_VERSION="3.5" CODESNIFFER_IGNORE="vendor,*.info,*.txt,*.md,SolrPhpClient" - php: 5.3.3 dist: precise - env: FEDORA_VERSION="3.6.2" + env: FEDORA_VERSION="3.6.2" CODESNIFFER_IGNORE="vendor,*.info,*.txt,*.md,SolrPhpClient" - php: 5.3.3 dist: precise - env: FEDORA_VERSION="3.7.0" + env: FEDORA_VERSION="3.7.0" CODESNIFFER_IGNORE="vendor,*.info,*.txt,*.md,SolrPhpClient" - php: 5.3.3 dist: precise - env: FEDORA_VERSION="3.8.1" + env: FEDORA_VERSION="3.8.1" CODESNIFFER_IGNORE="vendor,*.info,*.txt,*.md,SolrPhpClient" allow_failures: # 5.3.3 can fail now. - php: 5.3.3 dist: precise - env: FEDORA_VERSION="3.5" + env: FEDORA_VERSION="3.5" CODESNIFFER_IGNORE="vendor,*.info,*.txt,*.md,SolrPhpClient" - php: 5.3.3 dist: precise - env: FEDORA_VERSION="3.6.2" + env: FEDORA_VERSION="3.6.2" CODESNIFFER_IGNORE="vendor,*.info,*.txt,*.md,SolrPhpClient" - php: 5.3.3 dist: precise - env: FEDORA_VERSION="3.7.0" + env: FEDORA_VERSION="3.7.0" CODESNIFFER_IGNORE="vendor,*.info,*.txt,*.md,SolrPhpClient" - php: 5.3.3 dist: precise - env: FEDORA_VERSION="3.8.1" + env: FEDORA_VERSION="3.8.1" CODESNIFFER_IGNORE="vendor,*.info,*.txt,*.md,SolrPhpClient" php: - 5.4 - 5.5 @@ -38,10 +38,13 @@ php: - 7.0 - 7.1 env: - - FEDORA_VERSION="3.5" - - FEDORA_VERSION="3.6.2" - - FEDORA_VERSION="3.7.0" - - FEDORA_VERSION="3.8.1" + global: + - CODESNIFFER_IGNORE="vendor,*.info,*.txt,*.md,SolrPhpClient" + matrix: + - FEDORA_VERSION="3.5" + - FEDORA_VERSION="3.6.2" + - FEDORA_VERSION="3.7.0" + - FEDORA_VERSION="3.8.1" before_install: - cd $HOME @@ -55,8 +58,5 @@ before_script: # Mysql might time out for long tests, increase the wait timeout. - mysql -e 'SET @@GLOBAL.wait_timeout=1200' script: - - ant -buildfile sites/all/modules/islandora_solr_search/build.xml lint - - $ISLANDORA_DIR/tests/scripts/line_endings.sh sites/all/modules/islandora_solr_search - - drush coder-review --reviews=production,security,style,i18n,potx,sniffer islandora_solr - - phpcpd --names *.module,*.inc,*.test sites/all/modules/islandora_solr_search - - php scripts/run-tests.sh --php `phpenv which php` --url http://localhost:8081 --verbose "Islandora Solr Search" + - $HOME/islandora/tests/scripts/travis_scripts.sh + - $HOME/islandora/tests/scripts/run_tests.sh "Islandora Solr Search" diff --git a/SolrPhpClient/Apache/Solr/Document.php b/SolrPhpClient/Apache/Solr/Document.php index 7c388b8a..d2385dc7 100644 --- a/SolrPhpClient/Apache/Solr/Document.php +++ b/SolrPhpClient/Apache/Solr/Document.php @@ -1,7 +1,10 @@ _fieldBoosts[$key]); } } -// @codingStandardsIgnoreEnd diff --git a/SolrPhpClient/Apache/Solr/Response.php b/SolrPhpClient/Apache/Solr/Response.php index 65e55305..df353d86 100644 --- a/SolrPhpClient/Apache/Solr/Response.php +++ b/SolrPhpClient/Apache/Solr/Response.php @@ -1,7 +1,10 @@ _parsedData = $data; } } -// @codingStandardsIgnoreEnd diff --git a/SolrPhpClient/Apache/Solr/Service.php b/SolrPhpClient/Apache/Solr/Service.php index a8d2a348..0f6aa5da 100644 --- a/SolrPhpClient/Apache/Solr/Service.php +++ b/SolrPhpClient/Apache/Solr/Service.php @@ -1,7 +1,10 @@ 'container', @@ -494,7 +493,7 @@ function islandora_solr_simple_search_form($form, &$form_state) { * @param array $form_state * An associative array containing form state. */ -function islandora_solr_simple_search_form_submit($form, &$form_state) { +function islandora_solr_simple_search_form_submit(array $form, array &$form_state) { module_load_include('inc', 'islandora_solr', 'includes/utilities'); $search_string = islandora_solr_replace_slashes($form_state['values']['islandora_simple_search_query']); @@ -530,7 +529,7 @@ function islandora_solr_simple_search_form_submit($form, &$form_state) { * @return array * An associative array containing the fully built form structure. */ -function islandora_solr_advanced_search_form($form, &$form_state) { +function islandora_solr_advanced_search_form(array $form, array &$form_state) { global $_islandora_solr_queryclass; // 1: Form update using AJAX. @@ -723,11 +722,10 @@ function islandora_solr_advanced_search_form($form, &$form_state) { * * @see islandora_solr_advanced_search_form() */ -function _islandora_solr_advanced_search_terms($form, &$form_state) { +function _islandora_solr_advanced_search_terms(array $form, array &$form_state) { return $form['terms']; } - /** * Islandora Solr advanced search form submit callback. * @@ -738,7 +736,7 @@ function _islandora_solr_advanced_search_terms($form, &$form_state) { * * @see islandora_solr_advanced_search_form() */ -function islandora_solr_advanced_search_form_submit($form, &$form_state) { +function islandora_solr_advanced_search_form_submit(array $form, array &$form_state) { module_load_include('inc', 'islandora_solr', 'includes/utilities'); // Collect query values. @@ -871,7 +869,7 @@ function islandora_solr_display() { $attr['title'] = $display_description; $attr['href'] = url($path, array('query' => $query)); - // XXX: We're not using l() because of + // XXX: We're not using l() because of. // @link http://drupal.org/node/41595 active classes. @endlink $item = '' . check_plain($display_name) . ''; @@ -893,7 +891,6 @@ function islandora_solr_display() { return $output; } - /** * Provides a list to change the sorting on a current search query. * @@ -985,7 +982,7 @@ function islandora_solr_sort() { $hooks = islandora_build_hook_list(ISLANDORA_SOLR_FACET_BUCKET_CLASSES_HOOK_BASE); drupal_alter($hooks, $attributes, $_islandora_solr_queryclass); - // XXX: We're not using l() because of + // XXX: We're not using l() because of. // @link http://drupal.org/node/41595 active classes. @endlink $item = '' . $label . ' ' . $indicator . ''; @@ -1174,7 +1171,7 @@ function islandora_solr_search_results_limit() { $query['limit'] = $limit; unset($query['page']); $attr['href'] = url($path, array('query' => $query)); - // XXX: We're not using l() because of + // XXX: We're not using l() because of. // @link http://drupal.org/node/41595 active classes. @endlink $limit_list[] = '' . $limit . ''; } diff --git a/includes/breadcrumbs.inc b/includes/breadcrumbs.inc index 9137917e..c95539e1 100644 --- a/includes/breadcrumbs.inc +++ b/includes/breadcrumbs.inc @@ -1,4 +1,5 @@ executeQuery(FALSE); $results = (array) $solr_build->islandoraSolrResult['response']['objects']; - $find_solr_value = function($o, $field) { + $find_solr_value = function ($o, $field) { if (isset($o[$field])) { return $o[$field]; } diff --git a/includes/compound_backend.inc b/includes/compound_backend.inc index a347e164..f3649ecb 100644 --- a/includes/compound_backend.inc +++ b/includes/compound_backend.inc @@ -1,10 +1,10 @@ (($start * $rows) + $rows)); if (count($constituents) > 0) { - $sort = function($a, $b) use($sequence_pattern) { + $sort = function ($a, $b) use ($sequence_pattern) { $a = $a['solr_doc'][$sequence_pattern]; if (is_array($a)) { $a = reset($a); diff --git a/includes/db.inc b/includes/db.inc index 32ca640e..e3d8ac33 100644 --- a/includes/db.inc +++ b/includes/db.inc @@ -2,7 +2,7 @@ /** * @file - * This file contains DB query functions + * This file contains DB query functions. */ /** @@ -84,7 +84,7 @@ function islandora_solr_get_fields($field_type = NULL, $filter = TRUE, $simplifi * * @see islandora_solr_get_fields() */ -function _islandora_solr_filter_fields($records = array()) { +function _islandora_solr_filter_fields(array $records = array()) { global $user; // No checks for user 1. @@ -122,7 +122,7 @@ function _islandora_solr_filter_fields($records = array()) { * * @see islandora_solr_get_fields() */ -function _islandora_solr_simplify_fields($fields = array()) { +function _islandora_solr_simplify_fields(array $fields = array()) { // Render as term => label. $records = array(); foreach ($fields as $key => $value) { diff --git a/includes/explore.inc b/includes/explore.inc index 283712d2..b12eaa71 100644 --- a/includes/explore.inc +++ b/includes/explore.inc @@ -10,7 +10,7 @@ * * @return output * A rendered list containing explore links to islandora solr search and - * object counts. + * object counts. */ function islandora_solr_explore_generate_links() { $output = ''; @@ -45,10 +45,10 @@ function islandora_solr_explore_generate_links() { if (!empty($links)) { $output = theme('item_list', array( - 'items' => $links, - 'title' => NULL, - 'type' => 'ul', - 'attributes' => array('class' => 'islandora-solr-explore'), + 'items' => $links, + 'title' => NULL, + 'type' => 'ul', + 'attributes' => array('class' => 'islandora-solr-explore'), )); } diff --git a/includes/fields.features.inc b/includes/fields.features.inc index 556e9c02..beefcd3d 100644 --- a/includes/fields.features.inc +++ b/includes/fields.features.inc @@ -58,7 +58,7 @@ function islandora_solr_fields_features_revert($module_name) { * @return array * The input with "solr_field_settings" serialize with serialize(). */ -function islandora_solr_serialize_solr_field_settings($field) { +function islandora_solr_serialize_solr_field_settings(array $field) { if (!is_string($field['solr_field_settings'])) { $field['solr_field_settings'] = serialize($field['solr_field_settings']); } @@ -86,7 +86,7 @@ function islandora_solr_fields_features_rebuild($module_name) { 'field_type', 'weight', 'solr_field_settings', - )); + )); // Write to our database table. foreach ($values as $field) { diff --git a/includes/luke.inc b/includes/luke.inc index 29cc5b51..79113f06 100644 --- a/includes/luke.inc +++ b/includes/luke.inc @@ -131,8 +131,6 @@ function islandora_solr_get_luke($solr_url = NULL, $field = NULL, $num_terms = 0 * Returns an array containing all fields in Luke that are sortable. * * Must be indexed and can't be multivalued. - * @link http://archive.apache.org/dist/lucene/solr/ref-guide/ - * Common Query Parameters: Sort section for more info on constraints. @endlink * * @param string $solr_url * URL which points to Solr. @@ -140,6 +138,9 @@ function islandora_solr_get_luke($solr_url = NULL, $field = NULL, $num_terms = 0 * @return array|bool * An array containing all fields in Luke that are sortable. If no * fields are sortable, it returns FALSE. + * + * @see http://archive.apache.org/dist/lucene/solr/ref-guide/ + * Common Query Parameters: Sort section for more info on constraints. */ function islandora_solr_get_sortable($solr_url = NULL) { $sortable = array(); @@ -164,7 +165,6 @@ function islandora_solr_get_sortable($solr_url = NULL) { * Checks a single Solr field if it's sortable. * * Must be indexed and can't be multivalued. - * @link http://wiki.apache.org/solr/CommonQueryParameters#sort More info on constraints. @endlink * * @param string $solr_url * URL which points to Solr. @@ -174,6 +174,9 @@ function islandora_solr_get_sortable($solr_url = NULL) { * @return bool * Returns TRUE if the given field is sortable, returns FALSE if the field is * not sortable or if field is not set. + * + * @see http://wiki.apache.org/solr/CommonQueryParameters#sort + * More info on constraints. */ function islandora_solr_check_sortable($solr_url = NULL, $field = NULL) { $sortable = FALSE; @@ -245,13 +248,13 @@ function islandora_solr_get_type_class($solr_type) { * @return array|bool * The version array or FALSE if can't be determined. * - * Version array has keys: - * 'version' => 'string of version'. - * 'major' => first digit (if parseable), - * 'minor' => second digit (if applicable), - * 'patch' => third digit (if applicable) + * Version array has keys: + * 'version' => 'string of version'. + * 'major' => first digit (if parseable), + * 'minor' => second digit (if applicable), + * 'patch' => third digit (if applicable) * - * Only version is guaranteed to be returned on a successful request. + * Only version is guaranteed to be returned on a successful request. */ function islandora_solr_get_solr_version($reset = FALSE) { $version = &drupal_static(__FUNCTION__); diff --git a/includes/query_processor.inc b/includes/query_processor.inc index b369d41f..0ab7badc 100644 --- a/includes/query_processor.inc +++ b/includes/query_processor.inc @@ -2,8 +2,9 @@ /** * @file - * Contains methods to build and execute a solr query. Depends on - * Apache_Solr_Php client. + * Contains methods to build and execute a solr query. + * + * Depends on Apache_Solr_Php client. */ /** @@ -16,19 +17,59 @@ class IslandoraSolrQueryProcessor { public $solrQuery; - // Query alternative set if solrQuery is empty. + /** + * Query alternative set if solrQuery is empty. + * + * @var string + */ public $internalSolrQuery; + /** + * The starting position for the results. + * + * @var int + */ public $solrStart; + /** + * Max number of rows to return. + * + * @var int + */ public $solrLimit; + /** + * The type of query to execute. + * + * @var string + */ public $solrDefType; - // All other Solr parameters. + /** + * All other Solr parameters. + * + * @var array + */ public $solrParams = array(); - // Solr results tailored for Islandora's use. + /** + * Solr results tailored for Islandora's use. + * + * @var array + */ public $islandoraSolrResult; - // The current display (for modules wanting to alter the query of a display). + /** + * The current display (for modules wanting to alter the query of a display). + * + * @var string + */ public $display; - // Parameters from URL. + /** + * Parameters from URL. + * + * @var array + */ public $internalSolrParams; + /** + * Different strings of characters that are considered empty query strings. + * + * @var array + */ public $differentKindsOfNothing = array( ' ', '%20', @@ -38,6 +79,11 @@ class IslandoraSolrQueryProcessor { '', ); + /** + * Solr version from islandora_solr_get_solr_version(). + * + * @var array|bool + */ protected $solrVersion; /** @@ -96,7 +142,7 @@ class IslandoraSolrQueryProcessor { * @param bool $alter_results * Whether or not to send out hooks to alter the islandora_solr_results. */ - public function buildAndExecuteQuery($query, $params = NULL, $alter_results = TRUE) { + public function buildAndExecuteQuery($query, array $params = NULL, $alter_results = TRUE) { // Set empty string. if (variable_get('islandora_solr_request_handler', '') == 'standard') { if (!$query || $query == ' ') { @@ -118,14 +164,14 @@ class IslandoraSolrQueryProcessor { * be used for the query execution. Includes a module_invoke_all to make * changes to the query. * - * @see IslandoraSolrQueryProcessor::buildAndExecuteQuery() - * * @param string $query * The query string provided in the URL. * @param array $params * All URL parameters from the Solr results page. + * + * @see IslandoraSolrQueryProcessor::buildAndExecuteQuery() */ - public function buildQuery($query, $params = array()) { + public function buildQuery($query, array $params = array()) { // Set internal parameters gathered from the URL but not 'q' and 'page'. $this->internalSolrParams = $params; unset($this->internalSolrParams['q']); @@ -228,7 +274,7 @@ class IslandoraSolrQueryProcessor { if (!empty($facet_dates_ranges)) { // Set range/date variables. $params_date_facets = array(); - $facet_dates = array_filter($facet_dates_ranges, function($o) { + $facet_dates = array_filter($facet_dates_ranges, function ($o) { return islandora_solr_is_date_field($o['solr_field']); }); foreach ($facet_dates_ranges as $key => $value) { @@ -385,6 +431,8 @@ class IslandoraSolrQueryProcessor { * * @param bool $alter_results * Whether or not to send out hooks to alter the islandora_solr_results. + * @param bool $use_post + * Whether to use GET or POST for query. */ public function executeQuery($alter_results = TRUE, $use_post = FALSE) { // Init Apache_Solr_Service object. @@ -431,7 +479,8 @@ class IslandoraSolrQueryProcessor { 'solr_nav' => array( 'id' => $id, 'page' => (isset($page_params['page']) ? $page_params['page'] : 0), - )); + ), + ); } else { $url_params = array(); @@ -513,7 +562,7 @@ class IslandoraSolrQueryProcessor { * @return array * The object results array with updated solr doc values. */ - public function prepareSolrDoc($object_results) { + public function prepareSolrDoc(array $object_results) { // Optionally limit results to values given. $limit_results = variable_get('islandora_solr_limit_result_fields', 0); // Look for fields with no permission. diff --git a/includes/results.inc b/includes/results.inc index f95cc279..b30969ae 100644 --- a/includes/results.inc +++ b/includes/results.inc @@ -33,8 +33,6 @@ class IslandoraSolrResults { /** * Output the main body of the search results. * - * @see islandora_solr() - * * @param IslandoraSolrQueryProcessor $islandora_solr_query * The IslandoraSolrQueryProcessor object which includes the current query * settings and the raw Solr results. @@ -42,8 +40,10 @@ class IslandoraSolrResults { * @return string * Returns themed Solr results page, including wrapper and rendered search * results. + * + * @see islandora_solr() */ - public function displayResults($islandora_solr_query) { + public function displayResults(IslandoraSolrQueryProcessor $islandora_solr_query) { $this->islandoraSolrQueryProcessor = $islandora_solr_query; // Set variables to collect returned data. @@ -109,7 +109,7 @@ class IslandoraSolrResults { * * @see IslandoraSolrResults::displayResults() */ - public function addSecondaries($islandora_solr_query) { + public function addSecondaries(IslandoraSolrQueryProcessor $islandora_solr_query) { $query_list = array(); // Get secondary display profiles. $secondary_display_profiles = module_invoke_all('islandora_solr_secondary_display'); @@ -165,7 +165,7 @@ class IslandoraSolrResults { * * @see IslandoraSolrResults::displayResults() */ - public function printResults($solr_results) { + public function printResults(array $solr_results) { $solr_results = islandora_solr_prepare_solr_results($solr_results); $object_results = $solr_results['response']['objects']; $object_results = islandora_solr_prepare_solr_doc($object_results); @@ -191,7 +191,7 @@ class IslandoraSolrResults { * @return string * Rendered lists of the currently active query and/or filters. */ - public function currentQuery($islandora_solr_query) { + public function currentQuery(IslandoraSolrQueryProcessor $islandora_solr_query) { module_load_include('inc', 'islandora', 'includes/utilities'); $output = ''; @@ -325,7 +325,7 @@ class IslandoraSolrResults { * The IslandoraSolrQueryProcessor object, which includes the current query * settings and the raw Solr results. */ - public function setBreadcrumbs($islandora_solr_query) { + public function setBreadcrumbs(IslandoraSolrQueryProcessor $islandora_solr_query) { $breadcrumb = $this->getBreadcrumbs($islandora_solr_query); drupal_set_breadcrumb($breadcrumb); } @@ -343,7 +343,7 @@ class IslandoraSolrResults { * @return array * An array of breadcrumbs. */ - public function getBreadcrumbs($islandora_solr_query) { + public function getBreadcrumbs(IslandoraSolrQueryProcessor $islandora_solr_query) { // $_GET['q'] didn't seem to work here. $path = current_path(); // Get date format. @@ -581,7 +581,7 @@ class IslandoraSolrResults { * @see islandora_solr_islandora_solr_query_blocks() * @see islandora_solr_block_view() */ - public function displayFacets($islandora_solr_query) { + public function displayFacets(IslandoraSolrQueryProcessor $islandora_solr_query) { IslandoraSolrFacets::init($islandora_solr_query); $output = ''; $facet_order = $this->facetFieldArray; @@ -603,16 +603,16 @@ class IslandoraSolrResults { * Creates a fieldset containing raw Solr results of the current page for * debugging purposes. * - * @see IslandoraSolrResults::displayResults() - * * @param array $islandora_solr_results * The processed Solr results from - * IslandoraSolrQueryProcessor::islandoraSolrResult + * IslandoraSolrQueryProcessor::islandoraSolrResult. * * @return string * Rendered fieldset containing raw Solr results data. + * + * @see IslandoraSolrResults::displayResults() */ - public function printDebugOutput($islandora_solr_results) { + public function printDebugOutput(array $islandora_solr_results) { // Debug dump. $results = "
Results: " . print_r($islandora_solr_results, TRUE) . "
"; $fieldset = array( @@ -649,7 +649,7 @@ class IslandoraSolrResults { } /** - * Islandora Solr Facets + * Islandora Solr Facets. */ class IslandoraSolrFacets { public static $islandoraSolrQuery; @@ -750,7 +750,7 @@ class IslandoraSolrFacets { * Method called after a facet object is created. This will prepare the * results based on the type and user settings for this facet. It also does a * call to render the prepared data. This method also returns the rendered - * endresult. + * end result. * * @return string * Returns the title and rendered facet. @@ -759,11 +759,11 @@ class IslandoraSolrFacets { $this->findFacetType(); $this->getFacetResults(); if (empty($this->results)) { - return; + return ""; } $this->processFacets(); if (empty($this->content)) { - return; + return ""; } $elements = array( 'title' => $this->title, @@ -975,7 +975,7 @@ class IslandoraSolrFacets { * @param array $results * An array with the prepared facet results. */ - public function renderText($results) { + public function renderText(array $results) { $facet_field = $this->facet_field; $islandora_solr_query = self::$islandoraSolrQuery; $soft_limit = self::$soft_limit; @@ -1195,7 +1195,7 @@ class IslandoraSolrFacets { $results = array_reverse($results); // Add end date. - if (isset($new_end['count']) AND $new_end['count'] == 0) { + if (isset($new_end['count']) and $new_end['count'] == 0) { $end_bucket = $new_end['bucket']; $results[$end_bucket] = NULL; } @@ -1579,4 +1579,5 @@ class IslandoraSolrFacets { $results = $min_max_query->islandoraSolrResult; return $results['response']['objects'][0]['solr_doc'][$field]; } + } diff --git a/includes/utilities.inc b/includes/utilities.inc index 11122960..1f3907a1 100644 --- a/includes/utilities.inc +++ b/includes/utilities.inc @@ -11,8 +11,6 @@ * The nuts and bolts of this function are borrowed from z3950.module * and also apachesolr.module. * - * @see pager_query() - * * @param int $total * The total number of items found. * @param int $limit @@ -22,6 +20,8 @@ * * @return int * The current page for $element. 0 by default if $_GET['page'] is empty. + * + * @see pager_query() */ function islandora_solr_pager_init($total, $limit = 10, $element = 0) { global $pager_page_array, $pager_total, $pager_total_items; @@ -85,6 +85,7 @@ function islandora_solr_replace_slashes($str) { * A better explode method allows quotes in the returned strings. * * Taken from php.net. + * XXX: Is this function really necessary? * * @param string $delim * The delimiter on which to break (',' by default). @@ -95,8 +96,6 @@ function islandora_solr_replace_slashes($str) { * @param bool $preserve * ??? Something to do with $enclose. * - * XXX: Is this function really necessary? - * * @return array * An array containing the items of $str, broken apart on $delim. */ @@ -126,14 +125,13 @@ function islandora_solr_csv_explode($delim = ',', $str = '', $enclose = '"', $pr * * @param string $value * A string to escape. - * * @param array $pattern - * An regular expression pattern + * An regular expression pattern. * * @return string * The escaped string. */ -function islandora_solr_facet_query_escape($value, $pattern = NULL) { +function islandora_solr_facet_query_escape($value, array $pattern = NULL) { if (!$pattern) { $pattern = ISLANDORA_SOLR_QUERY_FACET_LUCENE_ESCAPE_REGEX_DEFAULT; } @@ -212,10 +210,6 @@ function islandora_solr_escape($facets) { * * Mostly used with variable_get(). * - * @deprecated - * No longer used, due to the use of a separate database table for - * configuration. - * * @param string $raw_field_list * A string containing the list of fields to parse, with individual items * separated by either a comma or newline. Each field entry may be either a @@ -227,6 +221,10 @@ function islandora_solr_escape($facets) { * * @return array * An associative array mapping the fields to our human-readable label. + * + * @deprecated + * No longer used, due to the use of a separate database table for + * configuration. */ function islandora_solr_build_substitution_list($raw_field_list) { $facet_array = array(); @@ -265,7 +263,7 @@ function islandora_solr_build_substitution_list($raw_field_list) { * @return array * The original object results array, but with a modified Solr doc. */ -function islandora_solr_prepare_solr_doc($object_results) { +function islandora_solr_prepare_solr_doc(array $object_results) { $fields_all = islandora_solr_get_fields('result_fields', FALSE); // Loop over object results. foreach ($object_results as $object_index => $object_result) { @@ -301,7 +299,7 @@ function islandora_solr_prepare_solr_doc($object_results) { * @return array * Returns the same array but with prepared Solr field values. */ -function islandora_solr_prepare_solr_results($solr_results) { +function islandora_solr_prepare_solr_results(array $solr_results) { module_load_include('inc', 'islandora_solr', 'includes/field_truncation'); $object_results = $solr_results['response']['objects']; @@ -521,7 +519,7 @@ function islandora_solr_islandora_basic_collection_backend_callable($collection_ * Min wordsafe length. * @param string $separator * A separator to use for display output. - * @param array|NULL $link_options + * @param array|null $link_options * (Optional) An array of link options including: * - 'link_to_object' : (bool) Include link to object. * - 'link_to_search' : (bool) Include link to search results. @@ -532,7 +530,7 @@ function islandora_solr_islandora_basic_collection_backend_callable($collection_ * @return string * The updated display values. */ -function islandora_solr_truncate_field_display($display_values, $max_length, $add_ellipsis, $word_safe, $wordsafe_length, $separator, $link_options = NULL) { +function islandora_solr_truncate_field_display(array $display_values, $max_length, $add_ellipsis, $word_safe, $wordsafe_length, $separator, $link_options = NULL) { module_load_include('inc', 'islandora_solr', 'includes/field_truncation'); $updated_display_values = $display_values; @@ -582,7 +580,7 @@ function islandora_solr_truncate_field_display($display_values, $max_length, $ad $solr_query = format_string('!field:"!value"', array( '!field' => $link_options['field'], '!value' => islandora_solr_lesser_escape($original_value), - )); + )); $original_value = l( $original_value, "islandora/search/$solr_query", @@ -625,7 +623,7 @@ function islandora_solr_truncate_field_display($display_values, $max_length, $ad * Check the field type against the user-specified list of date field types. * * @param string $solr_field - * The Solr field name + * The Solr field name. * * @return bool * Whether the field matches the date field types. @@ -667,7 +665,7 @@ function islandora_solr_is_boolean_field($solr_field) { * @return bool * Whether the field type is in the provided list. */ -function islandora_solr_is_typed_field($solr_field, $types) { +function islandora_solr_is_typed_field($solr_field, array $types) { $luke_result = islandora_solr_get_luke(NULL, $solr_field); $type = (isset($luke_result['fields'][$solr_field]['type']) ? $luke_result['fields'][$solr_field]['type'] : FALSE); if ($type) { diff --git a/islandora_solr.api.php b/islandora_solr.api.php index adb23ee6..1df0ed25 100644 --- a/islandora_solr.api.php +++ b/islandora_solr.api.php @@ -91,8 +91,8 @@ function hook_islandora_solr_secondary_display() { * * @see IslandoraSolrQueryProcessor::buildQuery() */ -function hook_islandora_solr_query($islandora_solr_query) { - // example: on example_display, always sort descending on fgs.createdDate +function hook_islandora_solr_query(IslandoraSolrQueryProcessor $islandora_solr_query) { + // example: on example_display, always sort descending on fgs.createdDate. if ($islandora_solr_query->display == 'example_display') { $islandora_solr_query->solrParams['sort'] = 'fgs.createdDate desc'; } @@ -108,7 +108,7 @@ function hook_islandora_solr_query($islandora_solr_query) { * @see hook_islandora_solr_query() * @see IslandoraSolrQueryProcessor::buildQuery() */ -function hook_islandora_solr_query_alter($islandora_solr_query) { +function hook_islandora_solr_query_alter(IslandoraSolrQueryProcessor $islandora_solr_query) { } @@ -148,15 +148,14 @@ function hook_islandora_solr_query_result(array $result) { } } -/** +/* * @} End of "addtogroup hooks". */ - /** * Implements hook_CMODEL_PID_islandora_solr_object_result_alter(). */ -function hook_islandora_pageCModel_islandora_solr_object_result_alter(&$search_result, $query_processor) { +function hook_islandora_pagecmodel_islandora_solr_object_result_alter(&$search_result, $query_processor) { $search_result['object_url_params']['terms'] = $query_processor->solrQuery; } @@ -179,12 +178,12 @@ function hook_islandora_solr_object_result_alter(&$search_result, $query_process * * Somtimes you might want to alter how an rss item is displayed. * - * @param rssItem $item - * The rssItem object + * @param array $item + * The rssItem object. * @param array $doc - * The solr results document + * The solr results document. */ -function hook_islandora_solr_search_rss_item_alter($item, $doc) { +function hook_islandora_solr_search_rss_item_alter(array $item, array $doc) { $item['title'] = $doc['PID']; $item['description'] = 'this is the new rss item description'; @@ -210,7 +209,7 @@ function hook_islandora_solr_search_rss_item_alter($item, $doc) { * @param IslandoraSolrQueryProcessor $query_processor * The query processor for the current query (with results attached). */ -function hook_islandora_solr_facet_bucket_classes_alter(&$buckets, &$query_processor) { +function hook_islandora_solr_facet_bucket_classes_alter(array &$buckets, IslandoraSolrQueryProcessor &$query_processor) { foreach ($buckets as $bucket => &$value) { // Add the 'use-ajax' bit so Drupal will use AJAX. diff --git a/islandora_solr.install b/islandora_solr.install index 46e5fe44..b43363c8 100644 --- a/islandora_solr.install +++ b/islandora_solr.install @@ -30,7 +30,6 @@ function islandora_solr_requirements($phase) { return $requirements; } - /** * Implements hook_install(). */ @@ -253,7 +252,7 @@ function islandora_solr_update_7002() { ->fields('c', array('collection_pid', 'sort_string')) ->execute(); - $is_empty = function($o) { + $is_empty = function ($o) { return (empty($o) || !trim($o)); }; diff --git a/islandora_solr.module b/islandora_solr.module index f9328335..bc176b26 100644 --- a/islandora_solr.module +++ b/islandora_solr.module @@ -258,16 +258,16 @@ function islandora_solr_islandora_solr_primary_display() { * Finds the right display and calls the IslandoraSolrRestuls class to build the * display, which it returns to the page. * - * @global IslandoraSolrQueryProcessor $_islandora_solr_queryclass - * The IslandoraSolrQueryProcessor object which includes the current query - * settings and the raw Solr results. - * * @param string $query * The query string. * * @return string * A rendered Solr display * + * @global IslandoraSolrQueryProcessor $_islandora_solr_queryclass + * The IslandoraSolrQueryProcessor object which includes the current query + * settings and the raw Solr results. + * * @see hook_menu() */ function islandora_solr($query = NULL, $params = NULL) { diff --git a/islandora_solr_config/includes/admin.inc b/islandora_solr_config/includes/admin.inc index 89288394..808ecbde 100644 --- a/islandora_solr_config/includes/admin.inc +++ b/islandora_solr_config/includes/admin.inc @@ -2,7 +2,7 @@ /** * @file - * Contains all administration related functionality + * Contains all administration related functionality. */ /** @@ -16,7 +16,7 @@ * @return array * The admin form to be rendered. */ -function islandora_solr_config_admin_rss_settings($form, &$form_state) { +function islandora_solr_config_admin_rss_settings(array $form, array &$form_state) { // Get variables. $rss_item = variable_get('islandora_solr_config_rss_item', array( 'title' => 'fgs_label_s', diff --git a/islandora_solr_config/includes/csv_results.inc b/islandora_solr_config/includes/csv_results.inc index 38b2c858..65751886 100644 --- a/islandora_solr_config/includes/csv_results.inc +++ b/islandora_solr_config/includes/csv_results.inc @@ -2,8 +2,9 @@ /** * @file - * Contains methods to search solr and display results. Depends on - * Apache_Solr_Php client. + * Contains methods to search solr and display results. + * + * Depends on Apache_Solr_Php client. */ /** @@ -17,15 +18,15 @@ class IslandoraSolrResultsCSV extends IslandoraSolrResults { * Renders the Solr results as a comma separated values file (.csv). Resets * the html headers so it'll prompt to be downloaded. * - * @see IslandoraSolrResults - * - * @global type $base_url - * - * @param object $islandora_solr_query + * @param IslandoraSolrQueryProcessor $islandora_solr_query * The IslandoraSolrQueryProcessor object which includes the current query * settings and the raw Solr results. + * + * @see IslandoraSolrResults + * + * @global string $base_url */ - public function printCSV($islandora_solr_query) { + public function printCsv(IslandoraSolrQueryProcessor $islandora_solr_query) { global $base_url; $redirect = drupal_parse_url(request_uri()); // We want to unset the display profile of CSV, but keep everything else. @@ -44,10 +45,13 @@ class IslandoraSolrResultsCSV extends IslandoraSolrResults { /** * Constructs a batch that creates a CSV for export. * - * @param object $islandora_solr_query + * @param IslandoraSolrQueryProcessor $islandora_solr_query * The Islandora Solr Query processor. + * + * @return array + * The batch operations. */ - public function batchSolrResults($islandora_solr_query) { + public function batchSolrResults(IslandoraSolrQueryProcessor $islandora_solr_query) { return array( 'operations' => array( array('islandora_solr_config_csv_batch_update_operation', array($islandora_solr_query)), @@ -60,6 +64,7 @@ class IslandoraSolrResultsCSV extends IslandoraSolrResults { 'finished' => 'islandora_solr_config_csv_download_csv', ); } + } /** @@ -67,12 +72,12 @@ class IslandoraSolrResultsCSV extends IslandoraSolrResults { * * Batch in 1000 increments so Solr doesn't go kaboooom. * - * @param object $islandora_solr_query + * @param IslandoraSolrQueryProcessor $islandora_solr_query * An Islandora Solr Query processor object. * @param array $context * The context array for the current batch. */ -function islandora_solr_config_csv_batch_update_operation($islandora_solr_query, &$context) { +function islandora_solr_config_csv_batch_update_operation(IslandoraSolrQueryProcessor $islandora_solr_query, array &$context) { $csv_batch_limit = 100; $sandbox = &$context['sandbox']; @@ -123,16 +128,16 @@ function islandora_solr_config_csv_batch_update_operation($islandora_solr_query, /** * Copies file from tmp and appends headers on the front for export. * - * @global type $user - * * @param array $success * The success array from the batch. * @param array $results * The results array from the batch. * @param array $operations * The operations array from the batch. + * + * @global $user */ -function islandora_solr_config_csv_download_csv($success, $results, $operations) { +function islandora_solr_config_csv_download_csv(array $success, array $results, array $operations) { global $user; $export_uri = 'public://csv_export_' . time() . '.csv'; // We register this file into Drupal so it will be deleted. diff --git a/islandora_solr_config/includes/grid_results.inc b/islandora_solr_config/includes/grid_results.inc index 6702b8d9..c6a6bbb7 100644 --- a/islandora_solr_config/includes/grid_results.inc +++ b/islandora_solr_config/includes/grid_results.inc @@ -2,7 +2,7 @@ /** * @file - * Class override for grid display + * Class override for grid display. */ /** @@ -16,16 +16,16 @@ class IslandoraSolrResultsGrid extends IslandoraSolrResults { * Markup and styling is based on the Islandora collection grid view. Some * styling is inherited from it. * - * @see IslandoraSolrResults::displayResults() - * * @param array $solr_results * The processed Solr results from * IslandoraSolrQueryProcessor::islandoraSolrResult. * * @return string * Rendered Solr results. + * + * @see IslandoraSolrResults::displayResults() */ - public function printResults($solr_results) { + public function printResults(array $solr_results) { $mod_path = drupal_get_path('module', 'islandora_solr_config'); drupal_add_css("$mod_path/css/islandora_solr_config.theme.css"); $object_results = $solr_results['response']['objects']; @@ -39,4 +39,5 @@ class IslandoraSolrResultsGrid extends IslandoraSolrResults { 'elements' => $elements, )); } + } diff --git a/islandora_solr_config/includes/rss_results.inc b/islandora_solr_config/includes/rss_results.inc index df45a163..724cf839 100644 --- a/islandora_solr_config/includes/rss_results.inc +++ b/islandora_solr_config/includes/rss_results.inc @@ -2,16 +2,17 @@ /** * @file - * Contains methods to search solr and display results. depends on - * Apache_Solr_Php client. + * Contains methods to search solr and display results. + * + * Depends on Apache_Solr_Php client. */ /** * Extention of IslandoraSolrResults for templating purposes. + * * This overrides the displayResults function to provide an alternate display * type. */ - class IslandoraSolrResultsRSS extends IslandoraSolrResults { /** @@ -19,16 +20,16 @@ class IslandoraSolrResultsRSS extends IslandoraSolrResults { * * Thumbnails pulled from the Fedora repository. * - * @param object $islandora_solr_query + * @param IslandoraSolrQueryProcessor $islandora_solr_query * A solr query object. + * @param string $title + * Unused and should be removed. + * * - * @return string - * html output for the resultset. Note: we currently create this + * Directly outputs html for the resultset. Note: we currently create this * output manually, should refactor to use drupal forms api. */ - public function printRSS($islandora_solr_query, $title = "Search Results") { - - global $base_url; + public function printRss(IslandoraSolrQueryProcessor $islandora_solr_query, $title = "Search Results") { drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8'); $islandora_solr_query->solrLimit = variable_get('islandora_solr_config_rss_limit', 50); @@ -94,7 +95,6 @@ class IslandoraSolrResultsRSS extends IslandoraSolrResults { exit; } - /** * Function for setting the values of the elements for the RSS display. * @@ -138,31 +138,42 @@ class IslandoraSolrResultsRSS extends IslandoraSolrResults { $result['items'] = array( array( 'key' => 'author', - 'value' => ($rss_item['author'] && isset($doc[$rss_item['author']])) ? $doc[$rss_item['author']] : ''), + 'value' => ($rss_item['author'] && isset($doc[$rss_item['author']])) ? $doc[$rss_item['author']] : '', + ), array( 'key' => 'guid', 'value' => $doc['PID'], - 'attributes' => array('isPermaLink' => 'false')), + 'attributes' => array('isPermaLink' => 'false'), + ), array( 'key' => 'pubDate', - 'value' => ($rss_item['pubDate'] && isset($doc[$rss_item['pubDate']])) ? $doc[$rss_item['pubDate']] : ''), + 'value' => ($rss_item['pubDate'] && isset($doc[$rss_item['pubDate']])) ? $doc[$rss_item['pubDate']] : '', + ), array( 'key' => 'category', - 'value' => ($rss_item['category'] && isset($doc[$rss_item['category']])) ? $doc[$rss_item['category']] : ''), + 'value' => ($rss_item['category'] && isset($doc[$rss_item['category']])) ? $doc[$rss_item['category']] : '', + ), array( 'key' => 'comments', - 'value' => ''), + 'value' => '', + ), array( 'key' => 'source', - 'value' => $rss_source, 'attributes' => array('url' => $base_url)), + 'value' => $rss_source, + 'attributes' => array('url' => $base_url), + ), ); if ($is_datastream) { $result['items'][] = array( 'key' => 'enclosure', - 'value' => '', 'attributes' => array( - 'url' => $enclosure_url, 'length' => '', - 'type' => '')); + 'value' => '', + 'attributes' => array( + 'url' => $enclosure_url, + 'length' => '', + 'type' => '', + ), + ); } return $result; @@ -171,6 +182,9 @@ class IslandoraSolrResultsRSS extends IslandoraSolrResults { /** * Function to set values of the elements for the RSS display. * + * @param string $query + * The query being used. + * * @tutorial http://feed2.w3.org/docs/rss2.html#requiredChannelElements * * @return array @@ -194,14 +208,18 @@ class IslandoraSolrResultsRSS extends IslandoraSolrResults { $result['args'] = array( array( 'key' => 'copyright', - 'value' => $rss_channel['copyright']), + 'value' => $rss_channel['copyright'], + ), array( 'key' => 'managingEditor', - 'value' => $rss_channel['managingEditor']), + 'value' => $rss_channel['managingEditor'], + ), array( 'key' => 'webMaster', - 'value' => $rss_channel['webMaster']), + 'value' => $rss_channel['webMaster'], + ), ); return $result; } + } diff --git a/islandora_solr_config/includes/table_results.inc b/islandora_solr_config/includes/table_results.inc index 7543d011..55cef63f 100644 --- a/islandora_solr_config/includes/table_results.inc +++ b/islandora_solr_config/includes/table_results.inc @@ -2,8 +2,9 @@ /** * @file - * Contains methods to search solr and display results. Depends on - * Apache_Solr_Php client. + * Contains methods to search solr and display results. + * + * Depends on Apache_Solr_Php client. */ /** @@ -14,16 +15,16 @@ class IslandoraSolrResultsTable extends IslandoraSolrResults { /** * Renders the Solr results as a table. * - * @see IslandoraSolrResults::displayResults() - * * @param array $solr_results * The raw Solr results from * IslandoraSolrQueryProcessor::islandoraSolrResult. * * @return string * Rendered Solr results + * + * @see IslandoraSolrResults::displayResults() */ - public function printResults($solr_results) { + public function printResults(array $solr_results) { $mod_path = drupal_get_path('module', 'islandora_solr_config'); drupal_add_css("$mod_path/css/islandora_solr_config.theme.css"); diff --git a/islandora_solr_config/islandora_solr_config.api.php b/islandora_solr_config/islandora_solr_config.api.php index 81b04425..1d160c3f 100644 --- a/islandora_solr_config/islandora_solr_config.api.php +++ b/islandora_solr_config/islandora_solr_config.api.php @@ -13,7 +13,7 @@ * @param array $doc * A Solr result. */ -function hook_islandora_solr_config_rss_item_post_render_alter(&$rendered_item, &$doc) { +function hook_islandora_solr_config_rss_item_post_render_alter(&$rendered_item, array &$doc) { $item = new DOMDocument(); $item->loadXML($rendered_item); @@ -38,7 +38,7 @@ function hook_islandora_solr_config_rss_item_post_render_alter(&$rendered_item, * @param string $items * The rendered items to add in the channel. */ -function hook_islandora_solr_config_rss_root_element_attributes_alter(&$root_attributes, &$channel_info, &$items) { +function hook_islandora_solr_config_rss_root_element_attributes_alter(array &$root_attributes, array &$channel_info, &$items) { // Could add namespaces to the root element or mess with the values to output // for the channel or all the items... If trying to parse $items, one would // have to treat it as a document fragment (its not valid XML on diff --git a/islandora_solr_config/islandora_solr_config.module b/islandora_solr_config/islandora_solr_config.module index fbe5ef5b..dd263210 100644 --- a/islandora_solr_config/islandora_solr_config.module +++ b/islandora_solr_config/islandora_solr_config.module @@ -81,6 +81,7 @@ function islandora_solr_config_menu() { ); return $items; } + /** * Implements hook_theme(). */ diff --git a/islandora_solr_config/theme/islandora-solr-grid.tpl.php b/islandora_solr_config/theme/islandora-solr-grid.tpl.php index 2684209e..a44aa74b 100644 --- a/islandora_solr_config/theme/islandora-solr-grid.tpl.php +++ b/islandora_solr_config/theme/islandora-solr-grid.tpl.php @@ -1,10 +1,11 @@ - - diff --git a/theme/islandora-solr-wrapper.tpl.php b/theme/islandora-solr-wrapper.tpl.php index a82f1ea8..7251fbe3 100644 --- a/theme/islandora-solr-wrapper.tpl.php +++ b/theme/islandora-solr-wrapper.tpl.php @@ -1,7 +1,8 @@

diff --git a/theme/theme.inc b/theme/theme.inc index 9c39897f..e0771ff8 100644 --- a/theme/theme.inc +++ b/theme/theme.inc @@ -5,14 +5,11 @@ * Theme functions for the Islandora Solr Search module. */ - /** * Prepares variables for islandora_solr_wrapper templates. * * Default template: theme/islandora-solr-wrapper.tpl.php. * - * @global string $base_url - * * @param array $variables * An associative array containing: * - results: Rendered primary display @@ -22,12 +19,14 @@ * - pager: (optional) Rendered pager * - solr_total: (optional) Total amount of documents found. * - solr_start: (optional) Solr start position - * - solr_end: (optional) Solr end position + * - solr_end: (optional) Solr end position. + * + * @global string $base_url * * @see islandora_solr_theme() * @see IslandoraSolrResults::displayResults() */ -function template_preprocess_islandora_solr_wrapper(&$variables) { +function template_preprocess_islandora_solr_wrapper(array &$variables) { global $base_url; $variables['base_url'] = $base_url; @@ -111,7 +110,7 @@ function template_preprocess_islandora_solr_facet(&$variables) { * * @ingroup themeable */ -function theme_islandora_solr_facet_wrapper($variables) { +function theme_islandora_solr_facet_wrapper(array $variables) { $output = '
'; $output .= '

' . $variables['title'] . '

'; $output .= $variables['content'];