Example #1
0
 public function onEnvironmentUpdate(BaseEvent $event)
 {
     ConfigService::setConfigsPath(DC::getEnvironment()->getConfigRoot());
     ConfigService::loadAllConfigs();
     DC::getLogger()->setLogsPath(DC::getEnvironment()->getTmpRoot() . 'log');
     DC::getAutoloader()->registerSharedPath(DC::getEnvironment()->getUserClassesRoot(), true);
     DC::getAutoloader()->registerSharedPath(DC::getEnvironment()->getUserClassesRoot() . 'db/bases');
     DC::getAutoloader()->registerSharedPath(DC::getEnvironment()->getUserClassesRoot() . 'db/classes');
     DC::getAutoloader()->registerNamespaceSharedPaths(DC::getEnvironment()->getUserClassesRoot() . 'classes/', true);
     FilesAbility::setBaseStoreLocation(DC::getEnvironment()->getUploadRoot());
 }
Example #2
0
 protected static function putTestContent()
 {
     QC::executeSQL('SET FOREIGN_KEY_CHECKS = 0');
     QC::executeSQL('DROP TABLE IF EXISTS brands');
     $storagePath = __DIR__ . '/storage/';
     $mo = ModelOperator::getInstance($storagePath);
     $mo->generateBasicStructure('Brand');
     ModelStructure::getInstanceForModel('Brand')->addAbility('files', array('logo' => array('name' => 'original', 'multiple' => true), 'info' => array(), 'avatar' => array('sizes' => array('small' => array('size' => '100x100', 'method' => 'fitOut')))))->saveStructure();
     $mo->generateAllModelClasses();
     require_once $storagePath . 'bases/BaseBrand.php';
     require_once $storagePath . 'classes/Brand.php';
     $webRoot = __DIR__ . '/upload/';
     FilesAbility::setBaseStoreLocation($webRoot);
     FSService::setWebRoot($webRoot);
     FSService::unlinkRecursive($webRoot);
     $mo->updateDBForAllModels();
 }
Example #3
0
 public function uploadAction()
 {
     $tmpLocation = DC::getEnvironment()->getTmpRoot() . session_id() . '/' . $this->_moduleName . '/';
     FSService::makeWritable($tmpLocation);
     $sessionStorage = new SessionStorage(array(), 'file_storage_' . $this->_moduleName);
     $preview = array();
     $files = FilesAbility::reformatFilesArray($_FILES);
     foreach ($files as $index => $fileList) {
         $filesToSave = array();
         $fieldName = false;
         foreach ($fileList as $name => $info) {
             $location = $tmpLocation . $name . '/';
             FSService::makeWritable($location);
             move_uploaded_file($info['tmp_name'], $location . $info['name']);
             $filesToSave[] = $location . $info['name'];
             $preview[$name] = FSService::getFileInfo($location . $info['name']);
             $preview[$name]['link'] = 'admin/' . $this->_moduleName . '/tmp-file/?p=' . $preview[$name]['link'];
             $fieldName = $name;
         }
         if ($fieldName) {
             $sessionStorage->set($fieldName, $filesToSave);
         }
     }
     $this->setData($preview, 'preview');
 }