Changeset 11924


Ignore:
Timestamp:
2006-06-16T12:10:04+12:00 (18 years ago)
Author:
mdewsnip
Message:

Lots of improvements to designer pages: now displays places the same as other browse pages, and PDFs are ignored.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cic-hcap/perllib/plugins/CICPlug.pm

    r11923 r11924  
    670670    $designer_sql_handle->execute() or die "Could not execute SQL statement.";
    671671
    672     # Prepare SQL statement for getting the Place images
    673     my $place_images_sql_statement = "SELECT FileName,Location FROM tblImages WHERE FileType=1 AND Entry_ID=?";
    674     my $place_images_sql_handle = $dbh->prepare($place_images_sql_statement);
    675     $place_images_sql_handle->{LongReadLen} = 65536;
     672    # Prepare SQL statement for getting the Place name
     673    my $place_name_sql_statement = "SELECT Current_name FROM tblPlace WHERE Entry_ID=?";
     674    my $place_name_sql_handle = $dbh->prepare($place_name_sql_statement);
     675
     676    # Prepare SQL statement for getting the Place institution
     677    my $place_institution_sql_statement = "SELECT Institution_Name FROM tblInstitution,tblPlace WHERE tblInstitution.Institution_ID=tblPlace.Institution_ID and tblPlace.Entry_ID=?";
     678    my $place_institution_sql_handle = $dbh->prepare($place_institution_sql_statement);
    676679
    677680    # Prepare SQL statement for getting the Place "date of construction"
     
    679682    my $place_construction_date_sql_handle = $dbh->prepare($place_construction_date_sql_statement);
    680683
    681     # Prepare SQL statement for getting the Place name
    682     my $place_name_sql_statement = "SELECT Current_name FROM tblPlace WHERE Entry_ID=?";
    683     my $place_name_sql_handle = $dbh->prepare($place_name_sql_statement);
     684    # Prepare SQL statement for getting the Place non-PDF images
     685    my $place_images_sql_statement = "SELECT Location FROM tblImages WHERE FileType=1 AND Location NOT LIKE '%.pdf' AND Entry_ID=?";
     686    my $place_images_sql_handle = $dbh->prepare($place_images_sql_statement);
     687    $place_images_sql_handle->{LongReadLen} = 65536;
    684688
    685689    # Get a list of all the designers, and the places they worked on
     
    716720    &new_metadata_entry($designer_doc_obj, "Designer_name", $designer_name);
    717721
    718     my $designer_places_image_html = "";
     722    my $designer_places_list_html = "";
    719723    foreach my $designer_place_id (@{$designer_name_to_place_ids_mapping{$designer_name}}) {
     724        # Get place name
     725        $place_name_sql_handle->execute($designer_place_id) or die "Could not execute SQL statement.";
     726        my $designer_place_name = $place_name_sql_handle->fetchrow();
     727
     728        # Get place institution name
     729        $place_institution_sql_handle->execute($designer_place_id) or die "Could not execute SQL statement.";
     730        my $designer_place_institution_name = $place_institution_sql_handle->fetchrow();
     731
    720732        # Get place date of construction
    721733        $place_construction_date_sql_handle->execute($designer_place_id) or die "Could not execute SQL statement.";
    722734        my $designer_place_construction_date_value = $place_construction_date_sql_handle->fetchrow() || "";
    723735
    724         # Get the first image for this place
    725         $place_images_sql_handle->execute($designer_place_id) or die "Could not execute SQL statement.";
    726         my $designer_place_image_match_hashref = $place_images_sql_handle->fetchrow_hashref();
    727         if (defined($designer_place_image_match_hashref)) {
    728         my $designer_place_image_location = $designer_place_image_match_hashref->{"Location"};
    729         $self->generate_place_image_variant($designer_doc_obj, $designer_place_image_location, "small");
    730 
    731         my $designer_place_image_name = $designer_place_image_match_hashref->{"FileName"};
    732         my $designer_place_image_small_file_href;
    733         if (defined($designer_place_image_name)) {
    734             my $designer_place_image_small_file_name = $designer_place_image_name . "-small.jpg";
    735             $designer_place_image_small_file_name =~ s/ /%20/g;
    736             $designer_place_image_small_file_href = "_httpcollection_/index/assoc/[assocfilepath]/$designer_place_image_small_file_name";
    737         }
    738         else {
    739             # Get the name of this place (since we don't have a filename)
    740             $place_name_sql_handle->execute($designer_place_id) or die "Could not execute SQL statement.";
    741             $designer_place_image_name = $place_name_sql_handle->fetchrow() || "";
    742             $designer_place_image_small_file_href = "_httpcollection_/images/no_image.jpg";
    743         }
    744         $designer_places_image_html .= "<tr><td valign=\"top\"><a href=\"_gwcgi_?a=d&d=p$designer_place_id\"><img src=\"$designer_place_image_small_file_href\"/></a></td><td valign=\"top\"><a href=\"_gwcgi_?a=d&d=p$designer_place_id\"><span class=\"cictext\">$designer_place_image_name</span></a><br /><b>Date of construction:</b> $designer_place_construction_date_value</td></tr>\n";
    745         }
    746     }
    747 
    748     &new_metadata_entry($designer_doc_obj, "DesignerPlacesImageHTML", "<table>" . $designer_places_image_html . "</table>");
     736        # Get the first non-PDF image for this place
     737        my $designer_place_image_small_file_href;
     738            $place_images_sql_handle->execute($designer_place_id) or die "Could not execute SQL statement.";
     739        my $designer_place_image_location = $place_images_sql_handle->fetchrow();
     740        if (defined($designer_place_image_location)) {
     741        $designer_place_image_small_file_href = $self->generate_place_image_variant($designer_doc_obj, $designer_place_image_location, "small");
     742        }
     743        else {
     744        # There is no non-PDF image for this place
     745        $designer_place_image_small_file_href = "_httpcollection_/images/no_image.jpg";
     746        }
     747
     748        $designer_places_list_html .= "<tr><td valign=\"top\"><a href=\"_gwcgi_?a=d&d=p$designer_place_id\"><img src=\"$designer_place_image_small_file_href\"/></a></td><td valign=\"top\"><a href=\"_gwcgi_?a=d&d=p$designer_place_id\">$designer_place_name</a>, $designer_place_institution_name<br /><b>Date of construction:</b> $designer_place_construction_date_value</td></tr>\n";
     749    }
     750
     751    &new_metadata_entry($designer_doc_obj, "DesignerPlacesListHTML", "<table>" . $designer_places_list_html . "</table>");
    749752
    750753    $designer_doc_obj->add_utf8_text($designer_doc_obj->get_top_section(), "Some dummy text.");
Note: See TracChangeset for help on using the changeset viewer.