You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

70 lines
1.7 KiB

<?php
/**
* Fonctions partagées entre les passes de compilation
*/
namespace autodoc\Plugin\Core\Compiler\Pass;
use phpDocumentor\Compiler\CompilerPassInterface;
use phpDocumentor\Descriptor\Collection;
use phpDocumentor\Descriptor\ProjectDescriptor;
/**
* Fonctions partagées
*/
class SpipShare
{
const URL_CODE_SPIP = "https://code.spip.net/autodoc/";
const URL_FQSEN_SPIP = "https://code.spip.net/autodoc/fqsen_data.xml";
/**
* Est-ce une arborescence du logiciel SPIP complet ?
*
* @param ProjectDescriptor $project
* @return bool
**/
public static function is_spip(ProjectDescriptor $project) {
/**
* @var bool|null $is_spip
**/
static $is_spip = null;
if (is_null($is_spip)) {
$fqsen = "./ecrire/inc_version.php";
$is_spip = (bool) $project->getIndexes()->get('elements')->get($fqsen);
}
return $is_spip;
}
/**
* Liste des fqsen => url des éléments de SPIP
*
* @param ProjectDescriptor $project
* @return bool
**/
public static function getAllSpipFqsen() {
/**
* @var bool|null $liste
**/
static $liste = null;
if (is_null($liste)) {
$items = simplexml_load_file(SpipShare::URL_FQSEN_SPIP);
$liste = new \ArrayObject();
if ($items) {
foreach ($items as $item) {
$liste[ (string)$item['fqsen'] ] = SpipShare::URL_CODE_SPIP . (string)$item['url'];
}
unset($item, $items);
} else {
// Impossible de récupérer le fichier :/
}
}
return $liste;
}
}