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
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
 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
0
 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
0
 /**
  * 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
0
 public function load($name = null)
 {
     if ($name == null) {
         $name = $this->_confname;
     }
     if (!file_exists($name)) {
         $this->save();
     }
     parent::load($name);
 }
 /**
  * @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
0
 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
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);
 }
Пример #10
0
 /**
  * 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
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);
 }
Пример #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) {
         $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
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');
 }
Пример #15
0
 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;
 }
Пример #16
0
 /**
  * Setup/initialize Phing environment from commandline args.
  *
  * @param  array $args commandline args passed to phing shell.
  *
  * @throws ConfigurationException
  *
  * @return void
  */
 public function execute($args)
 {
     self::$definedProps = new Properties();
     $this->searchForThis = null;
     // 1) First handle any options which should always
     // Note: The order in which these are executed is important (if multiple of these options are specified)
     if (in_array('-help', $args) || in_array('-h', $args)) {
         $this->printUsage();
         return;
     }
     if (in_array('-version', $args) || in_array('-v', $args)) {
         $this->printVersion();
         return;
     }
     if (in_array('-diagnostics', $args)) {
         Diagnostics::doReport(new PrintStream(self::$out));
         return;
     }
     // 2) Next pull out stand-alone args.
     // Note: The order in which these are executed is important (if multiple of these options are specified)
     if (false !== ($key = array_search('-quiet', $args, true)) || false !== ($key = array_search('-q', $args, true))) {
         self::$msgOutputLevel = Project::MSG_WARN;
         unset($args[$key]);
     }
     if (false !== ($key = array_search('-emacs', $args, true)) || false !== ($key = array_search('-e', $args, true))) {
         $this->emacsMode = true;
         unset($args[$key]);
     }
     if (false !== ($key = array_search('-verbose', $args, true))) {
         self::$msgOutputLevel = Project::MSG_VERBOSE;
         unset($args[$key]);
     }
     if (false !== ($key = array_search('-debug', $args, true))) {
         self::$msgOutputLevel = Project::MSG_DEBUG;
         unset($args[$key]);
     }
     if (false !== ($key = array_search('-silent', $args, true)) || false !== ($key = array_search('-S', $args, true))) {
         $this->silent = true;
         unset($args[$key]);
     }
     // 3) Finally, cycle through to parse remaining args
     //
     $keys = array_keys($args);
     // Use keys and iterate to max(keys) since there may be some gaps
     $max = $keys ? max($keys) : -1;
     for ($i = 0; $i <= $max; $i++) {
         if (!array_key_exists($i, $args)) {
             // skip this argument, since it must have been removed above.
             continue;
         }
         $arg = $args[$i];
         if ($arg == "-logfile") {
             try {
                 // see: http://phing.info/trac/ticket/65
                 if (!isset($args[$i + 1])) {
                     $msg = "You must specify a log file when using the -logfile argument\n";
                     throw new ConfigurationException($msg);
                 } else {
                     $logFile = new PhingFile($args[++$i]);
                     $out = new FileOutputStream($logFile);
                     // overwrite
                     self::setOutputStream($out);
                     self::setErrorStream($out);
                     self::$isLogFileUsed = true;
                 }
             } catch (IOException $ioe) {
                 $msg = "Cannot write on the specified log file. Make sure the path exists and you have write permissions.";
                 throw new ConfigurationException($msg, $ioe);
             }
         } elseif ($arg == "-buildfile" || $arg == "-file" || $arg == "-f") {
             if (!isset($args[$i + 1])) {
                 $msg = "You must specify a buildfile when using the -buildfile argument.";
                 throw new ConfigurationException($msg);
             } else {
                 $this->buildFile = new PhingFile($args[++$i]);
             }
         } elseif ($arg == "-listener") {
             if (!isset($args[$i + 1])) {
                 $msg = "You must specify a listener class when using the -listener argument";
                 throw new ConfigurationException($msg);
             } else {
                 $this->listeners[] = $args[++$i];
             }
         } elseif (StringHelper::startsWith("-D", $arg)) {
             // Evaluating the property information //
             // Checking whether arg. is not just a switch, and next arg. does not starts with switch identifier
             if ('-D' == $arg && !StringHelper::startsWith('-', $args[$i + 1])) {
                 $name = $args[++$i];
             } else {
                 $name = substr($arg, 2);
             }
             $value = null;
             $posEq = strpos($name, "=");
             if ($posEq !== false) {
                 $value = substr($name, $posEq + 1);
                 $name = substr($name, 0, $posEq);
             } elseif ($i < count($args) - 1 && !StringHelper::startsWith("-D", $args[$i + 1])) {
                 $value = $args[++$i];
             }
             self::$definedProps->setProperty($name, $value);
         } elseif ($arg == "-logger") {
             if (!isset($args[$i + 1])) {
                 $msg = "You must specify a classname when using the -logger argument";
                 throw new ConfigurationException($msg);
             } else {
                 $this->loggerClassname = $args[++$i];
             }
         } elseif ($arg == "-inputhandler") {
             if ($this->inputHandlerClassname !== null) {
                 throw new ConfigurationException("Only one input handler class may be specified.");
             }
             if (!isset($args[$i + 1])) {
                 $msg = "You must specify a classname when using the -inputhandler argument";
                 throw new ConfigurationException($msg);
             } else {
                 $this->inputHandlerClassname = $args[++$i];
             }
         } elseif ($arg == "-propertyfile") {
             if (!isset($args[$i + 1])) {
                 $msg = "You must specify a filename when using the -propertyfile argument";
                 throw new ConfigurationException($msg);
             } else {
                 $p = new Properties();
                 $p->load(new PhingFile($args[++$i]));
                 foreach ($p->getProperties() as $prop => $value) {
                     $this->setProperty($prop, $value);
                 }
             }
         } elseif ($arg == "-longtargets") {
             self::$definedProps->setProperty('phing.showlongtargets', 1);
         } elseif ($arg == "-projecthelp" || $arg == "-targets" || $arg == "-list" || $arg == "-l" || $arg == "-p") {
             // set the flag to display the targets and quit
             $this->projectHelp = true;
         } elseif ($arg == "-find") {
             // eat up next arg if present, default to build.xml
             if ($i < count($args) - 1) {
                 $this->searchForThis = $args[++$i];
             } else {
                 $this->searchForThis = self::DEFAULT_BUILD_FILENAME;
             }
         } elseif (substr($arg, 0, 1) == "-") {
             // we don't have any more args
             self::printUsage();
             self::$err->write(PHP_EOL);
             throw new ConfigurationException("Unknown argument: " . $arg);
         } else {
             // if it's no other arg, it may be the target
             array_push($this->targets, $arg);
         }
     }
     // if buildFile was not specified on the command line,
     if ($this->buildFile === null) {
         // but -find then search for it
         if ($this->searchForThis !== null) {
             $this->buildFile = $this->_findBuildFile(self::getProperty("user.dir"), $this->searchForThis);
         } else {
             $this->buildFile = new PhingFile(self::DEFAULT_BUILD_FILENAME);
         }
     }
     try {
         // make sure buildfile (or buildfile.dist) exists
         if (!$this->buildFile->exists()) {
             $distFile = new PhingFile($this->buildFile->getAbsolutePath() . ".dist");
             if (!$distFile->exists()) {
                 throw new ConfigurationException("Buildfile: " . $this->buildFile->__toString() . " does not exist!");
             }
             $this->buildFile = $distFile;
         }
         // make sure it's not a directory
         if ($this->buildFile->isDirectory()) {
             throw new ConfigurationException("Buildfile: " . $this->buildFile->__toString() . " is a dir!");
         }
     } catch (IOException $e) {
         // something else happened, buildfile probably not readable
         throw new ConfigurationException("Buildfile: " . $this->buildFile->__toString() . " is not readable!");
     }
     $this->readyToRun = true;
 }
 /**
  * load properties from a file.
  * @param PhingFile $file
  * @throws BuildException
  */
 protected function loadFile(PhingFile $file)
 {
     $props = new Properties();
     $this->log("Loading " . $file->getAbsolutePath(), $this->logOutput ? Project::MSG_INFO : Project::MSG_VERBOSE);
     try {
         // try to load file
         if ($file->exists()) {
             $props->load($file);
             $this->addProperties($props);
         } else {
             $this->log("Unable to find property file: " . $file->getAbsolutePath() . "... skipped", Project::MSG_WARN);
         }
     } catch (IOException $ioe) {
         throw new BuildException("Could not load properties from file.", $ioe);
     }
 }
 protected function getFilesToExecute()
 {
     $map = new Properties();
     try {
         $map->load($this->getSqlDbMap());
     } catch (IOException $ioe) {
         throw new BuildException("Cannot open and process the sqldbmap!");
     }
     $databases = array();
     foreach ($map->getProperties() as $sqlfile => $database) {
         if (!isset($databases[$database])) {
             $databases[$database] = array();
         }
         // We want to make sure that the base schemas
         // are inserted first.
         if (strpos($sqlfile, "schema.sql") !== false) {
             // add to the beginning of the array
             array_unshift($databases[$database], $sqlfile);
         } else {
             // add to the end of the array
             array_push($databases[$database], $sqlfile);
         }
     }
     return $databases;
 }
