This repository has been archived by the owner on May 5, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
début de plugin complémentaire pour update des metadatas des document…
…s cf #11
- Loading branch information
Showing
4 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
geodiversite_complements/geodiversite_metadatas/genie/geol_metadatas_update.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
if (!defined('_ECRIRE_INC_VERSION')) return; | ||
|
||
function genie_geol_metadatas_update_dist($t) { | ||
// nombre de documents traités par iteration | ||
$nb_docs = @define('_GEOL_METADATAS_NB_DOCS',5); | ||
$extensions = array('jpg'); | ||
if ($documents = sql_select("*", "spip_documents", sql_in("extensions", $extensions) ." AND geol_metadatas = 'non'", "", "maj", "0,".intval($nb_docs+1))) { | ||
while($nb_docs-- AND $row = sql_fetch($documents)) { | ||
include_spip('inc/distant'); | ||
include_spip('inc/documents'); | ||
// le fichier existe-t-il/est-il accessible ? | ||
if (!$fichier = copie_locale(get_spip_doc($row['fichier']), 'test')) { | ||
// le fichier n'est pas accessible, on log mais on poursuit pour les autres | ||
spip_log('Pas de copie locale de '.$row['fichier'], "geol_metadatas"); | ||
// et on met le statut en erreur | ||
sql_updateq("spip_documents", array('geol_metadatas' => 'err'), "id_document=".intval($row['id_document'])); | ||
}else{ | ||
// le fichier existe, on update | ||
|
||
} | ||
} | ||
if ($row = sql_fetch($documents)) { | ||
spip_log("il reste des docs a indexer...", "geol_metadatas"); | ||
return 0-$t; // il y a encore des docs a indexer | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
?> |
37 changes: 37 additions & 0 deletions
37
geodiversite_complements/geodiversite_metadatas/geol_metadatas_administrations.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
if (!defined('_ECRIRE_INC_VERSION')) return; | ||
|
||
/** | ||
* Fonction d'installation et de mise à jour du plugin. | ||
* | ||
* Ajoute le champ sur la table spip_documents | ||
* | ||
* @param string $nom_meta_base_version | ||
* Le nom de la meta d'installation | ||
* @param float $version_cible | ||
* Le numéro de version vers laquelle mettre à jour | ||
*/ | ||
function geol_metadatas_upgrade($nom_meta_base_version, $version_cible) { | ||
$maj = array(); | ||
$maj['create'] = array( | ||
array('sql_alter',"TABLE spip_documents ADD geol_metadatas VARCHAR(3) NOT NULL default 'non'"), | ||
); | ||
include_spip('base/upgrade'); | ||
maj_plugin($nom_meta_base_version, $version_cible, $maj); | ||
} | ||
|
||
/** | ||
* Fonction de désinstallation du plugin. | ||
* | ||
* Supprime le champ sur la table spip_documents et la meta d'installation du plugin | ||
* | ||
* @param string $nom_meta_base_version | ||
* Le nom de la meta d'installation | ||
*/ | ||
function geol_metadatas_vider_tables($nom_meta_base_version) { | ||
sql_alter("TABLE spip_documents DROP geol_metadatas"); | ||
effacer_meta($nom_meta_base_version); | ||
} | ||
|
||
?> |
21 changes: 21 additions & 0 deletions
21
geodiversite_complements/geodiversite_metadatas/geol_metadatas_pipelines.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
if (!defined('_ECRIRE_INC_VERSION')) return; | ||
|
||
/** | ||
* Insertion dans le pipeline taches_generales_cron | ||
* | ||
* Vérifie la présence à intervalle régulier de fichiers à mettre à jour | ||
* | ||
* @param array $taches_generales Un array des tâches du cron de SPIP | ||
* @return L'array des taches complété | ||
*/ | ||
function geol_metadatas_taches_generales_cron($taches_generales) { | ||
|
||
@define('_GEOL_METADATAS_INTERVALLE_CRON',120); // toutes les 2 minutes | ||
$taches_generales['geol_metadatas_update'] = _GEOL_METADATAS_INTERVALLE_CRON; | ||
|
||
return $taches_generales; | ||
} | ||
|
||
?> |
27 changes: 27 additions & 0 deletions
27
geodiversite_complements/geodiversite_metadatas/paquet.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<paquet | ||
prefix="geol_metadatas" | ||
categorie="squelette" | ||
version="1.0.0" | ||
schema="1.0.0" | ||
etat="test" | ||
compatibilite="[3.0.0;3.0.99]" | ||
logo="images/geol_metadatas.png" | ||
> | ||
|
||
<nom>Géodiversité - Metadatas</nom> | ||
<!-- Complément metadatas pour Géodiversité --> | ||
|
||
<auteur>b_b</auteur> | ||
|
||
<copyright>2013</copyright> | ||
|
||
<licence lien="http://www.gnu.org/licenses/gpl-3.0.html">GPL 3</licence> | ||
|
||
<pipeline nom="declarer_tables_principales" inclure="base/geol_metadatas.php" /> | ||
<pipeline nom="taches_generales_cron" inclure="geol_metadatas_pipelines.php" /> | ||
|
||
<necessite nom="geol" compatibilite="[1.3.2;[" /> | ||
<necessite nom="gis" compatibilite="[4.0.0;[" /> | ||
<necessite nom="photo_infos" compatibilite="[2.0.1;[" /> | ||
|
||
</paquet> |