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


PHP File::getFileContents方法代码示例

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


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

示例1: getById

 /**
  * @param $templateName
  * @return array|null
  */
 public static function getById($templateName)
 {
     $result = null;
     $localPathOfIcon = static::LOCAL_DIR_IMG . bx_basename($templateName) . '.png';
     $fullPathOfIcon = \Bitrix\Main\Loader::getLocal($localPathOfIcon);
     $fullPathOfFile = \Bitrix\Main\Loader::getLocal(static::LOCAL_DIR_TMPL . bx_basename($templateName) . '.php');
     if ($fullPathOfFile) {
         $fileContent = File::getFileContents($fullPathOfFile);
     } else {
         $fileContent = '';
     }
     if (!empty($fileContent) || $templateName == 'empty') {
         $fileContent = str_replace(array('%TEXT_UNSUB_TEXT%', '%TEXT_UNSUB_LINK%'), array(Loc::getMessage('PRESET_MAILBLOCK_unsub_TEXT_UNSUB_TEXT'), Loc::getMessage('PRESET_MAILBLOCK_unsub_TEXT_UNSUB_LINK')), $fileContent);
         $result = array('TYPE' => 'BASE', 'NAME' => Loc::getMessage('PRESET_TEMPLATE_' . $templateName), 'ICON' => !empty($fullPathOfIcon) ? '/bitrix' . $localPathOfIcon : '', 'HTML' => $fileContent);
     }
     return $result;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:21,代码来源:template.php

示例2: bindTemplate

 /**
  * Binds (and creates if it's necessary) template to the application folder
  *
  * @param $templateId - symbolic code of the template
  * @param $folder - the application folder
  * @param bool $createNew - flag of the necessity of creating a new template
  */
 public static function bindTemplate($templateId, $folder, $createNew)
 {
     $arFields = array("TEMPLATE" => array());
     if ($createNew) {
         CopyDirFiles(Application::getDocumentRoot() . "/bitrix/modules/mobileapp/templates/default_app/", Application::getDocumentRoot() . "/bitrix/templates/" . $templateId, True, True);
         File::putFileContents(Application::getDocumentRoot() . "/bitrix/templates/" . $templateId . "/description.php", str_replace(array("#mobile_template_name#"), array($templateId), File::getFileContents(Application::getDocumentRoot() . "/bitrix/templates/" . $templateId . "/description.php")));
         $arFields["TEMPLATE"][] = array("SORT" => 1, "CONDITION" => "CSite::InDir('/" . $folder . "/')", "TEMPLATE" => $templateId);
     }
     $default_site_id = \CSite::GetDefSite();
     if ($default_site_id) {
         $dbTemplates = \CSite::GetTemplateList($default_site_id);
         $arFields["LID"] = $default_site_id;
         $isTemplateFound = false;
         while ($template = $dbTemplates->Fetch()) {
             $arFields["TEMPLATE"][] = array("TEMPLATE" => $template['TEMPLATE'], "SORT" => $template['SORT'], "CONDITION" => $template['CONDITION']);
             if ($template["TEMPLATE"] == $templateId && !$createNew && !$isTemplateFound) {
                 $isTemplateFound = true;
                 $arFields["TEMPLATE"][] = array("SORT" => 1, "CONDITION" => "CSite::InDir('/" . $folder . "/')", "TEMPLATE" => $templateId);
             }
         }
         $obSite = new \CSite();
         $obSite->Update($default_site_id, $arFields);
     }
 }
开发者ID:Satariall,项目名称:izurit,代码行数:31,代码来源:manager.php

示例3: setTheme

 protected function setTheme($site_template_id)
 {
     if (strlen($site_template_id) > 0) {
         $result = \CSiteTemplate::GetByID($site_template_id);
         if ($templateFields = $result->Fetch()) {
             $template_path_header = \Bitrix\Main\Application::getDocumentRoot() . $templateFields['PATH'] . '/header.php';
             $template_path_footer = \Bitrix\Main\Application::getDocumentRoot() . $templateFields['PATH'] . '/footer.php';
             if ($templateFields['PATH'] != '' && IO\File::isFileExists($template_path_footer) && IO\File::isFileExists($template_path_header)) {
                 $this->themeStylesString .= $templateFields['TEMPLATE_STYLES'] . "\r\n";
                 $this->themeStylesString .= $templateFields['STYLES'] . "\r\n";
                 $this->setThemeProlog(IO\File::getFileContents($template_path_header));
                 $this->setThemeEpilog(IO\File::getFileContents($template_path_footer));
             }
         }
     }
 }
开发者ID:Satariall,项目名称:izurit,代码行数:16,代码来源:eventmessagethemecompiler.php

示例4: createInBucketFirstPartFromFileArray

 /**
  * Creates first part of file in bucket.
  * @param array                $fileData Array like as $_FILE.
  * @param array                $data Additional fields to TmpFile.
  * @param \CCloudStorageBucket $bucket Cloud bucket.
  * @param array                $params Parameters (startRange, endRange, fileSize).
  * @param ErrorCollection      $errorCollection Error collection.
  * @return Model|null|static
  */
 public static function createInBucketFirstPartFromFileArray(array $fileData, array $data, \CCloudStorageBucket $bucket, array $params, ErrorCollection $errorCollection)
 {
     $data = static::prepareDataToInsertFromFileArray($fileData, $data, $errorCollection);
     $data['IS_CLOUD'] = 1;
     /** @noinspection PhpUndefinedFieldInspection */
     $data['BUCKET_ID'] = $bucket->ID;
     $model = static::add($data, $errorCollection);
     if (!$model) {
         return null;
     }
     $uploadStatus = $model->appendContentCloud(IO\File::getFileContents($model->getAbsoluteNonCloudPath()), $params['startRange'], $params['endRange'], $params['fileSize']);
     if (!$uploadStatus) {
         $errorCollection->add($model->getErrors());
         //todo Are we right?
         $model->delete();
         unset($model);
         return null;
     }
     return $model;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:29,代码来源:tmpfile.php

示例5: setAttachment

 /**
  *
  */
 public function setAttachment()
 {
     $files = $this->attachment;
     if (is_array($this->filesReplacedFromBody)) {
         $files = array_merge($files, array_values($this->filesReplacedFromBody));
     }
     if (count($files) > 0) {
         $eol = $this->eol;
         $charset = $this->charset;
         $bodyPart = '';
         foreach ($files as $attachment) {
             try {
                 $fileContent = File::getFileContents($attachment["PATH"]);
             } catch (\Exception $exception) {
                 $fileContent = '';
             }
             $attachment_name = $this->encodeSubject($attachment["NAME"], $charset);
             $bodyPart .= $eol . "--" . $this->boundary . $eol;
             $bodyPart .= "Content-Type: " . $attachment["CONTENT_TYPE"] . "; name=\"" . $attachment_name . "\"" . $eol;
             $bodyPart .= "Content-Transfer-Encoding: base64" . $eol;
             $bodyPart .= "Content-ID: <" . $attachment["ID"] . ">" . $eol . $eol;
             $bodyPart .= chunk_split(base64_encode($fileContent), 72, $eol);
         }
         $this->body .= $bodyPart;
     }
 }
开发者ID:Satariall,项目名称:izurit,代码行数:29,代码来源:mail.php

示例6: getById

 /**
  * @param $blockName
  * @return array|null
  */
 public static function getById($blockName)
 {
     $result = null;
     $type = null;
     $arBlockByType = static::getBlockListByType();
     foreach ($arBlockByType as $searchType => $arBlock) {
         foreach ($arBlock as $searchBlockName) {
             if ($blockName == $searchBlockName) {
                 $type = $searchType;
                 break;
             }
         }
     }
     $fullPathOfFile = \Bitrix\Main\Loader::getLocal(static::LOCAL_DIR_BLOCK . bx_basename($blockName) . '.html');
     if ($fullPathOfFile) {
         $fileContent = File::getFileContents($fullPathOfFile);
         if ($blockName == 'unsub') {
             $fileContent = str_replace(array('%TEXT_UNSUB_TEXT%', '%TEXT_UNSUB_LINK%'), array(Loc::getMessage('PRESET_MAILBLOCK_' . $blockName . '_TEXT_UNSUB_TEXT'), Loc::getMessage('PRESET_MAILBLOCK_' . $blockName . '_TEXT_UNSUB_LINK')), $fileContent);
         }
         $result = array('TYPE' => Loc::getMessage('TYPE_PRESET_MAILBLOCK_' . $type), 'CODE' => $blockName, 'NAME' => Loc::getMessage('PRESET_MAILBLOCK_' . $blockName), 'ICON' => '', 'HTML' => $fileContent);
     }
     return $result;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:27,代码来源:mailblock.php

示例7: upload

 public function upload($filename, array $fileData)
 {
     $tmpFileClass = $this->tmpFileClass;
     list($startRange, $endRange) = $this->getContentRange();
     $fileSize = $this->getFileSize();
     if ($startRange === null) {
         $fileData['name'] = $filename;
         list($fileData['width'], $fileData['height']) = CFile::getImageSize($fileData['tmp_name']);
         $tmpFile = $tmpFileClass::createFromFileArray($fileData, array('CREATED_BY' => $this->getUserId()), $this->errorCollection);
         if (!$tmpFile) {
             $this->errorCollection->addOne(new Error("Could not create tmpFile model (simple mode)", self::ERROR_CREATE_TMP_FILE_NON_BUCKET));
             return false;
         }
         $this->token = $tmpFile->getToken();
         return true;
     }
     if ($endRange - $startRange + 1 != $fileData['size']) {
         $this->errorCollection->addOne(new Error('Size of file: ' . $fileData['size'] . ' not equals size of chunk: ' . ($endRange - $startRange + 1), self::ERROR_CHUNK_ERROR));
         return false;
     }
     if ($this->isFirstChunk($startRange)) {
         $fileData['name'] = $filename;
         list($fileData['width'], $fileData['height']) = \CFile::getImageSize($fileData['tmp_name']);
         //attempt to decide: cloud? not cloud?
         $bucket = $this->findBucketForFile(array('name' => $filename, 'fileSize' => $fileSize));
         if ($bucket) {
             /** @var TmpFile $tmpFile */
             $tmpFile = $tmpFileClass::createInBucketFirstPartFromFileArray($fileData, array('CREATED_BY' => $this->getUserId()), $bucket, compact('startRange', 'endRange', 'fileSize'), $this->errorCollection);
             if (!$tmpFile) {
                 $this->errorCollection->addOne(new Error("Could not create tmpFile model (cloud bucket {$bucket->ID})", self::ERROR_CREATE_TMP_FILE_BUCKET));
                 return false;
             }
         } else {
             $tmpFile = $tmpFileClass::createFromFileArray($fileData, array('CREATED_BY' => $this->getUserId()), $this->errorCollection);
             if (!$tmpFile) {
                 $this->errorCollection->addOne(new Error("Could not create tmpFile model (simple mode)", self::ERROR_CREATE_TMP_FILE_NON_BUCKET));
                 return false;
             }
         }
         $this->token = $tmpFile->getToken();
         return true;
     }
     //if run resumable upload we needed token.
     if (!$this->hasToken()) {
         $this->errorCollection->addOne(new Error("Could not append content to file. Have to set token parameter.", self::ERROR_EMPTY_TOKEN));
         return false;
     }
     $tmpFile = $this->findUserSpecificTmpFileByToken();
     if (!$tmpFile) {
         $this->errorCollection->addOne(new Error("Could not find file by token", self::ERROR_UNKNOWN_TOKEN));
         return false;
     }
     $success = $tmpFile->append(IO\File::getFileContents($fileData['tmp_name']), compact('startRange', 'endRange', 'fileSize'));
     if (!$success) {
         $this->errorCollection->add($tmpFile->getErrors());
         return false;
     }
     $this->token = $tmpFile->getToken();
     return true;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:60,代码来源:uploadfilemanager.php

示例8: replaceTemplateByDefaultData

 /**
  * @param string $template
  * @return string
  */
 protected static function replaceTemplateByDefaultData($template)
 {
     $phone = '8 495 212-85-06';
     $phonePath = Application::getDocumentRoot() . '/include/telephone.php';
     $logoHeader = '/include/logo.png';
     $logoFooter = '/include/logo_mobile.png';
     if (!File::isFileExists(Application::getDocumentRoot() . $logoHeader)) {
         $logoHeader = '/bitrix/images/sender/preset/blocked1/logo.png';
     }
     if (!File::isFileExists(Application::getDocumentRoot() . $logoFooter)) {
         $logoFooter = '/bitrix/images/sender/preset/blocked1/logo_m.png';
     }
     if (File::isFileExists($phonePath)) {
         $phone = File::getFileContents($phonePath);
     }
     $themeContent = File::getFileContents(\Bitrix\Main\Loader::getLocal(static::LOCAL_DIR_TMPL . 'theme.php'));
     return str_replace(array('%TEMPLATE_CONTENT%', '%LOGO_PATH_HEADER%', '%LOGO_PATH_FOOTER%', '%PHONE%', '%UNSUB_LINK%', '%MENU_CONTACTS%', '%MENU_HOWTO%', '%MENU_DELIVERY%', '%MENU_ABOUT%', '%MENU_GUARANTEE%', '%SCHEDULE_NAME%', '%SCHEDULE_DETAIL%', '%BUTTON%', '%HEADER%', '%TEXT1%', '%TEXT2%', '%TEXT3%', '%TEXT4%', '%TEXT5%', '%TEXT6%'), array($template, $logoHeader, $logoFooter, $phone, Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_UNSUB_LINK'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_MENU_CONTACTS'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_MENU_HOWTO'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_MENU_DELIVERY'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_MENU_ABOUT'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_MENU_GUARANTEE'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_SCHEDULE_NAME'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_SCHEDULE_DETAIL'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_BUTTON'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_HEADER'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_TEXT1'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_TEXT2'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_TEXT3'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_TEXT4'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_TEXT5'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_TEXT6')), $themeContent);
 }
开发者ID:Hawkart,项目名称:megatv,代码行数:22,代码来源:template.php

示例9: createFileInternal

 protected function createFileInternal(FileData $fileData)
 {
     if (!$this->checkRequiredInputParams($fileData->toArray(), array('name', 'src'))) {
         return null;
     }
     $accessToken = $this->getAccessToken();
     $fileName = $fileData->getName();
     $fileName = $this->convertToUtf8($fileName);
     $http = new HttpClient(array('redirect' => false, 'socketTimeout' => 10, 'streamTimeout' => 30, 'version' => HttpClient::HTTP_1_1));
     $fileName = urlencode($fileName);
     $accessToken = urlencode($accessToken);
     if ($http->query('PUT', "https://apis.live.net/v5.0/me/skydrive/files/{$fileName}?access_token={$accessToken}", IO\File::getFileContents(IO\Path::convertPhysicalToLogical($fileData->getSrc()))) === false) {
         $errorString = implode('; ', array_keys($http->getError()));
         $this->errorCollection->add(array(new Error($errorString, self::ERROR_HTTP_FILE_INTERNAL)));
         return null;
     }
     if (!$this->checkHttpResponse($http)) {
         return null;
     }
     $finalOutput = Json::decode($http->getResult());
     if ($finalOutput === null) {
         $this->errorCollection->add(array(new Error('Could not decode response as json', self::ERROR_BAD_JSON)));
         return null;
     }
     $fileData->setId($finalOutput['id']);
     $props = $this->getFileData($fileData);
     if ($props === null) {
         return null;
     }
     $fileData->setLinkInService($props['link']);
     return $fileData;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:32,代码来源:onedrivehandler.php


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