public function declareParameters() { $track = new String('track'); $track->setValidateType('int'); $album = new String('album'); $album->setValidateType('int'); $this->source = new XorParameter('source'); $this->source->addParameter($track); $this->source->addParameter($album); $this->source->setRequired(); $this->source->setDefaultParameter($track); $this->addParameter($this->source); $this->autoplay = new Boolean('autoplay'); $this->addParameter($this->autoplay); $this->lang = new XorParameter('lang'); $this->lang->addParameter(new Option('en')); $this->lang->addParameter(new Option('fr')); $this->lang->setDefaultValue('en'); $this->addParameter($this->lang); $float = new XorParameter('float'); $this->right = new Option('right'); $float->addParameter($this->right); $this->left = new Option('left'); $float->addParameter($this->left); $this->addParameter($float); }
function ShowProduct($id_product) { $objResponse = new xajaxResponse(); $bError = false; $stringutil = new String(""); $tempname = "en_title"; $tempdescription = "en_detaileddescription"; $SQL = "SELECT {$tempname},{$tempdescription} FROM " . DB_PREFIX . "product WHERE id_product='" . $id_product . "'"; //$objResponse->addAlert($SQL); $retid = mysql_query($SQL); if (!$retid) { echo mysql_error(); } if ($row = mysql_fetch_array($retid)) { $name = $row[$tempname]; $description = $stringutil->cleanDescription2($row[$tempdescription]); } $ft = new FastTemplate(TEMPLATE_PATH); $ft->define(array("main" => "product_rightmenu.html")); $ft->assign("NAME", $name); //if (NONSEO==1) $ft->assign("URL_TYPE", "product.php?name=".$stringutil->CleanLink($name)."&id=".$id_product.""); //else $ft->assign("URL_TYPE", "product.php/".$stringutil->CleanLink($name)."/".$id_product."/"); $ft->assign("DESCRIPTION", $description); $ft->multiple_assign_define("LANG_"); $ft->parse("mainContent", "main"); $ft->showDebugInfo(ERROR_DEBUG); $c = $ft->fetch("mainContent"); //$objResponse->addAlert($c); $objResponse->addAssign("body_firstpage_background_right", "innerHTML", $c); return $objResponse; }
function testNoMatch() { $input = new String("blaat"); $pattern = "|<[^>]+>(.*)</[^>]+>|U"; $matches = $input->getMatches($pattern); $this->assertEqual(0, $matches->size()); }
/** * Inject HTML in the navigation element * * @param string $html The HTML string * @return \ValidFormBuilder\String */ public function addHtml($html) { $objString = new String($html); $objString->setMeta("parent", $this, true); $this->__fields->addObject($objString); return $objString; }
protected function declareParameters() { $this->source = new XorParameter('source'); $email = new String('email'); $email->setValidateType('email'); $this->source->addParameter($email); $user = new User('user'); $this->source->addParameter($user); $this->source->setDefaultParameter($user); global $wgUser; $this->source->setDefaultValue($wgUser, false); $this->addParameter($this->source); $this->size = new IntegerInPixel('size'); global $wgWFMKMaxWidth; $this->size->setMax(min(array($wgWFMKMaxWidth, 2048))); $this->size->setDefaultValue(80); $this->addParameter($this->size); /* * Currently, rating is forced to G: "suitable for display on all websites with any audience type" $this->rating = new XorParameter('rating'); $this->rating->addParameter(new Option('g')); // +++ all websites with any audience type $this->rating->addParameter(new Option('pg')); // ++ $this->rating->addParameter(new Option('r')); // + $this->rating->addParameter(new Option('x')); // ! hardcore $this->addParameter($this->rating); */ $float = new XorParameter('float'); $this->right = new Option('right'); $float->addParameter($this->right); $this->left = new Option('left'); $float->addParameter($this->left); $this->addParameter($float); }
/** * Declares the widget's parameters: * <ul> * <li>instanciates Parameter objects,</li> * <li>configures them and</li> * <li>calls addParameter() for each of them.</li> * </ul> * * @return void */ protected function declareParameters() { global $wgWFMKMaxWidth; $user = new String('user'); $user->setEscapeMode('quotes'); $search = new String('search'); $search->setEscapeMode('quotes'); $this->source = new XorParameter('source'); $this->source->addParameter($user); $this->source->addParameter($search); $this->source->setRequired(); // one of theses parameters has to be set $this->source->setDefaultParameter($user); // user don't need to type "user=xxx", just "xxx" at right position $this->addParameter($this->source); $this->faves = new Option('faves'); $this->list = new String('list'); $this->list->setEscapeMode('quotes'); $this->follow = new Option('follow'); $mode = new XorParameter('mode'); $mode->addParameter($this->faves); $mode->addParameter($this->list); $mode->addParameter($this->follow); $this->addParameter($mode); $this->title = new String('title'); $this->title->setEscapeMode('quotes'); $this->addParameter($this->title); $this->subject = new String('subject'); $this->subject->setEscapeMode('quotes'); $this->addParameter($this->subject); $this->width = new IntegerInPixel('width'); $this->width->setDefaultValue($wgWFMKMaxWidth); $this->width->setMin(0); $this->width->setMax($wgWFMKMaxWidth); $this->addParameter($this->width); $this->height = new IntegerInPixel('height'); $this->height->setDefaultValue(441); $this->height->setMin(0); $this->addParameter($this->height); $this->count = new Integer('count'); $this->count->setDefaultValue(5); $this->count->setMin(0); $this->count->setMax(30); $this->addParameter($this->count); $this->scrollbar = new Boolean('scrollbar'); $this->addParameter($this->scrollbar); $this->live = new Boolean('live'); $this->addParameter($this->live); $this->loop = new Boolean('loop'); $this->addParameter($this->loop); $this->all = new Boolean('all'); $this->addParameter($this->all); $float = new XorParameter('float'); $this->right = new Option('right'); $float->addParameter($this->right); $this->left = new Option('left'); $float->addParameter($this->left); $this->addParameter($float); }
public function setParam($nm, $val) { assert(isset($this->sth)); //no use to set param before calling prepare $snm = new String($nm); $this->params[$snm->prepend(':')] = $val; return $this; }
public function getParent() { $result = new String($this->m_sFilename); if ($result->lastIndexOf(new java_lang_String("/")) > -1) { return $result->substring(0, $result->lastIndexOf(new String("/"))); } else { return Translator_JavaBase::$null; } }
/** * @param string|int $string */ public function __construct($string = null) { if (is_int($string)) { parent::__construct($string); return; } $string = new String($string); parent::__construct($string->length() + 16); $this->append($string); }
public function testStringProperty() { $validString = 'ABCDEFGHIJKLMNOP'; $invalidString = 'ABCDEFGHIJKLMNOPQR'; $property = new String('Name', null, 16); $property->setValue($validString); $this->assertEquals($validString, $property->getValue()); $property->setValue($invalidString); $this->assertEquals(16, strlen($property->getValue())); }
/** * @test * Enter description here... * @return unknown_type */ public function itShouldConcatinateStrings() { $array = array("I have", " a enumerable object ", "of strings"); $start = new String("notice:"); $container = $start->concat(" this is a test. "); foreach ($array as $value) { $container = $container->concat($value); } $this->expectsThat($start)->equals("notice:"); $this->expectsThat($container)->equals("notice: this is a test. I have a enumerable object of strings"); }
public function funname() { import('@.ORG.String'); /** * 生成随机名称 */ $str = new String(); $name = $str->uuid(); $name = str_replace("}", "", $name); $name = str_replace("{", "", $name); return $name; }
protected static function quoteInto($sql) { if (func_num_args() == 1) { return $sql; } $sql = new String($sql); $args = func_get_args(); $args = array_slice($args, 1); foreach ($args as $i => $arg) { $sql->{$i} = $arg; } return $sql->__toString(); }
/** * particularidade() Faz em tempo de execução mudanças que sejam imprescindíveis * para a geração correta do código de barras * Particularmente para o Banrisul, ele acrescenta ao array OB::$Data, que * guarda as variáveis que geram o código de barras, uma nova variável * $DuploDigito, específica desse banco * * @version 0.1 28/05/2011 Initial */ public function particularidade($object) { $codigo = String::insert('21:Agencia:CodigoCedente:NossoNumero041', $object->Data); $dv1 = Math::Mod10($codigo); $dv2 = Math::Mod11($codigo . $dv1); return $object->Data['DuploDigito'] = self::DuploDigito($codigo); }
/** * @see TypeDescription::parseTypeName() */ function parseTypeName($typeName) { // Standard validators are based on string input. parent::parseTypeName('string'); // Split the type name into validator name and arguments. $typeNameParts = explode('(', $typeName, 2); switch (count($typeNameParts)) { case 1: // no argument $this->_validatorArgs = ''; break; case 2: // parse arguments (no UTF8-treatment necessary) if (substr($typeNameParts[1], -1) != ')') { return false; } // FIXME: Escape for PHP code inclusion? $this->_validatorArgs = substr($typeNameParts[1], 0, -1); break; } // Validator name must start with a lower case letter // and may contain only alphanumeric letters. if (!String::regexp_match('/^[a-z][a-zA-Z0-9]+$/', $typeNameParts[0])) { return false; } // Translate the validator name into a validator class name. $this->_validatorClassName = 'Validator' . String::ucfirst($typeNameParts[0]); return true; }
/** * Returns a string with all spaces converted to $replacement and non word characters removed. * * @param string $string * @param string $replacement * @return string * @static */ static function slug($string, $replacement = '-') { $string = trim($string); $map = array('/à|á|å|â|ä/' => 'a', '/è|é|ê|ẽ|ë/' => 'e', '/ì|í|î/' => 'i', '/ò|ó|ô|ø/' => 'o', '/ù|ú|ů|û/' => 'u', '/ç|č/' => 'c', '/ñ|ň/' => 'n', '/ľ/' => 'l', '/ý/' => 'y', '/ť/' => 't', '/ž/' => 'z', '/š/' => 's', '/æ/' => 'ae', '/ö/' => 'oe', '/ü/' => 'ue', '/Ä/' => 'Ae', '/Ü/' => 'Ue', '/Ö/' => 'Oe', '/ß/' => 'ss', '/[^\\w\\s]/' => ' ', '/\\s+/' => $replacement, String::insert('/^[:replacement]+|[:replacement]+$/', array('replacement' => preg_quote($replacement, '/'))) => ''); $string = preg_replace(array_keys($map), array_values($map), $string); return low($string); }
/** * Generate the content element */ protected function compile() { global $objPage; // Clean the RTE output if ($objPage->outputFormat == 'xhtml') { $this->text = \String::toXhtml($this->text); } else { $this->text = \String::toHtml5($this->text); } // Add the static files URL to images if (TL_FILES_URL != '') { $path = $GLOBALS['TL_CONFIG']['uploadPath'] . '/'; $this->text = str_replace(' src="' . $path, ' src="' . TL_FILES_URL . $path, $this->text); } $this->Template->text = \String::encodeEmail($this->text); $this->Template->addImage = false; // Add an image if ($this->addImage && $this->singleSRC != '') { if (!is_numeric($this->singleSRC)) { $this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>'; } else { $objModel = \FilesModel::findByPk($this->singleSRC); if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) { $this->singleSRC = $objModel->path; $this->addImageToTemplate($this->Template, $this->arrData); } } } }
function main() { if (empty($this->args)) { return $this->err('Usage: ./cake uuidize <table>'); } if ($this->args[0] == '?') { return $this->out('Usage: ./cake uuidize <table> [-force] [-reindex]'); } $options = array('force' => false, 'reindex' => false); foreach ($this->params as $key => $val) { foreach ($options as $name => $option) { if (isset($this->params[$name]) || isset($this->params['-' . $name]) || isset($this->params[$name[0]])) { $options[$name] = true; } } } foreach ($this->args as $table) { $name = Inflector::classify($table); $Model = new AppModel(array('name' => $name, 'table' => $table)); $records = $Model->find('all'); foreach ($records as $record) { $Model->updateAll(array('id' => '"' . String::uuid() . '"'), array('id' => $record[$name]['id'])); } } }
/** * undocumented function * * @return void * @access public */ function testGiftsAddRedirectsIfNoValidAppealGiven() { $this->fakeRequest('get'); $this->Sut->params['named']['appeal_id'] = ''; $this->Sut->add(); $this->is($this->Sut->redirectUrl, '/'); // any non existant appeal id $this->Sut->redirectUrl = ''; $this->Sut->params['named']['appeal_id'] = String::uuid(); $this->Sut->add(); $this->is($this->Sut->redirectUrl, '/'); // valid appeal id $this->Sut->redirectUrl = false; $this->Sut->params['named']['appeal_id'] = $this->gpiAppealId; $this->Sut->add(); $this->false($this->Sut->redirectUrl); // setting appeal id allowed only at step 1 if different from session office id $this->Sut->redirectUrl = false; $this->Sut->params['named']['appeal_id'] = $this->gpiAppealId; $this->Sut->add(); $this->false($this->Sut->redirectUrl); $this->Sut->params['named']['appeal_id'] = $this->exampleAppealId; $this->Sut->add(2); $this->is($this->Sut->redirectUrl, '/'); $this->Sut->redirectUrl = false; $this->Sut->params['named']['appeal_id'] = $this->gpiAppealId; $this->Sut->add(); $this->false($this->Sut->redirectUrl); $this->Sut->params['named']['appeal_id'] = $this->gpiAppealId; $this->Sut->add(2); $this->false($this->Sut->redirectUrl); }
/** * Format XML for single DC element. * @param $propertyName string * @param $value array * @param $multilingual boolean optional */ function formatElement($propertyName, $values, $multilingual = false) { if (!is_array($values)) { $values = array($values); } // Translate the property name to XML syntax. $openingElement = str_replace(array('[@', ']'), array(' ', ''), $propertyName); $closingElement = String::regexp_replace('/\\[@.*/', '', $propertyName); // Create the actual XML entry. $response = ''; foreach ($values as $key => $value) { if ($multilingual) { $key = str_replace('_', '-', $key); assert(is_array($value)); foreach ($value as $subValue) { if ($key == METADATA_DESCRIPTION_UNKNOWN_LOCALE) { $response .= "\t<{$openingElement}>" . OAIUtils::prepOutput($subValue) . "</{$closingElement}>\n"; } else { $response .= "\t<{$openingElement} xml:lang=\"{$key}\">" . OAIUtils::prepOutput($subValue) . "</{$closingElement}>\n"; } } } else { assert(is_scalar($value)); $response .= "\t<{$openingElement}>" . OAIUtils::prepOutput($value) . "</{$closingElement}>\n"; } } return $response; }
public function __construct($value) { parent::__construct(strtoupper($value), 1); if (!preg_match('/^[A-Z0-9]$/', (string) $value)) { throw new InvalidFieldException('File Id Modifier "' . $value . '" must be A-Z 0-9.'); } }
/** * read * * Bespoke read method to read the api of an external translations api * * @param Model $model * @param array $queryData * @param mixed $recursive * @return void */ public function read(Model $model, $queryData = array(), $recursive = null) { $class = get_class($model); $config = $class::config(); $url = String::insert($this->config['host'], $queryData['conditions'] + $config); $result = $this->execute($url); if (!$result) { return $result; } if ($queryData['fields'] === 'COUNT(*) AS count') { return count(current($result)); } $defaults = array_intersect_key($queryData['conditions'] + $config, array_flip(array('domain', 'category', 'locale'))); $return = array(); foreach (current($result) as $key => $value) { if (is_array($value)) { foreach ($value as $case => $val) { $return[] = array($model->alias => array('key' => $key, 'value' => $val, 'plural_case' => $case) + $defaults); } } else { $return[] = array($model->alias => array('key' => $key, 'value' => $value, 'plural_case' => null) + $defaults); } } return $return; }
/** * Generate a filename for a library file. * @param $type int LIBRARY_FILE_TYPE_... * @param $originalFileName string * @return string */ function generateFileName($type, $originalFileName) { $libraryFileDao =& DAORegistry::getDAO('LibraryFileDAO'); $suffix = $this->getFileSuffixFromType($type); $ext = $this->getExtension($originalFileName); $truncated = $this->truncateFileName($originalFileName, 127 - String::strlen($suffix) - 1); $baseName = String::substr($truncated, 0, String::strpos($originalFileName, $ext) - 1); // Try a simple syntax first $fileName = $baseName . '-' . $suffix . '.' . $ext; if (!$libraryFileDao->filenameExists($this->pressId, $fileName)) { return $fileName; } for ($i = 1;; $i++) { $fullSuffix = $suffix . '-' . $i; //truncate more if necessary $truncated = $this->truncateFileName($originalFileName, 127 - String::strlen($fullSuffix) - 1); // get the base name and append the suffix $baseName = String::substr($truncated, 0, String::strpos($originalFileName, $ext) - 1); //try the following $fileName = $baseName . '-' . $fullSuffix . '.' . $ext; if (!$libraryFileDao->filenameExists($this->pressId, $fileName)) { return $fileName; } } }
/** * Instância singleton * * @version * 0.1 18/05/2011 Initial * * @param string $text Texto a ser verificado * @param int $length Tamanho máximo */ public static function instance() { if (empty(self::$self)) { self::$self = new String(); } return self::$self; }
/** * Get the date the post was created. * * @param \Carbon|null $date * @return string */ public function date($date = null) { if (is_null($date)) { $date = $this->created_at; } return String::date($date); }
public function decode($text, $textType = "") { if (is_object($text)) { return $text; } return String::htmlDecode($text); }
public function translate($message, $count = NULL) { $case = $this->detectCase($message); $args = func_get_args(); if (is_string($count)) { if (isset($args[2]) && is_numeric($args[2])) { $count = $args[2]; } } $counter = $count; if (is_numeric($count)) { $counter = $this->inflexion($count); } $node = String::lower($message . $counter); if (isset($this->dict[$node])) { $message = $this->dict[$node]; } else { $message = implode(' ', explode('_', $message)); } if (count($args) > 1) { array_shift($args); $message = vsprintf($message, $args); } if ($case == 'default') { return $message; } elseif ($case == 'firstUpper') { return ucfirst($message); } else { return call_user_func(array('String', $case), $message); } }
/** * Save uploaded file * * @param array $data data as POSTed from form * @return array|boolean false for errors or array containing fields to save */ protected function _saveUploadedFile($data) { $file = $data[$this->alias]['file']; unset($data[$this->alias]['file']); // check if file with same path exists $destination = WWW_ROOT . $this->uploadsDir . DS . $file['name']; if (file_exists($destination)) { $newFileName = String::uuid() . '-' . $file['name']; $destination = WWW_ROOT . $this->uploadsDir . DS . $newFileName; } else { $newFileName = $file['name']; } // remove the extension for title if (explode('.', $file['name']) > 0) { $fileTitleE = explode('.', $file['name']); array_pop($fileTitleE); $fileTitle = implode('.', $fileTitleE); } else { $fileTitle = $file['name']; } $data[$this->alias]['title'] = $fileTitle; $data[$this->alias]['slug'] = $newFileName; $data[$this->alias]['body'] = ''; $data[$this->alias]['mime_type'] = $file['type']; $data[$this->alias]['type'] = $this->type; $data[$this->alias]['path'] = '/' . $this->uploadsDir . '/' . $newFileName; // move the file $moved = move_uploaded_file($file['tmp_name'], $destination); if ($moved) { return $data; } return false; }
/** * Generate authorization hash. * * @return string Hash * @access public * @static */ function generateAuthKey() { if (!class_exists('String')) { App::import('Core', 'String'); } return Security::hash(String::uuid()); }
/** * Meta field: with key/value fields * * @param string $key (optional) key * @param string $value (optional) value * @param integer $id (optional) ID of Meta * @param array $options (optional) options * @return string */ public function field($key = '', $value = null, $id = null, $options = array()) { $_options = array('key' => array('label' => __d('croogo', 'Key'), 'value' => $key, 'class' => 'span12'), 'value' => array('label' => __d('croogo', 'Value'), 'value' => $value, 'class' => 'span12', 'type' => 'textarea', 'rows' => 2)); $options = Hash::merge($_options, $options); $uuid = String::uuid(); $fields = ''; if ($id != null) { $fields .= $this->Form->input('Meta.' . $uuid . '.id', array('type' => 'hidden', 'value' => $id)); $this->Form->unlockField('Meta.' . $uuid . '.id'); } $fields .= $this->Form->input('Meta.' . $uuid . '.key', $options['key']); $fields .= $this->Form->input('Meta.' . $uuid . '.value', $options['value']); $this->Form->unlockField('Meta.' . $uuid . '.key'); $this->Form->unlockField('Meta.' . $uuid . '.value'); $fields = $this->Html->tag('div', $fields, array('class' => 'fields')); $id = is_null($id) ? $uuid : $id; $deleteUrl = array_intersect_key($this->request->params, array('admin' => null, 'plugin' => null, 'controller' => null, 'named' => null)); $deleteUrl['action'] = 'delete_meta'; $deleteUrl[] = $id; $deleteUrl = $this->url($deleteUrl); $actions = $this->Html->link(__d('croogo', 'Remove'), $deleteUrl, array('class' => 'remove-meta', 'rel' => $id)); $actions = $this->Html->tag('div', $actions, array('class' => 'actions')); $output = $this->Html->tag('div', $actions . $fields, array('class' => 'meta')); return $output; }