/** * Get module list * * @return afResponse */ protected function processGetList() { $root = afStudioUtil::getRootDir(); $data = array(); $apps = afStudioUtil::getDirectories("{$root}/apps/", true); $i = 0; foreach ($apps as $app) { $data[$i]['text'] = $app; $data[$i]['type'] = 'app'; foreach (afStudioUtil::getDirectories("{$root}/apps/{$app}/modules/", true) as $module) { $data[$i]['children'][] = afStudioModuleCommandHelper::getModuleInfo($module, $app); } $i++; } return afResponseHelper::create()->success(true)->data(array(), $data, 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');
/** * 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; }
/** * 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; }
/** * 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; }
/** * @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)); } }