Changeset 272
- Timestamp:
- 10/30/07 23:06:04 (1 year ago)
- Files:
-
- branches/2.3/classes/phing/tasks/system/PropertyPromptTask.php (modified) (7 diffs)
- branches/2.3/docs/phing_guide/book/chapters/appendixes/AppendixB-CoreTasks.html (modified) (1 diff)
- branches/2.3/docs/phing_guide/book/toc/FrameToC.html (modified) (1 diff)
- branches/2.3/docs/phing_guide/book/toc/ToC.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2.3/classes/phing/tasks/system/PropertyPromptTask.php
r144 r272 37 37 */ 38 38 class PropertyPromptTask extends Task { 39 39 40 /** 41 * The property name to set with the output. 42 * @var string 43 */ 40 44 private $propertyName; // required 45 46 /** 47 * The default value to use if no input is entered. 48 * @var string 49 */ 41 50 private $defaultValue; 42 private $proposedValue; // required 43 private $promptText; // required 51 52 /** 53 * The entered value. 54 * @var string 55 */ 56 private $proposedValue; 57 58 /** 59 * The text to use for the prompt. 60 * @var string 61 */ 62 private $promptText; 63 64 /** 65 * The character to put after the text. 66 * @var string 67 */ 44 68 private $promptCharacter; 69 70 /** 71 * 72 */ 45 73 private $useExistingValue; 46 47 /**48 * Sets the prompt text that will be presented to the user.49 * @param string $prompt50 * @return void51 */52 public function addText($prompt) {53 $this->setPromptText($prompt);54 }55 74 56 75 /** … … 59 78 */ 60 79 public function main() { 80 61 81 $this->proposedValue = $this->project->getProperty($this->propertyName); 62 82 $currentValue = $this->defaultValue; 63 if ($currentValue == "" && $this->proposedValue !== null) { $currentValue = $this->proposedValue; } 64 if (! (($this->useExistingValue === true) && ($this->proposedValue !== null))) { 83 84 if ($currentValue == "" && $this->proposedValue !== null) { 85 $currentValue = $this->proposedValue; 86 } 87 88 if ($this->useExistingValue !== true || $this->proposedValue === null) { 65 89 66 90 $this->log("Prompting user for " . $this->propertyName . ". " . $this->getDefaultMessage(), Project::MSG_VERBOSE); … … 78 102 } 79 103 80 if ( empty($this->proposedValue)) {104 if ($this->proposedValue === "") { 81 105 $this->log("No value specified, using default.", Project::MSG_VERBOSE); 82 106 $this->proposedValue = $this->defaultValue; 83 107 } 84 108 85 if ( !empty($this->proposedValue)) {109 if (isset($this->proposedValue) && $this->proposedValue !== "") { 86 110 $this->project->setProperty($this->propertyName, $this->proposedValue); 87 111 } … … 167 191 * Sets the terminating character used to 168 192 * punctuate the prompt text (default is "?"). 169 * @param newPromptcharacter java.lang.String193 * @param string $newPromptcharacter 170 194 */ 171 195 public function setPromptCharacter($newPromptcharacter) { … … 175 199 /** 176 200 * Sets text of the prompt. 177 * @param newPrompttext java.lang.String201 * @param string $newPrompttext 178 202 */ 179 203 public function setPromptText($newPrompttext) { … … 192 216 /** 193 217 * 194 * 195 * @param boolean newUseExistingValue 218 * @param boolean $newUseExistingValue 196 219 */ 197 220 public function setUseExistingValue($newUseExistingValue) { … … 199 222 } 200 223 224 /** 225 * Sets the prompt text that will be presented to the user. 226 * @param string $prompt 227 * @return void 228 */ 229 public function addText($prompt) { 230 $this->setPromptText($prompt); 231 } 232 233 201 234 } branches/2.3/docs/phing_guide/book/chapters/appendixes/AppendixB-CoreTasks.html
r207 r272 1309 1309 <td>n/a</td> 1310 1310 <td>No</td> 1311 1311 </tr> 1312 </tbody> 1313 </table> 1314 1315 <h2><a name="PropertyPromptTask"></a>PropertyPromptTask</h2> 1316 <p> 1317 PropertyPromptTask is a simple task to read in user input into a property. 1318 If you need something more advanced, see the <a href="#InputTask">InputTask</a>. 1319 </p> 1320 <h3>Example</h3> 1321 1322 <pre><propertyprompt propertyName="someprop" defaultValue="/var/www" 1323 promptText="Enter your web root" /> 1324 <echo>${someprop}</echo> 1325 </pre> 1326 <h3>Attributes</h3> 1327 <table> 1328 <thead> 1329 <tr> 1330 <th>Name</th> 1331 <th>Type</th> 1332 <th>Description</th> 1333 <th>Default</th> 1334 <th>Required</th> 1335 </tr> 1336 </thead> 1337 <tbody> 1338 <tr> 1339 <td>propertyName</td> 1340 <td>String</td> 1341 <td> 1342 The name of the Property to set. 1343 </td> 1344 <td>n/a</td> 1345 <td>Yes</td> 1346 </tr> 1347 <tr> 1348 <td>promptText</td> 1349 <td>String</td> 1350 <td> 1351 The text to use for the prompt. 1352 </td> 1353 <td>n/a</td> 1354 <td>Yes</td> 1355 </tr> 1356 <tr> 1357 <td>promptCharacter</td> 1358 <td>String</td> 1359 <td> 1360 The character to use after the prompt. 1361 </td> 1362 <td>?</td> 1363 <td>No</td> 1364 </tr> 1365 <tr> 1366 <td>defaultValue</td> 1367 <td>String</td> 1368 <td> 1369 A default value to use (if user just hits enter). 1370 </td> 1371 <td>n/a</td> 1372 <td>No</td> 1373 </tr> 1374 <tr> 1375 <td>useExistingValue</td> 1376 <td>String</td> 1377 <td>Whether existing property should be used if available. (This will 1378 result in user only being prompted if the propertyName property is not already set.)</td> 1379 <td>false</td> 1380 <td>No</td> 1381 </tr> 1312 1382 </tbody> 1313 1383 </table> branches/2.3/docs/phing_guide/book/toc/FrameToC.html
r271 r272 109 109 <li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#PhpEvalTask" target="Content">PhpEvalTask</a></li> 110 110 <li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#PropertyTask" target="Content">PropertyTask</a></li> 111 <li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#PropertyPromptTask" target="Content">PropertyPromptTask</a></li> 111 112 <li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#ReflexiveTask" target="Content">ReflexiveTask</a></li> 112 113 <li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#ResolvePathTask" target="Content">ResolvePathTask</a></li> branches/2.3/docs/phing_guide/book/toc/ToC.html
r271 r272 94 94 <li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#PhpEvalTask">PhpEvalTask</a></li> 95 95 <li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#PropertyTask">PropertyTask</a></li> 96 <li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#PropertyPromptTask">PropertyPromptTask</a></li> 96 97 <li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#ReflexiveTask">ReflexiveTask</a></li> 97 98 <li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#ResolvePathTask">ResolvePathTask</a></li>
