## Apache Zeta Components Manual :: File Source for menu_dialog.php

## Source for file menu_dialog.php

Documentation is available at menu_dialog.php

1. <?php
2. /**
3. * File containing the ezcConsoleMenuDialogOptions class.
4. *
5. * Licensed to the Apache Software Foundation (ASF) under one
6. * or more contributor license agreements. See the NOTICE file
7. * distributed with this work for additional information
8. * regarding copyright ownership. The ASF licenses this file
9. * to you under the Apache License, Version 2.0 (the
10. * "License"); you may not use this file except in compliance
11. * with the License. You may obtain a copy of the License at
12. *
13. * http://www.apache.org/licenses/LICENSE-2.0
14. *
15. * Unless required by applicable law or agreed to in writing,
16. * software distributed under the License is distributed on an
17. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18. * KIND, either express or implied. See the License for the
19. * specific language governing permissions and limitations
20. * under the License.
21. *
22. * @package ConsoleTools
23. * @version //autogentag//
24. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
25. * @filesource
26. */
28. /**
29. * Basic options class for ezcConsoleDialog implementations.
30. *
31. * @package ConsoleTools
32. * @version //autogen//
33. *
34. * @property string $text
35. * The text to display before the menu.
36. * @property string $formatString
37. * The format string for each menu element.
38. * @property string $selectText
39. * The test to display after the menu to indicate the user that he
40. * should select an item.
41. * @property ezcConsoleMenuDialogValidator $validator
42. * The validator to use with this menu.
43. * @property string $format
44. * The output format for the dialog.
45. */
46. class ezcConsoleMenuDialogOptions extends ezcConsoleDialogOptions
47. {
49. /**
50. * Construct a new options object.
51. * Options are constructed from an option array by default. The constructor
52. * automatically passes the given options to the __set() method to set them
53. * in the class.
54. *
55. * @throws ezcBasePropertyNotFoundException
56. * If trying to access a non existent property.
57. * @throws ezcBaseValueException
58. * If the value for a property is out of range.
59. * @param array(string=>mixed) $options The initial options to set.
60. */
61. public function __construct ( array $options = array() )
62. {
63. $this-> properties ["text"] = "Please choose an item.";
64. $this-> properties ["formatString"] = "%3s) %s\n";
65. $this-> properties ["selectText"] = "Select: ";
66. $this-> properties ["validator"] = new ezcConsoleMenuDialogDefaultValidator ();
67. parent::__construct( $options );
68. }
70. /**
71. * Property write access.
72. *
73. * @param string $propertyName Name of the property.
74. * @param mixed $propertyValue The value for the property.
75. *
76. * @throws ezcBasePropertyPermissionException
77. * If the property you try to access is read-only.
78. * @throws ezcBasePropertyNotFoundException
79. * If the the desired property is not found.
80. * @ignore
81. */
82. public function __set( $propertyName, $propertyValue )
83. {
84. switch ( $propertyName )
85. {
86. case "text":
87. if ( is_string ( $propertyValue ) === false || strlen ( $propertyValue ) < 1 )
88. {
89. throw new ezcBaseValueException (
90. $propertyName,
91. $propertyValue,
92. "string, length > 0"
93. );
94. }
95. break;
96. case "selectText":
97. if ( is_string ( $propertyValue ) === false )
98. {
99. throw new ezcBaseValueException (
100. $propertyName,
101. $propertyValue,
102. "string"
103. );
104. }
105. break;
106. case "formatString":
107. if ( is_string ( $propertyValue ) === false )
108. {
109. throw new ezcBaseValueException (
110. $propertyName,
111. $propertyValue,
112. "string"
113. );
114. }
115. break;
116. case "validator":
117. if ( ( $propertyValue instanceof ezcConsoleMenuDialogValidator ) === false )
118. {
119. throw new ezcBaseValueException (
120. $propertyName,
121. $propertyValue,
122. "ezcConsoleMenuDialogValidator"
123. );
124. }
125. default:
126. parent::__set( $propertyName, $propertyValue );
127. }
128. $this-> properties [$propertyName] = $propertyValue;
129. }
130. }
132. ?>

Documentation generated by phpDocumentor 1.4.3