From b54e7a0b72982b396436dd47189b3520dd3f0b5e Mon Sep 17 00:00:00 2001 From: dj3c1t Date: Sat, 26 Oct 2013 15:26:11 +0200 Subject: [PATCH] nouveaux noms d'elements dans les fichiers XML des sources --- app/controllers/users/morceaux.php | 1 + .../modules/share/sml_data_sources_xml_format.php | 314 ++++++++++++++------- app/data/modules/sql/sml_data_source_groupes.php | 4 +- app/out/default/css/sourceml_accounts.css | 12 +- app/out/default/views/content/sources/xml_form.php | 22 ++ app/out/default/views/sources/source/header.php | 42 ++- 6 files changed, 281 insertions(+), 114 deletions(-) diff --git a/app/controllers/users/morceaux.php b/app/controllers/users/morceaux.php index 93cf57f..75414bc 100644 --- a/app/controllers/users/morceaux.php +++ b/app/controllers/users/morceaux.php @@ -390,6 +390,7 @@ ), isset($_POST["use_edit_reference_content"]) ? true : false ); + $morceau["licence"]["id"] = 0; } else{ if(!($morceau["titre"] = trim($_POST["titre"]))){ 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 1916bea..320ecee 100644 --- a/app/data/modules/share/sml_data_sources_xml_format.php +++ b/app/data/modules/share/sml_data_sources_xml_format.php @@ -1,7 +1,6 @@ env(); + 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["groupes"]) $this->groupes = $this->source["groupes"]; + if($this->status !== false){ + $this->source = isset($params["source"]) ? $params["source"] : $this->source($id, true); + if($this->source !== false){ + 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); - if($this->groupes !== false) - { $this->licence = isset($params["licence"]) ? $params["licence"] : $this->licence($this->source["licence"]["id"]); - if($this->licence !== false) - { if(($this->sources = $this->source_compositions(array("id_composition" => $id))) !== false) - { $content = "\n"; - if($this->source["derivations"]) - { foreach($this->source["derivations"] as $id_derivation => $derivation) - { $content .= " \n"; + if($this->groupes !== false){ + $this->licence = isset($params["licence"]) ? $params["licence"] : $this->licence($this->source["licence"]["id"]); + if($this->licence !== false){ + if(($this->sources = $this->source_compositions(array("id_composition" => $id))) !== false){ + $content = "\n"; + if($this->source["derivations"]){ + foreach($this->source["derivations"] as $id_derivation => $derivation){ + $content .= " \n"; } } - if($this->source["reference"]) $content .= " source["reference"]["xml"]["url"]."]]>\n"; - else - { $content .= - " source["titre"]."]]>\n" - ." url("sources/".$this->status[$this->source["status"]]["nom"]."/view", array($this->status[$this->source["status"]]["nom"] => $id))."]]>\n"; + if($this->source["reference"]) $content .= " source["reference"]["xml"]["url"]."\" />\n"; + else{ + $content .= + " <![CDATA[".$this->source["titre"]."]]>\n" + ." url("sources/".$this->status[$this->source["status"]]["nom"]."/view", array($this->status[$this->source["status"]]["nom"] => $id))."\" />\n"; + if(isset($this->source["image_uri"]) && $this->source["image_uri"]){ + $content .= + " path("web").$this->source["image_uri"]."\" />\n"; + } + if(isset($this->source["date_creation"]) && $this->source["date_creation"]){ + $content .= + " ".$this->source["date_creation"]."\n"; + } + if(isset($this->source["description"]) && $this->source["description"]){ + $content .= + " source["description"]."]]>\n"; + } $HAS_AUTHOR = false; - foreach($this->groupes as $id_groupe => $groupe) - { if($groupe["nom"] && $groupe["id_groupe_status"]) - { if - ( $groupe["id_groupe_status"] == $this->id_groupe_status_admin() + foreach($this->groupes as $id_groupe => $groupe){ + if($groupe["nom"] && $groupe["id_groupe_status"]){ + if( + $groupe["id_groupe_status"] == $this->id_groupe_status_admin() || $groupe["id_groupe_status"] == $this->id_groupe_status_editeur() - ) - { $content .= " \n"; + ){ + $content .= " \n"; $HAS_AUTHOR = true; } } else return false; } if(!$HAS_AUTHOR) return false; - foreach($this->source["documents"] as $id_document => $document) - { $content .= - " \n" - ." \n" - ." \n" + foreach($this->source["documents"] as $id_document => $document){ + $content .= + " \n" + ." \n" ." \n"; } - if($this->licence) - { $content .= - " licence["url"]."\">licence["nom"]."]]>\n"; + if($this->licence){ + $content .= + " licence["url"]."\">licence["nom"]."]]>\n"; } - if(isset($this->sources[$id])) - { foreach($this->sources[$id] as $id_source) - { $content .= " source_xml_url($id_source)."\" />\n"; + if(isset($this->sources[$id])){ + foreach($this->sources[$id] as $id_source){ + $content .= " source_xml_url($id_source)."\" />\n"; } } } @@ -83,26 +93,27 @@ # XML vers data # - function parse_source_xml($xml_content) - { if(!isset($this->sxml)) $this->sxml = new sxml(); + 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()) - { $source = array - ( "groupes" => array(), + function empty_source($params = array()){ + $source = array( + "groupes" => array(), "titre" => "", + "date_creation" => "", "from" => "", - "licence" => array - ( "nom" => "", + "licence" => array( + "nom" => "", "url" => "" ), "documents" => array(), "derivations" => array(), "reference" => array(), - "xml" => array - ( "url" => "", + "xml" => array( + "url" => "", "content" => "", "use_edit_content" => false ) @@ -111,61 +122,21 @@ return $source; } - 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); - $source["xml"] = array - ( "url" => $url, - "content" => $this->xml_content, - "use_edit_content" => false - ); - if($this->parse_source_xml($this->xml_content)) - { $this->buffer = $this->sxml->data["source"][0]; - foreach($this->buffer["subs"] as $key => $value) - { if($key == "auteur") - { $source["groupes"][] = array - ( "nom" => $value[0]["data"] - ); - } - elseif($key == "document") - { foreach($value as $id_document => $document) - { $source["documents"][$id_document] = array - ( "nom" => $document["subs"]["nom"][0]["data"], - "url" => $document["subs"]["url"][0]["data"] - ); - } - } - elseif($key == "derivation") - { $source["derivations"][] = array - ( "xml" => array - ( "url" => $value[0]["data"], - "content" => "", - "use_edit_content" => false - ) - ); - } - elseif($key == "reference") - { $source["reference"] = array - ( "xml" => array - ( "url" => $value[0]["data"], - "content" => "", - "use_edit_content" => false - ) - ); - } - elseif($key == "licence") - { $source["licence"] = array - ( "nom" => $value[0]["data"], - "url" => $value[0]["attrs"]["url"] - ); - } - else - { if(isset($value[0]["data"])) $source[$key] = $value[0]["data"]; - } + 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); + if($this->parse_source_xml($this->xml_content)){ + $source["xml"] = array( + "url" => $url, + "content" => $this->xml_content, + "use_edit_content" => false + ); + $this->buffer = $this->sxml->data["source"][0]; + if($source_xml_version = $this->get_source_buffer_xml_version()){ + $source = $this->parse_source_buffer($source_xml_version, $source); } - $source["auteur"] = ""; - foreach($source["groupes"] as $auteur) $source["auteur"] .= ($source["auteur"] ? ", " : "").$auteur["nom"]; + else return false; } else return false; } @@ -173,6 +144,147 @@ return $source; } + 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(){ + if(!isset($this->buffer["subs"])) return false; + foreach($this->buffer["subs"] as $key => $value){ + if($key == "titre" || $key == "auteur"){ + return "v1"; + } + if($key == "title" || $key == "author"){ + return "v2"; + } + } + } + + // -------------------------------------- source XML v2 + + 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; + foreach($this->buffer["subs"] as $key => $value){ + if($key == "title"){ + $source["titre"] = $value[0]["data"]; + } + elseif($key == "link"){ + $source["from"] = $value[0]["attrs"]["href"]; + } + elseif($key == "image"){ + $source["image"] = $value[0]["attrs"]["src"]; + } + elseif($key == "author"){ + foreach($value as $author){ + $source["groupes"][] = array( + "nom" => $author["data"], + "id_groupe_status" => 0 + ); + } + } + elseif($key == "date"){ + $source["date_creation"] = $value[0]["data"]; + } + elseif($key == "document"){ + foreach($value as $id_document => $document){ + $source["documents"][$id_document] = array( + "nom" => $document["data"], + "url" => $document["attrs"]["src"] + ); + } + } + elseif($key == "derivated_from"){ + $source["derivations"][] = array( + "xml" => array( + "url" => $value[0]["attrs"]["href"], + "content" => "", + "use_edit_content" => false + ) + ); + } + elseif($key == "reference"){ + $source["reference"] = array( + "xml" => array( + "url" => $value[0]["attrs"]["href"], + "content" => "", + "use_edit_content" => false + ) + ); + } + elseif($key == "licence"){ + $source["licence"] = array( + "id" => 0, + "nom" => $value[0]["data"], + "url" => $value[0]["attrs"]["href"] + ); + } + else{ + if(isset($value[0]["data"])) $source[$key] = $value[0]["data"]; + } + } + $source["auteur"] = ""; + foreach($source["groupes"] as $auteur) $source["auteur"] .= ($source["auteur"] ? ", " : "").$auteur["nom"]; + return $source; + } + + // -------------------------------------- source XML v1 + + 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; + foreach($this->buffer["subs"] as $key => $value){ + if($key == "auteur"){ + $source["groupes"][] = array( + "nom" => $value[0]["data"] + ); + } + elseif($key == "document"){ + foreach($value as $id_document => $document){ + $source["documents"][$id_document] = array( + "nom" => $document["subs"]["nom"][0]["data"], + "url" => $document["subs"]["url"][0]["data"] + ); + } + } + elseif($key == "derivation"){ + $source["derivations"][] = array( + "xml" => array( + "url" => $value[0]["data"], + "content" => "", + "use_edit_content" => false + ) + ); + } + elseif($key == "reference"){ + $source["reference"] = array( + "xml" => array( + "url" => $value[0]["data"], + "content" => "", + "use_edit_content" => false + ) + ); + } + elseif($key == "licence"){ + $source["licence"] = array( + "nom" => $value[0]["data"], + "url" => $value[0]["attrs"]["url"] + ); + } + else{ + if(isset($value[0]["data"])) $source[$key] = $value[0]["data"]; + } + } + $source["auteur"] = ""; + foreach($source["groupes"] as $auteur) $source["auteur"] .= ($source["auteur"] ? ", " : "").$auteur["nom"]; + return $source; + } + } ?> \ No newline at end of file diff --git a/app/data/modules/sql/sml_data_source_groupes.php b/app/data/modules/sql/sml_data_source_groupes.php index 45d07b1..e2fb23f 100644 --- a/app/data/modules/sql/sml_data_source_groupes.php +++ b/app/data/modules/sql/sml_data_source_groupes.php @@ -198,8 +198,8 @@ function get_editor_groupes($groupes){ $editor_groupes = array(); - if(is_array($groupes)) foreach($groupes as $source_groupe) - { if( + if(is_array($groupes)) foreach($groupes as $source_groupe){ + if( $source_groupe["id_groupe_status"] == $this->id_groupe_status_admin() || $source_groupe["id_groupe_status"] == $this->id_groupe_status_editeur() ){ diff --git a/app/out/default/css/sourceml_accounts.css b/app/out/default/css/sourceml_accounts.css index 1354534..e435031 100644 --- a/app/out/default/css/sourceml_accounts.css +++ b/app/out/default/css/sourceml_accounts.css @@ -49,14 +49,22 @@ ul.xml_infos li color: #c0c0c0; } -.admin_source_infos ul.admin_source_head -{ list-style-type: none; +.admin_source_infos p.logo_source{ + float: left; +} + +.admin_source_infos ul.admin_source_head{ + float: right; + list-style-type: none; margin: 0px 0px 0px 0px; text-align: right; padding-bottom: 10px; padding-top: 5px; } +.admin_source_infos .admin_source_url{ + margin-top: 10px; +} #documents .document { border: solid 1px #c0c0c0; diff --git a/app/out/default/views/content/sources/xml_form.php b/app/out/default/views/content/sources/xml_form.php index 3b01a82..faa21c2 100644 --- a/app/out/default/views/content/sources/xml_form.php +++ b/app/out/default/views/content/sources/xml_form.php @@ -19,9 +19,30 @@
+ img_size($source["image"], 150, 150)) !== false + ) : + + ?> +

