Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.4] Make absolute template paths work. #1688

Merged
1 commit merged into from
May 21, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/lib/legacy/Zikula/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,20 @@ public function _get_auto_filename($path, $auto_source = null, $auto_id = null,
$path .= !empty($auto_id) ? '/' . $auto_id : '';

// takes in account the source subdirectory
$path .= strpos($auto_source, '/') !== false ? '/' . dirname($auto_source) : '';
if ($auto_source) {
if (strpos($auto_source, 'file:') === 0) {
// This is an absolute path needing special handling.
$auto_source = substr($auto_source, 5);
$cwd = DataUtil::formatForOS(getcwd());
if (strpos($auto_source, $cwd) !== 0) {
throw new \RuntimeException('The template path cannot be outside the Zikula root.');
}

$path .= '/absolutepath' . substr(dirname($auto_source), strlen($cwd));
} else {
$path .= strpos($auto_source, '/') !== false ? '/' . dirname($auto_source) : '';
}
}

// make sure the path exists to write the compiled/cached template there
if (!file_exists($path)) {
Expand Down