Completed
Pull Request — stable9 (#4226)
by Lukas
11:11
created
core/templates/internalaltmail.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 print_unescaped($l->t("Hey there,\n\njust letting you know that %s shared %s with you.\nView it: %s\n\n", array($_['user_displayname'], $_['filename'], $_['link'])));
3 3
 if ( isset($_['expiration']) ) {
4
-	print_unescaped($l->t("The share will expire on %s.", array($_['expiration'])));
5
-	print_unescaped("\n\n");
4
+    print_unescaped($l->t("The share will expire on %s.", array($_['expiration'])));
5
+    print_unescaped("\n\n");
6 6
 }
7 7
 // TRANSLATORS term at the end of a mail
8 8
 p($l->t("Cheers!"));
Please login to merge, or discard this patch.
core/templates/internalmail.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@
 block discarded – undo
13 13
 <?php
14 14
 print_unescaped($l->t('Hey there,<br><br>just letting you know that %s shared <strong>%s</strong> with you.<br><a href="%s">View it!</a><br><br>', array($_['user_displayname'], $_['filename'], $_['link'])));
15 15
 if ( isset($_['expiration']) ) {
16
-	p($l->t("The share will expire on %s.", array($_['expiration'])));
17
-	print_unescaped('<br><br>');
16
+    p($l->t("The share will expire on %s.", array($_['expiration'])));
17
+    print_unescaped('<br><br>');
18 18
 }
19 19
 // TRANSLATORS term at the end of a mail
20 20
 p($l->t('Cheers!'));
Please login to merge, or discard this patch.
core/ajax/appconfig.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 $action=isset($_POST['action'])?$_POST['action']:$_GET['action'];
30 30
 
31 31
 if(isset($_POST['app']) || isset($_GET['app'])) {
32
-	$app=OC_App::cleanAppId(isset($_POST['app'])? (string)$_POST['app']: (string)$_GET['app']);
32
+    $app=OC_App::cleanAppId(isset($_POST['app'])? (string)$_POST['app']: (string)$_GET['app']);
33 33
 }
34 34
 
35 35
 // An admin should not be able to add remote and public services
@@ -37,34 +37,34 @@  discard block
 block discarded – undo
37 37
 // This change is due the fact that an admin may not be expected 
38 38
 // to execute arbitrary code in every environment.
39 39
 if($app === 'core' && isset($_POST['key']) &&(substr((string)$_POST['key'],0,7) === 'remote_' || substr((string)$_POST['key'],0,7) === 'public_')) {
40
-	OC_JSON::error(array('data' => array('message' => 'Unexpected error!')));
41
-	return;
40
+    OC_JSON::error(array('data' => array('message' => 'Unexpected error!')));
41
+    return;
42 42
 }
43 43
 
44 44
 $result=false;
45 45
 $appConfig = \OC::$server->getAppConfig();
46 46
 switch($action) {
47
-	case 'getValue':
48
-		$result=$appConfig->getValue($app, (string)$_GET['key'], (string)$_GET['defaultValue']);
49
-		break;
50
-	case 'setValue':
51
-		$result=$appConfig->setValue($app, (string)$_POST['key'], (string)$_POST['value']);
52
-		break;
53
-	case 'getApps':
54
-		$result=$appConfig->getApps();
55
-		break;
56
-	case 'getKeys':
57
-		$result=$appConfig->getKeys($app);
58
-		break;
59
-	case 'hasKey':
60
-		$result=$appConfig->hasKey($app, (string)$_GET['key']);
61
-		break;
62
-	case 'deleteKey':
63
-		$result=$appConfig->deleteKey($app, (string)$_POST['key']);
64
-		break;
65
-	case 'deleteApp':
66
-		$result=$appConfig->deleteApp($app);
67
-		break;
47
+    case 'getValue':
48
+        $result=$appConfig->getValue($app, (string)$_GET['key'], (string)$_GET['defaultValue']);
49
+        break;
50
+    case 'setValue':
51
+        $result=$appConfig->setValue($app, (string)$_POST['key'], (string)$_POST['value']);
52
+        break;
53
+    case 'getApps':
54
+        $result=$appConfig->getApps();
55
+        break;
56
+    case 'getKeys':
57
+        $result=$appConfig->getKeys($app);
58
+        break;
59
+    case 'hasKey':
60
+        $result=$appConfig->hasKey($app, (string)$_GET['key']);
61
+        break;
62
+    case 'deleteKey':
63
+        $result=$appConfig->deleteKey($app, (string)$_POST['key']);
64
+        break;
65
+    case 'deleteApp':
66
+        $result=$appConfig->deleteApp($app);
67
+        break;
68 68
 }
69 69
 OC_JSON::success(array('data'=>$result));
70 70
 
Please login to merge, or discard this patch.
core/js/config.php 1 patch
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  */
35 35
 
36 36
 if(!\OC::$server->getRequest()->passesStrictCookieCheck()) {
37
-	die();
37
+    die();
38 38
 }
39 39
 
40 40
 // Set the content type to Javascript
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 // Get the config
54 54
 $apps_paths = array();
55 55
 foreach(OC_App::getEnabledApps() as $app) {
56
-	$apps_paths[$app] = OC_App::getAppWebPath($app);
56
+    $apps_paths[$app] = OC_App::getAppWebPath($app);
57 57
 }
58 58
 
59 59
 $config = \OC::$server->getConfig();
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 $defaultExpireDateEnabled = ($value === 'yes') ? true :false;
62 62
 $defaultExpireDate = $enforceDefaultExpireDate = null;
63 63
 if ($defaultExpireDateEnabled) {
64
-	$defaultExpireDate = (int) $config->getAppValue('core', 'shareapi_expire_after_n_days', '7');
65
-	$value = $config->getAppValue('core', 'shareapi_enforce_expire_date', 'no');
66
-	$enforceDefaultExpireDate = ($value === 'yes') ? true : false;
64
+    $defaultExpireDate = (int) $config->getAppValue('core', 'shareapi_expire_after_n_days', '7');
65
+    $value = $config->getAppValue('core', 'shareapi_enforce_expire_date', 'no');
66
+    $enforceDefaultExpireDate = ($value === 'yes') ? true : false;
67 67
 }
68 68
 $outgoingServer2serverShareEnabled = $config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes';
69 69
 
@@ -71,123 +71,123 @@  discard block
 block discarded – undo
71 71
 
72 72
 $dataLocation = str_replace(OC::$SERVERROOT .'/', '', $config->getSystemValue('datadirectory', ''), $countOfDataLocation);
73 73
 if($countOfDataLocation !== 1 || !OC_User::isAdminUser(OC_User::getUser())){
74
-	$dataLocation = false;
74
+    $dataLocation = false;
75 75
 }
76 76
 
77 77
 $array = array(
78
-	"oc_debug" => $config->getSystemValue('debug', false) ? 'true' : 'false',
79
-	"oc_isadmin" => OC_User::isAdminUser(OC_User::getUser()) ? 'true' : 'false',
80
-	"oc_dataURL" => is_string($dataLocation) ? "\"".$dataLocation."\"" : 'false',
81
-	"oc_webroot" => "\"".OC::$WEBROOT."\"",
82
-	"oc_appswebroots" =>  str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution
83
-	"datepickerFormatDate" => json_encode($l->l('jsdate', null)),
84
-	"dayNames" =>  json_encode(
85
-		array(
86
-			(string)$l->t('Sunday'),
87
-			(string)$l->t('Monday'),
88
-			(string)$l->t('Tuesday'),
89
-			(string)$l->t('Wednesday'),
90
-			(string)$l->t('Thursday'),
91
-			(string)$l->t('Friday'),
92
-			(string)$l->t('Saturday')
93
-		)
94
-	),
95
-	"dayNamesShort" =>  json_encode(
96
-		array(
97
-			(string)$l->t('Sun.'),
98
-			(string)$l->t('Mon.'),
99
-			(string)$l->t('Tue.'),
100
-			(string)$l->t('Wed.'),
101
-			(string)$l->t('Thu.'),
102
-			(string)$l->t('Fri.'),
103
-			(string)$l->t('Sat.')
104
-		)
105
-	),
106
-	"dayNamesMin" =>  json_encode(
107
-		array(
108
-			(string)$l->t('Su'),
109
-			(string)$l->t('Mo'),
110
-			(string)$l->t('Tu'),
111
-			(string)$l->t('We'),
112
-			(string)$l->t('Th'),
113
-			(string)$l->t('Fr'),
114
-			(string)$l->t('Sa')
115
-		)
116
-	),
117
-	"monthNames" => json_encode(
118
-		array(
119
-			(string)$l->t('January'),
120
-			(string)$l->t('February'),
121
-			(string)$l->t('March'),
122
-			(string)$l->t('April'),
123
-			(string)$l->t('May'),
124
-			(string)$l->t('June'),
125
-			(string)$l->t('July'),
126
-			(string)$l->t('August'),
127
-			(string)$l->t('September'),
128
-			(string)$l->t('October'),
129
-			(string)$l->t('November'),
130
-			(string)$l->t('December')
131
-		)
132
-	),
133
-	"monthNamesShort" => json_encode(
134
-		array(
135
-			(string)$l->t('Jan.'),
136
-			(string)$l->t('Feb.'),
137
-			(string)$l->t('Mar.'),
138
-			(string)$l->t('Apr.'),
139
-			(string)$l->t('May.'),
140
-			(string)$l->t('Jun.'),
141
-			(string)$l->t('Jul.'),
142
-			(string)$l->t('Aug.'),
143
-			(string)$l->t('Sep.'),
144
-			(string)$l->t('Oct.'),
145
-			(string)$l->t('Nov.'),
146
-			(string)$l->t('Dec.')
147
-		)
148
-	),
149
-	"firstDay" => json_encode($l->l('firstday', null)) ,
150
-	"oc_config" => json_encode(
151
-		array(
152
-			'session_lifetime'	=> min(\OCP\Config::getSystemValue('session_lifetime', OC::$server->getIniWrapper()->getNumeric('session.gc_maxlifetime')), OC::$server->getIniWrapper()->getNumeric('session.gc_maxlifetime')),
153
-			'session_keepalive'	=> \OCP\Config::getSystemValue('session_keepalive', true),
154
-			'version'			=> implode('.', \OCP\Util::getVersion()),
155
-			'versionstring'		=> OC_Util::getVersionString(),
156
-			'enable_avatars'	=> \OC::$server->getConfig()->getSystemValue('enable_avatars', true) === true,
157
-			'lost_password_link'=> \OC::$server->getConfig()->getSystemValue('lost_password_link', null),
158
-			'modRewriteWorking'	=> (getenv('front_controller_active') === 'true'),
159
-		)
160
-	),
161
-	"oc_appconfig" => json_encode(
162
-			array("core" => array(
163
-				'defaultExpireDateEnabled' => $defaultExpireDateEnabled,
164
-				'defaultExpireDate' => $defaultExpireDate,
165
-				'defaultExpireDateEnforced' => $enforceDefaultExpireDate,
166
-				'enforcePasswordForPublicLink' => \OCP\Util::isPublicLinkPasswordRequired(),
167
-				'sharingDisabledForUser' => \OCP\Util::isSharingDisabledForUser(),
168
-				'resharingAllowed' => \OCP\Share::isResharingAllowed(),
169
-				'remoteShareAllowed' => $outgoingServer2serverShareEnabled,
170
-				'federatedCloudShareDoc' => \OC::$server->getURLGenerator()->linkToDocs('user-sharing-federated'),
171
-				'allowGroupSharing' => \OC::$server->getShareManager()->allowGroupSharing()
172
-				)
173
-			)
174
-	),
175
-	"oc_defaults" => json_encode(
176
-		array(
177
-			'entity' => $defaults->getEntity(),
178
-			'name' => $defaults->getName(),
179
-			'title' => $defaults->getTitle(),
180
-			'baseUrl' => $defaults->getBaseUrl(),
181
-			'syncClientUrl' => $defaults->getSyncClientUrl(),
182
-			'docBaseUrl' => $defaults->getDocBaseUrl(),
183
-			'docPlaceholderUrl' => $defaults->buildDocLinkToKey('PLACEHOLDER'),
184
-			'slogan' => $defaults->getSlogan(),
185
-			'logoClaim' => $defaults->getLogoClaim(),
186
-			'shortFooter' => $defaults->getShortFooter(),
187
-			'longFooter' => $defaults->getLongFooter(),
188
-			'folder' => OC_Util::getTheme(),
189
-		)
190
-	)
78
+    "oc_debug" => $config->getSystemValue('debug', false) ? 'true' : 'false',
79
+    "oc_isadmin" => OC_User::isAdminUser(OC_User::getUser()) ? 'true' : 'false',
80
+    "oc_dataURL" => is_string($dataLocation) ? "\"".$dataLocation."\"" : 'false',
81
+    "oc_webroot" => "\"".OC::$WEBROOT."\"",
82
+    "oc_appswebroots" =>  str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution
83
+    "datepickerFormatDate" => json_encode($l->l('jsdate', null)),
84
+    "dayNames" =>  json_encode(
85
+        array(
86
+            (string)$l->t('Sunday'),
87
+            (string)$l->t('Monday'),
88
+            (string)$l->t('Tuesday'),
89
+            (string)$l->t('Wednesday'),
90
+            (string)$l->t('Thursday'),
91
+            (string)$l->t('Friday'),
92
+            (string)$l->t('Saturday')
93
+        )
94
+    ),
95
+    "dayNamesShort" =>  json_encode(
96
+        array(
97
+            (string)$l->t('Sun.'),
98
+            (string)$l->t('Mon.'),
99
+            (string)$l->t('Tue.'),
100
+            (string)$l->t('Wed.'),
101
+            (string)$l->t('Thu.'),
102
+            (string)$l->t('Fri.'),
103
+            (string)$l->t('Sat.')
104
+        )
105
+    ),
106
+    "dayNamesMin" =>  json_encode(
107
+        array(
108
+            (string)$l->t('Su'),
109
+            (string)$l->t('Mo'),
110
+            (string)$l->t('Tu'),
111
+            (string)$l->t('We'),
112
+            (string)$l->t('Th'),
113
+            (string)$l->t('Fr'),
114
+            (string)$l->t('Sa')
115
+        )
116
+    ),
117
+    "monthNames" => json_encode(
118
+        array(
119
+            (string)$l->t('January'),
120
+            (string)$l->t('February'),
121
+            (string)$l->t('March'),
122
+            (string)$l->t('April'),
123
+            (string)$l->t('May'),
124
+            (string)$l->t('June'),
125
+            (string)$l->t('July'),
126
+            (string)$l->t('August'),
127
+            (string)$l->t('September'),
128
+            (string)$l->t('October'),
129
+            (string)$l->t('November'),
130
+            (string)$l->t('December')
131
+        )
132
+    ),
133
+    "monthNamesShort" => json_encode(
134
+        array(
135
+            (string)$l->t('Jan.'),
136
+            (string)$l->t('Feb.'),
137
+            (string)$l->t('Mar.'),
138
+            (string)$l->t('Apr.'),
139
+            (string)$l->t('May.'),
140
+            (string)$l->t('Jun.'),
141
+            (string)$l->t('Jul.'),
142
+            (string)$l->t('Aug.'),
143
+            (string)$l->t('Sep.'),
144
+            (string)$l->t('Oct.'),
145
+            (string)$l->t('Nov.'),
146
+            (string)$l->t('Dec.')
147
+        )
148
+    ),
149
+    "firstDay" => json_encode($l->l('firstday', null)) ,
150
+    "oc_config" => json_encode(
151
+        array(
152
+            'session_lifetime'	=> min(\OCP\Config::getSystemValue('session_lifetime', OC::$server->getIniWrapper()->getNumeric('session.gc_maxlifetime')), OC::$server->getIniWrapper()->getNumeric('session.gc_maxlifetime')),
153
+            'session_keepalive'	=> \OCP\Config::getSystemValue('session_keepalive', true),
154
+            'version'			=> implode('.', \OCP\Util::getVersion()),
155
+            'versionstring'		=> OC_Util::getVersionString(),
156
+            'enable_avatars'	=> \OC::$server->getConfig()->getSystemValue('enable_avatars', true) === true,
157
+            'lost_password_link'=> \OC::$server->getConfig()->getSystemValue('lost_password_link', null),
158
+            'modRewriteWorking'	=> (getenv('front_controller_active') === 'true'),
159
+        )
160
+    ),
161
+    "oc_appconfig" => json_encode(
162
+            array("core" => array(
163
+                'defaultExpireDateEnabled' => $defaultExpireDateEnabled,
164
+                'defaultExpireDate' => $defaultExpireDate,
165
+                'defaultExpireDateEnforced' => $enforceDefaultExpireDate,
166
+                'enforcePasswordForPublicLink' => \OCP\Util::isPublicLinkPasswordRequired(),
167
+                'sharingDisabledForUser' => \OCP\Util::isSharingDisabledForUser(),
168
+                'resharingAllowed' => \OCP\Share::isResharingAllowed(),
169
+                'remoteShareAllowed' => $outgoingServer2serverShareEnabled,
170
+                'federatedCloudShareDoc' => \OC::$server->getURLGenerator()->linkToDocs('user-sharing-federated'),
171
+                'allowGroupSharing' => \OC::$server->getShareManager()->allowGroupSharing()
172
+                )
173
+            )
174
+    ),
175
+    "oc_defaults" => json_encode(
176
+        array(
177
+            'entity' => $defaults->getEntity(),
178
+            'name' => $defaults->getName(),
179
+            'title' => $defaults->getTitle(),
180
+            'baseUrl' => $defaults->getBaseUrl(),
181
+            'syncClientUrl' => $defaults->getSyncClientUrl(),
182
+            'docBaseUrl' => $defaults->getDocBaseUrl(),
183
+            'docPlaceholderUrl' => $defaults->buildDocLinkToKey('PLACEHOLDER'),
184
+            'slogan' => $defaults->getSlogan(),
185
+            'logoClaim' => $defaults->getLogoClaim(),
186
+            'shortFooter' => $defaults->getShortFooter(),
187
+            'longFooter' => $defaults->getLongFooter(),
188
+            'folder' => OC_Util::getTheme(),
189
+        )
190
+    )
191 191
 );
192 192
 
193 193
 // Allow hooks to modify the output values
@@ -195,5 +195,5 @@  discard block
 block discarded – undo
195 195
 
196 196
 // Echo it
197 197
 foreach ($array as  $setting => $value) {
198
-	echo("var ". $setting ."=".$value.";\n");
198
+    echo("var ". $setting ."=".$value.";\n");
199 199
 }
Please login to merge, or discard this patch.
lib/private/legacy/l10n.php 1 patch
Indentation   +305 added lines, -305 removed lines patch added patch discarded remove patch
@@ -35,309 +35,309 @@
 block discarded – undo
35 35
  * @deprecated 9.0.0 Use \OC::$server->getL10NFactory()->get() instead
36 36
  */
37 37
 class OC_L10N implements \OCP\IL10N {
38
-	/**
39
-	 * cache
40
-	 */
41
-	protected static $cache = array();
42
-	protected static $availableLanguages = array();
43
-
44
-	/**
45
-	 * The best language
46
-	 */
47
-	protected static $language = '';
48
-
49
-	/**
50
-	 * App of this object
51
-	 */
52
-	protected $app;
53
-
54
-	/**
55
-	 * Language of this object
56
-	 */
57
-	protected $lang;
58
-
59
-	/**
60
-	 * Translations
61
-	 */
62
-	private $translations = array();
63
-
64
-	/**
65
-	 * Plural forms (string)
66
-	 */
67
-	private $pluralFormString = 'nplurals=2; plural=(n != 1);';
68
-
69
-	/**
70
-	 * Plural forms (function)
71
-	 */
72
-	private $pluralFormFunction = null;
73
-
74
-	/**
75
-	 * The constructor
76
-	 * @param string $app app requesting l10n
77
-	 * @param string $lang default: null Language
78
-	 *
79
-	 * If language is not set, the constructor tries to find the right
80
-	 * language.
81
-	 * @deprecated 9.0.0 Use \OC::$server->getL10NFactory()->get() instead
82
-	 */
83
-	public function __construct($app, $lang = null) {
84
-		$app = \OC_App::cleanAppId($app);
85
-		$this->app = $app;
86
-
87
-		if ($lang !== null) {
88
-			$lang = str_replace(array('\0', '/', '\\', '..'), '', $lang);
89
-		}
90
-
91
-		// Find the right language
92
-		if ($app !== 'test' && !\OC::$server->getL10NFactory()->languageExists($app, $lang)) {
93
-			$lang = \OC::$server->getL10NFactory()->findLanguage($app);
94
-		}
95
-
96
-		$this->lang = $lang;
97
-	}
98
-
99
-	/**
100
-	 * @param $transFile
101
-	 * @return bool
102
-	 */
103
-	public function load($transFile) {
104
-		$this->app = true;
105
-
106
-		$json = json_decode(file_get_contents($transFile), true);
107
-		if (!is_array($json)) {
108
-			$jsonError = json_last_error();
109
-			\OC::$server->getLogger()->warning("Failed to load $transFile - json error code: $jsonError", ['app' => 'l10n']);
110
-			return false;
111
-		}
112
-
113
-		$this->pluralFormString = $json['pluralForm'];
114
-		$translations = $json['translations'];
115
-
116
-		$this->translations = array_merge($this->translations, $translations);
117
-
118
-		return true;
119
-	}
120
-
121
-	protected function init() {
122
-		if ($this->app === true) {
123
-			return;
124
-		}
125
-		$app = $this->app;
126
-		$lang = $this->lang;
127
-		$this->app = true;
128
-
129
-		/** @var \OC\L10N\Factory $factory */
130
-		$factory = \OC::$server->getL10NFactory();
131
-		$languageFiles = $factory->getL10nFilesForApp($app, $lang);
132
-
133
-		$this->translations = [];
134
-		foreach ($languageFiles as $languageFile) {
135
-			$this->load($languageFile);
136
-		}
137
-	}
138
-
139
-	/**
140
-	 * Translating
141
-	 * @param string $text The text we need a translation for
142
-	 * @param array $parameters default:array() Parameters for sprintf
143
-	 * @return \OC_L10N_String Translation or the same text
144
-	 *
145
-	 * Returns the translation. If no translation is found, $text will be
146
-	 * returned.
147
-	 */
148
-	public function t($text, $parameters = array()) {
149
-		return new OC_L10N_String($this, $text, $parameters);
150
-	}
151
-
152
-	/**
153
-	 * Translating
154
-	 * @param string $text_singular the string to translate for exactly one object
155
-	 * @param string $text_plural the string to translate for n objects
156
-	 * @param integer $count Number of objects
157
-	 * @param array $parameters default:array() Parameters for sprintf
158
-	 * @return \OC_L10N_String Translation or the same text
159
-	 *
160
-	 * Returns the translation. If no translation is found, $text will be
161
-	 * returned. %n will be replaced with the number of objects.
162
-	 *
163
-	 * The correct plural is determined by the plural_forms-function
164
-	 * provided by the po file.
165
-	 *
166
-	 */
167
-	public function n($text_singular, $text_plural, $count, $parameters = array()) {
168
-		$this->init();
169
-		$identifier = "_${text_singular}_::_${text_plural}_";
170
-		if( array_key_exists($identifier, $this->translations)) {
171
-			return new OC_L10N_String( $this, $identifier, $parameters, $count );
172
-		}else{
173
-			if($count === 1) {
174
-				return new OC_L10N_String($this, $text_singular, $parameters, $count);
175
-			}else{
176
-				return new OC_L10N_String($this, $text_plural, $parameters, $count);
177
-			}
178
-		}
179
-	}
180
-
181
-	/**
182
-	 * getTranslations
183
-	 * @return array Fetch all translations
184
-	 *
185
-	 * Returns an associative array with all translations
186
-	 */
187
-	public function getTranslations() {
188
-		$this->init();
189
-		return $this->translations;
190
-	}
191
-
192
-	/**
193
-	 * getPluralFormFunction
194
-	 * @return string the plural form function
195
-	 *
196
-	 * returned function accepts the argument $n
197
-	 */
198
-	public function getPluralFormFunction() {
199
-		$this->init();
200
-		if (is_null($this->pluralFormFunction)) {
201
-			$this->pluralFormFunction = \OC::$server->getL10NFactory()->createPluralFunction($this->pluralFormString);
202
-		}
203
-		return $this->pluralFormFunction;
204
-	}
205
-
206
-	/**
207
-	 * Localization
208
-	 * @param string $type Type of localization
209
-	 * @param array|int|string $data parameters for this localization
210
-	 * @param array $options
211
-	 * @return string|false
212
-	 *
213
-	 * Returns the localized data.
214
-	 *
215
-	 * Implemented types:
216
-	 *  - date
217
-	 *    - Creates a date
218
-	 *    - params: timestamp (int/string)
219
-	 *  - datetime
220
-	 *    - Creates date and time
221
-	 *    - params: timestamp (int/string)
222
-	 *  - time
223
-	 *    - Creates a time
224
-	 *    - params: timestamp (int/string)
225
-	 *  - firstday: Returns the first day of the week (0 sunday - 6 saturday)
226
-	 *  - jsdate: Returns the short JS date format
227
-	 */
228
-	public function l($type, $data, $options = array()) {
229
-		if ($type === 'firstday') {
230
-			return $this->getFirstWeekDay();
231
-		}
232
-		if ($type === 'jsdate') {
233
-			return $this->getDateFormat();
234
-		}
235
-
236
-		$this->init();
237
-		$value = new DateTime();
238
-		if($data instanceof DateTime) {
239
-			$value = $data;
240
-		} elseif(is_string($data) && !is_numeric($data)) {
241
-			$data = strtotime($data);
242
-			$value->setTimestamp($data);
243
-		} else {
244
-			$value->setTimestamp($data);
245
-		}
246
-
247
-		// Use the language of the instance
248
-		$locale = $this->transformToCLDRLocale($this->getLanguageCode());
249
-
250
-		$options = array_merge(array('width' => 'long'), $options);
251
-		$width = $options['width'];
252
-		switch($type) {
253
-			case 'date':
254
-				return Punic\Calendar::formatDate($value, $width, $locale);
255
-			case 'datetime':
256
-				return Punic\Calendar::formatDatetime($value, $width, $locale);
257
-			case 'time':
258
-				return Punic\Calendar::formatTime($value, $width, $locale);
259
-			default:
260
-				return false;
261
-		}
262
-	}
263
-
264
-	/**
265
-	 * The code (en, de, ...) of the language that is used for this OC_L10N object
266
-	 *
267
-	 * @return string language
268
-	 */
269
-	public function getLanguageCode() {
270
-		return $this->lang;
271
-	}
272
-
273
-	/**
274
-	 * @return string
275
-	 * @throws \Punic\Exception\ValueNotInList
276
-	 * @deprecated 9.0.0 Use $this->l('jsdate', null) instead
277
-	 */
278
-	public function getDateFormat() {
279
-		$locale = $this->transformToCLDRLocale($this->getLanguageCode());
280
-		return Punic\Calendar::getDateFormat('short', $locale);
281
-	}
282
-
283
-	/**
284
-	 * @return int
285
-	 * @deprecated 9.0.0 Use $this->l('firstday', null) instead
286
-	 */
287
-	public function getFirstWeekDay() {
288
-		$locale = $this->transformToCLDRLocale($this->getLanguageCode());
289
-		return Punic\Calendar::getFirstWeekday($locale);
290
-	}
291
-
292
-	/**
293
-	 * @param string $locale
294
-	 * @return string
295
-	 */
296
-	private function transformToCLDRLocale($locale) {
297
-		if ($locale === 'sr@latin') {
298
-			return 'sr_latn';
299
-		}
300
-
301
-		return $locale;
302
-	}
303
-
304
-	/**
305
-	 * find the best language
306
-	 * @param string $app
307
-	 * @return string language
308
-	 *
309
-	 * If nothing works it returns 'en'
310
-	 * @deprecated 9.0.0 Use \OC::$server->getL10NFactory()->findLanguage() instead
311
-	 */
312
-	public static function findLanguage($app = null) {
313
-		return \OC::$server->getL10NFactory()->findLanguage($app);
314
-	}
315
-
316
-	/**
317
-	 * @return string
318
-	 * @deprecated 9.0.0 Use \OC::$server->getL10NFactory()->setLanguageFromRequest() instead
319
-	 */
320
-	public static function setLanguageFromRequest() {
321
-		return \OC::$server->getL10NFactory()->setLanguageFromRequest();
322
-	}
323
-
324
-	/**
325
-	 * find all available languages for an app
326
-	 * @param string $app App that needs to be translated
327
-	 * @return array an array of available languages
328
-	 * @deprecated 9.0.0 Use \OC::$server->getL10NFactory()->findAvailableLanguages() instead
329
-	 */
330
-	public static function findAvailableLanguages($app=null) {
331
-		return \OC::$server->getL10NFactory()->findAvailableLanguages($app);
332
-	}
333
-
334
-	/**
335
-	 * @param string $app
336
-	 * @param string $lang
337
-	 * @return bool
338
-	 * @deprecated 9.0.0 Use \OC::$server->getL10NFactory()->languageExists() instead
339
-	 */
340
-	public static function languageExists($app, $lang) {
341
-		return \OC::$server->getL10NFactory()->languageExists($app, $lang);
342
-	}
38
+    /**
39
+     * cache
40
+     */
41
+    protected static $cache = array();
42
+    protected static $availableLanguages = array();
43
+
44
+    /**
45
+     * The best language
46
+     */
47
+    protected static $language = '';
48
+
49
+    /**
50
+     * App of this object
51
+     */
52
+    protected $app;
53
+
54
+    /**
55
+     * Language of this object
56
+     */
57
+    protected $lang;
58
+
59
+    /**
60
+     * Translations
61
+     */
62
+    private $translations = array();
63
+
64
+    /**
65
+     * Plural forms (string)
66
+     */
67
+    private $pluralFormString = 'nplurals=2; plural=(n != 1);';
68
+
69
+    /**
70
+     * Plural forms (function)
71
+     */
72
+    private $pluralFormFunction = null;
73
+
74
+    /**
75
+     * The constructor
76
+     * @param string $app app requesting l10n
77
+     * @param string $lang default: null Language
78
+     *
79
+     * If language is not set, the constructor tries to find the right
80
+     * language.
81
+     * @deprecated 9.0.0 Use \OC::$server->getL10NFactory()->get() instead
82
+     */
83
+    public function __construct($app, $lang = null) {
84
+        $app = \OC_App::cleanAppId($app);
85
+        $this->app = $app;
86
+
87
+        if ($lang !== null) {
88
+            $lang = str_replace(array('\0', '/', '\\', '..'), '', $lang);
89
+        }
90
+
91
+        // Find the right language
92
+        if ($app !== 'test' && !\OC::$server->getL10NFactory()->languageExists($app, $lang)) {
93
+            $lang = \OC::$server->getL10NFactory()->findLanguage($app);
94
+        }
95
+
96
+        $this->lang = $lang;
97
+    }
98
+
99
+    /**
100
+     * @param $transFile
101
+     * @return bool
102
+     */
103
+    public function load($transFile) {
104
+        $this->app = true;
105
+
106
+        $json = json_decode(file_get_contents($transFile), true);
107
+        if (!is_array($json)) {
108
+            $jsonError = json_last_error();
109
+            \OC::$server->getLogger()->warning("Failed to load $transFile - json error code: $jsonError", ['app' => 'l10n']);
110
+            return false;
111
+        }
112
+
113
+        $this->pluralFormString = $json['pluralForm'];
114
+        $translations = $json['translations'];
115
+
116
+        $this->translations = array_merge($this->translations, $translations);
117
+
118
+        return true;
119
+    }
120
+
121
+    protected function init() {
122
+        if ($this->app === true) {
123
+            return;
124
+        }
125
+        $app = $this->app;
126
+        $lang = $this->lang;
127
+        $this->app = true;
128
+
129
+        /** @var \OC\L10N\Factory $factory */
130
+        $factory = \OC::$server->getL10NFactory();
131
+        $languageFiles = $factory->getL10nFilesForApp($app, $lang);
132
+
133
+        $this->translations = [];
134
+        foreach ($languageFiles as $languageFile) {
135
+            $this->load($languageFile);
136
+        }
137
+    }
138
+
139
+    /**
140
+     * Translating
141
+     * @param string $text The text we need a translation for
142
+     * @param array $parameters default:array() Parameters for sprintf
143
+     * @return \OC_L10N_String Translation or the same text
144
+     *
145
+     * Returns the translation. If no translation is found, $text will be
146
+     * returned.
147
+     */
148
+    public function t($text, $parameters = array()) {
149
+        return new OC_L10N_String($this, $text, $parameters);
150
+    }
151
+
152
+    /**
153
+     * Translating
154
+     * @param string $text_singular the string to translate for exactly one object
155
+     * @param string $text_plural the string to translate for n objects
156
+     * @param integer $count Number of objects
157
+     * @param array $parameters default:array() Parameters for sprintf
158
+     * @return \OC_L10N_String Translation or the same text
159
+     *
160
+     * Returns the translation. If no translation is found, $text will be
161
+     * returned. %n will be replaced with the number of objects.
162
+     *
163
+     * The correct plural is determined by the plural_forms-function
164
+     * provided by the po file.
165
+     *
166
+     */
167
+    public function n($text_singular, $text_plural, $count, $parameters = array()) {
168
+        $this->init();
169
+        $identifier = "_${text_singular}_::_${text_plural}_";
170
+        if( array_key_exists($identifier, $this->translations)) {
171
+            return new OC_L10N_String( $this, $identifier, $parameters, $count );
172
+        }else{
173
+            if($count === 1) {
174
+                return new OC_L10N_String($this, $text_singular, $parameters, $count);
175
+            }else{
176
+                return new OC_L10N_String($this, $text_plural, $parameters, $count);
177
+            }
178
+        }
179
+    }
180
+
181
+    /**
182
+     * getTranslations
183
+     * @return array Fetch all translations
184
+     *
185
+     * Returns an associative array with all translations
186
+     */
187
+    public function getTranslations() {
188
+        $this->init();
189
+        return $this->translations;
190
+    }
191
+
192
+    /**
193
+     * getPluralFormFunction
194
+     * @return string the plural form function
195
+     *
196
+     * returned function accepts the argument $n
197
+     */
198
+    public function getPluralFormFunction() {
199
+        $this->init();
200
+        if (is_null($this->pluralFormFunction)) {
201
+            $this->pluralFormFunction = \OC::$server->getL10NFactory()->createPluralFunction($this->pluralFormString);
202
+        }
203
+        return $this->pluralFormFunction;
204
+    }
205
+
206
+    /**
207
+     * Localization
208
+     * @param string $type Type of localization
209
+     * @param array|int|string $data parameters for this localization
210
+     * @param array $options
211
+     * @return string|false
212
+     *
213
+     * Returns the localized data.
214
+     *
215
+     * Implemented types:
216
+     *  - date
217
+     *    - Creates a date
218
+     *    - params: timestamp (int/string)
219
+     *  - datetime
220
+     *    - Creates date and time
221
+     *    - params: timestamp (int/string)
222
+     *  - time
223
+     *    - Creates a time
224
+     *    - params: timestamp (int/string)
225
+     *  - firstday: Returns the first day of the week (0 sunday - 6 saturday)
226
+     *  - jsdate: Returns the short JS date format
227
+     */
228
+    public function l($type, $data, $options = array()) {
229
+        if ($type === 'firstday') {
230
+            return $this->getFirstWeekDay();
231
+        }
232
+        if ($type === 'jsdate') {
233
+            return $this->getDateFormat();
234
+        }
235
+
236
+        $this->init();
237
+        $value = new DateTime();
238
+        if($data instanceof DateTime) {
239
+            $value = $data;
240
+        } elseif(is_string($data) && !is_numeric($data)) {
241
+            $data = strtotime($data);
242
+            $value->setTimestamp($data);
243
+        } else {
244
+            $value->setTimestamp($data);
245
+        }
246
+
247
+        // Use the language of the instance
248
+        $locale = $this->transformToCLDRLocale($this->getLanguageCode());
249
+
250
+        $options = array_merge(array('width' => 'long'), $options);
251
+        $width = $options['width'];
252
+        switch($type) {
253
+            case 'date':
254
+                return Punic\Calendar::formatDate($value, $width, $locale);
255
+            case 'datetime':
256
+                return Punic\Calendar::formatDatetime($value, $width, $locale);
257
+            case 'time':
258
+                return Punic\Calendar::formatTime($value, $width, $locale);
259
+            default:
260
+                return false;
261
+        }
262
+    }
263
+
264
+    /**
265
+     * The code (en, de, ...) of the language that is used for this OC_L10N object
266
+     *
267
+     * @return string language
268
+     */
269
+    public function getLanguageCode() {
270
+        return $this->lang;
271
+    }
272
+
273
+    /**
274
+     * @return string
275
+     * @throws \Punic\Exception\ValueNotInList
276
+     * @deprecated 9.0.0 Use $this->l('jsdate', null) instead
277
+     */
278
+    public function getDateFormat() {
279
+        $locale = $this->transformToCLDRLocale($this->getLanguageCode());
280
+        return Punic\Calendar::getDateFormat('short', $locale);
281
+    }
282
+
283
+    /**
284
+     * @return int
285
+     * @deprecated 9.0.0 Use $this->l('firstday', null) instead
286
+     */
287
+    public function getFirstWeekDay() {
288
+        $locale = $this->transformToCLDRLocale($this->getLanguageCode());
289
+        return Punic\Calendar::getFirstWeekday($locale);
290
+    }
291
+
292
+    /**
293
+     * @param string $locale
294
+     * @return string
295
+     */
296
+    private function transformToCLDRLocale($locale) {
297
+        if ($locale === 'sr@latin') {
298
+            return 'sr_latn';
299
+        }
300
+
301
+        return $locale;
302
+    }
303
+
304
+    /**
305
+     * find the best language
306
+     * @param string $app
307
+     * @return string language
308
+     *
309
+     * If nothing works it returns 'en'
310
+     * @deprecated 9.0.0 Use \OC::$server->getL10NFactory()->findLanguage() instead
311
+     */
312
+    public static function findLanguage($app = null) {
313
+        return \OC::$server->getL10NFactory()->findLanguage($app);
314
+    }
315
+
316
+    /**
317
+     * @return string
318
+     * @deprecated 9.0.0 Use \OC::$server->getL10NFactory()->setLanguageFromRequest() instead
319
+     */
320
+    public static function setLanguageFromRequest() {
321
+        return \OC::$server->getL10NFactory()->setLanguageFromRequest();
322
+    }
323
+
324
+    /**
325
+     * find all available languages for an app
326
+     * @param string $app App that needs to be translated
327
+     * @return array an array of available languages
328
+     * @deprecated 9.0.0 Use \OC::$server->getL10NFactory()->findAvailableLanguages() instead
329
+     */
330
+    public static function findAvailableLanguages($app=null) {
331
+        return \OC::$server->getL10NFactory()->findAvailableLanguages($app);
332
+    }
333
+
334
+    /**
335
+     * @param string $app
336
+     * @param string $lang
337
+     * @return bool
338
+     * @deprecated 9.0.0 Use \OC::$server->getL10NFactory()->languageExists() instead
339
+     */
340
+    public static function languageExists($app, $lang) {
341
+        return \OC::$server->getL10NFactory()->languageExists($app, $lang);
342
+    }
343 343
 }
Please login to merge, or discard this patch.
settings/templates/email.new_user.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@
 block discarded – undo
12 12
 					<td width="20px">&nbsp;</td>
13 13
 					<td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">
14 14
 						<?php
15
-						print_unescaped($l->t('Hey there,<br><br>just letting you know that you now have an %s account.<br><br>Your username: %s<br>Access it: <a href="%s">%s</a><br><br>', array($theme->getName(), $_['username'], $_['url'], $_['url'])));
15
+                        print_unescaped($l->t('Hey there,<br><br>just letting you know that you now have an %s account.<br><br>Your username: %s<br>Access it: <a href="%s">%s</a><br><br>', array($theme->getName(), $_['username'], $_['url'], $_['url'])));
16 16
 
17
-						// TRANSLATORS term at the end of a mail
18
-						p($l->t('Cheers!'));
19
-						?>
17
+                        // TRANSLATORS term at the end of a mail
18
+                        p($l->t('Cheers!'));
19
+                        ?>
20 20
 					</td>
21 21
 				</tr>
22 22
 				<tr><td colspan="2">&nbsp;</td></tr>
Please login to merge, or discard this patch.
settings/templates/apps.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,24 +1,24 @@
 block discarded – undo
1 1
 <?php
2 2
 style('settings', 'settings');
3 3
 vendor_style(
4
-	'core',
5
-	[
6
-		'select2/select2',
7
-	]
4
+    'core',
5
+    [
6
+        'select2/select2',
7
+    ]
8 8
 );
9 9
 vendor_script(
10
-	'core',
11
-	[
12
-		'handlebars/handlebars',
13
-		'select2/select2'
14
-	]
10
+    'core',
11
+    [
12
+        'handlebars/handlebars',
13
+        'select2/select2'
14
+    ]
15 15
 );
16 16
 script(
17
-	'settings',
18
-	[
19
-		'settings',
20
-		'apps',
21
-	]
17
+    'settings',
18
+    [
19
+        'settings',
20
+        'apps',
21
+    ]
22 22
 );
23 23
 /** @var array $_ */
24 24
 ?>
Please login to merge, or discard this patch.
settings/templates/personal.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 <div id="app-navigation">
12 12
 	<ul>
13 13
 	<?php foreach($_['forms'] as $form) {
14
-		if (isset($form['anchor'])) {
15
-			$anchor = '#' . $form['anchor'];
16
-			$sectionName = $form['section-name'];
17
-			print_unescaped(sprintf("<li><a href='%s'>%s</a></li>", \OCP\Util::sanitizeHTML($anchor), \OCP\Util::sanitizeHTML($sectionName)));
18
-		}
19
-	}?>
14
+        if (isset($form['anchor'])) {
15
+            $anchor = '#' . $form['anchor'];
16
+            $sectionName = $form['section-name'];
17
+            print_unescaped(sprintf("<li><a href='%s'>%s</a></li>", \OCP\Util::sanitizeHTML($anchor), \OCP\Util::sanitizeHTML($sectionName)));
18
+        }
19
+    }?>
20 20
 	</ul>
