Fixes caps lock accidentally turned on.
@return string
349244
private static function removeCapsLock($password)
    {
        return $password === Strings::upper($password) ? Strings::lower($password) : $password;
    }
1255921
public function toUpperCase() {
    $token = $this->getConstantName()->lastToken();
    $token->setText(strtoupper($token->getText()));
    return $this;
  }
827623
public function index()
    {
        if (!userHasPermission('admin:captcha:settings:*')) {
            unauthorised();
        }

        $oDb                   = Factory::service('Database');
        $oInput                = Factory::service('Input');
        $oCaptchaDriverService = Factory::service('CaptchaDriver', 'nails/module-captcha');

        if ($oInput->post()) {

            //  Settings keys
            $sKeyCaptchaDriver = $oCaptchaDriverService->getSettingKey();

            //  Validation
            $oFormValidation = Factory::service('FormValidation');

            $oFormValidation->set_rules($sKeyCaptchaDriver, '', 'required');

            if ($oFormValidation->run()) {

                try {

                    $oDb->trans_begin();

                    //  Drivers
                    $oCaptchaDriverService->saveEnabled($oInput->post($sKeyCaptchaDriver));

                    $oDb->trans_commit();
                    $this->data['success'] = 'Captcha settings were saved.';

                } catch (\Exception $e) {
                    $oDb->trans_rollback();
                    $this->data['error'] = 'There was a problem saving settings. ' . $e->getMessage();
                }

            } else {

                $this->data['error'] = lang('fv_there_were_errors');
            }
        }

        // --------------------------------------------------------------------------

        //  Get data
        $this->data['settings']                = appSetting(null, 'nails/module-captcha', true);
        $this->data['captcha_drivers']         = $oCaptchaDriverService->getAll();
        $this->data['captcha_drivers_enabled'] = $oCaptchaDriverService->getEnabledSlug();

        Helper::loadView('index');
    }
780099
protected function getInput()
	{
		// Initialize some field attributes.
		$class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
		$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
		$columns = $this->element['cols'] ? ' cols="' . (int) $this->element['cols'] . '"' : '';
		$rows = $this->element['rows'] ? ' rows="' . (int) $this->element['rows'] . '"' : '';

		// Initialize JavaScript field attributes.
		$onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';

		return '<textarea name="' . $this->name . '" id="' . $this->id . '"' . $columns . $rows . $class . $disabled . $onchange . '>'
			. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '</textarea>';
	}
1202695
public function format()
    {
        $this->allowTemplateCode();
        $str = (string) $this->getRequiredParameter('value');

        // InputClean might be all you need but
        // if not, do more stuff after
        $str = $this->InputClean->clean($str, 'p,br');
        $str = $this->InputClean->unAutoParagraph($str);

        // mutant characters inserted by the wysiwyg.
        // a combo capital A, circumflex and non-breaking space
        $tincyMCEHack = chr(194) . chr(160);
        $str = str_replace($tincyMCEHack, '', $str);

        $str = preg_replace("/(\r\n){3,}|(\n|\r){3,}/", "\n\n", $str);
        return trim($str);
    }
30386
public function getHelp()
	{
		$help='Usage: '.$this->getCommandRunner()->getScriptName().' '.$this->getName();
		$options=$this->getOptionHelp();
		if(empty($options))
			return $help."\n";
		if(count($options)===1)
			return $help.' '.$options[0]."\n";
		$help.=" <action>\nActions:\n";
		foreach($options as $option)
			$help.='    '.$option."\n";
		return $help;
	}
458397
public function getEscape()
    {
        if (null === $this->_escape) {
            if (null !== ($escape = $this->getOption('escape'))) {
                $this->setEscape($escape);
                $this->removeOption('escape');
            } else {
                $this->setEscape(true);
            }
        }

        return $this->_escape;
    }
654212
public function GetActiveSettingAsHiddenInputField()
    {
        $sHTML = '';
        if (is_array($this->aActiveFilterData)) {
            reset($this->aActiveFilterData);
            foreach ($this->aActiveFilterData as $sItemName) {
                $sHTML .= '<input type="hidden" name="'.TGlobal::OutHTML($this->GetURLInputName()).'[]" value="'.TGlobal::OutHTML($sItemName).'" />';
            }
            reset($this->aActiveFilterData);
        }

        return $sHTML;
    }
255415
public function addClose()
    {
        if ($this->recall('closed', false)) {
            $this->destroy();
        }

        $self = $this;
        /** @type Icon $icon */
        $icon = $this->add('Icon', null, 'Button');
        $icon
            ->addComponents(array('size' => 'mega'))
            ->set('cancel-1')
            ->addStyle(array('cursor' => 'pointer'))
            ->on('click', function ($js) use ($self) {
                $self->memorize('closed', true);

                return $self->js()->hide()->execute();
            });

        return $this;
    }
506575
public function lineBreak()
    {
        return $this->style(str_repeat('─', $this->terminal->getWidth()), 'yellow');
    }
127410
public function getTextOutput()
    {
        $patchLevel = $this->getPatchLevel();

        $commands     = array(sprintf('-- Patch level %d structural changes', $patchLevel));
        $lastLocation = '';
        $lastName     = '';
        $noOutput     = true;
        foreach ($this->getStructuralPatches($patchLevel) as $patch) {
            if ($patch['gpa_location'] != $lastLocation) {
                $commands[] = sprintf("\n-- DATABASE LOCATION: %s", $patch['gpa_location']);
                $lastLocation = $patch['gpa_location'];
            }
            if ($patch['gpa_name'] != $lastName) {
                $commands[] = sprintf("\n-- PATCH: %s", $patch['gpa_name']);
                $lastName = $patch['gpa_name'];
            }
            $commands[] = $patch['gpa_sql'] . ';';
            $noOutput = false;
        }

        if ($noOutput) {
            $commands[] = sprintf("\n-- No structural changes in patchlevel %d", $patchLevel);
        }
        $commands[] = '';

        return implode("\n", $commands);
    }
806892
protected function getTokenInstance()
    {
        if (!$this->tokenInstance) {
            $this->tokenInstance = Token::instance('captcha')->setOptions(['title' => '图形码']);
        }
        
        return $this->tokenInstance;
    }
588428
protected function getKeyForSaveQuery()
    {
        if (isset($this->original[$this->getKeyName()])) {
            return $this->original[$this->getKeyName()];
        }

        return $this->getAttribute($this->getKeyName());
    }
27656
public function getAnonymizeed()
	{
		$userinfo = $this->toObject();
		$userinfo->password_clear = '******';
		if (isset($userinfo->password)) {
			$userinfo->password = substr($userinfo->password, 0, 6) . '********';
		}
		if (isset($userinfo->password_salt)) {
			$userinfo->password_salt = substr($userinfo->password_salt, 0, 4) . '*****';
		}
		return $userinfo;
	}
1098035
protected function resetInput()
    {
        if ($this->minInput === 0) {
            $this->state = self::STATE_COMPLETE;
        } else {
            $this->state = self::STATE_TIMEOUT;
        }
        $this->input = self::DTMF_NONE;
        return $this;
    }
767413
protected function getUnsettedKeys()
    {
        $unsettedKeys = [];

        foreach ($this->_originalAttributes as $key=>$value) {

            if (!array_key_exists($key, $this->_attributes)) {
                $unsettedKeys[] = $key;
                continue;
            }
        }

        return $unsettedKeys;
    }
1012250
public function toUpperCase() {
        $str = mb_strtoupper($this->str, $this->encoding);

        return self::create($str, $this->encoding);
    }