Пример #19
0
 /**
  * Set the colors to use from a property file specified by the
  * special ant property ant.logger.defaults
  */
 private final function setColors()
 {
     $userColorFile = Phing::getProperty("phing.logger.defaults");
     $systemColorFile = new PhingFile(Phing::getResourcePath("phing/listener/defaults.properties"));
     $in = null;
     try {
         $prop = new Properties();
         if ($userColorFile !== null) {
             $prop->load($userColorFile);
         } else {
             $prop->load($systemColorFile);
         }
         $err = $prop->getProperty("AnsiColorLogger.ERROR_COLOR");
         $warn = $prop->getProperty("AnsiColorLogger.WARNING_COLOR");
         $info = $prop->getProperty("AnsiColorLogger.INFO_COLOR");
         $verbose = $prop->getProperty("AnsiColorLogger.VERBOSE_COLOR");
         $debug = $prop->getProperty("AnsiColorLogger.DEBUG_COLOR");
         if ($err !== null) {
             $this->errColor = self::PREFIX . $err . self::SUFFIX;
         }
         if ($warn !== null) {
             $this->warnColor = self::PREFIX . $warn . self::SUFFIX;
         }
         if ($info !== null) {
             $this->infoColor = self::PREFIX . $info . self::SUFFIX;
         }
         if ($verbose !== null) {
             $this->verboseColor = self::PREFIX . $verbose . self::SUFFIX;
         }
         if ($debug !== null) {
             $this->debugColor = self::PREFIX . $debug . self::SUFFIX;
         }
     } catch (IOException $ioe) {
         //Ignore exception - we will use the defaults.
     }
 }
 public function main()
 {
     if ($this->_database === null) {
         $coverageDatabase = $this->project->getProperty('coverage.database');
         if (!$coverageDatabase) {
             throw new BuildException('Either include coverage-setup in your build file or set ' . 'the "database" attribute');
         }
         $database = new PhingFile($coverageDatabase);
     } else {
         $database = $this->_database;
     }
     $this->log('Calculating coverage threshold: min. ' . $this->_perProject . '% per project, ' . $this->_perClass . '% per class and ' . $this->_perMethod . '% per method is required');
     $props = new Properties();
     $props->load($database);
     foreach ($props->keys() as $filename) {
         $file = unserialize($props->getProperty($filename));
         // Skip file if excluded from coverage threshold validation
         if ($this->_excludes !== null) {
             if (in_array($file['fullname'], $this->_excludes->getExcludedFiles())) {
                 continue;
             }
         }
         $this->calculateCoverageThreshold($file['fullname'], $file['coverage']);
     }
     if ($this->_projectStatementCount > 0) {
         $coverage = $this->_projectStatementsCovered / $this->_projectStatementCount * 100;
     } else {
         $coverage = 0;
     }
     if ($coverage < $this->_perProject) {
         throw new BuildException('The coverage (' . round($coverage, 2) . '%) for the entire project ' . 'is lower than the specified threshold (' . $this->_perProject . '%)');
     }
     $this->log('Passed coverage threshold. Minimum found coverage values are: ' . round($coverage, 2) . '% per project, ' . round($this->_minClassCoverageFound, 2) . '% per class and ' . round($this->_minMethodCoverageFound, 2) . '% per method');
 }
 /**
  *  Run the task.
  *
  * @throws BuildException  trouble, probably file IO
  */
 public function main()
 {
     if ($this->prefix != null && $this->regex != null) {
         throw new BuildException("Please specify either prefix or regex, but not both", $this->getLocation());
     }
     //copy the properties file
     $allProps = array();
     /* load properties from file if specified, otherwise use Phing's properties */
     if ($this->inFile == null) {
         // add phing properties
         $allProps = $this->getProject()->getProperties();
     } elseif ($this->inFile != null) {
         if ($this->inFile->exists() && $this->inFile->isDirectory()) {
             $message = "srcfile is a directory!";
             $this->failOnErrorAction(null, $message, Project::MSG_ERR);
             return;
         }
         if ($this->inFile->exists() && !$this->inFile->canRead()) {
             $message = "Can not read from the specified srcfile!";
             $this->failOnErrorAction(null, $message, Project::MSG_ERR);
             return;
         }
         try {
             $props = new Properties();
             $props->load(new PhingFile($this->inFile));
             $allProps = $props->getProperties();
         } catch (IOException $ioe) {
             $message = "Could not read file " . $this->inFile->getAbsolutePath();
             $this->failOnErrorAction($ioe, $message, Project::MSG_WARN);
             return;
         }
     }
     $os = null;
     try {
         if ($this->destfile == null) {
             $os = Phing::getOutputStream();
             $this->saveProperties($allProps, $os);
             $this->log($os, Project::MSG_INFO);
         } else {
             if ($this->destfile->exists() && $this->destfile->isDirectory()) {
                 $message = "destfile is a directory!";
                 $this->failOnErrorAction(null, $message, Project::MSG_ERR);
                 return;
             }
             if ($this->destfile->exists() && !$this->destfile->canWrite()) {
                 $message = "Can not write to the specified destfile!";
                 $this->failOnErrorAction(null, $message, Project::MSG_ERR);
                 return;
             }
             $os = new FileOutputStream($this->destfile);
             $this->saveProperties($allProps, $os);
         }
     } catch (IOException $ioe) {
         $this->failOnErrorAction($ioe);
     }
 }
