* @license PHP License * @package WB * @subpackage db */ WBClass::load('WBDatasource_FormAttribute'); /** * Populate form element's values with VFS folders * * * @version 0.1.0 * @package WB * @subpackage db */ class WBDatasource_FormAttribute_VFSExplorer extends WBDatasource_FormAttribute { /** * configuration parameter * @var array */ protected $config = array( 'user' => 'group', 'path' => '/', 'dir' => '0', ); /** * directory browser * @var WBVFS_Explorer */ protected $expl; /** * get attribute's value * * Use dicktionary to fetch list of values * * @param mixed $current actual attribute value * @return array */ protected function getAttributeValue($current) { $param = array( 'user' => $this->config['user'] ); $this->expl = WBClass::create('WBVFS_Explorer', $param); if (!is_array($current)) { $current = array(); } $list = $this->expl->lsDir($this->config['dir']); foreach ($list as $v => $l) { $current[] = array( 'value' => $l['id'], 'label' => $l['name'] ); } return $current; } }