Ejemplo n.º 1
0
 /**
  * @param bool $getFromFileIfPossible
  * @return string|null
  */
 public function getSrc($getFromFileIfPossible = true)
 {
     if (!$this->src && $getFromFileIfPossible && $this->file instanceof File) {
         $fileArray = \CFile::makeFileArray($this->file->getFileId());
         if (!is_array($fileArray)) {
             return null;
         }
         $this->src = $fileArray['tmp_name'];
     }
     return $this->src;
 }
Ejemplo n.º 2
0
 /**
  *
  * @return null|string
  */
 protected function getFileSrcToPublish()
 {
     if ($this->isSpecificVersion()) {
         $fileId = $this->version->getFileId();
     } else {
         $fileId = $this->file->getFileId();
     }
     $fileArray = \CFile::makeFileArray($fileId);
     if (!is_array($fileArray)) {
         return null;
     }
     return $fileArray['tmp_name'];
 }
Ejemplo n.º 3
0
 private function getFileContent(File $file)
 {
     static $maxFileSize = null;
     if (!isset($maxFileSize)) {
         $maxFileSize = Option::get("search", "max_file_size", 0) * 1024;
     }
     $searchData = '';
     $searchData .= strip_tags($file->getName()) . "\r\n";
     if ($maxFileSize > 0 && $file->getSize() > $maxFileSize) {
         return '';
     }
     $searchDataFile = array();
     $fileArray = CFile::makeFileArray($file->getFileId());
     if ($fileArray && $fileArray['tmp_name']) {
         $fileAbsPath = \CBXVirtualIo::getInstance()->getLogicalName($fileArray['tmp_name']);
         foreach (GetModuleEvents('search', 'OnSearchGetFileContent', true) as $event) {
             if ($searchDataFile = executeModuleEventEx($event, array($fileAbsPath, getFileExtension($fileArray['name'])))) {
                 break;
             }
         }
         return is_array($searchDataFile) ? $searchData . "\r\n" . $searchDataFile['CONTENT'] : $searchData;
     }
     return $searchData;
 }