public function indexAction()
 {
     // Get, check and setup the parameters
     if (!($widget_id = $this->getRequest()->getParam("id"))) {
         throw new Stuffpress_Exception("No widget id provided to the widget controller");
     }
     // Verify if the requested widget exist and get its data
     $widgets = new Widgets();
     if (!($widget = $widgets->getWidget($widget_id))) {
         throw new Stuffpress_Exception("Invalid widget id");
     }
     // Get the user
     $users = new Users();
     $user = $users->getUser($widget['user_id']);
     // Get all sources configured for that user
     $properties = new Properties(array(Properties::KEY => $user->id));
     // Get the bio data
     // User profile
     $this->view->username = $user->username;
     $this->view->first_name = $properties->getProperty('first_name');
     $this->view->last_name = $properties->getProperty('last_name');
     $this->view->bio = $properties->getProperty('bio');
     $this->view->location = $properties->getProperty('location');
     $this->view->avatar = $properties->getProperty('avatar_image');
     // Get the widget properties
     $properties = new WidgetsProperties(array(Properties::KEY => $widget_id));
     $title = $properties->getProperty('title');
     $this->view->title = $title ? $title : "About {$user->username}";
 }
Exemple #2
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);
 }
 /**
  * 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 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');
 }
 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;
 }
 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;
 }
 /**
  * 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);
     }
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
 /**
  * Assign the configuration of this Manager. Valid configuration options are as
  * follows:
  *	database_index			integer
  *	database_name			string
  *	default_theme			object Theme
  *
  * @param object Properties $configuration (original type: java.util.Properties)
  *
  * @throws object OsidException An exception with one of the following
  *		   messages defined in org.osid.OsidException:	{@link
  *		   org.osid.OsidException#OPERATION_FAILED OPERATION_FAILED},
  *		   {@link org.osid.OsidException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.OsidException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.OsidException#UNIMPLEMENTED UNIMPLEMENTED}, {@link
  *		   org.osid.OsidException#NULL_ARGUMENT NULL_ARGUMENT}
  *
  * @access public
  */
 function assignConfiguration(Properties $configuration)
 {
     $this->_configuration = $configuration;
     $dbIndex = $configuration->getProperty('database_index');
     $dbName = $configuration->getProperty('database_name');
     $theme = $configuration->getProperty('default_theme');
     $id = $configuration->getProperty('default_state_id');
     $arrayOfDefaultThemes = $configuration->getProperty('array_of_default_themes');
     // ** parameter validation
     ArgumentValidator::validate($dbIndex, IntegerValidatorRule::getRule(), true);
     ArgumentValidator::validate($theme, ExtendsValidatorRule::getRule("ThemeInterface"), true);
     ArgumentValidator::validate($arrayOfDefaultThemes, ArrayValidatorRule::getRule(), true);
     // ** end of parameter validation
     $this->_dbName = $dbName;
     $this->_dbIndex = $dbIndex;
     $this->_themeList = $arrayOfDefaultThemes;
     $this->setTheme($theme);
 }
 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);
 }
 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);
 }
 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);
 }
 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);
 }
 public function indexAction()
 {
     // Get, check and setup the parameters
     if (!($widget_id = $this->getRequest()->getParam("id"))) {
         throw new Stuffpress_Exception("No widget id provided to the widget controller");
     }
     // Verify if the requested widget exist and get its data
     $widgets = new Widgets();
     if (!($widget = $widgets->getWidget($widget_id))) {
         throw new Stuffpress_Exception("Invalid widget id");
     }
     // Get the user
     $users = new Users();
     $user = $users->getUser($widget['user_id']);
     // Get all sources configured for that user
     $properties = new Properties(array(Properties::KEY => $user->id));
     // Get the friendconnect data
     $this->view->googlefc = $properties->getProperty('googlefc');
     // Get the widget properties
     $properties = new WidgetsProperties(array(Properties::KEY => $widget_id));
     $title = $properties->getProperty('title');
     $this->view->title = $title;
 }
