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


PHP File::copy方法代码示例

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


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

示例1: makeOfferIn

 function makeOfferIn($basket, $universe, $peopleId, $companyId, $companyaddress_id, $delivery = [], $geo = [])
 {
     $collection = $collectionPush = [];
     $company = Model::Company()->find($companyId);
     $people = Model::People()->find($peopleId);
     if ($company && $people) {
         $companyStatus = isAke($company->assoc(), 'status_id', getStatus('UNCHECKED'));
         $offers = [];
         if (!empty($basket)) {
             $i = 0;
             foreach ($basket as $article) {
                 $dir = realpath(APPLICATION_PATH . DS . '..' . DS . 'public' . DS . 'files' . DS . $universe . DS . 'users' . DS . $peopleId . DS . 'tmp_basket' . DS . $i);
                 if ($dir) {
                     $files = glob($dir . DS . '*');
                     if (!empty($files)) {
                         foreach ($files as $file) {
                             $article['attach'][] = $file;
                         }
                     }
                 }
                 $market = 0;
                 $item_id = isake($article, 'item_id', 0);
                 if (0 >= $item_id) {
                     $market = isAke($article, 'market', 0);
                 } else {
                     $family = repo('segment')->getFamilyfromItem($item_id);
                     if (!empty($family)) {
                         $market = current($family);
                         $market = isAke($market, 'id', 0);
                     }
                 }
                 if (0 < $market) {
                     unset($article['family']);
                     $offers[$market][] = $article;
                 }
                 $i++;
             }
         }
         if (!empty($offers)) {
             foreach ($offers as $idMarket => $articles) {
                 $statusOffer = $companyStatus == getStatus('UNCHECKED') ? getStatus('WAIT') : getStatus('OK');
                 $offer = bigDb('offerin')->create(['global' => true, 'companyaddress_id' => $companyaddress_id, 'delivery_date' => isAke($delivery, 'date', null), 'delivery_type' => isAke($delivery, 'type', null), 'delivery_moment' => isAke($delivery, 'moment', null), 'expiration' => strtotime('+1 month'), 'universe' => $universe, 'market' => (int) $idMarket, 'status_id' => (int) $statusOffer, 'date' => time(), 'zip' => $company->zip, 'people_id' => (int) $peopleId, 'company_id' => $companyId])->save();
                 foreach ($geo as $g) {
                     bigDb('offeringeo')->create(['offerin_id' => $offer->id, 'type' => isAke($g, 'type'), isAke($g, 'type') . '_id' => isAke($g, 'id'), 'range' => isAke($g, 'range')])->save();
                 }
                 foreach ($articles as $art) {
                     $options_comp_name = isAke($art, 'options_comp_name');
                     $options_comp_val = isAke($art, 'options_comp_val');
                     $item_id = isAke($article, 'item_id', 0);
                     if (0 == $item_id) {
                         $statusOffer = (int) getStatus('ADV');
                         $offer = $offer->setStatusId($statusOffer)->save();
                     }
                     if (!empty($options_comp_name) && !empty($options_comp_val)) {
                         /* On cherche les doublons d'option le cas échéant */
                         list($options_comp_name, $options_comp_val) = cleanOptCompOfferIn($options_comp_name, $options_comp_val);
                         $art['options_comp_name'] = $options_comp_name;
                         $art['options_comp_val'] = $options_comp_val;
                     }
                     $attach = isAke($art, 'attach', []);
                     unset($art['attach']);
                     $art['offerin_id'] = $offer->id;
                     $a = bigDb('articlein')->create($art)->save();
                     if (!empty($attach)) {
                         $dirOffer = APPLICATION_PATH . DS . '..' . DS . 'public' . DS . 'files' . DS . $universe . DS . 'offer_in';
                         if (!is_dir($dirOffer)) {
                             File::mkdir($dirOffer);
                         }
                         $dirOffer .= DS . $offer->id;
                         if (!is_dir($dirOffer)) {
                             File::mkdir($dirOffer);
                         }
                         $dirOffer .= DS . $a->id;
                         if (!is_dir($dirOffer)) {
                             File::mkdir($dirOffer);
                         }
                         foreach ($attach as $f) {
                             $tab = explode(DS, $f);
                             $nameAttach = Arrays::last($tab);
                             $newFile = $dirOffer . DS . $nameAttach;
                             File::copy($f, $newFile);
                             File::delete($f);
                         }
                     }
                 }
                 array_push($collection, $offer->assoc());
                 if ($statusOffer == getStatus('OK')) {
                     array_push($collectionPush, $offer->assoc());
                 }
             }
         }
     }
     if (!empty($collectionPush)) {
         $resellers = lib('bourse')->getResellersByOffer($collectionPush);
         $employees = lib('bourse')->getEmployeesToNotif($resellers, $collectionPush);
         lib('bourse')->push($employees);
     }
     return $collection;
 }
开发者ID:schpill,项目名称:standalone,代码行数:99,代码来源:functions.php


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