[SPIP][PLUGINS] v3.0-->v3.2
[lhc/web/www.git] / www / plugins-dist / compagnon / compagnon_messages.php
index 9f433e3..6c4072d 100644 (file)
@@ -1,44 +1,60 @@
 <?php
 
-if (!defined('_ECRIRE_INC_VERSION')) return;
+/**
+ * Gestion de l'action compagnon
+ *
+ * @package SPIP\Compagnon\Pipelines
+ **/
 
+if (!defined('_ECRIRE_INC_VERSION')) {
+       return;
+}
 
+/**
+ * Définition des messages de compagnon par défaut en fonction
+ *
+ * Retourne une liste de messages d'aides en fonction du pipeline
+ * demandé
+ *
+ * @pipeline compagnon_messages
+ *
+ * @param array $flux
+ *     Données du pipeline
+ * @return array $flux
+ *     Données du pipeline
+ **/
 function compagnon_compagnon_messages($flux) {
 
-       $exec     = $flux['args']['exec'];
+       $exec = $flux['args']['exec'];
        $pipeline = $flux['args']['pipeline'];
-       $vus      = $flux['args']['deja_vus'];
-       $aides    = &$flux['data'];
+       $vus = $flux['args']['deja_vus'];
+       $aides = &$flux['data'];
 
        switch ($pipeline) {
-               
                case 'affiche_milieu':
                        switch ($exec) {
-
-                               
                                case 'accueil':
                                        $aides[] = array(
                                                'id' => 'accueil',
                                                'inclure' => 'compagnon/accueil',
-                                               'statuts'=> array('1comite', '0minirezo', 'webmestre')
+                                               'statuts' => array('1comite', '0minirezo', 'webmestre')
                                        );
                                        $aides[] = array(
                                                'id' => 'accueil_configurer',
                                                'titre' => _T('compagnon:c_accueil_configurer_site'),
-                                               'texte' => _T('compagnon:c_accueil_configurer_site_texte', array('nom'=>$GLOBALS['meta']['nom_site'])),
-                                               'statuts'=> array('webmestre'),
+                                               'texte' => _T('compagnon:c_accueil_configurer_site_texte', array('nom' => $GLOBALS['meta']['nom_site'])),
+                                               'statuts' => array('webmestre'),
                                                'target' => '#bando_identite .nom_site_spip .nom',
                                        );
                                        $aides[] = array(
                                                'id' => 'accueil_publication',
                                                'titre' => _T('compagnon:c_accueil_publication'),
                                                'texte' => _T('compagnon:c_accueil_publication_texte'),
-                                               'statuts'=> array('webmestre'),
-                                               'target'=> '#bando1_menu_edition',
+                                               'statuts' => array('webmestre'),
+                                               'target' => '#bando1_menu_edition',
                                        );
                                        break;
 
-
                                case 'rubriques':
                                        // eviter si possible une requete sql.
                                        if (!isset($vus['rubriques']) and !sql_countsel('spip_rubriques')) {
@@ -46,8 +62,8 @@ function compagnon_compagnon_messages($flux) {
                                                        'id' => 'rubriques',
                                                        'titre' => _T('compagnon:c_rubriques_creer'),
                                                        'texte' => _T('compagnon:c_rubriques_creer_texte'),
-                                                       'statuts'=> array('webmestre'),
-                                                       'target'=> '#contenu .icone:first-of-type',
+                                                       'statuts' => array('webmestre'),
+                                                       'target' => '#contenu .icone:first-of-type',
                                                );
                                        }
                                        break;
@@ -56,14 +72,14 @@ function compagnon_compagnon_messages($flux) {
                                case 'rubrique':
                                        // eviter si possible une requete sql.
                                        if (!isset($vus['rubrique'])) {
-                                               $statut = sql_getfetsel('statut', 'spip_rubriques', 'id_rubrique='.$flux['args']['id_rubrique']);
+                                               $statut = sql_getfetsel('statut', 'spip_rubriques', 'id_rubrique=' . $flux['args']['id_rubrique']);
                                                if ($statut != 'publie') {
                                                        $aides[] = array(
                                                                'id' => 'rubrique',
                                                                'titre' => _T('compagnon:c_rubrique_publier'),
                                                                'texte' => _T('compagnon:c_rubrique_publier_texte'),
-                                                               'statuts'=> array('webmestre'),
-                                                               'target'=> '#contenu .icone.article-new-24'
+                                                               'statuts' => array('webmestre'),
+                                                               'target' => '#contenu .icone.article-new-24'
                                                        );
                                                }
                                        }
@@ -76,7 +92,19 @@ function compagnon_compagnon_messages($flux) {
                                                        'id' => 'articles',
                                                        'titre' => _T('compagnon:c_articles_creer'),
                                                        'texte' => _T('compagnon:c_articles_creer_texte'),
-                                                       'statuts'=> array('webmestre')
+                                                       'statuts' => array('webmestre')
+                                               );
+                                       }
+                                       break;
+
+                               case 'sites':
+                                       // eviter si possible une requete sql.
+                                       if (!isset($vus['sites']) and !sql_countsel('spip_rubriques')) {
+                                               $aides[] = array(
+                                                       'id' => 'sites',
+                                                       'titre' => _T('compagnon:c_sites_creer'),
+                                                       'texte' => _T('compagnon:c_sites_creer_texte'),
+                                                       'statuts' => array('webmestre')
                                                );
                                        }
                                        break;
@@ -85,12 +113,12 @@ function compagnon_compagnon_messages($flux) {
                                        $aides[] = array(
                                                'id' => 'article_redaction',
                                                'inclure' => 'compagnon/article_redaction',
-                                               'statuts'=> array('0minirezo', 'webmestre')
-                                       );      
+                                               'statuts' => array('0minirezo', 'webmestre')
+                                       );
                                        $aides[] = array(
                                                'id' => 'article_redaction_redacteur',
                                                'inclure' => 'compagnon/article_redaction_redacteur',
-                                               'statuts'=> array('1comite')
+                                               'statuts' => array('1comite')
                                        );
                                        break;
                        }
@@ -103,15 +131,12 @@ function compagnon_compagnon_messages($flux) {
                                                'id' => 'job_queue',
                                                'titre' => _T('compagnon:c_job'),
                                                'texte' => _T('compagnon:c_job_texte'),
-                                               'statuts'=> array('webmestre')
+                                               'statuts' => array('webmestre')
                                        );
                                        break;
                        }
                        break;
        }
 
-       
        return $flux;
 }
-
-?>