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;
 }
示例#3
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);
 }
 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;
 }
 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;
 }
示例#10
0
 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));
 }
示例#11
0
文件: h2o.php 项目: nadams810/kritbit
/**
 * Convenient wrapper for loading template file or string
 * @param $name
 * @param $options - H2o options
 * @return Instance of H2o Template
 */
function h2o($name, $options = array())
{
    $is_file = '/([^\\s]*?)(\\.[^.\\s]*$)/';
    if (!preg_match($is_file, $name)) {
        return H2o::parseString($name, $options);
    }
    $instance = new H2o($name, $options);
    return $instance;
}
示例#12
0
 function build_print_diffusion($expl_id, $start_diff_id)
 {
     global $serialcirc_circ_pdf_diffusion, $charset, $serialcirc_circ_pdf_diffusion_destinataire;
     global $msg;
     if (!$start_diff_id) {
         foreach ($this->info_expl[$expl_id]['serialcirc_diff']->diffusion as $diff_id => $diffusion) {
             $start_diff_id = $diff_id;
             break;
         }
     }
     if (!$this->info_expl[$expl_id]) {
         return false;
     }
     $req = "UPDATE serialcirc_expl SET num_serialcirc_expl_serialcirc_diff=" . $start_diff_id . ",\n\t\tserialcirc_expl_state_circ=1,\n\t\tserialcirc_expl_start_date=CURDATE()\n\t\twhere num_serialcirc_expl_id= {$expl_id}";
     pmb_mysql_query($req);
     $req = "select date_format(CURDATE(), '" . $msg["format_date"] . "') as print_date";
     $result = pmb_mysql_query($req);
     $obj = pmb_mysql_fetch_object($result);
     $print_date = $obj->print_date;
     $tpl = $serialcirc_circ_pdf_diffusion;
     $tpl = str_replace("!!expl_cb!!", htmlentities($this->info_expl[$expl_id]['expl_cb'], ENT_QUOTES, $charset), $tpl);
     $tpl = str_replace("!!date!!", htmlentities($this->info_expl[$expl_id]['mention_date'], ENT_QUOTES, $charset), $tpl);
     $tpl = str_replace("!!periodique!!", htmlentities($this->info_expl[$expl_id]['serial_title'], ENT_QUOTES, $charset), $tpl);
     $tpl = str_replace("!!numero!!", htmlentities($this->info_expl[$expl_id]['numero'], ENT_QUOTES, $charset), $tpl);
     $tpl = str_replace("!!print_date!!", htmlentities($print_date, ENT_QUOTES, $charset), $tpl);
     //	$tpl=str_replace("!!abonnement!!", htmlentities($this->info_expl[$expl_id]['serialcirc_diff']->abt_name,ENT_QUOTES,$charset), $tpl);
     if ($start_diff_id) {
         $found = 0;
     } else {
         $found = 1;
     }
     foreach ($this->info_expl[$expl_id]['serialcirc_diff']->diffusion as $diff_id => $diffusion) {
         if ($start_diff_id && !$found) {
             if ($start_diff_id == $diff_id) {
                 $found = 1;
             }
         }
         if ($found) {
             $diff_list[] = $diff_id;
             if ($diffusion["empr_type"] == SERIALCIRC_EMPR_TYPE_group) {
                 $name = $diffusion["empr_name"];
                 foreach ($diffusion['group'] as $empr_group) {
                     $empr_list[$empr_group["num_empr"]] = $diff_id;
                     if ($empr_group["duration"]) {
                         $empr_days[$empr_group["num_empr"]] = $empr_group["duration"];
                     } else {
                         $empr_days[$empr_group["num_empr"]] = $this->info_expl[$expl_id]['serialcirc_diff']->duration;
                     }
                     if ($diffusion['type_diff'] == 1 && !$empr_group["responsable"]) {
                         // groupe marguerite: on n'imprimera pas ce lecteur sauf le responsable
                         //$empr_no_display[$empr_group["num_empr"]]=1;
                     }
                 }
             } else {
                 $name = $this->info_expl[$expl_id]['serialcirc_diff']->empr_info[$diffusion["num_empr"]]["empr_libelle"];
                 $empr_list[$diffusion["num_empr"]] = $diff_id;
                 if ($diffusion["duration"]) {
                     $empr_days[$diffusion["num_empr"]] = $diffusion["duration"];
                 } else {
                     $empr_days[$diffusion["num_empr"]] = $this->info_expl[$expl_id]['serialcirc_diff']->duration;
                 }
             }
             if ($this->info_expl[$expl_id]['serialcirc_diff']->circ_type == SERIALCIRC_TYPE_star) {
                 // on n'imprime que le suivant dans la liste
                 break;
             }
         }
         $last_empr = $this->info_expl[$expl_id]['serialcirc_diff']->empr_info[$diffusion["num_empr"]];
     }
     $this->gen_circ($empr_list, $empr_days, $expl_id);
     $gen_tpl = new serialcirc_print_fields($this->info_expl[$expl_id]['num_serialcirc']);
     $header_list = $gen_tpl->get_header_list();
     $nb_col = count($header_list);
     $width_col = (int) (100 / $nb_col);
     foreach ($header_list as $titre) {
         $th .= "<th style='width: {$width_col}%; text-align: left'>" . htmlentities($titre, ENT_QUOTES, $charset) . "</th>";
     }
     $tpl = str_replace("!!th!!", $th, $tpl);
     $tr_list = "";
     foreach ($empr_list as $empr_id => $diff_id) {
         if ($empr_no_display[$empr_id]) {
             continue;
         }
         $data['empr_id'] = $empr_id;
         $data_fields = $gen_tpl->get_line($data);
         $td_list = "";
         foreach ($data_fields as $field) {
             $td_list .= "<td style='width: {$width_col}%; text-align: left'>" . htmlentities($field, ENT_QUOTES, $charset) . "</td>";
         }
         $tr_list .= "<tr>" . $td_list . "</tr>";
     }
     $tpl = str_replace("!!table_contens!!", $tr_list, $tpl);
     if ($gen_tpl->piedpage) {
         $data = array();
         $data['expl'] = $this->info_expl[$expl_id];
         $data['last_empr'] = $last_empr;
         //		 	printr($data['expl']);
         $tpl .= H2o::parseString($gen_tpl->piedpage)->render($data);
     }
     if ($this->info_expl[$expl_id]['serialcirc_diff']->no_ret_circ) {
         //pas de retour sur site, suppression de la circulation.
         $this->delete_diffusion($expl_id);
     }
     if ($charset != "utf-8") {
         $tpl = utf8_encode($tpl);
     }
     return $tpl;
 }
 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;
 }
 /**
  * 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));
 }
 /**
  * Retourne la liste à afficher
  * @param array $datas Liste des concepts formatés
  * @param string $template Nom du template à utiliser
  * @param array $parameters Paramètres qui influent sur la liste
  * @return string La liste à afficher
  */
 public static function render($datas, $template, $parameters = array())
 {
     global ${$template};
     return H2o::parseString(${$template})->render(array('concepts_list' => $datas, 'parameters' => $parameters));
 }
