Apache Zeta Components Manual :: File Source for dialog_viewer.php

Source for file dialog_viewer.php

Documentation is available at dialog_viewer.php

  1. <?php
  2. /**
  3.  * File containing the ezcConsoleDialogViewer 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.  */
  27.  
  28. /**
  29.  * Utility class for ezcConsoleDialog implementations.
  30.  * This class contains utility methods for working with {@link }
  31.  * ezcConsoleDialog} implementations.
  32.  *
  33.  * To display a dialog in a loop until a valid result is received do:
  34.  * <code>
  35.  * // Instatiate dialog in $dialog ...
  36.  * ezcConsoleDialogViewer::displayDialog( $dialog );
  37.  * </code>
  38.  *
  39.  * For implementing a custom dialog, the method {@link readLine()} method can be
  40.  * used to read a line of input from the user.
  41.  * 
  42.  * @package ConsoleTools
  43.  * @version //autogen//
  44.  */
  45. {
  46.     /**
  47.      * Displays a dialog and returns a valid result from it.
  48.      * This methods displays a dialog in a loop, until it received a valid
  49.      * result from it and returns this result.
  50.      * 
  51.      * @param ezcConsoleDialog $dialog The dialog to display.
  52.      * @return mixed The result from this dialog.
  53.      */
  54.     public static function displayDialogezcConsoleDialog $dialog )
  55.     {
  56.         do
  57.         {
  58.             $dialog->display();
  59.         }
  60.         while $dialog->hasValidResult(=== false );
  61.         return $dialog->getResult();
  62.     }
  63.  
  64.     /**
  65.      * Returns a line from STDIN.
  66.      * The returned line is fully trimmed.
  67.      * 
  68.      * @return string 
  69.      * @throws ezcConsoleDialogAbortException
  70.      *          if the user closes STDIN using <CTRL>-D.
  71.      */
  72.     public static function readLine()
  73.     {
  74.         $res trimfgetsSTDIN ) );
  75.         if feofSTDIN ) )
  76.         {
  77.             throw new ezcConsoleDialogAbortException();
  78.         }
  79.         return $res;
  80.     }
  81. }
  82.  
  83. ?>
Documentation generated by phpDocumentor 1.4.3