Hi Mark,
Thanks for answering...
modx-tree-directory does not fit what I want because it shows files inside directories... I just want to show the folders/subfolders not the files inside them....
I desperatly try to fill a combo with a JSON array return by a processor extending modProcessor, I get the list of folders as I want in my processor but can't figure out how to display it in my combo...
Maybe you have some ideas...
code in the window
[...]
{
xtype: 'picman-combo-folders',
fieldLabel: 'Folder',
name: 'name',
hiddenName: 'name',
anchor: '100%'
}
code of combo
Picman.combo.Folders = function(config){
config = config || {};
Ext.applyIf(config,{
id: 'picman-combo-folders',
url: Picman.config.connectorUrl,
baseParams: {
action: 'mgr/images/getListFolder'
},
store: new Ext.data.JsonStore({
autoLoad: true,
url: Picman.config.connectorUrl,
baseParams: {
action: 'mgr/images/getListFolder'
},
id:0, // these lines are my problem what is the 'field' I call regarding my processor ?
fields: ['name'],
displayField: 'name',
valueField: 'name'
//
})
});
Picman.combo.Folders.superclass.constructor.call(this, config);
};
Ext.extend(Picman.combo.Folders,MODx.combo.ComboBox);
Ext.reg('picman-combo-folders',Picman.combo.Folders);
processor code
class picmanGetListFolderProcessor extends modProcessor {
public function process() {
$assetspath = $this->modx->config['assets_path'];
$dir = $assetspath . 'master/img';
$stack[] = $dir;
while ($stack) {
$thisdir = array_pop($stack);
if ($dircont = scandir($thisdir)) {
$i = 0;
while (isset($dircont[$i])) {
if ($dircont[$i] !== '.' && $dircont[$i] !== '..') {
$current_file = "{$thisdir}/{$dircont[$i]}";
//$this->modx->log(modX::LOG_LEVEL_ERROR, ' - curfile :' . $current_file);
if (is_file($current_file)) {
$path[] = "";
} elseif (is_dir($current_file)) {
$path[] = "{$thisdir}/{$dircont[$i]}";
$stack[] = $current_file;
}
}
$i++;
}
}
}
$lp = count($path);
$this->modx->log(modX::LOG_LEVEL_ERROR, 'lp :' . $lp);
for ($x = 0; $x < $lp; $x++) {
$suppr = $assetspath . master/img/';
$this->modx->log(modX::LOG_LEVEL_ERROR, $x . ' - path :' . $path[$x]);
$fold = $path[$x];
$this->modx->log(modX::LOG_LEVEL_ERROR, $x . ' - fold :' . $fold);
if ($fold != '') {
$folder = str_replace($suppr, '', $fold);
$this->modx->log(modX::LOG_LEVEL_ERROR, $x . ' - folder :' . $folder);
$myArray[] = $folder;
}
}
$this->modx->log(modX::LOG_LEVEL_ERROR, 'path ' . print_r($myArray));
// Prints :
// Array
// (
// [0] => abc
// [1] => def
// [2] => ghij
// [3] => klm
// [4] => mnop
// [5] => mnop/abcd
// [6] => mnop/efgh
// [7] => mnop/ijkl
// )
return $this->toJSON($myArray);
// in FF it gives (which is correct I think):
// ["abc","def","ghij","klm","mnop","mnop\/abcd","mnop\/efgh","mnop\/ijkl"]
}
}
return 'picmanGetListFolderProcessor';
And my combo still empty...
Any help would be appreciated...
Cheers
[ed. note: anso last edited this post 14 years, 6 months ago.]