Пример #22
0
 public function enviarPantallaActiva()
 {
     //enviar pantalla principal.
     $pantallaActiva = new Properties();
     $pantallaActiva->load(file_get_contents("./pantallaActiva.properties"));
     $activ = $pantallaActiva->getProperty('Pantalla.activa');
     if ($activ == 1) {
         //guiSistema
         AccesoGui::$guiSistema->bienvenidaSistema();
         AccesoGui::$guiSistema->dibujarPantalla();
     } else {
         if ($activ == 3) {
             //guiEscenarios
             AccesoGui::$guiEscenarios->dibujarPantalla();
         } else {
             AccesoGui::$guiMenus->dibujarPantalla();
             AccesoGui::$guiMenus->menuPrincipal();
         }
     }
     /*if($activ==2) {//guiMenus
     
                 AccesoGui::$guiMenus->dibujarPantalla();
     	    AccesoGui::$guiMenus->menuPrincipal();
             }
             if($activ==3) {//guiEscenarios
     
                 AccesoGui::$guiEscenarios->dibujarPantalla();
             }
             if($activ==4) {//guiVideoconferencia
     
                 AccesoGui::$guiMenus->dibujarPantalla();
                 AccesoGui::$guiVideoconferencia->dibujarPantalla();
             }
             if($activ==5) {//guiSonido
     
                 AccesoGui::$guiMenus->dibujarPantalla();
                 AccesoGui::$guiSonido->dibujarPantalla();
             }
             if($activ==6) {//guiLuces
     
     
                 AccesoGui::$guiMenus->dibujarPantalla();
                 AccesoGui::$guiLuces->dibujarPantalla();
     
             }
             if($activ==7) {//guiDispositivos
     
                 AccesoGui::$guiMenus->dibujarPantalla();
                 AccesoGui::$guiDispositivos->dibujarPantalla();
             }
             if($activ==8) {//guiCamaras
     
                 AccesoGui::$guiMenus->dibujarPantalla();
                 AccesoGui::$guiDispositivos->dibujarPantalla();
     
             }
             if($activ==9) {//guiLectorDVD
     
                 AccesoGui::$guiMenus->dibujarPantalla();
                 AccesoGui::$guiDispositivos->dibujarPantalla();
                 AccesoGui::$guiLectorDVD->dibujarPantalla();
             }
             if($activ==10) {//guiGrabador
     
                 AccesoGui::$guiMenus->dibujarPantalla();
                 AccesoGui::$guiDispositivos->dibujarPantalla();
                 AccesoGui::$guiGrabadorDVD->dibujarPantalla();
     
             }
             if($activ==11) {//guiPantallas
     
                 AccesoGui::$guiMenus->dibujarPantalla();
                 AccesoGui::$guiDispositivos->dibujarPantalla();
                 AccesoGui::$guiPantallas->dibujarPantalla();
                 AccesoGui::$guiProyectores->dibujarPantalla();
     
             }
             if($activ==12) {//gui proyectores
     
                 AccesoGui::$guiMenus->dibujarPantalla();
                 AccesoGui::$guiDispositivos->dibujarPantalla();
                 AccesoGui::$guiProyectores->dibujarPantalla();
                 AccesoGui::$guiPantallas->dibujarPantalla();
     
             }
             if($activ==13) {//guiRedThinkclient
     
                 AccesoGui::$guiMenus->dibujarPantalla();
                 AccesoGui::$guiDispositivos->dibujarPantalla();
                 AccesoGui::$guiRedThinkClient->dibujarPantalla();
     
             }
             if($activ==14) {//guiCamaraDocumentos
     
                 AccesoGui::$guiMenus->dibujarPantalla();
                 AccesoGui::$guiDispositivos->dibujarPantalla();
                 AccesoGui::$guicamaraDocumentos->dibujarPantalla();
     
             }
             if($activ==15) {//guiPlasma
     
                 AccesoGui::$guiMenus->dibujarPantalla();
                 AccesoGui::$guiDispositivos->dibujarPantalla();
                 AccesoGui::$guiPlasma->dibujarPantalla();
     
             }
             if($activ==16) {//guiFocos
     
                 AccesoGui::$guiMenus->dibujarPantalla();
                 AccesoGui::$guiDispositivos->dibujarPantalla();
                 AccesoGui::$guiFocos->dibujarPantalla();
     
             }
             if($activ==17) {//guiAlumno
     
                 AccesoGui::$guiMenus->dibujarPantalla();
                 AccesoGui::$guiDispositivos->dibujarPantalla();
                 AccesoGui::$guiAlumno->dibujarPantalla();
     
             }*/
     AccesoGui::$guiSistema->enviarMenu();
     AccesoGui::$guiEscenarios->dibujarEscenarioMenu();
 }
