当前位置: 首页>>代码示例>>PHP>>正文


PHP F::File_Copy方法代码示例

本文整理汇总了PHP中F::File_Copy方法的典型用法代码示例。如果您正苦于以下问题:PHP F::File_Copy方法的具体用法?PHP F::File_Copy怎么用?PHP F::File_Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在F的用法示例。


在下文中一共展示了F::File_Copy方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: EventSkin

 protected function EventSkin()
 {
     $aParams = $this->GetParams();
     $sSkinName = array_shift($aParams);
     $sRelPath = implode('/', $aParams);
     $sOriginalFile = Config::Get('path.skins.dir') . $sSkinName . '/' . $sRelPath;
     if (F::File_Exists($sOriginalFile)) {
         $sAssetFile = F::File_GetAssetDir() . 'skin/' . $sSkinName . '/' . $sRelPath;
         if (F::File_Copy($sOriginalFile, $sAssetFile)) {
             if (headers_sent($sFile, $nLine)) {
                 $sUrl = F::File_GetAssetUrl() . 'skin/' . $sSkinName . '/' . $sRelPath;
                 if (strpos($sUrl, '?')) {
                     $sUrl .= '&' . uniqid();
                 } else {
                     $sUrl .= '?' . uniqid();
                 }
                 R::Location($sUrl);
             } else {
                 header_remove();
                 if ($sMimeType = F::File_MimeType($sAssetFile)) {
                     header('Content-Type: ' . $sMimeType);
                 }
                 echo file_get_contents($sAssetFile);
                 exit;
             }
         }
     }
     F::HttpHeader('404 Not Found');
     exit;
 }
开发者ID:AntiqS,项目名称:altocms,代码行数:30,代码来源:ActionAsset.class.php

示例2: _saveTopicImage

 /**
  * Save uploaded image into store
  *
  * @param string                $sImageFile
  * @param ModuleUser_EntityUser $oUser
  * @param string                $sType
  * @param array                 $aOptions
  *
  * @return bool
  */
 protected function _saveTopicImage($sImageFile, $oUser, $sType, $aOptions = array())
 {
     $sExtension = F::File_GetExtension($sImageFile, true);
     $aConfig = E::ModuleUploader()->GetConfig($sImageFile, 'images.' . $sType);
     if ($aOptions) {
         $aConfig['transform'] = F::Array_Merge($aConfig['transform'], $aOptions);
     }
     // Check whether to save the original
     if (isset($aConfig['original']['save']) && $aConfig['original']['save']) {
         $sSuffix = isset($aConfig['original']['suffix']) ? $aConfig['original']['suffix'] : '-original';
         $sOriginalFile = F::File_Copy($sImageFile, $sImageFile . $sSuffix . '.' . $sExtension);
     } else {
         $sSuffix = '';
         $sOriginalFile = null;
     }
     // Transform image before saving
     $sFileTmp = E::ModuleImg()->TransformFile($sImageFile, $aConfig['transform']);
     if ($sFileTmp) {
         $sDirUpload = E::ModuleUploader()->GetUserImageDir($oUser->getId(), true, $sType);
         $sFileImage = E::ModuleUploader()->Uniqname($sDirUpload, $sExtension);
         if ($oStoredFile = E::ModuleUploader()->Store($sFileTmp, $sFileImage)) {
             if ($sOriginalFile) {
                 E::ModuleUploader()->Move($sOriginalFile, $oStoredFile->GetFile() . $sSuffix . '.' . $sExtension);
             }
             return $oStoredFile->GetUrl();
         }
     }
     return false;
 }
开发者ID:AlexSSN,项目名称:altocms,代码行数:39,代码来源:Topic.class.php

