Пример #1
0
 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
0
 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
0
 /**
  * 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
0
 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);
 }
 /**
  * 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
0
 /**
  * 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());
     }
 }
 /**
  * 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
0
 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
0
 /**
  * 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
0
 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');
 }
 /**
  * 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
0
 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
0
 /**
  * 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
0
 /**
  *
  *
  * @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
0
 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));
     }
 }
Пример #16
0
 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);
 }
Пример #17
0
 function main()
 {
     /**
      * Whitelist files when using PHPUnit > 3.5
      */
     @(include_once 'PHPUnit/Runner/Version.php');
     if (version_compare(PHPUnit_Runner_Version::id(), '3.5.0') >= 0) {
         $newFilter = true;
     } else {
         $newFilter = false;
         @(include_once 'PHPUnit/Util/Filter.php');
     }
     $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())));
         if ($newFilter) {
             PHP_CodeCoverage_Filter::getInstance()->addFileToWhiteList($file['fullname']);
         } else {
             PHPUnit_Util_Filter::addFileToWhitelist($file['fullname']);
         }
     }
     $dbfile = new PhingFile($this->database);
     $props->store($dbfile);
     $this->project->setProperty('coverage.database', $dbfile->getAbsolutePath());
 }
 /**
  * load the environment values
  *
  * @param string $prefix prefix to place before them
  */
 protected function loadEnvironment($prefix)
 {
     $props = new Properties();
     if (substr($prefix, strlen($prefix) - 1) == '.') {
         $prefix .= ".";
     }
     $this->log("Loading Environment {$prefix}", Project::MSG_VERBOSE);
     foreach ($_ENV as $key => $value) {
         $props->setProperty($prefix . '.' . $key, $value);
     }
     $this->addProperties($props);
 }
Пример #19
0
 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);
 }
