예제 #1
0
파일: Helpers.php 프로젝트: jave007/test
 private static function sanitize($type, $value)
 {
     if ($type === Form::DATA_TEXT) {
         return is_scalar($value) ? Strings::normalizeNewLines($value) : NULL;
     } elseif ($type === Form::DATA_LINE) {
         return is_scalar($value) ? Strings::trim(strtr($value, "\r\n", '  ')) : NULL;
     } elseif ($type === Form::DATA_FILE) {
         return $value instanceof Nette\Http\FileUpload ? $value : NULL;
     } else {
         throw new Nette\InvalidArgumentException('Unknown data type');
     }
 }
예제 #2
0
 /**
  * Run CasperJS and output result
  *
  * @param string $filename
  */
 private function doRun($filename)
 {
     $command = $this->getCommand($filename);
     echo $this->getInfoHeader($command);
     $fp = popen($command, 'r');
     while (!feof($fp)) {
         $line = fread($fp, 1024);
         // skip line with message of PhantomJS bug for non-debug level
         if ($this->getLogLevel() !== self::LOG_LEVEL_DEBUG && Strings::contains($line, 'Unsafe JavaScript attempt to access frame')) {
             continue;
         }
         // skip JS strict warnings for non-debug level
         if ($this->getLogLevel() !== self::LOG_LEVEL_DEBUG && Strings::contains($line, 'JavaScript strict warning:')) {
             continue;
         }
         $line = Strings::replace($line, '[\\[phantom\\] |\\[remote\\] ]');
         $line = Strings::normalizeNewLines($line);
         $this->output[] = $line;
         echo $line;
         flush();
     }
     echo PHP_EOL;
     pclose($fp);
 }