* regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * @package ConsoleTools * @version //autogentag// * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 */ require_once dirname(__FILE__) . "/../../../../Base/src/base.php"; function __autoload($className) { ezcBase::autoload($className); } $out = new ezcConsoleOutput(); $opts = new ezcConsoleQuestionDialogOptions(); $opts->text = "Do you want to proceed?"; $opts->showResults = true; $opts->validator = new ezcConsoleQuestionDialogCollectionValidator(array("y", "n"), "n", ezcConsoleQuestionDialogCollectionValidator::CONVERT_LOWER); $dialog = new ezcConsoleQuestionDialog($out, $opts); echo "The user decided to " . (ezcConsoleDialogViewer::displayDialog($dialog) === "n" ? "not " : "") . "proceed.\n";
* distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * @package ConsoleTools * @version //autogentag// * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 */ require_once dirname(__FILE__) . "/../../../../Base/src/base.php"; function __autoload($className) { ezcBase::autoload($className); } $out = new ezcConsoleOutput(); $opts = new ezcConsoleQuestionDialogOptions(); $opts->text = "Please enter your email address: "; $opts->validator = new ezcConsoleQuestionDialogRegexValidator("/[a-z0-9_\\.]+@[a-z0-9_\\.]+\\.[a-z0-9_\\.]+/"); $dialog = new ezcConsoleQuestionDialog($out, $opts); echo "The email address is " . ezcConsoleDialogViewer::displayDialog($dialog) . ".\n";
<?php require_once "Base/src/base.php"; function __autoload($className) { ezcBase::autoload($className); } $out = new ezcConsoleOutput(); $dialog = ezcConsoleQuestionDialog::YesNoQuestion($out, "Is the answer to everything 42?", "y"); if (($res = ezcConsoleDialogViewer::displayDialog($dialog)) === "y") { echo "You are so right! Don't forget your towel! :)\n"; } else { echo "You should better read some Douglas Adams!\n"; }
function userWantsToOverrideElement($target) { // setting default action $option = 'prompt'; // check if there is set any default prompt option, and set this to the option if ($this->cfg->getSetting('account', 'Accounts', 'DefaultPromptOption')) { $option = $this->cfg->getSetting('account', 'Accounts', 'DefaultPromptOption'); } // if the ini file say that we alway should answear the prompt with the default answer we return false if ($option == 'use_default') { return false; } $this->output->formats->question->color = 'yellow'; $question = new ezcConsoleQuestionDialog($this->output); $question->options->text = "The element {$target} already exists on the new installation. Do you want to override it?"; $question->options->format = 'question'; $question->options->showResults = true; $question->options->validator = new ezcConsoleQuestionDialogCollectionValidator(array("y", "n"), "n", ezcConsoleQuestionDialogCollectionValidator::CONVERT_LOWER); // if the answer is yes if (ezcConsoleDialogViewer::displayDialog($question) == 'y') { return true; } else { return false; } }
/** * Displays the dialog and retreives a value from the user. * Displays the dialog and retreives the desired answer from the user. If * the a valid result is retrieved, it can be obtained using {@link * getResult()}. The method {@link hasValidResult()} can be used to check * if a valid result is available. * * @return void * @throws ezcConsoleDialogAbortException * if the user closes STDIN using <CTRL>-D. */ public function display() { $this->reset(); $this->output->outputText($this->options->text . ($this->options->showResults === true ? " " . $this->options->validator->getResultString() : "") . " ", $this->options->format); $result = $this->options->validator->fixup(ezcConsoleDialogViewer::readLine()); if ($this->options->validator->validate($result)) { $this->result = $result; } }
* to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * @package ConsoleTools * @version //autogentag// * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 */ require_once "Base/src/base.php"; function __autoload($className) { ezcBase::autoload($className); } $out = new ezcConsoleOutput(); $opts = new ezcConsoleMenuDialogOptions(); $opts->text = "Please choose a possibility:\n"; $opts->validator = new ezcConsoleMenuDialogDefaultValidator(array("A" => "Selection A", "B" => "Selection B", "C" => "Selection C", "D" => "Selection D", "Z" => "Selection Z"), "Z", ezcConsoleMenuDialogDefaultValidator::CONVERT_UPPER); $dialog = new ezcConsoleMenuDialog($out, $opts); while (($res = ezcConsoleDialogViewer::displayDialog($dialog)) !== 'Z') { echo "User seletced {$res}\n"; } echo "User quitted\n";
* distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * @package ConsoleTools * @version //autogentag// * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 */ require_once "Base/src/base.php"; function __autoload($className) { ezcBase::autoload($className); } $out = new ezcConsoleOutput(); $opts = new ezcConsoleMenuDialogOptions(); $opts->text = "Please choose a possibility:\n"; $opts->validator = new ezcConsoleMenuDialogDefaultValidator(array("A" => "Selection A", "B" => "Selection B", "C" => "Selection C", "D" => "Selection D", "Z" => "Selection Z"), "Z", ezcConsoleMenuDialogDefaultValidator::CONVERT_UPPER); $dialog = new ezcConsoleMenuDialog($out, $opts); $res = ezcConsoleDialogViewer::displayDialog($dialog); echo "User seletced {$res}\n";
/** * Displays the dialog and retreives a value from the user. * Displays the dialog and retreives the desired answer from the user. If * the a valid result is retrieved, it can be obtained using {@link * getResult()}. The method {@link hasValidResult()} can be used to check * if a valid result is available. * * @return void * @throws ezcConsoleDialogAbortException * if the user closes STDIN using <CTRL>-D. */ public function display() { $this->reset(); $text = "{$this->options->text}\n"; foreach ($this->options->validator->getElements() as $key => $entry) { $text .= sprintf($this->options->formatString, $key, $entry); } $text .= "\n{$this->options->selectText}{$this->options->validator->getResultString()} "; $this->output->outputText($text, $this->options->format); $result = $this->options->validator->fixup(ezcConsoleDialogViewer::readLine()); if ($this->options->validator->validate($result)) { $this->result = $result; } }
<?php require_once 'tutorial_autoload.php'; $output = new ezcConsoleOutput(); $menu = new ezcConsoleMenuDialog($output); $menu->options = new ezcConsoleMenuDialogOptions(); $menu->options->text = "Please choose a possibility:\n"; $menu->options->validator = new ezcConsoleMenuDialogDefaultValidator(array("1" => "Perform some more actions", "2" => "Perform another action", "0" => "Quit"), "0"); while (($choice = ezcConsoleDialogViewer::displayDialog($menu)) != 0) { switch ($choice) { case 1: echo "Performing some more actions...\n"; break; case 2: echo "Performing some other actions!\n"; break; } }
function checkpoint($exitedOn, $extraText = '', $forceCheckpoint = false) { if ($this->checkpoint or $forceCheckpoint) { $this->output->formats->question->color = 'blue'; $question = new ezcConsoleQuestionDialog($this->output); $question->options->text = $extraText . "Do you want to continue?"; $question->options->format = 'question'; $question->options->showResults = true; $question->options->validator = new ezcConsoleQuestionDialogCollectionValidator(array("y", "n"), "y", ezcConsoleQuestionDialogCollectionValidator::CONVERT_LOWER); // if the answer is yes if (ezcConsoleDialogViewer::displayDialog($question) == 'y') { return true; } else { $this->log('Exited on: ' . $exitedOn, 'critical'); } } return true; }
<?php require_once 'tutorial_autoload.php'; $output = new ezcConsoleOutput(); $question = ezcConsoleQuestionDialog::YesNoQuestion($output, "Do you want to proceed?", "y"); do { echo "\nSome action performed...\n\n"; } while (ezcConsoleDialogViewer::displayDialog($question) !== "n"); echo "Goodbye!\n";
$script->setUseDebugAccumulators(true); $user = eZUser::fetchByName('admin'); eZUser::setCurrentlyLoggedInUser($user, $user->attribute('contentobject_id')); $varDir = eZSys::varDirectory(); if ($options['from_path']) { $path = $options['from_path']; } else { $cli->error("Specifica il percorso da sostituire"); $script->shutdown(); eZExecution::cleanExit(); } $path = rtrim($path, '/') . '/'; $varDir = rtrim($varDir, '/') . '/'; $output = new ezcConsoleOutput(); $question = ezcConsoleQuestionDialog::YesNoQuestion($output, "Correggo i percorsi per VarDir: da \"{$path}\" a \"{$varDir}\" ?", "y"); if (ezcConsoleDialogViewer::displayDialog($question) == "n") { $script->shutdown(); eZExecution::cleanExit(); } else { $cli->output("Process ezimagefile table"); $list = eZImageFile::fetchObjectList(eZImageFile::definition()); foreach ($list as $item) { $newPath = str_replace($path, $varDir, $item->attribute('filepath')); if ($newPath != $item->attribute('filepath')) { $cli->output("Fix attribute " . $item->attribute('contentobject_attribute_id') . " " . $item->attribute('filepath')); eZImageFile::moveFilepath($item->attribute('contentobject_attribute_id'), $item->attribute('filepath'), $newPath); } $attributes = eZPersistentObject::fetchObjectList(eZContentObjectAttribute::definition(), null, array('id' => $item->attribute('contentobject_attribute_id'))); foreach ($attributes as $attribute) { $newDataText = str_replace($path, $varDir, $attribute->attribute('data_text')); $attribute->setAttribute('data_text', $newDataText);