本文整理汇总了PHP中H2o类的典型用法代码示例。如果您正苦于以下问题:PHP H2o类的具体用法?PHP H2o怎么用?PHP H2o使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了H2o类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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');
}
示例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/');
}
示例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();
}
示例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);
}
示例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);
}
示例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));
}
示例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();
}
示例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 '';
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
示例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;
}
示例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);
}