Exemplo n.º 1
0
 /**
  * Callback for output handling.
  *
  * @param string|array $buffer
  * @param int          $flags
  * @return string|array
  */
 public function callback($buffer, $flags)
 {
     $marker = $this->opt & Output::IGNORE_MARKERS || is_array($buffer) ? null : Output::curMarker();
     // Directly flush the output
     if (!isset($marker)) {
         return $this->transform->process($buffer);
     }
     // Keep caching the output of flush
     $this->data[$marker] = $this->data;
     return $flags & PHP_OUTPUT_HANDLER_END ? $this->transform->process($this->data) : null;
 }
Exemplo n.º 2
0
 /**
  * 返回数据到客户端
  * @access protected
  * @param mixed $data 要返回的数据
  * @param String $type 返回数据格式
  * @param bool $exit 是否终止执行
  * @return void
  */
 public static function returnData($data, $type = '', $exit = true)
 {
     $headers = ['json' => 'application/json', 'xml' => 'text/xml', 'html' => 'text/html', 'jsonp' => 'application/javascript', 'script' => 'application/javascript', 'text' => 'text/plain'];
     $type = strtolower($type);
     if (isset($headers[$type])) {
         header('Content-Type:' . $headers[$type] . '; charset=utf-8');
     }
     switch ($type) {
         case 'json':
             // 返回JSON数据格式到客户端 包含状态信息
             $data = json_encode($data, JSON_UNESCAPED_UNICODE);
             break;
         case 'xml':
             // 返回xml格式数据
             $data = \org\Transform::xmlEncode($data);
             break;
         case 'jsonp':
             // 返回JSON数据格式到客户端 包含状态信息
             $handler = isset($_GET[Config::get('var_jsonp_handler')]) ? $_GET[Config::get('var_jsonp_handler')] : Config::get('default_jsonp_handler');
             $data = $handler . '(' . Transform::jsonEncode($data) . ');';
             break;
     }
     if ($exit) {
         exit($data);
     } else {
         echo $data;
     }
 }
Exemplo n.º 3
0
Arquivo: FOP.php Projeto: jasny/Q
 /**
  * Class constructor
  * 
  * @param array $options
  */
 public function __construct($options = array())
 {
     if (!isset($options['file']) && isset($options[0])) {
         $options['file'] = $options[0];
     }
     parent::__construct($options);
 }
Exemplo n.º 4
0
Arquivo: Yaml.php Projeto: jasny/Q
 /**
  * Load a config file or dir (no caching)
  * 
  * @param Fs_Item $file_object
  * @param string $group
  * @return array
  */
 protected function loadFile($file_object, $group = null)
 {
     if ($file_object instanceof Fs_File) {
         return Transform::with('unserialize-yaml')->process($file_object->path());
     } elseif ($file_object instanceof Fs_Dir) {
         return $this->loadDir($file_object);
     }
     return array();
 }
Exemplo n.º 5
0
Arquivo: Ini.php Projeto: jasny/Q
 /**
  * Load a config file or dir
  *
  * @param Fs_Item $file_object
  * @param string $group
  * @return array
  */
 protected function loadFile($file_object, $group = null)
 {
     if ($file_object instanceof Fs_File) {
         return Transform::with('unserialize-ini')->process($file_object->path());
     } elseif (!empty($this->_options['recursive']) && $file_object instanceof Fs_Dir) {
         return $this->loadDir($file_object);
     }
     return array();
 }
Exemplo n.º 6
0
Arquivo: PHP.php Projeto: jasny/Q
 /**
  * Class constructor
  * 
  * @param array $options Specific options: array('file'=>file_path) or array(file_path)
  */
 public function __construct($options = array())
 {
     if (isset($options[0])) {
         $options['file'] = Fs::file($options[0]);
     } elseif (isset($options['file']) && !$options['file'] instanceof Fs_Node) {
         $options['file'] = Fs::file($options['file']);
     }
     parent::__construct($options);
 }
