Skip to content

Commit

Permalink
Fix issues with filemanager_path/url in non-web contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaun McCormick committed May 11, 2011
1 parent 30d5538 commit 339e489
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions core/model/modx/modfilehandler.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ public function make($path, array $options = array(), $overrideClass = '') {
/**
* Get the modX base path for the user.
*
* @param string $prependBasePath If true, will prepend the modX base path
* to the return value. Defaults to true.
* @return string The base path
*/
public function getBasePath() {
Expand All @@ -76,6 +74,8 @@ public function getBasePath() {

/**
* Get base URL of file manager
*
* @return string The base URL
*/
public function getBaseUrl() {
$baseUrl = $this->context->getOption('filemanager_url', $this->context->getOption('rb_base_url', MODX_BASE_URL, $this->config), $this->config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
return $modx->error->failure($modx->lexicon('permission_denied'));
}
$params['wctx'] = $workingContext->get('key');
$modx->fileHandler->context =& $workingContext;
} else {
$params['wctx'] = $modx->context->get('key');
$workingContext =& $modx->context;
}

$value = $this->get('value');
Expand All @@ -37,15 +39,15 @@
if (empty($params['basePath'])) {
$params['basePath'] = $modx->fileHandler->getBasePath();
$params['basePath'] = str_replace($replaceKeys,$replaceValues,$params['basePath']);
$params['basePathRelative'] = $this->xpdo->getOption('filemanager_path_relative',null,true) ? 1 : 0;
$params['basePathRelative'] = $workingContext->getOption('filemanager_path_relative',true) ? 1 : 0;
} else {
$params['basePath'] = str_replace($replaceKeys,$replaceValues,$params['basePath']);
$params['basePathRelative'] = !isset($params['basePathRelative']) || in_array($params['basePathRelative'],array('true',1,'1'));
}
if (empty($params['baseUrl'])) {
$params['baseUrl'] = $modx->fileHandler->getBaseUrl();
$params['baseUrl'] = str_replace($replaceKeys,$replaceValues,$params['baseUrl']);
$params['baseUrlRelative'] = $this->xpdo->getOption('filemanager_url_relative',null,true) ? 1 : 0;
$params['baseUrlRelative'] = $workingContext->getOption('filemanager_url_relative',true) ? 1 : 0;
} else {
$params['baseUrl'] = str_replace($replaceKeys,$replaceValues,$params['baseUrl']);
$params['baseUrlRelative'] = !isset($params['baseUrlRelative']) || in_array($params['baseUrlRelative'],array('true',1,'1'));
Expand All @@ -64,7 +66,6 @@
} else {
$relativeValue = $value;
}

if (!empty($value) && strpos($value,'/') !== false) {
$dir = pathinfo($value,PATHINFO_DIRNAME);
$dir = rtrim($dir,'/').'/';
Expand Down
3 changes: 3 additions & 0 deletions manager/controllers/default/resource/tvs.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
$resourceClass = $resource->get('class_key');
$resourceDir= strtolower(substr($resourceClass, 3));
$resourceId = !empty($resource) ? $resource->get('id') : 0;
if ($resource && $resource instanceof modResource) {
$_GET['wctx'] = $resource->get('context_key');
}

$onResourceTVFormPrerender = $modx->invokeEvent('OnResourceTVFormPrerender',array(
'resource' => $resourceId,
Expand Down

0 comments on commit 339e489

Please sign in to comment.