本文整理汇总了PHP中Properties类的典型用法代码示例。如果您正苦于以下问题:PHP Properties类的具体用法?PHP Properties怎么用?PHP Properties使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Properties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assignConfiguration
/**
* Stores the configuration. Calls the parent configuration first,
* then does additional operations.
*
* @param object Properties $configuration
* @return object
* @access public
* @since 3/24/05
*/
function assignConfiguration(Properties $configuration)
{
// Set the configuration values to our custom values.
$configuration->addProperty('authentication_table', 'auth_visitor');
$configuration->addProperty('username_field', 'email');
$configuration->addProperty('password_field', 'password');
$propertiesFields = array('name' => 'display_name', 'email' => 'email');
$configuration->addProperty('properties_fields', $propertiesFields);
try {
ArgumentValidator::validate($configuration->getProperty('email_from_name'), NonzeroLengthStringValidatorRule::getRule());
} catch (InvalidArgumentException $e) {
throw new ConfigurationErrorException("'email_from_name' must be a string. " . $e->getMessage());
}
try {
ArgumentValidator::validate($configuration->getProperty('email_from_address'), RegexValidatorRule::getRule('/^.+@.+$/'));
} catch (InvalidArgumentException $e) {
throw new ConfigurationErrorException("'email_from_address' must be an email address. " . $e->getMessage());
}
try {
ArgumentValidator::validate($configuration->getProperty('domain_blacklist'), OptionalRule::getRule(ArrayValidatorRuleWithRule::getRule(NonzeroLengthStringValidatorRule::getRule())));
ArgumentValidator::validate($configuration->getProperty('domain_whitelist'), OptionalRule::getRule(ArrayValidatorRuleWithRule::getRule(NonzeroLengthStringValidatorRule::getRule())));
} catch (InvalidArgumentException $e) {
throw new ConfigurationErrorException("'domain_blacklist' and 'domain_whitelist' if specified must be arrays of domain name strings. " . $e->getMessage());
}
parent::assignConfiguration($configuration);
}
示例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: 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;
}
示例4: 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);
}
示例5: assignConfiguration
/**
* Assign the configuration of this Manager. There are no valid configuration options for
* this manager.
*
* @param object Properties $configuration (original type: java.util.Properties)
*
* @throws object OsidException An exception with one of the following
* messages defined in org.osid.OsidException: {@link
* org.osid.OsidException#OPERATION_FAILED OPERATION_FAILED},
* {@link org.osid.OsidException#PERMISSION_DENIED
* PERMISSION_DENIED}, {@link
* org.osid.OsidException#CONFIGURATION_ERROR
* CONFIGURATION_ERROR}, {@link
* org.osid.OsidException#UNIMPLEMENTED UNIMPLEMENTED}, {@link
* org.osid.OsidException#NULL_ARGUMENT NULL_ARGUMENT}
*
* @access public
*/
function assignConfiguration(Properties $configuration)
{
$def = $configuration->getProperty('default_authority');
// ** parameter validation
ArgumentValidator::validate($def, StringValidatorRule::getRule(), true);
// ** end of parameter validation
$this->_defaultAuthority = $def;
}
示例6: propertiesJsonQuery
public function propertiesJsonQuery($string)
{
$propertiesClient = new Properties();
if (!$this->validateProperties($string)) {
return "";
}
$response = $propertiesClient->find($string);
return $response;
}
示例7: assignConfiguration
/**
* Assigns the configuration of databases etc.
*
* @param object $configuration
*
* @access public
*
* @return void
*/
function assignConfiguration(Properties $configuration)
{
$this->_configuration = $configuration;
$dbIndex = $configuration->getProperty('database_index');
// ** parameter validation
ArgumentValidator::validate($dbIndex, IntegerValidatorRule::getRule(), true);
// ** end of parameter validation
$this->_dbIndex = $dbIndex;
}
示例8: getDetailed
public function getDetailed($criterion = null)
{
$Properties = new Properties();
$featured_properties = $this->get($criterion);
foreach ($featured_properties as &$featured_property) {
$featured_property = $Properties->get($featured_property->property_id);
}
return $featured_properties;
}
示例9: _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;
}
示例10: resolve
/**
* Retrieves the new property or properties.
*
* @return Properties The list of properties.
*/
public function resolve()
{
if ($this->name === null) {
throw new BuildException('The name attribute must be specified');
}
if ($this->value === null) {
throw new BuildException('The value attribute must be specified');
}
$properties = new Properties();
$properties->setProperty($this->name, $this->value);
return $properties;
}
示例11: forUser
public static function forUser($id)
{
$properties = new Properties(array(Properties::KEY => $id));
$sources = new Sources(array(Stuffpress_Db_Table::USER => $id));
$source_id = $properties->getProperty('stuffpress_source');
if (!$source_id) {
$source_id = $sources->addSource('stuffpress');
$sources->setImported($source_id, 1);
$properties->setProperty('stuffpress_source', $source_id);
}
$source = $sources->getSource($source_id);
return new StuffpressModel($source);
}
示例12: testMergePropertiesWithSameKeyAndOverride
/**
* Test's the merge() method with two properties instances containing the same key
* and the override flag has been passed.
*
* @return void
*/
public function testMergePropertiesWithSameKeyAndOverride()
{
// initialize the properties
$properties = new Properties();
$properties->setProperty('foo', '${bar}');
// initialize the properties to be merged
$propertiesToMerge = new Properties();
$propertiesToMerge->setProperty('foo', 'bar');
// merge the properties
$properties->mergeProperties($propertiesToMerge, true);
// assert that the results are as expected
$this->assertSame('bar', $properties->getProperty('foo'));
}
示例13: 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);
}
示例14: signupAction
public function signupAction()
{
if (!$this->getRequest()->isPost()) {
$this->addErrorMessage("Form was not properly posted.");
$this->_forward('index');
}
// Retrieve the form values and its values
$form = $this->getForm();
$valid = $form->isValid($_POST);
$values = $form->getValues();
$username = $values['username'];
$email = $values['email'];
$password = $values['password'];
// Validate the form itself
if (!$form->isValid($_POST)) {
// Failed validation; redisplay form
$this->view->form = $form;
$this->addErrorMessage("Your form contains some errors, please correct them and submit this form again");
return $this->_forward('register');
}
// Register user
$users = new Users();
$user = $users->addUser($username, $password, $email);
// Add some default widgets to the user
$widgets = new Widgets(array(Stuffpress_Db_Table::USER => $user->id));
$widgets->addWidget('search');
$widgets->addWidget('rsslink');
$widgets->addWidget('links');
$widgets->addWidget('lastcomments');
$widgets->addWidget('archives');
$widgets->addWidget('logo');
// Add some default properties
$properties = new Properties(array(Stuffpress_Db_Properties::KEY => $user->id));
$properties->setProperty('theme', 'clouds');
$properties->setProperty('title', ucfirst($username));
$properties->setProperty('subtitle', "my life online");
// Add the storytlr data source
StuffpressModel::forUser($user->id);
// Add default pages
$pages = new Pages(array(Stuffpress_Db_Table::USER => $user->id));
//$pages->addPage('dashboard', 'Home');
$pages->addPage('lifestream', 'Stream');
$pages->addPage('stories', 'Stories');
// Send the user a verification email
Stuffpress_Emails::sendWelcomeEmail($email, $username, $password, $user->token);
// Done !
$this->view->username = $username;
$this->view->email = $email;
$this->render('success');
}
示例15: updateData
public function updateData($import = false)
{
// Get service propertie
$config = Zend_Registry::get("configuration");
$pages = $import ? 50 : 1;
$count = $import ? 200 : 50;
// Get application properties
$app_properties = new Properties(array(Stuffpress_Db_Properties::KEY => Zend_Registry::get("shard")));
// Get twitter user properties
$username = $this->getProperty('username');
$uid = $this->getProperty('uid', 0);
if (!$username) {
throw new Stuffpress_Exception("Update failed, connector not properly configured");
}
// Get twitter consumer tokens and user secrets
$consumer_key = $config->twitter->consumer_key;
$consumer_secret = $config->twitter->consumer_secret;
$oauth_token = $app_properties->getProperty('twitter_oauth_token');
$oauth_token_secret = $app_properties->getProperty('twitter_oauth_token_secret');
if (!$consumer_key || !$consumer_secret || !$oauth_token || !$oauth_token_secret) {
throw new Stuffpress_Exception("Missing twitter credentials. Please configure your twitter account in the <a href='/admin/sns/'>Configure -> Social Networks</a> section.");
}
// Fetch the data from twitter
$result = array();
$connection = new TwitterOAuth_Client($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
$connection->host = "https://api.twitter.com/1.1/";
$max_id = false;
$params = array('screen_name' => $username, 'count' => $count);
for ($page = 1; $page <= $pages; $page++) {
if ($max_id) {
$params['max_id'] = $max_id;
}
$response = $connection->get('statuses/user_timeline', $params);
if ($response && isset($response->errors) && count($response->errors) > 0) {
throw new Stuffpress_Exception($response->errors[0]->message);
}
if (count($response) == 0) {
break;
}
$max_id = $response[count($response) - 1]->id_str;
$items = $this->processItems($response);
if (count($items) == 0) {
break;
}
$result = array_merge($result, $items);
}
// Mark as updated (could have been with errors)
$this->markUpdated();
return $result;
}