Пример #23
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());
     }
 }
Пример #24
0
 public function getEstadoSistema()
 {
     $status = new status_class();
     $status->checkStatus();
     $properties = new Properties();
     $properties->load(file_get_contents("./sinta.properties"));
     $dispositivos = array();
     foreach ($properties->propertyNames() as $property) {
         $pos = stripos($property, ".");
         $disp = substr($property, 0, $pos);
         $parent = $properties->getProperty($disp . ".parent");
         $parentStatus = $properties->getProperty($parent . ".status");
         if (!in_array($disp, $dispositivos) && $properties->getProperty($disp . ".status") == 1 && (empty($parent) || $parentStatus == 0)) {
             $dispositivos[] = $disp;
         }
     }
     if (count($dispositivos) == 0) {
         return '';
     }
     $alert_messages = array();
     // $dispositivos=array("CamaraPresidencia","CamaraAlumnos1","CamaraAlumnos2","FocoMovil","Dvd","DvdGrabador","GeneradorMultiventanas","MatrizVGA","MatrizVideo","MesaMezclas","Pantalla","PantallaPresidencia","PantallaEntrada","Plasma","ProyectorCentral","ProyectorPizarra","Videoconferencia","VisorOpacos","Luces","Automata");
     foreach ($dispositivos as $dispositivo) {
         $errorMsg = $properties->getProperty($dispositivo . ".error");
         if (empty($errorMsg)) {
             $alert_messages[] = "ERROR {$dispositivo}";
         } else {
             $alert_messages[] = $properties->getProperty($dispositivo . ".error");
         }
     }
     $alert_message = implode("\n", $alert_messages);
     echo "ALERT::: " . $alert_message;
     $alert_message = str_replace('"', '', $alert_message);
     return $alert_message;
 }
 /**
  * Load the sql file and then execute it
  *
  * @throws     BuildException
  */
 public function main()
 {
     $this->sqlCommand = trim($this->sqlCommand);
     if ($this->sqldbmap === null || $this->getSqlDbMap()->exists() === false) {
         throw new BuildException("You haven't provided an sqldbmap, or " . "the one you specified doesn't exist: " . $this->sqldbmap->getPath());
     }
     if ($this->url === null) {
         throw new BuildException("DSN url attribute must be set!");
     }
     $map = new Properties();
     try {
         $map->load($this->getSqlDbMap());
     } catch (IOException $ioe) {
         throw new BuildException("Cannot open and process the sqldbmap!");
     }
     $databases = array();
     foreach ($map->keys() as $sqlfile) {
         $database = $map->getProperty($sqlfile);
         // Q: already there?
         if (!isset($databases[$database])) {
             // A: No.
             $databases[$database] = array();
         }
         // We want to make sure that the base schemas
         // are inserted first.
         if (strpos($sqlfile, "schema.sql") !== false) {
             // add to the beginning of the array
             array_unshift($databases[$database], $sqlfile);
         } else {
             array_push($databases[$database], $sqlfile);
         }
     }
     foreach ($databases as $db => $files) {
         $transactions = array();
         foreach ($files as $fileName) {
             $file = new PhingFile($this->srcDir, $fileName);
             if ($file->exists()) {
                 $this->log("Executing statements in file: " . $file->__toString());
                 $transaction = new PropelSQLExecTransaction($this);
                 $transaction->setSrc($file);
                 $transactions[] = $transaction;
             } else {
                 $this->log("File '" . $file->__toString() . "' in sqldbmap does not exist, so skipping it.");
             }
         }
         $this->insertDatabaseSqlFiles($this->url, $db, $transactions);
     }
 }
