diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-11-03 19:46:47 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-11-03 19:46:47 +0000 |
commit | 998a39940b27561d7a2e98b68c8929dab68fe62f (patch) | |
tree | 79e73eb7bd8ae843609a2f4f0a526377800430e1 | |
parent | 4b3749440c560da36b7deadcee65133062fd10a1 (diff) | |
download | elgg-998a39940b27561d7a2e98b68c8929dab68fe62f.tar.gz elgg-998a39940b27561d7a2e98b68c8929dab68fe62f.tar.bz2 |
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
59 files changed, 218 insertions, 220 deletions
diff --git a/actions/admin/plugins/disable.php b/actions/admin/plugins/disable.php index 48116e43a..9db5aec11 100644 --- a/actions/admin/plugins/disable.php +++ b/actions/admin/plugins/disable.php @@ -20,10 +20,11 @@ if (!is_array($plugin)) { foreach ($plugin as $p) { if (disable_plugin($p)) { - system_message(sprintf(elgg_echo('admin:plugins:disable:yes'), $p)); + system_message(elgg_echo('admin:plugins:disable:yes', array($p))); + elgg_delete_admin_notice('first_installation_plugin_reminder'); } else { - register_error(sprintf(elgg_echo('admin:plugins:disable:no'), $p)); + register_error(elgg_echo('admin:plugins:disable:no', array($p))); } } diff --git a/actions/admin/plugins/disableall.php b/actions/admin/plugins/disableall.php index bd68c17b1..21938727e 100644 --- a/actions/admin/plugins/disableall.php +++ b/actions/admin/plugins/disableall.php @@ -16,9 +16,9 @@ $plugins = get_installed_plugins(); foreach ($plugins as $p => $data) { if (disable_plugin($p)) { elgg_delete_admin_notice('first_installation_plugin_reminder'); - system_message(sprintf(elgg_echo('admin:plugins:disable:yes'), $p)); + system_message(elgg_echo('admin:plugins:disable:yes', array($p))); } else { - register_error(sprintf(elgg_echo('admin:plugins:disable:no'), $p)); + register_error(elgg_echo('admin:plugins:disable:no', array($p))); } } diff --git a/actions/admin/plugins/enable.php b/actions/admin/plugins/enable.php index b15666093..d3ad5606d 100644 --- a/actions/admin/plugins/enable.php +++ b/actions/admin/plugins/enable.php @@ -22,9 +22,9 @@ if (!is_array($plugin)) { foreach ($plugin as $p) { if (enable_plugin($p)) { elgg_delete_admin_notice('first_installation_plugin_reminder'); - system_message(sprintf(elgg_echo('admin:plugins:enable:yes'), $p)); + system_message(elgg_echo('admin:plugins:enable:yes', array($p))); } else { - register_error(sprintf(elgg_echo('admin:plugins:enable:no'), $p)); + register_error(elgg_echo('admin:plugins:enable:no', array($p))); } } diff --git a/actions/admin/plugins/enableall.php b/actions/admin/plugins/enableall.php index b959c235f..9a2df00dc 100644 --- a/actions/admin/plugins/enableall.php +++ b/actions/admin/plugins/enableall.php @@ -16,9 +16,9 @@ $plugins = get_installed_plugins(); foreach ($plugins as $p => $data) { if (enable_plugin($p)) { elgg_delete_admin_notice('first_installation_plugin_reminder'); - system_message(sprintf(elgg_echo('admin:plugins:enable:yes'), $p)); + system_message(elgg_echo('admin:plugins:enable:yes', array($p))); } else { - register_error(sprintf(elgg_echo('admin:plugins:enable:no'), $p)); + register_error(elgg_echo('admin:plugins:enable:no', array($p))); } } diff --git a/actions/admin/plugins/reorder.php b/actions/admin/plugins/reorder.php index e3c65f6e5..2158653e1 100644 --- a/actions/admin/plugins/reorder.php +++ b/actions/admin/plugins/reorder.php @@ -40,9 +40,9 @@ if ($key = array_search($mod, $plugins)) { // Disable if (regenerate_plugin_list($plugins)) { elgg_delete_admin_notice('first_installation_plugin_reminder'); - system_message(sprintf(elgg_echo('admin:plugins:reorder:yes'), $plugin)); + system_message(elgg_echo('admin:plugins:reorder:yes', array($plugin))); } else { - register_error(sprintf(elgg_echo('admin:plugins:reorder:no'), $plugin)); + register_error(elgg_echo('admin:plugins:reorder:no', array($plugin))); } // don't regenerate the simplecache because the plugin won't be diff --git a/actions/admin/user/delete.php b/actions/admin/user/delete.php index 375f8b809..e8d835722 100644 --- a/actions/admin/user/delete.php +++ b/actions/admin/user/delete.php @@ -22,7 +22,7 @@ $username = $obj->username; if (($obj instanceof ElggUser) && ($obj->canEdit())) { if ($obj->delete()) { - system_message(sprintf(elgg_echo('admin:user:delete:yes'), $name)); + system_message(elgg_echo('admin:user:delete:yes', array($name))); } else { register_error(elgg_echo('admin:user:delete:no')); } diff --git a/actions/admin/user/resetpassword.php b/actions/admin/user/resetpassword.php index 46a983c86..24127eb8b 100644 --- a/actions/admin/user/resetpassword.php +++ b/actions/admin/user/resetpassword.php @@ -32,7 +32,7 @@ if (($obj instanceof ElggUser) && ($obj->canEdit())) { notify_user($obj->guid, $CONFIG->site->guid, elgg_echo('email:resetpassword:subject'), - sprintf(elgg_echo('email:resetpassword:body'), $obj->username, $password), + elgg_echo('email:resetpassword:body', array($obj->username, $password)), NULL, 'email'); } else { diff --git a/actions/comments/add.php b/actions/comments/add.php index b7feb4b66..11418a2e2 100644 --- a/actions/comments/add.php +++ b/actions/comments/add.php @@ -47,15 +47,14 @@ if ($entity->owner_guid != $user->guid) { notify_user($entity->owner_guid, $user->guid, elgg_echo('generic_comment:email:subject'), - sprintf( - elgg_echo('generic_comment:email:body'), + elgg_echo('generic_comment:email:body', array( $entity->title, $user->name, $comment_text, $entity->getURL(), $user->name, $user->getURL() - ) + )) ); } diff --git a/actions/entities/delete.php b/actions/entities/delete.php index 3ec88bd04..823e85c59 100644 --- a/actions/entities/delete.php +++ b/actions/entities/delete.php @@ -13,12 +13,12 @@ $entity = get_entity($guid); if (($entity) && ($entity->canEdit())) { if ($entity->delete()) { - system_message(sprintf(elgg_echo('entity:delete:success'), $guid)); + system_message(elgg_echo('entity:delete:success', array($guid))); } else { - register_error(sprintf(elgg_echo('entity:delete:fail'), $guid)); + register_error(elgg_echo('entity:delete:fail', array($guid))); } } else { - register_error(sprintf(elgg_echo('entity:delete:fail'), $guid)); + register_error(elgg_echo('entity:delete:fail', array($guid))); } forward(REFERER); diff --git a/actions/friends/add.php b/actions/friends/add.php index 60431a27d..d0a0d3d7c 100644 --- a/actions/friends/add.php +++ b/actions/friends/add.php @@ -21,13 +21,13 @@ try { $errors = true; } } catch (Exception $e) { - register_error(sprintf(elgg_echo("friends:add:failure"), $friend->name)); + register_error(elgg_echo("friends:add:failure", array($friend->name))); $errors = true; } if (!$errors) { // add to river add_to_river('friends/river/create', 'friend', get_loggedin_userid(), $friend_guid); - system_message(sprintf(elgg_echo("friends:add:successful"), $friend->name)); + system_message(elgg_echo("friends:add:successful", array($friend->name))); } // Forward back to the page you friended the user on diff --git a/actions/friends/remove.php b/actions/friends/remove.php index 786b5975b..1230b12af 100644 --- a/actions/friends/remove.php +++ b/actions/friends/remove.php @@ -19,16 +19,16 @@ try{ if ($friend instanceof ElggUser) { get_loggedin_user()->removeFriend($friend_guid); } else { - register_error(sprintf(elgg_echo("friends:remove:failure"), $friend->name)); + register_error(elgg_echo("friends:remove:failure", array($friend->name))); $errors = true; } } catch (Exception $e) { - register_error(sprintf(elgg_echo("friends:remove:failure"), $friend->name)); + register_error(elgg_echo("friends:remove:failure", array($friend->name))); $errors = true; } if (!$errors) { - system_message(sprintf(elgg_echo("friends:remove:successful"), $friend->name)); + system_message(elgg_echo("friends:remove:successful", array($friend->name))); } // Forward back to the page you made the friend on diff --git a/actions/likes/add.php b/actions/likes/add.php index 211cb340b..b8c2f18b8 100644 --- a/actions/likes/add.php +++ b/actions/likes/add.php @@ -41,15 +41,14 @@ if ($entity->owner_guid != $user->guid) { notify_user($entity->owner_guid, $user->guid, elgg_echo('likes:email:subject'), - sprintf( - elgg_echo('likes:email:body'), + elgg_echo('likes:email:body', array( $user->name, $entity->title, //$comment_text, $entity->getURL(), $user->name, $user->getURL() - ) + )) ); } diff --git a/actions/plugins/settings/save.php b/actions/plugins/settings/save.php index 1a8b2db3d..b67fa401f 100644 --- a/actions/plugins/settings/save.php +++ b/actions/plugins/settings/save.php @@ -9,7 +9,7 @@ $params = get_input('params'); $plugin = get_input('plugin'); if (!$plugin_info = load_plugin_manifest($plugin)) { - register_error(sprintf(elgg_echo('plugins:settings:save:fail'), $plugin)); + register_error(elgg_echo('plugins:settings:save:fail', array($plugin))); forward(REFERER); } @@ -31,29 +31,29 @@ if (elgg_action_exist("settings/$plugin/save")) { } else { foreach ($params as $k => $v) { if (!$result = set_plugin_setting($k, $v, $plugin)) { - register_error(sprintf(elgg_echo('plugins:settings:save:fail'), $plugin_name)); + register_error(elgg_echo('plugins:settings:save:fail', array($plugin_name))); forward(REFERER); exit; } } } -system_message(sprintf(elgg_echo('plugins:settings:save:ok'), $plugin_name)); +system_message(elgg_echo('plugins:settings:save:ok', array($plugin_name))); forward(REFERER); // //$trigger = trigger_plugin_hook('plugin:save_settings', $plugin, $options, NULL); //if ($trigger === NULL) { // foreach ($params as $k => $v) { // if (!$result = set_plugin_setting($k, $v, $plugin)) { -// register_error(sprintf(elgg_echo('plugins:settings:save:fail'), $plugin_name)); +// register_error(elgg_echo('plugins:settings:save:fail', array($plugin_name))); // forward(REFERER); // exit; // } // } //} elseif ($trigger === FALSE) { -// register_error(sprintf(elgg_echo('plugins:settings:save:fail'), $plugin_name)); +// register_error(elgg_echo('plugins:settings:save:fail', array($plugin_name))); // forward(REFERER); //} // -//system_message(sprintf(elgg_echo('plugins:settings:save:ok'), $plugin_name)); +//system_message(elgg_echo('plugins:settings:save:ok', array($plugin_name))); //forward(REFERER);
\ No newline at end of file diff --git a/actions/plugins/usersettings/save.php b/actions/plugins/usersettings/save.php index 27f549184..705871fac 100644 --- a/actions/plugins/usersettings/save.php +++ b/actions/plugins/usersettings/save.php @@ -19,11 +19,11 @@ foreach ($params as $k => $v) { // Error? if (!$result) { - register_error(sprintf(elgg_echo('plugins:usersettings:save:fail'), $plugin)); + register_error(elgg_echo('plugins:usersettings:save:fail', array($plugin))); forward(REFERER); exit; } } -system_message(sprintf(elgg_echo('plugins:usersettings:save:ok'), $plugin)); +system_message(elgg_echo('plugins:usersettings:save:ok', array($plugin))); forward(REFERER); diff --git a/actions/register.php b/actions/register.php index fcb25de35..3a45cb69b 100644 --- a/actions/register.php +++ b/actions/register.php @@ -52,7 +52,7 @@ if ($CONFIG->allow_registration) { throw new RegistrationException(elgg_echo('registerbad')); } - system_message(sprintf(elgg_echo("registerok"), $CONFIG->sitename)); + system_message(elgg_echo("registerok", array($CONFIG->sitename))); // Forward on success, assume everything else is an error... login($new_user); diff --git a/actions/user/requestnewpassword.php b/actions/user/requestnewpassword.php index 22b4008e8..5dfa24952 100644 --- a/actions/user/requestnewpassword.php +++ b/actions/user/requestnewpassword.php @@ -16,7 +16,7 @@ if ($user) { register_error(elgg_echo('user:password:resetreq:fail')); } } else { - register_error(sprintf(elgg_echo('user:username:notfound'), $username)); + register_error(elgg_echo('user:username:notfound', array($username))); } forward(); diff --git a/actions/useradd.php b/actions/useradd.php index 54def11b3..82625ad1b 100644 --- a/actions/useradd.php +++ b/actions/useradd.php @@ -35,12 +35,12 @@ try { $new_user->created_by_guid = get_loggedin_userid(); $subject = elgg_echo('useradd:subject'); - $body = sprintf(elgg_echo('useradd:body'), $name, - $CONFIG->site->name, $CONFIG->site->url, $username, $password); + $body = elgg_echo('useradd:body', array($name, + $CONFIG->site->name, $CONFIG->site->url, $username, $password)); notify_user($new_user->guid, $CONFIG->site->guid, $subject, $body); - system_message(sprintf(elgg_echo("adduser:ok"), $CONFIG->sitename)); + system_message(elgg_echo("adduser:ok", array($CONFIG->sitename))); } else { register_error(elgg_echo("adduser:bad")); } 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: * <pre> * { @@ -392,18 +392,18 @@ function elgg_is_xhr() { * } * </pre> * 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); } @@ -45,7 +45,7 @@ if (!trigger_plugin_hook('index', 'system', null, FALSE)) { $activity = elgg_list_registered_entities($options); } elgg_set_context('main'); - + global $autofeed; $autofeed = FALSE; diff --git a/install/ElggInstaller.php b/install/ElggInstaller.php index 61f4cc4e3..2eba692b3 100644 --- a/install/ElggInstaller.php +++ b/install/ElggInstaller.php @@ -59,7 +59,7 @@ class ElggInstaller { $this->processRewriteTest(); if (!in_array($step, $this->getSteps())) { - $msg = sprintf(elgg_echo('InstallationException:UnknownStep'), $step); + $msg = elgg_echo('InstallationException:UnknownStep', array($step)); throw new InstallationException($msg); } @@ -131,7 +131,7 @@ class ElggInstaller { ); foreach ($requiredParams as $key) { if (!array_key_exists($key, $params)) { - $msg = sprintf(elgg_echo('install:error:requiredfield'), $key); + $msg = elgg_echo('install:error:requiredfield', array($key)); throw new InstallationException($msg); } } @@ -580,7 +580,7 @@ class ElggInstaller { } if (!include_once("{$CONFIG->path}engine/lib/database.php")) { - $msg = sprintf(elgg_echo('InstallationException:MissingLibrary'), 'database.php'); + $msg = elgg_echo('InstallationException:MissingLibrary', array('database.php')); throw new InstallationException($msg); } @@ -736,7 +736,7 @@ class ElggInstaller { 'calendar.php', 'configuration.php', 'cron.php', 'entities.php', 'extender.php', 'filestore.php', 'group.php', 'location.php', 'mb_wrapper.php', - 'memcache.php', 'metadata.php', 'metastrings.php', + 'memcache.php', 'metadata.php', 'metastrings.php', 'navigation.php', 'notification.php', 'objects.php', 'opendd.php', 'pagehandler.php', 'pageowner.php', 'pam.php', 'plugins.php', @@ -748,7 +748,7 @@ class ElggInstaller { foreach ($lib_files as $file) { $path = $lib_dir . $file; if (!include_once($path)) { - $msg = sprintf(elgg_echo('InstallationException:MissingLibrary'), $file); + $msg = elgg_echo('InstallationException:MissingLibrary', array($file)); throw new InstallationException($msg); } } @@ -922,7 +922,7 @@ class ElggInstaller { if (version_compare(PHP_VERSION, $elgg_php_version, '<')) { $phpReport[] = array( 'severity' => 'failure', - 'message' => sprintf(elgg_echo('install:check:php:version'), $elgg_php_version, PHP_VERSION) + 'message' => elgg_echo('install:check:php:version', array($elgg_php_version, PHP_VERSION)) ); } @@ -959,7 +959,7 @@ class ElggInstaller { if (!in_array($extension, $extensions)) { $phpReport[] = array( 'severity' => 'failure', - 'message' => sprintf(elgg_echo('install:check:php:extension'), $extension) + 'message' => elgg_echo('install:check:php:extension', array($extension)) ); } } @@ -971,7 +971,7 @@ class ElggInstaller { if (!in_array($extension, $extensions)) { $phpReport[] = array( 'severity' => 'warning', - 'message' => sprintf(elgg_echo('install:check:php:extension:recommend'), $extension) + 'message' => elgg_echo('install:check:php:extension:recommend', array($extension)) ); } } @@ -1001,7 +1001,7 @@ class ElggInstaller { if (ini_get('arg_separator.output') !== '&') { $separator = htmlspecialchars(ini_get('arg_separator.output')); - $msg = sprintf(elgg_echo("install:check:php:arg_separator"), $separator); + $msg = elgg_echo("install:check:php:arg_separator", array($separator)); $phpReport[] = array( 'severity' => 'failure', 'message' => $msg, @@ -1122,14 +1122,14 @@ class ElggInstaller { $version = mysql_get_server_info(); $points = explode('.', $version); if ($points[0] < $required_version) { - register_error(sprintf(elgg_echo('install:error:oldmysql'), $version)); + register_error(elgg_echo('install:error:oldmysql', array($version))); return FALSE; } mysql_close($mysql_dblink); if (!$result) { - register_error(sprintf(elgg_echo('install:error:nodatabase'), $dbname)); + register_error(elgg_echo('install:error:nodatabase', array($dbname))); } return $result; @@ -1180,7 +1180,7 @@ class ElggInstaller { } if (!include_once("{$CONFIG->path}engine/lib/database.php")) { - $msg = sprintf(elgg_echo('InstallationException:MissingLibrary'), 'database.php'); + $msg = elgg_echo('InstallationException:MissingLibrary', array('database.php')); register_error($msg); return FALSE; } @@ -1234,28 +1234,28 @@ class ElggInstaller { foreach ($formVars as $field => $info) { if ($info['required'] == TRUE && !$submissionVars[$field]) { $name = elgg_echo("install:settings:label:$field"); - register_error(sprintf(elgg_echo('install:error:requiredfield'), $name)); + register_error(elgg_echo('install:error:requiredfield', array($name))); return FALSE; } } // check that data root is writable if (!is_writable($submissionVars['dataroot'])) { - $msg = sprintf(elgg_echo('install:error:writedatadirectory'), $submissionVars['dataroot']); + $msg = elgg_echo('install:error:writedatadirectory', array($submissionVars['dataroot'])); register_error($msg); return FALSE; } // check that data root is not subdirectory of Elgg root if (stripos($submissionVars['dataroot'], $submissionVars['path']) !== FALSE) { - $msg = sprintf(elgg_echo('install:error:locationdatadirectory'), $submissionVars['dataroot']); + $msg = elgg_echo('install:error:locationdatadirectory', array($submissionVars['dataroot'])); register_error($msg); return FALSE; } // check that email address is email address if ($submissionVars['siteemail'] && !is_email_address($submissionVars['siteemail'])) { - $msg = sprintf(elgg_echo('install:error:emailaddress'), $submissionVars['siteemail']); + $msg = elgg_echo('install:error:emailaddress', array($submissionVars['siteemail'])); register_error($msg); return FALSE; } @@ -1353,7 +1353,7 @@ class ElggInstaller { foreach ($formVars as $field => $info) { if ($info['required'] == TRUE && !$submissionVars[$field]) { $name = elgg_echo("install:admin:label:$field"); - register_error(sprintf(elgg_echo('install:error:requiredfield'), $name)); + register_error(elgg_echo('install:error:requiredfield', array($name))); return FALSE; } } @@ -1376,7 +1376,7 @@ class ElggInstaller { // check that email address is email address if ($submissionVars['email'] && !is_email_address($submissionVars['email'])) { - $msg = sprintf(elgg_echo('install:error:emailaddress'), $submissionVars['email']); + $msg = elgg_echo('install:error:emailaddress', array($submissionVars['email'])); register_error($msg); return FALSE; } diff --git a/install/ElggRewriteTester.php b/install/ElggRewriteTester.php index b2e914e55..64785da1a 100644 --- a/install/ElggRewriteTester.php +++ b/install/ElggRewriteTester.php @@ -152,7 +152,7 @@ class ElggRewriteTester { } if ($this->serverSupportsRemoteRead == FALSE) { - $msg = sprintf(elgg_echo('install:warning:rewrite:unknown'), $url); + $msg = elgg_echo('install:warning:rewrite:unknown', array($url)); return array( 'severity' => 'warning', 'message' => $msg, diff --git a/languages/en.php b/languages/en.php index 6ed5bb709..522f9e364 100644 --- a/languages/en.php +++ b/languages/en.php @@ -2,8 +2,8 @@ /** * Core English Language * - * @package ElggLanguage - * @subpackage Core + * @package Elgg.Core + * @subpackage Languages.English */ $english = array( @@ -41,7 +41,8 @@ $english = array( 'actionloggedout' => "Sorry, you cannot perform this action while logged out.", 'actionunauthorized' => 'You are unauthorized to perform this action', - 'InstallationException:SiteNotInstalled' => 'Unable to handle this request. This site is not configured or the database is down.', + 'InstallationException:SiteNotInstalled' => 'Unable to handle this request. This site ' + . ' is not configured or the database is down.', 'InstallationException:MissingLibrary' => 'Could not load %s', 'InstallationException:CannotLoadSettings' => 'Elgg could not load the settings file. It does not exist or there is a file permissions issue.', diff --git a/pages/friends/index.php b/pages/friends/index.php index 4e379cae4..473e456c4 100644 --- a/pages/friends/index.php +++ b/pages/friends/index.php @@ -13,7 +13,7 @@ if (!$owner) { $owner = elgg_get_page_owner(); } -$title = sprintf(elgg_echo("friends:owned"), $owner->name); +$title = elgg_echo("friends:owned", array($owner->name)); $content = elgg_view_title($title); diff --git a/pages/friends/of.php b/pages/friends/of.php index 19806786e..9e49ccfd4 100644 --- a/pages/friends/of.php +++ b/pages/friends/of.php @@ -13,7 +13,7 @@ if (!$owner) { $owner = elgg_get_page_owner(); } -$title = sprintf(elgg_echo("friends:of:owned"), $owner->name); +$title = elgg_echo("friends:of:owned", array($owner->name)); $content = elgg_view_title($title); diff --git a/services/export/handler.php b/services/export/handler.php index 21336bbec..9ce1419df 100644 --- a/services/export/handler.php +++ b/services/export/handler.php @@ -26,7 +26,7 @@ if (($guid != "") && ($type == "") && ($id_or_name == "")) { $entity = get_entity($guid); if (!$entity) { - $query = sprintf(elgg_echo('InvalidParameterException:GUIDNotFound'), $guid); + $query = elgg_echo('InvalidParameterException:GUIDNotFound', array($guid)); throw new InvalidParameterException($query); } @@ -38,7 +38,7 @@ if (($guid != "") && ($type == "") && ($id_or_name == "")) { // Get a uuid $entity = get_entity($guid); if (!$entity) { - $msg = sprintf(elgg_echo('InvalidParameterException:GUIDNotFound'), $guid); + $msg = elgg_echo('InvalidParameterException:GUIDNotFound', array($guid)); throw new InvalidParameterException($msg); } @@ -48,7 +48,7 @@ if (($guid != "") && ($type == "") && ($id_or_name == "")) { case 'attr' : // @todo: Do this better? - This is a bit of a hack... $v = $entity->get($id_or_name); if (!$v) { - $msg = sprintf(elgg_echo('InvalidParameterException:IdNotExistForGUID'), $id_or_name, $guid); + $msg = elgg_echo('InvalidParameterException:IdNotExistForGUID', array($id_or_name, $guid)); throw new InvalidParameterException($msg); } @@ -78,7 +78,7 @@ if (($guid != "") && ($type == "") && ($id_or_name == "")) { break; default : - $msg = sprintf(elgg_echo('InvalidParameterException:CanNotExportType'), $type); + $msg = elgg_echo('InvalidParameterException:CanNotExportType', array($type)); throw new InvalidParameterException($msg); } diff --git a/views/default/admin/plugins/simple.php b/views/default/admin/plugins/simple.php index 017c6e7fe..9b9897944 100644 --- a/views/default/admin/plugins/simple.php +++ b/views/default/admin/plugins/simple.php @@ -45,11 +45,11 @@ foreach ($plugin_list as $name => $info) { $author = $link = $version = $settings = ''; if (isset($manifest['author'])) { - $author = sprintf(elgg_echo('admin:plugins:author'), $manifest['author']); + $author = elgg_echo('admin:plugins:author', array($manifest['author'])); } if (isset($manifest['version'])) { - $version = ' | ' . sprintf(elgg_echo('admin:plugins:version'), $manifest['version']); + $version = ' | ' . elgg_echo('admin:plugins:version', array($manifest['version'])); } if (isset($manifest['website'])) { diff --git a/views/default/annotation/annotate.php b/views/default/annotation/annotate.php index 3266b2904..6e83e8afb 100644 --- a/views/default/annotation/annotate.php +++ b/views/default/annotation/annotate.php @@ -16,7 +16,7 @@ if ($vars['item']->annotation_id != 0) { } $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>"; -$string = sprintf(elgg_echo("river:posted:generic"), $url) . " "; +$string = elgg_echo("river:posted:generic", array($url)) . " "; $string .= elgg_echo("{$subtype}:river:annotate") . " <a href=\"{$object->getURL()}\">" . $title . "</a> <span class='entity_subtext'>" . elgg_view_friendly_time($object->time_created) . "<a class='river_comment_form_button link'>Comment</a>"; $string .= elgg_view('likes/forms/link', array('entity' => $object)); $string .= "</span>"; diff --git a/views/default/friends/river/create.php b/views/default/friends/river/create.php index b0319beb5..cd84c5289 100644 --- a/views/default/friends/river/create.php +++ b/views/default/friends/river/create.php @@ -10,7 +10,7 @@ $performed_by = get_entity($vars['item']->subject_guid); $performed_on = get_entity($vars['item']->object_guid); $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>"; -$string = sprintf(elgg_echo("friends:river:add"),$url) . " "; +$string = elgg_echo("friends:river:add", array($url) . " "; $string .= "<a href=\"{$performed_on->getURL()}\">{$performed_on->name}</a>"; $string .= "<div class=\"river_content_display\">"; $string .= "<table><tr><td>" . elgg_view("profile/icon",array('entity' => $performed_by, 'size' => 'tiny')) . "</td>"; diff --git a/views/default/group/search/startblurb.php b/views/default/group/search/startblurb.php index 3a5809193..92256d1db 100644 --- a/views/default/group/search/startblurb.php +++ b/views/default/group/search/startblurb.php @@ -9,6 +9,6 @@ elgg_deprecated_notice('view groups/search/startblurb was deprecated.', 1.7); <div class="contentWrapper"> <?php - echo sprintf(elgg_echo("group:search:startblurb"),$vars['tag']); + echo elgg_echo("group:search:startblurb", array($vars['tag'])); ?> </div> diff --git a/views/default/object/default.php b/views/default/object/default.php index 0f07996b2..040bae832 100644 --- a/views/default/object/default.php +++ b/views/default/object/default.php @@ -29,7 +29,7 @@ if ($vars['full']) { $controls = ""; if ($vars['entity']->canEdit()) { $delete = elgg_view('output/confirm_link', array( - 'href' => "action/entities/delete?guid={$vars['entity']->guid}", + 'href' => "action/entities/delete?guid={$vars['entity']->guid}", 'text' => elgg_echo('delete') )); $controls .= " ($delete)"; @@ -44,13 +44,13 @@ if ($vars['full']) { $owner = $vars['entity']->getOwnerEntity(); $ownertxt = elgg_echo('unknown'); if ($owner) { - $ownertxt = "<a href=\"" . $owner->getURL() . "\">" . $owner->name ."</a>"; + $ownertxt = "<a href=\"" . $owner->getURL() . "\">" . $owner->name . "</a>"; } - $info .= "<div>".sprintf(elgg_echo("entity:default:strapline"), + $info .= "<div>" . elgg_echo("entity:default:strapline", array( elgg_view_friendly_time($vars['entity']->time_created), $ownertxt - ); + )); $info .= "</div>"; diff --git a/views/default/user/search/startblurb.php b/views/default/user/search/startblurb.php index a4ee421a1..806157609 100644 --- a/views/default/user/search/startblurb.php +++ b/views/default/user/search/startblurb.php @@ -7,6 +7,4 @@ elgg_deprecated_notice('view user/search/startblurb was deprecated.', 1.7); -echo sprintf(elgg_echo("user:search:startblurb"),$vars['tag']); - -?> +echo elgg_echo("user:search:startblurb", array($vars['tag']));
\ No newline at end of file |