charset = $charset; return $this; } public function getCharset(){ $charset = $this->charset; return is_null($charset) ? self::DEFAULT_CHARSET : $charset; } protected function setContentType($contentType){ $this->contentType = $contentType; return $this; } protected function callContentType(){ header('Content-Type: ' . $this->contentType); } public function display(){ echo $this->stringify(); return $this; } public function setDatas(array $datas){ $this->datas = $datas; return $this; } public function getDatas(){ if( !is_array($this->datas) ){ throw new \LogicException('Feed the ' . get_class($this) . ' with "setDatas" method before !'); } return $this->datas; } /** * Define common informations can be required by formats and set default value for unknow values * @param array $extraInfos array with know informations (there isn't merge !!!) * @return this */ public function setExtraInfos(array $extraInfos = array()){ foreach(array('name', 'uri') as $infoName){ if( !isset($extraInfos[$infoName]) ){ $extraInfos[$infoName] = ''; } } $this->extraInfos = $extraInfos; return $this; } /** * Return extra infos * @return array See "setExtraInfos" detail method to know what extra are disponibles */ public function getExtraInfos(){ if( is_null($this->extraInfos) ){ // No extra info ? $this->setExtraInfos(); // Define with default value } return $this->extraInfos; } /** * Sanitized html while leaving it functionnal. * The aim is to keep html as-is (with clickable hyperlinks) * while reducing annoying and potentially dangerous things. * Yes, I know sanitizing HTML 100% is an impossible task. * Maybe we'll switch to http://htmlpurifier.org/ * or http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/index.php */ public function sanitizeHtml($html) { $html = str_replace('