當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Attachments::getMatching方法代碼示例

本文整理匯總了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 = '';
     }
//.........這裏部分代碼省略.........
開發者ID:Hassanj343,項目名稱:candidats,代碼行數:101,代碼來源:Attachments.php


注:本文中的Attachments::getMatching方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。