reuse OC_L10N objects

remotes/origin/stable4
Robin Appelman 13 years ago
parent 721311c909
commit b1bcc60d83
  1. 2
      apps/admin_dependencies_chk/appinfo/app.php
  2. 2
      apps/admin_dependencies_chk/settings.php
  3. 2
      apps/bookmarks/bookmarksHelper.php
  4. 2
      apps/bookmarks/templates/bookmarklet.php
  5. 1
      apps/calendar/ajax/calendar/new.form.php
  6. 2
      apps/calendar/ajax/calendar/overview.php
  7. 2
      apps/calendar/ajax/event/delete.php
  8. 2
      apps/calendar/ajax/event/new.php
  9. 2
      apps/calendar/ajax/events.php
  10. 1
      apps/calendar/ajax/import/dialog.php
  11. 2
      apps/calendar/ajax/settings/guesstimezone.php
  12. 2
      apps/calendar/ajax/settings/settimezone.php
  13. 2
      apps/calendar/appinfo/app.php
  14. 2
      apps/calendar/lib/app.php
  15. 2
      apps/contacts/lib/app.php
  16. 2
      apps/gallery/appinfo/app.php
  17. 2
      apps/gallery/templates/index.php
  18. 2
      apps/gallery/templates/view_album.php
  19. 2
      apps/media/appinfo/app.php
  20. 2
      core/ajax/translations.php
  21. 2
      core/lostpassword/index.php
  22. 2
      core/strings.php
  23. 2
      files/ajax/upload.php
  24. 2
      files/appinfo/app.php
  25. 2
      lib/app.php
  26. 4
      lib/files.php
  27. 6
      lib/json.php
  28. 20
      lib/l10n.php
  29. 4
      lib/template.php
  30. 2
      settings/ajax/lostpassword.php
  31. 2
      settings/ajax/openid.php
  32. 2
      settings/ajax/setlanguage.php
  33. 2
      settings/personal.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,

@ -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();

@ -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');
}

@ -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>';

@ -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();

@ -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");

@ -7,8 +7,6 @@
*/
require_once('../../../../lib/base.php');
$l10n = new OC_L10N('calendar');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');

@ -8,8 +8,6 @@
require_once('../../../../lib/base.php');
$l10n = new OC_L10N('calendar');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');

@ -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();

@ -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']);

@ -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'];

@ -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();

@ -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';

@ -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;

@ -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;

@ -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,

@ -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">

@ -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() {

@ -20,7 +20,7 @@
*
*/
$l=new OC_L10N('media');
$l=OC_L10N::get('media');
require_once('apps/media/lib_media.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()));
?>

@ -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);
}

@ -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");

@ -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'),

@ -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" ));

@ -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

@ -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(

@ -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();
}

@ -24,6 +24,11 @@
* This class is for i18n and l10n
*/
class OC_L10N{
/**
* cached instances
*/
protected static $instances=array();
/**
* cache
*/
@ -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

@ -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);
}

@ -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'] ) ){

@ -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');

@ -3,7 +3,7 @@
// Init owncloud
require_once('../../lib/base.php');
$l=new OC_L10N('settings');
$l=OC_L10N::get('settings');
OC_JSON::checkLoggedIn();

@ -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])){

Loading…
Cancel
Save