当前位置: 首页>>代码示例>>PHP>>正文


PHP CTemplate::SetValues方法代码示例

本文整理汇总了PHP中CTemplate::SetValues方法的典型用法代码示例。如果您正苦于以下问题:PHP CTemplate::SetValues方法的具体用法?PHP CTemplate::SetValues怎么用?PHP CTemplate::SetValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CTemplate的用法示例。


在下文中一共展示了CTemplate::SetValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: LogLangSettings

    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();
开发者ID:ratan203,项目名称:phpsyntaxtree,代码行数:31,代码来源:index.php

示例2: Parse

 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;
 }
开发者ID:ratan203,项目名称:phpsyntaxtree,代码行数:40,代码来源:class.template.php


注:本文中的CTemplate::SetValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。