@@ -26,31 +26,31 @@ |
||
26 | 26 | namespace OC\Log; |
27 | 27 | |
28 | 28 | class Syslog { |
29 | - static protected $levels = array( |
|
30 | - \OCP\Util::DEBUG => LOG_DEBUG, |
|
31 | - \OCP\Util::INFO => LOG_INFO, |
|
32 | - \OCP\Util::WARN => LOG_WARNING, |
|
33 | - \OCP\Util::ERROR => LOG_ERR, |
|
34 | - \OCP\Util::FATAL => LOG_CRIT, |
|
35 | - ); |
|
29 | + static protected $levels = array( |
|
30 | + \OCP\Util::DEBUG => LOG_DEBUG, |
|
31 | + \OCP\Util::INFO => LOG_INFO, |
|
32 | + \OCP\Util::WARN => LOG_WARNING, |
|
33 | + \OCP\Util::ERROR => LOG_ERR, |
|
34 | + \OCP\Util::FATAL => LOG_CRIT, |
|
35 | + ); |
|
36 | 36 | |
37 | - /** |
|
38 | - * Init class data |
|
39 | - */ |
|
40 | - public static function init() { |
|
41 | - openlog(\OC::$server->getSystemConfig()->getValue("syslog_tag", "ownCloud"), LOG_PID | LOG_CONS, LOG_USER); |
|
42 | - // Close at shutdown |
|
43 | - register_shutdown_function('closelog'); |
|
44 | - } |
|
37 | + /** |
|
38 | + * Init class data |
|
39 | + */ |
|
40 | + public static function init() { |
|
41 | + openlog(\OC::$server->getSystemConfig()->getValue("syslog_tag", "ownCloud"), LOG_PID | LOG_CONS, LOG_USER); |
|
42 | + // Close at shutdown |
|
43 | + register_shutdown_function('closelog'); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * write a message in the log |
|
48 | - * @param string $app |
|
49 | - * @param string $message |
|
50 | - * @param int $level |
|
51 | - */ |
|
52 | - public static function write($app, $message, $level) { |
|
53 | - $syslog_level = self::$levels[$level]; |
|
54 | - syslog($syslog_level, '{'.$app.'} '.$message); |
|
55 | - } |
|
46 | + /** |
|
47 | + * write a message in the log |
|
48 | + * @param string $app |
|
49 | + * @param string $message |
|
50 | + * @param int $level |
|
51 | + */ |
|
52 | + public static function write($app, $message, $level) { |
|
53 | + $syslog_level = self::$levels[$level]; |
|
54 | + syslog($syslog_level, '{'.$app.'} '.$message); |
|
55 | + } |
|
56 | 56 | } |
@@ -28,74 +28,74 @@ |
||
28 | 28 | use OCP\ILogger; |
29 | 29 | |
30 | 30 | class ErrorHandler { |
31 | - /** @var ILogger */ |
|
32 | - private static $logger; |
|
31 | + /** @var ILogger */ |
|
32 | + private static $logger; |
|
33 | 33 | |
34 | - /** |
|
35 | - * remove password in URLs |
|
36 | - * @param string $msg |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - protected static function removePassword($msg) { |
|
40 | - return preg_replace('/\/\/(.*):(.*)@/', '//xxx:xxx@', $msg); |
|
41 | - } |
|
34 | + /** |
|
35 | + * remove password in URLs |
|
36 | + * @param string $msg |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + protected static function removePassword($msg) { |
|
40 | + return preg_replace('/\/\/(.*):(.*)@/', '//xxx:xxx@', $msg); |
|
41 | + } |
|
42 | 42 | |
43 | - public static function register($debug=false) { |
|
44 | - $handler = new ErrorHandler(); |
|
43 | + public static function register($debug=false) { |
|
44 | + $handler = new ErrorHandler(); |
|
45 | 45 | |
46 | - if ($debug) { |
|
47 | - set_error_handler(array($handler, 'onAll'), E_ALL); |
|
48 | - if (\OC::$CLI) { |
|
49 | - set_exception_handler(array('OC_Template', 'printExceptionErrorPage')); |
|
50 | - } |
|
51 | - } else { |
|
52 | - set_error_handler(array($handler, 'onError')); |
|
53 | - } |
|
54 | - register_shutdown_function(array($handler, 'onShutdown')); |
|
55 | - set_exception_handler(array($handler, 'onException')); |
|
56 | - } |
|
46 | + if ($debug) { |
|
47 | + set_error_handler(array($handler, 'onAll'), E_ALL); |
|
48 | + if (\OC::$CLI) { |
|
49 | + set_exception_handler(array('OC_Template', 'printExceptionErrorPage')); |
|
50 | + } |
|
51 | + } else { |
|
52 | + set_error_handler(array($handler, 'onError')); |
|
53 | + } |
|
54 | + register_shutdown_function(array($handler, 'onShutdown')); |
|
55 | + set_exception_handler(array($handler, 'onException')); |
|
56 | + } |
|
57 | 57 | |
58 | - public static function setLogger(ILogger $logger) { |
|
59 | - self::$logger = $logger; |
|
60 | - } |
|
58 | + public static function setLogger(ILogger $logger) { |
|
59 | + self::$logger = $logger; |
|
60 | + } |
|
61 | 61 | |
62 | - //Fatal errors handler |
|
63 | - public static function onShutdown() { |
|
64 | - $error = error_get_last(); |
|
65 | - if($error && self::$logger) { |
|
66 | - //ob_end_clean(); |
|
67 | - $msg = $error['message'] . ' at ' . $error['file'] . '#' . $error['line']; |
|
68 | - self::$logger->critical(self::removePassword($msg), array('app' => 'PHP')); |
|
69 | - } |
|
70 | - } |
|
62 | + //Fatal errors handler |
|
63 | + public static function onShutdown() { |
|
64 | + $error = error_get_last(); |
|
65 | + if($error && self::$logger) { |
|
66 | + //ob_end_clean(); |
|
67 | + $msg = $error['message'] . ' at ' . $error['file'] . '#' . $error['line']; |
|
68 | + self::$logger->critical(self::removePassword($msg), array('app' => 'PHP')); |
|
69 | + } |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Uncaught exception handler |
|
74 | - * |
|
75 | - * @param \Exception $exception |
|
76 | - */ |
|
77 | - public static function onException($exception) { |
|
78 | - $class = get_class($exception); |
|
79 | - $msg = $exception->getMessage(); |
|
80 | - $msg = "$class: $msg at " . $exception->getFile() . '#' . $exception->getLine(); |
|
81 | - self::$logger->critical(self::removePassword($msg), ['app' => 'PHP']); |
|
82 | - } |
|
72 | + /** |
|
73 | + * Uncaught exception handler |
|
74 | + * |
|
75 | + * @param \Exception $exception |
|
76 | + */ |
|
77 | + public static function onException($exception) { |
|
78 | + $class = get_class($exception); |
|
79 | + $msg = $exception->getMessage(); |
|
80 | + $msg = "$class: $msg at " . $exception->getFile() . '#' . $exception->getLine(); |
|
81 | + self::$logger->critical(self::removePassword($msg), ['app' => 'PHP']); |
|
82 | + } |
|
83 | 83 | |
84 | - //Recoverable errors handler |
|
85 | - public static function onError($number, $message, $file, $line) { |
|
86 | - if (error_reporting() === 0) { |
|
87 | - return; |
|
88 | - } |
|
89 | - $msg = $message . ' at ' . $file . '#' . $line; |
|
90 | - self::$logger->error(self::removePassword($msg), array('app' => 'PHP')); |
|
84 | + //Recoverable errors handler |
|
85 | + public static function onError($number, $message, $file, $line) { |
|
86 | + if (error_reporting() === 0) { |
|
87 | + return; |
|
88 | + } |
|
89 | + $msg = $message . ' at ' . $file . '#' . $line; |
|
90 | + self::$logger->error(self::removePassword($msg), array('app' => 'PHP')); |
|
91 | 91 | |
92 | - } |
|
92 | + } |
|
93 | 93 | |
94 | - //Recoverable handler which catch all errors, warnings and notices |
|
95 | - public static function onAll($number, $message, $file, $line) { |
|
96 | - $msg = $message . ' at ' . $file . '#' . $line; |
|
97 | - self::$logger->debug(self::removePassword($msg), array('app' => 'PHP')); |
|
94 | + //Recoverable handler which catch all errors, warnings and notices |
|
95 | + public static function onAll($number, $message, $file, $line) { |
|
96 | + $msg = $message . ' at ' . $file . '#' . $line; |
|
97 | + self::$logger->debug(self::removePassword($msg), array('app' => 'PHP')); |
|
98 | 98 | |
99 | - } |
|
99 | + } |
|
100 | 100 | |
101 | 101 | } |
@@ -34,97 +34,97 @@ |
||
34 | 34 | */ |
35 | 35 | class Search implements ISearch { |
36 | 36 | |
37 | - private $providers = array(); |
|
38 | - private $registeredProviders = array(); |
|
37 | + private $providers = array(); |
|
38 | + private $registeredProviders = array(); |
|
39 | 39 | |
40 | - /** |
|
41 | - * Search all providers for $query |
|
42 | - * @param string $query |
|
43 | - * @param string[] $inApps optionally limit results to the given apps |
|
44 | - * @return array An array of OC\Search\Result's |
|
45 | - */ |
|
46 | - public function search($query, array $inApps = array()) { |
|
47 | - // old apps might assume they get all results, so we set size 0 |
|
48 | - return $this->searchPaged($query, $inApps, 1, 0); |
|
49 | - } |
|
40 | + /** |
|
41 | + * Search all providers for $query |
|
42 | + * @param string $query |
|
43 | + * @param string[] $inApps optionally limit results to the given apps |
|
44 | + * @return array An array of OC\Search\Result's |
|
45 | + */ |
|
46 | + public function search($query, array $inApps = array()) { |
|
47 | + // old apps might assume they get all results, so we set size 0 |
|
48 | + return $this->searchPaged($query, $inApps, 1, 0); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Search all providers for $query |
|
53 | - * @param string $query |
|
54 | - * @param string[] $inApps optionally limit results to the given apps |
|
55 | - * @param int $page pages start at page 1 |
|
56 | - * @param int $size, 0 = all |
|
57 | - * @return array An array of OC\Search\Result's |
|
58 | - */ |
|
59 | - public function searchPaged($query, array $inApps = array(), $page = 1, $size = 30) { |
|
60 | - $this->initProviders(); |
|
61 | - $results = array(); |
|
62 | - foreach($this->providers as $provider) { |
|
63 | - /** @var $provider Provider */ |
|
64 | - if ( ! $provider->providesResultsFor($inApps) ) { |
|
65 | - continue; |
|
66 | - } |
|
67 | - if ($provider instanceof PagedProvider) { |
|
68 | - $results = array_merge($results, $provider->searchPaged($query, $page, $size)); |
|
69 | - } else if ($provider instanceof Provider) { |
|
70 | - $providerResults = $provider->search($query); |
|
71 | - if ($size > 0) { |
|
72 | - $slicedResults = array_slice($providerResults, ($page - 1) * $size, $size); |
|
73 | - $results = array_merge($results, $slicedResults); |
|
74 | - } else { |
|
75 | - $results = array_merge($results, $providerResults); |
|
76 | - } |
|
77 | - } else { |
|
78 | - \OC::$server->getLogger()->warning('Ignoring Unknown search provider', array('provider' => $provider)); |
|
79 | - } |
|
80 | - } |
|
81 | - return $results; |
|
82 | - } |
|
51 | + /** |
|
52 | + * Search all providers for $query |
|
53 | + * @param string $query |
|
54 | + * @param string[] $inApps optionally limit results to the given apps |
|
55 | + * @param int $page pages start at page 1 |
|
56 | + * @param int $size, 0 = all |
|
57 | + * @return array An array of OC\Search\Result's |
|
58 | + */ |
|
59 | + public function searchPaged($query, array $inApps = array(), $page = 1, $size = 30) { |
|
60 | + $this->initProviders(); |
|
61 | + $results = array(); |
|
62 | + foreach($this->providers as $provider) { |
|
63 | + /** @var $provider Provider */ |
|
64 | + if ( ! $provider->providesResultsFor($inApps) ) { |
|
65 | + continue; |
|
66 | + } |
|
67 | + if ($provider instanceof PagedProvider) { |
|
68 | + $results = array_merge($results, $provider->searchPaged($query, $page, $size)); |
|
69 | + } else if ($provider instanceof Provider) { |
|
70 | + $providerResults = $provider->search($query); |
|
71 | + if ($size > 0) { |
|
72 | + $slicedResults = array_slice($providerResults, ($page - 1) * $size, $size); |
|
73 | + $results = array_merge($results, $slicedResults); |
|
74 | + } else { |
|
75 | + $results = array_merge($results, $providerResults); |
|
76 | + } |
|
77 | + } else { |
|
78 | + \OC::$server->getLogger()->warning('Ignoring Unknown search provider', array('provider' => $provider)); |
|
79 | + } |
|
80 | + } |
|
81 | + return $results; |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * Remove all registered search providers |
|
86 | - */ |
|
87 | - public function clearProviders() { |
|
88 | - $this->providers = array(); |
|
89 | - $this->registeredProviders = array(); |
|
90 | - } |
|
84 | + /** |
|
85 | + * Remove all registered search providers |
|
86 | + */ |
|
87 | + public function clearProviders() { |
|
88 | + $this->providers = array(); |
|
89 | + $this->registeredProviders = array(); |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Remove one existing search provider |
|
94 | - * @param string $provider class name of a OC\Search\Provider |
|
95 | - */ |
|
96 | - public function removeProvider($provider) { |
|
97 | - $this->registeredProviders = array_filter( |
|
98 | - $this->registeredProviders, |
|
99 | - function ($element) use ($provider) { |
|
100 | - return ($element['class'] != $provider); |
|
101 | - } |
|
102 | - ); |
|
103 | - // force regeneration of providers on next search |
|
104 | - $this->providers = array(); |
|
105 | - } |
|
92 | + /** |
|
93 | + * Remove one existing search provider |
|
94 | + * @param string $provider class name of a OC\Search\Provider |
|
95 | + */ |
|
96 | + public function removeProvider($provider) { |
|
97 | + $this->registeredProviders = array_filter( |
|
98 | + $this->registeredProviders, |
|
99 | + function ($element) use ($provider) { |
|
100 | + return ($element['class'] != $provider); |
|
101 | + } |
|
102 | + ); |
|
103 | + // force regeneration of providers on next search |
|
104 | + $this->providers = array(); |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * Register a new search provider to search with |
|
109 | - * @param string $class class name of a OC\Search\Provider |
|
110 | - * @param array $options optional |
|
111 | - */ |
|
112 | - public function registerProvider($class, array $options = array()) { |
|
113 | - $this->registeredProviders[] = array('class' => $class, 'options' => $options); |
|
114 | - } |
|
107 | + /** |
|
108 | + * Register a new search provider to search with |
|
109 | + * @param string $class class name of a OC\Search\Provider |
|
110 | + * @param array $options optional |
|
111 | + */ |
|
112 | + public function registerProvider($class, array $options = array()) { |
|
113 | + $this->registeredProviders[] = array('class' => $class, 'options' => $options); |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * Create instances of all the registered search providers |
|
118 | - */ |
|
119 | - private function initProviders() { |
|
120 | - if( ! empty($this->providers) ) { |
|
121 | - return; |
|
122 | - } |
|
123 | - foreach($this->registeredProviders as $provider) { |
|
124 | - $class = $provider['class']; |
|
125 | - $options = $provider['options']; |
|
126 | - $this->providers[] = new $class($options); |
|
127 | - } |
|
128 | - } |
|
116 | + /** |
|
117 | + * Create instances of all the registered search providers |
|
118 | + */ |
|
119 | + private function initProviders() { |
|
120 | + if( ! empty($this->providers) ) { |
|
121 | + return; |
|
122 | + } |
|
123 | + foreach($this->registeredProviders as $provider) { |
|
124 | + $class = $provider['class']; |
|
125 | + $options = $provider['options']; |
|
126 | + $this->providers[] = new $class($options); |
|
127 | + } |
|
128 | + } |
|
129 | 129 | |
130 | 130 | } |
@@ -28,190 +28,190 @@ |
||
28 | 28 | |
29 | 29 | class L10N implements IL10N { |
30 | 30 | |
31 | - /** @var IFactory */ |
|
32 | - protected $factory; |
|
33 | - |
|
34 | - /** @var string App of this object */ |
|
35 | - protected $app; |
|
36 | - |
|
37 | - /** @var string Language of this object */ |
|
38 | - protected $lang; |
|
39 | - |
|
40 | - /** @var string Plural forms (string) */ |
|
41 | - private $pluralFormString = 'nplurals=2; plural=(n != 1);'; |
|
42 | - |
|
43 | - /** @var string Plural forms (function) */ |
|
44 | - private $pluralFormFunction = null; |
|
45 | - |
|
46 | - /** @var string[] */ |
|
47 | - private $translations = []; |
|
48 | - |
|
49 | - /** |
|
50 | - * @param IFactory $factory |
|
51 | - * @param string $app |
|
52 | - * @param string $lang |
|
53 | - * @param array $files |
|
54 | - */ |
|
55 | - public function __construct(IFactory $factory, $app, $lang, array $files) { |
|
56 | - $this->factory = $factory; |
|
57 | - $this->app = $app; |
|
58 | - $this->lang = $lang; |
|
59 | - |
|
60 | - $this->translations = []; |
|
61 | - foreach ($files as $languageFile) { |
|
62 | - $this->load($languageFile); |
|
63 | - } |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * The code (en, de, ...) of the language that is used for this instance |
|
68 | - * |
|
69 | - * @return string language |
|
70 | - */ |
|
71 | - public function getLanguageCode() { |
|
72 | - return $this->lang; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Translating |
|
77 | - * @param string $text The text we need a translation for |
|
78 | - * @param array $parameters default:array() Parameters for sprintf |
|
79 | - * @return string Translation or the same text |
|
80 | - * |
|
81 | - * Returns the translation. If no translation is found, $text will be |
|
82 | - * returned. |
|
83 | - */ |
|
84 | - public function t($text, $parameters = array()) { |
|
85 | - return (string) new \OC_L10N_String($this, $text, $parameters); |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Translating |
|
90 | - * @param string $text_singular the string to translate for exactly one object |
|
91 | - * @param string $text_plural the string to translate for n objects |
|
92 | - * @param integer $count Number of objects |
|
93 | - * @param array $parameters default:array() Parameters for sprintf |
|
94 | - * @return string Translation or the same text |
|
95 | - * |
|
96 | - * Returns the translation. If no translation is found, $text will be |
|
97 | - * returned. %n will be replaced with the number of objects. |
|
98 | - * |
|
99 | - * The correct plural is determined by the plural_forms-function |
|
100 | - * provided by the po file. |
|
101 | - * |
|
102 | - */ |
|
103 | - public function n($text_singular, $text_plural, $count, $parameters = array()) { |
|
104 | - $identifier = "_${text_singular}_::_${text_plural}_"; |
|
105 | - if (isset($this->translations[$identifier])) { |
|
106 | - return (string) new \OC_L10N_String($this, $identifier, $parameters, $count); |
|
107 | - } else { |
|
108 | - if ($count === 1) { |
|
109 | - return (string) new \OC_L10N_String($this, $text_singular, $parameters, $count); |
|
110 | - } else { |
|
111 | - return (string) new \OC_L10N_String($this, $text_plural, $parameters, $count); |
|
112 | - } |
|
113 | - } |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Localization |
|
118 | - * @param string $type Type of localization |
|
119 | - * @param \DateTime|int|string $data parameters for this localization |
|
120 | - * @param array $options |
|
121 | - * @return string|int|false |
|
122 | - * |
|
123 | - * Returns the localized data. |
|
124 | - * |
|
125 | - * Implemented types: |
|
126 | - * - date |
|
127 | - * - Creates a date |
|
128 | - * - params: timestamp (int/string) |
|
129 | - * - datetime |
|
130 | - * - Creates date and time |
|
131 | - * - params: timestamp (int/string) |
|
132 | - * - time |
|
133 | - * - Creates a time |
|
134 | - * - params: timestamp (int/string) |
|
135 | - * - firstday: Returns the first day of the week (0 sunday - 6 saturday) |
|
136 | - * - jsdate: Returns the short JS date format |
|
137 | - */ |
|
138 | - public function l($type, $data = null, $options = array()) { |
|
139 | - // Use the language of the instance |
|
140 | - $locale = $this->getLanguageCode(); |
|
141 | - if ($locale === 'sr@latin') { |
|
142 | - $locale = 'sr_latn'; |
|
143 | - } |
|
144 | - |
|
145 | - if ($type === 'firstday') { |
|
146 | - return (int) Calendar::getFirstWeekday($locale); |
|
147 | - } |
|
148 | - if ($type === 'jsdate') { |
|
149 | - return (string) Calendar::getDateFormat('short', $locale); |
|
150 | - } |
|
151 | - |
|
152 | - $value = new \DateTime(); |
|
153 | - if ($data instanceof \DateTime) { |
|
154 | - $value = $data; |
|
155 | - } else if (is_string($data) && !is_numeric($data)) { |
|
156 | - $data = strtotime($data); |
|
157 | - $value->setTimestamp($data); |
|
158 | - } else if ($data !== null) { |
|
159 | - $value->setTimestamp($data); |
|
160 | - } |
|
161 | - |
|
162 | - $options = array_merge(array('width' => 'long'), $options); |
|
163 | - $width = $options['width']; |
|
164 | - switch ($type) { |
|
165 | - case 'date': |
|
166 | - return (string) Calendar::formatDate($value, $width, $locale); |
|
167 | - case 'datetime': |
|
168 | - return (string) Calendar::formatDatetime($value, $width, $locale); |
|
169 | - case 'time': |
|
170 | - return (string) Calendar::formatTime($value, $width, $locale); |
|
171 | - default: |
|
172 | - return false; |
|
173 | - } |
|
174 | - } |
|
175 | - |
|
176 | - /** |
|
177 | - * Returns an associative array with all translations |
|
178 | - * |
|
179 | - * Called by \OC_L10N_String |
|
180 | - * @return array |
|
181 | - */ |
|
182 | - public function getTranslations() { |
|
183 | - return $this->translations; |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * Returnsed function accepts the argument $n |
|
188 | - * |
|
189 | - * Called by \OC_L10N_String |
|
190 | - * @return string the plural form function |
|
191 | - */ |
|
192 | - public function getPluralFormFunction() { |
|
193 | - if (is_null($this->pluralFormFunction)) { |
|
194 | - $this->pluralFormFunction = $this->factory->createPluralFunction($this->pluralFormString); |
|
195 | - } |
|
196 | - return $this->pluralFormFunction; |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * @param $translationFile |
|
201 | - * @return bool |
|
202 | - */ |
|
203 | - protected function load($translationFile) { |
|
204 | - $json = json_decode(file_get_contents($translationFile), true); |
|
205 | - if (!is_array($json)) { |
|
206 | - $jsonError = json_last_error(); |
|
207 | - \OC::$server->getLogger()->warning("Failed to load $translationFile - json error code: $jsonError", ['app' => 'l10n']); |
|
208 | - return false; |
|
209 | - } |
|
210 | - |
|
211 | - if (!empty($json['pluralForm'])) { |
|
212 | - $this->pluralFormString = $json['pluralForm']; |
|
213 | - } |
|
214 | - $this->translations = array_merge($this->translations, $json['translations']); |
|
215 | - return true; |
|
216 | - } |
|
31 | + /** @var IFactory */ |
|
32 | + protected $factory; |
|
33 | + |
|
34 | + /** @var string App of this object */ |
|
35 | + protected $app; |
|
36 | + |
|
37 | + /** @var string Language of this object */ |
|
38 | + protected $lang; |
|
39 | + |
|
40 | + /** @var string Plural forms (string) */ |
|
41 | + private $pluralFormString = 'nplurals=2; plural=(n != 1);'; |
|
42 | + |
|
43 | + /** @var string Plural forms (function) */ |
|
44 | + private $pluralFormFunction = null; |
|
45 | + |
|
46 | + /** @var string[] */ |
|
47 | + private $translations = []; |
|
48 | + |
|
49 | + /** |
|
50 | + * @param IFactory $factory |
|
51 | + * @param string $app |
|
52 | + * @param string $lang |
|
53 | + * @param array $files |
|
54 | + */ |
|
55 | + public function __construct(IFactory $factory, $app, $lang, array $files) { |
|
56 | + $this->factory = $factory; |
|
57 | + $this->app = $app; |
|
58 | + $this->lang = $lang; |
|
59 | + |
|
60 | + $this->translations = []; |
|
61 | + foreach ($files as $languageFile) { |
|
62 | + $this->load($languageFile); |
|
63 | + } |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * The code (en, de, ...) of the language that is used for this instance |
|
68 | + * |
|
69 | + * @return string language |
|
70 | + */ |
|
71 | + public function getLanguageCode() { |
|
72 | + return $this->lang; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Translating |
|
77 | + * @param string $text The text we need a translation for |
|
78 | + * @param array $parameters default:array() Parameters for sprintf |
|
79 | + * @return string Translation or the same text |
|
80 | + * |
|
81 | + * Returns the translation. If no translation is found, $text will be |
|
82 | + * returned. |
|
83 | + */ |
|
84 | + public function t($text, $parameters = array()) { |
|
85 | + return (string) new \OC_L10N_String($this, $text, $parameters); |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Translating |
|
90 | + * @param string $text_singular the string to translate for exactly one object |
|
91 | + * @param string $text_plural the string to translate for n objects |
|
92 | + * @param integer $count Number of objects |
|
93 | + * @param array $parameters default:array() Parameters for sprintf |
|
94 | + * @return string Translation or the same text |
|
95 | + * |
|
96 | + * Returns the translation. If no translation is found, $text will be |
|
97 | + * returned. %n will be replaced with the number of objects. |
|
98 | + * |
|
99 | + * The correct plural is determined by the plural_forms-function |
|
100 | + * provided by the po file. |
|
101 | + * |
|
102 | + */ |
|
103 | + public function n($text_singular, $text_plural, $count, $parameters = array()) { |
|
104 | + $identifier = "_${text_singular}_::_${text_plural}_"; |
|
105 | + if (isset($this->translations[$identifier])) { |
|
106 | + return (string) new \OC_L10N_String($this, $identifier, $parameters, $count); |
|
107 | + } else { |
|
108 | + if ($count === 1) { |
|
109 | + return (string) new \OC_L10N_String($this, $text_singular, $parameters, $count); |
|
110 | + } else { |
|
111 | + return (string) new \OC_L10N_String($this, $text_plural, $parameters, $count); |
|
112 | + } |
|
113 | + } |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * Localization |
|
118 | + * @param string $type Type of localization |
|
119 | + * @param \DateTime|int|string $data parameters for this localization |
|
120 | + * @param array $options |
|
121 | + * @return string|int|false |
|
122 | + * |
|
123 | + * Returns the localized data. |
|
124 | + * |
|
125 | + * Implemented types: |
|
126 | + * - date |
|
127 | + * - Creates a date |
|
128 | + * - params: timestamp (int/string) |
|
129 | + * - datetime |
|
130 | + * - Creates date and time |
|
131 | + * - params: timestamp (int/string) |
|
132 | + * - time |
|
133 | + * - Creates a time |
|
134 | + * - params: timestamp (int/string) |
|
135 | + * - firstday: Returns the first day of the week (0 sunday - 6 saturday) |
|
136 | + * - jsdate: Returns the short JS date format |
|
137 | + */ |
|
138 | + public function l($type, $data = null, $options = array()) { |
|
139 | + // Use the language of the instance |
|
140 | + $locale = $this->getLanguageCode(); |
|
141 | + if ($locale === 'sr@latin') { |
|
142 | + $locale = 'sr_latn'; |
|
143 | + } |
|
144 | + |
|
145 | + if ($type === 'firstday') { |
|
146 | + return (int) Calendar::getFirstWeekday($locale); |
|
147 | + } |
|
148 | + if ($type === 'jsdate') { |
|
149 | + return (string) Calendar::getDateFormat('short', $locale); |
|
150 | + } |
|
151 | + |
|
152 | + $value = new \DateTime(); |
|
153 | + if ($data instanceof \DateTime) { |
|
154 | + $value = $data; |
|
155 | + } else if (is_string($data) && !is_numeric($data)) { |
|
156 | + $data = strtotime($data); |
|
157 | + $value->setTimestamp($data); |
|
158 | + } else if ($data !== null) { |
|
159 | + $value->setTimestamp($data); |
|
160 | + } |
|
161 | + |
|
162 | + $options = array_merge(array('width' => 'long'), $options); |
|
163 | + $width = $options['width']; |
|
164 | + switch ($type) { |
|
165 | + case 'date': |
|
166 | + return (string) Calendar::formatDate($value, $width, $locale); |
|
167 | + case 'datetime': |
|
168 | + return (string) Calendar::formatDatetime($value, $width, $locale); |
|
169 | + case 'time': |
|
170 | + return (string) Calendar::formatTime($value, $width, $locale); |
|
171 | + default: |
|
172 | + return false; |
|
173 | + } |
|
174 | + } |
|
175 | + |
|
176 | + /** |
|
177 | + * Returns an associative array with all translations |
|
178 | + * |
|
179 | + * Called by \OC_L10N_String |
|
180 | + * @return array |
|
181 | + */ |
|
182 | + public function getTranslations() { |
|
183 | + return $this->translations; |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * Returnsed function accepts the argument $n |
|
188 | + * |
|
189 | + * Called by \OC_L10N_String |
|
190 | + * @return string the plural form function |
|
191 | + */ |
|
192 | + public function getPluralFormFunction() { |
|
193 | + if (is_null($this->pluralFormFunction)) { |
|
194 | + $this->pluralFormFunction = $this->factory->createPluralFunction($this->pluralFormString); |
|
195 | + } |
|
196 | + return $this->pluralFormFunction; |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * @param $translationFile |
|
201 | + * @return bool |
|
202 | + */ |
|
203 | + protected function load($translationFile) { |
|
204 | + $json = json_decode(file_get_contents($translationFile), true); |
|
205 | + if (!is_array($json)) { |
|
206 | + $jsonError = json_last_error(); |
|
207 | + \OC::$server->getLogger()->warning("Failed to load $translationFile - json error code: $jsonError", ['app' => 'l10n']); |
|
208 | + return false; |
|
209 | + } |
|
210 | + |
|
211 | + if (!empty($json['pluralForm'])) { |
|
212 | + $this->pluralFormString = $json['pluralForm']; |
|
213 | + } |
|
214 | + $this->translations = array_merge($this->translations, $json['translations']); |
|
215 | + return true; |
|
216 | + } |
|
217 | 217 | } |
@@ -32,51 +32,51 @@ |
||
32 | 32 | * @package OC\Http |
33 | 33 | */ |
34 | 34 | class Response implements IResponse { |
35 | - /** @var GuzzleResponse */ |
|
36 | - private $response; |
|
35 | + /** @var GuzzleResponse */ |
|
36 | + private $response; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @var bool |
|
40 | - */ |
|
41 | - private $stream; |
|
38 | + /** |
|
39 | + * @var bool |
|
40 | + */ |
|
41 | + private $stream; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param GuzzleResponse $response |
|
45 | - * @param bool $stream |
|
46 | - */ |
|
47 | - public function __construct(GuzzleResponse $response, $stream = false) { |
|
48 | - $this->response = $response; |
|
49 | - $this->stream = $stream; |
|
50 | - } |
|
43 | + /** |
|
44 | + * @param GuzzleResponse $response |
|
45 | + * @param bool $stream |
|
46 | + */ |
|
47 | + public function __construct(GuzzleResponse $response, $stream = false) { |
|
48 | + $this->response = $response; |
|
49 | + $this->stream = $stream; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return string|resource |
|
54 | - */ |
|
55 | - public function getBody() { |
|
56 | - return $this->stream ? |
|
57 | - $this->response->getBody()->detach(): |
|
58 | - $this->response->getBody()->getContents(); |
|
59 | - } |
|
52 | + /** |
|
53 | + * @return string|resource |
|
54 | + */ |
|
55 | + public function getBody() { |
|
56 | + return $this->stream ? |
|
57 | + $this->response->getBody()->detach(): |
|
58 | + $this->response->getBody()->getContents(); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @return int |
|
63 | - */ |
|
64 | - public function getStatusCode() { |
|
65 | - return $this->response->getStatusCode(); |
|
66 | - } |
|
61 | + /** |
|
62 | + * @return int |
|
63 | + */ |
|
64 | + public function getStatusCode() { |
|
65 | + return $this->response->getStatusCode(); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @param $key |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - public function getHeader($key) { |
|
73 | - return $this->response->getHeader($key); |
|
74 | - } |
|
68 | + /** |
|
69 | + * @param $key |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + public function getHeader($key) { |
|
73 | + return $this->response->getHeader($key); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @return array |
|
78 | - */ |
|
79 | - public function getHeaders() { |
|
80 | - return $this->response->getHeaders(); |
|
81 | - } |
|
76 | + /** |
|
77 | + * @return array |
|
78 | + */ |
|
79 | + public function getHeaders() { |
|
80 | + return $this->response->getHeaders(); |
|
81 | + } |
|
82 | 82 | } |
@@ -33,25 +33,25 @@ |
||
33 | 33 | * @package OC\Http |
34 | 34 | */ |
35 | 35 | class ClientService implements IClientService { |
36 | - /** @var IConfig */ |
|
37 | - private $config; |
|
38 | - /** @var ICertificateManager */ |
|
39 | - private $certificateManager; |
|
36 | + /** @var IConfig */ |
|
37 | + private $config; |
|
38 | + /** @var ICertificateManager */ |
|
39 | + private $certificateManager; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param IConfig $config |
|
43 | - * @param ICertificateManager $certificateManager |
|
44 | - */ |
|
45 | - public function __construct(IConfig $config, |
|
46 | - ICertificateManager $certificateManager) { |
|
47 | - $this->config = $config; |
|
48 | - $this->certificateManager = $certificateManager; |
|
49 | - } |
|
41 | + /** |
|
42 | + * @param IConfig $config |
|
43 | + * @param ICertificateManager $certificateManager |
|
44 | + */ |
|
45 | + public function __construct(IConfig $config, |
|
46 | + ICertificateManager $certificateManager) { |
|
47 | + $this->config = $config; |
|
48 | + $this->certificateManager = $certificateManager; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @return Client |
|
53 | - */ |
|
54 | - public function newClient() { |
|
55 | - return new Client($this->config, $this->certificateManager, new GuzzleClient()); |
|
56 | - } |
|
51 | + /** |
|
52 | + * @return Client |
|
53 | + */ |
|
54 | + public function newClient() { |
|
55 | + return new Client($this->config, $this->certificateManager, new GuzzleClient()); |
|
56 | + } |
|
57 | 57 | } |
@@ -38,86 +38,86 @@ |
||
38 | 38 | * @package OC\Session |
39 | 39 | */ |
40 | 40 | class Memory extends Session { |
41 | - protected $data; |
|
41 | + protected $data; |
|
42 | 42 | |
43 | - public function __construct($name) { |
|
44 | - //no need to use $name since all data is already scoped to this instance |
|
45 | - $this->data = array(); |
|
46 | - } |
|
43 | + public function __construct($name) { |
|
44 | + //no need to use $name since all data is already scoped to this instance |
|
45 | + $this->data = array(); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @param string $key |
|
50 | - * @param integer $value |
|
51 | - */ |
|
52 | - public function set($key, $value) { |
|
53 | - $this->validateSession(); |
|
54 | - $this->data[$key] = $value; |
|
55 | - } |
|
48 | + /** |
|
49 | + * @param string $key |
|
50 | + * @param integer $value |
|
51 | + */ |
|
52 | + public function set($key, $value) { |
|
53 | + $this->validateSession(); |
|
54 | + $this->data[$key] = $value; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @param string $key |
|
59 | - * @return mixed |
|
60 | - */ |
|
61 | - public function get($key) { |
|
62 | - if (!$this->exists($key)) { |
|
63 | - return null; |
|
64 | - } |
|
65 | - return $this->data[$key]; |
|
66 | - } |
|
57 | + /** |
|
58 | + * @param string $key |
|
59 | + * @return mixed |
|
60 | + */ |
|
61 | + public function get($key) { |
|
62 | + if (!$this->exists($key)) { |
|
63 | + return null; |
|
64 | + } |
|
65 | + return $this->data[$key]; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @param string $key |
|
70 | - * @return bool |
|
71 | - */ |
|
72 | - public function exists($key) { |
|
73 | - return isset($this->data[$key]); |
|
74 | - } |
|
68 | + /** |
|
69 | + * @param string $key |
|
70 | + * @return bool |
|
71 | + */ |
|
72 | + public function exists($key) { |
|
73 | + return isset($this->data[$key]); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @param string $key |
|
78 | - */ |
|
79 | - public function remove($key) { |
|
80 | - $this->validateSession(); |
|
81 | - unset($this->data[$key]); |
|
82 | - } |
|
76 | + /** |
|
77 | + * @param string $key |
|
78 | + */ |
|
79 | + public function remove($key) { |
|
80 | + $this->validateSession(); |
|
81 | + unset($this->data[$key]); |
|
82 | + } |
|
83 | 83 | |
84 | - public function clear() { |
|
85 | - $this->data = array(); |
|
86 | - } |
|
84 | + public function clear() { |
|
85 | + $this->data = array(); |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * Stub since the session ID does not need to get regenerated for the cache |
|
90 | - * |
|
91 | - * @param bool $deleteOldSession |
|
92 | - */ |
|
93 | - public function regenerateId($deleteOldSession = true) {} |
|
88 | + /** |
|
89 | + * Stub since the session ID does not need to get regenerated for the cache |
|
90 | + * |
|
91 | + * @param bool $deleteOldSession |
|
92 | + */ |
|
93 | + public function regenerateId($deleteOldSession = true) {} |
|
94 | 94 | |
95 | - /** |
|
96 | - * Wrapper around session_id |
|
97 | - * |
|
98 | - * @return string |
|
99 | - * @throws SessionNotAvailableException |
|
100 | - * @since 9.1.0 |
|
101 | - */ |
|
102 | - public function getId() { |
|
103 | - throw new SessionNotAvailableException('Memory session does not have an ID'); |
|
104 | - } |
|
95 | + /** |
|
96 | + * Wrapper around session_id |
|
97 | + * |
|
98 | + * @return string |
|
99 | + * @throws SessionNotAvailableException |
|
100 | + * @since 9.1.0 |
|
101 | + */ |
|
102 | + public function getId() { |
|
103 | + throw new SessionNotAvailableException('Memory session does not have an ID'); |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Helper function for PHPUnit execution - don't use in non-test code |
|
108 | - */ |
|
109 | - public function reopen() { |
|
110 | - $this->sessionClosed = false; |
|
111 | - } |
|
106 | + /** |
|
107 | + * Helper function for PHPUnit execution - don't use in non-test code |
|
108 | + */ |
|
109 | + public function reopen() { |
|
110 | + $this->sessionClosed = false; |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
114 | - * In case the session has already been locked an exception will be thrown |
|
115 | - * |
|
116 | - * @throws Exception |
|
117 | - */ |
|
118 | - private function validateSession() { |
|
119 | - if ($this->sessionClosed) { |
|
120 | - throw new Exception('Session has been closed - no further changes to the session are allowed'); |
|
121 | - } |
|
122 | - } |
|
113 | + /** |
|
114 | + * In case the session has already been locked an exception will be thrown |
|
115 | + * |
|
116 | + * @throws Exception |
|
117 | + */ |
|
118 | + private function validateSession() { |
|
119 | + if ($this->sessionClosed) { |
|
120 | + throw new Exception('Session has been closed - no further changes to the session are allowed'); |
|
121 | + } |
|
122 | + } |
|
123 | 123 | } |
@@ -38,120 +38,120 @@ |
||
38 | 38 | * @package OC\Session |
39 | 39 | */ |
40 | 40 | class Internal extends Session { |
41 | - /** |
|
42 | - * @param string $name |
|
43 | - * @throws \Exception |
|
44 | - */ |
|
45 | - public function __construct($name) { |
|
46 | - session_name($name); |
|
47 | - set_error_handler(array($this, 'trapError')); |
|
48 | - try { |
|
49 | - session_start(); |
|
50 | - } catch (\Exception $e) { |
|
51 | - setcookie(session_name(), null, -1, \OC::$WEBROOT ? : '/'); |
|
52 | - } |
|
53 | - restore_error_handler(); |
|
54 | - if (!isset($_SESSION)) { |
|
55 | - throw new \Exception('Failed to start session'); |
|
56 | - } |
|
57 | - } |
|
41 | + /** |
|
42 | + * @param string $name |
|
43 | + * @throws \Exception |
|
44 | + */ |
|
45 | + public function __construct($name) { |
|
46 | + session_name($name); |
|
47 | + set_error_handler(array($this, 'trapError')); |
|
48 | + try { |
|
49 | + session_start(); |
|
50 | + } catch (\Exception $e) { |
|
51 | + setcookie(session_name(), null, -1, \OC::$WEBROOT ? : '/'); |
|
52 | + } |
|
53 | + restore_error_handler(); |
|
54 | + if (!isset($_SESSION)) { |
|
55 | + throw new \Exception('Failed to start session'); |
|
56 | + } |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * @param string $key |
|
61 | - * @param integer $value |
|
62 | - */ |
|
63 | - public function set($key, $value) { |
|
64 | - $this->validateSession(); |
|
65 | - $_SESSION[$key] = $value; |
|
66 | - } |
|
59 | + /** |
|
60 | + * @param string $key |
|
61 | + * @param integer $value |
|
62 | + */ |
|
63 | + public function set($key, $value) { |
|
64 | + $this->validateSession(); |
|
65 | + $_SESSION[$key] = $value; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @param string $key |
|
70 | - * @return mixed |
|
71 | - */ |
|
72 | - public function get($key) { |
|
73 | - if (!$this->exists($key)) { |
|
74 | - return null; |
|
75 | - } |
|
76 | - return $_SESSION[$key]; |
|
77 | - } |
|
68 | + /** |
|
69 | + * @param string $key |
|
70 | + * @return mixed |
|
71 | + */ |
|
72 | + public function get($key) { |
|
73 | + if (!$this->exists($key)) { |
|
74 | + return null; |
|
75 | + } |
|
76 | + return $_SESSION[$key]; |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * @param string $key |
|
81 | - * @return bool |
|
82 | - */ |
|
83 | - public function exists($key) { |
|
84 | - return isset($_SESSION[$key]); |
|
85 | - } |
|
79 | + /** |
|
80 | + * @param string $key |
|
81 | + * @return bool |
|
82 | + */ |
|
83 | + public function exists($key) { |
|
84 | + return isset($_SESSION[$key]); |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * @param string $key |
|
89 | - */ |
|
90 | - public function remove($key) { |
|
91 | - if (isset($_SESSION[$key])) { |
|
92 | - unset($_SESSION[$key]); |
|
93 | - } |
|
94 | - } |
|
87 | + /** |
|
88 | + * @param string $key |
|
89 | + */ |
|
90 | + public function remove($key) { |
|
91 | + if (isset($_SESSION[$key])) { |
|
92 | + unset($_SESSION[$key]); |
|
93 | + } |
|
94 | + } |
|
95 | 95 | |
96 | - public function clear() { |
|
97 | - session_unset(); |
|
98 | - $this->regenerateId(); |
|
99 | - @session_start(); |
|
100 | - $_SESSION = array(); |
|
101 | - } |
|
96 | + public function clear() { |
|
97 | + session_unset(); |
|
98 | + $this->regenerateId(); |
|
99 | + @session_start(); |
|
100 | + $_SESSION = array(); |
|
101 | + } |
|
102 | 102 | |
103 | - public function close() { |
|
104 | - session_write_close(); |
|
105 | - parent::close(); |
|
106 | - } |
|
103 | + public function close() { |
|
104 | + session_write_close(); |
|
105 | + parent::close(); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * Wrapper around session_regenerate_id |
|
110 | - * |
|
111 | - * @param bool $deleteOldSession Whether to delete the old associated session file or not. |
|
112 | - * @return void |
|
113 | - */ |
|
114 | - public function regenerateId($deleteOldSession = true) { |
|
115 | - @session_regenerate_id($deleteOldSession); |
|
116 | - } |
|
108 | + /** |
|
109 | + * Wrapper around session_regenerate_id |
|
110 | + * |
|
111 | + * @param bool $deleteOldSession Whether to delete the old associated session file or not. |
|
112 | + * @return void |
|
113 | + */ |
|
114 | + public function regenerateId($deleteOldSession = true) { |
|
115 | + @session_regenerate_id($deleteOldSession); |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * Wrapper around session_id |
|
120 | - * |
|
121 | - * @return string |
|
122 | - * @throws SessionNotAvailableException |
|
123 | - * @since 9.1.0 |
|
124 | - */ |
|
125 | - public function getId() { |
|
126 | - $id = @session_id(); |
|
127 | - if ($id === '') { |
|
128 | - throw new SessionNotAvailableException(); |
|
129 | - } |
|
130 | - return $id; |
|
131 | - } |
|
118 | + /** |
|
119 | + * Wrapper around session_id |
|
120 | + * |
|
121 | + * @return string |
|
122 | + * @throws SessionNotAvailableException |
|
123 | + * @since 9.1.0 |
|
124 | + */ |
|
125 | + public function getId() { |
|
126 | + $id = @session_id(); |
|
127 | + if ($id === '') { |
|
128 | + throw new SessionNotAvailableException(); |
|
129 | + } |
|
130 | + return $id; |
|
131 | + } |
|
132 | 132 | |
133 | - /** |
|
134 | - * @throws \Exception |
|
135 | - */ |
|
136 | - public function reopen() { |
|
137 | - throw new \Exception('The session cannot be reopened - reopen() is ony to be used in unit testing.'); |
|
138 | - } |
|
133 | + /** |
|
134 | + * @throws \Exception |
|
135 | + */ |
|
136 | + public function reopen() { |
|
137 | + throw new \Exception('The session cannot be reopened - reopen() is ony to be used in unit testing.'); |
|
138 | + } |
|
139 | 139 | |
140 | - /** |
|
141 | - * @param int $errorNumber |
|
142 | - * @param string $errorString |
|
143 | - * @throws \ErrorException |
|
144 | - */ |
|
145 | - public function trapError($errorNumber, $errorString) { |
|
146 | - throw new \ErrorException($errorString); |
|
147 | - } |
|
140 | + /** |
|
141 | + * @param int $errorNumber |
|
142 | + * @param string $errorString |
|
143 | + * @throws \ErrorException |
|
144 | + */ |
|
145 | + public function trapError($errorNumber, $errorString) { |
|
146 | + throw new \ErrorException($errorString); |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * @throws \Exception |
|
151 | - */ |
|
152 | - private function validateSession() { |
|
153 | - if ($this->sessionClosed) { |
|
154 | - throw new \Exception('Session has been closed - no further changes to the session are allowed'); |
|
155 | - } |
|
156 | - } |
|
149 | + /** |
|
150 | + * @throws \Exception |
|
151 | + */ |
|
152 | + private function validateSession() { |
|
153 | + if ($this->sessionClosed) { |
|
154 | + throw new \Exception('Session has been closed - no further changes to the session are allowed'); |
|
155 | + } |
|
156 | + } |
|
157 | 157 | } |
@@ -28,53 +28,53 @@ |
||
28 | 28 | |
29 | 29 | abstract class Session implements \ArrayAccess, ISession { |
30 | 30 | |
31 | - /** |
|
32 | - * @var bool |
|
33 | - */ |
|
34 | - protected $sessionClosed = false; |
|
31 | + /** |
|
32 | + * @var bool |
|
33 | + */ |
|
34 | + protected $sessionClosed = false; |
|
35 | 35 | |
36 | - /** |
|
37 | - * $name serves as a namespace for the session keys |
|
38 | - * |
|
39 | - * @param string $name |
|
40 | - */ |
|
41 | - abstract public function __construct($name); |
|
36 | + /** |
|
37 | + * $name serves as a namespace for the session keys |
|
38 | + * |
|
39 | + * @param string $name |
|
40 | + */ |
|
41 | + abstract public function __construct($name); |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param mixed $offset |
|
45 | - * @return bool |
|
46 | - */ |
|
47 | - public function offsetExists($offset) { |
|
48 | - return $this->exists($offset); |
|
49 | - } |
|
43 | + /** |
|
44 | + * @param mixed $offset |
|
45 | + * @return bool |
|
46 | + */ |
|
47 | + public function offsetExists($offset) { |
|
48 | + return $this->exists($offset); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param mixed $offset |
|
53 | - * @return mixed |
|
54 | - */ |
|
55 | - public function offsetGet($offset) { |
|
56 | - return $this->get($offset); |
|
57 | - } |
|
51 | + /** |
|
52 | + * @param mixed $offset |
|
53 | + * @return mixed |
|
54 | + */ |
|
55 | + public function offsetGet($offset) { |
|
56 | + return $this->get($offset); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * @param mixed $offset |
|
61 | - * @param mixed $value |
|
62 | - */ |
|
63 | - public function offsetSet($offset, $value) { |
|
64 | - $this->set($offset, $value); |
|
65 | - } |
|
59 | + /** |
|
60 | + * @param mixed $offset |
|
61 | + * @param mixed $value |
|
62 | + */ |
|
63 | + public function offsetSet($offset, $value) { |
|
64 | + $this->set($offset, $value); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * @param mixed $offset |
|
69 | - */ |
|
70 | - public function offsetUnset($offset) { |
|
71 | - $this->remove($offset); |
|
72 | - } |
|
67 | + /** |
|
68 | + * @param mixed $offset |
|
69 | + */ |
|
70 | + public function offsetUnset($offset) { |
|
71 | + $this->remove($offset); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Close the session and release the lock |
|
76 | - */ |
|
77 | - public function close() { |
|
78 | - $this->sessionClosed = true; |
|
79 | - } |
|
74 | + /** |
|
75 | + * Close the session and release the lock |
|
76 | + */ |
|
77 | + public function close() { |
|
78 | + $this->sessionClosed = true; |
|
79 | + } |
|
80 | 80 | } |