本文整理汇总了PHP中SJB_HelperFunctions::docx2text方法的典型用法代码示例。如果您正苦于以下问题:PHP SJB_HelperFunctions::docx2text方法的具体用法?PHP SJB_HelperFunctions::docx2text怎么用?PHP SJB_HelperFunctions::docx2text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SJB_HelperFunctions
的用法示例。
在下文中一共展示了SJB_HelperFunctions::docx2text方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getKeywordValue
function getKeywordValue()
{
$keywords = '';
if (!self::isEmpty() && SJB_Settings::getSettingByName('get_keyword_from_file')) {
$fileId = $this->getComplexParent() . ":" . $this->property_info['id'] . ":" . $this->complexEnum . "_" . $this->object_sid;
$fileInfo = SJB_UploadFileManager::getUploadedFileInfo($fileId);
if ($fileInfo) {
$uploadManager = new SJB_UploadFileManager();
$uploadManager->setFileGroup("files");
$fileUrl = $uploadManager->getUploadedFileLink($fileId, $fileInfo, true);
$fileExtension = substr(strrchr($fileInfo['saved_file_name'], "."), 1);
if (file_exists($fileUrl)) {
switch ($fileExtension) {
case 'doc':
$doc = new doc();
$doc->read($fileUrl);
$keywords = preg_replace('/[\\n\\r]/', '', strip_tags($doc->parse()));
break;
case 'docx':
$keywords = SJB_HelperFunctions::docx2text($fileUrl);
$keywords = preg_replace('/[\\n\\r]/', '', strip_tags(html_entity_decode($keywords)));
break;
case 'xls':
case 'xlsx':
$fileInfo['tmp_name'] = $fileUrl;
$fileObj = new SJB_ImportFileXLS($fileInfo);
$fileObj->parse();
$data = $fileObj->getData();
$keywords = '';
foreach ($data as $val) {
$val = array_unique($val);
$val = array_diff($val, array(''));
$keywords .= implode(' ', $val);
}
$keywords = preg_replace("/[[:punct:]^\\s]/ui", " ", $keywords);
break;
case 'pdf':
$outFilename = str_replace("." . $fileExtension, '.txt', $fileUrl);
exec("pdftotext {$fileUrl} {$outFilename}");
if (file_exists($outFilename)) {
$keywords = file_get_contents($outFilename);
$keywords = preg_replace('/[\\n\\r]/', '', strip_tags(html_entity_decode($keywords)));
unlink($outFilename);
}
break;
case 'txt':
$keywords = file_get_contents($fileUrl);
$keywords = preg_replace('/[\\n\\r]/', '', strip_tags(html_entity_decode($keywords)));
break;
}
}
}
}
return $keywords;
}