".$this->get_format_data_structure_tree($this->get_form_value_name("query"))."
"; return $form; } public function save_form(){ $this->parameters['query'] = stripslashes($this->get_value_from_form("query")); return parent::save_form(); } 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' => 10 ); $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)); } } }catch(Exception $e){ $rows = array(); } } } $this->debug($query); $datas['result'] = $rows; return $datas; } public function get_manage_form(){ global $base_path; //variables persos... global $cms_store; global $cms_store_delete; if(!$this->managed_datas) $this->managed_datas = array(); if($this->managed_datas['stores'][$cms_store_delete]) unset($this->managed_datas['stores'][$cms_store_delete]); $form="
"; if($this->managed_datas['stores']){ foreach($this->managed_datas['stores'] as $key => $infos){ $form.="

".$this->format_text($infos['name'])."   ".$this->format_text($this->msg[

"; } } $form.=" ".$this->format_text($this->msg['cms_module_sparql_datasource_sparql_add_store']).""; $form.="
"; if($cms_store){ $form.=$this->get_managed_form_start(array('cms_store'=>$cms_store)); $form.=$this->get_managed_store_form($cms_store); $form.=$this->get_managed_form_end(); } $form.="
"; return $form; } protected function get_managed_store_form($cms_store){ global $opac_url_base; global $cms_module_sparql_datasource_sparql_managed_store_type; global $selector_choice; if($cms_store != "new"){ $infos = $this->managed_datas['stores'][$cms_store]; }else{ $infos = array( 'name' => "Nouveau store", 'selector' => "", 'selector_id' => 0, 'content' => $this->default_store ); } //nom $form.="
"; $selectors = $this->get_managed_selectors(); $form.= "
"; $form.="
"; if($infos['selector']){ $form.=" "; } return $form; } public function save_manage_form($managed_datas){ global $cms_store; global $cms_store_delete; global $cms_module_sparql_datasource_sparql_managed_storename; global $selector_choice; if($cms_store_delete){ if($managed_datas['stores'][$cms_store_delete]['selector']){ $selector = new $managed_datas['stores'][$cms_store_delete]['selector']($managed_datas['stores'][$cms_store_delete]['selector_id']); $selector->delete(); } unset($managed_datas['stores'][$cms_store_delete]); }else{ if($cms_store == "new"){ $cms_store = "store".(self::get_max_store_id($managed_datas['stores'])+1); $selector = new $selector_choice(); }else{ $selector = new $selector_choice($managed_datas['stores'][$cms_store]['selector_id']); } $result = $selector->save_form(); if($result){ $managed_datas['stores'][$cms_store] = array( 'name' => stripslashes($cms_module_sparql_datasource_sparql_managed_storename), 'selector' => stripslashes($selector_choice), 'selector_id' => stripslashes($selector->id) ); } } return $managed_datas; } protected function get_max_store_id($datas){ $max = 0; if(count($datas)){ foreach ($datas as $key => $val){ $key = str_replace("store","",$key)*1; if($key>$max) $max = $key; } } return $max; } public function get_format_data_structure_tree($textarea){ $html = "
"; return $html; } public function get_format_datasource_data_structure(){ // $this->debug($GLOBALS,CMS_DEBUG_MODE_FILE);na $postdatas = $getdatas = $datas = array(); foreach($this->cms_build_env['get'] as $key => $value){ $getdatas[] = array( 'var' => "get_vars.".$key, 'desc'=> "", ); } $datas[] = array( 'var' => "get", 'desc'=> "", 'children' => $getdatas ); foreach($this->cms_build_env['post'] as $key => $value){ $postdatas[] = array( 'var' => "post_vars.".$key, 'desc'=> "", ); } $datas[] = array( 'var' => "post", 'desc'=> "", 'children' => $postdatas ); return $datas; } }