示例#17
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;
 }
示例#18
0
 /**
  * constructs the template from given source
  * 
  * @param $templateString string -- the template source
  */
 public function __construct($templateString = "")
 {
     $this->template = H2o::parseString($templateString, array("autoescape" => false));
 }
示例#19
0
 function getEnrichment($notice_id, $source_id, $type = "", $enrich_params = array())
 {
     global $charset;
     $params = $this->get_source_params($source_id);
     if ($params["PARAMETERS"]) {
         //Affichage du formulaire avec $params["PARAMETERS"]
         $vars = unserialize($params["PARAMETERS"]);
     }
     $enrichment = array();
     switch ($type) {
         case "artevod":
         default:
             $perso_params = new parametres_perso("notices");
             $perso_params->get_values($notice_id);
             $values = $perso_params->values;
             $link = "http://www.mediatheque-numerique.com/ws/films/" . $values[$vars['cp_field']][0];
             $infos = unserialize($this->parameters);
             $curl = new Curl();
             if (isset($infos['accesskey']) && $infos['accesskey']) {
                 $curl->set_option("CURLOPT_USERPWD", $infos['accesskey'] . ":" . $infos['secretkey']);
             }
             $result = $curl->get($link);
             $result = _parser_text_no_function_($result->body, "WSOBJECTQUERY");
             $content = "";
             $film = array();
             // Titre
             $film['title'] = $result['FILM'][0]['EDITORIAL'][0]['TITLE'][0]['value'];
             $film['original_title'] = $result['FILM'][0]['EDITORIAL'][0]['ORIGINAL_TITLE'][0]['value'];
             // Genres
             $film['genres'] = array();
             foreach ($result['FILM'][0]['EDITORIAL'][0]['GENRE'] as $genre) {
                 foreach ($genre['LABEL'] as $label) {
                     if ($label['LANG'] == 'fr') {
                         $film['genres'][] = $label['value'];
                     }
                 }
             }
             // Sous-genres
             $film['subgenres'] = array();
             foreach ($result['FILM'][0]['EDITORIAL'][0]['SUB_GENRE'] as $genre) {
                 foreach ($genre['LABEL'] as $label) {
                     if ($label['LANG'] == 'fr') {
                         $film['subgenres'][] = $label['value'];
                     }
                 }
             }
             // Auteurs
             $film['authors'] = array();
             foreach ($result['FILM'][0]['STAFF'][0]['AUTHORS'][0]['PERSON'] as $author) {
                 if ($author['FULL_NAME'][0]['value']) {
                     $film['authors'][] = $author['FULL_NAME'][0]['value'];
                 } else {
                     $film['authors'][] = $author['FIRST_NAME'][0]['value'] . " " . $author['LAST_NAME'][0]['value'];
                 }
             }
             // Acteurs
             $film['actors'] = array();
             foreach ($result['FILM'][0]['STAFF'][0]['ACTORS'][0]['PERSON'] as $actor) {
                 if ($actor['FULL_NAME'][0]['value']) {
                     $film['actors'][] = $actor['FULL_NAME'][0]['value'];
                 } else {
                     $film['actors'][] = $actor['FIRST_NAME'][0]['value'] . " " . $actor['LAST_NAME'][0]['value'];
                 }
             }
             // Couverture
             $film['poster'] = $result['FILM'][0]['MEDIA'][0]['POSTERS'][0]['MEDIA'][0]['SRC'];
             // Durée
             $film['duration'] = array('raw_value' => $result['FILM'][0]['TECHNICAL'][0]['DURATION'][0]['value'], 'format_value' => floor($result['FILM'][0]['TECHNICAL'][0]['DURATION'][0]['value'] / 60) . ":" . str_pad($result['FILM'][0]['TECHNICAL'][0]['DURATION'][0]['value'] % 60, 2, '0', STR_PAD_LEFT));
             // Description
             $film['description'] = $result['FILM'][0]['EDITORIAL'][0]['DESCRIPTION'][0]['value'];
             // Résumé
             $film['body'] = $result['FILM'][0]['EDITORIAL'][0]['BODY'][0]['value'];
             // Extraits
             $film['trailers'] = array();
             foreach ($result['FILM'][0]['MEDIA'][0]['TRAILERS'][0]['MEDIA'] as $trailer) {
                 $film['trailers'][] = $trailer['SRC'];
             }
             // Photos
             $film['photos'] = array();
             foreach ($result['FILM'][0]['MEDIA'][0]['PHOTOS'][0]['MEDIA'] as $photo) {
                 $film['photos'][] = $photo['SRC'];
             }
             // Public
             $film['target_audience'] = $result['FILM'][0]['TECHNICAL'][0]['TARGET_AUDIENCE'][0]['LABEL'][0]['value'];
             // Année de production
             $film['production_year'] = $result['FILM'][0]['TECHNICAL'][0]['PRODUCTION_YEAR'][0]['value'];
             // Pays de production
             $film['production_countries'] = array();
             foreach ($result['FILM'][0]['TECHNICAL'][0]['PRODUCTION_COUNTRIES'][0]['COUNTRY'] as $country) {
                 foreach ($country['LABEL'] as $label) {
                     if ($label['LANG'] == 'fr') {
                         $film['production_countries'] = $label['value'];
                     }
                 }
             }
             // Langues
             $film['languages'] = array();
             foreach ($result['FILM'][0]['TECHNICAL'][0]['LANGUAGES'][0]['LANGUAGE'] as $language) {
                 foreach ($language['LABEL'] as $label) {
                     if ($label['LANG'] == 'fr') {
                         $film['languages'] = $label['value'];
                     }
                 }
             }
             // Lien externe
             if ($result['FILM'][0]['EXTERNALURI'][0]['value']) {
                 $film['externaluri'] = $result['FILM'][0]['EXTERNALURI'][0]['value'];
                 if ($_SESSION['user_code'] && isset($infos['privatekey'])) {
                     global $empr_cb, $empr_nom, $empr_prenom, $empr_mail, $empr_year;
                     $id_encrypted = hash('sha256', $empr_cb . $infos['privatekey']);
                     $film['externaluri'] .= "?sso_id=mednum&id=" . $empr_cb . "&email=" . $empr_mail . "&nom=" . strtolower($empr_nom) . "&prenom=" . strtolower($empr_prenom) . "&dnaiss=" . $empr_year . "&id_encrypted=" . $id_encrypted;
                 }
             }
             $enrichment[$type]['content'] = H2o::parseString(stripslashes($vars['enrichment_template']))->render(array("film" => $film));
             break;
     }
     $enrichment['source_label'] = $this->msg['artevod_enrichment_source'];
     return $enrichment;
 }
