function confirmDialog($params)
    {
        $answers = $prompts = $types = array();
        foreach ($params as $param) {
            $prompts[$param['name']] = $param['prompt'];
            $types[$param['name']]   = $param['type'];
            $answers[$param['name']] = isset($param['default']) ? $param['default'] : '';
        }

        $tried = false;
        do {
            if ($tried) {
                $i = 1;
                foreach ($answers as $var => $value) {
                    if (!strlen($value)) {
                        echo $this->bold("* Enter an answer for #" . $i . ": ({$prompts[$var]})\n");
                    }
                    $i++;
                }
            }

            $answers = $this->userDialog('', $prompts, $types, $answers);
            $tried   = true;
        } while (is_array($answers) && count(array_filter($answers)) != count($prompts));

        return $answers;
    }
function confirmDialog($params)
    {
        $answers = $prompts = $types = array();
        foreach ($params as $param) {
            $prompts[$param['name']] = $param['prompt'];
            $types[$param['name']]   = $param['type'];
            $answers[$param['name']] = isset($param['default']) ? $param['default'] : '';
        }

        $tried = false;
        do {
            if ($tried) {
                $i = 1;
                foreach ($answers as $var => $value) {
                    if (!strlen($value)) {
                        echo $this->bold("* Enter an answer for #" . $i . ": ({$prompts[$var]})\n");
                    }
                    $i++;
                }
            }

            $answers = $this->userDialog('', $prompts, $types, $answers);
            $tried   = true;
        } while (is_array($answers) && count(array_filter($answers)) != count($prompts));

        return $answers;
    }
function confirmDialog ( $ params ) { $ answers = $ prompts = $ types = array ( ) ; foreach ( $ params as $ param ) { $ prompts [ $ param [ 'name' ] ] = $ param [ 'prompt' ] ; $ types [ $ param [ 'name' ] ] = $ param [ 'type' ] ; $ answers [ $ param [ 'name' ] ] = isset ( $ param [ 'default' ] ) ? $ param [ 'default' ] : '' ; } $ tried = false ; do { if ( $ tried ) { $ i = 1 ; foreach ( $ answers as $ var => $ value ) { if ( ! strlen ( $ value ) ) { echo $ this -> bold ( "* Enter an answer for #" . $ i . ": ({$prompts[$var]})\n" ) ; } $ i ++ ; } } $ answers = $ this -> userDialog ( '' , $ prompts , $ types , $ answers ) ; $ tried = true ; } while ( is_array ( $ answers ) && count ( array_filter ( $ answers ) ) != count ( $ prompts ) ) ; return $ answers ; }
Ask for user input, confirm the answers and continue until the user is satisfied
@param array an array of arrays, format array('name' => 'paramname', 'prompt' =>
'text to display', 'type' => 'string'[, default => 'default value'])
@return array
Ask for user input confirm the answers and continue until the user is satisfied