Location: PHPKode > projects > KvCMS Content Management System > kvframework/kvframework/sitehandler/kvframework_renderengine.class.php
<?php
/**
 * Default render engine class for the KvFramework.
 * @package KvFramework
 * @subpackage SiteHandler
 * @author Greg McWhirter <hide@address.com>
 * @copyright Copyright &copy; 2006, Greg McWhirter
 * @license BSD License
 * @version 1.0
 */

/**
 * @package KvFramework
 * @subpackage SiteHandler
 */
class kvframework_renderengine implements kvframework_irenderengine{
  function __construct(){}

  public function render_file($file, array $params = array(), $with_template = null){
    $layout_contents = "";
    $content_for_layout = "";
    if(is_null($with_template)){
      $layout_contents = "[CONTENT_FOR_LAYOUT]";
    } else {
      $layout_lines = file($with_template);
      $layout_contents = "";
      foreach($layout_lines as $l){$layout_contents .= $l."\n";}
    }

    $content_lines = file($file);
    $content_for_layout = "";
    foreach($content_lines as $l){$content_for_layout .= $l."\n";}

    kvframework_site::do_eval("?>". preg_replace("#\[CONTENT_FOR_LAYOUT\]#", $content_for_layout, $layout_contents));
    return true;
  }

  public function render_text($text, array $params = array(), $with_template = null){
    $layout_contents = "";
    if(is_null($with_template)){
      $layout_contents = "[CONTENT_FOR_LAYOUT]";
    } else {
      $layout_lines = file($with_template);
      $layout_contents = "";
      foreach($layout_lines as $l){$layout_contents .= $l."\n";}
    }

    kvframework_site::do_eval("?>". preg_replace("#\[CONTENT_FOR_LAYOUT\]#", $text, $layout_contents));
    return true;
  }
}
?>
Return current item: KvCMS Content Management System