Exemplo n.º 1
0
 /**
  *
  * Execute the command to extract an embedded object from a flash file
  *
  * @param string         $pathfile   the file
  * @param EmbeddedObject $embedded   The id of the object
  * @param string         $outputFile the path where to extract
  *
  * @return string|null The ouptut string, null on error
  *
  * @throws InvalidArgumentException
  * @throws RuntimeException
  */
 public function extract($pathfile, EmbeddedObject $embedded, $outputFile)
 {
     if (trim($outputFile) === '') {
         throw new InvalidArgumentException('Invalid output file');
     }
     try {
         return $this->command(array('-' . $embedded->getOption(), $embedded->getId(), $pathfile, '-o', $outputFile));
     } catch (ExecutionFailureException $e) {
         throw new RuntimeException(sprintf('%s failed to run command', $this->getName()), $e->getCode(), $e);
     }
 }
Exemplo n.º 2
0
 /**
  * List all embedded object of the current flash file
  *
  * @param  string           $inputFile
  * @return type
  * @throws RuntimeException
  */
 public function listEmbeddedObjects($inputFile)
 {
     $embedded = array();
     try {
         $datas = explode("\n", $this->container['swfextract']->listEmbedded($inputFile));
     } catch (ExecutableNotFoundException $e) {
         throw new RuntimeException('Unable to load swfextract', $e->getCode(), $e);
     }
     foreach ($datas as $line) {
         $matches = array();
         preg_match('/\\[-([a-z]{1})\\]\\ [0-9]+\\ ([a-z]+):\\ ID\\(s\\)\\ ([0-9-,\\ ]+)/i', $line, $matches);
         if (count($matches) === 0) {
             continue;
         }
         $option = $matches[1];
         $type = EmbeddedObject::detectType($matches[2]);
         if (!$type) {
             continue;
         }
         foreach (explode(",", $matches[3]) as $id) {
             if (false !== ($offset = strpos($id, '-'))) {
                 for ($i = substr($id, 0, $offset); $i <= substr($id, $offset + 1); $i++) {
                     $embedded[] = new EmbeddedObject($option, $matches[2], $i);
                 }
             } else {
                 $embedded[] = new EmbeddedObject($option, $type, $id);
             }
         }
     }
     return $embedded;
 }
Exemplo n.º 3
0
 /**
  * @covers SwfTools\EmbeddedObject::detectType
  */
 public function testDetectType()
 {
     $this->assertEquals(EmbeddedObject::TYPE_JPEG, EmbeddedObject::detectType('JPEGs'));
     $this->assertEquals(EmbeddedObject::TYPE_JPEG, EmbeddedObject::detectType('JPEG'));
     $this->assertEquals(EmbeddedObject::TYPE_PNG, EmbeddedObject::detectType('PNG'));
     $this->assertEquals(EmbeddedObject::TYPE_PNG, EmbeddedObject::detectType('PNGs'));
     $this->assertEquals(EmbeddedObject::TYPE_MOVIECLIP, EmbeddedObject::detectType('MovieClip'));
     $this->assertEquals(EmbeddedObject::TYPE_MOVIECLIP, EmbeddedObject::detectType('MovieClip'));
     $this->assertEquals(EmbeddedObject::TYPE_FRAME, EmbeddedObject::detectType('Frame'));
     $this->assertEquals(EmbeddedObject::TYPE_FRAME, EmbeddedObject::detectType('Frames'));
     $this->assertEquals(EmbeddedObject::TYPE_SOUND, EmbeddedObject::detectType('Sound'));
     $this->assertEquals(EmbeddedObject::TYPE_SOUND, EmbeddedObject::detectType('Sound'));
     $this->assertEquals(EmbeddedObject::TYPE_SHAPE, EmbeddedObject::detectType('Shape'));
     $this->assertEquals(EmbeddedObject::TYPE_SHAPE, EmbeddedObject::detectType('Shapes'));
     $this->assertNull(EmbeddedObject::detectType('Unknown'));
 }