Exemple #16
0
 private function _getProperty($cached, $key, $defaultValue = NULL)
 {
     if (in_array($key, $cached)) {
         // loop detected
         return '';
     }
     $cached[] = $key;
     $value = parent::getProperty($key, $defaultValue);
     if ($value === NULL) {
         return $value;
     }
     $result = '';
     while (strlen($value) > 0) {
         if (preg_match('/^([^\\{]+)/', $value, $matches)) {
             $result .= $matches[1];
             $value = substr($value, strlen($matches[1]));
         } elseif (preg_match('/^\\{\\%([^}]+)\\}/', $value, $matches)) {
             // an environment-name placeholder
             $name = $matches[1];
             if (isset($_ENV[$name])) {
                 $result .= $_ENV[$name];
             } elseif (isset($_SERVER[$name])) {
                 $result .= $_SERVER[$name];
             }
             $value = substr($value, strlen($matches[0]));
         } elseif (preg_match('/^\\{\\$([^}]+)\\}/', $value, $matches)) {
             // an property-name placeholder
             $name = $matches[1];
             $result .= $this->_getProperty($cached, $name);
             $value = substr($value, strlen($matches[0]));
         } else {
             $result .= substr($value, 0, 1);
             $value = substr($value, 1);
         }
     }
     return $result;
 }
 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;
 }
Exemple #18
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");
     }
 }
