/** * Create a text field with Autocomplete. * * Creates an autocomplete field with the given ID and options. * * options['with'] defaults to "Form.Element.serialize('$field')", * but can be any valid javascript expression defining the additional fields. * * @param string $field DOM ID of field to observe * @param string $url URL for the autocomplete action * @param array $options Ajax options * @return string Ajax script */ function autoComplete($field, $url = "", $options = array()) { $var = ''; if (isset($options['var'])) { $var = 'var ' . $options['var'] . ' = '; unset($options['var']); } if (!isset($options['id'])) { $options['id'] = Inflector::camelize(str_replace(".", "_", $field)); } $divOptions = array('id' => $options['id'] . "_autoComplete", 'class' => isset($options['class']) ? $options['class'] : 'auto_complete'); if (isset($options['div_id'])) { $divOptions['id'] = $options['div_id']; unset($options['div_id']); } $htmlOptions = $this->__getHtmlOptions($options); $htmlOptions['autocomplete'] = "off"; foreach ($this->autoCompleteOptions as $opt) { unset($htmlOptions[$opt]); } if (isset($options['tokens'])) { if (is_array($options['tokens'])) { $options['tokens'] = $this->Javascript->object($options['tokens']); } else { $options['tokens'] = '"' . $options['tokens'] . '"'; } } $options = $this->_optionsToString($options, array('paramName', 'indicator')); $options = $this->_buildOptions($options, $this->autoCompleteOptions); return $this->Form->text($field, $htmlOptions) . "\n" . $this->Html->div(null, '', $divOptions) . "\n" . $this->Javascript->codeBlock("{$var}new Ajax.Autocompleter('" . $htmlOptions['id'] . "', '" . $divOptions['id'] . "', '" . $this->Html->url($url) . "', " . $options . ");"); }
/** * testDiv method * * @access public * @return void */ function testDiv() { $result = $this->Html->div('class-name'); $this->assertTags($result, array('div' => array('class' => 'class-name'))); $result = $this->Html->div('class-name', 'text'); $this->assertTags($result, array('div' => array('class' => 'class-name'), 'text', '/div')); $result = $this->Html->div('class-name', '<text>', array('escape' => true)); $this->assertTags($result, array('div' => array('class' => 'class-name'), '<text>', '/div')); }
/** * testDiv method * * @return void */ public function testDiv() { $result = $this->Html->div('class-name'); $expected = ['div' => ['class' => 'class-name']]; $this->assertHtml($expected, $result); $result = $this->Html->div('class-name', 'text'); $expected = ['div' => ['class' => 'class-name'], 'text', '/div']; $this->assertHtml($expected, $result); $result = $this->Html->div('class-name', '<text>', ['escape' => true]); $expected = ['div' => ['class' => 'class-name'], '<text>', '/div']; $this->assertHtml($expected, $result); }
/** * testDiv method * * @return void */ public function testDiv() { $result = $this->Html->div('class-name'); $expected = array('div' => array('class' => 'class-name')); $this->assertHtml($expected, $result); $result = $this->Html->div('class-name', 'text'); $expected = array('div' => array('class' => 'class-name'), 'text', '/div'); $this->assertHtml($expected, $result); $result = $this->Html->div('class-name', '<text>', array('escape' => true)); $expected = array('div' => array('class' => 'class-name'), '<text>', '/div'); $this->assertHtml($expected, $result); }
/** * Decryption * * @param string $c * @access public * @return string */ public function decrypt($c) { $coded = explode(' ', $c); $message = ''; $max = count($coded); for ($i = 0; $i < $max; $i++) { $code = $this->math->mod($this->math->pow($coded[$i], $this->d), $this->n); while ($this->math->cmp($code, '0') != 0) { $ascii = $this->math->mod($code, '256'); $code = $this->math->div($code, '256', 0); $message .= chr($ascii); } } return $message; }
/** * The generic value encoding method. * * @param string $val A number to convert. * @param string $base The base to convert it into. * @return string The same number but in a different base. * @throws \Exception */ private function encodeValue($val, $base) { $this->preOpMethodParamsCheck(array($val, $base)); $digits = $this->baseCheck($base); try { $new = ''; while ($this->math->comp($val, '0') > 0) { $qq = $this->math->div($val, $base); $rem = $this->math->mod($val, $base); $val = $qq; $new = $new . $digits[$rem]; } return $new; } catch (\Exception $e) { throw $e; } }