public function selectData(CustomExternalFieldData &$data) { $path = $this->getUploadDir(); $dir = new Folder($path); $files = $dir->getFiles(); foreach ($files as $key => $file) { $files[$key] = new GalleryImage($path, $file->name()); } $data->setData(null, $files); }
<?php require SYSPATH . '/helpers/Folder' . EXT; /** * Bootstrap File */ /** * Getting all config files, * check application directory first then the system directory. */ $config_dir = 'config/'; $files = Folder::getFiles(SYSPATH . $config_dir); foreach ($files as $file) { $ext = end(explode('.', $file)); if ($ext === 'php') { if (file_exists(APPPATH . $config_dir . $file)) { include APPPATH . $config_dir . $file; } else { include SYSPATH . $config_dir . $file; } } } // Set default controller and action define('DEFAULT_CONTROLLER', $route['_default']); define('DEFAULT_ACTION', 'index'); // Load core files require SYSPATH . '/core/Model' . EXT; require SYSPATH . '/core/View' . EXT; require SYSPATH . '/core/Controller' . EXT; require SYSPATH . '/helpers/Inflector' . EXT; require SYSPATH . '/core/Benchmark' . EXT;
<?php $MODULE = array('getFiles' => function () { $path = post('path'); $FOLDER = new Folder($path); return array('files' => $FOLDER->getFiles(function ($file) use($FOLDER) { return $file->path != $FOLDER->path; }, function ($file) { return $file->toArray(); }), 'info' => $FOLDER->toFileArray()); }, 'newFile' => function () { $path = post('path'); return array('error' => File::create($path)); }, 'newFolder' => function () { $path = post('path'); return array('error' => Folder::create($path)); }, 'delete' => function () { $path = post('path'); $err = _is_dir($path) ? Folder::delete($path) : File::delete($path); return array('error' => $err); }, 'unlock' => function () { $path = post('path'); return array('error' => File::unlock($path)); });