Exemplo n.º 7
0
Arquivo: Replace.php Projeto: jasny/Q
 /**
  * Class constructor
  * 
  * @param array $options
  */
 public function __construct($options = array())
 {
     if (isset($options[0])) {
         $options['template'] = Fs::file($options[0]);
     } elseif (isset($options['file'])) {
         $options['template'] = Fs::file($options['file']);
     }
     unset($options[0], $options['file']);
     parent::__construct($options);
 }
Exemplo n.º 8
0
 /**
  * Constructs the class with given parameters and reads box related data from
  * the ISO Base Media file.
  *
  * @param Reader $reader The reader object.
  */
 public function __construct($reader, &$options = array())
 {
   parent::__construct($reader, $options);
   
   $entryCount = $this->_reader->readUInt32BE();
   $data = $this->_reader->read
     ($this->getOffset() + $this->getSize() - $this->_reader->getOffset());
   for ($i = 1; $i <= $entryCount; $i++)
     $this->_syncSampleTable[$i] =
       Transform::fromUInt32BE(substr($data, ($i - 1) * 4, 4));
 }
Exemplo n.º 9
0
 /**
  * Constructs the class with given parameters and parses object related
  * data.
  *
  * @param Zend_Io_Reader $reader The reader object.
  * @param Array $options The options array.
  */
 public function __construct($reader = null, &$options = array())
 {
     parent::__construct($reader, $options);
     if ($this->_reader === null) {
         throw new Zend_Media_Id3_Exception('Write not supported yet');
     }
     $this->_frames = Transform::fromInt16BE(substr($this->_data, 0, 2));
     $this->_bytes = Transform::fromInt32BE(substr($this->_data, 2, 3));
     $this->_milliseconds = Transform::fromInt32BE(substr($this->_data, 5, 3));
     $byteDevBits = Transform::fromInt8($this->_data[8]);
     $millisDevBits = Transform::fromInt8($this->_data[9]);
     // $data = substr($this->_data, 10);
 }
Exemplo n.º 10
0
Arquivo: Json.php Projeto: jasny/Q
 /**
  * Load a config file or dir (no caching)
  *
  * @param Fs_Item $file_object
  * @param string $group
  * @return array
  */
 protected function loadFile($file_object, $group = null)
 {
     $settings = array();
     if ($file_object instanceof Fs_File) {
         $settings = Transform::with('unserialize-json')->process($file_object->path());
         if (!isset($settings)) {
             trigger_error("Failed to parse json file '{$file}'.", E_USER_WARNING);
         }
     } elseif (!empty($this->_options['recursive']) && $file_object instanceof Fs_Dir) {
         $settings = $this->loadDir($file_object);
     }
     return $settings;
 }
Exemplo n.º 11
0
 /**
  * Constructs the class with given parameters and reads box related data from
  * the ISO Base Media file.
  *
  * @param Reader $reader The reader object.
  */
 public function __construct($reader, &$options = array())
 {
   parent::__construct($reader, $options);
   
   $entryCount = $this->_reader->readUInt32BE();
   $data = $this->_reader->read
     ($this->getOffset() + $this->getSize() - $this->_reader->getOffset());
   for ($i = 1; $i <= $entryCount; $i++)
     $this->_compositionOffsetTable[$i] = array
       ("sampleCount" =>
          Transform::fromUInt32BE(substr($data, ($i - 1) * 8, 4)),
        "sampleOffset" =>
          Transform::fromUInt32BE(substr($data, $i * 8 - 4, 4)));
 }
