summaryrefslogtreecommitdiff
path: root/src/view/Zenity.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/view/Zenity.php')
-rw-r--r--src/view/Zenity.php29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/view/Zenity.php b/src/view/Zenity.php
index 1299d1c..72d5eed 100644
--- a/src/view/Zenity.php
+++ b/src/view/Zenity.php
@@ -1,7 +1,8 @@
1<?php 1<?php
2// php/Zenity.php 2// php/Zenity.php
3// 3//
4// commande système zenity 4// générer les commandes qui ouvrent les fenêtres zenity, un objet = une commande
5// s'utilisent comme ceci: exec($Objet->get());
5 6
6abstract class ZenityCmd 7abstract class ZenityCmd
7{ 8{
@@ -33,17 +34,17 @@ class ZenityList extends ZenityCmd
33{ 34{
34 private $columns = 1; // tableau simple ou multidimensionnel? 35 private $columns = 1; // tableau simple ou multidimensionnel?
35 36
36 public function __construct(string $text, array $rows = [], int $columns = 1) 37 public function __construct(string $text, array $rows = [])
37 { 38 {
38 $this->command_type = ' --list'; 39 $this->command_type = ' --list';
39 parent::__construct($text, $rows); 40 parent::__construct($text, $rows);
40 $this->columns = $columns; 41 $this->columns = 1;
41 $this->height = 80 + count($this->rows) * 25;
42 $this->command .= ' --height=' . $this->height;
43 $this->command .= ' --hide-header'; // ligne inutile, il y a déjà le --text 42 $this->command .= ' --hide-header'; // ligne inutile, il y a déjà le --text
44 if($this->rows !== []) 43 if($this->rows !== [])
45 { 44 {
46 $this->command .= ' --width=' . $this->width; 45 $this->command .= ' --width=' . $this->width;
46 $this->height = 80 + count($this->rows) * 25;
47 $this->command .= ' --height=' . $this->height;
47 $this->fillZenityList(); 48 $this->fillZenityList();
48 } 49 }
49 } 50 }
@@ -54,8 +55,10 @@ class ZenityList extends ZenityCmd
54 { 55 {
55 $this->rows = $rows; 56 $this->rows = $rows;
56 $this->columns = count(StructTablesDB::$structureOfTables[$table]); 57 $this->columns = count(StructTablesDB::$structureOfTables[$table]);
57 $this->width = 600; 58 $this->width = 800;
58 $this->command .= ' --width=' . $this->width; 59 $this->command .= ' --width=' . $this->width;
60 $this->height = 80 + count($this->rows) * 25;
61 $this->command .= ' --height=' . $this->height;
59 $this->fillZenityList(); 62 $this->fillZenityList();
60 } 63 }
61 64
@@ -100,7 +103,7 @@ class ZenityList extends ZenityCmd
100 103
101class ZenityQuestion extends ZenityCmd 104class ZenityQuestion extends ZenityCmd
102{ 105{
103 public function __construct($text) 106 public function __construct(string $text)
104 { 107 {
105 $this->command_type = ' --question'; 108 $this->command_type = ' --question';
106 parent::__construct($text); 109 parent::__construct($text);
@@ -114,7 +117,7 @@ class ZenityQuestion extends ZenityCmd
114// si on clique sur 'Annuler', renvoie une chaine vide 117// si on clique sur 'Annuler', renvoie une chaine vide
115class ZenityForms extends ZenityCmd 118class ZenityForms extends ZenityCmd
116{ 119{
117 public function __construct($text, array $rows) 120 public function __construct(string $text, array $rows)
118 { 121 {
119 $this->command_type = ' --forms'; 122 $this->command_type = ' --forms';
120 parent::__construct($text, $rows); 123 parent::__construct($text, $rows);
@@ -122,12 +125,12 @@ class ZenityForms extends ZenityCmd
122 self::entriesZenityForms($this->rows); 125 self::entriesZenityForms($this->rows);
123 } 126 }
124 127
125 private function entriesZenityForms($entries) 128 private function entriesZenityForms(array $input)
126 { 129 {
127 $output = ''; 130 $output = '';
128 foreach($entries as $one_entry) 131 foreach($input as $one_question)
129 { 132 {
130 $output .= ' --add-entry="' . $one_entry . '"'; // forme: ' "choix 1" "choix 2"' 133 $output .= ' --add-entry="' . $one_question . '"'; // forme: ' "choix 1" "choix 2"'
131 } 134 }
132 $this->command .= $output; 135 $this->command .= $output;
133 } 136 }
@@ -135,7 +138,7 @@ class ZenityForms extends ZenityCmd
135 138
136class ZenityCalendar extends ZenityCmd 139class ZenityCalendar extends ZenityCmd
137{ 140{
138 public function __construct($text) 141 public function __construct(string $text)
139 { 142 {
140 $this->command_type = ' --calendar'; 143 $this->command_type = ' --calendar';
141 parent::__construct($text); 144 parent::__construct($text);
@@ -144,7 +147,7 @@ class ZenityCalendar extends ZenityCmd
144 147
145class ZenityEntry extends ZenityCmd 148class ZenityEntry extends ZenityCmd
146{ 149{
147 public function __construct($text) 150 public function __construct(string $text)
148 { 151 {
149 $this->command_type = ' --entry'; 152 $this->command_type = ' --entry';
150 parent::__construct($text); 153 parent::__construct($text);