Exemple #19
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)
 }
 /**
  * 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.
     }
 }
Exemple #22
0
	protected function updateTwitter($items) {
		// Get the user
		$users = new Users();
		$shortUrl = new ShortUrl(); 
		$user  = $users->getUser($this->getUserID());
		
		// Get twitter consumer tokens and user secrets
		$config = Zend_Registry::get("configuration");
		$consumer_key = $config->twitter->consumer_key;
		$consumer_secret = $config->twitter->consumer_secret;
		
		// Get twitter credentials
		$properties = new Properties(array(Properties::KEY => $user->id));
		$auth	    = $properties->getProperty('twitter_auth');
		$services   = $properties->getProperty('twitter_services');
		$oauth_token = $properties->getProperty('twitter_oauth_token');
		$oauth_token_secret = $properties->getProperty('twitter_oauth_token_secret');
		
		if (!$consumer_key || !$consumer_secret || !$oauth_token || !$oauth_token_secret) {
			return;
		}
		
		$has_preamble   = $properties->getProperty('preamble', true);
		
		// Return if not all conditions are met
		if (!$auth || !in_array($this->getID(), unserialize($services))) {
			return;
		}
		
		// Get an item
		$count		= count($items);
		$data		= new Data();
		$source_id	= $this->_source['id'];
					
		if ($count <= 3) {
			foreach($items as $id) {
				$item		= $data->getItem($source_id, $id);
				$title		= strip_tags($item->getTitle());
				$service	= $this->getServiceName();
				
				if (($item->getType() == SourceItem::STATUS_TYPE ) && strlen($title) < 140) {
					$tweet = $title;
				} 
				else {
					$preamble = $has_preamble ? $item->getPreamble() : "";
					$tweet	  = $preamble . $title;
					$url = $users->getUrl($user->id, "s/" . $shortUrl->shorten($item->getSlug()));
					if (strlen($tweet) + strlen($url) > 140) {
						$tweet = substr($tweet, 0, 140 - strlen($url) - 5) . "... $url"; 
					} else {
						$tweet 	= "$tweet $url";	
					}
				}
				
				try {
					$connection = new TwitterOAuth_Client($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
					$response = $connection->post('statuses/update', array('status' => $tweet));	
				} catch (Exception $e) {}
			}
		} else {
			$url = $users->getUrl($user->id);
			$tweet  = sprintf($this->_update_tweet, $count, $url);
			try {
				$twitter = new Stuffpress_Services_Twitter($username, $password);
				$twitter->sendTweet($tweet);
			} catch (Exception $e) {}			
			}
	}
Exemple #23
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();
     }
 }
Exemple #24
0
 protected function updateTwitter($items)
 {
     // Get the user
     $users = new Users();
     $user = $users->getUser($this->getUserID());
     // Get twitter credentials
     $properties = new Properties(array(Properties::KEY => $user->id));
     $auth = $properties->getProperty('twitter_auth');
     $services = $properties->getProperty('twitter_services');
     $username = $properties->getProperty('twitter_username');
     $password = $properties->getProperty('twitter_password');
     $has_preamble = $properties->getProperty('preamble', true);
     // Return if not all conditions are met
     if (!$auth || !in_array($this->getID(), unserialize($services))) {
         return;
     }
     // Get an item
     $count = count($items);
     $data = new Data();
     $source_id = $this->_source['id'];
     if ($count <= 3) {
         foreach ($items as $id) {
             $item = $data->getItem($source_id, $id);
             $title = strip_tags($item->getTitle());
             $service = $this->getServiceName();
             if ($item->getType() == SourceItem::STATUS_TYPE && strlen($title) < 140) {
                 $tweet = $title;
             } else {
                 $preamble = $has_preamble ? $item->getPreamble() : "";
                 $tweet = $preamble . $title;
                 $url = $users->getUrl($user->id, "/entry/" . $item->getSlug());
                 if (strlen($tweet) + strlen($url) > 140) {
                     $tweet = substr($tweet, 0, 140 - strlen($url) - 5) . "... {$url}";
                 } else {
                     $tweet = "{$tweet} {$url}";
                 }
             }
             try {
                 $twitter = new Stuffpress_Services_Twitter($username, $password);
                 $twitter->sendTweet($tweet);
             } catch (Exception $e) {
             }
         }
     } else {
         $url = $users->getUrl($user->id);
         $tweet = sprintf($this->_update_tweet, $count, $url);
         try {
             $twitter = new Stuffpress_Services_Twitter($username, $password);
             $twitter->sendTweet($tweet);
         } catch (Exception $e) {
         }
     }
 }
 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');
 }
 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();
 }
 /**
  * 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'));
 }
 /**
  * Assign the configuration of this Manager. Valid configuration options are as
  * follows:
  *	database_index			integer
  *	database_name			string
  * 
  * @param object Properties $configuration (original type: java.util.Properties)
  * 
  * @throws object OsidException An exception with one of the following
  *		   messages defined in org.osid.OsidException:	{@link
  *		   org.osid.OsidException#OPERATION_FAILED OPERATION_FAILED},
  *		   {@link org.osid.OsidException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.OsidException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.OsidException#UNIMPLEMENTED UNIMPLEMENTED}, {@link
  *		   org.osid.OsidException#NULL_ARGUMENT NULL_ARGUMENT}
  * 
  * @access public
  */
 function assignConfiguration(Properties $configuration)
 {
     $this->_configuration = $configuration;
     $dbIndex = $configuration->getProperty('database_index');
     $authzDB = $configuration->getProperty('database_name');
     // ** parameter validation
     ArgumentValidator::validate($dbIndex, IntegerValidatorRule::getRule(), true);
     ArgumentValidator::validate($authzDB, StringValidatorRule::getRule(), true);
     // ** end of parameter validation
     // Store the Harmoni_Db adapter if it is configured.
     $harmoni_db_name = $this->_configuration->getProperty('harmoni_db_name');
     if (!is_null($harmoni_db_name)) {
         try {
             $this->harmoni_db = Harmoni_Db::getDatabase($harmoni_db_name);
         } catch (UnknownIdException $e) {
         }
     }
     if (isset($this->harmoni_db)) {
         $this->_cache = new AuthZ2_AuthorizationCache($this, $dbIndex, $this->harmoni_db);
     } else {
         $this->_cache = new AuthZ2_AuthorizationCache($this, $dbIndex);
     }
     // do a test to see if our configuration worked.
     try {
         $this->getFunctionTypes();
     } catch (QueryDatabaseException $e) {
         throw new ConfigurationErrorException("Database is not properly set up for AuthZ2.");
     }
 }
Exemple #29
0
 /**
  * This gets a property that was set via command line or otherwise passed into Phing.
  * "Defined" in this case means "externally defined".  The reason this method exists is to
  * provide a public means of accessing commandline properties for (e.g.) logger or listener
  * scripts.  E.g. to specify which logfile to use, PearLogger needs to be able to access
  * the pear.log.name property.
  *
  * @param string $name
  * @return string value of found property (or null, if none found).
  */
 public static function getDefinedProperty($name)
 {
     return self::$definedProps->getProperty($name);
 }
 /**
  * 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);
     }
 }