Exemplo n.º 12
0
 /**
  * Constructs the class with given parameters and reads box related data from
  * the ISO Base Media file.
  *
  * @param Reader $reader The reader object.
  */
 public function __construct($reader, &$options = array())
 {
   parent::__construct($reader, $options);
   
   $entryCount = $this->_reader->readUInt32BE();
   $data = $this->_reader->read
     ($this->getOffset() + $this->getSize() - $this->_reader->getOffset());
   for ($i = 1; $i <= $entryCount; $i++)
     $this->_sampleToChunkTable[$i] = array
       ("firstChunk" =>
          Transform::fromUInt32BE(substr($data, ($i - 1) * 12, 4)),
        "samplesPerChunk" =>
          Transform::fromUInt32BE(substr($data, $i * 12 - 8, 4)),
        "sampleDescriptionIndex" =>
          Transform::fromUInt32BE(substr($data, $i * 12 - 4, 4)));
 }
Exemplo n.º 13
0
Arquivo: Dir.php Projeto: jasny/Q
 /**
  * Class constructor
  * 
  * @param array $options
  */
 public function __construct($path, $options = array())
 {
     if (is_array($path)) {
         $options = $path + $options;
         $path = null;
         if (isset($options['driver'])) {
             if (isset($options[0])) {
                 if (!isset($options['path'])) {
                     $options['path'] = $options[0];
                 }
                 if (!isset($options['ext'])) {
                     $options['ext'] = $options['driver'];
                 }
                 unset($options[0]);
             } else {
                 $options[0] = $options['driver'];
             }
         }
     }
     if (isset($options[0])) {
         if (strpos($options[0], ':') !== false) {
             list($options['ext'], $options['path']) = explode(':', $options[0], 2);
         } else {
             $key = !isset($options['ext']) && strpos($options[0], '.') === false && strpos($options[0], '/') === false ? 'ext' : 'path';
             if (!isset($options[$key])) {
                 $options[$key] = $options[0];
             }
         }
     }
     $this->_path = isset($path) ? Fs::dir($path) : (isset($options['path']) ? Fs::dir($options['path']) : null);
     if (isset($options['transformer'])) {
         $this->_transformer = $options['transformer'] instanceof Transformer ? $options['transformer'] : Transform::with($options['transformer']);
     }
     $this->_ext = isset($options['ext']) ? $options['ext'] : (isset($this->_transformer) ? $this->_transformer->ext : null);
     if (!isset($this->_transformer) && !empty($this->_ext)) {
         $this->_transformer = Transform::from($this->_ext);
     }
     \ArrayObject::__construct(array(), \ArrayObject::ARRAY_AS_PROPS);
     if (!empty($options['loadall'])) {
         $this->loadAll();
     }
 }
Exemplo n.º 14
0
 /**
  * Constructs the class with given parameters and parses object related data.
  *
  * @param Reader $reader The reader object.
  * @param Array $options The options array.
  */
 public function __construct($reader = null, &$options = array())
 {
     parent::__construct($reader, $options);
     if ($reader === null) {
         throw new ID3_Exception("Write not supported yet");
     }
     $this->_dataStart = Transform::fromInt32BE(substr($this->_data, 0, 4));
     $this->_dataLength = Transform::fromInt32BE(substr($this->_data, 4, 4));
     $this->_size = Transform::fromInt16BE(substr($this->_data, 8, 2));
     $bitsPerPoint = Transform::fromInt8($this->_data[10]);
     /*for ($i = 0, $offset = 11; $i < $this->_size; $i++) {
         if ($bitsPerPoint == 16) {
           $this->_fractions[$i] = substr($this->_data, $offset, 2);
           $offset += 2;
         } else {
           $this->_fractions[$i] = substr($this->_data, $offset, 1);
           $offset ++;
         }
       }*/
 }
