tailieunhanh - Tạo mạng xã hội với PHP - part 8

Tham khảo tài liệu 'tạo mạng xã hội với php - part 8', công nghệ thông tin, đồ họa - thiết kế - flash phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Planning and Developing the Core Framework @param String data if the tag value condition then extra tag is replaced with this value public function addAdditionalParsingData block tag condition extratag data this- apd block array tag array condition condition tag extratag data data We will want to get a list of all the template bits we need to process into the page processing is done by the template object . Get the template bits to be entered into the page return array the array of template tags and template file names public function getBits return this- bits We also need to get our array of additional parsing data for the template handler to process. public function getAdditionalParsingData return this- apd We often need to just access a specific loop block within our page this method makes this easy by searching for us using regular expressions and returning it. Gets a chunk of page content @param String the tag wrapping the block -- START tag -- block -- END tag -- return String the block of content public function getBlock tag echo tag preg_match -- START . tag . -- . -- END . tag . -- si this- content tor tor str_replace -- START . tag . -- tor 0 tor str_replace -- END . tag . -- tor return tor ------------------------------------ 52 ----------------------------------- Download from Chapter 2 Obviously we need to get the content from the page so we use the getContent method. public function getContent return this- content Finally when we are ready to output the content to the browser we do some final replacements. These are of template tags that we want to have in a template but may not always replace. One example is a registration form if the submission has errors we would replace the form fields with the user s submission attempt. If however the user is viewing the form for the first time they wouldn t want to see anything so we would either have to explicitly remove the template tags or instead prefix them with form_ and any leftovers are .