本文整理汇总了PHP中Zend_Filter类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Filter类的具体用法?PHP Zend_Filter怎么用?PHP Zend_Filter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Filter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _savePanel
/**
* Save changes to an existing panel. This can be expanded to allow adding of new Panels in the future.
*
* @return void
*/
protected function _savePanel()
{
// First of all we need to validate and sanitise the input from the form
$urlFilter = new Zend_Filter();
$urlFilter->addFilter(new Zend_Filter_StringTrim());
$urlFilter->addFilter(new Zend_Filter_StringTrim('/'));
$requiredText = new Zend_Validate();
$requiredText->addValidator(new Zend_Validate_NotEmpty());
$filters = array('id' => 'Digits');
$validators = array('id' => array('allowEmpty' => true), 'content' => array('allowEmpty' => true));
$input = new Zend_Filter_Input($filters, $validators, $_POST);
if ($input->isValid()) {
// Data is all valid, formatted and sanitized so we can save it in the database
$panel = new Datasource_Cms_Panels();
if (!$input->id) {
// This is a new panel so we need to create a new ID
// NOT IMPLEMENTED - YET
} else {
$panel->saveChanges($input->id, $input->getUnescaped('content'));
$panelID = $input->id;
}
// Changes saved - so send them back with a nice success message
$this->_helper->getHelper('FlashMessenger')->addMessage(array('saved' => true));
$this->_helper->getHelper('Redirector')->goToUrl('/cms-admin/panels/edit?id=' . $panelID);
} else {
// Invalid data in form
/*
print_r($_POST);
print_r($input->getErrors());
print_r($input->getInvalid());
*/
}
}
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:38,代码来源:PanelsController.php
示例2: init
public function init()
{
$this->setAttrib('enctype', 'multipart/form-data');
$renameResize = new Zend_Form_Element_File('renameResize');
$renameResize->setDestination('../upload');
$renameResize->setLabel('Rename before resize');
$renameResize->addFilter('Rename', 'rename-resize');
$renameResize->addFilter(new Skoch_Filter_File_Resize(array('width' => 200, 'height' => 300, 'keepRatio' => true)));
$this->addElement($renameResize);
$resizeRename = new Zend_Form_Element_File('resizeRename');
$resizeRename->setDestination('../upload');
$resizeRename->setLabel('Resize before rename');
$resizeRename->addFilter(new Skoch_Filter_File_Resize(array('width' => 200, 'height' => 300, 'keepRatio' => true)));
$resizeRename->addFilter('Rename', 'resize-rename');
$this->addElement($resizeRename);
$multiResize = new Zend_Form_Element_File('multiResize');
$multiResize->setDestination('../upload');
$multiResize->setLabel('Multiple resizes');
$filterChain = new Zend_Filter();
// Create one big image with at most 600x300 pixel
$filterChain->appendFilter(new Skoch_Filter_File_Resize(array('width' => 600, 'height' => 300, 'keepRatio' => true)));
// Create a medium image with at most 500x200 pixels
$filterChain->appendFilter(new Skoch_Filter_File_Resize(array('directory' => '../upload/medium', 'width' => 500, 'height' => 200, 'keepRatio' => true)));
$multiResize->addFilter('Rename', 'multi-resize');
$multiResize->addFilter($filterChain);
$this->addElement($multiResize);
$renameCrop = new Zend_Form_Element_File('renameCrop');
$renameCrop->setDestination('../upload');
$renameCrop->setLabel('Rename before crop');
$renameCrop->addFilter('Rename', 'rename-crop');
$renameCrop->addFilter(new Skoch_Filter_File_Resize(array('width' => 20, 'height' => 30, 'cropToFit' => true, 'keepRatio' => true)));
$this->addElement($renameCrop);
$submit = new Zend_Form_Element_Submit('submit');
$this->addElement($submit);
}
开发者ID:pbleuse-orange,项目名称:skoch-filter-file-resize,代码行数:35,代码来源:Image.php
示例3: testFilterOrder
/**
* Ensures that filters are executed in the expected order (FIFO)
*
* @return void
*/
public function testFilterOrder()
{
$this->_filter->addFilter(new Zend_FilterTest_LowerCase())->addFilter(new Zend_FilterTest_StripUpperCase());
$value = 'AbC';
$valueExpected = 'abc';
$this->assertEquals($valueExpected, $this->_filter->filter($value));
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:12,代码来源:FilterTest.php
示例4: run
/**
* Run the cli application
*
* @return void
*/
public function run()
{
$oLogger = $this->getResource('log');
$iArgumentsAmount = $_SERVER['argc'];
if (1 === $iArgumentsAmount) {
echo 'Please specify the task to run' . PHP_EOL;
$oLogger->err('Task not specified!');
exit;
}
$aArguments =& $_SERVER['argv'];
$aArguments = array_slice($aArguments, 1);
$oFilter = new Zend_Filter();
$oFilter->addFilter(new Zend_Filter_Word_UnderscoreToCamelCase());
$sTaskClass = 'AM_Cli_Task_' . $oFilter->filter($aArguments[0]);
if (!class_exists($sTaskClass)) {
echo sprintf('Class %s not found', $sTaskClass) . PHP_EOL;
$oLogger->err(sprintf('Class %s not found', $sTaskClass));
exit;
}
try {
$oTask = new $sTaskClass();
$oTask->run();
} catch (Exception $e) {
$oLogger->err($e);
exit;
}
}
开发者ID:pansot2,项目名称:PadCMS-backend,代码行数:32,代码来源:Bootstrap.php
示例5: _realloc
/**
* Realoca uma Imagem do Formulário
* @param string $filename Novo Nome do Arquivo
* @return string|boolean Resultado Obtido
*/
protected function _realloc($prefix)
{
/* @var $arquivo Zend_Form_Element_File */
$arquivo = $this->_getForm()->getElement('arquivo');
if (is_array($arquivo->getFilename())) {
// Não Enviado
return false;
}
// Diretório Base
$basename = APPLICATION_PATH . '/../public/images/sistema/';
// Remover Figuras com Prefixo
$dir = new DirectoryIterator($basename);
foreach ($dir as $current) {
if (preg_match('/^' . $prefix . '/', $current->getFilename())) {
unlink($current->getRealPath());
}
}
// Criação do Slug
$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_StringToLower())->addFilter(new Zend_Filter_Word_SeparatorToDash());
$slug = $filter->filter($prefix . ' ' . $arquivo->getFilename(null, false));
// Opções para Filtro
$options = array('target' => $basename . $slug, 'overwrite' => true);
// Renomear Arquivo
$rename = new Zend_Filter_File_Rename($options);
$result = $rename->filter($arquivo->getFilename());
return is_string($result) ? $slug : false;
}
开发者ID:laiello,项目名称:wanderson,代码行数:33,代码来源:FiguraController.php
示例6: filter
/**
* Filter data that was previously validated (input data)
* If data was not valid, filter the error message that will
* be output to the user (output data)
* @access public
* @return bool
*/
public function filter()
{
$this->_data = array();
$this->_error = array();
$values = $this->_options['values'];
$validator = $this->_options['validator'];
$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_StringTrim());
foreach ($values as $k => $v) {
if ($validator->isValid($values[$k])) {
//filter the input
$this->_data[$k] = $filter->filter($values[$k]);
} else {
foreach ($validator->getMessages() as $message) {
//filter the output
$this->_error[$k] = str_replace($values[$k], $filter->filter($values[$k]), $message);
}
}
}
if (empty($this->_error)) {
return true;
} else {
return false;
}
}
开发者ID:sandeepdwarkapuria,项目名称:dotkernel,代码行数:32,代码来源:Filter.php
示例7: filter
public function filter($value)
{
$filterChain = new Zend_Filter();
$filterChain->addFilter(new Zend_Filter_StripTags());
$filterChain->addFilter(new Zend_Filter_StringTrim());
$filterChain->addFilter(new Zend_Filter_StringToLower());
$value = $filterChain->filter($value);
// replace accented characters
$replaceArray = array('á' => 'a', 'é' => 'e', 'í' => 'i', 'ó' => 'o', 'ú' => 'u', 'à' => 'a', 'è' => 'e', 'ì' => 'i', 'ò' => 'o', 'ù' => 'u', 'ä' => 'a', 'ë' => 'e', 'ï' => 'i', 'ö' => 'o', 'ü' => 'u', 'â' => 'a', 'ê' => 'e', 'î' => 'i', 'ô' => 'o', 'û' => 'u', 'ç' => 'c', 'æ' => 'ae', 'œ' => 'oe', 'å' => 'a', 'ø' => 'o', '@' => 'at', '©' => 'copyright', '€' => 'euro', '™' => 'tm', '-' => ' ', '/' => ' ', '\\' => ' ');
$value = str_replace(array_keys($replaceArray), array_values($replaceArray), $value);
$valueTemp = '';
$allowedChars = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_', ' ');
$valueTemp = '';
for ($i = 0; $i < strlen($value); $i++) {
if (in_array($value[$i], $allowedChars)) {
$valueTemp .= $value[$i];
}
}
$value = $valueTemp;
// replace double spaces
$value = preg_replace('/\\s+/', ' ', $value);
$filterChain = new Zend_Filter();
$filterChain->addFilter(new Zend_Filter_StringTrim());
$filterChain->addFilter(new Zend_Filter_Word_SeparatorToDash());
$value = $filterChain->filter($value);
return $value;
}
开发者ID:hausdesign,项目名称:zf-library,代码行数:27,代码来源:Urlise.php
示例8: onAttachLink
public function onAttachLink($data)
{
try {
$viewer = Engine_Api::_()->user()->getViewer();
if (Engine_Api::_()->core()->hasSubject()) {
$subject = Engine_Api::_()->core()->getSubject();
if ($subject->getType() != 'user') {
$data['parent_type'] = $subject->getType();
$data['parent_id'] = $subject->getIdentity();
}
}
// Filter HTML
$filter = new Zend_Filter();
$filter->addFilter(new Engine_Filter_Censor());
$filter->addFilter(new Engine_Filter_HtmlSpecialChars());
if (!empty($data['title'])) {
$data['title'] = $filter->filter($data['title']);
}
if (!empty($data['description'])) {
$data['description'] = $filter->filter($data['description']);
}
$link = Engine_Api::_()->getApi('links', 'core')->createLink($viewer, $data);
} catch (Exception $e) {
throw $e;
return;
}
return $link;
}
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:28,代码来源:Composer.php
示例9: _setupTableName
/**
* @see Zend_Db_Table_Abstract::_setupTableName
*/
protected function _setupTableName()
{
if (!$this->_name) {
$oFilter = new Zend_Filter();
$oFilter->addFilter(new Zend_Filter_Word_CamelCaseToUnderscore())->addFilter(new Zend_Filter_StringToLower());
$this->_name = $oFilter->filter($this->_getModelName());
}
}
开发者ID:pansot2,项目名称:PadCMS-backend,代码行数:11,代码来源:Abstract.php
示例10: filter
function filter($instr)
{
$outstr = null;
$filterChain = new Zend_Filter();
$filterChain->addFilter(new Zend_Filter_StringToLower())->addFilter(new Zend_Filter_StringTrim());
$instr = $filterChain->filter($instr);
$outstr = str_replace(" ", "-", trim($instr));
return $outstr;
}
开发者ID:jaybill,项目名称:Bolts,代码行数:9,代码来源:FilterFilename.php
示例11: filter
public function filter($value)
{
$filterChain = new Zend_Filter();
//$geshiFilter = new HausDesign_Filter_Geshi();
//$filterChain->addFilter($geshiFilter);
$value = $filterChain->filter($value);
require_once 'markdown/markdown.php';
return Markdown($value);
}
开发者ID:hausdesign,项目名称:zf-library,代码行数:9,代码来源:Markdown.php
示例12: filter
/**
* Normalizuje ciag znakow z postaci stringa zawierajacego znaki specjalne i spacje do hasha
*
* @param string $value
* @return string
*/
public function filter($value)
{
$filterChain = new Zend_Filter();
$filterChain->addFilter(new Base_Filter_NoDiacritics())->addFilter(new Zend_Filter_StringToLower());
$value = $filterChain->filter($value);
$value = preg_replace('/[^0-9A-Za-z-_]/', null, $value);
$value = trim($value, '-');
$value = trim($value, '_');
return $value;
}
开发者ID:knatorski,项目名称:SMS,代码行数:16,代码来源:StringToHash.php
示例13: normalizeTag
/**
* Normalize tag
*
* Ensures tag is alphanumeric characters only, and all lowercase.
*
* @param string $tag
* @return string
*/
public function normalizeTag($tag)
{
if (!isset($this->_tagFilter)) {
require_once 'Zend/Filter.php';
require_once 'Zend/Filter/Alnum.php';
require_once 'Zend/Filter/StringToLower.php';
$this->_tagFilter = new Zend_Filter();
$this->_tagFilter->addFilter(new Zend_Filter_Alnum())->addFilter(new Zend_Filter_StringToLower());
}
return $this->_tagFilter->filter($tag);
}
开发者ID:hausdesign,项目名称:zf-library,代码行数:19,代码来源:FormWrapper.php
示例14: filter
public static function filter(&$data)
{
$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_StringTrim())->addFilter(new Lds_Filter_Htmlspecialchars());
if (is_array($data)) {
foreach ($data as $key => $value) {
$data[$key] = $filter->filter($value);
}
} else {
$data = $filter->filter($data);
}
}
开发者ID:sandin,项目名称:iMemo,代码行数:12,代码来源:Filter.php
示例15: filter
public function filter($value)
{
$filterChain = new Zend_Filter();
$htmlFilter = new HausDesign_Filter_HtmlPurifier();
$config = $htmlFilter->getConfig();
$config->set('AutoFormat', 'AutoParagraph', true);
$config->set('AutoFormat', 'Linkify', true);
$filterChain->addFilter($htmlFilter);
//$geshiFilter = new HausDesign_Filter_Geshi();
//$filterChain->addFilter($geshiFilter);
return $filterChain->filter($value);
}
开发者ID:hausdesign,项目名称:zf-library,代码行数:12,代码来源:AllHtml.php
示例16: getName
/**
* Get helper name
* @return string
*/
public function getName()
{
if (is_null($this->_sName)) {
$sClassName = get_class($this);
$aChunks = explode('_', $sClassName);
$this->_sName = array_pop($aChunks);
$oFilter = new Zend_Filter();
$oFilter->addFilter(new Zend_Filter_Word_CamelCaseToUnderscore())->addFilter(new Zend_Filter_StringToLower());
$this->_sName = $oFilter->filter($this->_sName);
}
return $this->_sName;
}
开发者ID:pansot2,项目名称:PadCMS-backend,代码行数:16,代码来源:Abstract.php
示例17: filterUrl
/**
* Filter url given to the toaster
*
* @param string $pageUrl
* @return mixed|string
*/
public function filterUrl($pageUrl)
{
$filterChain = new Zend_Filter();
$filterChain->addFilter(new Zend_Filter_PregReplace(array('match' => '/-/', 'replace' => ' ')))->addFilter(new Zend_Filter_Alnum(true))->addFilter(new Zend_Filter_StringTrim())->addFilter(new Zend_Filter_StringToLower('UTF-8'))->addFilter(new Zend_Filter_PregReplace(array('match' => '/\\s+/', 'replace' => '-')));
// filtering the page url
$pageUrl = $filterChain->filter($this->clean($pageUrl));
// add .html if needed
// TODO: in fact it always needed because of Zend_Filter_Alnum in $filterChain
if (!preg_match('/\\.html$/', $pageUrl)) {
$pageUrl .= '.html';
}
return $pageUrl;
}
开发者ID:PavloKovalov,项目名称:seotoaster,代码行数:19,代码来源:Page.php
示例18: filter
function filter($instr)
{
$outstr = null;
$filterChain = new Zend_Filter();
$filterChain->addFilter(new Zend_Filter_StringToLower())->addFilter(new Zend_Filter_StripTags())->addFilter(new Zend_Filter_StringTrim());
$instr = $filterChain->filter($instr);
$instr = str_replace(" ", "-", trim($instr));
preg_match_all("/^[a-z0-9\\-\\\$]{1,}\$/", $instr, $parts);
foreach ($parts as $part) {
$outstr .= $part[0];
}
return $outstr;
}
开发者ID:jaybill,项目名称:Bolts,代码行数:13,代码来源:FilterTags.php
示例19: _getFormReferencia
/**
* Captura um Formulário de Determinado Tipo
* @param string Nome do Formulário
* @return Local_Form_FormAbstract Elemento Solicitado
*/
protected function _getFormReferencia($tipo)
{
// Filtro de Dados
$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_StringToLower())->addFilter(new Zend_Filter_Callback('ucfirst'));
$tipo = $filter->filter($tipo);
// Verificação
if (!in_array($tipo, $this->_references)) {
throw new Zend_Controller_Action_Exception('Invalid Referencia');
}
$classname = 'Application_Form_Referencia_' . $tipo;
$reflect = new Zend_Reflection_Class($classname);
return $reflect->newInstance(array());
}
开发者ID:laiello,项目名称:wanderson,代码行数:19,代码来源:ReferenciaController.php
示例20: filter
public function filter($value)
{
$words = explode(',', $value);
$filterChain = new Zend_Filter();
$filterChain->addFilter(new Zend_Filter_StringTrim())->addFilter(new Zend_Filter_StringToLower())->addFilter(new Zend_Filter_StripNewlines())->addFilter(new Zend_Filter_Alnum(array('allowwhitespace' => true)));
$filterd = array();
foreach ($words as $word) {
$word = $filterChain->filter($word);
if (strlen($word) > 0) {
$filterd[] = $word;
}
}
return implode(',', $filterd);
}
开发者ID:roed,项目名称:zend-mvc-extend,代码行数:14,代码来源:Tags.php
注:本文中的Zend_Filter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论