Bug 5786 - Move AllowOnShelfHolds and OPACItemHolds system prefs to the Circulation...
[koha.git] / opac / opac-search.pl
index 2502768..cdf0fbb 100755 (executable)
@@ -28,47 +28,43 @@ use Modern::Perl;
 # to perform, etc.
 ## load Koha modules
 use C4::Context;
-
-my $searchengine = C4::Context->preference("SearchEngine");
-for ( $searchengine ) {
-    when ( /^Solr$/ ) {
-        warn "We use Solr";
-        require 'opac/search.pl';
-        exit;
-    }
-    when ( /^Zebra$/ ) {
-
-    }
-}
+use List::MoreUtils q/any/;
 
 use C4::Output;
 use C4::Auth qw(:DEFAULT get_session);
-use C4::Languages qw(getAllLanguages);
+use C4::Languages qw(getLanguages);
 use C4::Search;
+use C4::Search::History;
 use C4::Biblio;  # GetBiblioData
 use C4::Koha;
 use C4::Tags qw(get_tags);
 use C4::Branch; # GetBranches
 use C4::SocialData;
 use C4::Ratings;
+use C4::External::OverDrive;
+use C4::Members;
+use C4::Reserves;
 
 use POSIX qw(ceil floor strftime);
 use URI::Escape;
-use Storable qw(thaw freeze);
+use JSON qw/decode_json encode_json/;
 use Business::ISBN;
 
 my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold");
 # create a new CGI object
 # FIXME: no_undef_params needs to be tested
