|
|
|
@ -55,7 +55,7 @@ function tarteaucitron_liste_services_actifs($objet, $id_objet, $page, $recherch
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Retourne la liste des services TarteAuCitron et leur statut (enabled,disabled) |
|
|
|
|
* Retourne la liste des services TarteAuCitron et leur statut (installe,desinstalle) |
|
|
|
|
* |
|
|
|
|
* @return Array |
|
|
|
|
*/ |
|
|
|
@ -69,7 +69,7 @@ function tarteaucitron_liste_services() {
|
|
|
|
|
foreach($lines as $line) { |
|
|
|
|
if(preg_match('/^tarteaucitron\.services\.(\w+)/', $line, $matches)) { |
|
|
|
|
$service = $matches[1]; |
|
|
|
|
$statut = in_array($service,$services_installes) ? 'installe' : 'desinstalle'; |
|
|
|
|
$statut = ($services_installes[$service]) ? 'installe' : 'desinstalle'; |
|
|
|
|
|
|
|
|
|
if (preg_match('/"type": "(\w+)",/', $lines[$i+2], $matches)) { |
|
|
|
|
$type = $matches[1]; |
|
|
|
@ -77,7 +77,8 @@ function tarteaucitron_liste_services() {
|
|
|
|
|
|
|
|
|
|
$list_services[$service] = array( |
|
|
|
|
'type' => $type, |
|
|
|
|
'statut' => $statut |
|
|
|
|
'statut' => $statut, |
|
|
|
|
'hasKey' => ($services_installes[$service] == 'haskey') |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
$i++; |
|
|
|
@ -99,7 +100,7 @@ function tarteaucitron_liste_types_installes() {
|
|
|
|
|
|
|
|
|
|
foreach($services as $service => $prop) { |
|
|
|
|
if ($prop['statut']=='installe') { |
|
|
|
|
$list_types[$prop['type']][] = $service; |
|
|
|
|
$list_types[$prop['type']][$service] = $prop['hasKey']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -118,4 +119,53 @@ function tarteaucitron_dossier_squelettes() {
|
|
|
|
|
$dir_squelettes = $dir_racine . 'squelettes/'; |
|
|
|
|
|
|
|
|
|
return $dir_squelettes; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function tarteaucitron_scrap_service($service) { |
|
|
|
|
$tarteaucitron_url = 'https://tarteaucitron.io/fr/install/'; |
|
|
|
|
$html = file_get_contents($tarteaucitron_url); |
|
|
|
|
$ret['JS'] = ''; |
|
|
|
|
$ret['html'] = ''; |
|
|
|
|
|
|
|
|
|
$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'); |
|
|
|
|
|
|
|
|
|
$is_code_js_found = false; |
|
|
|
|
$nb_items = $span_elements->length; |
|
|
|
|
|
|
|
|
|
for($i=0; $i<$nb_items; $i++) { |
|
|
|
|
$child = $span_elements->item($i); |
|
|
|
|
$attributes = $child->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; |
|
|
|
|
} |
|
|
|
|
$s = $child->getElementsByTagName('s'); |
|
|
|
|
$child->removeChild($s[0]); |
|
|
|
|
$script = trim(strip_tags($child->nodeValue)); |
|
|
|
|
$script = preg_replace('/(\n\s+)/', "\n", $script); |
|
|
|
|
$script = str_replace("''","'",$script); |
|
|
|
|
$ret['JS'] = $script; |
|
|
|
|
$is_code_js_found = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO : récupérer le HTML pour le modèle |
|
|
|
|
$ret['html'] = "<p>Placez votre code HTML</p>"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $ret; |
|
|
|
|
|
|
|
|
|
} |