PicoYncludeRaw.php 1.0 KB

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /**
  3. * @package Pico
  4. * @subpackage PicoYncludeRaw
  5. * @author {notabug,framagit}.org/ohnonot
  6. */
  7. class PicoYncludeRaw extends AbstractPicoPlugin {
  8. const API_VERSION = 3;
  9. private $include_before = '';
  10. private $include_after = '';
  11. public function onMetaParsed(array $meta)
  12. {
  13. if(isset($meta['include_before'])) { $this->include_before = $meta['include_before']; }
  14. if(isset($meta['include_after'])) { $this->include_after = $meta['include_after']; }
  15. }
  16. public function onContentParsed(&$content)
  17. {
  18. if($this->include_before != "" and substr($this->include_before,0,1) == '/') {
  19. $file=$_SERVER['DOCUMENT_ROOT'].$this->include_before;
  20. if(file_exists($file)) $content=file_get_contents($file).$content;
  21. }
  22. if($this->include_after != "" and substr($this->include_after,0,1) == '/') {
  23. $file=$_SERVER['DOCUMENT_ROOT'].$this->include_after;
  24. if(file_exists($file)) $content=$content.file_get_contents($file);
  25. }
  26. }
  27. }