Changeset 272

Show
Ignore:
Timestamp:
10/30/07 23:06:04 (1 year ago)
Author:
hans
Message:

Cleaning up phpdoc for PropertyPromptTask and adding documentation for this task.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.3/classes/phing/tasks/system/PropertyPromptTask.php

    r144 r272  
    3737 */  
    3838class PropertyPromptTask extends Task { 
    39  
     39         
     40        /** 
     41         * The property name to set with the output. 
     42         * @var string 
     43         */ 
    4044    private $propertyName;        // required 
     45     
     46    /** 
     47     * The default value to use if no input is entered. 
     48     * @var string 
     49     */ 
    4150    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     */ 
    4468    private $promptCharacter; 
     69     
     70    /** 
     71     *  
     72     */ 
    4573    private $useExistingValue; 
    46  
    47     /** 
    48      * Sets the prompt text that will be presented to the user. 
    49      * @param string $prompt 
    50      * @return void 
    51      */ 
    52     public function addText($prompt) { 
    53         $this->setPromptText($prompt); 
    54     } 
    5574 
    5675    /** 
     
    5978     */ 
    6079    public function main() { 
     80         
    6181        $this->proposedValue = $this->project->getProperty($this->propertyName); 
    6282        $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) { 
    6589                         
    6690            $this->log("Prompting user for " . $this->propertyName . ". " . $this->getDefaultMessage(), Project::MSG_VERBOSE); 
     
    78102            } 
    79103             
    80             if (empty($this->proposedValue)) { 
     104            if ($this->proposedValue === "") { 
    81105                $this->log("No value specified, using default.", Project::MSG_VERBOSE); 
    82106                $this->proposedValue = $this->defaultValue; 
    83107            } 
    84108             
    85             if (!empty($this->proposedValue)) {                     
     109            if (isset($this->proposedValue) && $this->proposedValue !== "") {                     
    86110                $this->project->setProperty($this->propertyName, $this->proposedValue); 
    87111            } 
     
    167191     * Sets the terminating character used to  
    168192     * punctuate the prompt text (default is "?"). 
    169      * @param newPromptcharacter java.lang.String 
     193     * @param string $newPromptcharacter 
    170194     */ 
    171195    public function setPromptCharacter($newPromptcharacter) { 
     
    175199    /** 
    176200     * Sets text of the prompt. 
    177      * @param newPrompttext java.lang.String 
     201     * @param string $newPrompttext 
    178202     */ 
    179203    public function setPromptText($newPrompttext) { 
     
    192216    /** 
    193217     *  
    194      *  
    195      * @param boolean newUseExistingValue 
     218     * @param boolean $newUseExistingValue 
    196219     */ 
    197220    public function setUseExistingValue($newUseExistingValue) { 
     
    199222    } 
    200223     
     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     
    201234} 
  • branches/2.3/docs/phing_guide/book/chapters/appendixes/AppendixB-CoreTasks.html

    r207 r272  
    13091309                <td>n/a</td> 
    13101310                <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>&lt;propertyprompt propertyName=&quot;someprop&quot; defaultValue=&quot;/var/www&quot;  
     1323                promptText=&quot;Enter your web root&quot; /&gt; 
     1324&lt;echo&gt;${someprop}&lt;/echo&gt; 
     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> 
    13121382  </tbody> 
    13131383</table> 
  • branches/2.3/docs/phing_guide/book/toc/FrameToC.html

    r271 r272  
    109109<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#PhpEvalTask" target="Content">PhpEvalTask</a></li> 
    110110<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> 
    111112<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#ReflexiveTask" target="Content">ReflexiveTask</a></li> 
    112113<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  
    9494<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#PhpEvalTask">PhpEvalTask</a></li> 
    9595<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> 
    9697<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#ReflexiveTask">ReflexiveTask</a></li> 
    9798<li><a href="../chapters/appendixes/AppendixB-CoreTasks.html#ResolvePathTask">ResolvePathTask</a></li>