public function validate($source)
    {
        try {
            $this->assertSourceAsFile($source);

            if (! QtiPackage::isValidZip($source)) {
                throw new PortableElementParserException('Source package is not a valid zip.');
            }
        } catch (common_Exception $e) {
            throw new PortableElementParserException('A problem has occured during package parsing.', 0, $e);
        }

        $zip = new ZipArchive();
        $zip->open($source, ZIPARCHIVE::CHECKCONS);

        $definitionFiles = $this->getModel()->getDefinitionFiles();
        foreach ($definitionFiles as $file) {
            if ($zip->locateName($file) === false) {
                throw new PortableElementParserException(
                    'The portable element package "' .$this->getModel()->getId(). '" must contains a "' . $file . '" file at the root of the archive.'
                );
            }
        }

        $zip->close();

        $this->getModel()->createDataObject($this->getManifestContent($source));
        return true;
    }
public function validate($source)
    {
        try {
            $this->assertSourceAsFile($source);

            if (! QtiPackage::isValidZip($source)) {
                throw new PortableElementParserException('Source package is not a valid zip.');
            }
        } catch (common_Exception $e) {
            throw new PortableElementParserException('A problem has occured during package parsing.', 0, $e);
        }

        $zip = new ZipArchive();
        $zip->open($source, ZIPARCHIVE::CHECKCONS);

        $definitionFiles = $this->getModel()->getDefinitionFiles();
        foreach ($definitionFiles as $file) {
            if ($zip->locateName($file) === false) {
                throw new PortableElementParserException(
                    'The portable element package "' .$this->getModel()->getId(). '" must contains a "' . $file . '" file at the root of the archive.'
                );
            }
        }

        $zip->close();

        $this->getModel()->createDataObject($this->getManifestContent($source));
        return true;
    }
public function validate ( $ source ) { try { $ this -> assertSourceAsFile ( $ source ) ; if ( ! QtiPackage :: isValidZip ( $ source ) ) { throw new PortableElementParserException ( 'Source package is not a valid zip.' ) ; } } catch ( common_Exception $ e ) { throw new PortableElementParserException ( 'A problem has occured during package parsing.' , 0 , $ e ) ; } $ zip = new ZipArchive ( ) ; $ zip -> open ( $ source , ZIPARCHIVE :: CHECKCONS ) ; $ definitionFiles = $ this -> getModel ( ) -> getDefinitionFiles ( ) ; foreach ( $ definitionFiles as $ file ) { if ( $ zip -> locateName ( $ file ) === false ) { throw new PortableElementParserException ( 'The portable element package "' . $ this -> getModel ( ) -> getId ( ) . '" must contains a "' . $ file . '" file at the root of the archive.' ) ; } } $ zip -> close ( ) ; $ this -> getModel ( ) -> createDataObject ( $ this -> getManifestContent ( $ source ) ) ; return true ; }
Validate the zip package

@param string $source Zip package location to validate
@return bool
@throws PortableElementException
@throws PortableElementParserException
@throws PortableElementInconsistencyModelException
Validate the zip package