X-Git-Url: http://git.dj3c1t.com/index.cgi?a=blobdiff_plain;f=app%2Fdata%2Fmodules%2Fshare%2Fsml_data_sources_xml_format.php;h=e9d280435e4dfb7bad8fa49fe58d2fea4d5f61cd;hb=HEAD;hp=320ecee342af9af313b1a64118f42759a85a35c6;hpb=b54e7a0b72982b396436dd47189b3520dd3f0b5e;p=mw_sourceml diff --git a/app/data/modules/share/sml_data_sources_xml_format.php b/app/data/modules/share/sml_data_sources_xml_format.php index 320ecee..e9d2804 100644 --- a/app/data/modules/share/sml_data_sources_xml_format.php +++ b/app/data/modules/share/sml_data_sources_xml_format.php @@ -2,24 +2,27 @@ class sml_data_sources_xml_format extends mw_data{ - var $status; // classes de sources - table sml_classes - var $source; - var $groupes; - var $licence; - var $sources; - var $xml_content; + public $status; // classes de sources - table sml_classes + public $source; + public $groupes; + public $licence; + public $sources; + public $xml_content; # ---------------------------------------------------------------------------------------- # data vers XML # - function source_xml_content($id, $params = array()){ + public function source_xml_content($id, $params = array()){ $env = $this->env(); $content = false; $this->status = isset($this->status) ? $this->status : $this->source_status(); if($this->status !== false){ $this->source = isset($params["source"]) ? $params["source"] : $this->source($id, true); if($this->source !== false){ + if($this->source["reference"]){ + return $this->source["reference"]["xml"]["content"]; + } if($this->source["groupes"]) $this->groupes = $this->source["groupes"]; if(isset($params["groupes"])) $this->groupes = $params["groupes"]; if(!isset($this->groupes)) $this->groupes = $this->source_groupes($id); @@ -30,10 +33,10 @@ $content = "\n"; if($this->source["derivations"]){ foreach($this->source["derivations"] as $id_derivation => $derivation){ - $content .= " \n"; + $content .= " \n"; } } - if($this->source["reference"]) $content .= " source["reference"]["xml"]["url"]."\" />\n"; + if($this->source["reference"]) $content .= " source["reference"]["xml"]["url"]."\" />\n"; else{ $content .= " <![CDATA[".$this->source["titre"]."]]>\n" @@ -93,13 +96,13 @@ # XML vers data # - function parse_source_xml($xml_content){ + public function parse_source_xml($xml_content){ if(!isset($this->sxml)) $this->sxml = new sxml(); $this->sxml->parse($xml_content); return isset($this->sxml->data["source"][0]); } - function empty_source($params = array()){ + public function empty_source($params = array()){ $source = array( "groupes" => array(), "titre" => "", @@ -122,7 +125,7 @@ return $source; } - function source_xml_read($url, $xml_content = null){ + public function source_xml_read($url, $xml_content = null){ $source = $this->empty_source(); if($this->xml_content = (isset($xml_content) ? $xml_content : $this->get_source_xml_from_url($url))){ if($this->xml_content === -1) $this->xml_content = $this->get_source_xml_from_url($url, true); @@ -144,14 +147,14 @@ return $source; } - function parse_source_buffer($source_xml_version, $default_source = null){ + public function parse_source_buffer($source_xml_version, $default_source = null){ if(method_exists($this, $method_name = "parse_source_buffer_".$source_xml_version)){ return $this->$method_name($default_source); } return false; } - function get_source_buffer_xml_version(){ + public function get_source_buffer_xml_version(){ if(!isset($this->buffer["subs"])) return false; foreach($this->buffer["subs"] as $key => $value){ if($key == "titre" || $key == "auteur"){ @@ -165,7 +168,7 @@ // -------------------------------------- source XML v2 - function parse_source_buffer_v2($default_source = null){ + public function parse_source_buffer_v2($default_source = null){ if(isset($default_source)) $source = $default_source; else $source = $this->empty_source(); if(!isset($this->buffer["subs"])) return $source; @@ -201,7 +204,7 @@ elseif($key == "derivated_from"){ $source["derivations"][] = array( "xml" => array( - "url" => $value[0]["attrs"]["href"], + "url" => $value[0]["attrs"]["src"], "content" => "", "use_edit_content" => false ) @@ -210,7 +213,7 @@ elseif($key == "reference"){ $source["reference"] = array( "xml" => array( - "url" => $value[0]["attrs"]["href"], + "url" => $value[0]["attrs"]["src"], "content" => "", "use_edit_content" => false ) @@ -234,7 +237,7 @@ // -------------------------------------- source XML v1 - function parse_source_buffer_v1($default_source = null){ + public function parse_source_buffer_v1($default_source = null){ if(isset($default_source)) $source = $default_source; else $source = $this->empty_source(); if(!isset($this->buffer["subs"])) return $source; @@ -286,5 +289,3 @@ } } - -?> \ No newline at end of file