Mausglov

refactor

Feb 4th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.82 KB | None | 0 0
  1. $fname = static::downloadFile($manualUrl);
  2. if ($fname !== '') {
  3.  
  4.     $info = \CFile::MakeFileArray($fname);
  5.     $info['MODULE_ID'] = 'iblock';
  6.     $fileId = \CFile::SaveFile($info, $info['MODULE_ID']);
  7.     if ($fileId) {
  8.         $item->setProperty(static::MANUAL_CODE, $fileId);
  9.     }
  10. }
  11.  
  12. // new version
  13. public static function downloadManual( $manualUrl )
  14. {
  15.     $fileId = 0;
  16.     if ($manualUrl !== '') {
  17.         $fname = static::downloadFile($manualUrl);
  18.         if ($fname !== '') {
  19.  
  20.             $info = CFile::MakeFileArray($fname);
  21.             $info['MODULE_ID'] = 'iblock';
  22.             $fileId = CFile::SaveFile($info, $info['MODULE_ID']);
  23.         }
  24.     }
  25.     return $fileId;
  26. }
  27.  
  28. $fileId = static::downloadManual( $item->getManualUrl() );
  29. if ($fileId) {
  30.     $item->setProperty(static::MANUAL_CODE, $fileId);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment