|
|
|
@ -78,7 +78,7 @@ function tarteaucitron_liste_services() {
|
|
|
|
|
$list_services[$service] = array( |
|
|
|
|
'type' => $type, |
|
|
|
|
'statut' => $statut, |
|
|
|
|
'hasKey' => ($services_installes[$service] == 'haskey') |
|
|
|
|
'params' => $services_installes[$service] |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
$i++; |
|
|
|
@ -100,7 +100,7 @@ function tarteaucitron_liste_types_installes() {
|
|
|
|
|
|
|
|
|
|
foreach($services as $service => $prop) { |
|
|
|
|
if ($prop['statut']=='installe') { |
|
|
|
|
$list_types[$prop['type']][$service] = $prop['hasKey']; |
|
|
|
|
$list_types[$prop['type']][$service] = $prop['params']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -126,34 +126,42 @@ function tarteaucitron_scrap_service($service) {
|
|
|
|
|
$html = file_get_contents($tarteaucitron_url); |
|
|
|
|
$ret['JS'] = ''; |
|
|
|
|
$ret['html'] = ''; |
|
|
|
|
$ret['params'] = array(); |
|
|
|
|
|
|
|
|
|
$doc = new DOMDocument('1.0', 'UTF-8'); |
|
|
|
|
$internalErrors = libxml_use_internal_errors(true); |
|
|
|
|
$doc->loadHTML($html); |
|
|
|
|
libxml_use_internal_errors($internalErrors); |
|
|
|
|
|
|
|
|
|
$elem = $doc->getElementById('s_' . $service); |
|
|
|
|
$id = $elem->lastChild->attributes['id']->value; |
|
|
|
|
$elem = $doc->getElementById('m' . $id); |
|
|
|
|
$span_elements = $elem->getElementsByTagName('span'); |
|
|
|
|
$div_service = $doc->getElementById('s_' . $service); |
|
|
|
|
$id = $div_service->lastChild->attributes['id']->value; |
|
|
|
|
$div_code = $doc->getElementById('m' . $id); |
|
|
|
|
$span_list = $div_code->getElementsByTagName('span'); |
|
|
|
|
|
|
|
|
|
$is_code_js_found = false; |
|
|
|
|
$nb_items = $span_elements->length; |
|
|
|
|
$nb_items = $span_list->length; |
|
|
|
|
|
|
|
|
|
for($i=0; $i<$nb_items; $i++) { |
|
|
|
|
$child = $span_elements->item($i); |
|
|
|
|
$attributes = $child->attributes; |
|
|
|
|
$span = $span_list->item($i); |
|
|
|
|
$attributes = $span->attributes; |
|
|
|
|
|
|
|
|
|
foreach($attributes as $attr_name => $attr) { |
|
|
|
|
if ($attr_name == "class" && $attr->value == "code" && !$is_code_js_found) { |
|
|
|
|
$b = $child->getElementsByTagName('b'); |
|
|
|
|
if ($b->length != 0) { |
|
|
|
|
$newelement = $doc->createTextNode("'#CONFIG{tarteaucitron/services/" . $service . "key}'"); |
|
|
|
|
$child->replaceChild($newelement,$b[0]); |
|
|
|
|
$ret['hasKey'] = true; |
|
|
|
|
$param_list = $span->getElementsByTagName('b'); |
|
|
|
|
$j = $param_list->length -1; |
|
|
|
|
|
|
|
|
|
while ($j > -1) { |
|
|
|
|
$param = $param_list[$j]; |
|
|
|
|
$nom_param = str_replace(" ","_",$param->textContent); |
|
|
|
|
$newelement = $doc->createTextNode("'#CONFIG{tarteaucitron/services/" . $service . "_" . $nom_param . "}'"); |
|
|
|
|
$span->replaceChild($newelement,$param); |
|
|
|
|
$ret['params'][] = $nom_param; |
|
|
|
|
$j--; |
|
|
|
|
} |
|
|
|
|
$s = $child->getElementsByTagName('s'); |
|
|
|
|
$child->removeChild($s[0]); |
|
|
|
|
$script = trim(strip_tags($child->nodeValue)); |
|
|
|
|
|
|
|
|
|
$s = $span->getElementsByTagName('s'); |
|
|
|
|
$span->removeChild($s[0]); |
|
|
|
|
$script = trim(strip_tags($span->nodeValue)); |
|
|
|
|
$script = preg_replace('/(\n\s+)/', "\n", $script); |
|
|
|
|
$script = str_replace("''","'",$script); |
|
|
|
|
$ret['JS'] = $script; |
|
|
|
@ -165,7 +173,6 @@ function tarteaucitron_scrap_service($service) {
|
|
|
|
|
// TODO : récupérer le HTML pour le modèle |
|
|
|
|
$ret['html'] = "<p>Placez votre code HTML</p>"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $ret; |
|
|
|
|
|
|
|
|
|
} |