Ejemplo n.º 1
0
 public function run()
 {
     trigger('imerge_start', $this);
     mark('开始自动合图扫描', 'emphasize');
     $files = get_files_by_type(C('SRC.SRC_PATH'), 'css');
     $generator = new MergeConfigGenerator($files);
     $generator->generate();
     $writer = new MergeConfigWriter(C('IMERGE_PATH'));
     $writer->writeImageConfig($generator->getConfig());
     // 更新大图
     $this->updateSprite();
     trigger('imerge_end', $this);
 }
Ejemplo n.º 2
0
 /**
  * 添加一张小图配置
  * @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;
     }
 }