/ Published in: Other
Expand |
Embed | Plain Text
app/controllers/components/message.php <?php class MessageComponent extends Object { var $controller = null; function startup(& $controller) { $this->controller =& $controller; } function errormsg($message=null, $url=null) { if(!$url){ $url = "javascript:history.Back()"; } // $this->controller->Brita->testbrita($controller); $message = $this->controller->brita->purify( $message ); $this->controller->set('message', $message); $this->controller->set('url', $url); //$this->controller->render('errormsg','messages'); $this->controller->render(null, null, VIEWS.'messages'.DS.'errormsg.ctp'); } } ?> ---------------------------------------- app/controllers/test_controller.php <?php class TestsController extends AppController { var $uses = array(); var $autoRender = false; var $components = array('Test2Action','Message','Brita'); function index() { // コンポーネント+Britaよりエラーコントローラのビューを使ったエラーページを作成。 $this->Message->errormsg('test test あああああ', ''); } ?> ---------------------------------------- app/controllers/components/brita.php ※HTML Purifierとしてダウンロード http://htmlpurifier.org/ http://bakery.cakephp.org/articles/view/brita-component-with-html-purifier <?php //cake's version of a require_once() call //vendor('htmlpurifier'.DS.'library'.DS.'HTMLPurifier.auto'); //use this with the 1.1 core App::import('Vendor','HTMLPurifier' ,array('file'=>'htmlpurifier'.DS.'library'.DS.'HTMLPurifier.auto.php')); //use this with the 1.2 core class BritaComponent extends Object { var $controller; function startup( &$controller ) { //the next few lines allow the config settings to be cached $config = HTMLPurifier_Config::createDefault(); $config->set('HTML', 'DefinitionID', 'made by debugged interactive designs'); $config->set('HTML', 'DefinitionRev', 1); //levels describe how aggressive the Tidy module should be when cleaning up html //four levels: none, light, medium, heavy $config->set('HTML', 'TidyLevel', 'heavy'); //check the top of your html file for the next two $config->set('HTML', 'Doctype', 'XHTML 1.0 Transitional'); $config->set('Core', 'Encoding', 'UTF-8'); //BritaComponent instance of controller is replaced by a htmlpurifier instance $controller->brita =& new HTMLPurifier($config); $controller->set('brita',$controller->brita); } } ?>
You need to login to post a comment.
