From 998a39940b27561d7a2e98b68c8929dab68fe62f Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 3 Nov 2010 19:46:47 +0000 Subject: Refs #1320. Updated core to use elgg_echo()'s native string replacement. git-svn-id: http://code.elgg.org/elgg/trunk@7227 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/classes/ElggAnnotation.php | 6 +++--- engine/classes/ElggDiskFilestore.php | 8 ++++---- engine/classes/ElggExtender.php | 10 +++++----- engine/classes/ElggFile.php | 8 ++++---- engine/classes/ElggFileCache.php | 2 +- engine/classes/ElggGroup.php | 6 +++--- engine/classes/ElggMemcache.php | 6 +++--- engine/classes/ElggMetadata.php | 8 ++++---- engine/classes/ElggObject.php | 6 +++--- engine/classes/ElggRelationship.php | 4 ++-- engine/classes/ElggSite.php | 6 +++--- engine/classes/ElggUser.php | 6 +++--- engine/handlers/cron_handler.php | 2 +- engine/lib/actions.php | 30 ++++++++++++++-------------- engine/lib/api.php | 38 ++++++++++++++++++------------------ engine/lib/cron.php | 2 +- engine/lib/database.php | 8 ++++---- engine/lib/entities.php | 28 +++++++++++++------------- engine/lib/export.php | 2 +- engine/lib/extender.php | 6 +++--- engine/lib/group.php | 10 +++++----- engine/lib/notification.php | 12 ++++++------ engine/lib/objects.php | 2 +- engine/lib/output.php | 32 +++++++++++++++--------------- engine/lib/plugins.php | 8 ++++---- engine/lib/relationships.php | 6 +++--- engine/lib/sites.php | 2 +- engine/lib/users.php | 8 ++++---- engine/lib/xml-rpc.php | 8 ++++---- 29 files changed, 140 insertions(+), 140 deletions(-) (limited to 'engine') diff --git a/engine/classes/ElggAnnotation.php b/engine/classes/ElggAnnotation.php index da43aea23..60a79bac9 100644 --- a/engine/classes/ElggAnnotation.php +++ b/engine/classes/ElggAnnotation.php @@ -16,10 +16,10 @@ class ElggAnnotation extends ElggExtender { protected function initializeAttributes() { parent::initializeAttributes(); - + $this->attributes['type'] = 'annotation'; } - + /** * Construct a new annotation, optionally from a given id value or db object. * @@ -59,7 +59,7 @@ class ElggAnnotation extends ElggExtender { $this->value_type, $this->owner_guid, $this->access_id); if (!$this->id) { - throw new IOException(sprintf(elgg_echo('IOException:UnableToSaveNew'), get_class())); + throw new IOException(elgg_echo('IOException:UnableToSaveNew', array(get_class()))); } return $this->id; } diff --git a/engine/classes/ElggDiskFilestore.php b/engine/classes/ElggDiskFilestore.php index 4f9aae1af..780598a87 100644 --- a/engine/classes/ElggDiskFilestore.php +++ b/engine/classes/ElggDiskFilestore.php @@ -83,7 +83,7 @@ class ElggDiskFilestore extends ElggFilestore { $mode = "a+b"; break; default: - $msg = sprintf(elgg_echo('InvalidParameterException:UnrecognisedFileMode'), $mode); + $msg = elgg_echo('InvalidParameterException:UnrecognisedFileMode', array($mode)); throw new InvalidParameterException($msg); } @@ -206,8 +206,8 @@ class ElggDiskFilestore extends ElggFilestore { } if ((!$owner) || (!$owner->username)) { - $msg = sprintf(elgg_echo('InvalidParameterException:MissingOwner'), - $file->getFilename(), $file->guid); + $msg = elgg_echo('InvalidParameterException:MissingOwner', + array($file->getFilename(), $file->guid)); throw new InvalidParameterException($msg); } @@ -278,7 +278,7 @@ class ElggDiskFilestore extends ElggFilestore { protected function makeDirectoryRoot($dirroot) { if (!file_exists($dirroot)) { if (!@mkdir($dirroot, 0700, true)) { - throw new IOException(sprintf(elgg_echo('IOException:CouldNotMake'), $dirroot)); + throw new IOException(elgg_echo('IOException:CouldNotMake', array($dirroot))); } } diff --git a/engine/classes/ElggExtender.php b/engine/classes/ElggExtender.php index 8d0f4bd66..78ccea395 100644 --- a/engine/classes/ElggExtender.php +++ b/engine/classes/ElggExtender.php @@ -21,10 +21,10 @@ abstract class ElggExtender extends ElggData { protected function initializeAttributes() { parent::initializeAttributes(); - + $this->attributes['type'] = ''; } - + /** * Returns an attribute * @@ -48,8 +48,8 @@ abstract class ElggExtender extends ElggData break; default : - $msg = sprintf(elgg_echo('InstallationException:TypeNotSupported'), - $this->attributes['value_type']); + $msg = elgg_echo('InstallationException:TypeNotSupported', array( + $this->attributes['value_type'])); throw new InstallationException($msg); break; @@ -96,7 +96,7 @@ abstract class ElggExtender extends ElggData public function getOwnerEntity() { return get_entity($this->owner_guid); } - + /** * Return the entity this describes. * diff --git a/engine/classes/ElggFile.php b/engine/classes/ElggFile.php index 46cd0b6a0..a55bbc443 100644 --- a/engine/classes/ElggFile.php +++ b/engine/classes/ElggFile.php @@ -164,7 +164,7 @@ class ElggFile extends ElggObject { ($mode != "write") && ($mode != "append") ) { - $msg = sprintf(elgg_echo('InvalidParameterException:UnrecognisedFileMode'), $mode); + $msg = elgg_echo('InvalidParameterException:UnrecognisedFileMode', array($mode)); throw new InvalidParameterException($msg); } @@ -343,9 +343,9 @@ class ElggFile extends ElggObject { if (isset($parameters['filestore'])) { if (!class_exists($parameters['filestore'])) { - $msg = sprintf(elgg_echo('ClassNotFoundException:NotFoundNotSavedWithFile'), - $parameters['filestore'], - $this->guid); + $msg = elgg_echo('ClassNotFoundException:NotFoundNotSavedWithFile', + array($parameters['filestore'], + $this->guid)); throw new ClassNotFoundException($msg); } diff --git a/engine/classes/ElggFileCache.php b/engine/classes/ElggFileCache.php index 2072af620..c27e9aa32 100644 --- a/engine/classes/ElggFileCache.php +++ b/engine/classes/ElggFileCache.php @@ -188,7 +188,7 @@ class ElggFileCache extends ElggCache { $files = scandir($dir); if (!$files) { - throw new IOException(sprintf(elgg_echo('IOException:NotDirectory'), $dir)); + throw new IOException(elgg_echo('IOException:NotDirectory', array($dir))); } // Perform cleanup diff --git a/engine/classes/ElggGroup.php b/engine/classes/ElggGroup.php index 00502dd39..963d80821 100644 --- a/engine/classes/ElggGroup.php +++ b/engine/classes/ElggGroup.php @@ -54,7 +54,7 @@ class ElggGroup extends ElggEntity if ($guid instanceof stdClass) { // Load the rest if (!$this->load($guid->guid)) { - $msg = sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid->guid); + $msg = elgg_echo('IOException:FailedToLoadGUID', array(get_class(), $guid->guid)); throw new IOException($msg); } @@ -73,7 +73,7 @@ class ElggGroup extends ElggEntity // We assume if we have got this far, $guid is an int } else if (is_numeric($guid)) { if (!$this->load($guid)) { - throw new IOException(sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid)); + throw new IOException(elgg_echo('IOException:FailedToLoadGUID', array(get_class(), $guid))); } } else { throw new InvalidParameterException(elgg_echo('InvalidParameterException:UnrecognisedValue')); @@ -342,7 +342,7 @@ class ElggGroup extends ElggEntity // Check the type if ($this->attributes['type'] != 'group') { - $msg = sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $guid, get_class()); + $msg = elgg_echo('InvalidClassException:NotValidElggStar', array($guid, get_class())); throw new InvalidClassException($msg); } diff --git a/engine/classes/ElggMemcache.php b/engine/classes/ElggMemcache.php index e0d8e7bee..7d19fb2c7 100644 --- a/engine/classes/ElggMemcache.php +++ b/engine/classes/ElggMemcache.php @@ -85,10 +85,10 @@ class ElggMemcache extends ElggSharedMemoryCache { // Get version $this->version = $this->memcache->getVersion(); if (version_compare($this->version, ElggMemcache::$MINSERVERVERSION, '<')) { - $msg = sprintf(elgg_echo('memcache:versiontoolow'), - ElggMemcache::$MINSERVERVERSION, + $msg = elgg_echo('memcache:versiontoolow', + array(ElggMemcache::$MINSERVERVERSION, $this->version - ); + )); throw new ConfigurationException($msg); } diff --git a/engine/classes/ElggMetadata.php b/engine/classes/ElggMetadata.php index 90cbba5bd..12e458629 100644 --- a/engine/classes/ElggMetadata.php +++ b/engine/classes/ElggMetadata.php @@ -8,13 +8,13 @@ * @subpackage Metadata */ class ElggMetadata extends ElggExtender { - + protected function initializeAttributes() { parent::initializeAttributes(); - + $this->attributes['type'] = "metadata"; } - + /** * Construct a new site object, optionally from a given id value or row. * @@ -68,7 +68,7 @@ class ElggMetadata extends ElggExtender { $this->value_type, $this->owner_guid, $this->access_id); if (!$this->id) { - throw new IOException(sprintf(elgg_echo('IOException:UnableToSaveNew'), get_class())); + throw new IOException(elgg_echo('IOException:UnableToSaveNew', array(get_class()))); } return $this->id; } diff --git a/engine/classes/ElggObject.php b/engine/classes/ElggObject.php index b721c479c..a808f4b9f 100644 --- a/engine/classes/ElggObject.php +++ b/engine/classes/ElggObject.php @@ -69,7 +69,7 @@ class ElggObject extends ElggEntity { if ($guid instanceof stdClass) { // Load the rest if (!$this->load($guid->guid)) { - $msg = sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid->guid); + $msg = elgg_echo('IOException:FailedToLoadGUID', array(get_class(), $guid->guid)); throw new IOException($msg); } @@ -88,7 +88,7 @@ class ElggObject extends ElggEntity { // We assume if we have got this far, $guid is an int } else if (is_numeric($guid)) { if (!$this->load($guid)) { - throw new IOException(sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid)); + throw new IOException(elgg_echo('IOException:FailedToLoadGUID', array(get_class(), $guid))); } } else { throw new InvalidParameterException(elgg_echo('InvalidParameterException:UnrecognisedValue')); @@ -112,7 +112,7 @@ class ElggObject extends ElggEntity { // Check the type if ($this->attributes['type'] != 'object') { - $msg = sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $guid, get_class()); + $msg = elgg_echo('InvalidClassException:NotValidElggStar', array($guid, get_class())); throw new InvalidClassException($msg); } diff --git a/engine/classes/ElggRelationship.php b/engine/classes/ElggRelationship.php index 413527df3..50a86fff1 100644 --- a/engine/classes/ElggRelationship.php +++ b/engine/classes/ElggRelationship.php @@ -73,7 +73,7 @@ class ElggRelationship extends ElggData implements $this->id = add_entity_relationship($this->guid_one, $this->relationship, $this->guid_two); if (!$this->id) { - throw new IOException(sprintf(elgg_echo('IOException:UnableToSaveNew'), get_class())); + throw new IOException(elgg_echo('IOException:UnableToSaveNew', array(get_class()))); } return $this->id; @@ -168,7 +168,7 @@ class ElggRelationship extends ElggData implements // save $result = $this->save(); if (!$result) { - throw new ImportException(sprintf(elgg_echo('ImportException:ProblemSaving'), get_class())); + throw new ImportException(elgg_echo('ImportException:ProblemSaving', array(get_class()))); } return $this; diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php index febd70be6..0a4c48d8e 100644 --- a/engine/classes/ElggSite.php +++ b/engine/classes/ElggSite.php @@ -82,7 +82,7 @@ class ElggSite extends ElggEntity { if ($guid instanceof stdClass) { // Load the rest if (!$this->load($guid->guid)) { - $msg = sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid->guid); + $msg = elgg_echo('IOException:FailedToLoadGUID', array(get_class(), $guid->guid)); throw new IOException($msg); } @@ -108,7 +108,7 @@ class ElggSite extends ElggEntity { // We assume if we have got this far, $guid is an int } else if (is_numeric($guid)) { if (!$this->load($guid)) { - throw new IOException(sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid)); + throw new IOException(elgg_echo('IOException:FailedToLoadGUID', array(get_class(), $guid))); } } else { throw new InvalidParameterException(elgg_echo('InvalidParameterException:UnrecognisedValue')); @@ -132,7 +132,7 @@ class ElggSite extends ElggEntity { // Check the type if ($this->attributes['type'] != 'site') { - $msg = sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $guid, get_class()); + $msg = elgg_echo('InvalidClassException:NotValidElggStar', array($guid, get_class())); throw new InvalidClassException($msg); } diff --git a/engine/classes/ElggUser.php b/engine/classes/ElggUser.php index ec951b359..cb2d565fc 100644 --- a/engine/classes/ElggUser.php +++ b/engine/classes/ElggUser.php @@ -65,7 +65,7 @@ class ElggUser extends ElggEntity if ($guid instanceof stdClass) { // Load the rest if (!$this->load($guid->guid)) { - $msg = sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid->guid); + $msg = elgg_echo('IOException:FailedToLoadGUID', array(get_class(), $guid->guid)); throw new IOException($msg); } @@ -91,7 +91,7 @@ class ElggUser extends ElggEntity // We assume if we have got this far, $guid is an int } else if (is_numeric($guid)) { if (!$this->load($guid)) { - throw new IOException(sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid)); + throw new IOException(elgg_echo('IOException:FailedToLoadGUID', array(get_class(), $guid))); } } else { throw new InvalidParameterException(elgg_echo('InvalidParameterException:UnrecognisedValue')); @@ -116,7 +116,7 @@ class ElggUser extends ElggEntity // Check the type if ($this->attributes['type'] != 'user') { - $msg = sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $guid, get_class()); + $msg = elgg_echo('InvalidClassException:NotValidElggStar', array($guid, get_class())); throw new InvalidClassException($msg); } diff --git a/engine/handlers/cron_handler.php b/engine/handlers/cron_handler.php index 537b34f39..939beeaf4 100644 --- a/engine/handlers/cron_handler.php +++ b/engine/handlers/cron_handler.php @@ -18,7 +18,7 @@ global $CONFIG; $period = get_input('period'); if (!$period) { - throw new CronException(sprintf(elgg_echo('CronException:unknownperiod'), $period)); + throw new CronException(elgg_echo('CronException:unknownperiod', array($period))); } // Get a list of parameters diff --git a/engine/lib/actions.php b/engine/lib/actions.php index bcd7e759e..35f9dc4b3 100644 --- a/engine/lib/actions.php +++ b/engine/lib/actions.php @@ -100,7 +100,7 @@ function action($action, $forwarder = "") { // @todo make this better! if ($event_result) { if (!include($CONFIG->actions[$action]['file'])) { - register_error(sprintf(elgg_echo('actionnotfound'), $action)); + register_error(elgg_echo('actionnotfound', array($action))); } } } else { @@ -110,7 +110,7 @@ function action($action, $forwarder = "") { register_error(elgg_echo('actionunauthorized')); } } else { - register_error(sprintf(elgg_echo('actionundefined'), $action)); + register_error(elgg_echo('actionundefined', array($action))); } forward($forwarder); @@ -359,26 +359,26 @@ function elgg_action_exist($action) { function actions_init() { register_action('security/refreshtoken', TRUE); - + elgg_view_register_simplecache('js/languages/en'); - + register_plugin_hook('action', 'all', 'ajax_action_hook'); register_plugin_hook('forward', 'all', 'ajax_forward_hook'); } /** * Checks whether the request was requested via ajax - * + * * @return bool whether page was requested via ajax */ function elgg_is_xhr() { - return isset($_SERVER['HTTP_X_REQUESTED_WITH']) - && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'; + return isset($_SERVER['HTTP_X_REQUESTED_WITH']) + && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'; } /** * Catch calls to forward() in ajax request and force an exit. - * + * * Forces response is json of the following form: *
  * {
@@ -392,18 +392,18 @@ function elgg_is_xhr() {
  * }
  * 
* where "system_messages" is all message registers at the point of forwarding - * + * * @param string $hook - * @param string $type + * @param string $type * @param string $reason * @param array $params - * + * */ function ajax_forward_hook($hook, $type, $reason, $params) { if (elgg_is_xhr()) { //grab any data echo'd in the action $output = ob_get_clean(); - + //Avoid double-encoding in case data is json $json = json_decode($output); if (isset($json)) { @@ -411,16 +411,16 @@ function ajax_forward_hook($hook, $type, $reason, $params) { } else { $params['output'] = $output; } - + //Grab any system messages so we can inject them via ajax too $params['system_messages'] = system_messages(NULL, ""); - + if (isset($params['system_messages']['errors'])) { $params['status'] = -1; } else { $params['status'] = 0; } - + header("Content-type: application/json"); echo json_encode($params); exit; diff --git a/engine/lib/api.php b/engine/lib/api.php index 93de88d5b..642449fff 100644 --- a/engine/lib/api.php +++ b/engine/lib/api.php @@ -82,14 +82,14 @@ $call_method = "GET", $require_api_auth = false, $require_user_auth = false) { if ($parameters != NULL) { if (!is_array($parameters)) { - $msg = sprintf(elgg_echo('InvalidParameterException:APIParametersArrayStructure'), $method); + $msg = elgg_echo('InvalidParameterException:APIParametersArrayStructure', array($method)); throw new InvalidParameterException($msg); } // catch common mistake of not setting up param array correctly $first = current($parameters); if (!is_array($first)) { - $msg = sprintf(elgg_echo('InvalidParameterException:APIParametersArrayStructure'), $method); + $msg = elgg_echo('InvalidParameterException:APIParametersArrayStructure', array($method)); throw new InvalidParameterException($msg); } } @@ -115,8 +115,8 @@ $call_method = "GET", $require_api_auth = false, $require_user_auth = false) { $API_METHODS[$method]["call_method"] = 'GET'; break; default : - $msg = sprintf(elgg_echo('InvalidParameterException:UnrecognisedHttpMethod'), - $call_method, $method); + $msg = elgg_echo('InvalidParameterException:UnrecognisedHttpMethod', + array($call_method, $method)); throw new InvalidParameterException($msg); } @@ -159,7 +159,7 @@ function authenticate_method($method) { // method must be exposed if (!isset($API_METHODS[$method])) { - throw new APIException(sprintf(elgg_echo('APIException:MethodCallNotImplemented'), $method)); + throw new APIException(elgg_echo('APIException:MethodCallNotImplemented', array($method))); } // make sure that POST variables are available if needed @@ -201,7 +201,7 @@ function execute_method($method) { // method must be exposed if (!isset($API_METHODS[$method])) { - $msg = sprintf(elgg_echo('APIException:MethodCallNotImplemented'), $method); + $msg = elgg_echo('APIException:MethodCallNotImplemented', array($method)); throw new APIException($msg); } @@ -209,14 +209,14 @@ function execute_method($method) { if (!(isset($API_METHODS[$method]["function"])) || !(is_callable($API_METHODS[$method]["function"]))) { - $msg = sprintf(elgg_echo('APIException:FunctionDoesNotExist'), $method); + $msg = elgg_echo('APIException:FunctionDoesNotExist', array($method)); throw new APIException($msg); } // check http call method if (strcmp(get_call_method(), $API_METHODS[$method]["call_method"]) != 0) { - $msg = sprintf(elgg_echo('CallException:InvalidCallMethod'), $method, - $API_METHODS[$method]["call_method"]); + $msg = elgg_echo('CallException:InvalidCallMethod', array($method, + $API_METHODS[$method]["call_method"])); throw new CallException($msg); } @@ -242,13 +242,13 @@ function execute_method($method) { } if ($result === false) { - $msg = sprintf(elgg_echo('APIException:FunctionParseError'), $function, $serialised_parameters); + $msg = elgg_echo('APIException:FunctionParseError', array($function, $serialised_parameters)); throw new APIException($msg); } if ($result === NULL) { // If no value - $msg = sprintf(elgg_echo('APIException:FunctionNoReturn'), $function, $serialised_parameters); + $msg = elgg_echo('APIException:FunctionNoReturn', array($function, $serialised_parameters)); throw new APIException($msg); } @@ -365,13 +365,13 @@ function verify_parameters($method, $parameters) { // this tests the expose structure: must be array to describe parameter and type must be defined if (!is_array($value) || !isset($value['type'])) { - $msg = sprintf(elgg_echo('APIException:InvalidParameter'), $key, $method); + $msg = elgg_echo('APIException:InvalidParameter', array($key, $method)); throw new APIException($msg); } // Check that the variable is present in the request if required if ($value['required'] && !array_key_exists($key, $parameters)) { - $msg = sprintf(elgg_echo('APIException:MissingParameterInMethod'), $key, $method); + $msg = elgg_echo('APIException:MissingParameterInMethod', array($key, $method)); throw new APIException($msg); } } @@ -433,7 +433,7 @@ function serialise_parameters($method, $parameters) { case 'array': // we can handle an array of strings, maybe ints, definitely not booleans or other arrays if (!is_array($parameters[$key])) { - $msg = sprintf(elgg_echo('APIException:ParameterNotArray'), $key); + $msg = elgg_echo('APIException:ParameterNotArray', array($key)); throw new APIException($msg); } @@ -454,7 +454,7 @@ function serialise_parameters($method, $parameters) { $serialised_parameters .= $array; break; default: - $msg = sprintf(elgg_echo('APIException:UnrecognisedTypeCast'), $value['type'], $key, $method); + $msg = elgg_echo('APIException:UnrecognisedTypeCast', array($value['type'], $key, $method)); throw new APIException($msg); } } @@ -548,8 +548,8 @@ function api_auth_hmac() { $calculated_posthash = calculate_posthash($postdata, $api_header->posthash_algo); if (strcmp($api_header->posthash, $calculated_posthash) != 0) { - $msg = sprintf(elgg_echo('SecurityException:InvalidPostHash'), - $calculated_posthash, $api_header->posthash); + $msg = elgg_echo('SecurityException:InvalidPostHash', + array($calculated_posthash, $api_header->posthash)); throw new SecurityException($msg); } @@ -652,7 +652,7 @@ function map_api_hash($algo) { return $supported_algos[$algo]; } - throw new APIException(sprintf(elgg_echo('APIException:AlgorithmNotSupported'), $algo)); + throw new APIException(elgg_echo('APIException:AlgorithmNotSupported', array($algo))); } /** @@ -1039,7 +1039,7 @@ $content_type = 'application/octet-stream') { case 'POST' : break; default: - $msg = sprintf(elgg_echo('NotImplementedException:CallMethodNotImplemented'), $method); + $msg = elgg_echo('NotImplementedException:CallMethodNotImplemented', array($method)); throw new NotImplementedException($msg); } diff --git a/engine/lib/cron.php b/engine/lib/cron.php index 811a4cdda..d51a34bf7 100644 --- a/engine/lib/cron.php +++ b/engine/lib/cron.php @@ -44,7 +44,7 @@ function cron_page_handler($page) { set_input('period', $page[0]); break; default : - throw new CronException(sprintf(elgg_echo('CronException:unknownperiod'), $page[0])); + throw new CronException(elgg_echo('CronException:unknownperiod', array($page[0]))); } // Include cron handler diff --git a/engine/lib/database.php b/engine/lib/database.php index 16efb5874..4a99afea1 100644 --- a/engine/lib/database.php +++ b/engine/lib/database.php @@ -95,13 +95,13 @@ function establish_db_link($dblinkname = "readwrite") { // Connect to database if (!$dblink[$dblinkname] = mysql_connect($dbhost, $dbuser, $dbpass, true)) { - $msg = sprintf(elgg_echo('DatabaseException:WrongCredentials'), - $dbuser, $dbhost, "****"); + $msg = elgg_echo('DatabaseException:WrongCredentials', + array($dbuser, $dbhost, "****")); throw new DatabaseException($msg); } if (!mysql_select_db($dbname, $dblink[$dblinkname])) { - $msg = sprintf(elgg_echo('DatabaseException:NoConnect'), $dbname); + $msg = elgg_echo('DatabaseException:NoConnect', array($dbname)); throw new DatabaseException($msg); } @@ -640,7 +640,7 @@ function run_sql_script($scriptlocation) { throw new DatabaseException($msg); } } else { - $msg = sprintf(elgg_echo('DatabaseException:ScriptNotFound'), $scriptlocation); + $msg = elgg_echo('DatabaseException:ScriptNotFound', array($scriptlocation)); throw new DatabaseException($msg); } } diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 376133fec..36e9eb115 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -439,7 +439,7 @@ function update_entity($guid, $owner_guid, $access_id, $container_guid = null) { * * @param int $user_guid The user guid, or 0 for get_loggedin_userid() * @param int $container_guid The container, or 0 for the current page owner. - * @param string $type The type of entity we're looking to write + * @param string $type The type of entity we're looking to write * @param string $subtype The subtype of the entity we're looking to write * * @return bool @@ -619,11 +619,11 @@ function entity_row_to_elggstar($row) { $new_entity = new $classname($row); if (!($new_entity instanceof ElggEntity)) { - $msg = sprintf(elgg_echo('ClassException:ClassnameNotClass'), $classname, 'ElggEntity'); + $msg = elgg_echo('ClassException:ClassnameNotClass', array($classname, 'ElggEntity')); throw new ClassException($msg); } } else { - error_log(sprintf(elgg_echo('ClassNotFoundException:MissingClass'), $classname)); + error_log(elgg_echo('ClassNotFoundException:MissingClass', array($classname))); } } @@ -643,7 +643,7 @@ function entity_row_to_elggstar($row) { $new_entity = new ElggSite($row); break; default: - $msg = sprintf(elgg_echo('InstallationException:TypeNotSupported'), $row->type); + $msg = elgg_echo('InstallationException:TypeNotSupported', array($row->type)); throw new InstallationException($msg); } } @@ -1317,7 +1317,7 @@ function elgg_get_entity_site_where_sql($table, $site_guids) { * full_view => BOOL Display full view entities * view_type_toggle => BOOL Display gallery / list switch * pagination => BOOL Display pagination links - * + * * @param mixed $getter The entity getter function to use to fetch the entities * * @return string @@ -1334,12 +1334,12 @@ function elgg_list_entities(array $options = array(), $getter = 'elgg_get_entiti 'view_type_toggle' => FALSE, 'pagination' => TRUE, ); - + $options = array_merge($defaults, $options); $options['count'] = TRUE; $count = $getter($options); - + $options['count'] = FALSE; $entities = $getter($options); @@ -1817,7 +1817,7 @@ function export_entity_plugin_hook($hook, $entity_type, $returnvalue, $params) { // Get the entity $entity = get_entity($guid); if (!($entity instanceof ElggEntity)) { - $msg = sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $guid, get_class()); + $msg = elgg_echo('InvalidClassException:NotValidElggStar', array($guid, get_class())); throw new InvalidClassException($msg); } @@ -1858,11 +1858,11 @@ function oddentity_to_elggentity(ODDEntity $element) { $tmp = new $classname(); if (!($tmp instanceof ElggEntity)) { - $msg = sprintf(elgg_echo('ClassException:ClassnameNotClass', $classname, get_class())); + $msg = elgg_echo('ClassException:ClassnameNotClass', array($classname, get_class())); throw new ClassException($msg); } } else { - error_log(sprintf(elgg_echo('ClassNotFoundException:MissingClass'), $classname)); + error_log(elgg_echo('ClassNotFoundException:MissingClass', array($classname))); } } else { switch ($class) { @@ -1879,7 +1879,7 @@ function oddentity_to_elggentity(ODDEntity $element) { $tmp = new ElggSite($row); break; default: - $msg = sprintf(elgg_echo('InstallationException:TypeNotSupported'), $class); + $msg = elgg_echo('InstallationException:TypeNotSupported', array($class)); throw new InstallationException($msg); } } @@ -1887,7 +1887,7 @@ function oddentity_to_elggentity(ODDEntity $element) { if ($tmp) { if (!$tmp->import($element)) { - $msg = sprintf(elgg_echo('ImportException:ImportFailed'), $element->getAttribute('uuid')); + $msg = elgg_echo('ImportException:ImportFailed', array($element->getAttribute('uuid'))); throw new ImportException($msg); } @@ -1925,7 +1925,7 @@ function import_entity_plugin_hook($hook, $entity_type, $returnvalue, $params) { if ($tmp) { // Make sure its saved if (!$tmp->save()) { - sprintf(elgg_echo('ImportException:ProblemSaving'), $element->getAttribute('uuid')); + elgg_echo('ImportException:ProblemSaving', array($element->getAttribute('uuid'))); throw new ImportException($msg); } @@ -2141,7 +2141,7 @@ function get_entity_url($entity_guid) { if ($url == "") { $url = "pg/view/" . $entity_guid; } - + return elgg_normalize_url($url); } diff --git a/engine/lib/export.php b/engine/lib/export.php index 3a5c74a0f..1704ef81d 100644 --- a/engine/lib/export.php +++ b/engine/lib/export.php @@ -149,7 +149,7 @@ function exportAsArray($guid) { // Sanity check if ((!is_array($to_be_serialised)) || (count($to_be_serialised) == 0)) { - throw new ExportException(sprintf(elgg_echo('ExportException:NoSuchEntity'), $guid)); + throw new ExportException(elgg_echo('ExportException:NoSuchEntity', array($guid))); } return $to_be_serialised; diff --git a/engine/lib/extender.php b/engine/lib/extender.php index 845cfd85f..a67f29a68 100644 --- a/engine/lib/extender.php +++ b/engine/lib/extender.php @@ -97,14 +97,14 @@ function import_extender_plugin_hook($hook, $entity_type, $returnvalue, $params) $entity_uuid = $element->getAttribute('entity_uuid'); $entity = get_entity_from_uuid($entity_uuid); if (!$entity) { - throw new ImportException(sprintf(elgg_echo('ImportException:GUIDNotFound'), $entity_uuid)); + throw new ImportException(elgg_echo('ImportException:GUIDNotFound', array($entity_uuid))); } oddmetadata_to_elggextender($entity, $element); // Save if (!$entity->save()) { - $msg = sprintf(elgg_echo('ImportException:ProblemUpdatingMeta'), $attr_name, $entity_uuid); + $msg = elgg_echo('ImportException:ProblemUpdatingMeta', array($attr_name, $entity_uuid)); throw new ImportException($msg); } @@ -231,7 +231,7 @@ function get_extender_url(ElggExtender $extender) { } $url = "export/$view/$guid/$type/$nameid/"; } - + return elgg_normalize_url($url); } diff --git a/engine/lib/group.php b/engine/lib/group.php index 31dc434ab..53053976a 100644 --- a/engine/lib/group.php +++ b/engine/lib/group.php @@ -116,12 +116,12 @@ function add_object_to_group($group_guid, $object_guid) { } if (!($group instanceof ElggGroup)) { - $msg = sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $group_guid, 'ElggGroup'); + $msg = elgg_echo('InvalidClassException:NotValidElggStar', array($group_guid, 'ElggGroup')); throw new InvalidClassException($msg); } if (!($object instanceof ElggObject)) { - $msg = sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $object_guid, 'ElggObject'); + $msg = elgg_echo('InvalidClassException:NotValidElggStar', array($object_guid, 'ElggObject')); throw new InvalidClassException($msg); } @@ -150,12 +150,12 @@ function remove_object_from_group($group_guid, $object_guid) { } if (!($group instanceof ElggGroup)) { - $msg = sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $group_guid, 'ElggGroup'); + $msg = elgg_echo('InvalidClassException:NotValidElggStar', array($group_guid, 'ElggGroup')); throw new InvalidClassException($msg); } if (!($object instanceof ElggObject)) { - $msg = sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $object_guid, 'ElggObject'); + $msg = elgg_echo('InvalidClassException:NotValidElggStar', array($object_guid, 'ElggObject')); throw new InvalidClassException($msg); } @@ -390,7 +390,7 @@ function get_entities_from_metadata_groups_multi($group_guid, $meta_array, $enti $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) { elgg_deprecated_notice("get_entities_from_metadata_groups_multi was deprecated in 1.8.", 1.8); - + global $CONFIG; if (!is_array($meta_array) || sizeof($meta_array) == 0) { diff --git a/engine/lib/notification.php b/engine/lib/notification.php index cfb79715c..5aef42aad 100644 --- a/engine/lib/notification.php +++ b/engine/lib/notification.php @@ -132,7 +132,7 @@ function notify_user($to, $from, $subject, $message, array $params = NULL, $meth $handler = $details->handler; if ((!$NOTIFICATION_HANDLERS[$method]) || (!$handler)) { - error_log(sprintf(elgg_echo('NotificationException:NoHandlerFound'), $method)); + error_log(elgg_echo('NotificationException:NoHandlerFound', array($method))); } elgg_log("Sending message to $guid using $method"); @@ -238,17 +238,17 @@ array $params = NULL) { global $CONFIG; if (!$from) { - $msg = sprintf(elgg_echo('NotificationException:MissingParameter'), 'from'); + $msg = elgg_echo('NotificationException:MissingParameter', array('from')); throw new NotificationException($msg); } if (!$to) { - $msg = sprintf(elgg_echo('NotificationException:MissingParameter'), 'to'); + $msg = elgg_echo('NotificationException:MissingParameter', array('to')); throw new NotificationException($msg); } if ($to->email == "") { - $msg = sprintf(elgg_echo('NotificationException:NoEmailAddress'), $to->guid); + $msg = elgg_echo('NotificationException:NoEmailAddress', array($to->guid)); throw new NotificationException($msg); } @@ -287,12 +287,12 @@ function elgg_send_email($from, $to, $subject, $body, array $params = NULL) { global $CONFIG; if (!$from) { - $msg = sprintf(elgg_echo('NotificationException:NoEmailAddress'), 'from'); + $msg = elgg_echo('NotificationException:NoEmailAddress', array('from')); throw new NotificationException($msg); } if (!$to) { - $msg = sprintf(elgg_echo('NotificationException:NoEmailAddress'), 'to'); + $msg = elgg_echo('NotificationException:NoEmailAddress', array('to')); throw new NotificationException($msg); } diff --git a/engine/lib/objects.php b/engine/lib/objects.php index ae30edb13..5b7521922 100644 --- a/engine/lib/objects.php +++ b/engine/lib/objects.php @@ -89,7 +89,7 @@ function create_object_entity($guid, $title, $description) { * @return 1 */ function delete_object_entity($guid) { - system_message(sprintf(elgg_echo('deprecatedfunction'), 'delete_user_entity')); + system_message(elgg_echo('deprecatedfunction', array('delete_user_entity'))); return 1; // Always return that we have deleted one row in order to not break existing code. } diff --git a/engine/lib/output.php b/engine/lib/output.php index 35ace7c09..84b012631 100644 --- a/engine/lib/output.php +++ b/engine/lib/output.php @@ -140,31 +140,31 @@ function elgg_format_url($url) { } /** - * Converts shorthand urls to absolute urls. - * + * Converts shorthand urls to absolute urls. + * * If the url is already absolute or protocol-relative, no change is made. - * - * @example + * + * @example * elgg_normalize_url(''); // 'http://my.site.com/' * elgg_normalize_url('pg/dashboard'); // 'http://my.site.com/pg/dashboard' * elgg_normalize_url('http://google.com/'); // no change * elgg_normalize_url('//google.com/'); // no change - * + * * @param string $url The URL to normalize - * + * * @return string The absolute url */ function elgg_normalize_url($url) { // 'http://example.com', 'https://example.com', '//example.com' if (preg_match("#^(https?:)?//#i", $url)) { return $url; - } - + } + // 'example.com', 'example.com/subpage' elseif (preg_match("#[^/]*\.[^/]*/?#i", $url)) { return "http://$url"; - } - + } + // 'pg/page/handler' else { return elgg_get_site_url().$url; @@ -257,9 +257,9 @@ function elgg_get_friendly_time($time) { } if ($diff > 1) { - return sprintf(elgg_echo("friendlytime:minutes"), $diff); + return elgg_echo("friendlytime:minutes", array($diff)); } else { - return sprintf(elgg_echo("friendlytime:minutes:singular"), $diff); + return elgg_echo("friendlytime:minutes:singular", array($diff)); } } else if ($diff < $day) { $diff = round($diff / $hour); @@ -268,9 +268,9 @@ function elgg_get_friendly_time($time) { } if ($diff > 1) { - return sprintf(elgg_echo("friendlytime:hours"), $diff); + return elgg_echo("friendlytime:hours", array($diff)); } else { - return sprintf(elgg_echo("friendlytime:hours:singular"), $diff); + return elgg_echo("friendlytime:hours:singular", array($diff)); } } else { $diff = round($diff / $day); @@ -279,9 +279,9 @@ function elgg_get_friendly_time($time) { } if ($diff > 1) { - return sprintf(elgg_echo("friendlytime:days"), $diff); + return elgg_echo("friendlytime:days", array($diff)); } else { - return sprintf(elgg_echo("friendlytime:days:singular"), $diff); + return elgg_echo("friendlytime:days:singular", array($diff)); } } } diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php index d6352cbc6..b6aae9d7d 100644 --- a/engine/lib/plugins.php +++ b/engine/lib/plugins.php @@ -164,7 +164,7 @@ function load_plugins() { disable_plugin($mod); // register error rather than rendering the site unusable with exception - register_error(sprintf(elgg_echo('PluginException:MisconfiguredPlugin'), $mod)); + register_error(elgg_echo('PluginException:MisconfiguredPlugin', array($mod))); // continue loading remaining plugins continue; @@ -657,7 +657,7 @@ function enable_plugin($plugin, $site_guid = 0) { $site = get_entity($site_guid); if (!($site instanceof ElggSite)) { - $msg = sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $site_guid, "ElggSite"); + $msg = elgg_echo('InvalidClassException:NotValidElggStar', array($site_guid, "ElggSite")); throw new InvalidClassException($msg); } @@ -744,7 +744,7 @@ function disable_plugin($plugin, $site_guid = 0) { $site = get_entity($site_guid); if (!($site instanceof ElggSite)) { - $msg = sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $site_guid, "ElggSite"); + $msg = elgg_echo('InvalidClassException:NotValidElggStar', array($site_guid, "ElggSite")); throw new InvalidClassException(); } @@ -826,7 +826,7 @@ function is_plugin_enabled($plugin, $site_guid = 0) { if (!$ENABLED_PLUGINS_CACHE) { $site = get_entity($site_guid); if (!($site instanceof ElggSite)) { - $msg = sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $site_guid, "ElggSite"); + $msg = elgg_echo('InvalidClassException:NotValidElggStar', array($site_guid, "ElggSite")); throw new InvalidClassException($msg); } diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php index 186e5a595..c9b47df08 100644 --- a/engine/lib/relationships.php +++ b/engine/lib/relationships.php @@ -402,7 +402,7 @@ $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) { * Returns a viewable list of entities by relationship * * @param array $options - * + * * @see elgg_list_entities() * @see elgg_get_entities_from_relationship() * @@ -859,8 +859,8 @@ function relationship_notification_hook($event, $object_type, $object) { // Notify target user return notify_user($object->guid_two, $object->guid_one, - sprintf(elgg_echo('friend:newfriend:subject'), $user_one->name), - sprintf(elgg_echo("friend:newfriend:body"), $user_one->name, $user_one->getURL()) + elgg_echo('friend:newfriend:subject', array($user_one->name)), + elgg_echo("friend:newfriend:body", array($user_one->name, $user_one->getURL())) ); } } diff --git a/engine/lib/sites.php b/engine/lib/sites.php index 960e54ee3..8044f8fd2 100644 --- a/engine/lib/sites.php +++ b/engine/lib/sites.php @@ -94,7 +94,7 @@ function create_site_entity($guid, $name, $description, $url) { * @return 1 */ function delete_site_entity($guid) { - system_message(sprintf(elgg_echo('deprecatedfunction'), 'delete_user_entity')); + system_message(elgg_echo('deprecatedfunction', array('delete_user_entity'))); return 1; // Always return that we have deleted one row in order to not break existing code. } diff --git a/engine/lib/users.php b/engine/lib/users.php index 7533b2af0..ab7e6734d 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -293,7 +293,7 @@ function remove_user_admin($user_guid) { * @return 1 */ function delete_user_entity($guid) { - system_message(sprintf(elgg_echo('deprecatedfunction'), 'delete_user_entity')); + system_message(elgg_echo('deprecatedfunction', array('delete_user_entity'))); return 1; // Always return that we have deleted one row in order to not break existing code. } @@ -861,7 +861,7 @@ function send_new_password_request($user_guid) { $link = $CONFIG->site->url . "pg/resetpassword?u=$user_guid&c=$code"; // generate email - $email = sprintf(elgg_echo('email:resetreq:body'), $user->name, $_SERVER['REMOTE_ADDR'], $link); + $email = elgg_echo('email:resetreq:body', array($user->name, $_SERVER['REMOTE_ADDR'], $link)); return notify_user($user->guid, $CONFIG->site->guid, elgg_echo('email:resetreq:subject'), $email, NULL, 'email'); @@ -923,7 +923,7 @@ function execute_new_password_request($user_guid, $conf_code) { if (force_user_password_reset($user_guid, $password)) { remove_private_setting($user_guid, 'passwd_conf_code'); - $email = sprintf(elgg_echo('email:resetpassword:body'), $user->name, $password); + $email = elgg_echo('email:resetpassword:body', array($user->name, $password)); return notify_user($user->guid, $CONFIG->site->guid, elgg_echo('email:resetpassword:subject'), $email, NULL, 'email'); @@ -1049,7 +1049,7 @@ function validate_username($username) { for ($n = 0; $n < strlen($blacklist2); $n++) { if (strpos($username, $blacklist2[$n]) !== false) { - $msg = sprintf(elgg_echo('registration:invalidchars'), $blacklist2[$n], $blacklist2); + $msg = elgg_echo('registration:invalidchars', array($blacklist2[$n], $blacklist2)); throw new RegistrationException($msg); } } diff --git a/engine/lib/xml-rpc.php b/engine/lib/xml-rpc.php index 251d470a1..6c1084f70 100644 --- a/engine/lib/xml-rpc.php +++ b/engine/lib/xml-rpc.php @@ -119,8 +119,8 @@ function trigger_xmlrpc_handler(XMLRPCCall $parameters) { $result = $handler($parameters); if (!($result instanceof XMLRPCResponse)) { - $msg = sprintf(elgg_echo('InvalidParameterException:UnexpectedReturnFormat'), - $parameters->getMethodName()); + $msg = elgg_echo('InvalidParameterException:UnexpectedReturnFormat', + array($parameters->getMethodName())); throw new InvalidParameterException($msg); } @@ -129,8 +129,8 @@ function trigger_xmlrpc_handler(XMLRPCCall $parameters) { } // if no handler then throw exception - $msg = sprintf(elgg_echo('NotImplementedException:XMLRPCMethodNotImplemented'), - $parameters->getMethodName()); + $msg = elgg_echo('NotImplementedException:XMLRPCMethodNotImplemented', + array($parameters->getMethodName())); throw new NotImplementedException($msg); } -- cgit v1.2.3