Exemplo n.º 15
0
  /**
   * Writes the changes back to the original media file.
   *
   * Please note: currently the method writes only ID32 and ILST boxes to
   * <i>moov.udta.meta</i>. Changes to any other box are discarded. Write
   * operation will overwrite <i>moov.udta</i>, if found.
   */
  public function write()
  {
    if (!isset($this->moov->udta->meta->ilst) &&
        !isset($this->moov->udta->meta->id32))
      throw new ISO14496_Exception("Nothing to write");

    if ($this->getOption("readonly", false) !== false)
      throw new ISO14496_Exception("File is read only");
    
    if (($fd = fopen($this->_filename, file_exists
                     ($this->_filename) ? "r+b" : "wb")) === false)
      throw new ISO14496_Exception
        ("Unable to open file for writing: " . $filename);
    
    $this->moov->udta->meta->hdlr->setHandlerType("mdir");
    
    /* Calculate start position */
    $mark = ($this->moov->udta->getOffset() > 0 ?
             $this->moov->udta->getOffset() :
             $this->moov->getOffset() + $this->moov->getSize());
    
    /* Calculate file size */
    fseek($fd, 0, SEEK_END);
    $oldFileSize = ftell($fd);
    $newFileSize = $oldFileSize -
      ($this->moov->udta->getOffset() > 0 ? $this->moov->udta->getSize() : 0) -
      (isset($this->moov->udta->meta->free) ?
       $this->moov->udta->meta->free->getSize() : 0) +
      strlen($this->moov->udta);

    /* Calculate free space size */
    if ($oldFileSize < $newFileSize) {
      // Add free space to the file calculated using the following logaritmic
      // equation: log(0.2(x + 10)), ranging from 1k to 9k given the file size
      // of 0..4G
      $this->moov->udta->meta->free->setSize
        (ceil(log(0.2 * ($newFileSize / 1024 + 10), 10) * 1024));
      ftruncate($fd, $newFileSize += $this->moov->udta->meta->free->getSize());
      
      // Move data to the end of the file
      for ($i = 1, $cur = $oldFileSize; $cur > $mark; $cur -= 1024, $i++) {
        fseek($fd, -(($i * 1024) +
              ($excess = $cur - 1024 > $mark ? 0 : $cur - $mark - 1024) +
              ($newFileSize - $oldFileSize)), SEEK_END);
        $buffer = fread($fd, 1024);
        fseek($fd, -(($i * 1024) + $excess), SEEK_END);
        fwrite($fd, $buffer, 1024);
      }
      
      // Update stco/co64 to correspond the data move
      foreach ($this->moov->getBoxesByIdentifier("trak") as $trak) {
        $chunkOffsetBox = 
          (isset($trak->mdia->minf->stbl->stco) ?
           $trak->mdia->minf->stbl->stco : $trak->mdia->minf->stbl->co64);
        $chunkOffsetTable = $chunkOffsetBox->getChunkOffsetTable();
        $chunkOffsetTableCount = count($chunkOffsetTable);
        $chunkOffsetDelta = $newFileSize - $oldFileSize;
        for ($i = 1; $i <= $chunkOffsetTableCount; $i++)
          $chunkOffsetTable[$i] += $chunkOffsetDelta;
        $chunkOffsetBox->setChunkOffsetTable($chunkOffsetTable);
        fseek($fd, $chunkOffsetBox->getOffset());
        fwrite($fd, $chunkOffsetBox, $chunkOffsetBox->getSize());
      }
    } 
    else
      $this->moov->udta->meta->free->setSize($oldFileSize - $newFileSize);
    
    /* Update the target box */
    fseek($fd, $mark);
    $this->moov->udta->setSize(fwrite($fd, $this->moov->udta));
    
    /* Update the parent box */
    fseek($fd, $this->moov->getOffset());
    fwrite($fd, Transform::toUInt32BE($this->moov->getSize()));
    
    fclose($fd);
  }
