Skip to content

Commit

Permalink
Modify page titles to support the use of a common title prefix. Other…
Browse files Browse the repository at this point in the history
… minor modifications to title formatting for search results with an empty query (or wildcard query).
  • Loading branch information
jjwatts committed Jul 3, 2013
1 parent bd5287a commit 0878f38
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 27 deletions.
25 changes: 20 additions & 5 deletions application/controllers/advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ function _remap($path, $params = array()) {
$form = form_open('advanced/post');

$search_fields = $this->config->item('skylight_search_fields');
// Determine the page title and heading.
$page_title_prefix = $this->config->item('skylight_page_title_prefix');
if( !isset($page_title_prefix) ) {
$page_title_prefix = "";
}

foreach($search_fields as $key => $value) {

Expand Down Expand Up @@ -71,7 +76,7 @@ function _remap($path, $params = array()) {
$formdata['formhidden'] = false;

// Set the page title to the record title
$data['page_title'] = 'Advanced Search';
$data['page_title'] = $page_title_prefix.'Advanced Search';
$this->view('header', $data);
$this->view('div_main');
$this->view('advanced_search',$formdata);
Expand Down Expand Up @@ -204,18 +209,30 @@ function _remap($path, $params = array()) {
$data['sort_options'] = $sort_options;
// Variables to populate the search box
$data['searchbox_query'] = $query;
if (($data['searchbox_query'] == '*') || ($data['searchbox_query'] == '*:*')) $data['searchbox_query'] = '';
if (($data['searchbox_query'] == '*') || ($data['searchbox_query'] == '*:*')) {
$data['searchbox_query'] = '';
}
$data['searchbox_filters'] = $saved_filters;

$data['form'] = $form;
$data['formhidden'] = true;

$data['message'] = $message;


$decodedQuery = urldecode($query);
if( $decodedQuery !== "*:*" && $decodedQuery !== "*" && $decodedQuery !== "" ) {
$data['page_title'] = $page_title_prefix.'Search results for "'.$decodedQuery.'"';
$data['page_heading'] = 'Search results for "<span class=searched>'.$decodedQuery.'</span>"';
} else {
$data['page_title'] = $page_title_prefix.'Search Results';
$data['page_heading'] = 'Search Results"';
}


// Check for zero results
$result_count = $data['rows'];
if ($result_count == 0) {
$data['page_title'] = 'No search results found!';
$this->view('header', $data);
$this->view('div_main');
$this->view('advanced_search',$data);
Expand Down Expand Up @@ -246,8 +263,6 @@ function _remap($path, $params = array()) {
else
$data['endrow'] = $data['startrow'] + ($rows - 1);

// Set the page title to the record title
$data['page_title'] = 'Search results for "<span class=searched>'.urldecode($query).'</span>"';
$data['title_field'] = $title;
$data['author_field'] = $title = $this->skylight_utilities->getField('Author');
$data['fielddisplay'] = $this->config->item("skylight_searchresult_display");
Expand Down
24 changes: 15 additions & 9 deletions application/controllers/browse.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function _remap($field, $params = array()) {
$delimiter = $this->config->item('skylight_filter_delimiter');
$rows = 30;
$recorddisplay = $this->config->item('skylight_recorddisplay');
// $title = $recorddisplay['Title'];
//$title = $recorddisplay['Title'];

$saved_filters = array();
$url_filters = array();
Expand All @@ -35,10 +35,8 @@ function _remap($field, $params = array()) {
}
}


$offset = $this->input->get('offset');
$prefix = $this->input->get('prefix');
// echo "PREFIX IS $prefix";


// Base search URL
Expand All @@ -47,17 +45,25 @@ function _remap($field, $params = array()) {
$base_search .= '/'.$url_filter;
}

$decodedField = urldecode($field);

// Solr query business moved to solr_client library
$data = $this->solr_client->browseTerms($field, $rows, $offset, $prefix);
$data = $this->solr_client->browseTerms($decodedField, $rows, $offset, $prefix);


// Determine the page title and heading.
$page_title_prefix = $this->config->item('skylight_page_title_prefix');
if( !isset($page_title_prefix) ) {
$page_title_prefix = "";
}

// Check for zero results
$result_count = $data['rows'];
$facet_count = $data['facet']['termcount'];

if ($result_count == 0) {
$data['page_title'] = 'No search results found!';
$this->view('header', $data);
$data['page_title'] = $page_title_prefix.'Browse "'. $decodedField . '"';
$this->view('header', $data);
$this->view('div_main');
$this->view('search_noresults');
$this->view('div_main_end');
Expand All @@ -79,8 +85,8 @@ function _remap($field, $params = array()) {
$data['endrow'] = $data['startrow'] + ($rows - 1);

// Set the page title to the record title
$data['page_title'] = 'Browsing '.$field.' terms';
$data['browse_url'] = $browse_url;
$data['page_title'] = $page_title_prefix.'Browse "'. $decodedField . '"';
$data['browse_url'] = $browse_url;
$data['field'] = $field;
$data['offset'] = $offset;

Expand All @@ -104,4 +110,4 @@ function _remap($field, $params = array()) {
$this->view('div_sidebar_end');
$this->view('footer');
}
}
}
10 changes: 8 additions & 2 deletions application/controllers/feedback.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ function Feedback() {
public function index() {
$data['recaptcha_key_public'] = $this->config->item('skylight_recaptcha_key_public');

$data['page_title'] = 'Feedback';
// Determine the page title and heading.
$page_title_prefix = $this->config->item('skylight_page_title_prefix');
if( !isset($page_title_prefix) ) {
$page_title_prefix = "";
}

$data['page_title'] = $page_title_prefix.'Feedback';

$this->view('header', $data);
$this->view('div_main');
Expand Down Expand Up @@ -58,4 +64,4 @@ function _check_captcha($input) {
}

}
}
}
14 changes: 11 additions & 3 deletions application/controllers/record.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,15 @@ function _remap($id, $params = array()) {
// Solr query business moved to solr_client library
$data = $this->solr_client->getRecord($id);

// Determine the page title and heading.
$page_title_prefix = $this->config->item('skylight_page_title_prefix');
if( !isset($page_title_prefix) ) {
$page_title_prefix = "";
}

// Check for a valid ID
if ($data['result_count'] == 0) {
$data['page_title'] = 'Invalid record identifier!';
$data['page_title'] = $page_title_prefix.'Record - Invalid Identifier';
$this->view('header', $data);
$this->view('div_main');
$this->view('record_invalid');
Expand Down Expand Up @@ -94,7 +100,9 @@ function _remap($id, $params = array()) {

$data['sharethis'] = $this->config->item('skylight_share_buttons');

$data['page_title'] = $data['solr'][$title][0];
//$data['page_title'] = $data['solr'][$title][0];
$data['page_title'] = $page_title_prefix . '"'.$data['solr'][$title][0].'"';
$data['record_title'] = $data['solr'][$title][0];
$data['title_field'] = $title;

$data['id'] = $id;
Expand Down Expand Up @@ -122,4 +130,4 @@ function _remap($id, $params = array()) {

$this->view('footer');
}
}
}
24 changes: 17 additions & 7 deletions application/controllers/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,25 @@ function _remap($query, $params = array()) {
if (($data['searchbox_query'] == '*') || ($data['searchbox_query'] == '*:*')) $data['searchbox_query'] = '';
$data['searchbox_filters'] = $saved_filters;


// Obtain the common page title prefix.
$page_title_prefix = $this->config->item('skylight_page_title_prefix');
if( !isset($page_title_prefix) ) {
$page_title_prefix = "";
}

if( urldecode($query) != "*:*" && urldecode($query) != "*" ) {
$data['page_title'] = $page_title_prefix.'Search results for "'.urldecode($query).'"';
$data['page_heading'] = 'Search results for "<span class=searched>'.urldecode($query).'</span>"';
} else {
$data['page_title'] = $page_title_prefix.'Search Results';
$data['page_heading'] = 'Search Results"';
}


// Check for zero results
$result_count = $data['rows'];
if ($result_count == 0) {
$data['page_title'] = 'No search results found!';
$this->view('header', $data);
$this->view('div_main');
$this->view('search_suggestions', $data);
Expand Down Expand Up @@ -140,11 +155,6 @@ function _remap($query, $params = array()) {
$data['author_field'] = 'dccreator';
}

// Set the page title to the record title
$data['page_title'] = 'Search results for "'.urldecode($query).'"';
$data['page_heading'] = 'Search results for "<span class=searched>'.urldecode($query).'</span>"';


//$data['title_field'] = $title;
$data['fielddisplay'] = $this->config->item("skylight_searchresult_display");
// TODO: get rid of this, it's bad
Expand All @@ -164,4 +174,4 @@ function _remap($query, $params = array()) {
}


}
}
2 changes: 1 addition & 1 deletion application/views/record.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
?>


<h1 class="itemtitle"><span class="icon <?php echo $type ?>"></span><?php echo $page_title ?></h1>
<h1 class="itemtitle"><span class="icon <?php echo $type ?>"></span><?php echo $record_title ?></h1>
<div class="tags">
<?php

Expand Down

0 comments on commit 0878f38

Please sign in to comment.