コード例 #1
0
ファイル: BaseNameTest.php プロジェクト: lortnus/zf1
 /**
  * Ensures that the filter follows expected behavior
  *
  * @return void
  */
 public function testBasic()
 {
     $valuesExpected = array('/path/to/filename' => 'filename', '/path/to/filename.ext' => 'filename.ext');
     foreach ($valuesExpected as $input => $output) {
         $this->assertEquals($output, $this->_filter->filter($input));
     }
 }
コード例 #2
0
ファイル: Adapter.php プロジェクト: mygento/cdn
 public function getFile($downloadName)
 {
     Varien_Profiler::start('cdn_download_file_' . $downloadName);
     $adapter = $this->getAdapter();
     if ($adapter) {
         $fileName = Mage::helper('mycdn')->getRelativeFile($downloadName);
         $image = $adapter->downloadFile($fileName);
         if ($image) {
             $bn = new Zend_Filter_BaseName();
             $image_name = $bn->filter($downloadName);
             $dn = new Zend_Filter_Dir();
             $image_path = $dn->filter($downloadName);
             $file = new Varien_Io_File();
             $file->setAllowCreateFolders(true);
             $file->open(['path' => $image_path]);
             $file->streamOpen($image_name);
             $file->streamLock(true);
             $file->streamWrite($image);
             $file->streamUnlock();
             $file->streamClose();
             Mage::helper('mycdn')->addLog('[DOWNLOADED] File downloaded to ' . $downloadName);
             Varien_Profiler::stop('cdn_download_file_' . $downloadName);
             //saving to cache
             Mage::helper('mycdn')->savePathInCache($fileName, $this->getUrl($fileName));
             return true;
         } else {
             Mage::helper('mycdn')->addLog('[NOT DOWNLOADED] File not downloaded to ' . $downloadName);
         }
     }
     Varien_Profiler::stop('cdn_download_file_' . $downloadName);
     return false;
 }
コード例 #3
0
ファイル: Filter.php プロジェクト: jorgenils/zend-framework
 /**
  * Returns basename(value).
  *
  * @deprecated since 0.8.0
  * @param      mixed $value
  * @return     string
  */
 public static function noPath($value)
 {
     require_once 'Zend/Filter/BaseName.php';
     $filter = new Zend_Filter_BaseName();
     return $filter->filter($value);
 }
コード例 #4
0
ファイル: Mailer.php プロジェクト: lesleyauk/findsorguk
 /** Add attachments
  * @access protected
  * @todo test function
  * @param array $attachments
  * @throws Exception
  */
 protected function _addAttachments(array $attachments)
 {
     if (is_array($attachments)) {
         foreach ($attachments as $attach) {
             $filter = new Zend_Filter_BaseName();
             $file = file_get_contents($attach);
             $addition = $this->_mail->createAttachment($file);
             $addition->disposition = Zend_Mime::DISPOSITION_INLINE;
             $addition->encoding = Zend_Mime::ENCODING_BASE64;
             $addition->filename = $filter->filter($attach);
         }
     } else {
         throw new Exception('The attachment list is not an array.');
     }
 }