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.  */
  27.  
  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. {
  47.  
  48.     /**
  49.      * Construct a new options object.
  50.      * Options are constructed from an option array by default. The constructor
  51.      * automatically passes the given options to the __set() method to set them
  52.      * in the class.
  53.      * 
  54.      * @throws ezcBasePropertyNotFoundException
  55.      *          If trying to access a non existent property.
  56.      * @throws ezcBaseValueException
  57.      *          If the value for a property is out of range.
  58.      * @param array(string=>mixed) $options The initial options to set.
  59.      */
  60.     public function __constructarray $options array() )
  61.     {
  62.         $this->properties["text"]           "Please choose an item.";
  63.         $this->properties["formatString"]   "%3s) %s\n";
  64.         $this->properties["selectText"]     "Select: ";
  65.         $this->properties["validator"]      new ezcConsoleMenuDialogDefaultValidator();
  66.         parent::__construct$options );
  67.     }
  68.  
  69.     /**
  70.      * Property write access.
  71.      * 
  72.      * @param string $propertyName Name of the property.
  73.      * @param mixed $propertyValue The value for the property.
  74.      *
  75.      * @throws ezcBasePropertyPermissionException
  76.      *          If the property you try to access is read-only.
  77.      * @throws ezcBasePropertyNotFoundException
  78.      *          If the the desired property is not found.
  79.      * @ignore
  80.      */
  81.     public function __set$propertyName$propertyValue )
  82.     {
  83.         switch $propertyName )
  84.         {
  85.             case "text":
  86.                 if is_string$propertyValue === false || strlen$propertyValue )
  87.                 {
  88.                     throw new ezcBaseValueException(
  89.                         $propertyName,
  90.                         $propertyValue,
  91.                         "string, length > 0"
  92.                     );
  93.                 }
  94.                 break;
  95.             case "selectText":
  96.                 if is_string$propertyValue === false )
  97.                 {
  98.                     throw new ezcBaseValueException(
  99.                         $propertyName,
  100.                         $propertyValue,
  101.                         "string"
  102.                     );
  103.                 }
  104.                 break;
  105.             case "formatString":
  106.                 if is_string$propertyValue === false )
  107.                 {
  108.                     throw new ezcBaseValueException(
  109.                         $propertyName,
  110.                         $propertyValue,
  111.                         "string"
  112.                     );
  113.                 }
  114.                 break;
  115.             case "validator":
  116.                 if ( ( $propertyValue instanceof ezcConsoleMenuDialogValidator === false )
  117.                 {
  118.                     throw new ezcBaseValueException(
  119.                         $propertyName,
  120.                         $propertyValue,
  121.                         "ezcConsoleMenuDialogValidator"
  122.                     );
  123.                 }
  124.             default:
  125.                 parent::__set$propertyName$propertyValue );
  126.         }
  127.         $this->properties[$propertyName$propertyValue;
  128.     }
  129. }
  130.  
  131. ?>
Documentation generated by phpDocumentor 1.4.3