Browse Source

Début de la sortie des brèves du core... (Boucles, Descriptions de tables et boutons)

svn/root/tags/plugins/breves/1.0 v1.0
marcimat@rezo.net 13 years ago
commit
97f2921bbd
  1. 7
      .gitattributes
  2. 94
      base/breves.php
  3. 49
      base/breves_upgrade.php
  4. 24
      breves_autoriser.php
  5. 29
      breves_pipelines.php
  6. 49
      plugin.xml
  7. 37
      public/breves.php

7
.gitattributes vendored

@ -0,0 +1,7 @@
* text=auto !eol
base/breves.php -text
base/breves_upgrade.php -text
/breves_autoriser.php -text
/breves_pipelines.php -text
/plugin.xml -text
public/breves.php -text

94
base/breves.php

@ -0,0 +1,94 @@
<?php
/***************************************************************************\
* SPIP, Systeme de publication pour l'internet *
* *
* Copyright (c) 2001-2010 *
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
/**
* Interfaces des tables breves pour le compilateur
*
* @param array $interfaces
* @return array
*/
function breves_declarer_tables_interfaces($interfaces) {
$interfaces['table_des_tables']['breves'] = 'breves';
$interfaces['exceptions_des_tables']['breves']['id_secteur'] = 'id_rubrique';
$interfaces['exceptions_des_tables']['breves']['date'] = 'date_heure';
$interfaces['exceptions_des_tables']['breves']['nom_site'] = 'lien_titre';
$interfaces['exceptions_des_tables']['breves']['url_site'] = 'lien_url';
$interfaces['table_titre']['breves'] = 'titre, lang';
$interfaces['table_date']['breves'] = 'date_heure';
$interfaces['tables_jointures']['spip_breves'][]= 'documents_liens';
$interfaces['table_des_traitements']['LIEN_TITRE'][]= _TRAITEMENT_TYPO;
$interfaces['table_des_traitements']['LIEN_URL'][]= 'vider_url(%s)';
return $interfaces;
}
/**
* Table principale spip_breves
*
* @param array $tables_principales
* @return array
*/
function breves_declarer_tables_principales($tables_principales) {
$spip_breves = array(
"id_breve" => "bigint(21) NOT NULL",
"date_heure" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
"titre" => "text DEFAULT '' NOT NULL",
"texte" => "longtext DEFAULT '' NOT NULL",
"lien_titre" => "text DEFAULT '' NOT NULL",
"lien_url" => "text DEFAULT '' NOT NULL",
"statut" => "varchar(6) DEFAULT '0' NOT NULL",
"id_rubrique" => "bigint(21) DEFAULT '0' NOT NULL",
"lang" => "VARCHAR(10) DEFAULT '' NOT NULL",
"langue_choisie" => "VARCHAR(3) DEFAULT 'non'",
"maj" => "TIMESTAMP");
$spip_breves_key = array(
"PRIMARY KEY" => "id_breve",
"KEY id_rubrique" => "id_rubrique",
);
$spip_breves_join = array(
"id_breve"=>"id_breve",
"id_rubrique"=>"id_rubrique");
$tables_principales['spip_breves'] =
array('field' => &$spip_breves, 'key' => &$spip_breves_key,'join' => &$spip_breves_join);
return $tables_principales;
}
/**
* Declarer le surnom des breves
*
* @param array $surnoms
* @return array
*/
function breves_declarer_tables_objets_surnoms($surnoms) {
$surnoms['breve'] = "breves";
return $surnoms;
}
?>

49
base/breves_upgrade.php

@ -0,0 +1,49 @@
<?php
/***************************************************************************\
* SPIP, Systeme de publication pour l'internet *
* *
* Copyright (c) 2001-2010 *
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
/**
* Installation/maj des tables breves
*
* @param string $nom_meta_base_version
* @param string $version_cible
*/
function breves_upgrade($nom_meta_base_version,$version_cible){
$current_version = 0.0;
if ( (!isset($GLOBALS['meta'][$nom_meta_base_version]) )
|| (($current_version = $GLOBALS['meta'][$nom_meta_base_version])!=$version_cible)){
if ($current_version==0.0){
include_spip('base/create');
// creer les tables
creer_base();
// mettre les metas par defaut
$config = charger_fonction('config','inc');
$config();
ecrire_meta($nom_meta_base_version,$current_version=$version_cible);
}
}
}
/**
* Desinstallation/suppression des tables breves
*
* @param string $nom_meta_base_version
*/
function breves_vider_tables($nom_meta_base_version) {
sql_drop_table("spip_breves");
effacer_meta("activer_breves");
effacer_meta($nom_meta_base_version);
}
?>

