本文整理汇总了PHP中FileReader类的典型用法代码示例。如果您正苦于以下问题:PHP FileReader类的具体用法?PHP FileReader怎么用?PHP FileReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEvents
private static function getEvents($lastDate)
{
$events = array();
$fileReader = new FileReader($lastDate);
while (($line = $fileReader->getLine()) != null) {
if (is_a($line, "DateTime")) {
$event = new ServerStartedEvent($line);
} else {
$event = Parser::parseLine($line);
}
if ($event && Utils::getTimestamp($event->date) > Utils::getTimestamp($lastDate)) {
$events[] = $event;
}
}
return $events;
}
示例2: __construct
public function __construct()
{
//wczytanie danych z pliku textowego
$fr = new FileReader("operacje.txt");
//odczytanie wszystkich linii z pliku
$this->daneZPliku = $fr->getAll();
//utworzenie z danych obiektów Operacja
foreach ($this->daneZPliku as $linia) {
$model = new InteligentBuildingCommunicationModel();
$dane = explode(';', $linia);
$model->Operation = $this->getOperacja($dane);
$model->HomeAddress = $dane[0];
$model->DeviceName = $dane[1];
$this->modele[] = $model;
}
}
示例3: testReader
public function testReader()
{
$reader = new FileReader(__DIR__ . '/data/error.log');
$reader->next();
$this->assertTrue($reader->valid());
$this->assertEquals('Stack trace:', $reader->consumeLine(10));
}
示例4: import_from_file
/**
* Fills up with the entries from MO file $filename
*
* @param string $filename MO file to load
* @return bool Success
*/
public function import_from_file($filename)
{
$reader = new FileReader($filename);
if (!$reader->is_resource()) {
return false;
}
return $this->import_from_reader($reader);
}
示例5: __construct
public function __construct(string $filename)
{
$fileReader = new FileReader($filename);
$version = $fileReader->readPascalString(30);
$this->title = trim($fileReader->readDelphiString());
$this->subtitle = trim($fileReader->readDelphiString());
$this->artist = trim($fileReader->readDelphiString());
$this->album = trim($fileReader->readDelphiString());
$this->composer = trim($fileReader->readDelphiString());
$this->copyright = trim($fileReader->readDelphiString());
$this->transcriber = trim($fileReader->readDelphiString());
$this->instructions = trim($fileReader->readDelphiString());
}
示例6: fromRoute
/**
* @TODO
*/
public function fromRoute($route)
{
// $this->route = $route;
// Find the files that match the route.
$finder = new \Symfony\Component\Finder\Finder();
$glob = '#^default\\.(?:md|markdown|textile|html|htm|txt)$#';
if ($route !== '') {
$glob = '#^(?:\\d\\d\\.)?' . implode('\\/(?:\\d\\d\\.)?', explode('/', $route)) . '(?:\\/default)?\\.(?:md|markdown|textile|html|htm|txt)' . '$#';
}
$finder->in($this->documentPath)->path($glob);
$files = [];
foreach ($finder as $file) {
$files[] = $file->getRelativePathname();
}
// Work out if we have *any* matching documents. If not, throw an
// exception.
if (empty($files)) {
throw new Exceptions\NoCandidatesException($route);
}
// Sort functions.
$indexSort = function ($a, $b) {
// return 0;
return $a > $b;
};
$extensionSort = function ($a, $b) {
$allowedExtensions = explode('|', 'md|markdown|textile|html|htm|txt');
$aExt = pathinfo($a, PATHINFO_EXTENSION);
$bExt = pathinfo($b, PATHINFO_EXTENSION);
$aExtPos = array_search($aExt, $allowedExtensions);
$bExtPos = array_search($bExt, $allowedExtensions);
return $aExtPos > $bExtPos;
};
$isDefaultSort = function ($a, $b) {
$aHasDefault = strpos($a, 'default.');
$bHasDefault = strpos($b, 'default.');
return $aHasDefault < $bHasDefault;
};
// Sort the documents according to their priority.
$complexSort = \pjdietz\ComplexSort\ComplexSort::makeComplexSortFunction([$indexSort, $extensionSort, $isDefaultSort]);
usort($files, $complexSort);
// Read the file content from the filesystem.
$fileReader = new FileReader(new \League\Flysystem\Filesystem(new \League\Flysystem\Adapter\Local($this->documentPath)));
$filepath = $files[0];
$content = $fileReader->read($filepath);
// Create a document from the file content.
$document = new Document($content);
$document->filepath = $filepath;
$document->parse();
return $document;
}
示例7: getUnscoutedTeams
public static function getUnscoutedTeams($event)
{
$teams = array();
foreach (FileReader::getTeamsAtEvent($event) as $team) {
if (!PitScouting::where(array('team_id' => $team->team_number, 'event_id' => $event))->first()) {
array_push($teams, $team);
}
}
return $teams;
}
示例8: htmlformat_menuitem
function htmlformat_menuitem($root, $s, $u, $c)
{
$v['%sign%'] = $s;
$v['%url%'] = $u;
$v['%caption%'] = $c;
$a = Path::absolute($u);
$b = Path::absolute($root . substr($_SERVER['REQUEST_URI'], 1));
if ($a == $b) {
$item = FileReader::readFile($root . 'menulinkv.html', $v);
} else {
$item = FileReader::readFile($root . 'menulink.html', $v);
}
return $item;
}
示例9: get_neu_person_form
function get_neu_person_form($person)
{
$dir = $GLOBALS['root'] . 'benutzer/';
if (isset($person['accept'])) {
$person['accept'] = ' checked';
} else {
$person['accept'] = '';
}
if (!isset($person['vorname'])) {
$person['vorname'] = '';
}
if (!isset($person['nachname'])) {
$person['nachname'] = '';
}
if (!isset($person['gebtag'])) {
$person['gebtag'] = '';
}
if (!isset($person['gebmon'])) {
$person['gebmon'] = '';
}
if (!isset($person['mail'])) {
$person['mail'] = '';
}
if (!isset($person['passwd1'])) {
$person['passwd1'] = '';
}
if (!isset($person['passwd2'])) {
$person['passwd2'] = '';
}
$vars['%bedingungen%'] = FileReader::readFile($dir . 'bedingungen.html');
$vars['%accept%'] = $person['accept'];
$vars['%vorname%'] = text2html($person['vorname']);
$vars['%nachname%'] = text2html($person['nachname']);
if (isset($person['gebjahr'])) {
$gebjahr = $person['gebjahr'];
} else {
$gebjahr = date('Y') - 12;
}
$gebdat = get_select_int('person[gebtag]', 1, 32, $person['gebtag']);
$gebdat .= get_select_int('person[gebmon]', 1, 13, $person['gebmon']);
$gebdat .= get_select_int('person[gebjahr]', date('Y') - 65, date('Y') - 5, $gebjahr);
$vars['%gebdat%'] = $gebdat;
$vars['%mail%'] = $person['mail'];
$vars['%passwd1%'] = text2html($person['passwd1']);
$vars['%passwd2%'] = text2html($person['passwd2']);
$form = FileReader::readFile($dir . 'neu_person.html', $vars);
return $form;
}
示例10: testWriteInNotExistingFile
public function testWriteInNotExistingFile()
{
$filePath = __DIR__ . '/resources/none.txt';
$dummyFileReader = new FileReader($filePath);
$this->assertSame('', $dummyFileReader->read());
$this->assertSame(3, $dummyFileReader->write('abc'));
$this->assertSame('abc', $dummyFileReader->read());
$this->assertSame(3, $dummyFileReader->write('def'));
$this->assertSame('def', $dummyFileReader->read());
unlink($filePath);
}
示例11: getLine
/**
* @return null|string The next line to read, null on end
*/
public function getLine()
{
if ($this->logFiles[$this->currentFile] != $this->lastFile) {
$this->lastFile = $this->logFiles[$this->currentFile];
return FileReader::getDateFromFilename($this->lastFile);
}
$line = fgets($this->currentHandle);
if ($line == null) {
fclose($this->currentHandle);
$this->currentFile++;
if ($this->currentFile == count($this->logFiles)) {
return null;
}
$this->currentHandle = fopen($this->logFiles[$this->currentFile], "r");
$this->lastFile = $this->logFiles[$this->currentFile];
return FileReader::getDateFromFilename($this->lastFile);
}
return $line;
}
示例12: vplan_single
function vplan_single($pi = '')
{
global $output;
if ($_GET['key'] != 'kmyxl09') {
$output->secure();
}
$user_pi = '0';
if (isset($_GET['d'])) {
$user_pi = $_GET['d'];
}
if (strlen($pi) == 0) {
$pi = $user_pi;
}
(int) $pi;
$vplan = get_vplan($pi);
$vars = vplan2html_single($vplan['text']);
$vars['%url%'] = sessionurl('single.php?d=' . $pi);
$vars['%titel%'] = 'Vertretungsplan';
echo FileReader::readFile('single.html', $vars);
}
示例13: ServletContext
function ServletContext($web_xml_file)
{
$web_xml_file = new File($web_xml_file);
if (File::validClass($web_xml_file) && $web_xml_file->exists()) {
$this->file =& $web_xml_file;
$cache_file = new File($web_xml_file->getFilePath() . 'cached');
$valid_cache = FALSE;
if ($cache_file->exists() && $web_xml_file->lastModified() == $cache_file->lastModified()) {
$this->config = @unserialize(FileReader::readFileContent($cache_file));
if (ServletContext::validClass($this->config)) {
$valid_cache = TRUE;
}
}
if (!$valid_cache) {
$this->config =& ServletXMLConfigReader::readXMLConfig(new FileReader($web_xml_file));
FileWriter::writeToFile($cache_file, serialize($this->config), $web_xml_file->lastModified());
}
}
if (isset($this->config)) {
$this->initServletContext();
}
}
示例14: read
/**
* Reads stream, applies XSLT and returns resulting stream.
* @return string transformed buffer.
* @throws BuildException - if XSLT support missing, if error in xslt processing
*/
function read($len = null)
{
if (!class_exists('XSLTProcessor')) {
throw new BuildException("Could not find the XSLTProcessor class. Make sure PHP has been compiled/configured to support XSLT.");
}
if ($this->processed === true) {
return -1;
// EOF
}
if (!$this->getInitialized()) {
$this->_initialize();
$this->setInitialized(true);
}
// Read XML
$_xml = null;
while (($data = $this->in->read($len)) !== -1) {
$_xml .= $data;
}
if ($_xml === null) {
// EOF?
return -1;
}
if (empty($_xml)) {
$this->log("XML file is empty!", Project::MSG_WARN);
return '';
// return empty string, don't attempt to apply XSLT
}
// Read XSLT
$_xsl = null;
$xslFr = new FileReader($this->xslFile);
$xslFr->readInto($_xsl);
$this->log("Tranforming XML " . $this->in->getResource() . " using style " . $this->xslFile->getPath(), Project::MSG_VERBOSE);
$out = '';
try {
$out = $this->process($_xml, $_xsl);
$this->processed = true;
} catch (IOException $e) {
throw new BuildException($e);
}
return $out;
}
示例15: main
//.........这里部分代码省略.........
// the context for the template (unlike Velocity). We setup this object, calling it
// $this->context, and then initControlContext simply zeros out
// any assigned variables.
//
// Use the smarty backwards compatibility layer if existent.
if (class_exists('SmartyBC')) {
$this->context = new SmartyBC();
} else {
$this->context = new Smarty();
}
if ($this->compilePath !== null) {
$this->log("Using compilePath: " . $this->compilePath);
$this->context->compile_dir = $this->compilePath;
}
if ($this->configPath !== null) {
$this->log("Using configPath: " . $this->configPath);
$this->context->config_dir = $this->configPath;
}
if ($this->forceCompile !== null) {
$this->context->force_compile = $this->forceCompile;
}
if ($this->leftDelimiter !== null) {
$this->context->left_delimiter = $this->leftDelimiter;
}
if ($this->rightDelimiter !== null) {
$this->context->right_delimiter = $this->rightDelimiter;
}
if ($this->templatePath !== null) {
$this->log("Using templatePath: " . $this->templatePath);
$this->context->template_dir = $this->templatePath;
}
$smartyCompilePath = new PhingFile($this->context->compile_dir);
if (!$smartyCompilePath->exists()) {
$this->log("Compile directory does not exist, creating: " . $smartyCompilePath->getPath(), Project::MSG_VERBOSE);
if (!$smartyCompilePath->mkdirs()) {
throw new BuildException("Smarty needs a place to compile templates; specify a 'compilePath' or create " . $this->context->compile_dir);
}
}
// Make sure the output directory exists, if it doesn't
// then create it.
$file = new PhingFile($this->outputDirectory);
if (!$file->exists()) {
$this->log("Output directory does not exist, creating: " . $file->getAbsolutePath());
$file->mkdirs();
}
$path = $this->outputDirectory . DIRECTORY_SEPARATOR . $this->outputFile;
$this->log("Generating to file " . $path);
$writer = new FileWriter($path);
// The generator and the output path should
// be placed in the init context here and
// not in the generator class itself.
$c = $this->initControlContext();
// Set any variables that need to always
// be loaded
$this->populateInitialContext($c);
// Feed all the options into the initial
// control context so they are available
// in the control/worker templates.
if ($this->contextProperties !== null) {
foreach ($this->contextProperties->keys() as $property) {
$value = $this->contextProperties->getProperty($property);
// Special exception (from Texen)
// for properties ending in file.contents:
// in that case we dump the contents of the file
// as the "value" for the Property.
if (StringHelper::endsWith("file.contents", $property)) {
// pull in contents of file specified
$property = substr($property, 0, strpos($property, "file.contents") - 1);
// reset value, and then
// read in teh contents of the file into that var
$value = "";
$f = new PhingFile($this->project->resolveFile($value)->getCanonicalPath());
if ($f->exists()) {
try {
$fr = new FileReader($f);
$fr->readInto($value);
} catch (Exception $e) {
throw $e;
}
}
}
// if ends with file.contents
if (StringHelper::isBoolean($value)) {
$value = StringHelper::booleanValue($value);
}
$c->assign($property, $value);
}
// foreach property
}
// if contextProperties !== null
try {
//$c->display($this->controlTemplate);
$writer->write($c->fetch($this->controlTemplate));
$writer->close();
} catch (IOException $ioe) {
$writer->close();
throw new BuildException("Cannot write parsed template.");
}
$this->cleanup();
}