$this->filename = $filename;
}
- static function forTitle($title, $paths)
+ static function forTitle($title, array $paths, $language=null)
{
- if (!is_array($paths)) {
- $paths = array($paths);
- }
-
$filename = null;
if (Event::handle('StartDocFileForTitle', array($title, &$paths, &$filename))) {
}
if (!empty($lang) || !empty($def)) {
- $filename = self::negotiateLanguage($lang, $def);
+ $filename = self::negotiateLanguage($lang, $def, $language);
break;
}
}
}
}
- function toHTML(array $args=null)
+ function toHTML(array $args=array())
{
- if (is_null($args)) {
- $args = array();
- }
-
if (empty($this->contents)) {
$this->contents = file_get_contents($this->filename);
}
INSTALLDIR.'/doc-src/');
$site = StatusNet::currentSite();
-
+
if (!empty($site)) {
array_unshift($paths, INSTALLDIR.'/local/doc-src/'.$site.'/');
}
INSTALLDIR.'/mail-src/');
$site = StatusNet::currentSite();
-
+
if (!empty($site)) {
array_unshift($paths, INSTALLDIR.'/local/mail-src/'.$site.'/');
}
return $paths;
}
- static function negotiateLanguage($filenames, $defaultFilename=null)
+ private static function negotiateLanguage(array $filenames, $defaultFilename=null, $language = null)
{
- // XXX: do this better
-
+ // Default is current language
$langcode = common_language();
+ // Is a language set?
+ if (!empty($language)) {
+ // And is it valid?
+ if (common_valid_language($language)) {
+ // Use this as language (e.g. from form)
+ $langcode = strval($language);
+ }
+ }
+
foreach ($filenames as $filename) {
if (preg_match('/\.'.$langcode.'$/', $filename)) {
return $filename;