|
|
|
@ -15,7 +15,7 @@
|
|
|
|
|
* |
|
|
|
|
* @package SPIP\Breves\Pipelines |
|
|
|
|
**/ |
|
|
|
|
if (!defined("_ECRIRE_INC_VERSION")) { |
|
|
|
|
if (!defined('_ECRIRE_INC_VERSION')) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -80,13 +80,18 @@ function breves_affiche_enfants($flux) {
|
|
|
|
|
) { |
|
|
|
|
$id_rubrique = $flux['args']['id_rubrique']; |
|
|
|
|
|
|
|
|
|
if ($GLOBALS['meta']["activer_breves"] == 'oui') { |
|
|
|
|
if ($GLOBALS['meta']['activer_breves'] == 'oui') { |
|
|
|
|
$lister_objets = charger_fonction('lister_objets', 'inc'); |
|
|
|
|
$bouton_breves = ''; |
|
|
|
|
$id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . $id_rubrique); |
|
|
|
|
if (autoriser('creerbrevedans', 'rubrique', $id_rubrique, null, array('id_parent' => $id_parent))) { |
|
|
|
|
$bouton_breves .= icone_verticale(_T('breves:icone_nouvelle_breve'), |
|
|
|
|
generer_url_ecrire("breve_edit", "id_rubrique=$id_rubrique&new=oui"), "breve-24.png", "new", 'right') |
|
|
|
|
$bouton_breves .= icone_verticale( |
|
|
|
|
_T('breves:icone_nouvelle_breve'), |
|
|
|
|
generer_url_ecrire('breve_edit', "id_rubrique=$id_rubrique&new=oui"), |
|
|
|
|
'breve-24.png', |
|
|
|
|
'new', |
|
|
|
|
'right' |
|
|
|
|
) |
|
|
|
|
. "<br class='nettoyeur' />"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -119,14 +124,17 @@ function breves_affiche_enfants($flux) {
|
|
|
|
|
function breves_accueil_informations($texte) { |
|
|
|
|
include_spip('base/abstract_sql'); |
|
|
|
|
|
|
|
|
|
$q = sql_select("COUNT(*) AS cnt, statut", 'spip_breves', '', 'statut', '', '', "COUNT(*)<>0"); |
|
|
|
|
$q = sql_select('COUNT(*) AS cnt, statut', 'spip_breves', '', 'statut', '', '', 'COUNT(*)<>0'); |
|
|
|
|
|
|
|
|
|
$cpt = array(); |
|
|
|
|
$cpt2 = array(); |
|
|
|
|
$where = false; |
|
|
|
|
if ($GLOBALS['visiteur_session']['statut'] == '0minirezo') { |
|
|
|
|
$where = sql_allfetsel('id_objet', 'spip_auteurs_liens', |
|
|
|
|
"objet='rubrique' AND id_auteur=" . intval($GLOBALS['visiteur_session']['id_auteur'])); |
|
|
|
|
$where = sql_allfetsel( |
|
|
|
|
'id_objet', |
|
|
|
|
'spip_auteurs_liens', |
|
|
|
|
"objet='rubrique' AND id_auteur=" . intval($GLOBALS['visiteur_session']['id_auteur']) |
|
|
|
|
); |
|
|
|
|
if ($where) { |
|
|
|
|
$where = sql_in('id_rubrique', array_map('reset', $where)); |
|
|
|
|
} |
|
|
|
@ -139,23 +147,23 @@ function breves_accueil_informations($texte) {
|
|
|
|
|
|
|
|
|
|
if ($cpt) { |
|
|
|
|
if ($where) { |
|
|
|
|
$q = sql_select("COUNT(*) AS cnt, statut", 'spip_breves', $where, "statut"); |
|
|
|
|
$q = sql_select('COUNT(*) AS cnt, statut', 'spip_breves', $where, 'statut'); |
|
|
|
|
while ($row = sql_fetch($q)) { |
|
|
|
|
$r = $row['statut']; |
|
|
|
|
$cpt2[$r] = intval($row['cnt']) . '/'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$texte .= "<div class='accueil_informations breves liste'>"; |
|
|
|
|
$texte .= "<h4>" . afficher_plus_info(generer_url_ecrire("breves"), "", _T('breves:info_breves_02')) . "</h4>"; |
|
|
|
|
$texte .= '<h4>' . afficher_plus_info(generer_url_ecrire('breves'), '', _T('breves:info_breves_02')) . '</h4>'; |
|
|
|
|
$texte .= "<ul class='liste-items'>"; |
|
|
|
|
if (isset($cpt['prop'])) { |
|
|
|
|
$texte .= "<li class='item'>" . _T("texte_statut_attente_validation") . ": " . $cpt2['prop'] . $cpt['prop'] . '</li>'; |
|
|
|
|
$texte .= "<li class='item'>" . _T('texte_statut_attente_validation') . ': ' . $cpt2['prop'] . $cpt['prop'] . '</li>'; |
|
|
|
|
} |
|
|
|
|
if (isset($cpt['publie'])) { |
|
|
|
|
$texte .= "<li class='item on'>" . _T("texte_statut_publies") . ": " . $cpt2['publie'] . $cpt['publie'] . '</li>'; |
|
|
|
|
$texte .= "<li class='item on'>" . _T('texte_statut_publies') . ': ' . $cpt2['publie'] . $cpt['publie'] . '</li>'; |
|
|
|
|
} |
|
|
|
|
$texte .= "</ul>"; |
|
|
|
|
$texte .= "</div>"; |
|
|
|
|
$texte .= '</ul>'; |
|
|
|
|
$texte .= '</div>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $texte; |
|
|
|
@ -176,11 +184,15 @@ function breves_objet_compte_enfants($flux) {
|
|
|
|
|
) { |
|
|
|
|
// juste les publies ? |
|
|
|
|
if (array_key_exists('statut', $flux['args']) and ($flux['args']['statut'] == 'publie')) { |
|
|
|
|
$flux['data']['breve'] = sql_countsel('spip_breves', |
|
|
|
|
"id_rubrique=" . intval($id_rubrique) . " AND (statut='publie')"); |
|
|
|
|
$flux['data']['breve'] = sql_countsel( |
|
|
|
|
'spip_breves', |
|
|
|
|
'id_rubrique=' . intval($id_rubrique) . " AND (statut='publie')" |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
$flux['data']['breve'] = sql_countsel('spip_breves', |
|
|
|
|
"id_rubrique=" . intval($id_rubrique) . " AND (statut='publie' OR statut='prop')"); |
|
|
|
|
$flux['data']['breve'] = sql_countsel( |
|
|
|
|
'spip_breves', |
|
|
|
|
'id_rubrique=' . intval($id_rubrique) . " AND (statut='publie' OR statut='prop')" |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -197,12 +209,18 @@ function breves_objet_compte_enfants($flux) {
|
|
|
|
|
* @return array Données du pipeline |
|
|
|
|
*/ |
|
|
|
|
function breves_trig_calculer_langues_rubriques($flux) { |
|
|
|
|
|
|
|
|
|
$s = sql_select("A.id_breve AS id_breve, R.lang AS lang", "spip_breves AS A, spip_rubriques AS R", |
|
|
|
|
"A.id_rubrique = R.id_rubrique AND A.langue_choisie != 'oui' AND (A.lang='' OR R.lang<>'') AND R.lang<>A.lang"); |
|
|
|
|
$s = sql_select( |
|
|
|
|
'A.id_breve AS id_breve, R.lang AS lang', |
|
|
|
|
'spip_breves AS A, spip_rubriques AS R', |
|
|
|
|
"A.id_rubrique = R.id_rubrique AND A.langue_choisie != 'oui' AND (A.lang='' OR R.lang<>'') AND R.lang<>A.lang" |
|
|
|
|
); |
|
|
|
|
while ($row = sql_fetch($s)) { |
|
|
|
|
$id_breve = $row['id_breve']; |
|
|
|
|
sql_updateq('spip_breves', array("lang" => $row['lang'], 'langue_choisie' => 'non'), "id_breve=$id_breve"); |
|
|
|
|
sql_updateq( |
|
|
|
|
'spip_breves', |
|
|
|
|
array('lang' => $row['lang'], 'langue_choisie' => 'non'), |
|
|
|
|
'id_breve='.intval($id_breve) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $flux; |
|
|
|
@ -218,14 +236,18 @@ function breves_trig_calculer_langues_rubriques($flux) {
|
|
|
|
|
* @return array Données du pipeline |
|
|
|
|
*/ |
|
|
|
|
function breves_calculer_rubriques($flux) { |
|
|
|
|
|
|
|
|
|
$r = sql_select( |
|
|
|
|
"R.id_rubrique AS id, max(A.date_heure) AS date_h", |
|
|
|
|
"spip_rubriques AS R JOIN spip_breves AS A ON R.id_rubrique = A.id_rubrique", |
|
|
|
|
"A.date_heure>R.date_tmp AND A.statut='publie' ", "R.id_rubrique"); |
|
|
|
|
'R.id_rubrique AS id, max(A.date_heure) AS date_h', |
|
|
|
|
'spip_rubriques AS R JOIN spip_breves AS A ON R.id_rubrique = A.id_rubrique', |
|
|
|
|
"A.date_heure>R.date_tmp AND A.statut='publie' ", |
|
|
|
|
'R.id_rubrique' |
|
|
|
|
); |
|
|
|
|
while ($row = sql_fetch($r)) { |
|
|
|
|
sql_updateq('spip_rubriques', array('statut_tmp' => 'publie', 'date_tmp' => $row['date_h']), |
|
|
|
|
"id_rubrique=" . $row['id']); |
|
|
|
|
sql_updateq( |
|
|
|
|
'spip_rubriques', |
|
|
|
|
array('statut_tmp' => 'publie', 'date_tmp' => $row['date_h']), |
|
|
|
|
'id_rubrique=' . intval($row['id']) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $flux; |
|
|
|
@ -243,7 +265,6 @@ function breves_calculer_rubriques($flux) {
|
|
|
|
|
function breves_accueil_encours($flux) { |
|
|
|
|
$lister_objets = charger_fonction('lister_objets', 'inc'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$flux .= $lister_objets('breves', array( |
|
|
|
|
'titre' => afficher_plus_info(generer_url_ecrire('breves')) . _T('breves:info_breves_valider'), |
|
|
|
|
'statut' => array('prepa', 'prop'), |
|
|
|
@ -268,24 +289,23 @@ function breves_optimiser_base_disparus($flux) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# les breves qui sont dans une id_rubrique inexistante |
|
|
|
|
$res = sql_select("B.id_breve AS id", |
|
|
|
|
"spip_breves AS B |
|
|
|
|
LEFT JOIN spip_rubriques AS R |
|
|
|
|
ON B.id_rubrique=R.id_rubrique", |
|
|
|
|
"R.id_rubrique IS NULL |
|
|
|
|
AND B.maj < " . sql_quote($mydate)); |
|
|
|
|
$res = sql_select( |
|
|
|
|
'B.id_breve AS id', |
|
|
|
|
'spip_breves AS B |
|
|
|
|
LEFT JOIN spip_rubriques AS R |
|
|
|
|
ON B.id_rubrique=R.id_rubrique', |
|
|
|
|
'R.id_rubrique IS NULL |
|
|
|
|
AND B.maj < ' . sql_quote($mydate) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$n += optimiser_sansref('spip_breves', 'id_breve', $res); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
|
|
// Breves |
|
|
|
|
// |
|
|
|
|
|
|
|
|
|
sql_delete("spip_breves", "statut='refuse' AND maj < $mydate"); |
|
|
|
|
sql_delete('spip_breves', "statut='refuse' AND maj < $mydate"); |
|
|
|
|
|
|
|
|
|
return $flux; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -302,8 +322,8 @@ function breves_boite_infos($flux) {
|
|
|
|
|
and isset($flux['args']['id']) and $id_rubrique = $flux['args']['id'] |
|
|
|
|
) { |
|
|
|
|
if ($nb = sql_countsel('spip_breves', "statut='publie' AND id_rubrique=" . intval($id_rubrique))) { |
|
|
|
|
$nb = "<div>" . singulier_ou_pluriel($nb, "breves:info_1_breve", "breves:info_nb_breves") . "</div>"; |
|
|
|
|
if ($p = strpos($flux['data'], "<!--nb_elements-->")) { |
|
|
|
|
$nb = '<div>' . singulier_ou_pluriel($nb, 'breves:info_1_breve', 'breves:info_nb_breves') . '</div>'; |
|
|
|
|
if ($p = strpos($flux['data'], '<!--nb_elements-->')) { |
|
|
|
|
$flux['data'] = substr_replace($flux['data'], $nb, $p, 0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -322,8 +342,8 @@ function breves_boite_infos($flux) {
|
|
|
|
|
* @return array Données du pipeline |
|
|
|
|
*/ |
|
|
|
|
function breves_affiche_milieu($flux) { |
|
|
|
|
if ($flux["args"]["exec"] == "configurer_contenu") { |
|
|
|
|
$flux["data"] .= recuperer_fond('prive/squelettes/inclure/configurer', array('configurer' => 'configurer_breves')); |
|
|
|
|
if ($flux['args']['exec'] == 'configurer_contenu') { |
|
|
|
|
$flux['data'] .= recuperer_fond('prive/squelettes/inclure/configurer', array('configurer' => 'configurer_breves')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $flux; |
|
|
|
|