/**
  * Stores the configuration. Calls the parent configuration first,
  * then does additional operations.
  * 
  * @param object Properties $configuration
  * @return object
  * @access public
  * @since 3/24/05
  */
 function assignConfiguration(Properties $configuration)
 {
     // Set the configuration values to our custom values.
     $configuration->addProperty('authentication_table', 'auth_visitor');
     $configuration->addProperty('username_field', 'email');
     $configuration->addProperty('password_field', 'password');
     $propertiesFields = array('name' => 'display_name', 'email' => 'email');
     $configuration->addProperty('properties_fields', $propertiesFields);
     try {
         ArgumentValidator::validate($configuration->getProperty('email_from_name'), NonzeroLengthStringValidatorRule::getRule());
     } catch (InvalidArgumentException $e) {
         throw new ConfigurationErrorException("'email_from_name' must be a string. " . $e->getMessage());
     }
     try {
         ArgumentValidator::validate($configuration->getProperty('email_from_address'), RegexValidatorRule::getRule('/^.+@.+$/'));
     } catch (InvalidArgumentException $e) {
         throw new ConfigurationErrorException("'email_from_address' must be an email address. " . $e->getMessage());
     }
     try {
         ArgumentValidator::validate($configuration->getProperty('domain_blacklist'), OptionalRule::getRule(ArrayValidatorRuleWithRule::getRule(NonzeroLengthStringValidatorRule::getRule())));
         ArgumentValidator::validate($configuration->getProperty('domain_whitelist'), OptionalRule::getRule(ArrayValidatorRuleWithRule::getRule(NonzeroLengthStringValidatorRule::getRule())));
     } catch (InvalidArgumentException $e) {
         throw new ConfigurationErrorException("'domain_blacklist' and 'domain_whitelist' if specified must be arrays of domain name strings. " . $e->getMessage());
     }
     parent::assignConfiguration($configuration);
 }
 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));
 }
Beispiel #3
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;
 }
Beispiel #4
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);
 }
 /**
  * Assign the configuration of this Manager. There are no valid configuration options for
  * this manager.
  *
  * @param object Properties $configuration (original type: java.util.Properties)
  *
  * @throws object OsidException An exception with one of the following
  *		   messages defined in org.osid.OsidException:	{@link
  *		   org.osid.OsidException#OPERATION_FAILED OPERATION_FAILED},
  *		   {@link org.osid.OsidException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.OsidException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.OsidException#UNIMPLEMENTED UNIMPLEMENTED}, {@link
  *		   org.osid.OsidException#NULL_ARGUMENT NULL_ARGUMENT}
  *
  * @access public
  */
 function assignConfiguration(Properties $configuration)
 {
     $def = $configuration->getProperty('default_authority');
     // ** parameter validation
     ArgumentValidator::validate($def, StringValidatorRule::getRule(), true);
     // ** end of parameter validation
     $this->_defaultAuthority = $def;
 }
 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');
 }
Beispiel #7
0
 public function propertiesJsonQuery($string)
 {
     $propertiesClient = new Properties();
     if (!$this->validateProperties($string)) {
         return "";
     }
     $response = $propertiesClient->find($string);
     return $response;
 }
 /**
  * Assigns the configuration of databases etc.
  * 
  * @param object $configuration
  * 
  * @access public
  *
  * @return void
  */
 function assignConfiguration(Properties $configuration)
 {
     $this->_configuration = $configuration;
     $dbIndex = $configuration->getProperty('database_index');
     // ** parameter validation
     ArgumentValidator::validate($dbIndex, IntegerValidatorRule::getRule(), true);
     // ** end of parameter validation
     $this->_dbIndex = $dbIndex;
 }
 public function getDetailed($criterion = null)
 {
     $Properties = new Properties();
     $featured_properties = $this->get($criterion);
     foreach ($featured_properties as &$featured_property) {
         $featured_property = $Properties->get($featured_property->property_id);
     }
     return $featured_properties;
 }
 /**
  * @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;
 }
Beispiel #11
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;
 }
 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'));
 }
 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);
 }
 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');
 }
Beispiel #16
0
 public function updateData($import = false)
 {
     // Get service propertie
     $config = Zend_Registry::get("configuration");
     $pages = $import ? 50 : 1;
     $count = $import ? 200 : 50;
     // Get application properties
     $app_properties = new Properties(array(Stuffpress_Db_Properties::KEY => Zend_Registry::get("shard")));
     // Get twitter user properties
     $username = $this->getProperty('username');
     $uid = $this->getProperty('uid', 0);
     if (!$username) {
         throw new Stuffpress_Exception("Update failed, connector not properly configured");
     }
     // Get twitter consumer tokens and user secrets
     $consumer_key = $config->twitter->consumer_key;
     $consumer_secret = $config->twitter->consumer_secret;
     $oauth_token = $app_properties->getProperty('twitter_oauth_token');
     $oauth_token_secret = $app_properties->getProperty('twitter_oauth_token_secret');
     if (!$consumer_key || !$consumer_secret || !$oauth_token || !$oauth_token_secret) {
         throw new Stuffpress_Exception("Missing twitter credentials. Please configure your twitter account in the <a href='/admin/sns/'>Configure -> Social Networks</a> section.");
     }
     // Fetch the data from twitter
     $result = array();
     $connection = new TwitterOAuth_Client($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
     $connection->host = "https://api.twitter.com/1.1/";
     $max_id = false;
     $params = array('screen_name' => $username, 'count' => $count);
     for ($page = 1; $page <= $pages; $page++) {
         if ($max_id) {
             $params['max_id'] = $max_id;
         }
         $response = $connection->get('statuses/user_timeline', $params);
         if ($response && isset($response->errors) && count($response->errors) > 0) {
             throw new Stuffpress_Exception($response->errors[0]->message);
         }
         if (count($response) == 0) {
             break;
         }
         $max_id = $response[count($response) - 1]->id_str;
         $items = $this->processItems($response);
         if (count($items) == 0) {
             break;
         }
         $result = array_merge($result, $items);
     }
     // Mark as updated (could have been with errors)
     $this->markUpdated();
     return $result;
 }
 private static function generateUnsetPrivatePropertiesCode(Properties $properties, string $instanceName) : string
 {
     $groups = $properties->getGroupedPrivateProperties();
     if (!$groups) {
         return '';
     }
     $unsetClosureCalls = [];
     /* @var $privateProperties \ReflectionProperty[] */
     foreach ($groups as $privateProperties) {
         /* @var $firstProperty \ReflectionProperty */
         $firstProperty = reset($privateProperties);
         $unsetClosureCalls[] = self::generateUnsetClassPrivatePropertiesBlock($firstProperty->getDeclaringClass(), $privateProperties, $instanceName);
     }
     return implode("\n\n", $unsetClosureCalls) . "\n\n";
 }
 public function __construct($id, $module = null, $redirect = true)
 {
     parent::__construct($id, $module);
     $fullname = Yii::app()->user->getState('firstname') . ' ' . Yii::app()->user->getState('lastname');
     $this->userHello = $fullname;
     $this->message = "Hello " . $fullname;
     $this->ShowMessage = false;
     $this->propertyName = Yii::app()->user->getState('property_property_name');
     $this->propertyCountry = Yii::app()->user->getState('property_country');
     $this->propertyAdminCountry = Yii::app()->user->getState('property_adminCountry');
     $this->title = $this->propertyName;
     $this->propertyId = Yii::app()->user->getState('property_id');
     $this->access = $this->getActivePropertyAccess();
     $this->getAllProperties();
     $property = Properties::model()->find('id=:id AND isdeactivated=:isdeactivated', array(':id' => Yii::app()->user->getState('propertyId'), ':isdeactivated' => 1));
     if ($property != null && $redirect) {
         $access = UserAccessTable::getCurrentAccess();
         if ($access < UserAccessTable::GUEST) {
             $this->redirect(basePath('property/' . Yii::app()->user->getState('propertyId')));
         } else {
             $this->redirect(basePath('property/deactivated'));
         }
     }
     //        $this->access = UserAccessTable::BASIC_ACCESS;
 }
 public function run()
 {
     $faker = Faker\Factory::create();
     foreach (range(1, 20) as $index) {
         Properties::create(['serialno' => '123abc', 'propname' => $faker->firstName, 'propdesc' => 'Lorem ipsum dolor sit amet', 'propstatus' => 'In stock', 'propcondition' => 'Good', 'prop_category' => $faker->numberBetween($min = 1, $max = 5), 'propcost' => $faker->randomFloat(NULL, 500, 35000), 'dateacq' => $faker->dateTimeBetween('-10 years', '-1 year')->format('Y-m-d')]);
     }
 }
 public function __construct(array &$data_, $namespace_ = null)
 {
     parent::__construct($data_);
     $this->m_id = session_id();
     $this->m_name = session_name();
     $this->m_namespace = $namespace_;
 }
Beispiel #21
0
 protected function initPhingProperties(Project $project)
 {
     // Apply all file properties, then all non-file properties
     $properties = new Properties();
     foreach ($this->fileProps as $key => $value) {
         $properties->put($key, $value);
     }
     foreach ($this->customProps as $key => $value) {
         $properties->put($key, $value);
     }
     // Then swap out placeholder values
     foreach ($properties->getProperties() as $key => $value) {
         $value = ProjectConfigurator::replaceProperties($project, $value, $properties->getProperties());
         $project->setProperty($key, $value);
     }
 }
 public function propertiesFromSameFileAreEqual()
 {
     $one = Properties::fromFile($this->getClass()->getPackage()->getResourceAsStream('example.ini'));
     $two = Properties::fromFile($this->getClass()->getPackage()->getResourceAsStream('example.ini'));
     $this->assertFalse($one === $two);
     $this->assertTrue($one->equals($two));
 }
Beispiel #23
0
 public function item($code, array $data) : bool
 {
     Properties::$items = $this->driver->select(md5('SystemCartData')) ?? NULL;
     if (empty(Properties::$items)) {
         return false;
     }
     $i = 0;
     foreach (Properties::$items as $row) {
         if (is_array($code)) {
             if (isset($row[key($code)]) && $row[key($code)] == current($code)) {
                 $code = $row[key($code)];
             }
         }
         $key = array_search($code, $row);
         if (!empty($key)) {
             array_splice(Properties::$items, $i, 1);
             if (count($data) !== count($row)) {
                 foreach ($data as $k => $v) {
                     $row[$k] = $v;
                 }
                 array_push(Properties::$items, $row);
             } else {
                 array_push(Properties::$items, $data);
             }
         }
         $i++;
     }
     return $this->driver->insert(md5('SystemCartData'), Properties::$items);
 }
Beispiel #24
0
 /**
  * Main
  *
  * Exitcodes used:
  * <ul>
  *   <li>127: Archive referenced in -xar [...] does not exist</li>
  *   <li>126: No manifest or manifest does not have a main-class</li>
  * </ul>
  *
  * @see     http://tldp.org/LDP/abs/html/exitcodes.html
  * @param   string[] args
  * @return  int
  */
 public static function main(array $args)
 {
     // Open archive
     $f = new File(array_shift($args));
     if (!$f->exists()) {
         Console::$err->writeLine('*** Cannot find archive ' . $f->getURI());
         return 127;
     }
     // Register class loader
     $cl = ClassLoader::registerLoader(new ArchiveClassLoader(new Archive($f)));
     if (!$cl->providesResource(self::MANIFEST)) {
         Console::$err->writeLine('*** Archive ' . $f->getURI() . ' does not have a manifest');
         return 126;
     }
     // Load manifest
     $pr = Properties::fromString($cl->getResource(self::MANIFEST));
     if (NULL === ($class = $pr->readString('archive', 'main-class', NULL))) {
         Console::$err->writeLine('*** Archive ' . $f->getURI() . '\'s manifest does not have a main class');
         return 126;
     }
     // Run main()
     try {
         return XPClass::forName($class, $cl)->getMethod('main')->invoke(NULL, array($args));
     } catch (TargetInvocationException $e) {
         throw $e->getCause();
     }
 }
 /**
  * Gets the singleon instance of the Properties class
  *
  * @return unknown
  */
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 /**
  * 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);
 }
 /**
  * Assign the configuration of this Manager. Valid configuration options are as
  * follows:
  *		default_language	string	(ex: 'en_US')
  *		applications		array of strings (
  *								application_name => language_file_directory,
  *	 							...,
  * 								...,
  *							)
  *		
  * 
  * @param object Properties $configuration (original type: java.util.Properties)
  * 
  * @throws object OsidException An exception with one of the following
  *		   messages defined in org.osid.OsidException:	{@link
  *		   org.osid.OsidException#OPERATION_FAILED OPERATION_FAILED},
  *		   {@link org.osid.OsidException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.OsidException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.OsidException#UNIMPLEMENTED UNIMPLEMENTED}, {@link
  *		   org.osid.OsidException#NULL_ARGUMENT NULL_ARGUMENT}
  * 
  * @access public
  */
 function assignConfiguration(Properties $configuration)
 {
     $this->_configuration = $configuration;
     ArgumentValidator::validate($configuration->getProperty('default_language'), StringValidatorRule::getRule(), true);
     ArgumentValidator::validate($configuration->getProperty('applications'), ArrayValidatorRule::getRule(), true);
     // Get the current Language settings from the session if they exist.
     if (isset($_SESSION['__CurrentLanguage'])) {
         $this->setLanguage($_SESSION['__CurrentLanguage']);
     } else {
         $this->setLanguage($configuration->getProperty('default_language'));
     }
     foreach ($configuration->getProperty('applications') as $application => $languageDir) {
         ArgumentValidator::validate($application, StringValidatorRule::getRule(), true);
         ArgumentValidator::validate($languageDir, StringValidatorRule::getRule(), true);
         $this->addApplication($application, $languageDir);
     }
 }
 public function addValuesColumnQuery($query, $field, $val)
 {
     $sql_part = array();
     $sql_params = array();
     $value_from = $val['lower_value'];
     $value_to = $val['upper_value'];
     $unit = $val['property_unit'];
     // We have only 1 Value
     if ($value_from != '' && $value_to == '') {
         if ($unit == '') {
             $sql_part[] = '  ( lower_value = ? OR  upper_value = ?) ';
             $sql_params[] = $value_from;
             $sql_params[] = $value_from;
             //We don't know the filed unit
         } elseif (Properties::searchRecognizedUnitsGroups($unit) === false) {
             $sql_part[] = '  ( lower_value = ? OR  upper_value = ?) AND property_unit = ? ';
             $sql_params[] = $value_from;
             $sql_params[] = $value_from;
             $sql_params[] = $unit;
         } else {
             // Recognized unit
             $sql_params[] = $value_from;
             $sql_params[] = $unit;
             $sql_params[] = $unit;
             $unitGroupStr = implode(',', array_fill(0, count($unitGroup), '?'));
             $sql_part[] = ' ( convert_to_unified ( ?,  ? ) BETWEEN lower_value_unified AND  upper_value_unified) AND is_property_unit_in_group(property_unit, ?)  ';
         }
     } elseif ($value_from != '' && $value_to != '') {
         if ($unit == '') {
             $sql_part[] = ' ( ( lower_value = ? OR  upper_value = ?) OR ( lower_value = ? OR  upper_value = ?) )';
             $sql_params[] = $value_from;
             $sql_params[] = $value_from;
             $sql_params[] = $value_to;
             $sql_params[] = $value_to;
             //We don't know the filed unit
         } elseif (Properties::searchRecognizedUnitsGroups($unit) === false) {
             $sql_part[] = ' ( ( lower_value = ? OR  upper_value = ?) OR ( lower_value = ? OR  upper_value = ?) )  AND property_unit = ? ';
             $sql_params[] = $value_from;
             $sql_params[] = $value_from;
             $sql_params[] = $value_to;
             $sql_params[] = $value_to;
             $sql_params[] = $unit;
         } else {
             // Recognized unit
             $conn_MGR = Doctrine_Manager::connection();
             $lv = $conn_MGR->quote($value_from, 'string');
             $uv = $conn_MGR->quote($value_to, 'string');
             $unit = $conn_MGR->quote($unit, 'string');
             $sql_part[] = "\n            (\n              ( lower_value_unified BETWEEN convert_to_unified({$lv},{$unit}) AND convert_to_unified({$uv},{$unit}))\n              OR\n              ( upper_value_unified BETWEEN convert_to_unified({$lv},{$unit}) AND convert_to_unified({$uv},{$unit}))\n            )\n            OR\n            (\n              lower_value_unified BETWEEN 0 AND convert_to_unified({$lv},{$unit})\n              AND\n              upper_value_unified BETWEEN convert_to_unified({$uv},{$unit}) AND 'Infinity'\n        )";
             $query->andWhere("is_property_unit_in_group(property_unit,{$unit})");
         }
     }
     if (!empty($sql_part)) {
         $query->andWhere(implode(' AND ', $sql_part), $sql_params);
     }
     return $query;
 }
 /**
  * Prepare "environment" for invocation on bean method. Configures
  * the PropertyManager (always), the Logger (if log.ini has been provided
  * with the bean) and ConnectionManager (if database.ini has been provided
  * with the bean).
  *
  */
 protected function prepare()
 {
     if ($this->configuration['log.ini']) {
         Logger::getInstance()->configure(Properties::fromString($this->configuration['cl']->getResource('etc/log.ini')));
     }
     if ($this->configuration['database.ini']) {
         ConnectionManager::getInstance()->configure(Properties::fromString($this->configuration['cl']->getResource('etc/database.ini')));
     }
 }
Beispiel #30
0
 function testGetBool()
 {
     global $UBAR_GLOB;
     $path = $UBAR_GLOB['UBAR_ROOT'] . "test" . DIRECTORY_SEPARATOR . "data" . DIRECTORY_SEPARATOR . "sample.properties";
     $pathToPropertiesClass = $UBAR_GLOB['UBAR_ROOT'] . "core" . DIRECTORY_SEPARATOR . "Properties.php";
     $props = new Properties($path);
     // test valid
     $this->assertEquals(TRUE, $props->getBool("sample.boolean"));
     // test unable to convert (other errors covered in test_get()
     try {
         $props->getBool("sample.badboolean");
         $this->fail("Expected exception trying to get property you can't convert to bool.");
     } catch (Exception $e) {
         $value = $props->get("sample.badboolean");
         $expectedMessage = "The property found, " . $value . ", with the key \"sample.badboolean\" could not be converted to a boolean value in the file \"{$path}\".";
         $this->assertEquals($expectedMessage, $e->getMessage());
     }
 }