Do it! Prompt the user for information!

@return string
519302
public function prompt()
    {
        $this->writePrompt();

        $response = $this->valueOrDefault($this->getUserInput());

        if ($this->isValidResponse($response)) {
            return $response;
        }

        return $this->prompt();
    }
1366295
protected function getInput()
	{
		Behavior::tooltip();

		// Initialise some field attributes.
		$section    = $this->element['section'] ? (string) $this->element['section'] : '';
		$component  = $this->element['component'] ? (string) $this->element['component'] : '';
		$assetField = $this->element['asset_field'] ? (string) $this->element['asset_field'] : 'asset_id';

		// Get the actions for the asset.
		$comfile = $component ? App::get('component')->path($component) . '/config/access.xml' : '';
		$sectioned = "/access/section[@name='" . ($section ?: 'component') . "']/";

		$actions = Access::getActionsFromFile($comfile, $sectioned);

		// Iterate over the children and add to the actions.
		foreach ($this->element->children() as $el)
		{
			if ($el->getName() == 'action')
			{
				$actions[] = (object) array(
					'name' => (string) $el['name'],
					'title' => (string) $el['title'],
					'description' => (string) $el['description']
				);
			}
		}

		// Get the explicit rules for this asset.
		if ($section == 'component')
		{
			// Need to find the asset id by the name of the component.
			$db = App::get('db');

			$query = $db->getQuery()
				->select('id')
				->from('#__assets')
				->whereEquals('name', $component);
			$db->setQuery($query->toString());
			$assetId = (int) $db->loadResult();

			if ($error = $db->getErrorMsg())
			{
				throw new Exception(500, $error);
			}
		}
		else
		{
			// Find the asset id of the content.
			// Note that for global configuration, com_config injects asset_id = 1 into the form.
			$assetId = $this->form->getValue($assetField);
		}

		// Full width format.

		// Get the rules for just this asset (non-recursive).
		$assetRules = Access::getAssetRules($assetId);

		// Get the available user groups.
		$groups = $this->getUserGroups();

		// Build the form control.
		$curLevel = 0;

		$lang = App::get('language');

		// Prepare output
		$html = array();
		$html[] = '<div id="permissions-sliders" class="pane-sliders">';
		$html[] = '<p class="rule-desc">' . $lang->txt('JLIB_RULES_SETTINGS_DESC') . '</p>';
		$html[] = '<div id="permissions-rules">';
		// If AssetId is blank and section wasn't set to component, set it to the component name here for inheritance checks.
		$assetId = empty($assetId) && $section != 'component' ? $component : $assetId;

		// Start a row for each user group.
		foreach ($groups as $group)
		{
			$difLevel = $group->level - $curLevel;

			$html[] = '<h3 class="pane-toggler title"><a href="javascript:void(0);"><span>';
			$html[] = str_repeat('<span class="level">|&ndash;</span> ', $curLevel = $group->level) . $group->text;
			$html[] = '</span></a></h3>';
			$html[] = '<div class="panel">';
			$html[] = '<div class="pane-slider content pane-hide">';

			$html[] = '<table class="group-rules">';
			$html[] = '<thead>';
			$html[] = '<tr>';

			$html[] = '<th class="actions" id="actions-th' . $group->value . '">';
			$html[] = '<span class="acl-action">' . $lang->txt('JLIB_RULES_ACTION') . '</span>';
			$html[] = '</th>';

			$html[] = '<th class="settings" id="settings-th' . $group->value . '">';
			$html[] = '<span class="acl-action">' . $lang->txt('JLIB_RULES_SELECT_SETTING') . '</span>';
			$html[] = '</th>';

			// The calculated setting is not shown for the root group of global configuration.
			$canCalculateSettings = ($group->parent_id || !empty($component));
			if ($canCalculateSettings)
			{
				$html[] = '<th id="aclactionth' . $group->value . '">';
				$html[] = '<span class="acl-action">' . $lang->txt('JLIB_RULES_CALCULATED_SETTING') . '</span>';
				$html[] = '</th>';
			}

			$html[] = '</tr>';
			$html[] = '</thead>';
			$html[] = '<tbody>';

			foreach ($actions as $action)
			{
				$html[] = '<tr>';
				$html[] = '<td headers="actions-th' . $group->value . '">';
				$html[] = '<label class="hasTip" for="' . $this->id . '_' . $action->name . '_' . $group->value . '" title="' . htmlspecialchars($lang->txt($action->title) . '::' . $lang->txt($action->description), ENT_COMPAT, 'UTF-8') . '">';
				$html[] = $lang->txt($action->title);
				$html[] = '</label>';
				$html[] = '</td>';

				$html[] = '<td headers="settings-th' . $group->value . '">';

				$html[] = '<select name="' . $this->name . '[' . $action->name . '][' . $group->value . ']" id="' . $this->id . '_' . $action->name
					. '_' . $group->value . '" title="'
					. $lang->txt('JLIB_RULES_SELECT_ALLOW_DENY_GROUP', $lang->txt($action->title), trim($group->text)) . '">';
				$inheritedRule = Access::checkGroup($group->value, $action->name, $assetId);

				// Get the actual setting for the action for this group.
				$assetRule = $assetRules->allow($action->name, $group->value);

				// Build the dropdowns for the permissions sliders

				// The parent group has "Not Set", all children can rightly "Inherit" from that.
				$html[] = '<option value=""' . ($assetRule === null ? ' selected="selected"' : '') . '>' . $lang->txt(empty($group->parent_id) && empty($component) ? 'JLIB_RULES_NOT_SET' : 'JLIB_RULES_INHERITED') . '</option>';
				$html[] = '<option value="1"' . ($assetRule === true ? ' selected="selected"' : '') . '>' . $lang->txt('JLIB_RULES_ALLOWED') . '</option>';
				$html[] = '<option value="0"' . ($assetRule === false ? ' selected="selected"' : '') . '>' . $lang->txt('JLIB_RULES_DENIED') . '</option>';

				$html[] = '</select>&#160; ';

				// If this asset's rule is allowed, but the inherited rule is deny, we have a conflict.
				if (($assetRule === true) && ($inheritedRule === false))
				{
					$html[] = $lang->txt('JLIB_RULES_CONFLICT');
				}

				$html[] = '</td>';

				// Build the Calculated Settings column.
				// The inherited settings column is not displayed for the root group in global configuration.
				if ($canCalculateSettings)
				{
					$html[] = '<td headers="aclactionth' . $group->value . '">';

					// This is where we show the current effective settings considering currrent group, path and cascade.
					// Check whether this is a component or global. Change the text slightly.
					if (Access::checkGroup($group->value, 'core.admin', $assetId) !== true)
					{
						if ($inheritedRule === null)
						{
							$html[] = '<span class="icon-16-unset">' . $lang->txt('JLIB_RULES_NOT_ALLOWED') . '</span>';
						}
						elseif ($inheritedRule === true)
						{
							$html[] = '<span class="icon-16-allowed">' . $lang->txt('JLIB_RULES_ALLOWED') . '</span>';
						}
						elseif ($inheritedRule === false)
						{
							if ($assetRule === false)
							{
								$html[] = '<span class="icon-16-denied">' . $lang->txt('JLIB_RULES_NOT_ALLOWED') . '</span>';
							}
							else
							{
								$html[] = '<span class="icon-16-denied"><span class="icon-16-locked">' . $lang->txt('JLIB_RULES_NOT_ALLOWED_LOCKED') . '</span></span>';
							}
						}
					}
					elseif (!empty($component))
					{
						$html[] = '<span class="icon-16-allowed"><span class="icon-16-locked">' . $lang->txt('JLIB_RULES_ALLOWED_ADMIN') . '</span></span>';
					}
					else
					{
						// Special handling for  groups that have global admin because they can't  be denied.
						// The admin rights can be changed.
						if ($action->name === 'core.admin')
						{
							$html[] = '<span class="icon-16-allowed">' . $lang->txt('JLIB_RULES_ALLOWED') . '</span>';
						}
						elseif ($inheritedRule === false)
						{
							// Other actions cannot be changed.
							$html[] = '<span class="icon-16-denied"><span class="icon-16-locked">' . $lang->txt('JLIB_RULES_NOT_ALLOWED_ADMIN_CONFLICT') . '</span></span>';
						}
						else
						{
							$html[] = '<span class="icon-16-allowed"><span class="icon-16-locked">' . $lang->txt('JLIB_RULES_ALLOWED_ADMIN') . '</span></span>';
						}
					}

					$html[] = '</td>';
				}

				$html[] = '</tr>';
			}

			$html[] = '</tbody>';
			$html[] = '</table>';

			$html[] = '</div></div>';
		}

		$html[] = '</div><div class="rule-notes">';
		if ($section == 'component' || $section == null)
		{
			$html[] = $lang->txt('JLIB_RULES_SETTING_NOTES');
		}
		else
		{
			$html[] = $lang->txt('JLIB_RULES_SETTING_NOTES_ITEM');
		}
		$html[] = '</div>';
		$html[] = '</div>';

		$js = "jQuery(document).ready(function($){
				$('div#permissions-rules').accordion({
					heightStyle: 'content'
				});
			});";

		App::get('document')->addScriptDeclaration($js);

		return implode("\n", $html);
	}