Пример #26
0
 static function getPersonalities()
 {
     $theme = $theme = basename(dirname(dirname(__FILE__)));
     $root = SERVERPATH . "/themes/{$theme}/personality";
     $curdir = getcwd();
     chdir($root);
     $filelist = safe_glob('*');
     $list = array();
     foreach ($filelist as $file) {
         if (is_dir($file) && $file != '.' && $file != '..') {
             $internal = filesystemToInternal($file);
             //ignore __random__ and __void__ folders: it is a 'reserved' word
             //ignore _template folder: we donot want to consider it
             if ($internal == '__random__' || $internal == '_template' || $internal == '__void__') {
                 continue;
             }
             //properties file is mandatory
             if (!file_exists("{$root}/{$file}/persona.properties")) {
                 continue;
             }
             $props = new Properties();
             $props->load(file_get_contents("{$root}/{$file}/persona.properties"));
             $name = $props->getProperty('name');
             //name is mandatory
             if (!isset($name)) {
                 continue;
             }
             $dominant = $props->getProperty('dominant', '#fff');
             $disabled = $props->getProperty('disabled');
             //if persona marked as disabled, ignore it
             if ($disabled != 'true') {
                 $list[$internal] = array('name' => $name, 'dominant' => $dominant);
             }
         }
     }
     chdir($curdir);
     return $list;
 }
