Example #1
0
    public static function replaceRainTpl($code)
    {
        $function = self::loadFunction($code, 'draw');
        $function = preg_replace('/public /m', '', $function);
        $code = self::replaceFunction($code, 'draw');
        include "inc/lib/raintpl/Rain.php";
        raintpl::configure('tpl_dir', "class/tpl/");
        if (!is_dir('tmp')) {
            mkdir('tmp', 0705);
            chmod('tmp', 0705);
        }
        raintpl::configure('cache_dir', "tmp/");
        raintpl::configure('path_replace', false);
        $arrayTpl = glob("class/tpl/*.html");
        $rain = new Rain();
        foreach ($arrayTpl as $tpl) {
            $tpl = str_replace('.html', '', basename($tpl));
            $test = file_get_contents('class/tpl/' . $tpl . '.html');
            $test = str_replace(array("<?", "?>"), array("&lt;?", "?&gt;"), $test);
            $tmp = $rain->compileTemplate($test, 'class/tpl');
            $lines = explode(PHP_EOL, $tmp);
            for ($i = 0; $i < count($lines); $i++) {
                if (preg_match('/Rain/', $lines[$i])) {
                    $lines[$i] = self::replaceIncludeRainTpl($lines[$i]);
                }
            }
            $function = '
    public static function ' . $tpl . 'Tpl()
    {
        extract(FeedPage::$var);
?>
' . implode("\n", $lines) . '
<?php
    }
';
            $code = self::insertFunction($code, $function, 'FeedPage');
        }
        $code = preg_replace('/=\\$this->var\\[/', '=FeedPage::$var[', $code);
        return $code;
    }
 /**
  * rainfall Endpoint
  */
 protected function rain()
 {
     if (empty($this->id)) {
         return $this->_response("Location id not set. Cannot run \"rainfall\" without a valid location id.", 404);
     }
     $rain = new Rain();
     $rain->setupClass($this->args, $this->access, $this->extension);
     $rain->userid = $this->userid;
     $rain->locationid = $this->id;
     return $rain->process();
 }