classes/helper/AbstractImportModel.php
protected function importPreviewImage()
    {
        if (!$this->bNeedUpdatePreviewImage) {
            return;
        }

        $obPreviewImage = $this->obModel->preview_image;
        if (empty($obPreviewImage) && empty($this->sPreviewImage)) {
            return;
        }

        if (empty($obPreviewImage) && !empty($this->sPreviewImage)) {
            //Create new preview
            $obPreviewImage = new File();
            $obPreviewImage->fromFile($this->sPreviewImage);
            $this->obModel->preview_image()->add($obPreviewImage);

            return;
        }

        if (!file_exists($obPreviewImage->getLocalPath())) {
            $obPreviewImage->fromFile($this->sPreviewImage);
            $obPreviewImage->save();
        } elseif (!empty($this->sPreviewImage) && file_exists($obPreviewImage->getLocalPath()) && md5_file($this->sPreviewImage) != md5_file($obPreviewImage->getLocalPath())) {
            //Update preview image
            $obPreviewImage->deleteThumbs();
            $obPreviewImage->fromFile($this->sPreviewImage);
            $obPreviewImage->save();
        } elseif (!empty($obPreviewImage) && empty($this->sPreviewImage)) {
            $obPreviewImage->deleteThumbs();
            $obPreviewImage->delete();
        }
    }
protected function importPreviewImage()
    {
        if (!$this->bNeedUpdatePreviewImage) {
            return;
        }

        $obPreviewImage = $this->obModel->preview_image;
        if (empty($obPreviewImage) && empty($this->sPreviewImage)) {
            return;
        }

        if (empty($obPreviewImage) && !empty($this->sPreviewImage)) {
            //Create new preview
            $obPreviewImage = new File();
            $obPreviewImage->fromFile($this->sPreviewImage);
            $this->obModel->preview_image()->add($obPreviewImage);

            return;
        }

        if (!file_exists($obPreviewImage->getLocalPath())) {
            $obPreviewImage->fromFile($this->sPreviewImage);
            $obPreviewImage->save();
        } elseif (!empty($this->sPreviewImage) && file_exists($obPreviewImage->getLocalPath()) && md5_file($this->sPreviewImage) != md5_file($obPreviewImage->getLocalPath())) {
            //Update preview image
            $obPreviewImage->deleteThumbs();
            $obPreviewImage->fromFile($this->sPreviewImage);
            $obPreviewImage->save();
        } elseif (!empty($obPreviewImage) && empty($this->sPreviewImage)) {
            $obPreviewImage->deleteThumbs();
            $obPreviewImage->delete();
        }
    }
protected function importPreviewImage ( ) { if ( ! $ this -> bNeedUpdatePreviewImage ) { return ; } $ obPreviewImage = $ this -> obModel -> preview_image ; if ( empty ( $ obPreviewImage ) && empty ( $ this -> sPreviewImage ) ) { return ; } if ( empty ( $ obPreviewImage ) && ! empty ( $ this -> sPreviewImage ) ) { //Create new preview $ obPreviewImage = new File ( ) ; $ obPreviewImage -> fromFile ( $ this -> sPreviewImage ) ; $ this -> obModel -> preview_image ( ) -> add ( $ obPreviewImage ) ; return ; } if ( ! file_exists ( $ obPreviewImage -> getLocalPath ( ) ) ) { $ obPreviewImage -> fromFile ( $ this -> sPreviewImage ) ; $ obPreviewImage -> save ( ) ; } elseif ( ! empty ( $ this -> sPreviewImage ) && file_exists ( $ obPreviewImage -> getLocalPath ( ) ) && md5_file ( $ this -> sPreviewImage ) != md5_file ( $ obPreviewImage -> getLocalPath ( ) ) ) { //Update preview image $ obPreviewImage -> deleteThumbs ( ) ; $ obPreviewImage -> fromFile ( $ this -> sPreviewImage ) ; $ obPreviewImage -> save ( ) ; } elseif ( ! empty ( $ obPreviewImage ) && empty ( $ this -> sPreviewImage ) ) { $ obPreviewImage -> deleteThumbs ( ) ; $ obPreviewImage -> delete ( ) ; } }
Import preview image
Import preview image