本文整理汇总了PHP中Properties::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Properties::load方法的具体用法?PHP Properties::load怎么用?PHP Properties::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Properties
的用法示例。
在下文中一共展示了Properties::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testComments
public function testComments()
{
$file = new PhingFile(PHING_TEST_BASE . "/etc/system/util/comments.properties");
$this->props->load($file);
$this->assertEquals($this->props->getProperty('useragent'), 'Mozilla/5.0 (Windows NT 5.1; rv:8.0.1) Gecko/20100101 Firefox/8.0.1');
$this->assertEquals($this->props->getProperty('testline1'), 'Testline1');
$this->assertEquals($this->props->getProperty('testline2'), 'Testline2');
}
示例2: activarPantalla
public function activarPantalla()
{
$pantallaActual = new Properties();
$pantallaActual->load(file_get_contents("./pantallaActiva.properties"));
$pantallaActual->setProperty("Pantalla.activa", 10);
file_put_contents('./pantallaActiva.properties', $pantallaActual->toString(true));
}
示例3: merge
static function merge($project, $codeCoverageInformation)
{
$database = new PhingFile($project->getProperty('coverage.database'));
$props = new Properties();
$props->load($database);
$coverageTotal = $codeCoverageInformation;
foreach ($coverageTotal as $coverage) {
foreach ($coverage as $filename => $coverageFile) {
$filename = strtolower($filename);
if ($props->getProperty($filename) != null) {
$file = unserialize($props->getProperty($filename));
$left = $file['coverage'];
$right = $coverageFile;
if (!is_array($right)) {
$right = array_shift(PHPUnit_Util_CodeCoverage::bitStringToCodeCoverage(array($right), 1));
}
$coverageMerged = CoverageMerger::mergeCodeCoverage($left, $right);
foreach ($coverageMerged as $key => $value) {
if ($value == -2) {
unset($coverageMerged[$key]);
}
}
$file['coverage'] = $coverageMerged;
$props->setProperty($filename, serialize($file));
}
}
}
$props->store($database);
}
示例4: current
public function current()
{
Timer::start('iterator::' . get_class($this) . '::current');
$content = $this->get_next_record();
$separator = "**********\n";
//split the file at the separator
$meta = substr($content, 0, strpos($content, $separator));
$source = substr(strstr($content, $separator), strlen($separator));
Logger::info($meta);
$fp = fopen($this->currentArticleFile, "w");
fwrite($fp, $meta);
fclose($fp);
$fp = fopen($this->currentArticleFile, "r");
$p = new Properties();
$p->load($fp);
$meta = array();
$names = $p->propertyNames();
foreach ($names as $key) {
$meta[$key] = $p->getProperty($key);
}
fclose($fp);
$source = html_entity_decode($source);
$fp = fopen($this->currentArticleFile, "w");
fwrite($fp, $source);
fclose($fp);
Timer::stop('iterator::' . get_class($this) . '::current');
//$meta['title'] = urldecode($meta['title']);
$meta['pageTitle'] = urldecode($meta['pageTitle']);
$this->key = $meta['pageTitle'];
// return urldecode($pageID);
return $meta;
}
示例5: addPropertiesFile
/**
* Permits an arbitrary number of property files to be added
*/
public function addPropertiesFile($propertiesFile)
{
if (!file_exists($propertiesFile)) {
throw new Exception('Properties file does not exist');
}
$properties = new Properties();
$properties->load(new PhingFile($propertiesFile));
$this->fileProps = array_merge($this->fileProps, $properties->getProperties());
}
示例6: load
public function load($name = null)
{
if ($name == null) {
$name = $this->_confname;
}
if (!file_exists($name)) {
$this->save();
}
parent::load($name);
}
示例7: _getDatabase
/**
* @param Project $project
* @return Properties
* @throws BuildException
*/
protected static function _getDatabase($project)
{
$coverageDatabase = $project->getProperty('coverage.database');
if (!$coverageDatabase) {
throw new BuildException("Property coverage.database is not set - please include coverage-setup in your build file");
}
$database = new PhingFile($coverageDatabase);
$props = new Properties();
$props->load($database);
return $props;
}
示例8: load
public function load($name = null)
{
if (!isset($this->_props)) {
if ($name == null) {
$name = $this->inifile;
}
if (!file_exists($name)) {
$this->save();
}
parent::load($name);
}
}
示例9: merge
static function merge($project, $codeCoverageInformation)
{
$coverageDatabase = $project->getProperty('coverage.database');
if (!$coverageDatabase) {
throw new BuildException("Property coverage.database is not set - please include coverage-setup in your build file");
}
$database = new PhingFile($coverageDatabase);
$props = new Properties();
$props->load($database);
$coverageTotal = $codeCoverageInformation;
foreach ($coverageTotal as $filename => $data) {
if (version_compare(PHPUnit_Runner_Version::id(), '3.5.0') >= 0) {
$ignoreLines = PHP_CodeCoverage_Util::getLinesToBeIgnored($filename);
} else {
// FIXME retrieve ignored lines for PHPUnit Version < 3.5.0
$ignoreLines = array();
}
$lines = array();
$filename = strtolower($filename);
if ($props->getProperty($filename) != null) {
foreach ($data as $_line => $_data) {
if (is_array($_data)) {
$count = count($_data);
} else {
if (isset($ignoreLines[$_line])) {
// line is marked as ignored
$count = 1;
} else {
if ($_data == -1) {
// not executed
$count = -1;
} else {
if ($_data == -2) {
// dead code
$count = -2;
}
}
}
}
$lines[$_line] = $count;
}
ksort($lines);
$file = unserialize($props->getProperty($filename));
$left = $file['coverage'];
$coverageMerged = CoverageMerger::mergeCodeCoverage($left, $lines);
$file['coverage'] = $coverageMerged;
$props->setProperty($filename, serialize($file));
}
}
$props->store($database);
}
示例10: buildFinished
/**
* Sends the mail
*
* @see DefaultLogger#buildFinished
* @param BuildEvent $event
*/
public function buildFinished(BuildEvent $event)
{
parent::buildFinished($event);
$project = $event->getProject();
$properties = $project->getProperties();
$filename = $properties['phing.log.mail.properties.file'];
// overlay specified properties file (if any), which overrides project
// settings
$fileProperties = new Properties();
$file = new PhingFile($filename);
try {
$fileProperties->load($file);
} catch (IOException $ioe) {
// ignore because properties file is not required
}
foreach ($fileProperties as $key => $value) {
$properties['key'] = $project->replaceProperties($value);
}
$success = $event->getException() === null;
$prefix = $success ? 'success' : 'failure';
try {
$notify = StringHelper::booleanValue($this->getValue($properties, $prefix . '.notify', 'on'));
if (!$notify) {
return;
}
if (is_string(Phing::getDefinedProperty('phing.log.mail.subject'))) {
$defaultSubject = Phing::getDefinedProperty('phing.log.mail.subject');
} else {
$defaultSubject = $success ? 'Build Success' : 'Build Failure';
}
$hdrs = array();
$hdrs['From'] = $this->getValue($properties, 'from', $this->from);
$hdrs['Reply-To'] = $this->getValue($properties, 'replyto', '');
$hdrs['Cc'] = $this->getValue($properties, $prefix . '.cc', '');
$hdrs['Bcc'] = $this->getValue($properties, $prefix . '.bcc', '');
$hdrs['Body'] = $this->getValue($properties, $prefix . '.body', '');
$hdrs['Subject'] = $this->getValue($properties, $prefix . '.subject', $defaultSubject);
$tolist = $this->getValue($properties, $prefix . '.to', $this->tolist);
} catch (BadMethodCallException $e) {
$project->log($e->getMessage(), Project::MSG_WARN);
}
if (empty($tolist)) {
return;
}
$mail = Mail::factory('mail');
$mail->send($tolist, $hdrs, $this->mailMessage);
}
示例11: merge
static function merge($project, $codeCoverageInformation)
{
$database = new PhingFile($project->getProperty('coverage.database'));
$props = new Properties();
$props->load($database);
$coverageTotal = $codeCoverageInformation;
foreach ($coverageTotal as $coverage) {
foreach ($coverage as $filename => $coverageFile) {
$filename = strtolower($filename);
if ($props->getProperty($filename) != null) {
$file = unserialize($props->getProperty($filename));
$left = $file['coverage'];
$right = $coverageFile;
$coverageMerged = CoverageMerger::mergeCodeCoverage($left, $right);
$file['coverage'] = $coverageMerged;
$props->setProperty($filename, serialize($file));
}
}
}
$props->store($database);
}
示例12: merge
static function merge($project, $codeCoverageInformation)
{
$coverageDatabase = $project->getProperty('coverage.database');
if (!$coverageDatabase) {
throw new BuildException("Property coverage.database is not set - please include coverage-setup in your build file");
}
$database = new PhingFile($coverageDatabase);
$props = new Properties();
$props->load($database);
$coverageTotal = $codeCoverageInformation;
foreach ($coverageTotal as $filename => $data) {
$lines = array();
$filename = strtolower($filename);
if ($props->getProperty($filename) != null) {
foreach ($data as $_line => $_data) {
if (is_array($_data)) {
$count = count($_data);
} else {
if ($_data == -1) {
// not executed
$count = -1;
} else {
if ($_data == -2) {
// dead code
$count = -2;
}
}
}
$lines[$_line] = $count;
}
ksort($lines);
$file = unserialize($props->getProperty($filename));
$left = $file['coverage'];
$coverageMerged = CoverageMerger::mergeCodeCoverage($left, $lines);
$file['coverage'] = $coverageMerged;
$props->setProperty($filename, serialize($file));
}
}
$props->store($database);
}
示例13: createSqlDbMap
/**
* Create the sql -> database map.
*
* @throws IOException - if unable to store properties
*/
protected function createSqlDbMap()
{
if ($this->getSqlDbMap() === null) {
return;
}
// Produce the sql -> database map
$sqldbmap = new Properties();
// Check to see if the sqldbmap has already been created.
if ($this->getSqlDbMap()->exists()) {
$sqldbmap->load($this->getSqlDbMap());
}
if ($this->packageObjectModel) {
// in this case we'll get the sql file name from the package attribute
$dataModels = $this->packageDataModels();
foreach ($dataModels as $package => $dataModel) {
foreach ($dataModel->getDatabases() as $database) {
$name = ($package ? $package . '.' : '') . 'schema.xml';
$sqlFile = $this->getMappedFile($name);
$sqldbmap->setProperty($sqlFile->getName(), $database->getName());
}
}
} else {
// the traditional way is to map the schema.xml filenames
$dmMap = $this->getDataModelDbMap();
foreach (array_keys($dmMap) as $dataModelName) {
$sqlFile = $this->getMappedFile($dataModelName);
if ($this->getDatabase() === null) {
$databaseName = $dmMap[$dataModelName];
} else {
$databaseName = $this->getDatabase();
}
$sqldbmap->setProperty($sqlFile->getName(), $databaseName);
}
}
try {
$sqldbmap->store($this->getSqlDbMap(), "Sqlfile -> Database map");
} catch (IOException $e) {
throw new IOException("Unable to store properties: " . $e->getMessage());
}
}
示例14: main
/**
* Executes the task.
*/
public function main()
{
if ($this->file === null) {
throw new BuildException('The file attribute must be set');
}
$properties = new Properties();
if ($this->update === true) {
/* Load existing properties. */
try {
$properties->load($this->file);
} catch (IOException $ioe) {
/* File doesn't exist or isn't readable, so don't worry here. */
}
}
/* Add new properties. */
foreach ($this->properties as $property) {
foreach ($property->resolve()->getProperties() as $name => $value) {
$properties->setProperty($name, $value);
}
}
$properties->store($this->file, 'Automatically-updated properties file ' . 'generated by the Agavi write-properties task');
}
示例15: getFolderList
function getFolderList($root)
{
$curdir = getcwd();
chdir($root);
$filelist = safe_glob('*');
$list = array();
foreach ($filelist as $file) {
if (is_dir($file) && $file != '.' && $file != '..') {
$internal = filesystemToInternal($file);
if (!file_exists("{$root}/{$file}/persona.properties")) {
continue;
}
$props = new Properties();
$props->load(file_get_contents("{$root}/{$file}/persona.properties"));
$name = $props->getProperty('name');
if (!isset($name)) {
continue;
}
$list[$name] = $internal;
}
}
chdir($curdir);
return $list;
}