Exemplo n.º 16
0
 /**
  * Returns the frame raw data.
  *
  * @return string
  */
 public function __toString()
 {
   $data = $this->_device . "\0";
   foreach ($this->_adjustments as $channel) {
     $data .= Transform::toInt8($channel[self::channelType]) .
       Transform::toInt16BE($channel[self::volumeAdjustment] * 512);
     if (abs($channel[self::peakVolume]) <= 0xff)
       $data .= Transform::toInt8(8) .
         Transform::toUInt8($channel[self::peakVolume]);
     else if (abs($channel[self::peakVolume]) <= 0xffff)
       $data .= Transform::toInt8(16) .
         Transform::toUInt16BE($channel[self::peakVolume]);
     else if (abs($channel[self::peakVolume]) <= 0xffffffff)
       $data .= Transform::toInt8(32) .
         Transform::toUInt32BE($channel[self::peakVolume]);
     else
       $data .= Transform::toInt8(64) .
         Transform::toInt64BE($channel[self::peakVolume]); // UInt64
   }
   $this->setData($data);
   return parent::__toString();
 }
Exemplo n.º 17
0
 /**
  * Returns the frame raw data.
  *
  * @return string
  */
 public function __toString()
 {
   $data = Transform::toInt8($this->_interpolation) . $this->_device . "\0";
   foreach ($this->_adjustments as $frequency => $adjustment)
     $data .= Transform::toUInt16BE($frequency * 2) .
       Transform::toInt16BE($adjustment * 512);
   $this->setData($data);
   return parent::__toString();
 }
Exemplo n.º 18
0
 /**
  * swaps the index from end to beginning
  *
  * swaps the index from end to beginning
  * 
  * @return  mixed True if everything wents fine, otherwise error-message as string
  * @author  Benjamin Carl <*****@*****.**>
  * @version 0.1
  * @since   Method available since Release 0.1
  * @access  private
  */
 private function _swapIndex()
 {
     $moovSize = $this->_moovBytes->bytesAvailable();
     $moovAType = '';
     $moovASize = 0;
     $offsetCount = 0;
     $compressionCheck = $this->_moovBytes->readBytes(12, 4);
     if ($compressionCheck == Atom::CMOV_ATOM) {
         throw new Exception('compressed MP4/QT-file can\'t do this file: ' . $file);
     }
     // begin of metadata
     $metaDataOffsets = array();
     $metaDataStrings = array();
     $metaDataCurrentLevel = 0;
     $moovStartOffset = 12;
     for ($i = $moovStartOffset; $i < $moovSize - $moovStartOffset; $i++) {
         $moovAType = $this->_moovBytes->readUTFBytes($i, 4);
         if (Atom::isValidAtom($moovAType)) {
             $moovASize = $this->_moovBytes->readUnsignedInt($i - 4);
             if ($moovASize > 8 && $moovASize + $i < $moovSize - $moovStartOffset) {
                 try {
                     $containerLength = 0;
                     $containerString = $moovAType;
                     for ($mi = count($metaDataOffsets) - 1; $mi > -1; $mi--) {
                         $containerLength = $metaDataOffsets[$mi];
                         if ($i - $moovStartOffset < $containerLength && $i - $moovStartOffset + $moovASize > $containerLength) {
                             throw new Exception('bad atom nested size');
                         }
                         if ($i - $moovStartOffset == $containerLength) {
                             array_pop($metaDataOffsets);
                             array_pop($metaDataStrings);
                         } else {
                             $containerString = $metaDataStrings[$mi] . "." . $containerString;
                         }
                     }
                     if ($i - $moovStartOffset <= $containerLength) {
                         array_push($metaDataOffsets, $i - $moovStartOffset + $moovASize);
                         array_push($metaDataStrings, $moovAType);
                     }
                     if ($moovAType != Atom::STCO_ATOM && $moovAType != Atom::CO64_ATOM) {
                         $i += 4;
                     } elseif ($moovAType == Atom::URL_ATOM || $moovAType == Atom::XML_ATOM) {
                         $i += $moovASize - 4;
                     }
                 } catch (Exception $e) {
                     echo 'EXCEPTION: ' . $e->getMessage();
                 }
             }
         }
         if ($moovAType == Atom::STCO_ATOM) {
             $moovASize = $this->_moovBytes->readUnsignedInt($i - 4);
             if ($i + $moovASize - $moovStartOffset > $moovSize) {
                 throw new Exception('bad atom size');
                 return;
             }
             $offsetCount = $this->_moovBytes->readUnsignedInt($i + 8);
             for ($j = 0; $j < $offsetCount; $j++) {
                 $position = $i + 12 + $j * 4;
                 $currentOffset = $this->_moovBytes->readUnsignedInt($position);
                 // cause of mooving the moov-atom right before the rest of data
                 // (behind ftyp) the new offset is caluclated:
                 // current-offset + size of moov atom (box) = new offset
                 $currentOffset += $moovSize;
                 $this->_moovBytes->writeBytes(Transform::toUInt32BE($currentOffset), $position + 1);
             }
             $i += $moovASize - 4;
         } else {
             if ($moovAType == Atom::CO64_ATOM) {
                 $moovASize = $this->_moovBytes->readUnsignedInt($i - 4);
                 if ($i + $moovASize - $moovStartOffset > $moovSize) {
                     throw new Exception('bad atom size');
                     return;
                 }
                 $offsetCount = $this->_moovBytes->readDouble($i + 8);
                 for ($j2 = 0; $j2 < $offsetCount; $j2++) {
                     $position = $i + 12 + $j * 8;
                     $currentOffset = $this->_moovBytes->readUnsignedInt($position);
                     // cause of mooving the moov-atom right before the rest of data
                     // (behind ftyp) the new offset is caluclated:
                     // current-offset + size of moov atom (box) = new offset
                     $currentOffset += $moovSize;
                     // TODO implement!
                     //$this->_moovBytes->writeBytes(Transform::toUInt64BE($currentOffset), $position+1);
                 }
                 $i += $moovASize - 4;
             }
         }
     }
     return true;
 }
