Пример #1
0
 /**
  * Open inc tag handler.
  * 
  * @access	private
  * @param	associative array	$node
  * @return	string
  * 
  */
 function _inc($node)
 {
     // evaluate the node name
     $node['attributes']['name'] = $this->exp->evaluate($node['attributes']['name'], $node, 'string', true);
     if ($node['type'] != 'complete') {
         $this->ignoreUntilLevel($node['level']);
     }
     if ($node['attributes']['type'] == 'csv') {
         if (!empty($node['attributes']['delimiter'])) {
             $delimiters = array('tab' => "\t", 'comma' => ',', 'colon' => ':', 'pipe' => '|', 'semicolon' => ';');
             if (isset($delimiters[$node['attributes']['delimiter']])) {
                 $delimiter = $delimiters[$node['attributes']['delimiter']];
             } else {
                 $delimiter = $node['attributes']['delimiter'];
             }
         } else {
             $delimiter = $delimiters['comma'];
         }
         $out = "<table>\n";
         $data = @file($this->path() . '/' . $node['attributes']['name']);
         if (!is_array($data)) {
             return '';
         }
         if ($node['attributes']['header'] == 'yes') {
             $headers = array_shift($data);
             $out .= "\t<tr>\n";
             foreach (preg_split('/' . $delimiter . '/', $headers) as $header) {
                 $out .= "\t\t<th>" . $header . "</th>\n";
             }
             $out .= "\t</tr>\n";
         }
         foreach ($data as $line) {
             $out .= "\t<tr>\n";
             foreach (preg_split('/' . $delimiter . '/', $line) as $item) {
                 $out .= "\t\t<td>" . $item . "</td>\n";
             }
             $out .= "\t</tr>\n";
         }
         return $out . "<table>\n";
     } elseif ($node['attributes']['type'] == 'messy') {
         return $this->messy($node['attributes']['name'], $this->exp->register['object']);
     } elseif ($node['attributes']['type'] == 'simple') {
         return template_simple($node['attributes']['name'], $this->exp->register['object']);
     } elseif ($node['attributes']['type'] == 'virtual') {
         //ob_start ();
         if (strpos($node['attributes']['name'], '/') === 0 || strpos($node['attributes']['name'], '://') === false) {
             $url = site_url() . $node['attributes']['name'];
         } else {
             $url = $node['attributes']['name'];
         }
         //include ($url);
         //$o = ob_get_contents ();
         //ob_end_clean ();
         $o = @join('', @file($url));
         return $o;
     } elseif ($node['attributes']['type'] == 'xml') {
         $this->ignoreUntilLevel(-1);
         $this->open = true;
         $this->xmlinc = array('node' => $node, 'struct' => '');
         $this->open_var =& $this->xmlinc['struct'];
         return '';
     } elseif ($node['attributes']['type'] == 'plain') {
         return @join('', @file($this->path() . '/' . $node['attributes']['name']));
     } else {
         // type is 'xt' or not specified
         $o = template_xt($node['attributes']['name'], $this->exp->register['object']);
         if ($o === false) {
             return '<!-- ' . template_error() . ' (' . template_err_line() . ', ' . template_err_colnum() . ') -->';
         }
         return $o;
     }
 }
Пример #2
0
<?php

page_title('SiteTemplate - Validation Error');
$data = array('error' => '', 'err_ln' => '', 'err_cl' => '');
$error = template_validate($parameters['body']);
if ($error == 1) {
    //the template is valid
    page_title('SiteTemplate - Template Valid');
    echo template_simple('tpl_validate_noerr.spt', $data);
} else {
    //the template has errors, find the line with errors
    $data['error'] = template_error($parameters['body']);
    $data['err_ln'] = template_err_line($parameters['body']);
    $data['err_cl'] = template_err_colnum($parameters['body']);
    echo template_simple('tpl_validate.spt', $data);
    $list = preg_split('/(\\r\\n|\\n\\r|\\r|\\n)/s', $parameters['body']);
    echo '<pre style="padding: 10px; background-color: #eee; border: 1px solid #aaa">';
    foreach ($list as $key => $e) {
        if ($key > $data['err_ln'] - 8 && $key < $data['err_ln'] + 6) {
            if ($key == $data['err_ln'] - 1) {
                echo '<span STYLE="background-color:#ff0">' . ($key + 1) . ' ' . htmlentities($e) . '</span><br />';
            } else {
                echo $key + 1 . ' ' . htmlentities($e) . '<br />';
            }
        }
    }
    echo '</pre>';
}