当前位置: 首页>>代码示例>>PHP>>正文


PHP tools::sanitizeString方法代码示例

本文整理汇总了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;
 }
开发者ID:saitinet,项目名称:parsimony,代码行数:28,代码来源:url_rewriting.php

示例2: titleToUrlAction

 /**
  * Sanitize url
  * @param string $url
  * @return string 
  */
 protected function titleToUrlAction($url)
 {
     $url = \tools::sanitizeString($url);
     return $url;
 }
开发者ID:saitinet,项目名称:parsimony,代码行数:10,代码来源:module.php

示例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);
    }
开发者ID:saitinet,项目名称:parsimony,代码行数:59,代码来源:block.php


注:本文中的tools::sanitizeString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。