Exemplo n.º 19
0
 /**
  * Returns the frame raw data.
  *
  * @return string
  */
 public function __toString()
 {
     $data = Transform::toInt8($this->_encoding) . $this->_currency . $this->_price . "" . $this->_date;
     switch ($this->_encoding) {
         case self::UTF16:
             $data .= Transform::toString16($this->_seller);
             break;
         case self::UTF16BE:
             $data .= Transform::toString16BE($this->_seller);
             break;
         case self::UTF16LE:
             $data .= Transform::toString16LE($this->_seller);
             break;
         default:
             $data .= $this->_seller;
     }
     $this->setData($data);
     return parent::__toString();
 }
Exemplo n.º 20
0
 /**
  * Returns the frame raw data.
  *
  * @return string
  */
 public function __toString()
 {
     parent::setData($this->_owner . "" . Transform::toInt8($this->_method) . $this->_encryptionData);
     return parent::__toString();
 }
Exemplo n.º 21
0
 /**
  * Returns the frame raw data.
  *
  * @return string
  */
 public function __toString()
 {
   $data = Transform::toUInt8($this->_encoding);
   switch ($this->_encoding) {
   case self::UTF16:
   case self::UTF16LE:
     $data .= Transform::toString16
       ($this->_description, $this->_encoding == self::UTF16 ?
        Transform::MACHINE_ENDIAN_ORDER : Transform::LITTLE_ENDIAN_ORDER) .
       "\0\0";
     break;
   case self::UTF16BE:
     $data .= Transform::toString16BE($this->_description) . "\0\0";
     break;
   default:
     $data .= $this->_description . "\0";
   }
   $this->setData($data . $this->_link);
   return ID3_Frame::__toString();
 }
