本文整理汇总了PHP中FileReader类的典型用法代码示例。如果您正苦于以下问题:PHP FileReader类的具体用法?PHP FileReader怎么用?PHP FileReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:TheEntropics,项目名称:TeamSpeak3-stats,代码行数:16,代码来源:CacheService.php
示例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;
}
}
开发者ID:sparrow41,项目名称:training,代码行数:16,代码来源:RudiInteligentBuildingCommunication.php
示例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));
}
开发者ID:bfrohs,项目名称:icanhaslog,代码行数:7,代码来源:FileReader.test.php
示例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);
}
开发者ID:bohwaz,项目名称:featherbb,代码行数:14,代码来源:MO.php
示例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());
}
开发者ID:siiptuo,项目名称:tablak,代码行数:13,代码来源:GuitarProFile.php
示例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;
}
开发者ID:bluematt,项目名称:korpus-app,代码行数:53,代码来源:DocumentLocator.php
示例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;
}
开发者ID:ryanp73,项目名称:Eagle,代码行数:10,代码来源:Utils.php
示例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;
}
开发者ID:BackupTheBerlios,项目名称:infoschool-svn,代码行数:14,代码来源:index.php
示例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;
}
开发者ID:BackupTheBerlios,项目名称:infoschool-svn,代码行数:48,代码来源:func.php
示例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);
}
开发者ID:raphhh,项目名称:balloon,代码行数:11,代码来源:FileReaderTest.php
示例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;
}
开发者ID:TheEntropics,项目名称:TeamSpeak3-stats,代码行数:22,代码来源:FileReader.php
示例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);
}
开发者ID:BackupTheBerlios,项目名称:infoschool-svn,代码行数:20,代码来源:func.php
示例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();
}
}
开发者ID:alexpagnoni,项目名称:jphp,代码行数:22,代码来源:ServletContext.php
示例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;
}
开发者ID:umesecke,项目名称:phing,代码行数:46,代码来源:XsltFilter.php
示例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();
}
开发者ID:xxspartan16,项目名称:BMS-Market,代码行数:101,代码来源:SmartyTask.php
示例16: getPhingVersion
function getPhingVersion()
{
$versionPath = self::getResourcePath("phing/etc/VERSION.TXT");
if ($versionPath === null) {
$versionPath = self::getResourcePath("etc/VERSION.TXT");
}
try {
// try to read file
$buffer = null;
$file = new PhingFile($versionPath);
$reader = new FileReader($file);
$reader->readInto($buffer);
$buffer = trim($buffer);
//$buffer = "PHING version 1.0, Released 2002-??-??";
$phingVersion = $buffer;
} catch (IOException $iox) {
print "Can't read version information file\n";
throw new BuildException("Build failed");
}
return $phingVersion;
}
开发者ID:domenypl,项目名称:symfony1-legacy,代码行数:21,代码来源:Phing.php
示例17: LdifReader
/**
* Constructor of the class
*
* @param String $path2File path of the ldif file to read
* @param boolean $continuous_mode 1 if continuous mode operation, 0 otherwise
*/
function LdifReader($path2File, $continuous_mode = 0)
{
parent::FileReader($path2File);
$this->continuous_mode = $continuous_mode;
$this->_LdifReader();
}
开发者ID:azeckoski,项目名称:az-php-sandbox,代码行数:12,代码来源:ldif_functions.php
示例18: main
/**
* Execute the input script with Velocity
*
* @throws BuildException
* BuildExceptions are thrown when required attributes are missing.
* Exceptions thrown by Velocity are rethrown as BuildExceptions.
*/
public function main()
{
// Make sure the template path is set.
if (empty($this->templatePath)) {
throw new BuildException("The template path needs to be defined!");
}
// Make sure the control template is set.
if ($this->controlTemplate === null) {
throw new BuildException("The control template needs to be defined!");
}
// Make sure the output directory is set.
if ($this->outputDirectory === null) {
throw new BuildException("The output directory needs to be defined!");
}
// Make sure there is an output file.
if ($this->outputFile === null) {
throw new BuildException("The output file needs to be defined!");
}
// Setup Smarty runtime.
// Smarty uses one object to store properties and to store
// the context for the template (unlike Velocity). We setup this object, calling it
// $this->context, and then initControlContext simply zeros out
// any assigned variables.
$this->context = new Capsule();
if ($this->templatePath !== null) {
$this->log("Using templatePath: " . $this->templatePath);
$this->context->setTemplatePath($this->templatePath);
}
// Make sure the output directory exists, if it doesn't
// then create it.
$outputDir = new PhingFile($this->outputDirectory);
if (!$outputDir->exists()) {
$this->log("Output directory does not exist, creating: " . $outputDir->getAbsolutePath());
$outputDir->mkdirs();
}
$this->context->setOutputDirectory($outputDir->getAbsolutePath());
$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 (preg_match('/file\\.contents$/', $property)) {
// pull in contents of file specified
$property = substr($property, 0, strpos($property, "file.contents") - 1);
// reset value, and then
// read in the contents of the file into that var
$value = "";
$f = new PhingFile($this->project->resolveFile($value)->getCanonicalPath());
if ($f->exists()) {
$fr = new FileReader($f);
$fr->readInto($value);
}
}
// if ends with file.contents
if (StringHelper::isBoolean($value)) {
$value = StringHelper::booleanValue($value);
}
$c->put($property, $value);
}
// foreach property
}
// if contextProperties !== null
try {
$this->log("Parsing control template: " . $this->controlTemplate);
$c->parse($this->controlTemplate, $path);
} catch (Exception $ioe) {
throw new BuildException("Cannot write parsed template: " . $ioe->getMessage());
}
$this->cleanup();
}
开发者ID:Ingewikkeld,项目名称:phing,代码行数:92,代码来源:CapsuleTask.php
示例19: read
}
}
class INIFileReader
{
public function read($filePath)
{
return fopen($filePath, 'r');
}
}
class FileReader
{
public function read($filePath)
{
$extension = substr($filePath, -3);
switch ($extension) {
case 'ini':
$reader = new INIFileReader();
break;
case 'xml':
$reader = new XMLFileReader();
break;
default:
return false;
break;
}
return $reader->read($filePath);
}
}
$reader = new FileReader();
$reader->read("test.ini");
$reader = new INIFileReader();
开发者ID:VoidWalker,项目名称:learning-project,代码行数:31,代码来源:Factory.php
示例20: function
require_once './eagle/models/Comment.php';
require_once './eagle/models/Defense.php';
require_once './eagle/models/PitScouting.php';
$app->group('/team', function () {
$this->get('/{url:.*\\/}', function ($req, $res, $args) {
header('Location:/team/' . trim($args['url'], '/'));
exit;
});
$this->get('/{team:[0-9]{1,4}}', function ($req, $res, $args) {
Auth::redirectIfNotLoggedIn();
$team = FileReader::getTeam($args['team']);
if (!$team) {
Downloader::getTeam($args['team']);
header('Refresh:0');
}
$events = FileReader::getEventsForTeam($args['team']);
if (!$events) {
Downloader::getEventsForTeam($args['team']);
header('Refresh:0');
}
$comments = Comment::where('team_id', $team->team_number);
$defense = Defense::where('team_id', $args['team'])->orderBy('id', 'desc')->first();
$defenses = array();
$author = $defense ? $defense->author : false;
if ($defense) {
$defenses['Low Bar'] = $defense->low_bar;
$defenses['Portcullis'] = $defense->portcullis;
$defenses['Cheval de Frsie'] = $defense->cheval_de_frise;
$defenses['Moat'] = $defense->moat;
$defenses['Ramparts'] = $defense->ramparts;
$defenses['Drawbridge'] = $defense->drawbridge;
开发者ID:ryanp73,项目名称:Eagle,代码行数:31,代码来源:team.routes.php
注:本文中的FileReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论