1013538
public function getHelp()
    {
        print Color::head('Help:') . PHP_EOL;
        print Color::colorize('  Lists the commands available in Console') . PHP_EOL . PHP_EOL;

        $this->run([]);
    }
228869
protected function askForUsers()
    {
        $default = 0;
        $users = $this->users();
        $user_names = array_merge(
            ['Skip'],
            collect($users)->pluck('name')->toArray()
        );

        $selected_user_names =  $this->choice('Users?', $user_names ,$default, null, true);

        if ($selected_user_names == 0) return null;
        $users = collect($users)->filter(function ($user) use ($selected_user_names) {
            return in_array($user->name,$selected_user_names);
        });

        return $users->pluck('id');
    }
618755
private function commandResponseInfo()
    {
        $configCode = '';
        $configCode .= 'App\Providers\Bindings\\';
        
        if ($this->getFolderOptionInput()) {
            $configCode .= $this->getFolderOptionInput() . '\\'; 
        }
        
        $configCode .= $this->getNameInput() .'ServiceProvider::class';

        return $configCode;
    }
1023807
protected function getCommandInput()
    {
        $appName = trim($this->argument('application-name'));
        $layoutFileName = Helpers::postFixWith(trim($this->option('layout-filename')) ?: 'layout-filename', '.blade.php');
        $layoutDirectory = trim($this->option('layout-directory'));
        $withoutValidation = $this->option('without-validation');
        $force = $this->option('force');

        return (object) compact('appName', 'layoutFileName', 'layoutDirectory', 'withoutValidation', 'force');
    }
