Ejemplo n.º 1
0
 public static function base64ToFile($base64, $save)
 {
     $base64 = substr($base64, strpos($base64, ',') + 1);
     $base64 = base64_decode($base64);
     if (!$base64) {
         throw new \Exception("Invalid base64 image string");
     }
     $file = new File();
     $file->setFileName($save);
     $file->setContents($base64);
     $file->write();
     ImageValidate::mustBeImage($file);
     return $file;
 }
Ejemplo n.º 2
0
 public function parse(File $template)
 {
     $template->setReadFunction('fgets');
     $matches = array();
     foreach ($template as $number => $line) {
         $match = $this->parseLine($line, $number);
         if (!$match) {
             $this->log->log($line);
             continue;
         }
         $matches[] = $match;
     }
     return $matches;
 }
Ejemplo n.º 3
0
 public function __construct(array $parameters = array())
 {
     if (!array_key_exists('file', $parameters)) {
         throw new \InvalidArgumentException("No file specified, can not log without a log file!");
     }
     $this->setFile(FSFile::getInstance($parameters['file']));
     $this->enableFileColoring(array_key_exists('fileColoring', $parameters) ? $parameters['fileColoring'] : $this->colors);
     $this->enableStdout(array_key_exists('stdout', $parameters) ? $parameters['stdout'] : $this->stdout);
     parent::__construct($parameters);
     parent::enableStdout(FALSE);
 }
Ejemplo n.º 4
0
 public static function sendExcel(\PHPExcel_Writer_IWriter $writer, $fileName = NULL)
 {
     header("Pragma: public");
     header("Expires: 0");
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     header("Content-Type: application/force-download");
     header("Content-Type: application/octet-stream");
     header("Content-Type: application/download");
     header("Content-Disposition: attachment;filename={$fileName}");
     header("Content-Transfer-Encoding: binary ");
     //Seems that there's a bug on PHP excel 2007 and we can't write directly
     //to stdout. Actually the code attempts to make the EXACT same thing
     //we are doing here when the string equals to php://stdout or php://output
     $file = File::makeTemporary('__apf_excel_download');
     $writer->save($file);
     $file->chunkedOutput();
 }
Ejemplo n.º 5
0
 public function save(\apf\core\File $file)
 {
     try {
         $returnOpt = $this->getCurlOption("RETURNTRANSFER");
         $this->setCurlOption("RETURNTRANSFER", FALSE);
         $this->setCurlOption("FILE", $file->open("w"));
         $this->connect();
         $file->close();
         $this->setCurlOption("RETURNTRANSFER", $returnOpt);
         return TRUE;
     } catch (\Exception $e) {
         $this->setCurlOption("RETURNTRANSFER", $returnOpt);
         throw $e;
         return FALSE;
     }
 }
Ejemplo n.º 6
0
 public static function factory(File $file)
 {
     $configFile = new File(sprintf('%s', $file));
     $adapter = sprintf('\\apf\\core\\config\\adapter\\%s', ucwords($configFile->getExtension()));
     return new $adapter($configFile);
 }