Пример #20
0
 /**
  * Main method parses the XML files and creates SQL files.
  *
  * @return void
  * @throws Exception If there is an error parsing the data xml.
  */
 public function main()
 {
     $this->validate();
     $targetDatabase = $this->getTargetDatabase();
     $platform = $this->getPlatformForTargetDatabase();
     // Load the Data XML -> DB Name properties
     $map = new Properties();
     try {
         $map->load($this->getDataDbMap());
     } catch (IOException $ioe) {
         throw new BuildException("Cannot open and process the datadbmap!", $ioe);
     }
     DataModelBuilder::setBuildProperties($this->getPropelProperties());
     // Parse each file in teh data -> db map
     foreach ($map->keys() as $dataXMLFilename) {
         $dataXMLFile = new PhingFile($this->srcDir, $dataXMLFilename);
         // if file exists then proceed
         if ($dataXMLFile->exists()) {
             $dbname = $map->get($dataXMLFilename);
             $db = $this->getDatabase($dbname);
             if (!$db) {
                 throw new BuildException("Cannot find instantiated Database for name '{$dbname}' from datadbmap file.");
             }
             $db->setPlatform($platform);
             $outFile = $this->getMappedFile($dataXMLFilename);
             $this->log("Creating SQL from XML data dump file: " . $dataXMLFile->getAbsolutePath());
             try {
                 $dataXmlParser = new XmlToData($db, $this->dbEncoding);
                 $data = $dataXmlParser->parseFile($dataXMLFile->getAbsolutePath());
             } catch (Exception $e) {
                 throw new Exception("Exception parsing data XML: " . $e->getMessage());
             }
             $fp = fopen($outFile->getAbsolutePath(), 'w');
             $currTable = null;
             foreach ($data as $dataRow) {
                 if ($currTable !== $dataRow->getTable()) {
                     $currTable = $dataRow->getTable();
                     $builder = DataModelBuilder::builderFactory($currTable, 'datasql');
                 }
                 $sql = $builder->buildRowSql($dataRow);
                 fwrite($fp, $sql);
             }
             fclose($fp);
             // Place the generated SQL file(s)
             $p = new Properties();
             if ($this->getSqlDbMap()->exists()) {
                 $p->load($this->getSqlDbMap());
             }
             $p->setProperty($outFile->getName(), $db->getName());
             $p->store($this->getSqlDbMap(), "Sqlfile -> Database map");
         } else {
             $this->log("File '" . $dataXMLFile->getAbsolutePath() . "' in datadbmap does not exist, so skipping it.", PROJECT_MSG_WARN);
         }
     }
     // foreach data xml file
 }
 /**
  * Main method parses the XML files and creates SQL files.
  *
  * @return void
  * @throws Exception      If there is an error parsing the data xml.
  * @throws BuildException
  */
 public function main()
 {
     $this->validate();
     $targetDatabase = $this->getTargetDatabase();
     $platform = $this->getGeneratorConfig()->getConfiguredPlatform();
     // Load the Data XML -> DB Name properties
     $map = new Properties();
     try {
         $map->load($this->getDataDbMap());
     } catch (IOException $ioe) {
         throw new BuildException("Cannot open and process the datadbmap!", $ioe);
     }
     // Parse each file in the data -> db map
     foreach ($map->keys() as $dataXMLFilename) {
         $dataXMLFile = new PhingFile($this->srcDir, $dataXMLFilename);
         // if file exists then proceed
         if ($dataXMLFile->exists()) {
             $dbname = $map->get($dataXMLFilename);
             $db = $this->getDatabase($dbname);
             if (!$db) {
                 throw new BuildException("Cannot find instantiated Database for name '{$dbname}' from datadbmap file.");
             }
             $db->setPlatform($platform);
             $outFile = $this->getMappedFile($dataXMLFilename);
             $sqlWriter = new FileWriter($outFile);
             $this->log("Creating SQL from XML data dump file: " . $dataXMLFile->getAbsolutePath());
             try {
                 $dataXmlParser = new XmlToDataSQL($db, $this->getGeneratorConfig(), $this->dbEncoding);
                 $dataXmlParser->transform($dataXMLFile, $sqlWriter);
             } catch (Exception $e) {
                 throw new BuildException("Exception parsing data XML: " . $e->getMessage(), $x);
             }
             // Place the generated SQL file(s)
             $p = new Properties();
             if ($this->getSqlDbMap()->exists()) {
                 $p->load($this->getSqlDbMap());
             }
             $p->setProperty($outFile->getName(), $db->getName());
             $p->store($this->getSqlDbMap(), "Sqlfile -> Database map");
         } else {
             $this->log("File '" . $dataXMLFile->getAbsolutePath() . "' in datadbmap does not exist, so skipping it.", Project::MSG_WARN);
         }
     }
     // foreach data xml file
 }
Пример #22
0
 /**
  * This sets a property that was set via command line or otherwise passed into Phing.
  *
  * @param string $name
  * @return string value of found property (or null, if none found).
  */
 public static function setDefinedProperty($name, $value)
 {
     return self::$definedProps->setProperty($name, $value);
 }
 /**
  *  Send the key/value pairs in the hashtable to the given output stream.
  *  Only those properties matching the <tt>prefix</tt> constraint will be
  *  sent to the output stream.
  *  The output stream will be closed when this method returns.
  *
  * @param  array        $allProps propfile to save
  * @param  OutputStream $os       output stream
  *
  * @throws IOException      on output errors
  * @throws BuildException   on other errors
  */
 protected function saveProperties($allProps, $os)
 {
     ksort($allProps);
     $props = new Properties();
     if ($this->regex !== '') {
         $a = new ArrayIterator($allProps);
         $i = new RegexIterator($a, $this->regex, RegexIterator::MATCH, RegexIterator::USE_KEY);
         $allProps = iterator_to_array($i);
     }
     if ($this->prefix !== '') {
         $a = new ArrayIterator($allProps);
         $i = new RegexIterator($a, '~^' . preg_quote($this->prefix, '~') . '.*~', RegexIterator::MATCH, RegexIterator::USE_KEY);
         $allProps = iterator_to_array($i);
     }
     foreach ($allProps as $name => $value) {
         $props->setProperty($name, $value);
     }
     if ($this->format === "text") {
         $this->textSaveProperties($props, $os, "Phing properties");
     } elseif ($this->format === "xml") {
         $this->xmlSaveProperties($props, $os);
     }
 }
Пример #24
0
 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());
 }