@@ -106,7 +106,7 @@ |
||
| 106 | 106 | /** |
| 107 | 107 | * Return the relative date in relation to today. Returns something like "last hour" or "two month ago" |
| 108 | 108 | * @param int $timestamp unix timestamp |
| 109 | - * @param boolean $dateOnly |
|
| 109 | + * @param integer $dateOnly |
|
| 110 | 110 | * @return string human readable interpretation of the timestamp |
| 111 | 111 | * |
| 112 | 112 | * @deprecated 8.0.0 Use \OCP\Template::relative_modified_date() instead |
@@ -29,59 +29,59 @@ |
||
| 29 | 29 | namespace OC\L10N; |
| 30 | 30 | |
| 31 | 31 | class L10NString implements \JsonSerializable { |
| 32 | - /** @var \OC\L10N\L10N */ |
|
| 33 | - protected $l10n; |
|
| 32 | + /** @var \OC\L10N\L10N */ |
|
| 33 | + protected $l10n; |
|
| 34 | 34 | |
| 35 | - /** @var string */ |
|
| 36 | - protected $text; |
|
| 35 | + /** @var string */ |
|
| 36 | + protected $text; |
|
| 37 | 37 | |
| 38 | - /** @var array */ |
|
| 39 | - protected $parameters; |
|
| 38 | + /** @var array */ |
|
| 39 | + protected $parameters; |
|
| 40 | 40 | |
| 41 | - /** @var integer */ |
|
| 42 | - protected $count; |
|
| 41 | + /** @var integer */ |
|
| 42 | + protected $count; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @param \OC\L10N\L10N $l10n |
|
| 46 | - * @param string|string[] $text |
|
| 47 | - * @param array $parameters |
|
| 48 | - * @param int $count |
|
| 49 | - */ |
|
| 50 | - public function __construct(\OC\L10N\L10N $l10n, $text, $parameters, $count = 1) { |
|
| 51 | - $this->l10n = $l10n; |
|
| 52 | - $this->text = $text; |
|
| 53 | - $this->parameters = $parameters; |
|
| 54 | - $this->count = $count; |
|
| 55 | - } |
|
| 44 | + /** |
|
| 45 | + * @param \OC\L10N\L10N $l10n |
|
| 46 | + * @param string|string[] $text |
|
| 47 | + * @param array $parameters |
|
| 48 | + * @param int $count |
|
| 49 | + */ |
|
| 50 | + public function __construct(\OC\L10N\L10N $l10n, $text, $parameters, $count = 1) { |
|
| 51 | + $this->l10n = $l10n; |
|
| 52 | + $this->text = $text; |
|
| 53 | + $this->parameters = $parameters; |
|
| 54 | + $this->count = $count; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @return string |
|
| 59 | - */ |
|
| 60 | - public function __toString() { |
|
| 61 | - $translations = $this->l10n->getTranslations(); |
|
| 57 | + /** |
|
| 58 | + * @return string |
|
| 59 | + */ |
|
| 60 | + public function __toString() { |
|
| 61 | + $translations = $this->l10n->getTranslations(); |
|
| 62 | 62 | |
| 63 | - $text = $this->text; |
|
| 64 | - if(array_key_exists($this->text, $translations)) { |
|
| 65 | - if(is_array($translations[$this->text])) { |
|
| 66 | - $fn = $this->l10n->getPluralFormFunction(); |
|
| 67 | - $id = $fn($this->count); |
|
| 68 | - $text = $translations[$this->text][$id]; |
|
| 69 | - } |
|
| 70 | - else{ |
|
| 71 | - $text = $translations[$this->text]; |
|
| 72 | - } |
|
| 73 | - } |
|
| 63 | + $text = $this->text; |
|
| 64 | + if(array_key_exists($this->text, $translations)) { |
|
| 65 | + if(is_array($translations[$this->text])) { |
|
| 66 | + $fn = $this->l10n->getPluralFormFunction(); |
|
| 67 | + $id = $fn($this->count); |
|
| 68 | + $text = $translations[$this->text][$id]; |
|
| 69 | + } |
|
| 70 | + else{ |
|
| 71 | + $text = $translations[$this->text]; |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - // Replace %n first (won't interfere with vsprintf) |
|
| 76 | - $text = str_replace('%n', $this->count, $text); |
|
| 77 | - return vsprintf($text, $this->parameters); |
|
| 78 | - } |
|
| 75 | + // Replace %n first (won't interfere with vsprintf) |
|
| 76 | + $text = str_replace('%n', $this->count, $text); |
|
| 77 | + return vsprintf($text, $this->parameters); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * @return string |
|
| 83 | - */ |
|
| 84 | - public function jsonSerialize() { |
|
| 85 | - return $this->__toString(); |
|
| 86 | - } |
|
| 81 | + /** |
|
| 82 | + * @return string |
|
| 83 | + */ |
|
| 84 | + public function jsonSerialize() { |
|
| 85 | + return $this->__toString(); |
|
| 86 | + } |
|
| 87 | 87 | } |
@@ -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 L10NString($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 L10NString($this, $identifier, $parameters, $count); |
|
| 107 | - } else { |
|
| 108 | - if ($count === 1) { |
|
| 109 | - return (string) new L10NString($this, $text_singular, $parameters, $count); |
|
| 110 | - } else { |
|
| 111 | - return (string) new L10NString($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 L10NString($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 L10NString($this, $identifier, $parameters, $count); |
|
| 107 | + } else { |
|
| 108 | + if ($count === 1) { |
|
| 109 | + return (string) new L10NString($this, $text_singular, $parameters, $count); |
|
| 110 | + } else { |
|
| 111 | + return (string) new L10NString($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 | } |
@@ -35,154 +35,154 @@ |
||
| 35 | 35 | * @deprecated Use a AppFramework JSONResponse instead |
| 36 | 36 | */ |
| 37 | 37 | class OC_JSON{ |
| 38 | - static protected $send_content_type_header = false; |
|
| 39 | - /** |
|
| 40 | - * set Content-Type header to jsonrequest |
|
| 41 | - * @deprecated Use a AppFramework JSONResponse instead |
|
| 42 | - */ |
|
| 43 | - public static function setContentTypeHeader($type='application/json') { |
|
| 44 | - if (!self::$send_content_type_header) { |
|
| 45 | - // We send json data |
|
| 46 | - header( 'Content-Type: '.$type . '; charset=utf-8'); |
|
| 47 | - self::$send_content_type_header = true; |
|
| 48 | - } |
|
| 49 | - } |
|
| 38 | + static protected $send_content_type_header = false; |
|
| 39 | + /** |
|
| 40 | + * set Content-Type header to jsonrequest |
|
| 41 | + * @deprecated Use a AppFramework JSONResponse instead |
|
| 42 | + */ |
|
| 43 | + public static function setContentTypeHeader($type='application/json') { |
|
| 44 | + if (!self::$send_content_type_header) { |
|
| 45 | + // We send json data |
|
| 46 | + header( 'Content-Type: '.$type . '; charset=utf-8'); |
|
| 47 | + self::$send_content_type_header = true; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Check if the app is enabled, send json error msg if not |
|
| 53 | - * @param string $app |
|
| 54 | - * @deprecated Use the AppFramework instead. It will automatically check if the app is enabled. |
|
| 55 | - */ |
|
| 56 | - public static function checkAppEnabled($app) { |
|
| 57 | - if( !OC_App::isEnabled($app)) { |
|
| 58 | - $l = \OC::$server->getL10N('lib'); |
|
| 59 | - self::error(array( 'data' => array( 'message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled' ))); |
|
| 60 | - exit(); |
|
| 61 | - } |
|
| 62 | - } |
|
| 51 | + /** |
|
| 52 | + * Check if the app is enabled, send json error msg if not |
|
| 53 | + * @param string $app |
|
| 54 | + * @deprecated Use the AppFramework instead. It will automatically check if the app is enabled. |
|
| 55 | + */ |
|
| 56 | + public static function checkAppEnabled($app) { |
|
| 57 | + if( !OC_App::isEnabled($app)) { |
|
| 58 | + $l = \OC::$server->getL10N('lib'); |
|
| 59 | + self::error(array( 'data' => array( 'message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled' ))); |
|
| 60 | + exit(); |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Check if the user is logged in, send json error msg if not |
|
| 66 | - * @deprecated Use annotation based ACLs from the AppFramework instead |
|
| 67 | - */ |
|
| 68 | - public static function checkLoggedIn() { |
|
| 69 | - $twoFactorAuthManger = \OC::$server->getTwoFactorAuthManager(); |
|
| 70 | - if( !\OC::$server->getUserSession()->isLoggedIn() |
|
| 71 | - || $twoFactorAuthManger->needsSecondFactor(\OC::$server->getUserSession()->getUser())) { |
|
| 72 | - $l = \OC::$server->getL10N('lib'); |
|
| 73 | - http_response_code(\OCP\AppFramework\Http::STATUS_UNAUTHORIZED); |
|
| 74 | - self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ))); |
|
| 75 | - exit(); |
|
| 76 | - } |
|
| 77 | - } |
|
| 64 | + /** |
|
| 65 | + * Check if the user is logged in, send json error msg if not |
|
| 66 | + * @deprecated Use annotation based ACLs from the AppFramework instead |
|
| 67 | + */ |
|
| 68 | + public static function checkLoggedIn() { |
|
| 69 | + $twoFactorAuthManger = \OC::$server->getTwoFactorAuthManager(); |
|
| 70 | + if( !\OC::$server->getUserSession()->isLoggedIn() |
|
| 71 | + || $twoFactorAuthManger->needsSecondFactor(\OC::$server->getUserSession()->getUser())) { |
|
| 72 | + $l = \OC::$server->getL10N('lib'); |
|
| 73 | + http_response_code(\OCP\AppFramework\Http::STATUS_UNAUTHORIZED); |
|
| 74 | + self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ))); |
|
| 75 | + exit(); |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Check an ajax get/post call if the request token is valid, send json error msg if not. |
|
| 81 | - * @deprecated Use annotation based CSRF checks from the AppFramework instead |
|
| 82 | - */ |
|
| 83 | - public static function callCheck() { |
|
| 84 | - if(!\OC::$server->getRequest()->passesStrictCookieCheck()) { |
|
| 85 | - header('Location: '.\OC::$WEBROOT); |
|
| 86 | - exit(); |
|
| 87 | - } |
|
| 79 | + /** |
|
| 80 | + * Check an ajax get/post call if the request token is valid, send json error msg if not. |
|
| 81 | + * @deprecated Use annotation based CSRF checks from the AppFramework instead |
|
| 82 | + */ |
|
| 83 | + public static function callCheck() { |
|
| 84 | + if(!\OC::$server->getRequest()->passesStrictCookieCheck()) { |
|
| 85 | + header('Location: '.\OC::$WEBROOT); |
|
| 86 | + exit(); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - if( !(\OC::$server->getRequest()->passesCSRFCheck())) { |
|
| 90 | - $l = \OC::$server->getL10N('lib'); |
|
| 91 | - self::error(array( 'data' => array( 'message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired' ))); |
|
| 92 | - exit(); |
|
| 93 | - } |
|
| 94 | - } |
|
| 89 | + if( !(\OC::$server->getRequest()->passesCSRFCheck())) { |
|
| 90 | + $l = \OC::$server->getL10N('lib'); |
|
| 91 | + self::error(array( 'data' => array( 'message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired' ))); |
|
| 92 | + exit(); |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Check if the user is a admin, send json error msg if not. |
|
| 98 | - * @deprecated Use annotation based ACLs from the AppFramework instead |
|
| 99 | - */ |
|
| 100 | - public static function checkAdminUser() { |
|
| 101 | - if( !OC_User::isAdminUser(OC_User::getUser())) { |
|
| 102 | - $l = \OC::$server->getL10N('lib'); |
|
| 103 | - self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ))); |
|
| 104 | - exit(); |
|
| 105 | - } |
|
| 106 | - } |
|
| 96 | + /** |
|
| 97 | + * Check if the user is a admin, send json error msg if not. |
|
| 98 | + * @deprecated Use annotation based ACLs from the AppFramework instead |
|
| 99 | + */ |
|
| 100 | + public static function checkAdminUser() { |
|
| 101 | + if( !OC_User::isAdminUser(OC_User::getUser())) { |
|
| 102 | + $l = \OC::$server->getL10N('lib'); |
|
| 103 | + self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ))); |
|
| 104 | + exit(); |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * Check is a given user exists - send json error msg if not |
|
| 110 | - * @param string $user |
|
| 111 | - * @deprecated Use a AppFramework JSONResponse instead |
|
| 112 | - */ |
|
| 113 | - public static function checkUserExists($user) { |
|
| 114 | - if (!OCP\User::userExists($user)) { |
|
| 115 | - $l = \OC::$server->getL10N('lib'); |
|
| 116 | - OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user'), 'error' => 'unknown_user' ))); |
|
| 117 | - exit; |
|
| 118 | - } |
|
| 119 | - } |
|
| 108 | + /** |
|
| 109 | + * Check is a given user exists - send json error msg if not |
|
| 110 | + * @param string $user |
|
| 111 | + * @deprecated Use a AppFramework JSONResponse instead |
|
| 112 | + */ |
|
| 113 | + public static function checkUserExists($user) { |
|
| 114 | + if (!OCP\User::userExists($user)) { |
|
| 115 | + $l = \OC::$server->getL10N('lib'); |
|
| 116 | + OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user'), 'error' => 'unknown_user' ))); |
|
| 117 | + exit; |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | 121 | |
| 122 | - /** |
|
| 123 | - * Check if the user is a subadmin, send json error msg if not |
|
| 124 | - * @deprecated Use annotation based ACLs from the AppFramework instead |
|
| 125 | - */ |
|
| 126 | - public static function checkSubAdminUser() { |
|
| 127 | - $userObject = \OC::$server->getUserSession()->getUser(); |
|
| 128 | - $isSubAdmin = false; |
|
| 129 | - if($userObject !== null) { |
|
| 130 | - $isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject); |
|
| 131 | - } |
|
| 122 | + /** |
|
| 123 | + * Check if the user is a subadmin, send json error msg if not |
|
| 124 | + * @deprecated Use annotation based ACLs from the AppFramework instead |
|
| 125 | + */ |
|
| 126 | + public static function checkSubAdminUser() { |
|
| 127 | + $userObject = \OC::$server->getUserSession()->getUser(); |
|
| 128 | + $isSubAdmin = false; |
|
| 129 | + if($userObject !== null) { |
|
| 130 | + $isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject); |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - if(!$isSubAdmin) { |
|
| 134 | - $l = \OC::$server->getL10N('lib'); |
|
| 135 | - self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ))); |
|
| 136 | - exit(); |
|
| 137 | - } |
|
| 138 | - } |
|
| 133 | + if(!$isSubAdmin) { |
|
| 134 | + $l = \OC::$server->getL10N('lib'); |
|
| 135 | + self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ))); |
|
| 136 | + exit(); |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - /** |
|
| 141 | - * Send json error msg |
|
| 142 | - * @deprecated Use a AppFramework JSONResponse instead |
|
| 143 | - */ |
|
| 144 | - public static function error($data = array()) { |
|
| 145 | - $data['status'] = 'error'; |
|
| 146 | - self::encodedPrint($data); |
|
| 147 | - } |
|
| 140 | + /** |
|
| 141 | + * Send json error msg |
|
| 142 | + * @deprecated Use a AppFramework JSONResponse instead |
|
| 143 | + */ |
|
| 144 | + public static function error($data = array()) { |
|
| 145 | + $data['status'] = 'error'; |
|
| 146 | + self::encodedPrint($data); |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - /** |
|
| 150 | - * Send json success msg |
|
| 151 | - * @deprecated Use a AppFramework JSONResponse instead |
|
| 152 | - */ |
|
| 153 | - public static function success($data = array()) { |
|
| 154 | - $data['status'] = 'success'; |
|
| 155 | - self::encodedPrint($data); |
|
| 156 | - } |
|
| 149 | + /** |
|
| 150 | + * Send json success msg |
|
| 151 | + * @deprecated Use a AppFramework JSONResponse instead |
|
| 152 | + */ |
|
| 153 | + public static function success($data = array()) { |
|
| 154 | + $data['status'] = 'success'; |
|
| 155 | + self::encodedPrint($data); |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * Convert OC_L10N_String to string, for use in json encodings |
|
| 160 | - */ |
|
| 161 | - protected static function to_string(&$value) { |
|
| 162 | - if ($value instanceof \OC\L10N\L10NString) { |
|
| 163 | - $value = (string)$value; |
|
| 164 | - } |
|
| 165 | - } |
|
| 158 | + /** |
|
| 159 | + * Convert OC_L10N_String to string, for use in json encodings |
|
| 160 | + */ |
|
| 161 | + protected static function to_string(&$value) { |
|
| 162 | + if ($value instanceof \OC\L10N\L10NString) { |
|
| 163 | + $value = (string)$value; |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - /** |
|
| 168 | - * Encode and print $data in json format |
|
| 169 | - * @deprecated Use a AppFramework JSONResponse instead |
|
| 170 | - */ |
|
| 171 | - public static function encodedPrint($data, $setContentType=true) { |
|
| 172 | - if($setContentType) { |
|
| 173 | - self::setContentTypeHeader(); |
|
| 174 | - } |
|
| 175 | - echo self::encode($data); |
|
| 176 | - } |
|
| 167 | + /** |
|
| 168 | + * Encode and print $data in json format |
|
| 169 | + * @deprecated Use a AppFramework JSONResponse instead |
|
| 170 | + */ |
|
| 171 | + public static function encodedPrint($data, $setContentType=true) { |
|
| 172 | + if($setContentType) { |
|
| 173 | + self::setContentTypeHeader(); |
|
| 174 | + } |
|
| 175 | + echo self::encode($data); |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | - /** |
|
| 179 | - * Encode JSON |
|
| 180 | - * @deprecated Use a AppFramework JSONResponse instead |
|
| 181 | - */ |
|
| 182 | - public static function encode($data) { |
|
| 183 | - if (is_array($data)) { |
|
| 184 | - array_walk_recursive($data, array('OC_JSON', 'to_string')); |
|
| 185 | - } |
|
| 186 | - return json_encode($data, JSON_HEX_TAG); |
|
| 187 | - } |
|
| 178 | + /** |
|
| 179 | + * Encode JSON |
|
| 180 | + * @deprecated Use a AppFramework JSONResponse instead |
|
| 181 | + */ |
|
| 182 | + public static function encode($data) { |
|
| 183 | + if (is_array($data)) { |
|
| 184 | + array_walk_recursive($data, array('OC_JSON', 'to_string')); |
|
| 185 | + } |
|
| 186 | + return json_encode($data, JSON_HEX_TAG); |
|
| 187 | + } |
|
| 188 | 188 | } |
@@ -34,16 +34,16 @@ discard block |
||
| 34 | 34 | * Class OC_JSON |
| 35 | 35 | * @deprecated Use a AppFramework JSONResponse instead |
| 36 | 36 | */ |
| 37 | -class OC_JSON{ |
|
| 37 | +class OC_JSON { |
|
| 38 | 38 | static protected $send_content_type_header = false; |
| 39 | 39 | /** |
| 40 | 40 | * set Content-Type header to jsonrequest |
| 41 | 41 | * @deprecated Use a AppFramework JSONResponse instead |
| 42 | 42 | */ |
| 43 | - public static function setContentTypeHeader($type='application/json') { |
|
| 43 | + public static function setContentTypeHeader($type = 'application/json') { |
|
| 44 | 44 | if (!self::$send_content_type_header) { |
| 45 | 45 | // We send json data |
| 46 | - header( 'Content-Type: '.$type . '; charset=utf-8'); |
|
| 46 | + header('Content-Type: '.$type.'; charset=utf-8'); |
|
| 47 | 47 | self::$send_content_type_header = true; |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -54,9 +54,9 @@ discard block |
||
| 54 | 54 | * @deprecated Use the AppFramework instead. It will automatically check if the app is enabled. |
| 55 | 55 | */ |
| 56 | 56 | public static function checkAppEnabled($app) { |
| 57 | - if( !OC_App::isEnabled($app)) { |
|
| 57 | + if (!OC_App::isEnabled($app)) { |
|
| 58 | 58 | $l = \OC::$server->getL10N('lib'); |
| 59 | - self::error(array( 'data' => array( 'message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled' ))); |
|
| 59 | + self::error(array('data' => array('message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled'))); |
|
| 60 | 60 | exit(); |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -67,11 +67,11 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public static function checkLoggedIn() { |
| 69 | 69 | $twoFactorAuthManger = \OC::$server->getTwoFactorAuthManager(); |
| 70 | - if( !\OC::$server->getUserSession()->isLoggedIn() |
|
| 70 | + if (!\OC::$server->getUserSession()->isLoggedIn() |
|
| 71 | 71 | || $twoFactorAuthManger->needsSecondFactor(\OC::$server->getUserSession()->getUser())) { |
| 72 | 72 | $l = \OC::$server->getL10N('lib'); |
| 73 | 73 | http_response_code(\OCP\AppFramework\Http::STATUS_UNAUTHORIZED); |
| 74 | - self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ))); |
|
| 74 | + self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error'))); |
|
| 75 | 75 | exit(); |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -81,14 +81,14 @@ discard block |
||
| 81 | 81 | * @deprecated Use annotation based CSRF checks from the AppFramework instead |
| 82 | 82 | */ |
| 83 | 83 | public static function callCheck() { |
| 84 | - if(!\OC::$server->getRequest()->passesStrictCookieCheck()) { |
|
| 84 | + if (!\OC::$server->getRequest()->passesStrictCookieCheck()) { |
|
| 85 | 85 | header('Location: '.\OC::$WEBROOT); |
| 86 | 86 | exit(); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if( !(\OC::$server->getRequest()->passesCSRFCheck())) { |
|
| 89 | + if (!(\OC::$server->getRequest()->passesCSRFCheck())) { |
|
| 90 | 90 | $l = \OC::$server->getL10N('lib'); |
| 91 | - self::error(array( 'data' => array( 'message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired' ))); |
|
| 91 | + self::error(array('data' => array('message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired'))); |
|
| 92 | 92 | exit(); |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | * @deprecated Use annotation based ACLs from the AppFramework instead |
| 99 | 99 | */ |
| 100 | 100 | public static function checkAdminUser() { |
| 101 | - if( !OC_User::isAdminUser(OC_User::getUser())) { |
|
| 101 | + if (!OC_User::isAdminUser(OC_User::getUser())) { |
|
| 102 | 102 | $l = \OC::$server->getL10N('lib'); |
| 103 | - self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ))); |
|
| 103 | + self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error'))); |
|
| 104 | 104 | exit(); |
| 105 | 105 | } |
| 106 | 106 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | public static function checkUserExists($user) { |
| 114 | 114 | if (!OCP\User::userExists($user)) { |
| 115 | 115 | $l = \OC::$server->getL10N('lib'); |
| 116 | - OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user'), 'error' => 'unknown_user' ))); |
|
| 116 | + OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user'), 'error' => 'unknown_user'))); |
|
| 117 | 117 | exit; |
| 118 | 118 | } |
| 119 | 119 | } |
@@ -126,13 +126,13 @@ discard block |
||
| 126 | 126 | public static function checkSubAdminUser() { |
| 127 | 127 | $userObject = \OC::$server->getUserSession()->getUser(); |
| 128 | 128 | $isSubAdmin = false; |
| 129 | - if($userObject !== null) { |
|
| 129 | + if ($userObject !== null) { |
|
| 130 | 130 | $isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - if(!$isSubAdmin) { |
|
| 133 | + if (!$isSubAdmin) { |
|
| 134 | 134 | $l = \OC::$server->getL10N('lib'); |
| 135 | - self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ))); |
|
| 135 | + self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error'))); |
|
| 136 | 136 | exit(); |
| 137 | 137 | } |
| 138 | 138 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | protected static function to_string(&$value) { |
| 162 | 162 | if ($value instanceof \OC\L10N\L10NString) { |
| 163 | - $value = (string)$value; |
|
| 163 | + $value = (string) $value; |
|
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | |
@@ -168,8 +168,8 @@ discard block |
||
| 168 | 168 | * Encode and print $data in json format |
| 169 | 169 | * @deprecated Use a AppFramework JSONResponse instead |
| 170 | 170 | */ |
| 171 | - public static function encodedPrint($data, $setContentType=true) { |
|
| 172 | - if($setContentType) { |
|
| 171 | + public static function encodedPrint($data, $setContentType = true) { |
|
| 172 | + if ($setContentType) { |
|
| 173 | 173 | self::setContentTypeHeader(); |
| 174 | 174 | } |
| 175 | 175 | echo self::encode($data); |
@@ -43,69 +43,69 @@ |
||
| 43 | 43 | * @since 6.0.0 |
| 44 | 44 | */ |
| 45 | 45 | interface IL10N { |
| 46 | - /** |
|
| 47 | - * Translating |
|
| 48 | - * @param string $text The text we need a translation for |
|
| 49 | - * @param array $parameters default:array() Parameters for sprintf |
|
| 50 | - * @return string Translation or the same text |
|
| 51 | - * |
|
| 52 | - * Returns the translation. If no translation is found, $text will be |
|
| 53 | - * returned. |
|
| 54 | - * @since 6.0.0 |
|
| 55 | - */ |
|
| 56 | - public function t($text, $parameters = array()); |
|
| 46 | + /** |
|
| 47 | + * Translating |
|
| 48 | + * @param string $text The text we need a translation for |
|
| 49 | + * @param array $parameters default:array() Parameters for sprintf |
|
| 50 | + * @return string Translation or the same text |
|
| 51 | + * |
|
| 52 | + * Returns the translation. If no translation is found, $text will be |
|
| 53 | + * returned. |
|
| 54 | + * @since 6.0.0 |
|
| 55 | + */ |
|
| 56 | + public function t($text, $parameters = array()); |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Translating |
|
| 60 | - * @param string $text_singular the string to translate for exactly one object |
|
| 61 | - * @param string $text_plural the string to translate for n objects |
|
| 62 | - * @param integer $count Number of objects |
|
| 63 | - * @param array $parameters default:array() Parameters for sprintf |
|
| 64 | - * @return string Translation or the same text |
|
| 65 | - * |
|
| 66 | - * Returns the translation. If no translation is found, $text will be |
|
| 67 | - * returned. %n will be replaced with the number of objects. |
|
| 68 | - * |
|
| 69 | - * The correct plural is determined by the plural_forms-function |
|
| 70 | - * provided by the po file. |
|
| 71 | - * @since 6.0.0 |
|
| 72 | - * |
|
| 73 | - */ |
|
| 74 | - public function n($text_singular, $text_plural, $count, $parameters = array()); |
|
| 58 | + /** |
|
| 59 | + * Translating |
|
| 60 | + * @param string $text_singular the string to translate for exactly one object |
|
| 61 | + * @param string $text_plural the string to translate for n objects |
|
| 62 | + * @param integer $count Number of objects |
|
| 63 | + * @param array $parameters default:array() Parameters for sprintf |
|
| 64 | + * @return string Translation or the same text |
|
| 65 | + * |
|
| 66 | + * Returns the translation. If no translation is found, $text will be |
|
| 67 | + * returned. %n will be replaced with the number of objects. |
|
| 68 | + * |
|
| 69 | + * The correct plural is determined by the plural_forms-function |
|
| 70 | + * provided by the po file. |
|
| 71 | + * @since 6.0.0 |
|
| 72 | + * |
|
| 73 | + */ |
|
| 74 | + public function n($text_singular, $text_plural, $count, $parameters = array()); |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Localization |
|
| 78 | - * @param string $type Type of localization |
|
| 79 | - * @param \DateTime|int|string $data parameters for this localization |
|
| 80 | - * @param array $options currently supports following options: |
|
| 81 | - * - 'width': handed into \Punic\Calendar::formatDate as second parameter |
|
| 82 | - * @return string|int|false |
|
| 83 | - * |
|
| 84 | - * Returns the localized data. |
|
| 85 | - * |
|
| 86 | - * Implemented types: |
|
| 87 | - * - date |
|
| 88 | - * - Creates a date |
|
| 89 | - * - l10n-field: date |
|
| 90 | - * - params: timestamp (int/string) |
|
| 91 | - * - datetime |
|
| 92 | - * - Creates date and time |
|
| 93 | - * - l10n-field: datetime |
|
| 94 | - * - params: timestamp (int/string) |
|
| 95 | - * - time |
|
| 96 | - * - Creates a time |
|
| 97 | - * - l10n-field: time |
|
| 98 | - * - params: timestamp (int/string) |
|
| 99 | - * @since 6.0.0 - parameter $options was added in 8.0.0 |
|
| 100 | - */ |
|
| 101 | - public function l($type, $data, $options = array()); |
|
| 76 | + /** |
|
| 77 | + * Localization |
|
| 78 | + * @param string $type Type of localization |
|
| 79 | + * @param \DateTime|int|string $data parameters for this localization |
|
| 80 | + * @param array $options currently supports following options: |
|
| 81 | + * - 'width': handed into \Punic\Calendar::formatDate as second parameter |
|
| 82 | + * @return string|int|false |
|
| 83 | + * |
|
| 84 | + * Returns the localized data. |
|
| 85 | + * |
|
| 86 | + * Implemented types: |
|
| 87 | + * - date |
|
| 88 | + * - Creates a date |
|
| 89 | + * - l10n-field: date |
|
| 90 | + * - params: timestamp (int/string) |
|
| 91 | + * - datetime |
|
| 92 | + * - Creates date and time |
|
| 93 | + * - l10n-field: datetime |
|
| 94 | + * - params: timestamp (int/string) |
|
| 95 | + * - time |
|
| 96 | + * - Creates a time |
|
| 97 | + * - l10n-field: time |
|
| 98 | + * - params: timestamp (int/string) |
|
| 99 | + * @since 6.0.0 - parameter $options was added in 8.0.0 |
|
| 100 | + */ |
|
| 101 | + public function l($type, $data, $options = array()); |
|
| 102 | 102 | |
| 103 | 103 | |
| 104 | - /** |
|
| 105 | - * The code (en, de, ...) of the language that is used for this IL10N object |
|
| 106 | - * |
|
| 107 | - * @return string language |
|
| 108 | - * @since 7.0.0 |
|
| 109 | - */ |
|
| 110 | - public function getLanguageCode(); |
|
| 104 | + /** |
|
| 105 | + * The code (en, de, ...) of the language that is used for this IL10N object |
|
| 106 | + * |
|
| 107 | + * @return string language |
|
| 108 | + * @since 7.0.0 |
|
| 109 | + */ |
|
| 110 | + public function getLanguageCode(); |
|
| 111 | 111 | } |