本文整理汇总了PHP中CBXVirtualIo::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP CBXVirtualIo::getInstance方法的具体用法?PHP CBXVirtualIo::getInstance怎么用?PHP CBXVirtualIo::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBXVirtualIo
的用法示例。
在下文中一共展示了CBXVirtualIo::getInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: openFile
/**
* Opens file by it's absolute path. Returns true on success.
*
* @param string $filePath
* @return bool
*
*/
public function openFile($filePath)
{
$this->fileHandler = null;
$io = CBXVirtualIo::getInstance();
$file = $io->getFile($filePath);
$this->fileHandler = $file->open("rb");
if (is_resource($this->fileHandler)) {
if ($this->filePosition > 0) {
fseek($this->fileHandler, $this->filePosition);
}
$this->elementStack = array();
$this->positionStack = array();
foreach (explode("/", $this->xmlPosition) as $pathPart) {
@(list($elementPosition, $elementName) = explode("@", $pathPart, 2));
$this->elementStack[] = $elementName;
$this->positionStack[] = $elementPosition;
}
return true;
} else {
return false;
}
}
示例2: getFileContent
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;
}