public function Menu::parseURL in Forena Reports 7.5
Same name and namespace in other branches
- 8 src/Menu.php \Drupal\forena\Menu::parseURL()
Convert url into file paths based report name. Load all link data for the reprot. Most report urls look like a java lassname, so urls are of the form lang.subdir.anothersubdir.report.doctype. This function parses the url into it's components and store them in the menu object so that we can use this name.
Parameters
$url path style name:
File
- src/
Menu.php, line 54 - Menu.inc Drupal menu builder @author davidmetzler
Class
Namespace
Drupal\forenaCode
public function parseURL($url) {
global $language;
$name = $url;
$tlang = '';
// Determine if the report has an extention that is one of the docuemnt types
$p = pathinfo($url);
if (isset($p['extension']) && array_search($p['extension'], $this->doc_formats) !== FALSE) {
$name = $p['dirname'] == '.' ? $p['filename'] : $p['dirname'] . '/' . $p['filename'];
$format = $p['extension'];
}
else {
$format = 'web';
$ext = '';
}
// Convert class names to directory names.
$base_name = str_replace('.', '/', $name);
$name = $base_name;
$i_name = $base_name;
// Determine lanugage from url or drupal language interface.
$lang = $language->language;
if (module_exists('locale')) {
//First check to see if the report allready has a language in it
@(list($tlang, $tbase_name) = explode('/', $base_name, 2));
// FInd out if the starting name of the report is an installed language.
$lang_list = language_list();
if (array_key_exists($tlang, $lang_list)) {
$base_name = $tbase_name;
if ($lang != $tlang) {
$lang = $tlang;
$language = $lang_list[$lang];
$i_name = $tlang . '/' . $base_name;
}
if ($tlang == 'en') {
$name = $base_name = $tbase_name;
}
}
else {
if ($lang != 'en') {
$def_language = language_default('language');
if (Frx::File()
->exists("{$lang}/{$name}.frx")) {
$name = "{$lang}/{$name}";
}
elseif ($def_language != 'en' && Frx::File()
->exists("{$def_language}/{$name}.frx")) {
$name = "{$def_language}/{$name}";
$lang = $def_language;
}
}
}
}
//$name = trim(str_replace('.', '/', $base_name), '/');
$filename = $name . '.frx';
$desc['name'] = $this->name = $name;
$desc['directory'] = Frx::File()
->directory($filename);
$desc['filename'] = $filename;
$desc['base_name'] = $this->base_name = $base_name;
$desc['exists'] = Frx::File()
->exists($filename);
$desc['link'] = $this->link = 'reports/' . str_replace('/', '.', $name);
$desc['i_link'] = 'reports/' . ($this->i_link = str_replace('/', '.', $i_name));
$desc['language'] = $this->language = $lang;
$desc['format'] = $this->format = $format;
return $desc;
}