示例#1
0
文件: Installer.php 项目: solve/admin
 public static function onPostPackageInstall(CommandEvent $event)
 {
     $projectRoot = realpath(__DIR__ . '/../../../..') . '/';
     $packageRoot = __DIR__ . '/';
     $appRoot = $projectRoot . 'app/Admin/';
     $io = $event->getIO();
     if ($io->askConfirmation('Would you like to install admin panel? (Y/n) ', true)) {
         if (!is_dir($projectRoot . 'app')) {
             die('Solve project is not found in ' . $projectRoot . ', exiting...');
         }
         $name = $io->ask('Enter the app name (admin): ', 'admin');
         $kernel = Kernel::getMainInstance();
         $appRoot = $projectRoot . 'app/' . ucfirst($name) . '/';
         $kernel->getEnvironment()->setProjectRoot($projectRoot);
         $config = DC::getProjectConfig();
         while ($name && $config->get('applications/' . $name)) {
             $name = $io->ask('Application exists, specify other name(or type exit): ');
         }
         $config->set('applications/' . $name, $name);
         $config->save();
     }
     if ($io->askConfirmation('Would you like to update assets? (Y/n) ', true)) {
         FSService::makeWritable($appRoot);
         FSService::makeWritable($projectRoot . 'web/admin/');
         FSService::copyRecursive($packageRoot . 'app/', $appRoot);
         FSService::copyRecursive($packageRoot . 'assets/', $projectRoot . 'web/admin/');
         exec('cd ' . $projectRoot . 'web/admin/ && npm install');
     }
 }
示例#2
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');
 }
示例#3
0
 public function buildTestStructure()
 {
     FSService::makeWritable(array(__DIR__ . '/project/app/Frontend/Controllers', __DIR__ . '/project/app/Frontend/Views', __DIR__ . '/project/app/Admin', __DIR__ . '/project/src/classes', __DIR__ . '/project/src/db', __DIR__ . '/project/src/helpers', __DIR__ . '/project/src/libs', __DIR__ . '/project/tmp/log', __DIR__ . '/project/tmp/cache'));
     $pdo = new \PDO('mysql:host=127.0.0.1', 'root', 'root');
     $pdo->query('create database if not exists test_project_db');
 }
示例#4
0
 public function saveAs($path)
 {
     $this->process();
     if (substr($path, -1) !== DIRECTORY_SEPARATOR) {
         $dirPath = substr($path, 0, strrpos($path, DIRECTORY_SEPARATOR));
     }
     FSService::makeWritable($dirPath);
     file_put_contents($path, $this->getImageData());
 }
示例#5
0
文件: Slot.php 项目: solve/slot
 /**
  * @param string $compileDir
  */
 public function setCompileDir($compileDir)
 {
     $this->_compileDir = $compileDir;
     $this->_tplVars = array();
     FSService::makeWritable($this->_compileDir);
 }
示例#6
0
 /**
  * @param Model|ModelCollection $caller
  * @param $alias
  * @param $filePath
  * @param array $sourceFileInfo
  * @throws \Exception
  */
 public function attachFileFromPath($caller, $alias, $filePath, $sourceFileInfo = array())
 {
     $this->requireModeSingle($caller);
     if (!is_file($filePath)) {
         throw new \Exception('File specified is not readable');
     }
     if (!array_key_exists($alias, $this->_config)) {
         throw new \Exception('There is no such alias ' . $alias);
     }
     if (!is_array($this->_config[$alias])) {
         $this->_config[$alias] = array();
     }
     $storeLocation = $this->_getAliasFolder($caller, $alias) . '/';
     FSService::makeWritable($storeLocation);
     if (empty($sourceFileInfo)) {
         $sourceFileInfo = FSService::getFileInfo($filePath);
     }
     $newFileExtension = $sourceFileInfo['ext'];
     $newFileName = md5($sourceFileInfo['name'] . time());
     if (!empty($this->_config[$alias]['name'])) {
         if ($this->_config[$alias]['name'] == 'original') {
             $newFileName = $sourceFileInfo['name'];
             while (is_file($storeLocation . $newFileName . $newFileExtension)) {
                 $newFileName .= '_1';
             }
         }
     }
     if (empty($this->_config[$alias]['multiple'])) {
         $filesToDelete = GLOB($storeLocation . '*.*');
         foreach ($filesToDelete as $file) {
             unlink($file);
         }
     }
     copy($filePath, $storeLocation . $newFileName . $newFileExtension);
     if (!empty($this->_config[$alias]['sizes'])) {
         $ip = new ImageProcessor($storeLocation . $newFileName . $newFileExtension);
         foreach ($this->_config[$alias]['sizes'] as $sizeAlias => $sizeInfo) {
             if (!is_array($sizeInfo)) {
                 $sizeInfo = array('size' => $sizeInfo);
             }
             $method = empty($sizeInfo['method']) ? 'fitOut' : $sizeInfo['method'];
             $params = explode('x', $sizeInfo['size']);
             if (!empty($sizeInfo['geometry'])) {
                 $params[] = $sizeInfo['geometry'];
             }
             call_user_func_array(array($ip, $method), $params);
             $ip->saveAs($storeLocation . $sizeAlias . '/' . $newFileName . $newFileExtension);
         }
     }
     $caller->_setRawFieldValue($alias, $this->getModelValue($storeLocation, $this->_config[$alias]));
 }
示例#7
0
 /**
  * Dumps current database data to YML files
  * @param string|array $models
  */
 public function dataDump($models = null)
 {
     if (!empty($models)) {
         if (!is_array($models)) {
             $models = array($models);
         }
     } else {
         $models = array_keys($this->_structures);
     }
     $data_dir = $this->_storagePath . 'data/';
     FSService::makeWritable($data_dir);
     foreach ($models as $model) {
         $model = ucfirst($model);
         $file_name = $data_dir . strtolower($model) . '.yml';
         if (!isset($this->_structures[$model])) {
             continue;
         }
         if (is_file($file_name)) {
             unlink($file_name);
         }
         $data = QC::create($this->_structures[$model]['table'])->execute();
         file_put_contents($file_name, Yaml::dump($data, 6, 2));
     }
 }
示例#8
0
 protected function createCV($params)
 {
     $appPath = DC::getEnvironment()->getApplicationRoot() . $params['app'];
     FSService::makeWritable($appPath . '/Views/' . strtolower($params['name']));
     FSService::makeWritable($appPath . '/Controllers/');
     $this->safeCreateFromTemplate($appPath . '/Controllers/' . $params['name'] . 'Controller.php', '_controller', $params);
     $this->safeCreateFromTemplate($appPath . '/Views/' . strtolower($params['name']) . '/default.slot', '_view_default', $params);
 }