Exemplo n.º 1
0
    if (LOG_LANG) {
        LogLangSettings();
    }
} else {
    // If no phrase was submitted, show
    //   usage information, news, etc. .
    $page = new CTemplate(GetLocalizedFname('tpl/intro.html'));
}
// If we don't have data from the form or a
//   previous phrase stored in the sessions,
//   load the example data.
if (!isset($_SESSION['data'])) {
    $_SESSION['data'] = file_get_contents(GetLocalizedFname("var/sample.phrase"));
    $_SESSION['color'] = TRUE;
    $_SESSION['antialias'] = TRUE;
    $_SESSION['autosub'] = TRUE;
    $_SESSION['triangles'] = TRUE;
    $_SESSION['fontsel'] = "vera_sans";
    $_SESSION['font'] = "Vera.ttf";
    $_SESSION['fontsize'] = 8;
}
// Render the page
$phrase = htmlentities($_SESSION['data']);
$img = sprintf("<img src=\"stgraph.png.php?%s\" alt=\"\" title=\"%s\"/>", SID, $phrase);
$graph = sprintf("<a href=\"dnlgraph.php?%s\">%s</a>", SID, $img);
$icon = "<img src=\"img/vectorgfx.png\" alt=\"SVG\" />";
$svg = sprintf("<div id=\"svg\"><a href=\"stgraph.svg.php?%s\">%s</a></div>", SID, $icon);
$fontoption = sprintf("SELECT_%s", $_SESSION['fontsel']);
$sizeoption = sprintf("SELECT_size_%d", $_SESSION['fontsize']);
$page->SetValues(array('VERSION' => VERSION, 'FORM_ACTION' => sprintf("?%s", strip_tags(SID)), 'GRAPH' => $graph, 'SVG' => $svg, 'PHRASE' => $phrase, 'DATA_VAL' => $phrase, 'COLOR_VAL' => $_SESSION['color'] ? HTML_CHECKED : HTML_UNCHECKED, 'ANTIALIAS_VAL' => $_SESSION['antialias'] ? HTML_CHECKED : HTML_UNCHECKED, 'AUTOSUB_VAL' => $_SESSION['autosub'] ? HTML_CHECKED : HTML_UNCHECKED, 'TRIANGLES_VAL' => $_SESSION['triangles'] ? HTML_CHECKED : HTML_UNCHECKED, 'COUNTER' => GetCounter(), $fontoption => HTML_SELECTED, $sizeoption => HTML_SELECTED));
$page->Render();
Exemplo n.º 2
0
 function Parse()
 {
     $content = $this->_template;
     // Mask {{ and }} for later substitution with { and }
     $content = str_replace("{{", "_<<<_", $content);
     $content = str_replace("}}", "_>>>_", $content);
     // Parse includes
     $search = "#{INCLUDE}(.*){/INCLUDE}#isU";
     preg_match_all($search, $content, $matches, PREG_SET_ORDER);
     foreach ($matches as $match) {
         $incfile = dirname($this->_tpl_file) . DIRECTORY_SEPARATOR . $match[1];
         $t = new CTemplate($incfile);
         $t->SetValues($this->_values);
         $search = sprintf("#{INCLUDE}%s\\{/INCLUDE}#isU", $match[1]);
         $replace = str_replace("\$", "\\\$", $t->Parse());
         $content = preg_replace($search, $replace, $content);
     }
     // Replace single fields
     foreach ($this->_values as $token => $value) {
         $content = str_replace('{' . $token . '}', $value, $content);
     }
     // Replace template blocks
     foreach ($this->_blockdata as $token => $value) {
         $content = str_replace('{BLOCK_' . $token . '}', $value, $content);
     }
     // Parse PHP
     if ($this->_parse_php) {
         $content = $this->_parsePHP($content);
     }
     // Strip empty template placeholders
     if (!$this->_debug) {
         $content = preg_replace("/{.*}/U", "", $content);
     }
     // Now convert the {{ and }} replacements back to { and }
     $content = str_replace("_<<<_", "{", $content);
     $content = str_replace("_>>>_", "}", $content);
     // Return content
     $this->_content = $content;
     return $this->_content;
 }