From efe371fd6e883dde99ca6d90a7aae99eb4aeadea Mon Sep 17 00:00:00 2001 From: polo Date: Fri, 25 Nov 2022 03:59:32 +0100 Subject: =?UTF-8?q?premi=C3=A8re=20sauvegarde=20git?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- php/ZenityClasses.php | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 php/ZenityClasses.php (limited to 'php/ZenityClasses.php') diff --git a/php/ZenityClasses.php b/php/ZenityClasses.php new file mode 100644 index 0000000..c286d14 --- /dev/null +++ b/php/ZenityClasses.php @@ -0,0 +1,111 @@ +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 Zenity_list extends Zenity_cmd +{ + 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 Zenity_question extends Zenity_cmd +{ + 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 Zenity_forms extends Zenity_cmd +{ + 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 Zenity_calendar extends Zenity_cmd +{ + public function __construct($text) + { + $this->command_type = ' --calendar'; + parent::__construct($text); + } +} + +class Zenity_entry extends Zenity_cmd +{ + public function __construct($text) + { + $this->command_type = ' --entry'; + parent::__construct($text); + } +} -- cgit v1.2.3