Пример #27
0
 /** inits the project, called from main app */
 public function init()
 {
     // set builtin properties
     $this->setSystemProperties();
     // load default tasks
     $taskdefs = Phing::getResourcePath("phing/tasks/defaults.properties");
     try {
         // try to load taskdefs
         $props = new Properties();
         $in = new PhingFile((string) $taskdefs);
         if ($in === null) {
             throw new BuildException("Can't load default task list");
         }
         $props->load($in);
         $enum = $props->propertyNames();
         foreach ($enum as $key) {
             $value = $props->getProperty($key);
             $this->addTaskDefinition($key, $value);
         }
     } catch (IOException $ioe) {
         throw new BuildException("Can't load default task list");
     }
     // load default tasks
     $typedefs = Phing::getResourcePath("phing/types/defaults.properties");
     try {
         // try to load typedefs
         $props = new Properties();
         $in = new PhingFile((string) $typedefs);
         if ($in === null) {
             throw new BuildException("Can't load default datatype list");
         }
         $props->load($in);
         $enum = $props->propertyNames();
         foreach ($enum as $key) {
             $value = $props->getProperty($key);
             $this->addDataTypeDefinition($key, $value);
         }
     } catch (IOException $ioe) {
         throw new BuildException("Can't load default datatype list");
     }
 }
