tailieunhanh - Practical Web 2.0 Applications with PHP phần 8
Giấy phép người dùng xem trước bài viết mới. Hệ thống quy trình làm việc đơn giản này sẽ cho phép người sử dụng Trong chương 2, chúng tôi thiết lập khả năng đăng nhập cho ứng dụng web của chúng tôi, có nghĩa là chúng ta có thể ghi lại khi xảy ra sự kiện khác nhau. | Simpo PDF Merge and Split Unregistered Version - http CHAPTER 11 A DYNAMIC IMAGE GALLERY 399 image not found response- setHttpResponseCode 404 return try fullpath image- createThumbnail w h catch Exception ex fullpath image- getFullPath info getImageSize fullpath response- setHeader content-type info mime response- setHeader content-length filesize fullpath echo file_get_contents fullpath Managing Blog Post Images Now that we have the ability to view uploaded images both at their original size and as thumbnails we can display the images on the blog post preview page. In this section we will modify the blog manager to display uploaded images thereby allowing the user to easily delete images from their blog posts. Additionally we will implement Ajax code using Prototype and Scriptaculous that will allow the user to change the order in which the images in a single post are displayed. Automatically Loading Blog Post Images Before we can display the images on the blog post preview page we must modify DatabaseObject_BlogPost to automatically load all associated images when the blog post record is loaded. To do this we will change the postLoad function to automatically load the images. Currently this function only loads the profile data for the blog post but we will add a call to load the images as shown in Listing 11-30. Additionally we must initialize the images array. Listing 11-30. Automatically Loading a Blog Post s Images When the Post Is Loaded php class DatabaseObject_BlogPost extends DatabaseObject public images array . other code Simpo PDF Merge and Split Unregistered Version - http 400 CHAPTER 11 A DYNAMIC IMAGE GALLERY protected function postLoad this- profile- setPostId this- getId this- profile- load options array post_id this- getId this- images DatabaseObject_BlogPostImage GetImages this- getDb options . other code The code in Listing 11-30 calls a method called GetImages in DatabaseObject_ BlogPostImage which
đang nạp các trang xem trước