613041
protected function askForAnswers() {
    $this->say("<info>Let's start by entering some information about your project.</info>");
    $answers['human_name'] = $this->askDefault("Project name (human readable):", $this->getConfigValue('project.human_name'));
    $default_machine_name = StringManipulator::convertStringToMachineSafe($answers['human_name']);
    $answers['machine_name'] = $this->askDefault("Project machine name:", $default_machine_name);
    $default_prefix = StringManipulator::convertStringToPrefix($answers['human_name']);
    $answers['prefix'] = $this->askDefault("Project prefix:", $default_prefix);

    $this->say("<info>Great. Now let's make some choices about how your project will be set up.</info>");
    $answers['vm'] = $this->confirm('Do you want to create a VM?');
    $ci = $this->confirm('Do you want to use Continuous Integration?');
    if ($ci) {
      $provider_options = [
        'pipelines' => 'Acquia Pipelines',
        'travis' => 'Travis CI',
      ];
      $answers['ci']['provider'] = $this->askChoice('Choose a Continuous Integration provider:', $provider_options, 'travis');
    }

    $cm = $this->confirm('Do you want use Drupal core configuration management?');
    if ($cm) {
      $strategy_options = [
        'config-split' => 'Config Split (recommended)',
        'features' => 'Features',
        'core-only' => 'Core only',
      ];
      $answers['cm']['strategy'] = $this->askChoice('Choose a configuration management strategy:', $strategy_options, 'config-split');
    }
    else {
      $answers['cm']['strategy'] = 'none';
    }

    $profile_options = [
      'lightning' => 'Lightning',
      'minimal' => 'Minimal',
      'standard' => 'Standard',
    ];
    $this->say("You may change the installation profile later.");
    $answers['profile'] = $this->askChoice('Choose an installation profile:', $profile_options, 'lightning');

    return $answers;
  }
