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(string $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::oneColumnZenityList($this->rows); } // cas ou $this->rows est renseignée après public function setEntries(array $rows_set) { $this->rows = $rows_set; } // cas où on veut une seule colonne private function oneColumnZenityList(array $rows) { $output = ' --column=""'; foreach($rows as $entry) { $output .= ' "' . $entry . '"'; // forme: ' "choix 1" "choix 2"' } $this->command .= $output; } // cas où on veut plusieurs colonnes, le remplissage est horizontal, oui c'est tordu! } 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 } } // note: le formulaire renvoie une chaine avecdes pipes | entre les zones de texte (qui peuvent être vides) // si on clique sur 'Annuler', renvoie une chaine vide 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::entriesZenityForms($this->rows); } private function entriesZenityForms($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); } }