当前位置: 首页>>代码示例>>PHP>>正文


PHP Thumbnail::file_support_thumbnail方法代码示例

本文整理汇总了PHP中Thumbnail::file_support_thumbnail方法的典型用法代码示例。如果您正苦于以下问题:PHP Thumbnail::file_support_thumbnail方法的具体用法?PHP Thumbnail::file_support_thumbnail怎么用?PHP Thumbnail::file_support_thumbnail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Thumbnail的用法示例。


在下文中一共展示了Thumbnail::file_support_thumbnail方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createDocument

 /**
  * Create a new document and store its data.
  * This is a mix of new code and code moved from C_Document.class.php.
  *
  * @param  string  $patient_id   Patient pid; if not known then this may be a simple directory name
  * @param  integer $category_id  The desired document category ID
  * @param  string  $filename     Desired filename, may be modified for uniqueness
  * @param  string  $mimetype     MIME type
  * @param  string  &$data        The actual data to store (not encoded)
  * @param  string  $higher_level_path Optional subdirectory within the local document repository
  * @param  string  $path_depth   Number of directory levels in $higher_level_path, if specified
  * @param  integer $owner        Owner/user/service that is requesting this action
  * @param  string  $tmpfile      The tmp location of file (require for thumbnail generator)
  * @return string                Empty string if success, otherwise error message text
  */
 function createDocument($patient_id, $category_id, $filename, $mimetype, &$data, $higher_level_path = '', $path_depth = 1, $owner = 0, $tmpfile = null)
 {
     // The original code used the encounter ID but never set it to anything.
     // That was probably a mistake, but we reference it here for documentation
     // and leave it empty. Logically, documents are not tied to encounters.
     if ($GLOBALS['generate_doc_thumb']) {
         $thumb_size = $GLOBALS['thumb_doc_max_size'] > 0 ? $GLOBALS['thumb_doc_max_size'] : null;
         $thumbnail_class = new Thumbnail($thumb_size);
         if (!is_null($tmpfile)) {
             $has_thumbnail = $thumbnail_class->file_support_thumbnail($tmpfile);
         } else {
             $has_thumbnail = false;
         }
         if ($has_thumbnail) {
             $thumbnail_resource = $thumbnail_class->create_thumbnail(null, $data);
             if ($thumbnail_resource) {
                 $thumbnail_data = $thumbnail_class->get_string_file($thumbnail_resource);
             } else {
                 $has_thumbnail = false;
             }
         }
     } else {
         $has_thumbnail = false;
     }
     $encounter_id = '';
     $this->storagemethod = $GLOBALS['document_storage_method'];
     $this->mimetype = $mimetype;
     if ($this->storagemethod == 1) {
         // Store it using CouchDB.
         $couch = new CouchDB();
         $docname = $_SESSION['authId'] . $filename . $patient_id . $encounter_id . date("%Y-%m-%d H:i:s");
         $docid = $couch->stringToId($docname);
         $json = json_encode(base64_encode($data));
         if ($has_thumbnail) {
             $th_json = json_encode(base64_encode($thumbnail_data));
             $this->thumb_url = $this->get_thumb_name($filename);
         } else {
             $th_json = false;
         }
         $db = $GLOBALS['couchdb_dbase'];
         $couchdata = array($db, $docid, $patient_id, $encounter_id, $mimetype, $json, $th_json);
         $resp = $couch->check_saveDOC($couchdata);
         if (!$resp->id || !$resp->_rev) {
             // Not sure what this is supposed to do.  The references to id, rev,
             // _id and _rev seem pretty weird.
             $couchdata = array($db, $docid, $patient_id, $encounter_id);
             $resp = $couch->retrieve_doc($couchdata);
             $docid = $resp->_id;
             $revid = $resp->_rev;
         } else {
             $docid = $resp->id;
             $revid = $resp->rev;
         }
         if (!$docid && !$revid) {
             return xl('CouchDB save failed');
         }
         $this->url = $filename;
         $this->couch_docid = $docid;
         $this->couch_revid = $revid;
     } else {
         // Storing document files locally.
         $repository = $GLOBALS['oer_config']['documents']['repository'];
         $higher_level_path = preg_replace("/[^A-Za-z0-9\\/]/", "_", $higher_level_path);
         if (!empty($higher_level_path) && (is_numeric($patient_id) && $patient_id > 0)) {
             // Allow higher level directory structure in documents directory and a patient is mapped.
             $filepath = $repository . $higher_level_path . "/";
         } else {
             if (!empty($higher_level_path)) {
                 // Allow higher level directory structure in documents directory and there is no patient mapping
                 // (will create up to 10000 random directories and increment the path_depth by 1).
                 $filepath = $repository . $higher_level_path . '/' . rand(1, 10000) . '/';
                 ++$path_depth;
             } else {
                 if (!is_numeric($patient_id) || !($patient_id > 0)) {
                     // This is the default action except there is no patient mapping (when patient_id is 00 or direct)
                     // (will create up to 10000 random directories and set the path_depth to 2).
                     $filepath = $repository . $patient_id . '/' . rand(1, 10000) . '/';
                     $path_depth = 2;
                     $patient_id = 0;
                 } else {
                     // This is the default action where the patient is used as one level directory structure in documents directory.
                     $filepath = $repository . $patient_id . '/';
                     $path_depth = 1;
                 }
             }
//.........这里部分代码省略.........
开发者ID:juggernautsei,项目名称:openemr,代码行数:101,代码来源:Document.class.php


注:本文中的Thumbnail::file_support_thumbnail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。