21 21
 </div>
22 22
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 		<?php if($_['usage_relative'] > 80): ?> class="quota-warning" <?php endif; ?>>
28 28
 		<p id="quotatext">
29 29
 			<?php print_unescaped($l->t('You are using <strong>%s</strong> of <strong>%s</strong>',
30
-			array($_['usage'], $_['total_space'])));?>
30
+            array($_['usage'], $_['total_space'])));?>
31 31
 		</p>
32 32
 	</div>
33 33
 </div>
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 
115 115
 <?php
116 116
 if($_['passwordChangeSupported']) {
117
-	script('jquery-showpassword');
117
+    script('jquery-showpassword');
118 118
 ?>
119 119
 <form id="passwordform" class="section">
120 120
 	<h2 class="inlineblock"><?php p($l->t('Password'));?></h2>
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 </div>
251 251
 
252 252
 <?php foreach($_['forms'] as $form) {
253
-	if (isset($form['form'])) {?>
253
+    if (isset($form['form'])) {?>
254 254
 	<div id="<?php isset($form['anchor']) ? p($form['anchor']) : p('');?>"><?php print_unescaped($form['form']);?></div>
255 255
 	<?php }
256 256
 };?>
Please login to merge, or discard this patch.
settings/ajax/setlanguage.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -33,14 +33,14 @@
 block discarded – undo
33 33
 
34 34
 // Get data
35 35
 if( isset( $_POST['lang'] ) ) {
36
-	$languageCodes = \OC::$server->getL10NFactory()->findAvailableLanguages();
37
-	$lang = (string)$_POST['lang'];
38
-	if(array_search($lang, $languageCodes) or $lang === 'en') {
39
-		\OC::$server->getConfig()->setUserValue( OC_User::getUser(), 'core', 'lang', $lang );
40
-		OC_JSON::success(array("data" => array( "message" => $l->t("Language changed") )));
41
-	}else{
42
-		OC_JSON::error(array("data" => array( "message" => $l->t("Invalid request") )));
43
-	}
36
+    $languageCodes = \OC::$server->getL10NFactory()->findAvailableLanguages();
37
+    $lang = (string)$_POST['lang'];
38
+    if(array_search($lang, $languageCodes) or $lang === 'en') {
39
+        \OC::$server->getConfig()->setUserValue( OC_User::getUser(), 'core', 'lang', $lang );
40
+        OC_JSON::success(array("data" => array( "message" => $l->t("Language changed") )));
41
+    }else{
42
+        OC_JSON::error(array("data" => array( "message" => $l->t("Invalid request") )));
43
+    }
44 44
 }else{
45
-	OC_JSON::error(array("data" => array( "message" => $l->t("Invalid request") )));
45
+    OC_JSON::error(array("data" => array( "message" => $l->t("Invalid request") )));
46 46
 }
Please login to merge, or discard this patch.