www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

contact-index.php (3009B)


      1 <?php
      2 
      3 class ContactIndex {
      4 	public static function action($chemin, $action, $paramètres) {
      5 		if ($action == "anuler") {
      6 			return new Page($chemin, '', "redirect");
      7 		} else if ($action == "nouvelle_page") {
      8 			// SECURITE : On ne doit PAS pouvoir modifier dernier_numero arbitrairement
      9 			// CONCURENCE : Faire un lock quelque part...
     10 			$numéro_contact = 1 + Stockage::get_prop($chemin, "dernier_numero");
     11 			Stockage::set_prop($chemin, "dernier_numero", $numéro_contact);
     12 			$np = Stockage::nouvelle_page($chemin, "Contact" . $numéro_contact, "contact-contact");
     13 			Stockage::set_prop($np, "proprietaire", Authentification::get_utilisateur());
     14 			Stockage::set_prop($np, "nom", "Dupondt");
     15 			Stockage::set_prop($np, "prenom", "Jean");
     16 			Stockage::set_prop($np, "description", "");
     17 			enregistrer_nouveaute($np);
     18 			return new Page($np, '', "redirect");
     19 		} else {
     20 			if (isset($paramètres["description"])) {
     21 				Stockage::set_prop($chemin, "description", $paramètres["description"]);
     22 			}
     23 			
     24 			if (isset($paramètres["titre"])) {
     25 				Stockage::set_prop($chemin, "titre", $paramètres["titre"]);
     26 			}
     27 			
     28 			if (isset($paramètres["vue"])) {
     29 				return self::vue($chemin, $paramètres["vue"]);
     30 			} else {
     31 				return self::vue($chemin);
     32 			}
     33 		}
     34 	}
     35 	
     36 	public static function vue($chemin, $vue = "normal") {
     37 		if ($vue == "normal") {
     38 			$ret = '';
     39 			
     40 			if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) {
     41 				$ret .= '<form class="contact infos" method="post" action="' . $chemin->get_url() . '">';
     42 				$ret .= '<h2><input type="text" name="titre" value="' . Stockage::get_prop($chemin, "titre") . '" /></h2>';
     43 				$ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "description"), "description");
     44 				$ret .= '<p><input type="submit" value="appliquer" /></p>';
     45 				$ret .= '</form>';
     46 			} else {
     47 				$ret .= '<h2>' . Stockage::get_prop($chemin, "titre") . '</h2>';
     48 				$ret .= '<p class="contact index description affichage">' . Stockage::get_prop($chemin, "description") . '</p>';
     49 			}
     50 			
     51 			$ret .= '<div class="contact liste-contacts index">';
     52 			$ret .= '<ul>';
     53 			
     54 			if (Permissions::vérifier_permission($chemin, "nouvelle_page", Authentification::get_utilisateur())) {
     55 				$ret .= '<li>';
     56 				$ret .= '<div class="titre">';
     57 				
     58 				$ret .= '<form class="contact nouvelle_page" method="post" action="' . $chemin->get_url() . '">';
     59 				$ret .= '<p>';
     60 				$ret .= '<input type="hidden" name="action" value="nouvelle_page"/>';
     61 				$ret .= '<input type="submit" value="Nouveau contact"/>';
     62 				$ret .= '</p>';
     63 				$ret .= '</form>';
     64 				
     65 				$ret .= '</div>';
     66 				$ret .= '</li>';
     67 			}
     68 			
     69 	        foreach (stockage::liste_enfants($chemin) as $k) {
     70 	            $ret .= '<li>' . Modules::vue($k)->contenu . '</li>';
     71 	        }
     72 			
     73 			$ret .= '</ul>';
     74 			
     75 			return new Page($ret, Stockage::get_prop($chemin, "titre"));
     76 		}
     77 	}
     78 }
     79 
     80 Modules::enregister_module("ContactIndex", "contact-index", "vue", "titre description");
     81 
     82 ?>