示例3: _convertUrlsInCss

 protected function _convertUrlsInCss($sContent, $sSourceDir)
 {
     // Есть ли в файле URLs
     if (!preg_match_all('/(?P<src>src:)?url\\((?P<url>.*?)\\)/is', $sContent, $aMatchedUrl, PREG_OFFSET_CAPTURE)) {
         return $sContent;
     }
     // * Обрабатываем список URLs
     $aUrls = array();
     foreach ($aMatchedUrl['url'] as $nIdx => $aPart) {
         $sPath = $aPart[0];
         //$nPos = $aPart[1];
         // * Don't touch data URIs
         if (strstr($sPath, 'data:')) {
             continue;
         }
         $sPath = str_replace(array('\'', '"'), '', $sPath);
         // * Если путь является абсолютным, то не обрабатываем
         if (substr($sPath, 0, 1) == "/" || substr($sPath, 0, 5) == 'http:' || substr($sPath, 0, 6) == 'https:') {
             continue;
         }
         if (($n = strpos($sPath, '?')) || ($n = strpos($sPath, '#'))) {
             $sPath = substr($sPath, 0, $n);
             $sFileParam = substr($sPath, $n);
         } else {
             $sFileParam = '';
         }
         if (!isset($aUrls[$sPath])) {
             // if url didn't prepare...
             $sRealPath = realpath($sSourceDir . $sPath);
             if ($sRealPath) {
                 $sDestination = F::File_GetAssetDir() . F::Crc32(dirname($sRealPath), true) . '/' . basename($sRealPath);
                 $aUrls[$sPath] = array('source' => $sRealPath, 'destination' => $sDestination, 'url' => E::ModuleViewerAsset()->AssetFileDir2Url($sDestination) . $sFileParam);
                 F::File_Copy($sRealPath, $sDestination);
             }
         }
     }
     if ($aUrls) {
         $sContent = str_replace(array_keys($aUrls), F::Array_Column($aUrls, 'url'), $sContent);
     }
     return $sContent;
 }
开发者ID:hard990,项目名称:altocms,代码行数:41,代码来源:PackageCss.entity.class.php

示例4: File2Link

 /**
  * @param  string $sLocalFile
  * @param  string $sParentDir
  *
  * @return bool|string
  */
 public function File2Link($sLocalFile, $sParentDir = null)
 {
     $sAssetFile = $this->AssetFileDir($sLocalFile, $sParentDir);
     if (F::File_Exists($sAssetFile) || F::File_Copy($sLocalFile, $sAssetFile)) {
         return $this->AssetFileUrl($sLocalFile, $sParentDir);
     }
     return false;
 }
开发者ID:AntiqS,项目名称:altocms,代码行数:14,代码来源:ViewerAsset.class.php