-use CGI qw( -no_undef_params -utf8 );
+use CGI qw('-no_undef_params' -utf8);
 my $cgi = new CGI;
 
 my $branch_group_limit = $cgi->param("branch_group_limit");
 if ( $branch_group_limit ) {
-    if ( $branch_group_limit =~ /^multibranchlimit/ ) {
+    if ( $branch_group_limit =~ /^multibranchlimit-/ ) {
+        # For search groups we are going to convert this branch_group_limit CGI
+        # parameter into a multibranchlimit CGI parameter for the purposes of
+        # actually performing the query
         $cgi->param(
             -name => 'multibranchlimit',
-            -values => [ ( split( 'multibranchlimit-', $branch_group_limit ) )[1] ]
+            -values => substr($branch_group_limit, 17)
         );
     } else {
         $cgi->append(
@@ -86,7 +82,6 @@ BEGIN {
 }
 
 my ($template,$borrowernumber,$cookie);
-my $lang = C4::Templates::getlanguage($cgi, 'opac');
 # decide which template to use
 my $template_name;
 my $template_type = 'basic';
@@ -96,16 +91,16 @@ my @params = $cgi->param("limit");
 my $format = $cgi->param("format") || '';
 my $build_grouped_results = C4::Context->preference('OPACGroupResults');
 if ($format =~ /(rss|atom|opensearchdescription)/) {
-    $template_name = 'opac-opensearch.tmpl';
+    $template_name = 'opac-opensearch.tt';
 }
 elsif (@params && $build_grouped_results) {
-    $template_name = 'opac-results-grouped.tmpl';
+    $template_name = 'opac-results-grouped.tt';
 }
 elsif ((@params>=1) || ($cgi->param("q")) || ($cgi->param('multibranchlimit')) || ($cgi->param('limit-yr')) ) {
-    $template_name = 'opac-results.tmpl';
+    $template_name = 'opac-results.tt';
 }
 else {
-    $template_name = 'opac-advsearch.tmpl';
+    $template_name = 'opac-advsearch.tt';
     $template_type = 'advsearch';
 }
 # load the template
@@ -116,7 +111,10 @@ else {
     authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
     }
 );
-if ($template_name eq 'opac-results.tmpl') {
+
+my $lang = C4::Languages::getlanguage($cgi);
+
+if ($template_name eq 'opac-results.tt') {
    $template->param('COinSinOPACResults' => C4::Context->preference('COinSinOPACResults'));
 }
 
@@ -140,7 +138,7 @@ if (C4::Context->preference("marcflavour") eq "UNIMARC" ) {
 elsif (C4::Context->preference("marcflavour") eq "MARC21" ) {
     $template->param('usmarc' => 1);
 }
-$template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') );
+
 $template->param( 'OPACNoResultsFound' => C4::Context->preference('OPACNoResultsFound') );
 
 $template->param(
@@ -190,11 +188,11 @@ if (C4::Context->preference('TagsEnabled')) {
 
 my $branches = GetBranches();   # used later in *getRecords, probably should be internalized by those functions after caching in C4::Branch is established
 $template->param(
-    searchdomainloop => GetBranchCategories(undef,'searchdomain'),
+    searchdomainloop => GetBranchCategories('searchdomain'),
 );
 
 # load the language limits (for search)
-my $languages_limit_loop = getAllLanguages($lang);
+my $languages_limit_loop = getLanguages($lang, 1);
 $template->param(search_languages_loop => $languages_limit_loop,);
 
 # load the Type stuff
@@ -206,11 +204,27 @@ my $cnt;
 my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes") || "itemtypes";
 my @advanced_search_types = split(/\|/, $advanced_search_types);
 
+my $hidingrules = {};
+my $yaml = C4::Context->preference('OpacHiddenItems');
+if ( $yaml =~ /\S/ ) {
+    $yaml = "$yaml\n\n"; # YAML expects trailing newline. Surplus does not hurt.
+    eval {
+        $hidingrules = YAML::Load($yaml);
+    };
+    if ($@) {
+        warn "Unable to parse OpacHiddenItems syspref : $@";
+    }
+}
+
 foreach my $advanced_srch_type (@advanced_search_types) {
+    $advanced_srch_type =~ s/^\s*//;
+    $advanced_srch_type =~ s/\s*$//;
    if ($advanced_srch_type eq 'itemtypes') {
    # itemtype is a special case, since it's not defined in authorized values
         my @itypesloop;
        foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) {
+            next if $hidingrules->{itype} && any { $_ eq $thisitemtype } @{$hidingrules->{itype}};
+            next if $hidingrules->{itemtype} && any { $_ eq $thisitemtype } @{$hidingrules->{itemtype}};
            my %row =(  number=>$cnt++,
                ccl => "$itype_or_itemtype,phr",
                 code => $thisitemtype,
@@ -227,6 +241,9 @@ foreach my $advanced_srch_type (@advanced_search_types) {
        my $advsearchtypes = GetAuthorisedValues($advanced_srch_type, '', 'opac');
         my @authvalueloop;
        for my $thisitemtype (@$advsearchtypes) {
+            my $hiding_key = lc $thisitemtype->{category};
+            $hiding_key = "location" if $hiding_key eq 'loc';
+            next if $hidingrules->{$hiding_key} && any { $_ eq $thisitemtype->{authorised_value} } @{$hidingrules->{$hiding_key}};
                my %row =(
                                number=>$cnt++,
                                ccl => $advanced_srch_type,
@@ -243,10 +260,6 @@ foreach my $advanced_srch_type (@advanced_search_types) {
 }
 $template->param(advancedsearchesloop => \@advancedsearchesloop);
 
-# # load the itypes (Called item types in the template -- just authorized values for searching)
-# my ($itypecount,@itype_loop) = GetCcodes();
-# $template->param(itypeloop=>\@itype_loop,);
-
 # The following should only be loaded if we're bringing up the advanced search template
 if ( $template_type && $template_type eq 'advsearch' ) {
     # load the servers (used for searching -- to do federated searching, etc.)
@@ -295,9 +308,17 @@ if ( $template_type && $template_type eq 'advsearch' ) {
         }
 
     }
-    $template->param(uc(    C4::Context->preference("marcflavour")) => 1,   # we already did this for UNIMARC
-                            advsearch => 1,
-                            search_boxes_loop => \@search_boxes_array);
+
+    my @advsearch_limits = split /,/, C4::Context->preference('OpacAdvSearchOptions');
+    my @advsearch_more_limits = split /,/,
+      C4::Context->preference('OpacAdvSearchMoreOptions');
+    $template->param(
+        uc( C4::Context->preference("marcflavour") ) => 1,    # we already did this for UNIMARC
+        advsearch         => 1,
+        search_boxes_loop => \@search_boxes_array,
+        OpacAdvSearchOptions     => \@advsearch_limits,
+        OpacAdvSearchMoreOptions => \@advsearch_more_limits,
+    );
 
     # use the global setting by default
     if ( C4::Context->preference("expandedSearchOption") == 1 ) {
@@ -330,13 +351,14 @@ $tag = $params->{tag} if $params->{tag};
 
 
 # String with params with the search criteria for the paging in opac-detail
+# param value is URI encoded and params separator is HTML encode (&)
 my $pasarParams = '';
 my $j = 0;
 for (keys %$params) {
     my @pasarParam = $cgi->param($_);
     for my $paramValue(@pasarParam) {
         $pasarParams .= '&' if ($j > 0);
-        $pasarParams .= $_ . '=' . $paramValue;
+        $pasarParams .= $_ . '=' . uri_escape_utf8($paramValue);
         $j++;
     }
 }
@@ -357,7 +379,7 @@ my @allowed_sortby = qw /acqdate_asc acqdate_dsc author_az author_za call_number
 @sort_by = $cgi->param('sort_by');
 $sort_by[0] = $default_sort_by if !$sort_by[0] && defined($default_sort_by);
 foreach my $sort (@sort_by) {
-    if ( $sort ~~ @allowed_sortby ) {
+    if ( grep { /^$sort$/ } @allowed_sortby ) {
         $template->param($sort => 1);
     }
 }
@@ -401,9 +423,14 @@ if ($operands[0] && !$operands[1]) {
 # limits are use to limit to results to a pre-defined category such as branch or language
 my @limits = $cgi->param('limit');
 @limits = map { uri_unescape($_) } @limits;
+my @nolimits = $cgi->param('nolimit');
+@nolimits = map { uri_unescape($_) } @nolimits;
+my %is_nolimit = map { $_ => 1 } @nolimits;
+@limits = grep { not $is_nolimit{$_} } @limits;
 
 if($params->{'multibranchlimit'}) {
-    push @limits, '('.join( " or ", map { "branch: $_ " } @{ GetBranchesInCategory( $params->{'multibranchlimit'} ) } ).')';
+    my $multibranch = '('.join( " or ", map { "branch: $_ " } @{ GetBranchesInCategory( $params->{'multibranchlimit'} ) } ).')';
+    push @limits, $multibranch if ($multibranch ne  '()');
 }
 
 my $available;
@@ -452,7 +479,7 @@ sub _input_cgi_parse {
     for my $this_cgi ( split('&',shift) ) {
         next unless $this_cgi;
         $this_cgi =~ /(.*?)=(.*)/;
-        push @elements, { input_name => $1, input_value => $2 };
+        push @elements, { input_name => $1, input_value => Encode::decode_utf8( uri_unescape($2) ) };
     }
     return @elements;
 }
@@ -477,11 +504,20 @@ if (C4::Context->preference('OpacSuppression')) {
         my $IPAddress = $ENV{'REMOTE_ADDR'};
         my $IPRange = C4::Context->preference('OpacSuppressionByIPRange');
         if ($IPAddress !~ /^$IPRange/)  {
-            $query = "($query) not Suppress=1";
+            if ( $query_type eq 'pqf' ) {
+                $query = '@not '.$query.' @attr 1=9011 1';
+            } else {
+                $query = "($query) not Suppress=1";
+            }
         }
     }
     else {
-        $query = "($query) not Suppress=1";
+        if ( $query_type eq 'pqf' ) {
+            #$query = "($query) && -(suppress:1)"; #QP syntax
+            $query = '@not '.$query.' @attr 1=9011 1'; #PQF syntax
+        } else {
+            $query = "($query) not Suppress=1";
+        }
     }
 }
 
@@ -500,7 +536,7 @@ if ($tag) {
     my $taglist = get_tags({term=>$tag, approved=>1});
     $results_hashref->{biblioserver}->{hits} = scalar (@$taglist);
     my @biblist  = (map {GetBiblioData($_->{biblionumber})} @$taglist);
-    my @marclist = (map {$_->{marc}} @biblist );
+    my @marclist = (map { (C4::Context->config('zebra_bib_index_mode') eq 'dom')? $_->{marcxml}: $_->{marc}; } @biblist);
     $DEBUG and printf STDERR "taglist (%s biblionumber)\nmarclist (%s records)\n", scalar(@$taglist), scalar(@marclist);
     $results_hashref->{biblioserver}->{RECORDS} = \@marclist;
     # FIXME: tag search and standard search should work together, not exclusively
@@ -510,10 +546,10 @@ if ($tag) {
         ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
     };
 } else {
-    $pasarParams .= '&query=' . $query;
-    $pasarParams .= '&count=' . $results_per_page;
-    $pasarParams .= '&simple_query=' . $simple_query;
-    $pasarParams .= '&query_type=' . $query_type if ($query_type);
+    $pasarParams .= '&query=' . uri_escape_utf8($query);
+    $pasarParams .= '&count=' . uri_escape_utf8($results_per_page);
+    $pasarParams .= '&simple_query=' . uri_escape_utf8($simple_query);
+    $pasarParams .= '&query_type=' . uri_escape_utf8($query_type) if ($query_type);
     eval {
         ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$itemtypes,$query_type,$scan,1);
     };
@@ -533,8 +569,11 @@ if ($@ || $error) {
     exit;
 }
 
+my $borrower = $borrowernumber ? GetMember( borrowernumber => $borrowernumber ) : undef;
+
 # At this point, each server has given us a result set
 # now we build that set for template display
+my %allow_onshelf_holds;
 my @sup_results_array;
 for (my $i=0;$i<@servers;$i++) {
     my $server = $servers[$i];
@@ -549,59 +588,70 @@ for (my $i=0;$i<@servers;$i++) {
                 # we need to set the offset parameter of searchResults to 0
                 my @group_results = searchResults( 'opac', $query_desc, $group->{'group_count'},$results_per_page, 0, $scan,
                                                    $group->{"RECORDS"});
+                if ($borrower) {
+                    $_->{holdable} =
+                        IsAvailableForItemLevelRequest($_, $borrower) &&
+                        OPACItemHoldsAllowed($_, $borrower)
+                      foreach @group_results;
+                }
                 push @newresults, { group_label => $group->{'group_label'}, GROUP_RESULTS => \@group_results };
             }
         } else {
             @newresults = searchResults('opac', $query_desc, $hits, $results_per_page, $offset, $scan,
                                         $results_hashref->{$server}->{"RECORDS"});
-        }
-
-        # must define a value for size if not present in DB
-        # in order to avoid problems generated by the default size value in TT
-        foreach my $line (@newresults) {
-            if ( not exists $line->{'size'} ) { $line->{'size'} = "" }
-            # while we're checking each line, see if item is in the cart
-            if ( grep {$_ eq $line->{'biblionumber'}} @cart_list) {
-                $line->{'incart'} = 1;
+            if ($borrower) {
+                $_->{holdable} =
+                    IsAvailableForItemLevelRequest($_, $borrower) &&
+                    OPACItemHoldsAllowed($_, $borrower)
+                  foreach @newresults;
             }
         }
+        $hits = 0 unless @newresults;
 
+        foreach my $res (@newresults) {
 
-        my $tag_quantity;
-        if (C4::Context->preference('TagsEnabled') and
-            $tag_quantity = C4::Context->preference('TagsShowOnList')) {
-            foreach (@newresults) {
-                my $bibnum = $_->{biblionumber} or next;
-                $_->{itemsissued} = CountItemsIssued( $bibnum );
-                $_ ->{'TagLoop'} = get_tags({biblionumber=>$bibnum, approved=>1, 'sort'=>'-weight',
-                                        limit=>$tag_quantity });
+            # must define a value for size if not present in DB
+            # in order to avoid problems generated by the default size value in TT
+            if ( not exists $res->{'size'} ) { $res->{'size'} = "" }
+            # while we're checking each line, see if item is in the cart
+            if ( grep {$_ eq $res->{'biblionumber'}} @cart_list) {
+                $res->{'incart'} = 1;
             }
-        }
 
-        if (C4::Context->preference('COinSinOPACResults')) {
-            foreach (@newresults) {
-                my $record = GetMarcBiblio($_->{'biblionumber'});
-                $_->{coins} = GetCOinSBiblio($record);
-                if ( C4::Context->preference( "Babeltheque" ) and $_->{normalized_isbn} ) {
-                    my $isbn = Business::ISBN->new( $_->{normalized_isbn} );
-                    next if not $isbn;
+            if (C4::Context->preference('COinSinOPACResults')) {
+                my $record = GetMarcBiblio($res->{'biblionumber'});
+                $res->{coins} = GetCOinSBiblio($record);
+            }
+            if ( C4::Context->preference( "Babeltheque" ) and $res->{normalized_isbn} ) {
+                if( my $isbn = Business::ISBN->new( $res->{normalized_isbn} ) ) {
                     $isbn = $isbn->as_isbn13->as_string;
                     $isbn =~ s/-//g;
                     my $social_datas = C4::SocialData::get_data( $isbn );
-                    next if not $social_datas;
-                    for my $key ( keys %$social_datas ) {
-                        $_->{$key} = $$social_datas{$key};
-                        if ( $key eq 'score_avg' ){
-                            $_->{score_int} = sprintf("%.0f", $$social_datas{score_avg} );
+                    if ( $social_datas ) {
+                        for my $key ( keys %$social_datas ) {
+                            $res->{$key} = $$social_datas{$key};
+                            if ( $key eq 'score_avg' ){
+                                $res->{score_int} = sprintf("%.0f", $$social_datas{score_avg} );
+                            }
                         }
                     }
                 }
             }
-        }
 
+            if (C4::Context->preference('TagsEnabled') and
+                C4::Context->preference('TagsShowOnList')) {
+                if ( my $bibnum = $res->{biblionumber} ) {
+                    $res->{itemsissued} = CountItemsIssued( $bibnum );
+                    $res->{'TagLoop'} = get_tags({
+                        biblionumber => $bibnum,
+                        approved => 1,
+                        sort => '-weight',
+                        limit => C4::Context->preference('TagsShowOnList')
+                    });
+                }
+            }
 
-        if ( C4::Context->preference('OpacStarRatings') eq 'all' ) {
-            foreach my $res (@newresults) {
+            if ( C4::Context->preference('OpacStarRatings') eq 'all' ) {
                 my $rating = GetRating( $res->{'biblionumber'}, $borrowernumber );
                 $res->{'rating_value'}  = $rating->{'rating_value'};
                 $res->{'rating_total'}  = $rating->{'rating_total'};
@@ -611,60 +661,41 @@ for (my $i=0;$i<@servers;$i++) {
         }
 
         if ($results_hashref->{$server}->{"hits"}){
-            $total = $total + $results_hashref->{$server}->{"hits"};
+            $total = $total + $hits;
         }
 
         # Opac search history
-        my $newsearchcookie;
         if (C4::Context->preference('EnableOpacSearchHistory')) {
-            my @recentSearches;
-
-            # Getting the (maybe) already sent cookie
-            my $searchcookie = $cgi->cookie('KohaOpacRecentSearches');
-            if ($searchcookie){
-                $searchcookie = uri_unescape($searchcookie);
-                if (thaw($searchcookie)) {
-                    @recentSearches = @{thaw($searchcookie)};
-                }
-            }
-
-            # Adding the new search if needed
-            my $path_info = $cgi->url(-path_info=>1);
-            my $query_cgi_history = $cgi->url(-query=>1);
-            $query_cgi_history =~ s/^$path_info\?//;
-            $query_cgi_history =~ s/;/&/g;
-            my $query_desc_history = "$query_desc, $limit_desc";
-
-            if (!$borrowernumber || $borrowernumber eq '') {
-                # To a cookie (the user is not logged in)
-                if (!$offset) {
-                    push @recentSearches, {
-                                "query_desc" => $query_desc_history || "unknown",
-                                "query_cgi"  => $query_cgi_history  || "unknown",
-                                "time"       => time(),
-                                "total"      => $total
-                              };
-                    $template->param(ShowOpacRecentSearchLink => 1);
-                }
-
-                shift @recentSearches if (@recentSearches > 15);
-                # Pushing the cookie back
-                $newsearchcookie = $cgi->cookie(
-                            -name => 'KohaOpacRecentSearches',
-                            # We uri_escape the whole freezed structure so we're sure we won't have any encoding problems
-                            -value =>freeze(\@recentSearches),
-                            -expires => ''
-                );
-                $cookie = [$cookie, $newsearchcookie];
-            }
-            else {
-                # To the session (the user is logged in)
-                if (!$offset) {
-                    AddSearchHistory($borrowernumber, $cgi->cookie("CGISESSID"), $query_desc_history, $query_cgi_history, $total);
-                    $template->param(ShowOpacRecentSearchLink => 1);
+            unless ( $offset ) {
+                my $path_info = $cgi->url(-path_info=>1);
+                my $query_cgi_history = $cgi->url(-query=>1);
+                $query_cgi_history =~ s/^$path_info\?//;
+                $query_cgi_history =~ s/;/&/g;
+                my $query_desc_history = join ", ", grep { defined $_ } $query_desc, $limit_desc;
+
+                unless ( $borrowernumber ) {
+                    my $new_searches = C4::Search::History::add_to_session({
+                            cgi => $cgi,
+                            query_desc => $query_desc_history,
+                            query_cgi => $query_cgi_history,
+                            total => $total,
+                            type => "biblio",
+                    });
+                } else {
+                    # To the session (the user is logged in)
+                    C4::Search::History::add({
+                        userid => $borrowernumber,
+                        sessionid => $cgi->cookie("CGISESSID"),
+                        query_desc => $query_desc_history,
+                        query_cgi => $query_cgi_history,
+                        total => $total,
+                        type => "biblio",
+                    });
                 }
             }
+            $template->param( EnableOpacSearchHistory => 1 );
         }
+
         ## If there's just one result, redirect to the detail page
         if ($total == 1 && $format ne 'rss2'
         && $format ne 'opensearchdescription' && $format ne 'atom') {
@@ -685,12 +716,12 @@ for (my $i=0;$i<@servers;$i++) {
                 my $j = 0;
                 foreach (@newresults) {
                     my $bibnum = ($_->{biblionumber})?$_->{biblionumber}:0;
-                    $pasarParams .= $bibnum . ',';
+                    $pasarParams .= uri_escape_utf8($bibnum) . ',';
                     $j++;
                     last if ($j == $results_per_page);
                 }
                 chop $pasarParams if ($pasarParams =~ /,$/);
-                $pasarParams .= '&amp;total=' . int($total) if ($pasarParams !~ /total=(?:[0-9]+)?/);
+                $pasarParams .= '&amp;total=' . uri_escape_utf8( int($total) ) if ($pasarParams !~ /total=(?:[0-9]+)?/);
                 if ($pasarParams) {
                     my $session = get_session($cgi->cookie("CGISESSID"));
                     $session->param('busc' => $pasarParams);
@@ -858,6 +889,15 @@ for (my $i=0;$i<@servers;$i++) {
 } #/end of the for loop
 #$template->param(FEDERATED_RESULTS => \@results_array);
 
+for my $facet ( @$facets ) {
+    for my $entry ( @{ $facet->{facets} } ) {
+        my $index = $entry->{type_link_value};
+        my $value = $entry->{facet_link_value};
+        $entry->{active} = grep { $_->{input_value} eq qq{$index:$value} } @limit_inputs;
+    }
+}
+
+
 $template->param(
             #classlist => $classlist,
             total => $total,
@@ -897,5 +937,10 @@ $template->{VARS}->{IDreamBooksReviews} = C4::Context->preference('IDreamBooksRe
 $template->{VARS}->{IDreamBooksReadometer} = C4::Context->preference('IDreamBooksReadometer');
 $template->{VARS}->{IDreamBooksResults} = C4::Context->preference('IDreamBooksResults');
 
+if ($offset == 0 && IsOverDriveEnabled()) {
+    $template->param(OverDriveEnabled => 1);
+    $template->param(OverDriveLibraryID => C4::Context->preference('OverDriveLibraryID'));
+}
+
     $template->param( borrowernumber    => $borrowernumber);
 output_with_http_headers $cgi, $cookie, $template->output, $content_type;