Пример #28
0
 function main()
 {
     $this->log("Transforming coverage report");
     $database = new PhingFile($this->project->getProperty('coverage.database'));
     $props = new Properties();
     $props->load($database);
     foreach ($props->keys() as $filename) {
         $file = unserialize($props->getProperty($filename));
         $this->transformCoverageInformation($file['fullname'], $file['coverage']);
     }
     $this->calculateStatistics();
     $this->doc->save($this->outfile);
     foreach ($this->transformers as $transformer) {
         $transformer->setXmlDocument($this->doc);
         $transformer->transform();
     }
 }
Пример #29
0
 /**
  * Set the context properties that will be
  * fed into the initial context be the
  * generating process starts.
  * @param  string $file
  * @throws BuildException
  * @return void
  */
 public function setContextProperties($file)
 {
     $sources = explode(",", $file);
     $this->contextProperties = new Properties();
     // Always try to get the context properties resource
     // from a file first. Templates may be taken from a JAR
     // file but the context properties resource may be a
     // resource in the filesystem. If this fails than attempt
     // to get the context properties resource from the
     // classpath.
     for ($i = 0, $sourcesLength = count($sources); $i < $sourcesLength; $i++) {
         $source = new Properties();
         try {
             // resolve relative path from basedir and leave
             // absolute path untouched.
             $fullPath = $this->project->resolveFile($sources[$i]);
             $this->log("Using contextProperties file: " . $fullPath->__toString());
             $source->load($fullPath);
         } catch (Exception $e) {
             throw new BuildException("Context properties file " . $sources[$i] . " could not be found in the file system!");
         }
         $keys = $source->keys();
         foreach ($keys as $key) {
             $name = $key;
             $value = $this->project->replaceProperties($source->getProperty($name));
             $this->contextProperties->setProperty($name, $value);
         }
     }
 }
 function main()
 {
     $coverageDatabase = $this->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);
     $this->log("Transforming coverage report");
     $props = new Properties();
     $props->load($database);
     foreach ($props->keys() as $filename) {
         $file = unserialize($props->getProperty($filename));
         $this->transformCoverageInformation($file['fullname'], $file['coverage']);
     }
     $this->calculateStatistics();
     $this->doc->save($this->outfile);
     foreach ($this->transformers as $transformer) {
         $transformer->setXmlDocument($this->doc);
         $transformer->transform();
     }
 }