示例5: StoreImage

 /**
  * Stores uploaded image with optional cropping
  *
  * @param  string $sFile - The server path to the temporary image file
  * @param  string $sTarget - Target type
  * @param  string $sTargetId - Target ID
  * @param  array|int|bool $xSize - The size of the area to cut the picture:
  *                               array('x1'=>0,'y1'=>0,'x2'=>100,'y2'=>100)
  *                               100 - crop 100x100 by center
  *                               true - crop square by min side
  *
  * @param bool $bMulti - Target has many images
  * @return bool|ModuleMresource_EntityMresource
  */
 public function StoreImage($sFile, $sTarget, $sTargetId, $xSize = null, $bMulti = FALSE)
 {
     $oImg = E::ModuleImg()->Read($sFile);
     if (!$oImg) {
         // Возникла ошибка, надо обработать
         /** TODO Обработка ошибки */
         $this->nLastError = self::ERR_TRANSFORM_IMAGE;
         return false;
     }
     $sExtension = strtolower(pathinfo($sFile, PATHINFO_EXTENSION));
     $aConfig = $this->GetConfig($sFile, 'images.' . $sTarget);
     // Check whether to save the original
     if (isset($aConfig['original']['save']) && $aConfig['original']['save']) {
         $sSuffix = isset($aConfig['original']['suffix']) ? $aConfig['original']['suffix'] : '-original';
         $sOriginalFile = F::File_Copy($sFile, $sFile . $sSuffix . '.' . $sExtension);
     } else {
         $sOriginalFile = null;
     }
     if (!is_null($xSize)) {
         if ($xSize === true) {
             // crop square by min side
             $oImg = E::ModuleImg()->CropSquare($oImg, TRUE);
         } elseif (is_numeric($xSize)) {
             // crop square in center
             $oImg = E::ModuleImg()->CropCenter($oImg, intval($xSize), intval($xSize));
         } elseif (is_array($xSize) && !empty($xSize)) {
             if (!isset($xSize['w']) && isset($xSize['x1']) && isset($xSize['x2'])) {
                 $xSize['w'] = $xSize['x2'] - $xSize['x1'];
             }
             if (!isset($xSize['h']) && isset($xSize['y1']) && isset($xSize['y2'])) {
                 $xSize['h'] = $xSize['y2'] - $xSize['y1'];
             }
             if (isset($xSize['w']) && !isset($xSize['h'])) {
                 $xSize['h'] = $oImg->getHeight();
             }
             if (!isset($xSize['w']) && isset($xSize['h'])) {
                 $xSize['w'] = $oImg->getWidth();
             }
             if (isset($xSize['w']) && isset($xSize['h']) && !(isset($xSize['x1']) && isset($xSize['y1']))) {
                 $oImg = E::ModuleImg()->CropCenter($oImg, $xSize['w'], $xSize['h']);
             } else {
                 $oImg = E::ModuleImg()->Crop($oImg, $xSize['w'], $xSize['h'], $xSize['x1'], $xSize['y1']);
             }
         }
     }
     if ($aConfig['transform']) {
         E::ModuleImg()->Transform($oImg, $aConfig['transform']);
     }
     // Сохраняем изображение во временный файл
     if ($sTmpFile = $oImg->Save(F::File_UploadUniqname($sExtension))) {
         // Файл, куда будет записано изображение
         $sImageFile = $this->Uniqname(E::ModuleUploader()->GetUserImageDir(E::UserId(), true, false), $sExtension);
         // Окончательная запись файла
         if ($oStoredFile = $this->Store($sTmpFile, $sImageFile)) {
             $oResource = E::ModuleMresource()->GetMresourcesByUuid($oStoredFile->getUuid());
             $aTmpTarget = array('topic_comment', 'talk_comment', 'talk');
             if (!(in_array($sTarget, $aTmpTarget) && !$sTargetId)) {
                 if (!$this->AddRelationResourceTarget($oResource, $sTarget, $sTargetId, $bMulti)) {
                     // TODO Возможная ошибка
                 }
             }
             return $oStoredFile;
         }
     }
     return false;
 }
开发者ID:AntiqS,项目名称:altocms,代码行数:80,代码来源:Uploader.class.php

示例6: File2Link

 /**
  * @param  string $sLocalFile
  * @param  string $sParentDir
  *
  * @return bool|string
  */
 public function File2Link($sLocalFile, $sParentDir = null)
 {
     $sAssetFile = $this->AssetFileDir($sLocalFile, $sParentDir);
     $aInfo = F::File_PathInfo($sLocalFile);
     if (F::File_Exists($sAssetFile) || F::File_Copy($aInfo['dirname'] . '/' . $aInfo['basename'], $sAssetFile)) {
         return $this->AssetFileUrl($sLocalFile, $sParentDir);
     }
     return false;
 }
开发者ID:anp135,项目名称:altocms,代码行数:15,代码来源:ViewerAsset.class.php

示例7: PrepareFile

 /**
  * Обработка файла
  *
  * @param string $sFile
  * @param string $sDestination
  *
  * @return string
  */
 public function PrepareFile($sFile, $sDestination)
 {
     return F::File_Copy($sFile, $sDestination);
 }
开发者ID:hard990,项目名称:altocms,代码行数:12,代码来源:Package.entity.class.php


注:本文中的F::File_Copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。