+ "> + " + width="" + height="" + alt="" /> + +

+ +
URL du fichier XML : " />
diff --git a/app/out/default/views/sources/source/header.php b/app/out/default/views/sources/source/header.php index b32a289..31e1adf 100644 --- a/app/out/default/views/sources/source/header.php +++ b/app/out/default/views/sources/source/header.php @@ -1,7 +1,18 @@ get_editor_groupes($source["reference"] ? $source["reference"]["groupes"] : $source["groupes"]); - foreach($groupes as $k => $groupe) $groupes[$k]["url"] = $this->url("sources/groupe/view", array("id" => $groupe["id"])); + if($source["reference"]){ + $groupes = array(); + foreach($source["reference"]["groupes"] as $groupe){ + $groupes[] = array( + "nom" => $groupe["nom"], + "url" => $source["reference"] ? $source["reference"]["from"] : $source["url"] + ); + } + } + else{ + $groupes = $data->get_editor_groupes($source["reference"] ? $source["reference"]["groupes"] : $source["groupes"]); + foreach($groupes as $k => $groupe) $groupes[$k]["url"] = $this->url("sources/groupe/view", array("id" => $groupe["id"])); + } ?>
@@ -17,13 +28,26 @@ img_size($source["image_uri"], 100, 100)) !== false - ) : - $source_image_uri = $this->path("web").$source["image_uri"]; - $HAS_IMAGE = true; + if($source["reference"]){ + if + ( $source["reference"]["image"] + && ($img_size = $data->img_size($source["reference"]["image"], 100, 100)) !== false + ){ + $HAS_IMAGE = true; + $source_image_uri = $source["reference"]["image"]; + } + } + else{ + if + ( $source["image_uri"] + && file_exists($source["image_uri"]) + && ($img_size = $data->img_size($source["image_uri"], 100, 100)) !== false + ){ + $HAS_IMAGE = true; + $source_image_uri = $this->path("web").$source["image_uri"]; + } + } + if($HAS_IMAGE) : ?>

-- 2.1.4