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');
 }
Beispiel #2
0
 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/');
 }
Beispiel #3
0
 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();
 }
 /**
  * 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);
 }
Beispiel #5
0
 /**
  * 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);
 }
 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));
 }
Beispiel #7
0
 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();
 }
 /**
  * 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 '';
 }
 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;
 }
 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;
 }
Beispiel #11
0
 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);
 }
 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) . "&noticecode=!!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;
 }
 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;
     }
 }
 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;
 }
 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);
 }
Beispiel #16
0
 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;
 }
 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;
 }
Beispiel #18
0
            $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'));
Beispiel #19
0
<?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/>";
 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;
 }
 public function get_datas()
 {
     global $opac_url_base;
     global $opac_show_book_pics;
     global $opac_book_pics_url;
     global $dbh;
     //on commence par récupérer le type et le sous-type de page...
     $type_page_opac = cms_module_common_datasource_typepage_opac::get_type_page();
     $subtype_page_opac = cms_module_common_datasource_typepage_opac::get_subtype_page();
     if ($type_page_opac && $subtype_page_opac) {
         $group_metadatas = parent::get_group_metadatas();
         $datas = array();
         $query = $this->get_query();
         if ($query) {
             $post = $_POST;
             $get = $_GET;
             if ($post['lvl']) {
                 $niveau = $post['lvl'];
             } elseif ($get['lvl']) {
                 $niveau = $get['lvl'];
             } else {
                 $niveau = '';
             }
             $result = pmb_mysql_query($query, $dbh);
             while ($row = pmb_mysql_fetch_object($result)) {
                 $datas["id"] = $row->id;
                 $datas["title"] = $row->title;
                 $datas["resume"] = $row->resume;
                 if ($opac_show_book_pics == '1' && ($opac_book_pics_url || $row->logo_url)) {
                     $code_chiffre = pmb_preg_replace('/-|\\.| /', '', $row->code);
                     $url_image = $opac_book_pics_url;
                     $url_image = $opac_url_base . "getimage.php?url_image=" . urlencode($url_image) . "&noticecode=!!noticecode!!&vigurl=" . urlencode($row->logo_url);
                     if ($row->logo_url) {
                         $url_vign = $row->logo_url;
                     } else {
                         if ($code_chiffre) {
                             $url_vign = str_replace("!!noticecode!!", $code_chiffre, $url_image);
                         } else {
                             $url_vign = $opac_url_base . "images/vide.png";
                         }
                     }
                 }
                 $datas["logo_url"] = $url_vign;
                 $datas["link"] = $opac_url_base . "index.php?lvl=" . $niveau . "&id=" . $row->id;
                 $datas["type"] = $row->type;
             }
         }
         $datas["details"] = array('type_page' => cms_module_common_datasource_typepage_opac::get_label($type_page_opac), 'subtype_page' => cms_module_common_datasource_typepage_opac::get_label($subtype_page_opac));
         $datas = array_merge($datas, parent::get_datas());
         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;
 }
 function getEnrichment($notice_id, $source_id, $type = "", $enrich_params = array())
 {
     global $dbh;
     $enrichment = array();
     $params = $this->get_source_params($source_id);
     if ($params['PARAMETERS']) {
         //Affichage du formulaire avec $params["PARAMETERS"]
         $vars = unserialize($params["PARAMETERS"]);
     }
     $fields = array();
     $query = "select recid from notices_externes where num_notice = " . $notice_id;
     $result = pmb_mysql_query($query, $dbh);
     if ($result && pmb_mysql_num_rows($result)) {
         if ($row = pmb_mysql_fetch_object($result)) {
             $external_infos = explode(" ", $row->recid);
             $query = "select ufield, usubfield, field_order, value from entrepot_source_" . $external_infos[1] . " where connector_id = '" . $external_infos[0] . "' and source_id = '" . $external_infos[1] . "' and ref = '" . $external_infos[2] . "'";
             $result = pmb_mysql_query($query, $dbh);
             if ($result && pmb_mysql_num_rows($result)) {
                 while ($row = pmb_mysql_fetch_object($result)) {
                     // Si c'est une leçon, on a affaire à un champ répétable
                     if ($row->ufield == 917) {
                         $fields[$row->ufield][$row->field_order][$row->usubfield] = $row->value;
                     } else {
                         $fields[$row->ufield][$row->usubfield] = $row->value;
                     }
                 }
             }
         }
     }
     $lessons = array();
     // Titre
     $lessons['title'] = $fields[200]['a'];
     // Editeur
     $lessons['publisher'] = $fields[210]['c'];
     // Durée
     $lessons['duration'] = $fields[215]['a'];
     // Catégorie
     $lessons['category'] = $fields[610]['a'];
     // Démo
     $lessons['demo'] = $fields[856]['u'];
     // Vignette
     $lessons['thumbnail'] = $fields[896]['a'];
     // leçons
     $lessons['lessons'] = array();
     foreach ($fields[917] as $lesson) {
         $lessons['lessons'][] = array('id' => $lesson['a'], 'title' => $lesson['b']);
     }
     $infos = unserialize($this->parameters);
     // url de base
     if ($_SESSION['user_code'] && isset($infos['privatekey'])) {
         global $empr_cb, $empr_nom, $empr_prenom;
         $date = date("YmdHi");
         $hash = md5($empr_cb . $date . $infos['privatekey']);
         $lessons['base_url'] = "http://biblio.toutapprendre.com/ws/wsUrl.aspx?iduser="******"&firstname=" . $empr_prenom . "&lastname=" . $empr_nom . "&etablissement=" . $infos['establishmentid'] . "&d=" . $date . "&hash=" . $hash . "&pkl=";
     }
     $enrichment[$type]['content'] = H2o::parseString(stripslashes($vars['enrichment_template']))->render(array("lessons" => $lessons));
     $enrichment['source_label'] = $this->msg['toutapprendre_enrichment_source'];
     return $enrichment;
 }
Beispiel #23
0
 function noticeInfos($notice_id, $sparql_end_point)
 {
     global $lang, $charset;
     //On va rechercher l'isbn si il existe....
     $requete = "select code from notices where notice_id={$notice_id}";
     $resultat = mysql_query($requete);
     if (mysql_num_rows($resultat)) {
         $isbn = mysql_result($resultat, 0, 0);
     } else {
         $isbn = "";
     }
     if ($isbn) {
         //On y va !
         $config = array('remote_store_endpoint' => $sparql_end_point, 'remote_store_timeout' => 10);
         $store = ARC2::getRemoteStore($config);
         $sparql = "prefix bnf-onto: <http://data.bnf.fr/ontology/>\n\t\t\t\tprefix rdarelationships: <http://rdvocab.info/RDARelationshipsWEMI/>\n\t\t\t\tSELECT ?oeuvre WHERE {\n\t\t\t\t  ?manifestation bnf-onto:ISBN '{$isbn}' .\n\t\t\t\t  ?manifestation rdarelationships:workManifested ?oeuvre \n\t\t\t\t}";
         try {
             $rows = $store->query($sparql, 'rows');
         } catch (Exception $e) {
             $rows = array();
         }
         if ($rows[0]["oeuvre"]) {
             $oeuvre = $rows[0]["oeuvre"];
             $sparql = "prefix skos: <http://www.w3.org/2004/02/skos/core#>\n\t\t\t\t\tprefix foaf: <http://xmlns.com/foaf/0.1/>\n\t\t\t\t\tprefix dc: <http://purl.org/dc/terms/>\n\t\t\t\t\tprefix bnf-onto: <http://data.bnf.fr/ontology/>\n\t\t\t\t\tprefix rdarelationships: <http://rdvocab.info/RDARelationshipsWEMI/>\n\t\t\t\t\tprefix rdagroup1Elements: <http://RDVocab.info/Elements/>\n\t\t\t\t\tSELECT * WHERE {\n\t\t\t\t\t  <{$oeuvre}> rdfs:label ?titre .\n\t\t\t\t\t  OPTIONAL { <{$oeuvre}> dc:date ?date } .\n\t\t\t\t\t  OPTIONAL { <{$oeuvre}> foaf:depiction ?vignette } .\n\t\t\t\t\t  OPTIONAL { <{$oeuvre}> dc:description ?description } .\n\t\t\t\t\t  OPTIONAL { <{$oeuvre}> bnf-onto:subject ?sujet } .\n\t\t\t\t\t  OPTIONAL { <{$oeuvre}> dc:creator ?auteur .\n\t\t\t\t\t     ?auteur_concept foaf:focus ?auteur .\n\t\t\t\t\t     ?auteur_concept skos:prefLabel ?auteur_isbd .\n\t\t\t\t\t  } .\n\t\t\t\t\t  OPTIONAL { <{$oeuvre}> rdagroup1Elements:placeOfOriginOfTheWork ?lieu }\n\t\t\t\t\t}";
             try {
                 $rows = $store->query($sparql, 'rows');
             } catch (Exception $e) {
                 $rows = array();
             }
             $rows = array_uft8_decode($rows);
             $template = "\n\t\t\t\t\t\t<h3>{{result.0.titre}}<div style='float:right'><a href='{$oeuvre}' target='_blank'><img src='http://data.bnf.fr/data/85bec01e1d53356985bccf3036a2bb49/logo-data.gif' style='max-height:20px'/></a></div></h3>\n\t\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t\t<h3>Détail de l'oeuvre (BNF)</h3>\n\t\t\t\t\t\t{% if result.0.vignette %}\n\t\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td><img src='{{result.0.vignette}}' height='150px'/></td>\n\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t{% endif %}\n\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t<tr><td style='background:#EEEEEE'>Date</td><td>{{result.0.date}}</td></tr>\n\t\t\t\t\t\t\t<tr><td style='background:#EEEEEE'>Sujet</td><td>{{result.0.sujet}}</td></tr>\n\t\t\t\t\t\t\t<tr><td style='background:#EEEEEE'>Auteur</td><td><a href='index.php?uri={{result.0.auteur_concept}}&lvl=cmspage&pageid=12'>{{result.0.auteur_isbd}}</a></td></tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t\t{% if result.0.vignette %}\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t  </table>\n\t\t\t\t\t\t{% endif %}\n\t\t\t\t\t\t<br/>\t\n\t\t\t\t\t\t<h4>{{result.0.description}}</h4>\t\t\t\n\t\t\t\t";
             $html_to_return .= H2o::parseString($template)->render(array("result" => $rows));
             //Récupération des exemplaires de Gallica
             $sparql = "prefix skos: <http://www.w3.org/2004/02/skos/core#>\n\t\t\t\t\tprefix foaf: <http://xmlns.com/foaf/0.1/>\n\t\t\t\t\tprefix dc: <http://purl.org/dc/terms/>\n\t\t\t\t\tprefix bnf-onto: <http://data.bnf.fr/ontology/>\n\t\t\t\t\tprefix rdarelationships: <http://rdvocab.info/RDARelationshipsWEMI/>\n\t\t\t\t\tprefix rdagroup1Elements: <http://RDVocab.info/Elements/>\n\t\t\t\t\tSELECT * WHERE {\n\t\t\t\t\t\t?manifestation rdarelationships:workManifested <{$oeuvre}> .\n\t\t\t\t\t\tOPTIONAL { ?manifestation rdarelationships:electronicReproduction ?gallica } .\n\t\t\t\t\t\tOPTIONAL { ?manifestation bnf-onto:ISBN ?isbn } .\n\t\t\t\t\t\tOPTIONAL { <{$oeuvre}> foaf:depiction ?vignette } .\n\t\t\t\t\t\tOPTIONAL { ?manifestation dc:date ?date } .\n\t\t\t\t\t\tOPTIONAL { ?manifestation rdagroup1Elements:publishersName ?publisher } .\n\t\t\t\t\t\tOPTIONAL { ?manifestation rdagroup1Elements:note ?note } .\n\t\t\t\t\t\tOPTIONAL { ?manifestation rdagroup1Elements:placeOfPublication ?place } .\n\t\t\t\t\t\tOPTIONAL { ?manifestation rdagroup1Elements:dateOfCapture ?numerisele } .\n\t\t\t\t\t} group by ?manifestation order by ?date\n\t\t\t\t";
             try {
                 $rows = $store->query($sparql, 'rows');
             } catch (Exception $e) {
                 $rows = array();
             }
             $rows = array_uft8_decode($rows);
             $template = "\n\t\t\t\t\t\t<h3>Editions numérisées dans Gallica</h3><br/>\n\t\t\t\t\t\t<table>\n\t\t\t\t\t\t{% for record in result %}\n\t\t\t\t\t\t\t{% if record.gallica %}\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td><a href='{{record.gallica}}' target='_blank'><img height='40px' src='http://gallica.bnf.fr/images/dynamic/perso/logo_gallica.png' /></a></td>\n\t\t\t\t\t\t\t\t<td><a href='{{record.gallica}}' target='_blank'>Edition : {{record.date}} par {{record.publisher}} à {{record.place}}</a></td>\n\t\t\t\t\t\t\t\t<td>{{record.note}}</td>\n\t\t\t\t\t\t\t\t<td>{{record.numerisele}}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t{% endif %}\n\t\t\t\t\t\t{% endfor %}\n\t\t\t\t\t\t</table>\n\t\t\t\t";
             $html_to_return .= H2o::parseString($template)->render(array("result" => $rows));
             $template = "\n\t\t\t\t\t\t<h3>Editions dans la bibliothèque</h3><br/>\n\t\t\t\t\t\t<table>\n\t\t\t\t\t\t{% for record in result %}\n\t\t\t\t\t\t\t{% if record.isbn %}\n\t\t\t\t\t\t\t\t{% sqlvalue i_catalog %}\n\t\t\t\t\t\t\t\t\tselect count(expl_id) as nb,notice_id from exemplaires join notices on expl_notice=notice_id where code='{{record.isbn}}' group by notice_id\n\t\t\t\t\t\t\t\t{% endsqlvalue %}\n\t\t\t\t\t\t\t\t{% if i_catalog.0.nb %}\n\t\t\t\t\t\t\t\t\t<tr style='height:70px'>\n\t\t\t\t\t\t\t\t\t\t<td><a href='index.php?lvl=notice_display&id={{i_catalog.0.notice_id}}' target='_blank'>{% if record.vignette %}<img src='{{record.vignette}}' height='70px'/>{% else %}&nbsp;{% endif %}</a></td>\n\t\t\t\t\t\t\t\t\t\t<td><a href='index.php?lvl=notice_display&id={{i_catalog.0.notice_id}}' target='_blank'>Edition : {{record.date}} par {{record.publisher}} à {{record.place}}</a></td>\n\t\t\t\t\t\t\t\t\t\t<td>{{record.note}}</td>\n\t\t\t\t\t\t\t\t\t\t<td><a href='index.php?lvl=notice_display&id={{i_catalog.0.notice_id}}' target='_blank'>{{i_catalog.0.nb}} exemplaires disponible(s)</a></td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t{% endif %}\n\t\t\t\t\t\t\t{% endif %}\n\t\t\t\t\t\t{% endfor %}\n\t\t\t\t\t\t</table>\n\t\t\t\t";
             try {
                 $html_to_return .= H2o::parseString($template)->render(array("result" => $rows));
             } catch (Exception $e) {
                 $html_to_return .= highlight_string(print_r($e, true), true);
             }
         }
     }
     return $html_to_return;
 }
Beispiel #24
0
 /**
  * Register a new tag
  *
  *
  * h2o::addTag('tag_name', 'ClassName');
  *
  * h2o::addTag(array(
  *      'tag_name' => 'MagClass',
  *      'tag_name2' => 'TagClass2'
  * ));
  *
  *  h2o::addTag('tag_name');      // Tag_name_Tag
  *
  * h2o::addTag(array('tag_name',
  * @param unknown_type $tag
  * @param unknown_type $class
  */
 static function addTag($tag, $class = null)
 {
     $tags = array();
     if (is_string($tag)) {
         if (is_null($class)) {
             $class = ucwords("{$tag}_Tag");
         }
         $tags[$tag] = $class;
     } elseif (is_array($tag)) {
         $tags = $tag;
     }
     foreach ($tags as $tag => $tagClass) {
         if (is_integer($tag)) {
             unset($tags[$tag]);
             $tag = $tagClass;
             $tagClass = ucwords("{$tagClass}_Tag");
         }
         if (!class_exists($tagClass, false)) {
             throw new H2o_Error("{$tagClass} tag is not found");
         }
         $tags[$tag] = $tagClass;
     }
     self::$tags = array_merge(self::$tags, $tags);
 }
 static function get_isbd($id)
 {
     global $dbh;
     $req = "select * from authperso_authorities,authperso where id_authperso=authperso_authority_authperso_num and id_authperso_authority=" . $id;
     $res = pmb_mysql_query($req, $dbh);
     if ($r = pmb_mysql_fetch_object($res)) {
         $p_perso = new custom_parametres_perso("authperso", "authperso", $r->authperso_authority_authperso_num);
         $fields = $p_perso->get_out_values($id);
         $authperso_fields = $p_perso->values;
         if ($r->authperso_isbd_script) {
             $index_concept = new index_concept($id, TYPE_AUTHPERSO);
             $authperso_fields['index_concepts'] = $index_concept->get_data();
             $isbd = H2o::parseString($r->authperso_isbd_script)->render($authperso_fields);
         } else {
             foreach ($authperso_fields as $field) {
                 $isbd .= $field[values][0][format_value] . ".  ";
             }
         }
     }
     return trim(preg_replace('/\\s+/', ' ', $isbd));
 }
                        } else {
                            $resas_datas['flag_resa_possible'] = false;
                        }
                        if ($opac_show_exemplaires) {
                            $obj['display_expls'] = pmb_bidi(notice_affichage::expl_list("m", 0, $id));
                        }
                    } else {
                        $resas_datas['flag_resa_visible'] = false;
                    }
                    // On envoie le tout au template
                    if (file_exists($include_path . "/templates/record/" . $opac_notices_format_django_directory . "/bulletin_without_record_extended_display.tpl.html")) {
                        $template = $include_path . "/templates/record/" . $opac_notices_format_django_directory . "/bulletin_without_record_extended_display.tpl.html";
                    } else {
                        $template = $include_path . "/templates/record/common/bulletin_without_record_extended_display.tpl.html";
                    }
                    $h2o = new H2o($template);
                    print $h2o->render(array('bulletin' => $obj, 'parent' => $notice3, 'liens_opac' => $liens_opac, 'resas_datas' => $resas_datas));
                }
            }
        }
    }
}
pmb_mysql_free_result($resdep);
function do_carroussel($bull)
{
    global $gestion_acces_active, $gestion_acces_empr_notice, $opac_navigateur_bulletin_number;
    global $msg;
    if ($gestion_acces_active == 1 && $gestion_acces_empr_notice == 1) {
        $ac = new acces();
        $dom_2 = $ac->setDomain(2);
        $join_noti = $dom_2->getJoin($_SESSION["id_empr_session"], 4, "bulletins.num_notice");
 public function render($datas)
 {
     global $opac_default_style;
     $html2return = "";
     //TODO VERIF DOM ET APPEL AU JS
     if (count($datas['records'])) {
         $id = "carousel_" . $this->get_module_dom_id();
         $datas['id'] = $this->get_module_dom_id();
         //pour la no-image, on cherche celle du style, du common, du dossier image de base, sinon on sert celle par défaut
         $path = "./styles/" . $opac_default_style . "/images/";
         if (!file_exists(realpath($path) . $this->parameters['no_image'])) {
             $path = "./styles/common/images/";
             if (!file_exists(realpath($path) . $this->parameters['no_image'])) {
                 $path = "./images/";
                 if (!file_exists(realpath($path) . $this->parameters['no_image'])) {
                     $path = "./images/";
                     $this->parameters['no_image'] = "no_image_carousel.jpg";
                 }
             }
         }
         $datas['no_image_url'] = $path . $this->parameters['no_image'];
         for ($i = 0; $i < count($datas['records']); $i++) {
             if ($datas['records'][$i]['vign'] == "") {
                 $datas['records'][$i]['vign'] = $datas['no_image_url'];
             }
         }
         $html2return .= H2o::parseString($this->parameters['active_template'])->render($datas);
         $html2return .= "\n\t\t<script type='text/javascript'>\n\t\t\tjQuery(document).ready(function() {\n\t\t\t\tjQuery('#" . $id . "').bxSlider({\n\t\t\t\t\t//parametres generaux\n\t\t\t\t\tmode: \t\t\t\t\t'" . $this->parameters['mode'] . "',\n\t\t\t\t\tspeed: \t\t\t\t\t" . $this->parameters['speed'] . ",\n\t\t\t\t\tpause: \t\t\t\t\t" . $this->parameters['pause'] . ",\t\n\t\t\t\t\tautoStart: \t\t\t\t" . ($this->parameters['autostart'] ? "true" : "false") . ",\n\t\t\t\t\tautoHover: \t\t\t\t" . ($this->parameters['autohover'] ? "true" : "false") . ",\t\n\t\t\t\t\tpager: \t\t\t\t\t" . ($this->parameters['pager'] ? "true" : "false") . ",\t\n\t\t\t\t\tmoveSlides : \t\t\t'" . $this->parameters['slide_quantity'] . "',\t\n\t\t\t\t\tminSlides: \t\t\t\t'" . $this->parameters['display_min_quantity'] . "',\t\n\t\t\t\t\tmaxSlides: \t\t\t\t'" . $this->parameters['display_max_quantity'] . "',\n\t\t\t\t\tslideWidth: \t\t\t'" . $this->parameters['slide_width'] . "',\n\t\t\t\t\t//parametres avances\n\t\t\t\t\tslideMargin: \t\t\t'" . $this->parameters['slide_margin'] . "',\n\t\t\t\t\trandomStart: \t\t\t" . ($this->parameters['randomStart'] ? "true" : "false") . ",\n\t\t\t\t\teasing: \t\t\t\t'" . $this->parameters["easing"] . "',\n\t\t\t\t\tcaptions: \t\t\t\t" . ($this->parameters['captions'] ? "true" : "false") . ",\n\t\t\t\t\tadaptiveHeight:\t\t\t" . ($this->parameters['adaptive_heigt'] ? "true" : "false") . ",\n\t\t\t\t\tadaptiveHeightSpeed:\t'" . $this->parameters["adaptive_heigt_speed"] . "',\n\t\t\t\t\tpagerType:\t\t\t\t'" . $this->parameters["pager_type"] . "',\n\t\t\t\t\tpagerSeparator:\t\t\t'" . $this->parameters["pager_short_separator"] . "',\n\t\t\t\t\tcontrols:\t\t\t\t" . ($this->parameters['controls'] ? "true" : "false") . ",\n\t\t\t\t\tnextText:\t\t\t\t'" . $this->parameters["next_text"] . "',\n\t\t\t\t\tpreviouText:\t\t\t'" . $this->parameters["previous_text"] . "',\n\t\t\t\t\tautoControls: \t\t\t" . ($this->parameters['auto_controls'] ? "true" : "false") . ",\n\t\t\t\t\tstartText: \t\t\t\t'" . $this->parameters["start_text"] . "',\n\t\t\t\t\tstopText: \t\t\t\t'" . $this->parameters["stop_text"] . "',\n\t\t\t\t\tautoControlsCombine: \t" . ($this->parameters['autocontrols_combine'] ? "true" : "false") . ",\n\t\t\t\t\tautoDirection: \t\t\t'" . $this->parameters["auto_direction"] . "',\n\t\t\t\t\tautoDelay: \t\t\t\t'" . $this->parameters["auto_delay"] . "',\n\t\t\t\t\tauto: \t\t\t\t\t" . ($this->parameters['autotransition'] ? "true" : "false") . "\n\t\t\t\t});\n\t\t\t});\n\t\t</script>";
     }
     return $html2return;
 }
 /**
  * Retourne l'affichage d'un concept
  * @param array $datas Données
  * @param string $template Nom du template à utiliser
  * @return string
  */
 protected static function render($datas, $template)
 {
     global ${$template};
     return H2o::parseString(${$template})->render(array("concept" => $datas));
 }
Beispiel #29
0
 function get_view($id)
 {
     global $dbh;
     $req = "select * from authperso_authorities,authperso where id_authperso=authperso_authority_authperso_num and id_authperso_authority=" . $id;
     $res = pmb_mysql_query($req, $dbh);
     if ($r = pmb_mysql_fetch_object($res)) {
         $p_perso = new custom_parametres_perso("authperso", "authperso", $r->authperso_authority_authperso_num, "./autorites.php?categ=authperso&sub=update&id_authperso=" . $this->id, $option_navigation, $option_visibilite);
         $fields = $p_perso->get_out_values($id);
         $authperso_fields = $p_perso->values;
         $aut_link = new aut_link($r->authperso_authority_authperso_num + 1000, $id);
         $authperso_fields['authorities_link'] = $aut_link->get_data();
         //printr($authperso_fields);
         if ($r->authperso_view_script) {
             $view = H2o::parseString($r->authperso_view_script)->render($authperso_fields);
         } else {
             foreach ($authperso_fields as $field) {
                 $view .= $field[values][0][format_value] . ".  ";
             }
         }
     }
     return $view;
 }
Beispiel #30
0
 public function render($context = array())
 {
     global $opac_authorities_templates_folder;
     if (!$opac_authorities_templates_folder) {
         $opac_authorities_templates_folder = "./includes/templates/authorities/common";
     }
     $template_path = $opac_authorities_templates_folder . "/" . $this->get_type_autority() . ".html";
     if (!file_exists($template_path)) {
         $template_path = "./includes/templates/authorities/common/" . $this->get_type_autority() . ".html";
     }
     if (file_exists($opac_authorities_templates_folder . "/" . $this->get_type_autority() . "_subst.html")) {
         $template_path = $opac_authorities_templates_folder . "/" . $this->get_type_autority() . "_subst.html";
     }
     if (file_exists($template_path)) {
         $h2o = new H2o($template_path);
         $h2o->addLookup(array($this, "lookup"));
         echo $h2o->render($context);
     }
 }