520322
protected function askQuestion()
    {
        //  Ask away cap'n!
        $this->data['page']->title = lang('auth_twofactor_answer_title');
        $this->loadStyles(NAILS_APP_PATH . 'application/modules/auth/views/mfa/question/ask.php');
        Factory::service('View')
            ->load([
                'structure/header/blank',
                'auth/mfa/question/ask',
                'structure/footer/blank',
            ]);
    }
69843
private function package_prompt()
    {
        $question = new ChoiceQuestion(
            "\nPlease choose a package to publish:",
            Config::get('services.providers')
        );

        $question->setErrorMessage('[%s] is invalid.');

        return $this->helper->ask($this->input, $this->output, $question);
    }
1122163
protected function getInput() {

        @set_time_limit(120);
        @ini_set('max_execution_time', 120);

        // Initialisation.
        $html = array();
        $text = $this->getText();

        // JS
        (new RequireJSUtility())
            ->addDomReadyJS("$('[data-toggle=\"tooltip\"], .hasTooltip').tooltip({container:'body',html:true});", false, "bootstrap");

        if (!empty($this->value)) {
            $value = new Registry($this->value);
        }

        $class = $this->element['class'] ? ' ' . (string)$this->element['class'] : '';

        // On récupère l'instance de gestion ACL.
        $acl    = Acl::getInstance($this->form->getDb());
	    $simple = $acl->getSimpleAcl();

        // On récupère les sections et les actions.
        $actions = $this->getActions();

        // On charge les groupes utilisateurs.
        $groups = $this->getUserGroups();

	    // On charge les rôles.
	    $roles = $acl->getRoles();

        // Building tab nav
        $html[] = '<div role="tabpanel" class="nav-tabs-left">';

        $html[] = '<ul class="nav nav-tabs" role="tablist">';

        foreach ($groups as $i => $group) {
            $tab_class = $i == 0 ? ' class="active"' : '';
            $html[] = '<li role="presentation"' . $tab_class . '><a href="#group-' . $group->id . '" aria-controls="group-' . $group->id . '" role="tab" data-toggle="tab">';
            $html[] = str_repeat('<span class="level">&ndash;</span> ', $curLevel = $group->level) . $group->title;
            $html[] = '</a></li>';
        }

        $html[] = '</ul>';
        $html[] = '<div class="tab-content">';

        foreach ($groups as $i => $group) {

            $tab_class = $i == 0 ? ' active' : '';

            $html[] = '<div role="tabpanel" class="tab-pane' . $tab_class .'" id="group-' . $group->id . '">';

            $html[] = '<table class="rights table table-condensed' . $class . '">';

            $html[] = '<thead>';
            $html[] = '<tr>';
            $html[] = '<th>' . $text->translate('APP_GLOBAL_RIGHTS_HEADING_SECTION') . '</th>';
            $html[] = '<th>' . $text->translate('APP_GLOBAL_RIGHTS_HEADING_ACTION') . '</th>';
            $html[] = '<th>' . $text->translate('APP_GLOBAL_RIGHTS_HEADING_RIGHT') . '</th>';

            if ($group->parent_id) {
                $html[] = '<th id="aclactionth' . $group->id . '">';
                $html[] = '<span class="acl-action">' . $text->translate('APP_GLOBAL_RIGHTS_HEADING_CALCULATED_SETTING') . '</span>';
                $html[] = '</th>';
            }

            $html[] = '</tr>';
            $html[] = '</thead>';

            $html[] = '<tbody>';

            // On parcourt les sections.
            foreach ($actions as $section) {

                $rowspan = count($section->actions);

                foreach ($section->actions as $i => $action) {

                    $html[] = '<tr>';

                    if ($i == 0) {
                        $html[] = '<td class="section" rowspan="' . $rowspan . '"><span class="hasTooltip" title="' . $text->translate($section->description) . '">' . $text->translate($section->title) . '</td>';
                    }

                    $html[] = '<td class="action"><span class="hasTooltip" title="' . $text->translate($action->description) . '">' . $text->translate($action->title) . '</td>';
                    $html[] = '<td class="right">';

                    $html[] = '<select class="form-control input-sm"'
                        . ' name="' . $this->name . '[' . $section->name . '][' . $action->name . '][' . $group->id . ']"'
                        . ' id="' . $this->id . '_' . $section->name . '_' . $action->name	. '_' . $group->id . '"'
                        . ' title="' . $text->sprintf('APP_GLOBAL_RIGHTS_SELECT_ALLOW_DENY_GROUP', $text->translate($action->title), trim($group->title)) . '">';

                    // On récupère les droits pour l'action hérités pour le groupe.
                    $inheritedRule = $acl->checkGroup($group->id, $section->name, $action->name);

                    // On récupère les droits pour l'action NON HÉRITÉS pour le groupe.
                    $assetRule = null;

	                $groups = new RoleAggregate();
	                $groups->addRole($roles[$group->id]);
                    $res = $simple->isAllowedReturnResult($groups, $section->name, $action->name)->collection;

                    if ($res->count() > 0) {
                        $res->top();
                        while($res->valid()) {
                            $priority = $res->current()->getPriority();

                            // La règle est appliqué à ce groupe en particulier si la priorité est à zero.
                            if ($priority == 0) {
                                $assetRule = $res->current()->getAction();
                            }

                            $res->next();
                        }
                    }

                    // Build the dropdowns for the permissions sliders

                    // The parent group has "Not Set", all children can rightly "Inherit" from that.
                    $html[] = '<option value=""' . ($assetRule === null ? ' selected="selected"' : '') . '>'
                        . $text->translate(empty($group->parent_id) ? 'APP_GLOBAL_RIGHTS_NOT_SET' : 'APP_GLOBAL_RIGHTS_INHERITED') . '</option>';
                    $html[] = '<option value="1"' . ($assetRule === true ? ' selected="selected"' : '') . '>' . $text->translate('APP_GLOBAL_RIGHTS_ALLOWED')
                        . '</option>';
                    $html[] = '<option value="0"' . ($assetRule === false ? ' selected="selected"' : '') . '>' . $text->translate('APP_GLOBAL_RIGHTS_DENIED')
                        . '</option>';

                    $html[] = '</select>&#160; ';

                    // If this asset's rule is allowed, but the inherited rule is deny, we have a conflict.
                    if (($assetRule === true) && ($inheritedRule === false)) {
                        $html[] = $text->translate('APP_GLOBAL_RIGHTS_CONFLICT');
                    }

                    $html[] = '</td>';

                    // Build the Calculated Settings column.
                    // The inherited settings column is not displayed for the root group in global configuration.
                    if ($group->parent_id) {

                        $html[] = '<td headers="aclactionth' . $group->id . '">';

                        // This is where we show the current effective settings considering currrent group, path and cascade.
                        // Check whether this is a component or global. Change the text slightly.

                        if ($acl->checkGroup($group->id, "app", "admin") !== true) {

                            if ($inheritedRule === true) {
                                $html[] = '<span class="label label-success">' . $text->translate('APP_GLOBAL_RIGHTS_ALLOWED') . '</span>';
                            } elseif ($inheritedRule === false) {
                                $html[] = '<span class="label label-danger">' . $text->translate('APP_GLOBAL_RIGHTS_NOT_ALLOWED') . '</span>';
                            }

                        } elseif ($section->name != 'app') {
                                $html[] = '<span class="label label-success"><i class="fa fa-lock"></i> ' . $text->translate('APP_GLOBAL_RIGHTS_ALLOWED_ADMIN')
                                    . '</span>';
                        } else {

                            // Special handling for  groups that have global admin because they can't  be denied.
                            // The admin rights can be changed.

                            if ($section->name === 'app' && $action->name === 'admin') {
                                $html[] = '<span class="label label-success">' . $text->translate('APP_GLOBAL_RIGHTS_ALLOWED') . '</span>';
                            } elseif ($inheritedRule === false) {
                                // Other actions cannot be changed.
                                $html[] = '<span class="label label-danger"><i class="fa fa-lock"></i> '
                                    . $text->translate('APP_GLOBAL_RIGHTS_NOT_ALLOWED_ADMIN_CONFLICT') . '</span>';
                            } else {
                                $html[] = '<span class="label label-success"><i class="fa fa-lock"></i> ' . $text->translate('APP_GLOBAL_RIGHTS_ALLOWED_ADMIN')
                                    . '</span>';
                            }
                        }

                        $html[] = '</td>';
                    }

                    $html[] = '</tr>';

                }

            }


            $html[] = '';
            $html[] = '';
            $html[] = '';
            $html[] = '</tbody>';

            $html[] = '</table>';

            $html[] = '</div>';

        }

        $html[] = '</div>';
        $html[] = '</div>';

        return implode($html);

    }
