本文整理汇总了PHP中Input类的典型用法代码示例。如果您正苦于以下问题:PHP Input类的具体用法?PHP Input怎么用?PHP Input使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Input类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sortInputs
/**
* Callback for sorting inputs by date then value
*
* @param Input $a
* @param Input $b
* @return int
*/
protected function sortInputs($a, $b)
{
if ($a->getDate() == $b->getDate()) {
if ($a->getValue() == $b->getValue()) {
return 0;
}
// Positive values come first, so same-day start/ends are
// incremented before they are decremented
return $a->getValue() > $b->getValue() ? -1 : 1;
}
return $a->getDate() < $b->getDate() ? -1 : 1;
}
示例2: addInput
public function addInput($value, $type_sensor)
{
$new_input = new Input();
$new_input->setInformation($value);
$new_input->setType($type_sensor);
$this->setInput($new_input);
}
示例3: handle
/**
* {@inheritdoc}
*/
public function handle(\Input $input)
{
if ($input->post('FORM_SUBMIT') == 'tl_composer_migrate_undo') {
/** @var RootPackage $rootPackage */
$rootPackage = $this->composer->getPackage();
$requires = $rootPackage->getRequires();
foreach (array_keys($requires) as $package) {
if ($package != 'contao-community-alliance/composer') {
unset($requires[$package]);
}
}
$rootPackage->setRequires($requires);
$lockPathname = preg_replace('#\\.json$#', '.lock', $this->configPathname);
/** @var DownloadManager $downloadManager */
$downloadManager = $this->composer->getDownloadManager();
$downloadManager->setOutputProgress(false);
$installer = Installer::create($this->io, $this->composer);
if (file_exists(TL_ROOT . '/' . $lockPathname)) {
$installer->setUpdate(true);
}
if ($installer->run()) {
$_SESSION['COMPOSER_OUTPUT'] .= $this->io->getOutput();
} else {
$_SESSION['COMPOSER_OUTPUT'] .= $this->io->getOutput();
$this->redirect('contao/main.php?do=composer&migrate=undo');
}
// load config
$json = new JsonFile(TL_ROOT . '/' . $this->configPathname);
$config = $json->read();
// remove migration status
unset($config['extra']['contao']['migrated']);
// write config
$json->write($config);
// disable composer client and enable repository client
$inactiveModules = deserialize($GLOBALS['TL_CONFIG']['inactiveModules']);
$inactiveModules[] = '!composer';
foreach (array('rep_base', 'rep_client', 'repository') as $module) {
$pos = array_search($module, $inactiveModules);
if ($pos !== false) {
unset($inactiveModules[$pos]);
}
}
if (version_compare(VERSION, '3', '>=')) {
$skipFile = new \File('system/modules/!composer/.skip');
$skipFile->write('Remove this file to enable the module');
$skipFile->close();
}
if (file_exists(TL_ROOT . '/system/modules/repository/.skip')) {
$skipFile = new \File('system/modules/repository/.skip');
$skipFile->delete();
}
$this->Config->update("\$GLOBALS['TL_CONFIG']['inactiveModules']", serialize($inactiveModules));
$this->redirect('contao/main.php?do=repository_manager');
}
$template = new \BackendTemplate('be_composer_client_migrate_undo');
$template->composer = $this->composer;
$template->output = $_SESSION['COMPOSER_OUTPUT'];
unset($_SESSION['COMPOSER_OUTPUT']);
return $template->parse();
}
示例4: addInput
/**
* Add an Input object to the form
*
* @param Input $input
*/
public function addInput(Input $input)
{
if ($this->disableWrappers()) {
$input->disableWrapper();
}
$this->inputs[] = $input;
}
示例5: handle
/**
* {@inheritdoc}
*/
public function handle(\Input $input)
{
$removeNames = $input->post('packages') ? explode(',', $input->post('packages')) : array($input->post('remove'));
// filter undeletable packages
$removeNames = array_filter($removeNames, function ($removeName) {
return !in_array($removeName, InstalledController::$UNDELETABLE_PACKAGES);
});
// skip empty
if (empty($removeNames)) {
$this->redirect('contao/main.php?do=composer');
}
// make a backup
copy(TL_ROOT . '/' . $this->configPathname, TL_ROOT . '/' . $this->configPathname . '~');
// update requires
$json = new JsonFile(TL_ROOT . '/' . $this->configPathname);
$config = $json->read();
if (!array_key_exists('require', $config)) {
$config['require'] = array();
}
foreach ($removeNames as $removeName) {
unset($config['require'][$removeName]);
}
$json->write($config);
$_SESSION['TL_INFO'][] = sprintf($GLOBALS['TL_LANG']['composer_client']['removeCandidate'], implode(', ', $removeNames));
$_SESSION['COMPOSER_OUTPUT'] .= $this->io->getOutput();
$this->redirect('contao/main.php?do=composer');
}
示例6: handle
/**
* {@inheritdoc}
*
* @SuppressWarnings(PHPMD.LongVariable)
*/
public function handle(\Input $input)
{
$packageName = $input->get('install');
if ($packageName == 'contao/core') {
$this->redirect('contao/main.php?do=composer');
}
if ($input->post('version')) {
$version = base64_decode(rawurldecode($input->post('version')));
// make a backup
copy(TL_ROOT . '/' . $this->configPathname, TL_ROOT . '/' . $this->configPathname . '~');
// update requires
$json = new JsonFile(TL_ROOT . '/' . $this->configPathname);
$config = $json->read();
if (!array_key_exists('require', $config)) {
$config['require'] = array();
}
$config['require'][$packageName] = $version;
ksort($config['require']);
$json->write($config);
Messages::addInfo(sprintf($GLOBALS['TL_LANG']['composer_client']['added_candidate'], $packageName, $version));
$_SESSION['COMPOSER_OUTPUT'] .= $this->io->getOutput();
$this->redirect('contao/main.php?do=composer');
}
$installationCandidates = $this->searchPackage($packageName);
if (empty($installationCandidates)) {
Messages::addError(sprintf($GLOBALS['TL_LANG']['composer_client']['noInstallationCandidates'], $packageName));
$_SESSION['COMPOSER_OUTPUT'] .= $this->io->getOutput();
$this->redirect('contao/main.php?do=composer');
}
$template = new \BackendTemplate('be_composer_client_install');
$template->composer = $this->composer;
$template->packageName = $packageName;
$template->candidates = $installationCandidates;
return $template->parse();
}
示例7: handle
/**
* {@inheritdoc}
*/
public function handle(\Input $input)
{
$this->handleRunOnce();
// PATCH
if ($input->post('FORM_SUBMIT') == 'database-update') {
$count = 0;
$sql = deserialize($input->post('sql'));
if (is_array($sql)) {
foreach ($sql as $key) {
if (isset($_SESSION['sql_commands'][$key])) {
$this->Database->query(str_replace('DEFAULT CHARSET=utf8;', 'DEFAULT CHARSET=utf8 COLLATE ' . $GLOBALS['TL_CONFIG']['dbCollation'] . ';', $_SESSION['sql_commands'][$key]));
$count++;
}
}
}
$_SESSION['sql_commands'] = array();
Messages::addConfirmation(sprintf($GLOBALS['TL_LANG']['composer_client']['databaseUpdated'], $count));
$this->reload();
}
/** @var \Contao\Database\Installer $installer */
$installer = \System::importStatic('Database\\Installer');
$form = $installer->generateSqlForm();
if (empty($form)) {
Messages::addInfo($GLOBALS['TL_LANG']['composer_client']['databaseUptodate']);
$this->redirect('contao/main.php?do=composer');
}
$form = preg_replace('#(<label for="sql_\\d+")>(CREATE TABLE)#', '$1 class="create_table">$2', $form);
$form = preg_replace('#(<label for="sql_\\d+")>(ALTER TABLE `[^`]+` ADD)#', '$1 class="alter_add">$2', $form);
$form = preg_replace('#(<label for="sql_\\d+")>(ALTER TABLE `[^`]+` DROP)#', '$1 class="alter_drop">$2', $form);
$form = preg_replace('#(<label for="sql_\\d+")>(DROP TABLE)#', '$1 class="drop_table">$2', $form);
$template = new \BackendTemplate('be_composer_client_update');
$template->composer = $this->composer;
$template->form = $form;
return $template->parse();
}
示例8: testCanReplaceInputVlues
public function testCanReplaceInputVlues()
{
$newInputs = ["get" => ["foo" => "Hello"], "post" => ["bar" => "World"]];
$input = new Input();
$input->replace($newInputs);
$this->assertEquals($newInputs["get"]["foo"], $input->get("foo"));
$this->assertEquals($newInputs["post"]["bar"], $input->post("bar"));
}
示例9: testCanReplaceInputValues
public function testCanReplaceInputValues()
{
$newInputs = array('get' => array('foo' => 'hello'), 'post' => array('bar' => 'World'));
$input = new Input();
$input->replace($newInputs);
$this->assertEquals($newInputs['get']['foo'], $input->get('foo'));
$this->assertEquals($newInputs['post']['bar'], $input->post('bar'));
}
示例10: setFor
/**
* Define o alvo do label.
* @param Input $input
* @return Label Uma referência ao próprio component.
* @see Component::setAttribute()
*/
public function setFor(Input $input)
{
$id = $input->getId();
if ($id == null) {
$id = $input->generateId()->getId();
}
return $this->setAttribute('for', $id);
}
示例11: cuadroAsociado
function cuadroAsociado()
{
$cuadroTexto = new Input();
$this->atributos[self::TIPO] = self::HIDDEN;
$this->atributos["obligatorio"] = false;
$this->atributos[self::ETIQUETA] = "";
$this->atributos[self::VALOR] = "false";
return $cuadroTexto->cuadro_texto($this->atributos);
}
示例12: addTokenInput
/**
* @return $this
*/
protected function addTokenInput()
{
$input = new Input('token');
// Filter
$filterManager = $this->getFactory()->getDefaultFilterChain()->getPluginManager();
$input->getFilterChain()->attach($filterManager->get('stringtrim'));
$this->add($input);
return $this;
}
示例13: validate
public function validate()
{
$input = new Input();
$input->minMax($this->name, 1, 32, 'Company Name');
$input->minMax($this->address, 1, 64, 'Address');
$input->minMax($this->city, 1, 32, 'City');
$input->minMax($this->state, 1, 32, 'State');
$input->minMax($this->zip, 1, 14, 'Zip Code');
$input->phone($this->phone, 'Telephone Number');
$input->digits($this->zip, 'Zip Code');
$input->maximum($this->phone, 32, 'Telephone Number');
$input->maximum($this->logo, 128, 'Logo URL');
return true;
}
示例14: handle
/**
* {@inheritdoc}
*/
public function handle(\Input $input)
{
$configFile = new \File($this->configPathname);
if ($input->post('save')) {
$tempPathname = $this->configPathname . '~';
$tempFile = new \File($tempPathname);
$config = $input->postRaw('config');
$config = html_entity_decode($config, ENT_QUOTES, 'UTF-8');
$tempFile->write($config);
$tempFile->close();
$validator = new ConfigValidator($this->io);
list($errors, $publishErrors, $warnings) = $validator->validate(TL_ROOT . '/' . $tempPathname);
if (!$errors && !$publishErrors) {
$_SESSION['TL_CONFIRM'][] = $GLOBALS['TL_LANG']['composer_client']['configValid'];
$this->import('Files');
$this->Files->rename($tempPathname, $this->configPathname);
} else {
$tempFile->delete();
$_SESSION['COMPOSER_EDIT_CONFIG'] = $config;
if ($errors) {
foreach ($errors as $message) {
$_SESSION['TL_ERROR'][] = 'Error: ' . $message;
}
}
if ($publishErrors) {
foreach ($publishErrors as $message) {
$_SESSION['TL_ERROR'][] = 'Publish error: ' . $message;
}
}
}
if ($warnings) {
foreach ($warnings as $message) {
$_SESSION['TL_ERROR'][] = 'Warning: ' . $message;
}
}
$this->reload();
}
if (isset($_SESSION['COMPOSER_EDIT_CONFIG'])) {
$config = $_SESSION['COMPOSER_EDIT_CONFIG'];
unset($_SESSION['COMPOSER_EDIT_CONFIG']);
} else {
$config = $configFile->getContent();
}
$template = new \BackendTemplate('be_composer_client_editor');
$template->composer = $this->composer;
$template->config = $config;
return $template->parse();
}
示例15: __construct
/**
* Attempts to load a view and pre-load view data.
*
* @throws Kohana_Exception if the requested view cannot be found
* @param string $name view name
* @param string $page_type page type: album, photo, tags, etc
* @param string $theme_name view name
* @return void
*/
public function __construct($name, $page_type)
{
$theme_name = module::get_var("gallery", "active_site_theme");
if (!file_exists("themes/{$theme_name}")) {
module::set_var("gallery", "active_site_theme", "default");
theme::load_themes();
Kohana::log("error", "Unable to locate theme '{$theme_name}', switching to default theme.");
}
parent::__construct($name);
$this->theme_name = module::get_var("gallery", "active_site_theme");
if (user::active()->admin) {
$this->theme_name = Input::instance()->get("theme", $this->theme_name);
}
$this->item = null;
$this->tag = null;
$this->set_global("theme", $this);
$this->set_global("user", user::active());
$this->set_global("page_type", $page_type);
$this->set_global("page_title", null);
if ($page_type == "album") {
$this->set_global("thumb_proportion", $this->thumb_proportion());
}
$maintenance_mode = Kohana::config("core.maintenance_mode", false, false);
if ($maintenance_mode) {
message::warning(t("This site is currently in maintenance mode"));
}
}