本文整理汇总了PHP中Attachments::getMatching方法的典型用法代码示例。如果您正苦于以下问题:PHP Attachments::getMatching方法的具体用法?PHP Attachments::getMatching怎么用?PHP Attachments::getMatching使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Attachments
的用法示例。
在下文中一共展示了Attachments::getMatching方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createGeneric
/**
* Creates an attachment to the specified data item. This will also pass
* the attachment along for text extraction and indexing if requested. This
* method supports the above createFrom*() methods; however it may also be
* called directly.
*
* @param flag Data Item type flag.
* @param integer Data Item ID.
* @param boolean Is this a profile image attachment?
* @param boolean Attempt to extract, store, and index the attachment's
* text?
* @param string Attachment title, or boolean false to create a title
* automatically from the attachment's filename.
* @param string The filename an attachment originally before any renaming.
* @param string The temporary location where the file is currently stored
* on the system where CATS is located.
* @param string MIME content type (or '' if unknown).
* @param string File's contents if a file is being created from text /
* contents. Specify false if not creating a file by its
* contents.
* @param boolean Does this file actually exist? If true, the file will be
* moved to the created attachment directory automatically.
* If false, the caller is responsible. This has no effect
* if $fileContents is not false.
* @return boolean Was the attachment created successfully?
*/
public function createGeneric($dataItemType, $dataItemID, $isProfileImage, $extractText, $title, $originalFilename, $tempFilename, $contentType, $fileContents, $fileExists)
{
/* Make a 'safe' filename with only standard ASCII characters. */
$storedFilename = FileUtility::makeSafeFilename($originalFilename);
/* Create an attachment title. */
$attachmentTitle = FileUtility::getFileWithoutExtension($originalFilename);
/* Make attachment searchable. */
if (!$extractText) {
$extractedText = '';
} else {
$documentToText = new DocumentToText();
$documentType = $documentToText->getDocumentType($storedFilename, $contentType);
/* If we're creating a file from text contents, we can skip
* extracting because we already know the text contents.
*/
if ($fileContents !== false && $documentType == DOCUMENT_TYPE_TEXT) {
$extractedText = $fileContents;
} else {
if ($fileContents !== false) {
/* If it's not text and we are creating a file from contents,
* don't try to extract text.
*/
$extractedText = '';
} else {
if (!$fileExists) {
/* Can't extract text from a file that doesn't exist. */
$extractedText = '';
} else {
$documentToText->convert($tempFilename, $documentType);
if ($documentToText->isError()) {
$this->_isTextExtractionError = true;
$this->_textExtractionError = $documentToText->getError();
$extractedText = '';
} else {
$extractedText = $documentToText->getString();
}
/* If we are adding a bulk resume, and parsing fails, consider it
* a fatal error.
*/
if ($dataItemType == DATA_ITEM_BULKRESUME && $this->_isTextExtractionError) {
$this->_isError = true;
$this->_error = $this->_textExtractionError;
return false;
}
}
}
}
}
$attachments = new Attachments($this->_siteID);
/* We can only check for duplicates right now if the file actually
* exists. We'll do it again later below.
*/
if ($fileExists && !$fileContents) {
/* We store file size in KB, rounded to nearest KB. */
$fileSize = round(@filesize($tempFilename) / 1024);
/* The md5sum is stored for duplicate checking. */
$md5sum = @md5_file($tempFilename);
/* Check for duplicates. */
$duplicates = $attachments->getMatching($dataItemType, $dataItemID, $fileSize, $md5sum, $extractedText);
/* Duplicate attachments are never added, but this is not a fatal
* error. We will set a property to notify the caller that a
* duplicate occurred.
*/
if (!empty($duplicates)) {
$this->_duplicatesOccurred = true;
if (file_exists($tempFilename)) {
unlink($tempFilename);
}
return false;
}
} else {
$fileSize = 0;
$md5sum = '';
}
//.........这里部分代码省略.........