/**
  * Getting files
  *
  * @param string $plugin 
  * @param string $modulename 
  * @param string $pro_name 
  * @return Array
  */
 public static function getFiles($plugin, $modulename, $pro_name)
 {
     $root_dir = afStudioUtil::getRootDir();
     $dir = "{$root_dir}/plugins/{$plugin}/modules/{$modulename}/config/";
     $base_mod_dir = "{$root_dir}/plugins/{$plugin}/modules/{$modulename}";
     $securityPath = "{$base_mod_dir}/config/security.yml";
     $defaultActionPath = "{$base_mod_dir}/actions/actions.class.php";
     $files = array();
     if (is_dir($dir)) {
         $handler = opendir($dir);
         while (($f = readdir($handler)) !== false) {
             if (!is_dir($dir . $f) && strpos($f, $pro_name) > 0) {
                 $actionPath = $defaultActionPath;
                 $widgetName = pathinfo($f, PATHINFO_FILENAME);
                 $predictActions = "{$widgetName}Action.class.php";
                 $predictActionsPath = "{$base_mod_dir}/actions/{$predictActions}";
                 if (file_exists($predictActionsPath)) {
                     $actionPath = $predictActionsPath;
                 }
                 $actionName = pathinfo($actionPath, PATHINFO_BASENAME);
                 $files[] = array('text' => $f, 'type' => 'xml', 'widgetUri' => $modulename . '/' . str_replace('.xml', '', $f), 'securityPath' => $securityPath, 'actionPath' => $actionPath, 'actionName' => $actionName, 'widgetName' => $widgetName, 'leaf' => true);
             }
         }
     }
     return $files;
 }
 /**
  * Getting description when command empty
  *
  * @return string
  * @author Sergey Startsev
  */
 protected function getDescription()
 {
     $files = sfFinder::type('file')->name('*.*')->in(afStudioUtil::getRootDir() . '/batch/');
     foreach ($files as $file) {
         $baseFiles[] = basename($file);
     }
     $result = $this->render('../batch/<file>') . afsRenderConsoleCommand::render('<b>Usage:</b> batch "file"<br><b>Found batches:</b> ' . implode('; ', $baseFiles), array('class' => 'afStudio_result_command'));
     return $result;
 }
 public function save()
 {
     $confData = $this->databaseConfTemplate;
     $param =& $confData['all']['propel']['param'];
     $param['dsn'] = $this->buildDsn($confData['all']['propel']['param']['dsn']);
     $param['username'] = $this->params['username'];
     $param['password'] = $this->params['password'];
     $param['persistent'] = isset($this->params['persistent']) ? true : false;
     $param['pooling'] = isset($this->params['pooling']) ? true : false;
     afStudioUtil::writeFile($this->databaseConfFilePath, $this->dumpYaml($confData));
     afsNotificationPeer::log('Database Settings have been modified', 'afStudioConf');
     if (is_readable($this->databaseConfFilePath)) {
         $result = true;
     } else {
         $result = false;
     }
     return $result;
 }
 public function build()
 {
     if ($this->request->hasParameter('type') && $this->request->getParameter('type') == 'save') {
         $params = $this->request->getPostParameters();
         unset($params['type']);
         $params['autodeploy'] = !isset($params['autodeploy']) ? false : true;
         $params['url'] = afStudioUtil::getHost();
         $this->setProjectParams($params);
         afStudioUtil::writeFile($this->projectConfFilePath, $this->dumpYaml($this->projectConfTemplate));
         $result['success'] = true;
         $result['message'] = 'Project Settings saved successfully';
         afsNotificationPeer::log('Project Settings have been modified', 'afStudioConf');
     } else {
         $result['success'] = true;
         $result['data'] = $this->getProjectParams();
     }
     return json_encode($result);
 }
 /**
  * Rename action name inside module
  *
  * @param string $name 
  * @param string $renamed 
  * @param string $module
  * @param string $place 
  * @param string $type 
  * @return boolean
  * @author Sergey Startsev
  */
 public static function renameAction($name, $renamed, $module, $place, $type)
 {
     $root = afStudioUtil::getRootDir();
     $afConsole = afStudioConsole::getInstance();
     $console = '';
     $module_dir = "{$root}/{$type}s/{$place}/modules/{$module}";
     $action_dir = "{$module_dir}/actions";
     $predictActions = "{$name}Action.class.php";
     $predictActionsPath = "{$module_dir}/actions/{$predictActions}";
     $oldName = "{$name}Action.class.php";
     $newName = "{$renamed}Action.class.php";
     $oldPath = "{$action_dir}/{$oldName}";
     $newPath = "{$action_dir}/{$newName}";
     if (file_exists($oldPath)) {
         $action = file_get_contents($oldPath);
         $action = str_ireplace("{$name}Action", "{$renamed}Action", $action);
         afStudioUtil::writeFile($oldPath, $action);
         return afsFileSystem::create()->rename($oldPath, $newPath);
     }
     return true;
 }
 /**
  * Updating template
  *
  * @return afResponse
  * @author Radu Topala
  * @author Sergey Startsev
  */
 public function processUpdate()
 {
     $response = afResponseHelper::create();
     if (!$this->hasParameter('template')) {
         return $response->success(false)->message("You should define template name");
     }
     $templateName = strtolower($this->getParameter('template'));
     $projectPath = sfConfig::get('sf_root_dir');
     $projectYmlName = '/config/project.yml';
     $projectYmlPath = $projectPath . $projectYmlName;
     $appFlowerPluginPath = $projectPath . '/plugins/appFlowerPlugin/';
     $appFlowerStudioPluginPath = $projectPath . '/plugins/appFlowerStudioPlugin/';
     $projectYml = sfYaml::load($projectYmlPath);
     $pluginTemplateYml = sfYaml::load(sfConfig::get('sf_root_dir') . '/plugins/appFlowerStudioPlugin/config/template.yml');
     if (file_exists($appFlowerPluginPath) && file_exists($appFlowerStudioPluginPath)) {
         $projectYml['project']['template'] = in_array($templateName, $pluginTemplateYml['template']['types']) ? $templateName : $pluginTemplateYml['template']['default'];
         if (afStudioUtil::writeFile($projectYmlPath, sfYaml::dump($projectYml, 4))) {
             return $response->success(true)->message('Template was set to ' . ucfirst($templateName));
         } else {
             return $response->success(false)->message('File ' . $projectYmlName . ' is not writable!');
         }
     }
     return $response->success(false)->message("The selected path doesn't contain any valid AppFlower project!");
 }
 /**
  * Getting full file path with replaces 'root' token 
  *
  * @param string $file 
  * @return string
  * @author Sergey Startsev
  */
 public static function getPath($file)
 {
     return str_replace(self::PATH_ROOT_IDENTIFICATOR, afStudioUtil::getRootDir(), $file);
 }
 /**
  * Export data for a model
  * 
  * @return afResponse
  * @author Radu Topala
  */
 protected function processExportData()
 {
     $model = new $this->modelName();
     $peer = $model->getPeer();
     $table = $peer::TABLE_NAME;
     $db = afStudioUtil::getDbParams();
     $backupDir = sfConfig::get('sf_root_dir') . '/data/sql/backup/';
     $backupFile = $backupDir . $table . '_' . time() . '.sql';
     $webFile = 'data/sql/backup/' . $table . '_' . time() . '.sql';
     $console_result = afStudioConsole::getInstance()->execute(array("mkdir {$backupDir}", "mysqldump -u{$db['username']} -p{$db['password']} {$db['dbname']} {$table} --no-create-info --lock-tables --quick --complete-insert > {$backupFile}"));
     return afResponseHelper::create()->success(true)->message("A data backup of {$this->modelName} model was created at <a href=\"/studio#file#{$webFile}\">./{$webFile}</a>")->console($console_result);
 }
 /**
  * Try to find action 
  *
  * @param string $action 
  * @param string $module 
  * @return mixed - array/boolean
  * @author Sergey Startsev
  */
 public static function find($action, $module)
 {
     $root_dir = afStudioUtil::getRootDir();
     foreach (array('app', 'plugin') as $type) {
         foreach (afStudioUtil::getDirectories("{$root_dir}/{$type}s/", true) as $place) {
             $modules_dir = "{$root_dir}/{$type}s/{$place}/modules";
             if (in_array($module, afStudioUtil::getDirectories($modules_dir, true))) {
                 if (in_array("{$action}.xml", afStudioUtil::getFiles("{$modules_dir}/{$module}/config/", true, "xml"))) {
                     return array('place' => $place, 'placeType' => $type);
                 }
             }
         }
     }
     return false;
 }
 /**
  * Rename module functionality
  * 
  * @return afResponse
  * @author Sergey Startsev
  */
 protected function processRename()
 {
     $type = $this->getParameter('type');
     $place = $this->getParameter('place');
     $name = $this->getParameter('name');
     $renamed = $this->getParameter('renamed');
     $permissions = new Permissions();
     $is_writable = $permissions->isWritable(sfConfig::get('sf_apps_dir') . '/' . $place . '/modules/');
     if ($is_writable !== true) {
         return $is_writable;
     }
     $response = afResponseHelper::create();
     $root = afStudioUtil::getRootDir();
     if (!afStudioModuleCommandHelper::isValidName($renamed)) {
         return afResponseHelper::create()->success(false)->message("Module name not valid, should contains only upper and lower case alphabet characters");
     }
     $oldDir = "{$root}/{$type}s/{$place}/modules/{$name}/";
     $newDir = "{$root}/{$type}s/{$place}/modules/{$renamed}/";
     if (file_exists($newDir)) {
         return $response->success(false)->message("Module <b>{$renamed}</b> already exists inside <b>{$place}</b> {$type}!");
     }
     afsFileSystem::create()->rename($oldDir, $newDir);
     // Rename in actions class
     afStudioModuleCommandHelper::renameAction($name, $renamed, $place, $type);
     if (!file_exists($oldDir) && file_exists($newDir)) {
         $console = afStudioConsole::getInstance()->execute(array('afs fix-perms', 'sf cc'));
         return $response->success(true)->message("Renamed module from <b>{$name}</b> to <b>{$renamed}</b> inside <b>{$place}</b> {$type}!")->console($console);
     }
     return $response->success(false)->message("Can't rename module from <b>{$name}</b> to <b>{$renamed}</b> inside <b>{$place}</b> {$type}!");
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connections = $this->getConnections($databaseManager);
     //$connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     $i = new afsDbInfo();
     $this->logSection('propel', 'Reading databases structure...');
     $ad = new AppData();
     $totalNbTables = 0;
     foreach ($connections as $name => $params) {
         $pdo = $databaseManager->getDatabase($name)->getConnection();
         $database = new Database($name);
         $platform = $this->getPlatform($databaseManager, $name);
         $database->setPlatform($platform);
         $database->setDefaultIdMethod(IDMethod::NATIVE);
         $parser = $this->getParser($databaseManager, $name, $pdo);
         //$parser->setMigrationTable($options['migration-table']);
         $parser->setPlatform($platform);
         $nbTables = $parser->parse($database);
         $ad->addDatabase($database);
         $totalNbTables += $nbTables;
         $this->logSection('propel', sprintf('  %d tables imported from database "%s"', $nbTables, $name), null, 'COMMENT');
     }
     if ($totalNbTables) {
         $this->logSection('propel', sprintf('%d tables imported from databases.', $totalNbTables));
     } else {
         $this->logSection('propel', 'Database is empty');
     }
     $this->logSection('propel', 'Loading XML schema files...');
     Phing::startup();
     // required to locate behavior classes...
     $this->schemaToXML(self::DO_NOT_CHECK_SCHEMA, 'generated-');
     $this->copyXmlSchemaFromPlugins('generated-');
     $appData = $this->getModels($databaseManager, true);
     $this->logSection('propel', sprintf('%d tables defined in the schema files.', $appData->countTables()));
     $this->cleanup(true);
     $this->logSection('sql-diff', 'Comparing databases and schemas...');
     $manager = new PropelMigrationManager();
     $manager->setConnections($connections);
     foreach ($ad->getDatabases() as $database) {
         $name = $database->getName();
         $filenameDiff = sfConfig::get('sf_data_dir') . "/sql/{$name}." . time() . ".diff.sql";
         $this->logSection('sql-diff', sprintf('  Comparing database "%s"', $name), null, 'COMMENT');
         if (!$appData->hasDatabase($name)) {
             // FIXME: tables present in database but not in XML
             continue;
         }
         $databaseDiff = PropelDatabaseComparator::computeDiff($database, $appData->getDatabase($name));
         if (!$databaseDiff) {
             //no diff
         }
         $this->logSection('sql-diff', sprintf('Structure of database was modified in datasource "%s": %s', $name, $databaseDiff->getDescription()));
         $platform = $this->getPlatform($databaseManager, $name);
         //up sql
         $upDiff = $platform->getModifyDatabaseDDL($databaseDiff);
         //down sql
         $downDiff = $platform->getModifyDatabaseDDL($databaseDiff->getReverseDiff());
         if ($databaseDiff) {
             $this->logSection('sql-diff', "Writing file {$filenameDiff}");
             afStudioUtil::writeFile($filenameDiff, $upDiff);
             if ($options['insert'] === true || $options['insert'] === 'true') {
                 $this->logSection('sql-diff', "Inserting sql diff");
                 $i->executeSql($upDiff, Propel::getConnection($name));
             }
             if ($options['build'] === true || $options['build'] === 'true') {
                 $this->logSection('sql-diff', 'Creating models from current schema');
                 $this->createTask('propel:build-model')->run();
                 $this->logSection('sql-diff', 'Creating forms from current schema');
                 $this->createTask('propel:build-forms')->run();
                 $this->logSection('sql-diff', 'Setting AppFlower project permissions');
                 $this->createTask('afs:fix-perms')->run();
                 $this->logSection('sql-diff', 'Creating AppFlower validator cache');
                 $this->createTask('appflower:validator-cache')->run(array('frontend', 'cache', 'yes'));
                 $this->logSection('sql-diff', 'Clearing Symfony cache');
                 $this->createTask('cc')->run();
             }
         }
     }
 }
 /**
  * Creating new action
  *
  * @param string $module 
  * @return afResponse
  * @author Sergey Startsev
  */
 private function createAction($module = self::MODULE)
 {
     $response = afResponseHelper::create();
     if ($this->isNew()) {
         return $response->success(false)->message("can't create action for new page. Please first create and save definition");
     }
     $name = $this->getName();
     $path = $this->getPageActionPath();
     $definition = afsPageModelTemplate::create()->action($name);
     if (file_exists($path)) {
         return $response->success(true)->message("Action for '{$name}' already exists");
     }
     if (afStudioUtil::writeFile($path, $definition)) {
         return $response->success(true)->message("Action has been successfully created");
     }
     return $response->success(false)->message("Can't create action file");
 }
 /**
  * Setting user collection
  * 
  * @param   array $definition 
  * @author Sergey Startsev
  */
 public static function setCollection(array $definition, $filePath = false)
 {
     afStudioUtil::writeFile(self::getCollectionPath($filePath), sfYaml::dump($definition));
 }
 /**
  * Getting grouped module list 
  *
  * @param string $type 
  * @return array
  * @author Sergey Startsev
  */
 public static function getGroupedList($type)
 {
     $root = afStudioUtil::getRootDir();
     $deprecated = $type == self::TYPE_PLUGIN ? afStudioPluginCommandHelper::getDeprecatedList() : array();
     $data = array();
     foreach (afStudioUtil::getDirectories("{$root}/{$type}s/", true) as $place) {
         if (in_array($place, $deprecated)) {
             continue;
         }
         foreach (afStudioUtil::getDirectories("{$root}/{$type}s/{$place}/modules/", true) as $module) {
             $data[] = array('value' => $module, 'text' => $module, 'group' => $place, 'type' => $type);
         }
     }
     return $data;
 }
 /**
  * Validate definition
  *
  * @param string $definition 
  * @return mixed - success: boolean, unsuccess: string - message error
  * @author Sergey Startsev
  */
 protected function doValidatePacked()
 {
     $definition = $this->getDefinition();
     $tempPath = tempnam(sys_get_temp_dir(), 'studio_wi_wb') . '.xml';
     afStudioUtil::writeFile($tempPath, $definition);
     $validator = new XmlValidator($tempPath);
     $status = $validator->validateXmlDocument();
     unlink($tempPath);
     $status = $validator->validateXmlDocument(true);
     if ($status[0] == self::IDENTIFICATOR_ERROR) {
         $return = trim($status[1]->getMessage());
     } else {
         $return = true;
     }
     return $return;
 }
 /**
  * Extract archive functionality
  *
  * @return afResponse
  * @author Sergey Startsev
  */
 protected function processUnarchive()
 {
     $file = $this->getParameter('file');
     $file = substr($file, 0, 4) == 'root' ? str_replace('root', afStudioUtil::getRootDir(), substr($file, 0, 4)) . substr($file, 4) : $file;
     if (!file_exists($file)) {
         return afResponseHelper::create()->success(false)->message("File that you try to extract doesn't exists");
     }
     $arch = new Archive_Tar("{$file}", 'gz');
     $status = $arch->extract(dirname($file));
     return afResponseHelper::create()->success($status)->message($status ? "File has been successfully extracted" : "File can't be extracted");
 }
