<?php
/**
 * Update content Type
 *
 * @param string $type content type
 * @param string $encoding
 * @name updateContentTypeFilter
 */
class My_PHPTAL_Filter_UpdateContentType implements PHPTAL_Filter {
         protected 
$contentType '';
         protected 
$encoding '';

         
/**
          * Constructor
          *
          * @name __construct
          * @access public
          * @param  $type string
          */
         
public function __construct($type$encoding) {
              
$this->contentType $type;
              
$this->encoding $encoding;
         } 
// end __construct();

         /**
          * Method filter
          * This method
          *
          * @access public
          * @name filter
          * @param  $source
          * @return $source
          */
         
public function filter($source) {
              
$source preg_replace ('@(<meta[^>]+"content-type"[^>]+content=")([^;]+)(;\s+?charset=)([^"]+)("[^"]+>)@i'"\\1{$this->contentType}\\3{$this->encoding}\\5"$source1);
              return 
$source;
         }
         } 
// end class updateContentTypeFilter ;
?>