本文整理汇总了PHP中Properties::setProperty方法的典型用法代码示例。如果您正苦于以下问题:PHP Properties::setProperty方法的具体用法?PHP Properties::setProperty怎么用?PHP Properties::setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Properties
的用法示例。
在下文中一共展示了Properties::setProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
示例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: 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;
}
示例4: 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);
}
示例5: 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'));
}
示例6: 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());
}
}
示例7: 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');
}
示例8: 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);
}
示例9: _addNode
/**
* Adds an XML node
*
* @param SimpleXMLElement $node
* @param array $path Path to this node
* @param Properties $prop Properties will be added as they are found (by reference here)
*
* @return void
*/
protected function _addNode($node, $path, $prop)
{
foreach ($node as $tag => $value) {
$prefix = implode('.', $path);
// Check for attributes
foreach ($value->attributes() as $attribute => $val) {
if ($this->_collapseAttr) {
$prop->setProperty($prefix . ".{$attribute}", (string) $val);
} else {
$prop->setProperty($prefix . "({$attribute})", (string) $val);
}
}
//echo "\r\nCHILDREN ". count($value->children()). is_array($value);
// Add tag
if (count($value->children())) {
//echo "\r\nOBJECT $prefix.$tag ";
$path[] = $tag;
$this->_addNode($value, $path, $prop);
} else {
//echo "\r\nADD $prefix.$tag";
$val = (string) $value;
/* Check for * and ** on 'exclude' and 'include' tag / ant seems to do this? could use FileSet here
if($tag == 'exclude') {
}*/
// When property already exists, i.e. multiple xml tag
// <project>
// <exclude>file/a.php</exclude>
// <exclude>file/a.php</exclude>
// </project>
//
// Would be come project.exclude = file/a.php,file/a.php
$p = empty($prefix) ? $tag : $prefix . ".{$tag}";
$prop->append($p, (string) $val, $this->_delimiter);
}
}
}
示例10: uploadimageAction
public function uploadimageAction()
{
// Where we come from
$source = $this->_getParam('source');
// Verify that it is authorized
if (!in_array($source, array('design', 'profile'))) {
throw new Stuffpress_Exception("Invalid source specified {$source}");
}
// What are we uploading
$image = $this->_getParam('image');
$property = "{$image}_image";
// Was a file uploaded ?
if (!isset($_FILES['file'])) {
$this->addErrorMessage('Upload failed: no files received on server end.');
return $this->_forward('index', $source, 'admin');
}
// Validate the uploaded file
$tmp_file = $_FILES['file']['tmp_name'];
$file_name = basename($_FILES['file']['name']);
$file_type = $_FILES['file']['type'];
$file_ext = substr(trim(substr($file_name, strrpos($file_name, '.')), '.'), 0, 4);
// returns the ext only
// Check file size
if ($_SERVER['CONTENT_LENGTH'] > 2000000) {
$this->addErrorMessage('Upload failed: your file size is above 2Mbytes.');
return $this->_forward('index', $source, 'admin');
}
// Check file extension
if (!in_array(strtolower($file_ext), array("gif", "jpg", "png", "jpeg"))) {
$this->addErrorMessage('Upload failed: we only support jpg, gif and png files.');
return $this->_forward('index', $source, 'admin');
}
// Assign a random name to the file
$key = Stuffpress_Token::create(32);
$root = Zend_Registry::get("root");
$uploaddir = $root . "/upload/";
$uploadfile = $uploaddir . '/' . $key;
// Move the file to the upload folder
if (!move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
$this->addErrorMessage('Upload failed: your file size is above 2Mbytes.');
return $this->_forward('index', $source, 'admin');
}
// Store the file in the database
$files = new Files(array(Stuffpress_Db_Table::USER => $this->_application->user->id));
$file_id = $files->addFile($key, $file_name, "Lifestream custom image", $file_type, $file_ext);
// Build a thumbnail of the file
try {
$files->fitSquare($file_id, 75, 'thumbnails');
} catch (Exception $e) {
$message = $e->getMessage();
$this->addErrorMessage("Upload failed: could not process image ({$message})");
$files->deleteFile($key);
return $this->_forward('index', $source, 'admin');
}
// Replace the user property with the new file and delete the older one
$properties = new Properties(array(Properties::KEY => $this->_application->user->id));
$old_file = $properties->getProperty($property);
$properties->setProperty($property, $key);
if ($old_file) {
$files->deleteFile($old_file);
}
// If we are here, everything went smooth
$this->addStatusMessage('Your file was successfully uploaded');
return $this->_forward('index', $source, 'admin');
}
示例11: resolveAllProperties
/**
* Given a Properties object, this method goes through and resolves
* any references to properties within the object.
*
* @param Properties $props The collection of Properties that need to be resolved.
* @throws BuildException
* @return void
*/
protected function resolveAllProperties(Properties $props)
{
foreach ($props->keys() as $name) {
// There may be a nice regex/callback way to handle this
// replacement, but at the moment it is pretty complex, and
// would probably be a lot uglier to work into a preg_replace_callback()
// system. The biggest problem is the fact that a resolution may require
// multiple passes.
$value = $props->getProperty($name);
$resolved = false;
$resolveStack = array();
while (!$resolved) {
$fragments = array();
$propertyRefs = array();
// [HL] this was ::parsePropertyString($this->value ...) ... this seems wrong
self::parsePropertyString($value, $fragments, $propertyRefs);
$resolved = true;
if (count($propertyRefs) == 0) {
continue;
}
$sb = "";
$j = $propertyRefs;
foreach ($fragments as $fragment) {
if ($fragment !== null) {
$sb .= $fragment;
continue;
}
$propertyName = array_shift($j);
if (in_array($propertyName, $resolveStack)) {
// Should we maybe just log this as an error & move on?
// $this->log("Property ".$name." was circularly defined.", Project::MSG_ERR);
throw new BuildException("Property " . $propertyName . " was circularly defined.");
}
$fragment = $this->getProject()->getProperty($propertyName);
if ($fragment !== null) {
$sb .= $fragment;
continue;
}
if ($props->containsKey($propertyName)) {
$fragment = $props->getProperty($propertyName);
if (strpos($fragment, '${') !== false) {
$resolveStack[] = $propertyName;
$resolved = false;
// parse again (could have been replaced w/ another var)
}
} else {
$fragment = "\${" . $propertyName . "}";
}
$sb .= $fragment;
}
$this->log("Resolved Property \"{$value}\" to \"{$sb}\"", Project::MSG_DEBUG);
$value = $sb;
$props->setProperty($name, $value);
}
// while (!$resolved)
}
// while (count($keys)
}
示例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) {
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);
}
示例13: createDataDbMap
/**
* Create the data XML -> database map.
*
* This is necessary because there is currently no other method of knowing which
* data XML files correspond to which database. This map allows us to convert multiple
* data XML files into SQL.
*
* @throws IOException - if unable to store properties
*/
private function createDataDbMap()
{
if ($this->getDataDbMap() === null) {
return;
}
// Produce the sql -> database map
$datadbmap = new Properties();
// Check to see if the sqldbmap has already been created.
if ($this->getDataDbMap()->exists()) {
$datadbmap->load($this->getDataDbMap());
}
foreach ($this->getDataModels() as $dataModel) {
// there is really one 1 db per datamodel
foreach ($dataModel->getDatabases() as $database) {
// if database name is specified, then we only want to dump that one db.
if (empty($this->databaseName) || $this->databaseName && $database->getName() == $this->databaseName) {
$outFile = $this->getMappedFile($dataModel->getName());
$datadbmap->setProperty($outFile->getName(), $database->getName());
}
}
}
try {
$datadbmap->store($this->getDataDbMap(), "Data XML file -> Database map");
} catch (IOException $e) {
throw new IOException("Unable to store properties: " . $e->getMessage());
}
}
示例14: activarPantalla
/**
*
*
* @return
* @access public
*/
public function activarPantalla($id_pantalla = 2)
{
$pantallaActual = new Properties();
$pantallaActual->load(file_get_contents("./pantallaActiva.properties"));
$pantallaActual->setProperty("Pantalla.activa", $id_pantalla);
file_put_contents('./pantallaActiva.properties', $pantallaActual->toString(true));
// $this->pantalla_activa=$pantalla;
}
示例15: main
function main()
{
$files = $this->getFilenames();
$this->log("Setting up coverage database for " . count($files) . " files");
$props = new Properties();
foreach ($files as $file) {
$fullname = $file['fullname'];
$filename = $file['key'];
$props->setProperty($filename, serialize(array('fullname' => $fullname, 'coverage' => array())));
}
$dbfile = new PhingFile($this->database);
$props->store($dbfile);
$this->project->setProperty('coverage.database', $dbfile->getAbsolutePath());
foreach ($files as $file) {
$fullname = $file['fullname'];
xdebug_start_code_coverage(XDEBUG_CC_UNUSED);
Phing::__import($fullname, $this->classpath);
$coverage = xdebug_get_code_coverage();
xdebug_stop_code_coverage();
CoverageMerger::merge($this->project, array($coverage));
}
}