library/HTMLPurifier/AttrTransform/ImgRequired.php

Go to the documentation of this file.
00001 <?php
00002 
00003 // must be called POST validation
00004 
00011 class HTMLPurifier_AttrTransform_ImgRequired extends HTMLPurifier_AttrTransform
00012 {
00013     
00014     public function transform($attr, $config, $context) {
00015         
00016         $src = true;
00017         if (!isset($attr['src'])) {
00018             if ($config->get('Core', 'RemoveInvalidImg')) return $attr;
00019             $attr['src'] = $config->get('Attr', 'DefaultInvalidImage');
00020             $src = false;
00021         }
00022         
00023         if (!isset($attr['alt'])) {
00024             if ($src) {
00025                 $attr['alt'] = basename($attr['src']);
00026             } else {
00027                 $attr['alt'] = $config->get('Attr', 'DefaultInvalidImageAlt');
00028             }
00029         }
00030         
00031         return $attr;
00032         
00033     }
00034     
00035 }
00036 

Generated on Thu Jun 19 18:47:25 2008 for HTMLPurifier by  doxygen 1.5.3