本文整理汇总了PHP中SpoonFilter::isFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP SpoonFilter::isFilename方法的具体用法?PHP SpoonFilter::isFilename怎么用?PHP SpoonFilter::isFilename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpoonFilter
的用法示例。
在下文中一共展示了SpoonFilter::isFilename方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIsFilename
public function testIsFilename()
{
$this->assertTrue(SpoonFilter::isFilename('test.tpl'));
$this->assertTrue(SpoonFilter::isFilename('spoon_template.php'));
$this->assertFalse(SpoonFilter::isFilename('/Users/bauffman/Desktop/test.txt'));
// Simulating PHP < 5.4 behaviour
$this->assertTrue(SpoonFilter::isFilename(array()));
}
示例2: isFilename
/**
* Checks for a valid file name (including dots but no slashes and other forbidden characters).
*
* @return bool
* @param string[optional] $error The error message to set.
*/
public function isFilename($error = null)
{
// filled
if ($this->isFilled()) {
// post/get data
$data = $this->getMethod(true);
// validate
if (!isset($data[$this->attributes['name']]) || !SpoonFilter::isFilename($data[$this->attributes['name']])) {
if ($error !== null) {
$this->setError($error);
}
return false;
}
return true;
}
// has error
if ($error !== null) {
$this->setError($error);
}
return false;
}
示例3: processContent
/**
* Function to store the actual content for either HTML or plain text.
*
* @param string $content The body of the e-mail you wish to send.
* @param array $variables The variables to parse into the content.
* @param string[optional] $type The e-mail type. Either 'html' or 'plain'.
*/
private function processContent($content, $variables, $type = 'html')
{
// check for type
$type = SpoonFilter::getValue($type, array('html', 'plain'), 'html');
// exploded string
$exploded = explode('/', str_replace('\\', '/', $content));
$filename = end($exploded);
// check if the string provided is a formatted as a file
if (SpoonFilter::isFilename($filename) && preg_match('/^[\\S]+\\.\\w{2,3}[\\S]$/', $filename) && !strstr($filename, ' ')) {
// check if template exists
if (!SpoonFile::exists($content)) {
throw new SpoonEmailException('Template not found. (' . $content . ')');
}
// store content
$this->content[$type] = (string) $this->getTemplateContent($content, $variables);
} else {
// set the name for the temporary file
$tempFile = $this->compileDirectory . '/' . md5(uniqid()) . '.tpl';
// write temp file
SpoonFile::setContent($tempFile, $content);
// store content
$this->content[$type] = (string) $this->getTemplateContent($tempFile, $variables);
// delete the temporary
SpoonFile::delete($tempFile);
}
}
示例4: isFilename
/**
* Checks for a valid file name (including dots but no slashes and other forbidden characters).
*
* @return bool
* @param string[optional] $error The error message to set.
*/
public function isFilename($error = null)
{
// correct filename
if ($this->isFilled() && SpoonFilter::isFilename($this->getFileName())) {
return true;
}
// has error
if ($error !== null) {
$this->setError($error);
}
return false;
}
示例5: testIsFilename
public function testIsFilename()
{
$this->assertTrue(SpoonFilter::isFilename('test.tpl'));
$this->assertTrue(SpoonFilter::isFilename('spoon_template.php'));
$this->assertFalse(SpoonFilter::isFilename('/Users/bauffman/Desktop/test.txt'));
}