本文整理汇总了PHP中Zend_Filter::appendFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Filter::appendFilter方法的具体用法?PHP Zend_Filter::appendFilter怎么用?PHP Zend_Filter::appendFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Filter
的用法示例。
在下文中一共展示了Zend_Filter::appendFilter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: testFilterPrependOrder
/**
* Ensures that filters can be prepended and will be executed in the
* expected order
*/
public function testFilterPrependOrder()
{
$this->_filter->appendFilter(new Zend_FilterTest_StripUpperCase())->prependFilter(new Zend_FilterTest_LowerCase());
$value = 'AbC';
$valueExpected = 'abc';
$this->assertEquals($valueExpected, $this->_filter->filter($value));
}
示例3: saveImages
private function saveImages($data, $promo)
{
if (isset($data['filePromo'])) {
$relativeImageDir = '/customers/' . $data["userId"];
$customerImageDir = IMAGE_PATH . $relativeImageDir;
$form = $this->view->form;
$adapter = $form->filePromo->getTransferAdapter();
//create directory where files would be hold
if (!is_dir($customerImageDir)) {
mkdir($customerImageDir, 0777, 1);
}
$i = 0;
$images = array();
//loop uploaded files
$files = $adapter->getFileInfo();
foreach ($files as $file => $fileInfo) {
$extension = substr(strrchr($fileInfo['name'], '.'), 1);
$promoImageDir = $customerImageDir . '/' . $promo->getId();
$imageName = $promoImageDir . '/image_' . $i . '.' . $extension;
$imageName2 = $promoImageDir . '/thumb/image_' . $i . '.' . $extension;
if (!is_dir($promoImageDir)) {
mkdir($promoImageDir, 0777, 1);
}
if (!is_dir($promoImageDir . '/thumb')) {
mkdir($promoImageDir . '/thumb', 0777, 1);
}
$adapter->addFilter('Rename', array('target' => $imageName, 'overwrite' => true));
$filterChain = new Zend_Filter();
$filterChain->appendFilter(new Skoch_Filter_File_Resize(array('width' => 300, 'height' => 300, 'keepRatio' => true)));
$filterChain->appendFilter(new Skoch_Filter_File_Resize(array('directory' => $promoImageDir . '/thumb', 'width' => 60, 'height' => 60, 'keepRatio' => true)));
$adapter->addFilter($filterChain);
$images[] = $relativeImageDir . '/' . $promo->getId() . '/image_' . $i . '.' . $extension;
/* TODO: resizing de la imagen
$form->file->addFilter(new Skoch_Filter_File_Resize(array('width' => 200,'height' => 300,'keepRatio' => true,))); */
if (!$adapter->receive($file)) {
$mensajes = $form->filePromo->getMessages();
throw new Exception('Error!!');
}
chmod($logoName, 0777);
$i++;
}
/*foreach ($adapter->getFileInfo() as $info)
{
$extension = substr(strrchr($info['name'],'.'),1);
$promoImageDir = $customerImageDir.'/'.$promo->getId();
if(!is_dir($promoImageDir))
mkdir($promoImageDir, 0666, 1);
$logoName = $promoImageDir.'/image_'.$i.'.'.$extension;
$adapter->addFilter('Rename', array('target'=>$logoName, 'overwrite'=>true));
$images[] = $relativeImageDir.'/'.$promo->getId().'/image_'.$i.'.'.$extension;
TODO: resizing de la imagen
$form->file->addFilter(new Skoch_Filter_File_Resize(array('width' => 200,'height' => 300,'keepRatio' => true,)));
if (!$form->images->receive()) {
$mensajes = $form->images->getMessages();
throw new Exception('Error!!');
}
chmod($logoName,0666);
$i++;
} */
$promo->saveImages($images);
} else {
$promo->loadImages($this->user);
}
}