本文整理汇总了PHP中Properties::getProperty方法的典型用法代码示例。如果您正苦于以下问题:PHP Properties::getProperty方法的具体用法?PHP Properties::getProperty怎么用?PHP Properties::getProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Properties
的用法示例。
在下文中一共展示了Properties::getProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction()
{
// Get, check and setup the parameters
if (!($widget_id = $this->getRequest()->getParam("id"))) {
throw new Stuffpress_Exception("No widget id provided to the widget controller");
}
// Verify if the requested widget exist and get its data
$widgets = new Widgets();
if (!($widget = $widgets->getWidget($widget_id))) {
throw new Stuffpress_Exception("Invalid widget id");
}
// Get the user
$users = new Users();
$user = $users->getUser($widget['user_id']);
// Get all sources configured for that user
$properties = new Properties(array(Properties::KEY => $user->id));
// Get the bio data
// User profile
$this->view->username = $user->username;
$this->view->first_name = $properties->getProperty('first_name');
$this->view->last_name = $properties->getProperty('last_name');
$this->view->bio = $properties->getProperty('bio');
$this->view->location = $properties->getProperty('location');
$this->view->avatar = $properties->getProperty('avatar_image');
// Get the widget properties
$properties = new WidgetsProperties(array(Properties::KEY => $widget_id));
$title = $properties->getProperty('title');
$this->view->title = $title ? $title : "About {$user->username}";
}
示例2: 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);
}
示例3: 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);
}
示例4: 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');
}
示例5: 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;
}
示例6: 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;
}
示例7: assignConfiguration
/**
* Assign the configuration of this Manager. Valid configuration options are as
* follows:
* default_language string (ex: 'en_US')
* applications array of strings (
* application_name => language_file_directory,
* ...,
* ...,
* )
*
*
* @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)
{
$this->_configuration = $configuration;
ArgumentValidator::validate($configuration->getProperty('default_language'), StringValidatorRule::getRule(), true);
ArgumentValidator::validate($configuration->getProperty('applications'), ArrayValidatorRule::getRule(), true);
// Get the current Language settings from the session if they exist.
if (isset($_SESSION['__CurrentLanguage'])) {
$this->setLanguage($_SESSION['__CurrentLanguage']);
} else {
$this->setLanguage($configuration->getProperty('default_language'));
}
foreach ($configuration->getProperty('applications') as $application => $languageDir) {
ArgumentValidator::validate($application, StringValidatorRule::getRule(), true);
ArgumentValidator::validate($languageDir, StringValidatorRule::getRule(), true);
$this->addApplication($application, $languageDir);
}
}
示例8: 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;
}
示例9: 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;
}
示例10: assignConfiguration
/**
* Assign the configuration of this Manager. Valid configuration options are as
* follows:
* database_index integer
* database_name string
* default_theme object Theme
*
* @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)
{
$this->_configuration = $configuration;
$dbIndex = $configuration->getProperty('database_index');
$dbName = $configuration->getProperty('database_name');
$theme = $configuration->getProperty('default_theme');
$id = $configuration->getProperty('default_state_id');
$arrayOfDefaultThemes = $configuration->getProperty('array_of_default_themes');
// ** parameter validation
ArgumentValidator::validate($dbIndex, IntegerValidatorRule::getRule(), true);
ArgumentValidator::validate($theme, ExtendsValidatorRule::getRule("ThemeInterface"), true);
ArgumentValidator::validate($arrayOfDefaultThemes, ArrayValidatorRule::getRule(), true);
// ** end of parameter validation
$this->_dbName = $dbName;
$this->_dbIndex = $dbIndex;
$this->_themeList = $arrayOfDefaultThemes;
$this->setTheme($theme);
}
示例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: 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);
}
示例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: 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);
}
示例15: indexAction
public function indexAction()
{
// Get, check and setup the parameters
if (!($widget_id = $this->getRequest()->getParam("id"))) {
throw new Stuffpress_Exception("No widget id provided to the widget controller");
}
// Verify if the requested widget exist and get its data
$widgets = new Widgets();
if (!($widget = $widgets->getWidget($widget_id))) {
throw new Stuffpress_Exception("Invalid widget id");
}
// Get the user
$users = new Users();
$user = $users->getUser($widget['user_id']);
// Get all sources configured for that user
$properties = new Properties(array(Properties::KEY => $user->id));
// Get the friendconnect data
$this->view->googlefc = $properties->getProperty('googlefc');
// Get the widget properties
$properties = new WidgetsProperties(array(Properties::KEY => $widget_id));
$title = $properties->getProperty('title');
$this->view->title = $title;
}