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


PHP ProductDownload::engine方法代码示例

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


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

示例1: save


//.........这里部分代码省略.........
             $Price->save();
             // Save 'price' meta records after saving the price record
             if (isset($priceline['dimensions']) && is_array($priceline['dimensions'])) {
                 $priceline['dimensions'] = array_map(array('Shopp', 'floatval'), $priceline['dimensions']);
             }
             $settings = array('donation', 'recurring', 'membership', 'dimensions');
             $priceline['settings'] = array();
             foreach ($settings as $setting) {
                 if (!isset($priceline[$setting])) {
                     continue;
                 }
                 $priceline['settings'][$setting] = $priceline[$setting];
             }
             if (!empty($priceline['settings'])) {
                 shopp_set_meta($Price->id, 'price', 'settings', $priceline['settings']);
             }
             if (!empty($priceline['options'])) {
                 shopp_set_meta($Price->id, 'price', 'options', $priceline['options']);
             }
             $Product->sumprice($Price);
             if (!empty($priceline['download'])) {
                 $Price->attach_download($priceline['download']);
             }
             if (!empty($priceline['downloadpath'])) {
                 // Attach file specified by URI/path
                 if (!empty($Price->download->id) || empty($Price->download) && $Price->load_download()) {
                     $File = $Price->download;
                 } else {
                     $File = new ProductDownload();
                 }
                 $stored = false;
                 $tmpfile = sanitize_path($priceline['downloadpath']);
                 $File->storage = false;
                 $Engine = $File->engine();
                 // Set engine from storage settings
                 $File->parent = $Price->id;
                 $File->context = "price";
                 $File->type = "download";
                 $File->name = !empty($priceline['downloadfile']) ? $priceline['downloadfile'] : basename($tmpfile);
                 $File->filename = $File->name;
                 if ($File->found($tmpfile)) {
                     $File->uri = $tmpfile;
                     $stored = true;
                 } else {
                     $stored = $File->store($tmpfile, 'file');
                 }
                 if ($stored) {
                     $File->readmeta();
                     $File->save();
                 }
             }
             // END attach file by path/uri
         }
         // END foreach()
         unset($Price);
     }
     // END if (!empty($_POST['price']))
     $Product->load_sold($Product->id);
     // Refresh accurate product sales stats
     $Product->sumup();
     // Update taxonomies after pricing summary is generated
     // Summary table entry is needed for ProductTaxonomy::recount() to
     // count properly based on aggregate product inventory, see #2968
     foreach (get_object_taxonomies(Product::$posttype) as $taxonomy) {
         $tags = '';
         $taxonomy_obj = get_taxonomy($taxonomy);
开发者ID:forthrobot,项目名称:inuvik,代码行数:67,代码来源:Warehouse.php

示例2: import_file

 public function import_file()
 {
     check_admin_referer('wp_ajax_shopp_import_file');
     $Shopp = Shopp::object();
     $Engine =& $Shopp->Storage->engines['download'];
     $error = create_function('$s', 'die(json_encode(array("error" => $s)));');
     if (empty($_REQUEST['url'])) {
         $error(__('No file import URL was provided.', 'Shopp'));
     }
     $url = $_REQUEST['url'];
     $request = parse_url($url);
     $headers = array();
     $filename = basename($request['path']);
     $_ = new StdClass();
     $_->name = $filename;
     $_->stored = false;
     $File = new ProductDownload();
     $stored = false;
     $File->engine();
     // Set engine from storage settings
     $File->uri = sanitize_path($url);
     $File->type = "download";
     $File->name = $filename;
     $File->filename = $filename;
     if ($File->found()) {
         // File in storage, look up meta from storage engine
         $File->readmeta();
         $_->stored = true;
         $_->path = $File->uri;
         $_->size = $File->size;
         $_->mime = $File->mime;
         if ($_->mime == "application/octet-stream" || $_->mime == "text/plain") {
             $mime = file_mimetype($File->name);
         }
         if ($mime == "application/octet-stream" || $mime == "text/plain") {
             $_->mime = $mime;
         }
     } else {
         if (!($importfile = @tempnam(sanitize_path(realpath(SHOPP_TEMP_PATH)), 'shp'))) {
             $error(sprintf(__('A temporary file could not be created for importing the file.', 'Shopp'), $importfile));
         }
         if (!($incoming = @fopen($importfile, 'w'))) {
             $error(sprintf(__('A temporary file at %s could not be opened for importing.', 'Shopp'), $importfile));
         }
         if (!($file = @fopen(linkencode($url), 'rb'))) {
             $error(sprintf(__('The file at %s could not be opened for importing.', 'Shopp'), $url));
         }
         $data = @stream_get_meta_data($file);
         if (isset($data['timed_out']) && $data['timed_out']) {
             $error(__('The connection timed out while trying to get information about the target file.', 'Shopp'));
         }
         if (isset($data['wrapper_data'])) {
             foreach ($data['wrapper_data'] as $d) {
                 if (strpos($d, ':') === false) {
                     continue;
                 }
                 list($name, $value) = explode(': ', $d);
                 if ($rel = strpos($value, ';')) {
                     $headers[$name] = substr($value, 0, $rel);
                 } else {
                     $headers[$name] = $value;
                 }
             }
         }
         $tmp = basename($importfile);
         // $Settings =& ShoppSettings();
         $_->path = $importfile;
         if (empty($headers)) {
             // Stat file data directly if no stream data available
             $_->size = filesize($url);
             $_->mime = file_mimetype($url);
         } else {
             // Use the stream data
             $_->size = $headers['Content-Length'];
             $_->mime = $headers['Content-Type'] == 'text/plain' ? file_mimetype($_->name) : $headers['Content-Type'];
         }
     }
     // Mimetype must be set or we'll have problems in the UI
     if (!$_->mime) {
         $_->mime = "application/octet-stream";
     }
     echo str_repeat(' ', 1024);
     // Minimum browser data
     echo '<script type="text/javascript">var importFile = ' . json_encode($_) . ';</script>' . "\n";
     echo '<script type="text/javascript">var importProgress = 0;</script>' . "\n";
     if ($_->stored) {
         exit;
     }
     @ob_flush();
     @flush();
     $progress = 0;
     $bytesread = 0;
     fseek($file, 0);
     $packet = 1024 * 1024;
     set_time_limit(0);
     // Prevent timeouts
     while (!feof($file)) {
         if (connection_status() !== 0) {
             return false;
         }
//.........这里部分代码省略.........
开发者ID:msigley,项目名称:shopp,代码行数:101,代码来源:Ajax.php


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