;
var afStudioHost = { 
	name: '<?php 
echo afStudioConsole::getInstance()->getUnameShort();
?>
',
	user: '******' 
};
<?php 
$projectPath = sfConfig::get('sf_root_dir');
$projectInPath = explode('/', $projectPath);
unset($projectInPath[count($projectInPath) - 1]);
$projectInPath = implode('/', $projectInPath);
?>
var afProjectInPath = '<?php 
echo $projectInPath;
?>
';
var afTemplateConfig = <?php 
echo json_encode(afStudioUtil::getTemplateConfig());
?>
;
var afStudioProjectsManagementEnabled = <?php 
echo sfConfig::get('app_afs_projects_management_enabled') ? 'true' : 'false';
?>
;
</script>
 /**
  * Getting pages list from applications 
  * 
  * @return array
  * @author Sergey Startsev
  */
 private function getPagesList()
 {
     $sRealRoot = afStudioUtil::getRootDir();
     $data = array();
     $apps = afStudioUtil::getDirectories("{$sRealRoot}/apps/", true);
     foreach ($apps as $app) {
         $xmlNames = afStudioUtil::getFiles($sRealRoot . "/apps/{$app}/config/pages/", true, 'xml');
         $xmlPaths = afStudioUtil::getFiles($sRealRoot . "/apps/{$app}/config/pages/", false, 'xml');
         if (count($xmlNames) > 0) {
             foreach ($xmlNames as $xk => $page) {
                 $data[$app][] = array('text' => $page, 'xmlPath' => $xmlPaths[$xk], 'widgetUri' => 'pages/' . str_replace('.xml', '', $page));
             }
         }
     }
     return $data;
 }
 /**
  * Add plugin functionality
  * 
  * @return afResponse
  * @author Sergey Startsev
  */
 protected function processAdd()
 {
     $name = $this->getParameter('name');
     $root = sfConfig::get('sf_root_dir');
     $console = afStudioConsole::getInstance();
     $response = afResponseHelper::create();
     $filesystem = afsFileSystem::create();
     $permissions = new Permissions();
     $are_writable = $permissions->areWritable(array($root . "/plugins/"));
     if ($are_writable !== true) {
         return $are_writable;
     }
     $dir = "{$root}/plugins/{$name}";
     if (empty($name)) {
         return $response->success(false)->message('Please enter plugin name');
     }
     if (substr($name, -6) != 'Plugin') {
         return $response->success(false)->message("Plugin '{$name}' should Contains 'Plugin' in the end");
     }
     if (file_exists($dir)) {
         return $response->success(false)->message("Plugin '{$name}' already exists");
     }
     $dirs = array($dir, "{$dir}/config", "{$dir}/modules");
     foreach ($dirs as $dir) {
         $filesystem->mkdirs($dir);
     }
     if (file_exists($dir)) {
         // create config file with auto enable all modules in current plugin
         $created = afStudioUtil::writeFile("{$dir}/config/config.php", afStudioPluginCommandTemplate::config($name));
         $console_result = $console->execute(array('afs fix-perms', 'sf cc'));
         return $response->success(true)->message("Plugin '{$name}' successfully created")->console($console_result);
     }
     return $response->success(false)->message("Some problems to create dirs, please check permissions, and run fix-perms task");
 }
 /**
  * Getting prompt
  *
  * @return string
  * @author Sergey Startsev
  */
 private function getPrompt()
 {
     if (empty($this->prompt)) {
         $this->prompt = $this->getWhoami() . '@' . $this->getUnameShort() . ':' . '~/' . afStudioUtil::unRootify($this->getPwd()) . '$&nbsp;';
     }
     return $this->prompt;
 }
 /**
  * @author radu
  */
 public static function getTemplateConfig()
 {
     $pluginTemplateYml = sfYaml::load(sfConfig::get('sf_root_dir') . '/plugins/appFlowerStudioPlugin/config/template.yml');
     $projectYmlPath = sfConfig::get('sf_root_dir') . '/config/project.yml';
     $projectYml = sfYaml::load($projectYmlPath);
     if (isset($projectYml['project']['template'])) {
         $pluginTemplateYml['template']['current'] = $projectYml['project']['template'];
     } else {
         $pluginTemplateYml['template']['current'] = $pluginTemplateYml['template']['default'];
         $projectYml['project']['template'] = $pluginTemplateYml['template']['default'];
         afStudioUtil::writeFile($projectYmlPath, sfYaml::dump($projectYml, 4));
     }
     return $pluginTemplateYml;
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     if (strtolower(substr(PHP_OS, 0, 3)) !== 'win') {
         $root_dir = sfConfig::get('sf_root_dir');
         if ($options['set_web_group'] == 'true' || $options['set_web_group'] === true) {
             $this->setWebGroup($options);
         }
         $command_log = array();
         $this->createFolders();
         $folders = $this->getFolders();
         foreach ($folders as $folder) {
             if ($this->isInPlaces($folder)) {
                 foreach (array('app', 'plugin') as $type) {
                     foreach (afStudioUtil::getDirectories("{$root_dir}/{$type}s/", true) as $place) {
                         $path = "{$root_dir}/{$type}s/{$place}" . $this->getFolderPath($folder);
                         $this->processFolder($folder, $path);
                     }
                 }
                 continue;
             }
             $this->processFolder($folder);
         }
         $this->log_it("Chmods:\n" . implode("\n", $command_log));
     }
 }
 /**
  * Saving schema
  * 
  * @param string $schema 
  * @return boolean
  */
 private function saveSchema($schema = '')
 {
     if (empty($schema)) {
         $schema = $this->getSchemaFile();
     }
     if (!array_key_exists($schema, $this->originalSchemaArray)) {
         return false;
     }
     return afStudioUtil::writeFile($schema, sfYaml::dump($this->originalSchemaArray[$schema], 3));
 }
 /**
  * Prepare command
  *
  * @return string
  * @author Sergey Startsev
  */
 protected function prepare()
 {
     $command = 'appflower:' . substr($this->getCommand(), 10);
     return sprintf('%s "%s" %s', $this->getCli(), afStudioUtil::getRootDir() . '/symfony', $command);
 }
 /**
  * Replaces tokens in an array of files.
  *
  * @param array  $files       An array of filenames
  * @param string $beginToken  The begin token delimiter
  * @param string $endToken    The end token delimiter
  * @param array  $tokens      An array of token/value pairs
  */
 public function replaceTokens($files, $beginToken, $endToken, array $tokens)
 {
     if (!is_array($files)) {
         $files = array($files);
     }
     foreach ($files as $file) {
         $content = file_get_contents($file);
         foreach ($tokens as $key => $value) {
             $content = str_replace($beginToken . $key . $endToken, $value, $content, $count);
         }
         afStudioUtil::writeFile($file, $content);
     }
 }
