From ff14091476a35de16a9ea3208501040cfae93a06 Mon Sep 17 00:00:00 2001 From: polo Date: Wed, 14 Dec 2022 12:55:46 +0100 Subject: MODEL + reorganisation --- src/view/Zenity.php | 110 ++++++++++++++++++++++++++++++++++++++++++++++ src/view/zenity_setup.php | 37 ++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 src/view/Zenity.php create mode 100644 src/view/zenity_setup.php (limited to 'src/view') diff --git a/src/view/Zenity.php b/src/view/Zenity.php new file mode 100644 index 0000000..a04b794 --- /dev/null +++ b/src/view/Zenity.php @@ -0,0 +1,110 @@ +text = $text; + $this->rows= $rows; + $this->command .= $this->command_type; + $this->command .= ' --title="' . $this->title . '"'; + $this->command .= ' --text="' . $this->text . '"'; + } + + public function get() + { + return($this->command); + } +} + + +class ZenityList extends ZenityCmd +{ + public function __construct($text, array $rows) + { + $this->command_type = ' --list'; + parent::__construct($text, $rows); + $this->height = 80 + count($this->rows) * 25; + $this->command .= ' --width=' . $this->width; + $this->command .= ' --height=' . $this->height; + $this->command .= ' --hide-header'; // ligne inutile, il y a déjà le --text + self::one_column_zenity_list($this->rows); + } + + public function set_entries($rows_set) // variable renseignée après la construction + { + $this->rows = $rows_set; + } + + private function one_column_zenity_list($rows) + { + $output = ' --column=""'; + foreach($rows as $entry) + { + $output .= ' "' . $entry . '"'; // forme: ' "choix 1" "choix 2"' + } + $this->command .= $output; + } +} + +class ZenityQuestion extends ZenityCmd +{ + public function __construct($text) + { + $this->command_type = ' --question'; + parent::__construct($text); + $this->command .= ' && echo $?'; + // la sortie de "zenity --question" est le statut de sortie "$?" + // $? vaut 0 pour oui, 1 pour non, à ceci près que pour non zenity ne renvoie rien + } +} + +class ZenityForms extends ZenityCmd +{ + public function __construct($text, array $rows) + { + $this->command_type = ' --forms'; + parent::__construct($text, $rows); + //$this->height = 80 + count($this->rows) * 25; // à tester, mais devrait produire le rendu attendu + self::entries_zenity_forms($this->rows); + } + + private function entries_zenity_forms($entries) + { + $output = ''; + foreach($entries as $one_entry) + { + $output .= ' --add-entry="' . $one_entry . '"'; // forme: ' "choix 1" "choix 2"' + } + $this->command .= $output; + } +} + +class ZenityCalendar extends ZenityCmd +{ + public function __construct($text) + { + $this->command_type = ' --calendar'; + parent::__construct($text); + } +} + +class ZenityEntry extends ZenityCmd +{ + public function __construct($text) + { + $this->command_type = ' --entry'; + parent::__construct($text); + } +} diff --git a/src/view/zenity_setup.php b/src/view/zenity_setup.php new file mode 100644 index 0000000..2f55cf2 --- /dev/null +++ b/src/view/zenity_setup.php @@ -0,0 +1,37 @@ +get()); +$MenuPrincipal = new ZenityList($menu_principal_text, $menu_principal_entrees); +$QuestionNouveauClient = new ZenityQuestion($question_nouveau_client_text); +$MenuEnregistrement = new ZenityList($menu_enregistrement_text, $menu_enregistrement_entrees); +$MenuDocuments = new ZenityList($menu_documents_text, $menu_documents_entrees); +$MenuCommunication = new ZenityList($menu_communication_text, $menu_communication_entrees); +$RechercheClient = new zenityEntry($recherche_client_text); +$ResultatsRechercheClient = new zenityList($resultats_recherche_client_text, []); +$NouveauClient = new ZenityForms($nouveau_client_text, $nouveau_client_entrees); +$Calendrier = new ZenityCalendar($calendar_text); +$FormulairePrestation = new ZenityForms($formulaire_text, $formulaire_entrees); +$CommentairePrestation = new ZenityEntry($commentaire_prestation_text); -- cgit v1.2.3