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


PHP FileManager::getHash方法代碼示例

本文整理匯總了PHP中Includes\Utils\FileManager::getHash方法的典型用法代碼示例。如果您正苦於以下問題:PHP FileManager::getHash方法的具體用法?PHP FileManager::getHash怎麽用?PHP FileManager::getHash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Includes\Utils\FileManager的用法示例。


在下文中一共展示了FileManager::getHash方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: importImages

 /**
  * Import images
  *
  * @param \XLite\Model\Product $product Product
  * @param string               $data    Data
  *
  * @return void
  */
 protected function importImages(\XLite\Model\Product $product, $data)
 {
     // Save old images ids' list
     $oldImageIds = array();
     foreach ($product->getImages() as $image) {
         $oldImageIds[] = $image->getId();
     }
     if ($data) {
         // Load images
         foreach (explode(';', $data) as $url) {
             $url = trim($url);
             $hash = \Includes\Utils\FileManager::getHash($url);
             $image = null;
             if ($hash) {
                 foreach ($product->getImages() as $i) {
                     if ($i->getHash() == $hash) {
                         $image = $i;
                         $key = array_search($i->getId(), $oldImageIds);
                         unset($oldImageIds[$key]);
                         break;
                     }
                 }
             }
             if (!$image) {
                 $image = new \XLite\Model\Image\Product\Image();
                 $image->setProduct($product);
                 $result = preg_match('/^(https?|ftp):\\/\\//Ss', $url) ? $image->loadFromURL($url) : $image->loadFromLocalFile($url);
                 if ($result) {
                     $product->addImages($image);
                     \XLite\Core\Database::getEM()->persist($image);
                 } else {
                     $this->logImportWarning(static::t('X image unable to load', array('url' => $url)), $this->importCell['position'], 'images', $url, $product);
                 }
             }
         }
     }
     // Remove old images
     foreach ($product->getImages() as $image) {
         if (in_array($image->getId(), $oldImageIds)) {
             $product->getImages()->removeElement($image);
             \XLite\Core\Database::getEM()->remove($image);
         }
     }
 }
開發者ID:kingsj,項目名稱:core,代碼行數:52,代碼來源:ImportExport.php

示例2: loadHashesForInstalledFiles

 /**
  * Calculate hashes for current version
  *
  * @return array
  */
 protected function loadHashesForInstalledFiles()
 {
     $result = array();
     $module = $this->getModuleInstalled();
     if ($module) {
         $pack = new \XLite\Core\Pack\Module($module);
         foreach ($pack->getDirectoryIterator() as $file) {
             if ($file->isFile()) {
                 $relativePath = \Includes\Utils\FileManager::getRelativePath($file->getPathname(), LC_DIR_ROOT);
                 if ($relativePath) {
                     $result[$relativePath] = \Includes\Utils\FileManager::getHash($file->getPathname(), true);
                 }
             }
         }
     }
     return $result ?: $this->getHashes(true);
 }
開發者ID:kingsj,項目名稱:core,代碼行數:22,代碼來源:Uploaded.php

示例3: addPackHash

 /**
  * Create list of archive file hashes and add it to the pack
  *
  * @param \PharData $phar     PHAR archive
  * @param \Iterator $iterator Directory iterator
  *
  * @return void
  */
 protected static function addPackHash(\PharData $phar, \Iterator $iterator)
 {
     $data = array();
     foreach ($iterator as $filePath => $fileInfo) {
         $data[\Includes\Utils\FileManager::getRelativePath($filePath, LC_DIR_ROOT)] = \Includes\Utils\FileManager::getHash($filePath);
     }
     $phar->addFromString('.hash', json_encode($data));
 }
開發者ID:kingsj,項目名稱:core,代碼行數:16,代碼來源:PHARManager.php

示例4: renewByPath

 /**
  * Renew properties by path
  *
  * @param string $path Path
  *
  * @return boolean
  */
 protected function renewByPath($path)
 {
     $result = parent::renewByPath($path);
     if ($result) {
         $data = @getimagesize($path);
         if (is_array($data)) {
             $this->setWidth($data[0]);
             $this->setHeight($data[1]);
             $this->setMime($data['mime']);
             $hash = \Includes\Utils\FileManager::getHash($path);
             if ($hash) {
                 $this->setHash($hash);
             }
         } else {
             $result = false;
         }
     }
     return $result;
 }
開發者ID:kewaunited,項目名稱:xcart,代碼行數:26,代碼來源:Image.php

示例5: detectImage

 /**
  * Detect image 
  * 
  * @param \XLite\Model\Product $product Product
  * @param array                $image   Image info
  *  
  * @return \XLite\Model\Image\Product\Image
  */
 protected function detectImage(\XLite\Model\Product $product, array $image)
 {
     $hash = \Includes\Utils\FileManager::getHash($image['url']);
     $model = null;
     if ($hash) {
         foreach ($product->getImages() as $oldImage) {
             if ($oldImage->getHash() == $hash) {
                 $model = $oldImage;
                 break;
             }
         }
     }
     return $model;
 }
開發者ID:kirkbauer2,項目名稱:kirkxc,代碼行數:22,代碼來源:Product.php


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