Exemplo n.º 22
0
 /**
  * Returns the frame raw data.
  *
  * @return string
  */
 public function __toString()
 {
     $data = $this->_device . "";
     foreach ($this->_adjustments as $channel) {
         $data .= Transform::toInt8($channel["channelType"]) . Transform::toInt16BE($channel["volumeAdjustment"]);
         if ($channel["peakVolume"] < 255) {
             $data .= Transform::toInt8(8) . Transform::toInt8($channel["peakVolume"]);
         } else {
             if ($channel["peakVolume"] < 65535) {
                 $data .= Transform::toInt8(16) . Transform::toUInt16BE($channel["peakVolume"]);
             } else {
                 if ($channel["peakVolume"] < 4294967295) {
                     $data .= Transform::toInt8(32) . Transform::toUInt32BE($channel["peakVolume"]);
                 } else {
                     $data .= Transform::toInt8(64) . Transform::toUInt64BE($channel["peakVolume"]);
                 }
             }
         }
     }
     $this->setData($data);
     return parent::__toString();
 }
Exemplo n.º 23
0
 /**
  * Returns the frame raw data.
  *
  * @return string
  */
 public function __toString()
 {
   parent::setData
     ($this->_owner . "\0" . Transform::toUInt8($this->_group) .
      $this->_groupData);
   return parent::__toString();
 }
Exemplo n.º 24
0
 /**
  * Returns the frame raw data.
  *
  * @return string
  */
 public function __toString()
 {
     $this->setData(Transform::toInt32BE($this->_minOffset));
     return parent::__toString();
 }
Exemplo n.º 25
0
 /**
  * Returns the frame raw data.
  *
  * @return string
  */
 public function __toString()
 {
     $data = Transform::toInt8($this->_encoding) . $this->_price . "" . $this->_date . $this->_contact . "" . Transform::toInt8($this->_delivery);
     switch ($this->_encoding) {
         case self::UTF16:
             $data .= Transform::toString16($this->_seller) . "" . Transform::toString16($this->_description) . "";
             break;
         case self::UTF16BE:
             $data .= Transform::toString16BE($this->_seller) . "";
             Transform::toString16($this->_description) . "";
             break;
         case self::UTF16LE:
             $data .= Transform::toString16LE($this->_seller) . "";
             Transform::toString16($this->_description) . "";
             break;
         default:
             $data .= $this->_seller . "" . $this->_description . "";
     }
     parent::setData($data . ($this->_mimeType ? $this->_mimeType . "" . $this->_imageData : 0));
     return parent::__toString();
 }
Exemplo n.º 26
0
 /**
  * Returns the frame raw data.
  *
  * @return string
  */
 public function __toString()
 {
   $data = Transform::toUInt8($this->_encoding) . $this->_currency .
     $this->_price . "\0" . $this->_date . $this->_contact . "\0" .
     Transform::toUInt8($this->_delivery);
   switch ($this->_encoding) {
   case self::UTF16:
   case self::UTF16LE:
     $order = $this->_encoding == self::UTF16 ?
       Transform::MACHINE_ENDIAN_ORDER : Transform::LITTLE_ENDIAN_ORDER;
     $data .= Transform::toString16($this->_seller, $order) . "\0\0" .
       Transform::toString16($this->_description, $order) . "\0\0";
     break;
   case self::UTF16BE:
     $data .= Transform::toString16BE
       ($this->_seller . "\0\0" . $this->_description . "\0\0");
     break;
   default:
     $data .= $this->_seller . "\0" . $this->_description . "\0";
   }
   parent::setData
     ($data . ($this->_mimeType ?
               $this->_mimeType . "\0" . $this->_imageData : ""));
   return parent::__toString();
 }
Exemplo n.º 27
0
 /**
  * Returns the box raw data.
  *
  * @return string
  */
 public function __toString($data = "")
 {
   return parent::__toString(Transform::toUInt16BE(count($this->_boxes)));
 }
