本文整理汇总了PHP中tools::sanitizeString方法的典型用法代码示例。如果您正苦于以下问题:PHP tools::sanitizeString方法的具体用法?PHP tools::sanitizeString怎么用?PHP tools::sanitizeString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tools
的用法示例。
在下文中一共展示了tools::sanitizeString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
public function validate($value)
{
$length = strlen($value);
if ($length >= $this->characters_min && $length <= $this->characters_max) {
if (empty($value)) {
$title = $this->entity->getField($this->entity->getBehaviorTitle());
if (!$this->required) {
return '';
} elseif (!empty($title->value)) {
return \tools::sanitizeString($title->value);
} else {
return FALSE;
}
} else {
$args = func_get_args();
if ($this->unique && isset($args[1])) {
if ($args[1] === 'insert') {
$args[1] = FALSE;
}
if ($this->checkUniqueAction($value, $args[1]) === FALSE) {
return FALSE;
}
}
return filter_var($value, FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '#' . $this->regex . '#')));
}
}
return FALSE;
}
示例2: titleToUrlAction
/**
* Sanitize url
* @param string $url
* @return string
*/
protected function titleToUrlAction($url)
{
$url = \tools::sanitizeString($url);
return $url;
}
示例3: build
/**
* Generates the code to build a block
* @static
* @param string $moduleName Module name where the block is created
* @param string $blockName Block name to create
* @param string $extends
* @param string $configs
*/
public static function build($moduleName, $blockName, $extends, $configs, $viewPath)
{
$moduleName = tools::sanitizeString($moduleName);
$blockName = tools::sanitizeString($blockName);
$licence = str_replace('{{module}}', $blockName, file_get_contents("modules/admin/licence.txt"));
$dir = 'modules/' . $moduleName . '/blocks/' . $blockName;
tools::createDirectory('modules/' . $moduleName . '/blocks/' . $blockName);
list($moduleFrom, $b, $nameFrom) = explode('\\', $extends);
$template = '<?php
' . $licence . '
namespace ' . $moduleName . '\\blocks;
/**
* @title ' . $blockName . '
* @description ' . $blockName . '
* @copyright 1
* @browsers all
* @php_version_min 5.3
* @block_category ' . $moduleName . '
* @modules_dependencies ' . $moduleFrom . ':1
*/
class ' . $blockName . ' extends \\' . $extends . ' {
public function __construct($id) {
parent::__construct($id);
$configs = \'' . $configs . '\';
$this->configs = unserialize(base64_decode($configs));
}
public function getAdminView() {
ob_start();
include(\'modules/' . $moduleFrom . '/blocks/' . $nameFrom . '/adminView.php\');
return ob_get_clean();
}
}
?>';
if (is_dir($dir)) {
file_put_contents('modules/' . $moduleName . '/blocks/' . $blockName . '/block.php', $template);
file_put_contents('modules/' . $moduleName . '/blocks/' . $blockName . '/icon.png', file_get_contents('modules/' . $moduleFrom . '/blocks/' . $nameFrom . '/icon.png'));
file_put_contents('modules/' . $moduleName . '/blocks/' . $blockName . '/view.php', file_get_contents($viewPath, FILE_USE_INCLUDE_PATH));
$return = array('eval' => '', 'notification' => t('Block has been created'), 'notificationType' => 'positive');
} else {
$return = array('eval' => '', 'notification' => t('Block has\'nt been created', FALSE), 'notificationType' => 'negative');
}
\app::$response->setHeader('X-XSS-Protection', '0');
\app::$response->setHeader('Content-type', 'application/json');
return json_encode($return);
}