Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your PHP code will allow you to generate reviews for a variety of movies using the same code. For example: Rancid Tomatoes The Princess Bride

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Your PHP code will allow you to generate reviews for a variety of movies using the same code. For example: Rancid Tomatoes The Princess Bride (1987) GENERAL OVERVIEW 95% FRESH (17 reviews total) "One of Reiner's most entertaining films, effective as a swashbuckling epic, romantic fable, and satire of these genres." "One of the Top films of the 1980s, if not of all time. A treasure of a film that you'll want to watch again and again." PRINCESS BRIDE Emanuel Levy emanuellevy.com Clint Morris Moviehole * "Based on William Goldman's fairy tale that challenges and affirms the conventions of a genre that may not be flexible enough to support such horseplay." "An effective comedy, an interesting bedtime tale, and one of the greatest date rentals of all time." Brad Laidman Film Threat Variety Staff Variety "The lesson it most effectively demonstrates is that cinema has the power to turn you into a kid again. As we wish." "Rob Reiner's friendly 1987 fairy-tale adventure delicately mines the irony inherent in its make-believe without ever undermining the effectiveness of the fantasy." Phil Villarreal Arizona Daily Star STARRING Cary Elwes, Robin Wright, Andre the Giant, Mandy Patinkin DIRECTOR Rob Reiner PRODUCER Arnold Scheinman, Rob Reiner SCREENWRITER William Goldman RATING PG Jonathan Rosenbaum Chicago Reader 5 "My name is Marty Stepp. You killed my father. Prepare to die." Marty Stepp Step by Step Publishing RELEASE DATE September 25, 1987 (USA) RUNTIME 98 min SYNOPSIS Director Rob Reiner breathes vividly colored cinematic ife into William Goldman's THE PRINCESS BRDE, effectively evoking the wondrous, wide-eyed spirt of the witty 1973 novel RELEASE COMPANY 20th Century Fox W3C XHTML 1.1 (1-7) of 17 W3C css Turn in the following files: movie.php (code to produce review pages for movies) movie.css (the style sheet for your pages; does not need to be modified from HW2 version) Your pages must match the appearance specified in this document. It would be difficult to produce a pixel-perfect representation of the page that matches the image shown here, and we do not expect you to do so. But your page should follow all of the styles specified in this document and should match the overall look, layout, and behavior of the page shown here as closely as possible. You should base your movie.php on the tmnt.html you wrote in HW2. You can also reuse your style sheet, movie.css. The modifications you need to make to your HTML code are to cause it to read the movie information using PHP so that the same file can produce different movie review pages. Appearance Details: The overall page has the same appearance as it did in Homework 2. The difference is that the page might show reviews and information for a film other than TMNT. The page's title should reflect the movie; for example, when showing The Princess Bride, the page title should be The Princess Bride - Rancid Tomatoes. The page uses the same images as HW2 with the same file/path names, with two minor changes. The tmnt.html page showed a large rottenbig.png icon next to its 32% overall rating. But in this version, some films have high overall ratings. Any film whose overall rating is 60% or above should instead show the new image freshbig.png, shown at right. Also, the generaloverview.png FRESH image has moved, for reasons we will describe in the next section. As before, you should link to all images using their full absolute URLs, not relative ones. The general overview images are the one exception; since these now reside in the folder with the movie's information, you should link to these using a relative path such as "tmnt2/generaloverview.png". Dynamic Page Content: Your movie.php page will show reviews of different movies based upon a query parameter that is passed from the browser to the page in its URL. The browser will request your page with a URL such as the following: http:///3/movie.php?film=princessbride Your PHP code can store this parameter's into a variable using code such as the following: $movie = $_REQUEST["film" ); You may assume that the browser has properly supplied this parameter and has given it a valid value. You do not have to handle the case of a missing or empty film parameter, a value that contains bad characters, a value of a movie that is not found, etc. Based upon the film requested by the browser, you are to display a review of that film. Each film is stored in a directory whose name is the same as the film parameter. For example, the film princessbride stores its files in a folder named whose name is the same as the film parameter. For example, the film princessbride stores its files in a folder named princessbride/. The files associated with each movie are the following: info.txt, a file with exactly four lines of general information about the film: its title, year, overall rating, and number of reviews. Example: The Princess Bride 1987 95 117 generaloverview.txt, a file with information to be placed in the General Overview section of your page. Each line contains one item of information, with its title and value separated by a colon. The number of lines in the file varies from movie to movie. Example: STARRING:Cary Elwes, Robin Wright, Andre the Giant, Mandy Patinkin DIRECTOR:Rob Reiner PRODUCER:Arnold Scheinman, Rob Reiner SCREENWRITER:William Goldman RATING: PG RELEASE DATE: September 25, 1987 (USA) RUNTIME:98 min SYNOPSIS:Director Rob Reiner breathes vividly colored cinematic life into RELEASE COMPANY: 20th Century Fox GENERAL OVERVIEW generaloverview.png, an image to display at the top of the General Overview section. This is the movie poster for the film, such as the one shown at right. reviewl.txt, review2.txt, ..., files containing information for each review of the film. Each review file contains exactly four lines: The review, a fresh/rotten rating, the reviewer's name, and the publication. Example reviewl.txt: PRINCESS BRIDE One of Reiner's most entertaining films, effective as a swashbuckling... FRESH Emanuel Levy emanuellevy.com You map assume that all of the above files exist and are valid for the films your page is displaying. Part of your task is to successfully open these files, read the information from them, and display that information on the page. For example, if your page is requested as movie.php?film=princessbride, you should open princessbride/info.txt to read the film's title/year/etc. and display that in the headings and other text on the page. You would open the file princessbride/generaloverview.txt and display its contents in the General Overview section on the right side of the page. You would look for all review text files in the princessbride/ folder and would display each of them in the reviews area of the page. Different movies have different numbers of reviews. You should show the first half of the reviews in the left column on the page, and the rest on the right. If a given movie has an odd number of reviews, the right column should receive the extra review. For example, Princess Bride has 7 reviews, so the first three go into the left column and the last four into the right column. You do not have to worry about the possibility that the general overview section and the reviews sections will be wildly different in height; this would potentially upset the appearance of the page, but your page does not need to handle this. The image for each review are affected by the contents of the corresponding review text file. If the critic gave the film a FRESH rating, you should display an icon of fresh.gif in the review. If the critic gave the film a ROTTEN rating, you should display an icon of rotten.gif in the review. Several other various pieces of text on the page is now related to the contents of these input files. For example, the display of the number of reviews shown, the number of total reviews, and the large red rating text all adjust based on the film's input files. The number of total reviews comes from the info.txt file, and the number of reviews shown comes from the count of the number of review text files. Fortunately, you don't need to create and type all these text content for input files. You can get them from here (input files for tmnt, tmnt2, mortalkombat, and princessbride). Here is the screen shot of the outputs of these films for reference. Rancid Tomatoes Rancid Tomatoes The Princess Bride (1987) TMNT (2007) GENERAL OVERVIEW GENERAL OVERVIEW 2. 95%. Rotten 32070 views DB PRINCESS BRIDE -- TMNT " Tenham HA anal air D Barryallere detaly Show We Rand Tomatoes Mortal Kombat (1995) GENERAL OVERVIEW * 24%, ROTTEN MORTAL KOMBAT Ranced Tomatoes Teenage Mutant Ninja Turtles II: The Secret of the Ooze (1991) * 36%w.mm ROTTEN GENERAL OVERVIEW TEBIMEMUDIANT UNTUR ku What carattere Se M there (click each screen shot for a full-resolution view) Development Strategy and Hints: : PHP code is difficult to debug if you have lots of errors on your page. It is wise to write this program incrementally, adding small pieces of code to a known working page, and not advancing until you have tested and debugged the new code. Rather than trying to generalize all of your page at once, focus on incorporating a particular aspect or input file. Once this is successful, move on to the next. We suggest that get your page to display a single film (such as princessbride or tmnt2) first, then generalize it for other films. None of your code should refer to specific names of films such as princessbride. Since this program uses PHP code, you will need to upload your files to AWS to test your work (unless you install Apache/PHP on your own local machine!). Changes you make to your files will not be shown in the browser until you re-upload the file and refresh. The following PHP functions may be helpful to you in implementing this program: count - returns the number of elements in an array explode - breaks apart a string into an array of smaller strings based on a delimiter file - reads the lines of a file and returns them as an array glob - given a file path or wildcard such as foo/bar*.jpg, returns an array of matching file names list - unpacks an array into a set of variables; useful for dealing with fixed-size arrays of data trim - removes whitespace at the start/end of a string (gets rid of stray spaces in output) To make your code efficient and clear, you might want to avoid redundancy. One possible source redundancy is between different movies. You should not have code that depends on particular movies or that uses lots of if/else statements to figure out which movie to display; the same code should be able to display any movie. Use loops, functions, variables, if/else factoring, etc. to ensure that your code is not redundant. You should also reduce the number of large complex chunks of PHP code that are injected into the middle of your HTML code. When possible, try to replace such chunks with functions that are called in the HTML and declared at the bottom of your file. Also, you should minimize the use of print and echo statements. As much as possible you should insert dynamic content into the page using PHP expression blocks as taught in class. Here is a bad example that print HTML tags into the page such as the following: print "

I am adding content to the page!

"; # bad

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

4. Explain the characteristics of successful mentoring programs.

Answered: 1 week ago

Question

What is a verb?

Answered: 1 week ago