Commit 0ce3505f authored by dj3c1t's avatar dj3c1t

affichage source dérivations

parent 2df51592
......@@ -90,7 +90,6 @@ class SourceController extends Controller {
)
)->getResult();
}
return new RestResponse(
json_encode(
array(
......@@ -108,4 +107,26 @@ class SourceController extends Controller {
);
}
public function sourceDerivationsAction(Request $request, Source $source) {
$sources = array();
if(!$source->isReference()) {
$sources = $this->get('sourceml.source_manager')->getDerivations($source);
}
return new RestResponse(
json_encode(
array(
"error" => false,
"data" => array(
"source_list" => $this->get('twig')->render(
'Dj3c1tSourceMLBundle:Source:Source/list.html.twig',
array(
"sources" => $sources
)
)
)
)
)
);
}
}
......@@ -48,6 +48,10 @@ source_composition_sources:
path: /source/composition/sources/{source}
defaults: { _controller: Dj3c1tSourceMLBundle:Source/Source:compositionSources }
source_source_derivations:
path: /source/derivations/{source}
defaults: { _controller: Dj3c1tSourceMLBundle:Source/Source:sourceDerivations }
# -------------------------------------------------------------------
# Admin
#
......
......@@ -112,5 +112,16 @@
<div class="loaded"></div>
</div>
{% endif %}
{% set derivations = sourceml.getDerivations(source) %}
{% if derivations|length > 0 %}
<div class="source_derivations">
<button class="btn btn-default toggle_source_derivations" data-source-id="{{ source.id }}" style="margin-bottom: 1em;">
<span class="glyphicon glyphicon-chevron-down"></span>
Dérivations
<i class="loading glyphicon glyphicon-repeat glyphicon-rotate"></i>
</button>
<div class="loaded"></div>
</div>
{% endif %}
</div>
</section>
......@@ -62,6 +62,41 @@ $(document).ready(
}
);
$(".toggle_source_derivations").click(
function() {
var source_id = $(this).data("source-id");
var contentDiv = $("#source_" + source_id + " .source_derivations .loaded").first();
if(contentDiv.html()) {
contentDiv.slideUp(
400,
function() {
contentDiv.html("");
}
);
return;
}
var toggle_button = $(this);
var loading = toggle_button.parents(".source_derivations").first().find(".loading");
loading.show();
var url = "{{ path('source_source_derivations', {source: 1111}) }}";
url = url.replace("1111", source_id);
$.get(
url,
function(response) {
loading.hide();
if(response["error"]) {
app_message("danger", toggle_button.closest(".source"), response["error"]);
return;
}
contentDiv.hide();
contentDiv.html(response["data"]["source_list"]);
contentDiv.slideDown();
init_players(contentDiv);
}
);
}
);
$(".toggle_source_xml_view").click(
function() {
var xmlPre = $(this).parents(".source_xml_view").first().find("pre");
......
......@@ -312,6 +312,19 @@ class SourceManager {
return $playerAudioFiles;
}
public function getDerivations(Source $source) {
$derivations = array();
if($source->getId()) {
$em = $this->container->get('doctrine')->getManager();
$derivationRepo = $em->getRepository("Dj3c1tSourceMLBundle:DerivationSource");
$derivationSources = $derivationRepo->findByUrl($source->getXmlUrl());
foreach($derivationSources as $derivationSource) {
$derivations[] = $derivationSource->getSource();
}
}
return $derivations;
}
public function remove(Source $source) {
$em = $this->container->get('doctrine')->getManager();
if($media = $source->getImage()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment