static function forTitle($title, $paths)
{
- if (is_string($paths)) {
+ if (!is_array($paths)) {
$paths = array($paths);
}
$filename = null;
- foreach ($paths as $path) {
+ if (Event::handle('StartDocFileForTitle', array($title, &$paths, &$filename))) {
- $def = $path.'/'.$title;
- if (!file_exists($def)) {
- $def = null;
- }
+ foreach ($paths as $path) {
- $lang = glob($path.'/'.$title.'.*');
+ $def = $path.'/'.$title;
- if ($lang === false) {
- $lang = array();
- }
+ if (!file_exists($def)) {
+ $def = null;
+ }
+
+ $lang = glob($path.'/'.$title.'.*');
- if (!empty($lang) || !empty($def)) {
- $filename = self::negotiateLanguage($lang, $def);
- break;
+ if ($lang === false) {
+ $lang = array();
+ }
+
+ if (!empty($lang) || !empty($def)) {
+ $filename = self::negotiateLanguage($lang, $def);
+ break;
+ }
}
+
+ Event::handle('EndDocFileForTitle', array($title, $paths, &$filename));
}
if (empty($filename)) {
}
}
- function toHTML()
+ function toHTML($args=null)
{
+ if (is_null($args)) {
+ $args = array();
+ }
+
if (empty($this->contents)) {
$this->contents = file_get_contents($this->filename);
}
- $this->output = common_markup_to_html($this->contents);
+ return common_markup_to_html($this->contents, $args);
}
static function defaultPaths()
if (!empty($site)) {
array_unshift($paths, INSTALLDIR.'/local/doc-src/'.$site.'/');
}
+
+ return $paths;
+ }
+
+ static function mailPaths()
+ {
+ $paths = array(INSTALLDIR.'/local/mail-src/',
+ 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)