WriteHtmlCacheBehavior.class.php 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. // +--------------------------------------------------------------------------
  3. // | Senthot [ DEVELOPED BY ME ]
  4. // +--------------------------------------------------------------------------
  5. // | Copyright (c) 2005-2013 http://www.senthot.com All rights reserved.
  6. // | License ( http://www.apache.org/licenses/LICENSE-2.0 )
  7. // | Author: ms134n ( [email protected] )
  8. // +--------------------------------------------------------------------------
  9. defined('SEN_PATH') or exit();
  10. /**
  11. * System behavior extension : static cache write
  12. * @category Sen
  13. * @package Sen
  14. * @subpackage Behavior
  15. * @author ms134n <[email protected]>
  16. */
  17. class WriteHtmlCacheBehavior extends Behavior {
  18. // Behavior extension execution entry must be run
  19. public function run(&$content){
  20. if(C('HTML_CACHE_ON') && defined('HTML_FILE_NAME')) {
  21. //Static file write
  22. // If you turn on HTML features Check and rewrite the HTML file
  23. // No stencil operation does not generate static files
  24. if(!is_dir(dirname(HTML_FILE_NAME)))
  25. mkdir(dirname(HTML_FILE_NAME),0755,true);
  26. if( false === file_put_contents( HTML_FILE_NAME , $content ))
  27. throw_exception(L('_CACHE_WRITE_ERROR_').':'.HTML_FILE_NAME);
  28. }
  29. }
  30. }