public static function importImageFromUrl($pUrl, $pUserId)
 {
     try {
         // try to get an image from url
         $lImage = UrlUtils::getUrlContent($pUrl);
         // create folder structure and save the image to our local filesystem
         $path = FilesystemHelper::generateSystemPath(md5(strtolower($pUrl)) . '-' . $pUserId . '.jpg', sfConfig::get('sf_upload_dir') . DIRECTORY_SEPARATOR . 'avatars' . DIRECTORY_SEPARATOR . 'original');
         $fp = fopen($path, 'w+');
         fputs($fp, $lImage);
         fclose($fp);
         // transform to png
         // get mime-type
         $lImgData = GetImageSize($path);
         if ($lImgData['mime'] != 'image/x-ms-bmp' && $lImgData['mime'] != 'image/x-portable-bitmap' && $lImgData['mime'] != 'image/bmp') {
             $lImg = new sfImage($path, $lImgData['mime'], 'GD');
             $lImg->getMIMEType();
             $lImg->setQuality(100);
             $lImg->saveAs($path, 'image/jpg');
             unset($lImage);
             return true;
         }
         return false;
     } catch (Exception $e) {
         sfContext::getInstance()->getLogger()->err("{ImageImporter} Exception: " . print_r($e, true));
         return false;
     }
 }
 function downloadTime($file_path)
 {
     if ($file_path = FilesystemHelper::_findFilePath($file_path)) {
         return NFilesystem::download_time(filesize($file_path));
     }
     return false;
 }
 /**
  * Initializes the combine and minify-processes
  *
  * @param string $pDir
  * @param string $pFileName
  * @param string $pFileMinName
  */
 private function writeWholeFile($pDir, $pFileName, $pFileMinName)
 {
     //we get all Files we want to combine
     $lFiles = FilesystemHelper::retrieveFilesInDir($pDir, array('.svn', 'include', 'tiny_mce', 'widget', 'engineroom'), array($pFileName, $pFileMinName), '.css');
     //we combine the Files to one file named by given filename and save it in the include-folder
     $this->combineFiles($lFiles, $pFileName);
     //we minify the combined file and save it in the include-folder by given fileminname
     $lCssMin = Minify_CSS_Compressor::process(file_get_contents(dirname(__FILE__) . '/../../web/css/include/' . $pFileName));
     $lCssMinFile = fopen(dirname(__FILE__) . '/../../web/css/include/' . $pFileMinName, 'w+');
     $lDone = fwrite($lCssMinFile, $lCssMin);
     fclose($lCssMinFile);
     echo "build css-File: " . $pFileMinName;
     echo "\n\r";
 }
 /**
  * Minifies a given File(whole filepath) to a new filed named by fileminname
  *
  * @param string $pFile
  * @param string $pFileMinName
  */
 private function minifyFiles($pDirname, $pWriteMode = "a+", $pFileExtension = "min.js")
 {
     //take all combined files from the include-folder
     $lFiles = FilesystemHelper::retrieveFilesInDir($pDirname, array('.svn'), array(), '.js');
     foreach ($lFiles as $lFile) {
         //minify each single combined file
         $lJsMin = JSMin::minify(file_get_contents($lFile));
         //build the filename with path
         $lFileName = $pDirname . str_replace('.js', '', basename($lFile)) . '.' . $pFileExtension;
         //build a new minify-file named by given fileminname and open it
         $lMinFile = fopen($lFileName, $pWriteMode);
         //write the minified content to the new minify-file
         $lDone = fwrite($lMinFile, $lJsMin);
         //and close the new minify-file
         fclose($lMinFile);
         echo "Minified: " . $lFileName;
         echo "\n\r";
     }
 }
Beispiel #5
0
 /**
  * Get the mapping from extension to mime type
  *
  * @return array The associative array of extension => mime type mapping
  *
  * @since 1.0.0
  */
 public static function getMimeMapping()
 {
     // get current mimes
     $mimes = parent::getMimeMapping();
     // add missing mimes
     $mimes['mp3'][] = 'audio/mp3';
     // necesary for Chrome unsolved bug
     return $mimes;
 }