示例#20
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;
 }
 public function render($datas)
 {
     global $opac_url_base;
     global $id_empr, $empr_cb, $empr_nom, $empr_prenom, $empr_adr1, $empr_adr2, $empr_cp, $empr_ville, $empr_mail, $empr_tel1, $empr_tel2, $empr_prof, $empr_year, $empr_categ, $empr_codestat, $empr_sexe, $empr_login, $empr_ldap, $empr_location;
     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'];
         $datas['session_vars']['empr_cb'] = $empr_cb;
         $datas['session_vars']['empr_nom'] = $empr_nom;
         $datas['session_vars']['empr_prenom'] = $empr_prenom;
         $datas['session_vars']['empr_adr1'] = $empr_adr1;
         $datas['session_vars']['empr_adr2'] = $empr_adr2;
         $datas['session_vars']['empr_cp'] = $empr_cp;
         $datas['session_vars']['empr_ville'] = $empr_ville;
         $datas['session_vars']['empr_mail'] = $empr_mail;
         $datas['session_vars']['empr_tel1'] = $empr_tel1;
         $datas['session_vars']['empr_tel2'] = $empr_tel2;
         $datas['session_vars']['empr_prof'] = $empr_prof;
         $datas['session_vars']['empr_year'] = $empr_year;
         $datas['session_vars']['empr_categ'] = $empr_categ;
         $datas['session_vars']['empr_codestat'] = $empr_codestat;
         $datas['session_vars']['empr_sexe'] = $empr_sexe;
         $datas['session_vars']['empr_login'] = $empr_login;
         $datas['session_vars']['empr_location'] = $empr_location;
     }
     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;
 }