/**
  * 根据类型和小图路径,得到某一张小图的配置
  * @param $type
  * @param $image
  */
 public function getSingleImageConfig($type, $image)
 {
     $ret = null;
     $path = $this->root . '/' . C('IMERGE_IMAGE_DIR') . '/' . $type;
     $filename = file_uid($image);
     $autoPath = $path . '/' . $filename . '.php';
     $customPath = $path . '/_' . $filename . '.php';
     if (file_exists($customPath)) {
         $config = (include $customPath);
         $ret = $config[$image];
     } elseif (file_exists($autoPath)) {
         $config = (include $autoPath);
         $ret = $config[$image];
     }
     return $ret;
 }
 /**
  * 写入缓存
  * @param $path
  * @param $contents
  */
 private static function updateCache($path, $contents)
 {
     $file = self::$cacheDir . '/' . file_uid($path);
     contents_to_file($file, $contents);
     self::$cacheMap[$path] = $file;
 }
Exemple #3
0
 public function getFileUid()
 {
     if (!$this->fileUid) {
         $this->fileUid = file_uid($this->contents, $this->type);
     }
     return $this->fileUid;
 }
 /**
  * 添加一张小图配置
  * @param $type
  * @param $image
  * @param null $config
  * @return bool
  */
 public function addSingleImageConfig($type, $image, $config = null)
 {
     $path = $this->root . '/' . C('IMERGE_IMAGE_DIR') . '/' . $type;
     $filename = file_uid($image);
     $oldFile = $path . '/' . $filename . '.php';
     $newFile = $path . '/_' . $filename . '.php';
     if (file_exists($oldFile) || file_exists($newFile)) {
         // 小图已存在
         return false;
     } else {
         if (is_null($config)) {
             $config = MergeConfigGenerator::getDefaultConfig();
         }
         contents_to_file($newFile, self::configStringify($config, $image));
         return true;
     }
 }