Exemplo n.º 28
0
 /**
  * Returns the frame raw data.
  *
  * @return string
  */
 public function __toString()
 {
     $flags = 0;
     if ($this->_adjustments["right"] > 0) {
         $flags = $flags | 0x20;
     }
     if ($this->_adjustments["left"] > 0) {
         $flags = $flags | 0x10;
     }
     $data = Transform::toInt8(16) . Transform::toUInt16BE(abs($this->_adjustments["right"])) . Transform::toUInt16BE(abs($this->_adjustments["left"])) . Transform::toUInt16BE(abs($this->_adjustments["peakRight"])) . Transform::toUInt16BE(abs($this->_adjustments["peakLeft"]));
     if (isset($this->_adjustments["rightBack"]) && isset($this->_adjustments["leftBack"]) && isset($this->_adjustments["peakRightBack"]) && isset($this->_adjustments["peakLeftBack"])) {
         if ($this->_adjustments["rightBack"] > 0) {
             $flags = $flags | 0x8;
         }
         if ($this->_adjustments["leftBack"] > 0) {
             $flags = $flags | 0x4;
         }
         $data .= Transform::toUInt16BE(abs($this->_adjustments["rightBack"])) . Transform::toUInt16BE(abs($this->_adjustments["leftBack"])) . Transform::toUInt16BE(abs($this->_adjustments["peakRightBack"])) . Transform::toUInt16BE(abs($this->_adjustments["peakLeftBack"]));
     }
     if (isset($this->_adjustments["center"]) && isset($this->_adjustments["peakCenter"])) {
         if ($this->_adjustments["center"] > 0) {
             $flags = $flags | 0x2;
         }
         $data .= Transform::toUInt16BE(abs($this->_adjustments["center"])) . Transform::toUInt16BE(abs($this->_adjustments["peakCenter"]));
     }
     if (isset($this->_adjustments["bass"]) && isset($this->_adjustments["peakBass"])) {
         if ($this->_adjustments["bass"] > 0) {
             $flags = $flags | 0x1;
         }
         $data .= Transform::toUInt16BE(abs($this->_adjustments["bass"])) . Transform::toUInt16BE(abs($this->_adjustments["peakBass"]));
     }
     $this->setData(Transform::toInt8($flags) . $data);
     return parent::__toString();
 }
Exemplo n.º 29
0
 /**
  * Constructs the class with given parameters and reads box related data from
  * the ISO Base Media file.
  *
  * @param Reader $reader The reader object.
  */
 public function __construct($reader, &$options = array())
 {
   parent::__construct($reader, $options);
   
   $groupingType = $this->_reader->readUInt32BE();
   $entryCount = $this->_reader->readUInt32BE();
   $data = $this->_reader->read
     ($this->getOffset() + $this->getSize() - $this->_reader->getOffset());
   for ($i = 1; $i <= $entryCount; $i++)
     $this->_sampleToGroupTable[$i] = array
       ("sampleCount" =>
          Transform::fromUInt32BE(substr($data, ($i - 1) * 8, 4)),
        "groupDescriptionIndex" =>
          Transform::fromUInt32BE(substr($data, $i * 8 - 4, 4)));
 }
Exemplo n.º 30
0
 foreach ($regenTransforms as $inflId => $transformMatrix) {
     db_execute("delete from ModelDescription where modelId = {$model->id} and inflectionId = {$inflId}");
     $variant = 0;
     foreach ($transformMatrix as $transforms) {
         $accentShift = array_pop($transforms);
         if ($accentShift != UNKNOWN_ACCENT_SHIFT && $accentShift != NO_ACCENT_SHIFT) {
             $accentedVowel = array_pop($transforms);
         } else {
             $accentedVowel = '';
         }
         $order = 0;
         $mds = array();
         for ($i = count($transforms) - 1; $i >= 0; $i--) {
             $t = $transforms[$i];
             // Make sure the transform has an ID.
             $t = Transform::createOrLoad($t->transfFrom, $t->transfTo);
             $md = Model::factory('ModelDescription')->create();
             $md->modelId = $model->id;
             $md->inflectionId = $inflId;
             $md->variant = $variant;
             $md->applOrder = $order++;
             $md->isLoc = false;
             $md->recommended = false;
             $md->transformId = $t->id;
             $md->accentShift = $accentShift;
             $md->vowel = $accentedVowel;
             $md->save();
         }
         $variant++;
     }
 }