本文整理汇总了PHP中H2o类的典型用法代码示例。如果您正苦于以下问题:PHP H2o类的具体用法?PHP H2o怎么用?PHP H2o使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了H2o类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: should_render_inherited_template
public function should_render_inherited_template()
{
$h2o = new H2o('inherited.html', $this->option);
expects($h2o->render())->should_be('header,extended body,footer');
# extend nested blocks
$h2o->loadTemplate('nested_inherit');
expects($h2o->render())->should_be('h2o template rocks so hard ! and plays so hard');
}
开发者ID:tonjoo,项目名称:tiga-framework,代码行数:8,代码来源:inheritance_spec.php
示例2: should_be_able_to_include_in_nested_fashion
public function should_be_able_to_include_in_nested_fashion()
{
$h2o = new H2o('page.html', $this->option);
$result = $h2o->render();
expects($result)->should_match('/layout text/');
expects($result)->should_match('/Page footer/');
expects($result)->should_match('/page menu/');
}
开发者ID:tonjoo,项目名称:tiga-framework,代码行数:8,代码来源:include_spec.php
示例3: should_be_able_to_load_template_lazily
public function should_be_able_to_load_template_lazily()
{
$h2o = new H2o('a.html', array('searchpath' => 'templates'));
expects($h2o->render())->should_not_be_empty();
$h2o = new H2o(null, array('searchpath' => 'templates'));
$h2o->loadTemplate('b.html');
expects($h2o->render())->should_not_be_empty();
}
开发者ID:tonjoo,项目名称:tiga-framework,代码行数:8,代码来源:loader_spec.php
示例4: render
/**
* Renders a template using h2o
*
* @param string $template template file name
* @return string
*/
public function render($template)
{
if (!array_key_exists('searchpath', self::$h2o_options)) {
self::$h2o_options['searchpath'] = $this->getTemplatesDirectory() . '/';
}
$this->_load_h2o();
$h2o = new \H2o($template, self::$h2o_options);
return $h2o->render($this->data);
}
开发者ID:Alexander173,项目名称:angular-noCaptcha-reCaptcha,代码行数:15,代码来源:H2o.php
示例5: render
/**
* Renders a template using h2o
*
* @param string $template template file name
* @return string
*/
public function render($template)
{
if (!array_key_exists('searchpath', $this->h2o_options)) {
$this->h2o_options['searchpath'] = $this->getTemplatesDirectory() . '/';
}
// Make sure H2o is loaded
$this->_load_h2o();
$h2o = new H2o($template, $this->h2o_options);
return $h2o->render($this->data);
}
开发者ID:rubberneck,项目名称:slim-extras,代码行数:16,代码来源:H2o.php
示例6: get_display_list
public function get_display_list()
{
global $include_path, $scan_request_scripts;
$tpl = $include_path . '/templates/scan_request/scan_requests_list.tpl.html';
if (file_exists($include_path . '/templates/scan_request/scan_requests_list_subst.tpl.html')) {
$tpl = $include_path . '/templates/scan_request/scan_requests_list_subst.tpl.html';
}
$h2o = new H2o($tpl);
return $scan_request_scripts . $h2o->render(array('scan_requests' => $this));
}
开发者ID:noble82,项目名称:proyectos-ULS,代码行数:10,代码来源:scan_requests.class.php
示例7: should_be_able_to_load_template_lazily
function should_be_able_to_load_template_lazily()
{
chdir(dirname(__FILE__));
$paths = array(dirname(__FILE__) . DS . 'templates' . DS);
$h2o = h2o('a.html', array('searchpath' => $paths));
expects($h2o->render())->should_not_be_empty();
$h2o = new H2o('a.html', array('searchpath' => 'templates'));
expects($h2o->render())->should_not_be_empty();
$h2o = new H2o(null, array('searchpath' => 'templates'));
$h2o->loadTemplate('b.html');
expects($h2o->render())->should_not_be_empty();
}
开发者ID:JSilva,项目名称:h2o-php,代码行数:12,代码来源:loader_spec.php
示例8: generate_authority
/**
* Permet de générer l'affichage d'un élément de liste de type autorité
* @param authority $authority
* @param bool $recherche_ajax_mode
* @param int $group_id Identifiant du groupe
* @return string
*/
private function generate_authority($authority, $recherche_ajax_mode, $group_id)
{
global $include_path;
$template_path = $include_path . '/templates/authorities/list/' . $authority->get_string_type_object() . '.html';
if (file_exists($include_path . '/templates/authorities/list/' . $authority->get_string_type_object() . '_subst.html')) {
$template_path = $include_path . '/templates/authorities/list/' . $authority->get_string_type_object() . '_subst.html';
}
if (file_exists($template_path)) {
$h2o = new H2o($template_path);
$context = array('list_element' => $authority, 'group_id' => $group_id);
return $h2o->render($context);
}
return '';
}
开发者ID:noble82,项目名称:proyectos-ULS,代码行数:21,代码来源:elements_authorities_list_ui.class.php
示例9: get_datas
public function get_datas()
{
//on commence par récupérer l'identifiant retourné par le sélecteur...
$selector = $this->get_selected_selector();
if ($selector) {
$section_id = $selector->get_value();
$section_ids = $this->filter_datas("sections", array($section_id));
if ($section_ids[0]) {
$group_metadatas = parent::get_group_metadatas();
$datas = array();
$section = cms_provider::get_instance("section", $section_ids[0]);
$datas = $section->format_datas();
$datas["details"] = $datas;
$datas = array_merge($datas, parent::get_datas());
$datas['link'] = $this->get_constructed_link("section", $section_ids[0]);
$datas['logo_url'] = $datas["logo"]["big"];
foreach ($group_metadatas as $i => $metadatas) {
if (is_array($metadatas["metadatas"])) {
foreach ($metadatas["metadatas"] as $key => $value) {
try {
$group_metadatas[$i]["metadatas"][$key] = H2o::parseString($value)->render($datas);
} catch (Exception $e) {
}
}
}
}
return $group_metadatas;
}
}
return false;
}
开发者ID:noble82,项目名称:proyectos-ULS,代码行数:31,代码来源:cms_module_metadatas_datasource_metadatas_section.class.php
示例10: render
public function render($datas)
{
if (!$datas['id']) {
$datas['id'] = $this->get_module_dom_id();
}
if (!$datas['get_vars']) {
$datas['get_vars'] = $_GET;
}
if (!$datas['post_vars']) {
$datas['post_vars'] = $_POST;
}
if (!$datas['session_vars']) {
$datas['session_vars']['view'] = $_SESSION['opac_view'];
$datas['session_vars']['id_empr'] = $_SESSION['id_empr_session'];
}
if (!$datas['env_vars']) {
$datas['env_vars']['script'] = basename($_SERVER['SCRIPT_NAME']);
$datas['env_vars']['request'] = basename($_SERVER['REQUEST_URI']);
}
try {
$html = H2o::parseString($this->parameters['active_template'])->render($datas);
} catch (Exception $e) {
$html = $this->msg["cms_module_common_view_error_template"];
}
return $html;
}
开发者ID:hogsim,项目名称:PMB,代码行数:26,代码来源:cms_module_common_view_django.class.php
示例11: gen_print_card
function gen_print_card($data, $tpl = '')
{
global $msg;
$default_template = "@\n{% for empr in empr_list %}\n!\n{{empr.name}} {{empr.fistname}}\n!\nHfh k{{empr.cb}}\n{% endfor %}\nVA @";
if (!$tpl) {
$tpl = $default_template;
}
return H2o::parseString($tpl)->render($data);
}
开发者ID:bouchra012,项目名称:PMB,代码行数:9,代码来源:metapace.class.php
示例12: get_datas
public function get_datas()
{
global $opac_show_book_pics;
global $opac_book_pics_url;
global $opac_url_base;
//on commence par récupérer l'identifiant retourné par le sélecteur...
if ($this->parameters['selector'] != "") {
for ($i = 0; $i < count($this->selectors); $i++) {
if ($this->selectors[$i]['name'] == $this->parameters['selector']) {
$selector = new $this->parameters['selector']($this->selectors[$i]['id']);
break;
}
}
$notice = $selector->get_value();
if (is_array($notice)) {
$notice = $notice[0];
}
if ($notice) {
$group_metadatas = parent::get_group_metadatas();
$datas = array();
$notice_class = new notice($notice);
if ($opac_show_book_pics == '1' && ($opac_book_pics_url || $notice_class->thumbnail_url)) {
$code_chiffre = pmb_preg_replace('/-|\\.| /', '', $notice_class->code);
$url_image = $opac_book_pics_url;
$url_image = $opac_url_base . "getimage.php?url_image=" . urlencode($url_image) . "¬icecode=!!noticecode!!&vigurl=" . urlencode($notice_class->thumbnail_url);
if ($notice_class->thumbnail_url) {
$url_vign = $notice_class->thumbnail_url;
} else {
if ($code_chiffre) {
$url_vign = str_replace("!!noticecode!!", $code_chiffre, $url_image);
} else {
$url_vign = $opac_url_base . "images/vide.png";
}
}
}
$datas = array('id' => $notice_class->id, 'title' => $notice_class->tit1, 'link' => $this->get_constructed_link("notice", $notice_class->id), 'logo_url' => $url_vign, 'header' => $notice_class->notice_header, 'resume' => $notice_class->n_resume, 'content' => $content, 'type' => 'notice');
$datas["details"] = $datas;
$datas = array_merge($datas, parent::get_datas());
$datas['link'] = $this->get_constructed_link("notice", $notice_class->id);
foreach ($group_metadatas as $i => $metadatas) {
if (is_array($metadatas["metadatas"])) {
foreach ($metadatas["metadatas"] as $key => $value) {
try {
$group_metadatas[$i]["metadatas"][$key] = H2o::parseString($value)->render($datas);
} catch (Exception $e) {
}
}
}
}
return $group_metadatas;
}
}
return false;
}
开发者ID:hogsim,项目名称:PMB,代码行数:54,代码来源:cms_module_metadatas_datasource_metadatas_record.class.php
示例13: render
public static function render($id, $data)
{
global $dbh, $charset;
$requete = "SELECT * FROM bannette_tpl WHERE bannettetpl_id='" . $id . "' LIMIT 1 ";
$result = @pmb_mysql_query($requete, $dbh);
if (pmb_mysql_num_rows($result)) {
$temp = pmb_mysql_fetch_object($result);
$data_to_return = H2o::parseString($temp->bannettetpl_tpl)->render($data);
if ($charset != "utf-8") {
$data_to_return = utf8_decode($data_to_return);
}
return $data_to_return;
}
}
开发者ID:noble82,项目名称:proyectos-ULS,代码行数:14,代码来源:bannette_tpl.class.php
示例14: render
public function render($datas)
{
$html2return = "";
if (count($datas['records'])) {
$id = "carousel_" . $this->get_module_dom_id();
$datas['id'] = $this->get_module_dom_id();
$html2return .= H2o::parseString($this->parameters['active_template'])->render($datas);
$html2return .= "\n\t\t<script type='text/javascript'>\n\t\t\tjQuery(document).ready(function() {";
if ($this->parameters['mode'] == "horizontal") {
$html2return .= "\n\t\t\t\tvar item_width = document.getElementById('" . $this->get_module_dom_id() . "').offsetWidth/" . $this->parameters['display_quantity'] . ";\n\t\t\t\tvar items = document.getElementsByClassName('" . $this->get_module_dom_id() . "_item');\n\t\t\t\tfor(var i=0 ; i<items.length ; i++){\n\t\t\t\t\titems[i].style.width = item_width+'px';\n\t\t\t\t}";
} else {
$html2return .= "\n\t\t\t\tvar item_width = document.getElementById('" . $this->get_module_dom_id() . "').offsetHeight/" . $this->parameters['display_quantity'] . ";\n\t\t\t\tvar items = document.getElementsByClassName('" . $this->get_module_dom_id() . "_item');\n\t\t\t\tfor(var i=0 ; i<items.length ; i++){\n\t\t\t\t\titems[i].style.height = item_width+'px';\n\t\t\t\t}";
}
$html2return .= "\n\t\t\t\tjQuery('#" . $id . "').bxSlider({\n\t\t\t\t\tmode: '" . $this->parameters['mode'] . "',\n\t\t\t\t\tspeed: " . $this->parameters['speed'] . ",\n\t\t\t\t\tpause: " . $this->parameters['pause'] . ",\n\t\t\t\t\tauto: true,\n\t\t\t\t\tautoStart: " . ($this->parameters['autostart'] ? "true" : "false") . ",\n\t\t\t\t\tautoHover: " . ($this->parameters['autohover'] ? "true" : "false") . ",\n\t\t\t\t\tautoControls: false,\n\t\t\t\t\tcontrols:true,\n\t\t\t\t\tprevImage: '',\n\t\t\t\t\tprevText: '',\n\t\t\t\t\tnextImage: '',\n\t\t\t\t\tnextText: '',\n\t\t\t\t\tstartImage: '',\n\t\t\t\t\tstartText: '',\n\t\t\t\t\tstopImage: '',\n\t\t\t\t\t//stopText:'',\n\t\t\t\t\tpager: " . ($this->parameters['pager'] ? "true" : "false") . ",\n\t\t\t\t\trandomStart: false,\n\t\t\t\t\tdisplaySlideQty: " . $this->parameters['display_quantity'] . ",\n\t\t\t\t\tmoveSlideQty: " . $this->parameters['slide_quantity'] . "\n\t\t\t\t});\n\t\t\t});\n\t\t</script>";
}
return $html2return;
}
开发者ID:noble82,项目名称:proyectos-ULS,代码行数:17,代码来源:cms_module_carousel_view_carousel.class.php
示例15: render
public function render($datas)
{
if (!$datas['get_vars']) {
$datas['get_vars'] = $_GET;
}
if (!$datas['post_vars']) {
$datas['post_vars'] = $_POST;
}
if (!$datas['session_vars']) {
$datas['session_vars']['view'] = $_SESSION['opac_view'];
$datas['session_vars']['id_empr'] = $_SESSION['id_empr_session'];
}
if (!$datas['env_vars']) {
$datas['env_vars']['script'] = basename($_SERVER['SCRIPT_NAME']);
$datas['env_vars']['request'] = basename($_SERVER['REQUEST_URI']);
}
return H2o::parseString($this->parameters['active_template'])->render($datas);
}
开发者ID:bouchra012,项目名称:PMB,代码行数:18,代码来源:cms_module_common_view_django.class.php
示例16: func_get_args
function &parse()
{
$until = func_get_args();
$nodelist = new NodeList($this);
while ($token = $this->tokenstream->next()) {
//$token = $this->tokenstream->current();
switch ($token->type) {
case 'text':
$node = new TextNode($token->content, $token->position);
break;
case 'variable':
$args = H2o_Parser::parseArguments($token->content, $token->position);
$variable = array_shift($args);
$filters = $args;
$node = new VariableNode($variable, $filters, $token->position);
break;
case 'comment':
$node = new CommentNode($token->content);
break;
case 'block':
if (in_array($token->content, $until)) {
$this->token = $token;
return $nodelist;
}
$temp = preg_split('/\\s+/', $token->content, 2);
$name = $temp[0];
$args = count($temp) > 1 ? $temp[1] : null;
$node = H2o::createTag($name, $args, $this, $token->position);
$this->token = $token;
}
$this->searching = join(',', $until);
$this->first = false;
$nodelist->append($node);
}
if ($until) {
throw new TemplateSyntaxError('Unclose tag, expecting ' . $until[0]);
}
return $nodelist;
}
开发者ID:gigikir,项目名称:adebe,代码行数:39,代码来源:parser.php
示例17: get_datas
public function get_datas()
{
$datas = array();
$selector = $this->get_selected_selector();
$this->set_module_class_name("cms_module_sparql");
if ($selector->get_value()) {
//la config ARC2 varie en fonction de l'origine du server SPARL
$selector_config = new $this->managed_datas['stores'][$selector->get_value()]['selector']($this->managed_datas['stores'][$selector->get_value()]['selector_id']);
$config = array();
switch ($this->managed_datas['stores'][$selector->get_value()]['selector']) {
case "cms_module_sparql_selector_endpoint":
$config = array('remote_store_endpoint' => $selector_config->get_value(), 'remote_store_timeout' => 15);
$store = ARC2::getRemoteStore($config);
break;
}
if ($this->parameters['query']) {
$querydatas = array('get_vars' => $_GET, 'post_vars' => $_POST);
try {
$query = H2o::parseString($this->parameters['query'])->render($querydatas);
$rows = $store->query($query, 'rows');
if (!$rows) {
$this->debug("Execution failed : " . $query);
$errors = $store->getErrors();
foreach ($errors as $error) {
$this->debug(utf8_decode($error));
}
} else {
// $this->charset_normalize($rows, "utf-8");
}
} catch (Exception $e) {
$rows = array();
}
}
}
$this->debug($query);
$datas['result'] = $rows;
return $datas;
}
开发者ID:noble82,项目名称:proyectos-ULS,代码行数:38,代码来源:cms_module_sparql_datasource_sparql.class.php
示例18: H2o_Error
$this->enable = false;
} else {
throw new H2o_Error("Invalid syntax : autoescape on|off ");
}
}
function render($context, $stream)
{
$context->autoescape = $this->enable;
}
}
class Csrf_token_Tag extends H2o_Node
{
function render($context, $stream)
{
$token = "";
if (isset($_COOKIE["csrftoken"])) {
$token = $_COOKIE["csrftoken"];
} else {
global $SECRET_KEY;
if (defined('SECRET_KEY')) {
$token = md5(mt_rand() . SECRET_KEY);
} else {
$token = md5(mt_rand());
}
}
setcookie("csrftoken", $token, time() + 60 * 60 * 24 * 365, "/");
$stream->write("<div style='display:none'><input type=\"hidden\" value=\"{$token}\" name=\"csrfmiddlewaretoken\" /></div>");
}
}
H2o::addTag(array('block', 'extends', 'include', 'if', 'ifchanged', 'for', 'with', 'cycle', 'load', 'debug', 'now', 'autoescape', 'csrf_token'));
开发者ID:nesicus,项目名称:mephit,代码行数:30,代码来源:tags.php
示例19: H2o
<?php
require '../../h2o.php';
$template = new H2o('trans.html', array('cache' => false, 'i18n' => array('locale' => isset($_GET['lang']) ? $_GET['lang'] : false, 'charset' => 'UTF-8', 'gettext_path' => strtoupper(PHP_OS) == 'LINUX' ? '/usr/bin/' : '../bin/gettext/bin/', 'extract_message' => true, 'compile_message' => true)));
# Setup custom gettext resolver
$time_start = microtime(true);
echo $template->render(array('users' => array(array('username' => 'peter', 'tasks' => array('school', 'writing'), 'user_id' => 1), array('username' => 'anton', 'tasks' => array('go shopping'), 'user_id' => 2), array('username' => 'john doe', 'tasks' => array('write report', 'call tony', 'meeting with arron'), 'user_id' => 3), array('username' => 'foobar', 'tasks' => array(), 'user_id' => 4), array('username' => 'test', 'tasks' => null, 'user_id' => 5))));
echo "in " . (microtime(true) - $time_start) . " seconds\n<br/>";
开发者ID:nadams810,项目名称:h2o-php,代码行数:8,代码来源:index.php
示例20: get_isbd
public function get_isbd()
{
global $msg, $include_path;
$template_path = $include_path . '/templates/authorities/isbd/titre_uniforme.html';
if (file_exists($template_path)) {
$h2o = new H2o($template_path);
$authority = new authority(0, $this->id, AUT_TABLE_TITRES_UNIFORMES);
return $h2o->render(array('oeuvre' => $authority));
}
return $this->tu_isbd;
}
开发者ID:noble82,项目名称:proyectos-ULS,代码行数:11,代码来源:titre_uniforme.class.php
注:本文中的H2o类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论