diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-04-14 16:44:15 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-04-14 16:44:15 +0200 |
commit | b1bcc60d83866627b1b28a0eda336e0f246dbe8e (patch) | |
tree | a7100fbd8425e90c8b90888bc16a15349519038a | |
parent | 721311c9099780ecc22b6b186ed79dc5c9c92271 (diff) | |
download | nextcloud-server-b1bcc60d83866627b1b28a0eda336e0f246dbe8e.tar.gz nextcloud-server-b1bcc60d83866627b1b28a0eda336e0f246dbe8e.zip |
reuse OC_L10N objects
33 files changed, 52 insertions, 38 deletions
diff --git a/apps/admin_dependencies_chk/appinfo/app.php b/apps/admin_dependencies_chk/appinfo/app.php index e2169b5dd77..f282b103c87 100644 --- a/apps/admin_dependencies_chk/appinfo/app.php +++ b/apps/admin_dependencies_chk/appinfo/app.php @@ -1,5 +1,5 @@ <?php -$l=new OC_L10N('admin_dependencies_chk'); +$l=OC_L10N::get('admin_dependencies_chk'); OC_App::register( array( 'order' => 14, diff --git a/apps/admin_dependencies_chk/settings.php b/apps/admin_dependencies_chk/settings.php index ce90dd604ca..ea1ce9fb3dc 100644 --- a/apps/admin_dependencies_chk/settings.php +++ b/apps/admin_dependencies_chk/settings.php @@ -20,7 +20,7 @@ * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ -$l=new OC_L10N('admin_dependencies_chk'); +$l=OC_L10N::get('admin_dependencies_chk'); $tmpl = new OC_Template( 'admin_dependencies_chk', 'settings'); $modules = array(); diff --git a/apps/bookmarks/bookmarksHelper.php b/apps/bookmarks/bookmarksHelper.php index 7ada69014fb..f1464be79de 100644 --- a/apps/bookmarks/bookmarksHelper.php +++ b/apps/bookmarks/bookmarksHelper.php @@ -94,7 +94,7 @@ function addBookmark($url, $title, $tags='') { } if(empty($title)) { - $l = new OC_L10N('bookmarks'); + $l = OC_L10N::get('bookmarks'); $title = $l->t('unnamed'); } diff --git a/apps/bookmarks/templates/bookmarklet.php b/apps/bookmarks/templates/bookmarklet.php index 5ea67f04df2..f7074462a79 100644 --- a/apps/bookmarks/templates/bookmarklet.php +++ b/apps/bookmarks/templates/bookmarklet.php @@ -1,7 +1,7 @@ <?php function createBookmarklet() { - $l = new OC_L10N('bookmarks'); + $l = OC_L10N::get('bookmarks'); echo '<small>' . $l->t('Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:') . '</small>' . '<a class="bookmarklet" href="javascript:(function(){var a=window,b=document,c=encodeURIComponent,d=a.open(\'' . OC_Helper::linkToAbsolute('bookmarks', 'addBm.php') . '?output=popup&url=\'+c(b.location),\'bkmk_popup\',\'left=\'+((a.screenX||a.screenLeft)+10)+\',top=\'+((a.screenY||a.screenTop)+10)+\',height=230px,width=230px,resizable=1,alwaysRaised=1\');a.setTimeout(function(){d.focus()},300);})();">' . $l->t('Read later') . '</a>'; diff --git a/apps/calendar/ajax/calendar/new.form.php b/apps/calendar/ajax/calendar/new.form.php index 6e7423cbe92..fa014351f77 100644 --- a/apps/calendar/ajax/calendar/new.form.php +++ b/apps/calendar/ajax/calendar/new.form.php @@ -7,7 +7,6 @@ */ require_once('../../../../lib/base.php'); -$l10n = new OC_L10N('calendar'); OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); $calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions(); diff --git a/apps/calendar/ajax/calendar/overview.php b/apps/calendar/ajax/calendar/overview.php index 2f73f5d0710..dd55f3e018f 100644 --- a/apps/calendar/ajax/calendar/overview.php +++ b/apps/calendar/ajax/calendar/overview.php @@ -7,7 +7,7 @@ */ require_once('../../../../lib/base.php'); -$l10n = new OC_L10N('calendar'); +$l10n = OC_L10N::get('calendar'); OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); $output = new OC_TEMPLATE("calendar", "part.choosecalendar"); diff --git a/apps/calendar/ajax/event/delete.php b/apps/calendar/ajax/event/delete.php index 862dec6bf5b..5fc12900ef3 100644 --- a/apps/calendar/ajax/event/delete.php +++ b/apps/calendar/ajax/event/delete.php @@ -7,8 +7,6 @@ */ require_once('../../../../lib/base.php'); -$l10n = new OC_L10N('calendar'); - OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); diff --git a/apps/calendar/ajax/event/new.php b/apps/calendar/ajax/event/new.php index 59fda79da73..7070bbf05d7 100644 --- a/apps/calendar/ajax/event/new.php +++ b/apps/calendar/ajax/event/new.php @@ -8,8 +8,6 @@ require_once('../../../../lib/base.php'); -$l10n = new OC_L10N('calendar'); - OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php index c62f93c540e..d053df2e4c1 100755 --- a/apps/calendar/ajax/events.php +++ b/apps/calendar/ajax/events.php @@ -8,7 +8,7 @@ require_once ('../../../lib/base.php'); require_once('when/When.php'); -$l = new OC_L10N('calendar'); +$l = OC_L10N::get('calendar'); $unnamed = $l->t('unnamed'); function create_return_event($event, $vevent){ $return_event = array(); diff --git a/apps/calendar/ajax/import/dialog.php b/apps/calendar/ajax/import/dialog.php index 2e002092150..16ec54d14a2 100644 --- a/apps/calendar/ajax/import/dialog.php +++ b/apps/calendar/ajax/import/dialog.php @@ -9,7 +9,6 @@ require_once('../../../../lib/base.php'); OC_JSON::checkLoggedIn(); OC_Util::checkAppEnabled('calendar'); -$l10n = new OC_L10N('calendar'); $tmpl = new OC_Template('calendar', 'part.import'); $tmpl->assign('path', $_POST['path']); $tmpl->assign('filename', $_POST['filename']); diff --git a/apps/calendar/ajax/settings/guesstimezone.php b/apps/calendar/ajax/settings/guesstimezone.php index d45a70e1ce3..c02b8d10b8d 100755 --- a/apps/calendar/ajax/settings/guesstimezone.php +++ b/apps/calendar/ajax/settings/guesstimezone.php @@ -10,7 +10,7 @@ require_once('../../../../lib/base.php'); OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); -$l = new OC_L10N('calendar'); +$l = OC_L10N::get('calendar'); $lat = $_GET['lat']; $lng = $_GET['long']; diff --git a/apps/calendar/ajax/settings/settimezone.php b/apps/calendar/ajax/settings/settimezone.php index c639753fe2f..8dda28335f7 100644 --- a/apps/calendar/ajax/settings/settimezone.php +++ b/apps/calendar/ajax/settings/settimezone.php @@ -9,7 +9,7 @@ // Init owncloud require_once('../../../../lib/base.php'); -$l=new OC_L10N('calendar'); +$l=OC_L10N::get('calendar'); // Check if we are a user OC_JSON::checkLoggedIn(); diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php index f297c4d16d4..1fece8077ac 100644 --- a/apps/calendar/appinfo/app.php +++ b/apps/calendar/appinfo/app.php @@ -1,5 +1,5 @@ <?php -$l=new OC_L10N('calendar'); +$l=OC_L10N::get('calendar'); OC::$CLASSPATH['OC_Calendar_App'] = 'apps/calendar/lib/app.php'; OC::$CLASSPATH['OC_Calendar_Calendar'] = 'apps/calendar/lib/calendar.php'; OC::$CLASSPATH['OC_Calendar_Object'] = 'apps/calendar/lib/object.php'; diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php index 22c1133e006..4b481a4f286 100644 --- a/apps/calendar/lib/app.php +++ b/apps/calendar/lib/app.php @@ -9,7 +9,7 @@ /** * This class manages our app actions */ -OC_Calendar_App::$l10n = new OC_L10N('calendar'); +OC_Calendar_App::$l10n = OC_L10N::get('calendar'); class OC_Calendar_App{ public static $l10n; protected static $categories = null; diff --git a/apps/contacts/lib/app.php b/apps/contacts/lib/app.php index 78fdfe6a10a..475d2c8dc2e 100644 --- a/apps/contacts/lib/app.php +++ b/apps/contacts/lib/app.php @@ -9,7 +9,7 @@ /** * This class manages our app actions */ -OC_Contacts_App::$l10n = new OC_L10N('contacts'); +OC_Contacts_App::$l10n = OC_L10N::get('contacts'); OC_Contacts_App::$categories = new OC_VCategories('contacts'); class OC_Contacts_App { public static $l10n; diff --git a/apps/gallery/appinfo/app.php b/apps/gallery/appinfo/app.php index 325c2acf249..b8e7c14fcaf 100644 --- a/apps/gallery/appinfo/app.php +++ b/apps/gallery/appinfo/app.php @@ -27,7 +27,7 @@ OC::$CLASSPATH['OC_Gallery_Scanner'] = 'apps/gallery/lib/scanner.php'; OC::$CLASSPATH['OC_Gallery_Sharing'] = 'apps/gallery/lib/sharing.php'; OC::$CLASSPATH['OC_Gallery_Hooks_Handlers'] = 'apps/gallery/lib/hooks_handlers.php'; -$l = new OC_L10N('gallery'); +$l = OC_L10N::get('gallery'); OC_App::register(array( 'order' => 20, diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php index 9bec5db1b91..cf654b68c0b 100644 --- a/apps/gallery/templates/index.php +++ b/apps/gallery/templates/index.php @@ -7,7 +7,7 @@ OC_Util::addStyle('files', 'files'); OC_Util::addScript('files_imageviewer', 'jquery.mousewheel-3.0.4.pack'); OC_Util::addScript('files_imageviewer', 'jquery.fancybox-1.3.4.pack'); OC_Util::addStyle( 'files_imageviewer', 'jquery.fancybox-1.3.4' ); -$l = new OC_L10N('gallery'); +$l = OC_L10N::get('gallery'); ?> <script type="text/javascript">var gallery_scanning_root='<? echo OC_Preferences::getValue(OC_User::getUser(), 'gallery', 'root', '/'); ?>'; var gallery_default_order = '<? echo OC_Preferences::getValue(OC_User::getUser(), 'gallery', 'order', 'ASC'); ?>';</script> <div id="controls"> diff --git a/apps/gallery/templates/view_album.php b/apps/gallery/templates/view_album.php index 6b513a672d5..f938e487954 100644 --- a/apps/gallery/templates/view_album.php +++ b/apps/gallery/templates/view_album.php @@ -5,7 +5,7 @@ OC_Util::addScript('gallery', 'album_cover'); OC_Util::addScript('files_imageviewer', 'jquery.mousewheel-3.0.4.pack'); OC_Util::addScript('files_imageviewer', 'jquery.fancybox-1.3.4.pack'); OC_Util::addStyle( 'files_imageviewer', 'jquery.fancybox-1.3.4' ); -$l = new OC_L10N('gallery'); +$l = OC_L10N::get('gallery'); ?> <script type="text/javascript"> $(document).ready(function() { diff --git a/apps/media/appinfo/app.php b/apps/media/appinfo/app.php index 651067fbbe1..b0891874f7b 100644 --- a/apps/media/appinfo/app.php +++ b/apps/media/appinfo/app.php @@ -20,7 +20,7 @@ * */ -$l=new OC_L10N('media'); +$l=OC_L10N::get('media'); require_once('apps/media/lib_media.php'); diff --git a/core/ajax/translations.php b/core/ajax/translations.php index 2e436f8d84e..a6433b1964a 100644 --- a/core/ajax/translations.php +++ b/core/ajax/translations.php @@ -26,7 +26,7 @@ require_once('../../lib/base.php'); $app = $_POST["app"]; -$l = new OC_L10N( $app ); +$l = OC_L10N::get( $app ); OC_JSON::success(array('data' => $l->getTranslations())); ?> diff --git a/core/lostpassword/index.php b/core/lostpassword/index.php index a9b7d10804f..89bb6cfa794 100644 --- a/core/lostpassword/index.php +++ b/core/lostpassword/index.php @@ -20,7 +20,7 @@ if (isset($_POST['user'])) { $tmpl = new OC_Template('core/lostpassword', 'email'); $tmpl->assign('link', $link); $msg = $tmpl->fetchPage(); - $l = new OC_L10N('core'); + $l = OC_L10N::get('core'); $from = 'lostpassword-noreply@' . $_SERVER['HTTP_HOST']; mail($email, $l->t('Owncloud password reset'), $msg, 'From:' . $from); } diff --git a/core/strings.php b/core/strings.php index 9b4290db476..8c3f64ef14f 100644 --- a/core/strings.php +++ b/core/strings.php @@ -1,7 +1,7 @@ <?php //some strings that are used in /lib but wont be translatable unless they are in /core too -$l=new OC_L10N('core'); +$l=OC_L10N::get('core'); $l->t("Personal"); $l->t("Users"); $l->t("Apps"); diff --git a/files/ajax/upload.php b/files/ajax/upload.php index f8b8f0e2e5f..af7a7acf702 100644 --- a/files/ajax/upload.php +++ b/files/ajax/upload.php @@ -14,7 +14,7 @@ if (!isset($_FILES['files'])) { } foreach ($_FILES['files']['error'] as $error) { if ($error != 0) { - $l=new OC_L10N('files'); + $l=OC_L10N::get('files'); $errors = array( UPLOAD_ERR_OK=>$l->t("There is no error, the file uploaded with success"), UPLOAD_ERR_INI_SIZE=>$l->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'), diff --git a/files/appinfo/app.php b/files/appinfo/app.php index 0bf73d9a07e..1b495e52f40 100644 --- a/files/appinfo/app.php +++ b/files/appinfo/app.php @@ -1,7 +1,7 @@ <?php -$l=new OC_L10N('files'); +$l=OC_L10N::get('files'); OC_App::register( array( "order" => 2, "id" => "files", "name" => "Files" )); diff --git a/lib/app.php b/lib/app.php index b499e1a8ef2..db2df7c2434 100755 --- a/lib/app.php +++ b/lib/app.php @@ -254,7 +254,7 @@ class OC_App{ * entries are sorted by the key 'order' ascending. */ public static function getSettingsNavigation(){ - $l=new OC_L10N('core'); + $l=OC_L10N::get('core'); $settings = array(); // by default, settings only contain the help menu diff --git a/lib/files.php b/lib/files.php index 01558a68588..aacd2c9e004 100644 --- a/lib/files.php +++ b/lib/files.php @@ -225,7 +225,7 @@ class OC_Files { */ static function validateZipDownload($dir, $files) { if(!OC_Config::getValue('allowZipDownload', true)) { - $l = new OC_L10N('files'); + $l = OC_L10N::get('files'); header("HTTP/1.0 409 Conflict"); $tmpl = new OC_Template( '', 'error', 'user' ); $errors = array( @@ -250,7 +250,7 @@ class OC_Files { $totalsize += OC_Filesystem::filesize($dir.'/'.$files); } if($totalsize > $zipLimit) { - $l = new OC_L10N('files'); + $l = OC_L10N::get('files'); header("HTTP/1.0 409 Conflict"); $tmpl = new OC_Template( '', 'error', 'user' ); $errors = array( diff --git a/lib/json.php b/lib/json.php index cedf79fd7c3..0d208ce12a2 100644 --- a/lib/json.php +++ b/lib/json.php @@ -24,7 +24,7 @@ class OC_JSON{ */ public static function checkAppEnabled($app){ if( !OC_App::isEnabled($app)){ - $l = new OC_L10N('core'); + $l = OC_L10N::get('core'); self::error(array( 'data' => array( 'message' => $l->t('Application is not enabled') ))); exit(); } @@ -35,7 +35,7 @@ class OC_JSON{ */ public static function checkLoggedIn(){ if( !OC_User::isLoggedIn()){ - $l = new OC_L10N('core'); + $l = OC_L10N::get('core'); self::error(array( 'data' => array( 'message' => $l->t('Authentication error') ))); exit(); } @@ -47,7 +47,7 @@ class OC_JSON{ public static function checkAdminUser(){ self::checkLoggedIn(); if( !OC_Group::inGroup( OC_User::getUser(), 'admin' )){ - $l = new OC_L10N('core'); + $l = OC_L10N::get('core'); self::error(array( 'data' => array( 'message' => $l->t('Authentication error') ))); exit(); } diff --git a/lib/l10n.php b/lib/l10n.php index 00bff08bf7f..c0ecdbd1b70 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -25,6 +25,11 @@ */ class OC_L10N{ /** + * cached instances + */ + protected static $instances=array(); + + /** * cache */ protected static $cache = array(); @@ -46,6 +51,21 @@ class OC_L10N{ 'date' => 'd.m.Y', 'datetime' => 'd.m.Y H:i:s', 'time' => 'H:i:s'); + + /** + * get an L10N instance + * @return OC_L10N + */ + public static function get($app,$lang=null){ + if(is_null($lang)){ + if(!isset(self::$instances[$app])){ + self::$instances[$app]=new OC_L10N($app); + } + return self::$instances[$app]; + }else{ + return new OC_L10N($app,$lang); + } + } /** * @brief The constructor diff --git a/lib/template.php b/lib/template.php index 5bcf52b9321..cb39a10df31 100644 --- a/lib/template.php +++ b/lib/template.php @@ -76,7 +76,7 @@ function simple_file_size($bytes) { } function relative_modified_date($timestamp) { - $l=new OC_L10N('template'); + $l=OC_L10N::get('template'); $timediff = time() - $timestamp; $diffminutes = round($timediff/60); $diffhours = round($diffminutes/60); @@ -155,7 +155,7 @@ class OC_Template{ $this->renderas = $renderas; $this->application = $app; $this->vars = array(); - $this->l10n = new OC_L10N($app); + $this->l10n = OC_L10N::get($app); $this->findTemplate($name); } diff --git a/settings/ajax/lostpassword.php b/settings/ajax/lostpassword.php index a2dfc033206..5874dec9647 100644 --- a/settings/ajax/lostpassword.php +++ b/settings/ajax/lostpassword.php @@ -5,7 +5,7 @@ require_once('../../lib/base.php'); OC_JSON::checkLoggedIn(); -$l=new OC_L10N('core'); +$l=OC_L10N::get('core'); // Get data if( isset( $_POST['email'] ) ){ diff --git a/settings/ajax/openid.php b/settings/ajax/openid.php index c4b119b448d..58d071255c2 100644 --- a/settings/ajax/openid.php +++ b/settings/ajax/openid.php @@ -3,7 +3,7 @@ // Init owncloud require_once('../../lib/base.php'); -$l=new OC_L10N('settings'); +$l=OC_L10N::get('settings'); OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('user_openid'); diff --git a/settings/ajax/setlanguage.php b/settings/ajax/setlanguage.php index dc1128de2e5..d8d1a860378 100644 --- a/settings/ajax/setlanguage.php +++ b/settings/ajax/setlanguage.php @@ -3,7 +3,7 @@ // Init owncloud require_once('../../lib/base.php'); -$l=new OC_L10N('settings'); +$l=OC_L10N::get('settings'); OC_JSON::checkLoggedIn(); diff --git a/settings/personal.php b/settings/personal.php index 07030109de7..41499657ac7 100755 --- a/settings/personal.php +++ b/settings/personal.php @@ -35,7 +35,7 @@ array_unshift($languageCodes,$lang); $languageNames=include 'languageCodes.php'; $languages=array(); foreach($languageCodes as $lang){ - $l=new OC_L10N('settings',$lang); + $l=OC_L10N::get('settings',$lang); if(substr($l->t('__language_name__'),0,1)!='_'){//first check if the language name is in the translation file $languages[]=array('code'=>$lang,'name'=>$l->t('__language_name__')); }elseif(isset($languageNames[$lang])){ |