946105
public function help()
    {
        $this->usage(false);
        echo "\n";
        echo "available options:";
        echo "\n";

        foreach (self::$OPTIONS as $option) {
            list($long, $short, $mode, $comment) = $option;
            if ($mode == pakeGetopt::REQUIRED_ARGUMENT) {
                if (preg_match('/\b([A-Z]{2,})\b/', $comment, $match))
                    $long .= '='.$match[1];
            }

            printf("  %-20s", pakeColor::colorize($long, 'INFO'));
            if (!empty($short)) {
                printf(" (%s)", pakeColor::colorize($short, 'INFO'));
            }
            printf("\n      %s\n", $comment);
        }
    }
391182
protected function askForNewPassword()
    {
        $this->password = $this->ask('What would you like to set the password to?');

        $q = $this->ask('Confirm the password as "' . $this->password . '" [y/n]');

        if (strtolower($q) != 'y') {
            return $this->askForNewPassword();
        }
    }
395298
public function confirmInformationAction()
    {
        $accountInfo = $this->checkAccountInformation();

        if ($accountInfo) {
            return $accountInfo;
        }

        $this->title("Confirm Information");
        return $this->render("steps/confirm_information.phtml");
    }
1197789
public function getDescription(): string
    {
        if (\is_array($this->haystack)) {
            $haystack = implode(', ', $this->haystack);
        } else {
            $haystack = $this->haystack;
        }
        return __('must be in "%s"', $haystack);
    }
1193411
public function getActionText()
    {
        switch ($this->action) {
            case 'ask':
                return Yii::t('credit', 'Ask questions');
                break;
            case 'answer_question':
                return Yii::t('credit', 'Answered the question');
                break;
            case 'answer_adopted':
                return Yii::t('credit', 'answer is adopted');
                break;
            default:
                return null;
                break;
        }
    }
402081
protected function getScriptText()
    {
        $actionName = Builder::escapeText($this->actionName);
        $key        = null;
        $value      = null;
        if ($this->keyName !== null) {
            $key   = "KeyName";
            $value = $this->keyName;
        } else if ($this->keyCode !== null) {
            $key   = "KeyCode";
            $value = $this->keyCode;
        } else if ($this->charPressed !== null) {
            $key   = "CharPressed";
            $value = $this->charPressed;
        }
        $value = Builder::escapeText($value);
        return "
if (Event.{$key} == {$value}) {
	TriggerPageAction({$actionName});
}";
    }
80032
protected function getActionText()
    {
        if ($this->hasBeenSent()) {
            $action = 'action_sent';
        } elseif ($this->isSendingPrevented()) {
            $action = 'action_not_sent';
        } else {
            $action = 'action_unknown';
        }
        return $this->t($action);
    }