24
breves_autoriser.php

@ -0,0 +1,24 @@
<?php
/***************************************************************************\
* SPIP, Systeme de publication pour l'internet *
* *
* Copyright (c) 2001-2010 *
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
// pour le pipeline d'autorisation
function breves_autoriser(){}
// bouton du bandeau
function autoriser_breves_bouton_dist($faire, $type='', $id=0, $qui = NULL, $opt = NULL){
return ($GLOBALS['meta']["activer_breves"] != "non");
}
?>

29
breves_pipelines.php

@ -0,0 +1,29 @@
<?php
/***************************************************************************\
* SPIP, Systeme de publication pour l'internet *
* *
* Copyright (c) 2001-2010 *
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined("_ECRIRE_INC_VERSION")) return;
/**
* Definir les meta de configuration liee aux breves
*
* @param array $metas
* @return array
*/
function breves_configurer_liste_metas($metas){
$metas['activer_breves'] = 'non';
return $metas;
}
?>

49
plugin.xml

@ -0,0 +1,49 @@
<plugin>
<nom>Br&egrave;ves</nom>
<auteur>Collectif SPIP</auteur>
<version>1.0</version>
<version_base>1.0</version_base>
<install>base/breves_upgrade.php</install>
<etat>test</etat>
<description>Les br&egrave;ves sont des informations courtes, sans auteur.</description>
<prefix>breves</prefix>
<fonctions>public/breves.php</fonctions>
<pipeline>
<nom>configurer_liste_metas</nom>
<inclure>breves_pipelines.php</inclure>
</pipeline>
<pipeline>
<nom>declarer_tables_interfaces</nom>
<inclure>base/breves.php</inclure>
</pipeline>
<pipeline>
<nom>declarer_tables_objets_surnoms</nom>
<inclure>base/breves.php</inclure>
</pipeline>
<pipeline>
<nom>declarer_tables_principales</nom>
<inclure>base/breves.php</inclure>
</pipeline>
<pipeline>
<nom>autoriser</nom>
<inclure>breves_autoriser.php</inclure>
</pipeline>
<bouton id='breves' parent="bando_edition">
<icone>images/breve-16.png</icone>
<titre>icone_breves</titre>
</bouton>
<bouton id='breve_creer' parent="outils_rapides">
<icone>images/breve-new-16.png</icone>
<titre>icone_nouvelle_breve</titre>
<url>breves_edit</url>
<args>new=oui&amp;id_rubrique=@id_rubrique@</args>
</bouton>
</plugin>

37
public/breves.php

@ -0,0 +1,37 @@
<?php
/***************************************************************************\
* SPIP, Systeme de publication pour l'internet *
* *
* Copyright (c) 2001-2010 *
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined("_ECRIRE_INC_VERSION")) return;
//
// <BOUCLE(BREVES)>
//
// http://doc.spip.org/@boucle_BREVES_dist
function boucle_BREVES_dist($id_boucle, &$boucles) {
$boucle = &$boucles[$id_boucle];
$id_table = $boucle->id_table;
$mstatut = $id_table .'.statut';
// Restreindre aux elements publies
if (!isset($boucle->modificateur['criteres']['statut'])) {
if (!$GLOBALS['var_preview'])
array_unshift($boucle->where,array("'='", "'$mstatut'", "'\\'publie\\''"));
else
array_unshift($boucle->where,array("'IN'", "'$mstatut'", "'(\\'publie\\',\\'prop\\')'"));
}
return calculer_boucle($id_boucle, $boucles);
}
?>
Loading…
Cancel
Save