Exemple #26
0
<?php

ini_set("max_execution_time", "160");
require_once dirname(__DIR__) . '/lib/vendor/autoload/UniversalClassLoader.class.php';
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array('AppFlower\\Studio' => dirname(__DIR__) . '/lib/vendor'));
$loader->registerNamespaceFallbacks(array(dirname(__DIR__) . '/lib'));
$loader->register();
$this->dispatcher->connect('routing.load_configuration', array('afsRouting', 'listenToRoutingLoadConfigurationEvent'));
$modules = afStudioUtil::getDirectories(sfConfig::get('sf_plugins_dir') . "/appFlowerStudioPlugin/modules/", true);
sfConfig::set('sf_enabled_modules', array_merge(sfConfig::get('sf_enabled_modules'), $modules));
/**
 * setting the layout
 */
sfConfig::set('symfony.view.appFlowerStudio_studio_layout', sfConfig::get('sf_plugins_dir') . '/appFlowerStudioPlugin/templates/layout');
sfConfig::set('symfony.view.appFlowerStudio_preview_layout', sfConfig::get('sf_plugins_dir') . '/appFlowerStudioPlugin/templates/layout');
 /**
  * Export project functionality
  *
  * @return afResponse
  * @author Sergey Startsev
  */
 protected function processExport()
 {
     // ini set for windows
     ini_set("max_execution_time", "300");
     $response = afResponseHelper::create();
     $by_os = $this->getParameter('by_os', 'true');
     $type = $this->getParameter('type', 'project');
     $path = $this->getParameter('path', sys_get_temp_dir());
     if (substr($path, -1, 1) != DIRECTORY_SEPARATOR) {
         $path .= DIRECTORY_SEPARATOR;
     }
     $name = $this->getParameter('name', pathinfo(afStudioUtil::getRootDir(), PATHINFO_BASENAME));
     $console_result = afStudioConsole::getInstance()->execute("sf afs:export --type={$type} --by_os={$by_os} --path={$path} --project_name={$name}");
     $postfix = $type == 'db' ? 'sql' : 'tar.gz';
     if (!file_exists("{$path}{$name}.{$postfix}")) {
         return $response->success(false)->message('Please check permissions, and propel settings');
     }
     return $response->success(true)->data(array(), array('name' => $name, 'file' => "{$name}.{$postfix}", 'path' => $path), 0)->console($console_result);
 }
 /**
  * Rename model content
  *
  * @param string $path 
  * @param string $name 
  * @param string $renamed 
  * @return bool
  * @author Sergey Startsev
  */
 public static function renameModelContent($path, $name, $renamed)
 {
     $content = file_get_contents($path);
     $content = str_ireplace($name, $renamed, $content);
     return afStudioUtil::writeFile($path, $content);
 }
 /**
  * checks if action file exists
  * if not - we are createing new action file
  * 
  * @return boolean
  * @author Lukasz Wojciechowski
  * @author Sergey Startsev
  * @author Radu Topala
  */
 private function ensureActionExists()
 {
     if (!$this->ensureFolderExists($this->getPlaceActionsPath())) {
         return false;
     }
     $action_file_name = "{$this->getAction()}Action.class.php";
     $action_file_path = $this->getPlaceActionsPath() . DIRECTORY_SEPARATOR . $action_file_name;
     if (!file_exists($action_file_path)) {
         afStudioUtil::writeFile($action_file_path, afsWidgetModelTemplate::create()->action($this->getAction(), $this->getType(), $this->getModel()));
     }
     //if list action is generated, then also generate delete action
     if ($this->getType() == 'list') {
         $modelProcessed = lcfirst(sfInflector::camelize($this->getModel()));
         $delete_action_file_name = "{$modelProcessed}DeleteAction.class.php";
         $delete_action_file_path = $this->getPlaceActionsPath() . DIRECTORY_SEPARATOR . $delete_action_file_name;
         if (!file_exists($delete_action_file_path)) {
             afStudioUtil::writeFile($delete_action_file_path, afsWidgetModelTemplate::create()->action($modelProcessed . 'Delete', 'delete', $this->getModel()));
         }
     }
     return file_exists($action_file_path);
 }