/**
  * Data URI scheme - base64 encoding.
  *
  * @param string $sFile
  * @return string Returns format: data:[<MIME-type>][;base64],<data>
  */
 public static function dataUri($sFile)
 {
     $oFile = new \PH7\Framework\File\File();
     // Switch to right MIME-type
     $sExt = $oFile->getFileExt($sFile);
     $sMimeType = $oFile->getMimeType($sExt);
     unset($oFile);
     $sBase64 = base64_encode(file_get_contents($sFile));
     return "data:{$sMimeType};base64,{$sBase64}";
 }
Пример #2
0
 /**
  * Set a Mode (Generic method).
  *
  * @access private
  * @param string $sReplace The Mode site.
  * @see PH7\Framework\Config\Config::setProductionMode()
  * @see PH7\Framework\Config\Config::setDevelopmentMode()
  * @return void
  */
 private function _setMode($sReplace)
 {
     $sSearch = $sReplace === self::DEVELOPMENT_MODE ? self::PRODUCTION_MODE : self::DEVELOPMENT_MODE;
     $oFile = new \PH7\Framework\File\File();
     // Check and correct the file permission if necessary.
     $oFile->chmod($this->_sConfigAppFilePath, 0666);
     $sContents = $oFile->getFile($this->_sConfigAppFilePath);
     $sNewContents = str_replace('environment = ' . $sSearch . ' ; production or development', 'environment = ' . $sReplace . ' ; production or development', $sContents);
     $oFile->putFile($this->_sConfigAppFilePath, $sNewContents);
     // Check and correct the file permission if necessary.
     $oFile->chmod($this->_sConfigAppFilePath, 0644);
     unset($oFile, $sContents);
 }