Exemplo n.º 1
0
 /**
  * Ensures that the filter follows expected behavior
  *
  * @return void
  */
 public function testBasic()
 {
     $valuesExpected = array('filename' => '.', '/path/to/filename' => '/path/to', '/path/to/filename.ext' => '/path/to');
     foreach ($valuesExpected as $input => $output) {
         $this->assertEquals($output, $this->_filter->filter($input));
     }
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 /**
  * Returns dirname(value).
  *
  * @deprecated since 0.8.0
  * @param      mixed $value
  * @return     string
  */
 public static function getDir($value)
 {
     require_once 'Zend/Filter/Dir.php';
     $filter = new Zend_Filter_Dir();
     return $filter->filter($value);
 }