TAILIEUCHUNG - Practical Web 2.0 Applications with PHP phần 7

Chúng tôi sẽ thực hiện các hình thức (và tương ứng xử lý code) cho phép người dùng nhập vào nội dung này, và điều đó một cách chính xác các bộ lọc trình mã HTML để các cuộc tấn công dựa trên JavaScript không có thể xảy ra. Mẫu này cũng sẽ được sử dụng để chỉnh sửa bài viết hiện tại. • | Simpo PDF Merge and Split Unregistered Version - http CHAPTER 10 IMPLEMENTING WEB FEATURES 339 Additionally to ensure that no duplicate tags are inserted we retrieve all tags using getTags and then make them all lowercase using array_map . Finally each tag is inserted into the database. We could instead use hasTag to check whether the new tag already exists but this would result in one lookup query for each tag whereas doing it this way requires only one lookup query. The next function we implement is deleteTags which we use to remove one or more tags from a blog post as shown in Listing 10-5. Listing 10-5. Deleting One or More Blog Post Tags with deleteTagsO public function deleteTags tags if this- isSaved return if is_array tags tags array tags _tags array foreach tags as tag tag trim tag if strlen tag 0 _tags strtolower tag if count _tags 0 return where array post_id . this- getId this- _db- quoteInto lower tag in tags this- _db- delete blog_posts_tags where Just as when inserting tags we must clean up the tags that are passed in which can be either a single tag or an array of tags . Once this has been done we can use the Zend_Db s delete method to remove the matching rows. Finally we include the deleteAllTags method which takes no arguments and removes every tag associated with a single post as shown in Listing 10-6. This is primarily used in the preDelete method which will we update shortly. Listing 10-6. Deleting All of a Post s Tags public function deleteAllTags if this- isSaved return Simpo PDF Merge and Split Unregistered Version - http 340 CHAPTER 10 IMPLEMENTING WEB FEATURES this- _db- delete blog_posts_tags post_id . this- getId . other code As mentioned we must call this function in the preDelete method of DatabaseObject_ BlogPost which is called automatically prior to a blog post being deleted. This is shown in Listing 10-7. We do this so prior to a blog post being deleted the .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.