/** * Getting module info * * @param string $module_name * @param string $app * @return array * @author Sergey Startsev */ public static function getModuleInfo($module_name, $app) { $root = afStudioUtil::getRootDir(); $module = array(); $module['text'] = $module_name; $module_dir = "{$root}/apps/{$app}/modules/{$module_name}"; $xmlNames = afStudioUtil::getFiles("{$module_dir}/config/", true, "xml"); $xmlPaths = afStudioUtil::getFiles("{$module_dir}/config/", false, "xml"); $securityPath = "{$module_dir}/config/security.yml"; $defaultActionPath = "{$module_dir}/actions/actions.class.php"; $module['type'] = 'module'; $module['app'] = $app; if (count($xmlNames) > 0) { $k = 0; $module['leaf'] = false; foreach ($xmlNames as $xk => $xmlName) { $actionPath = $defaultActionPath; $widgetName = pathinfo($xmlName, PATHINFO_FILENAME); $predictActions = "{$widgetName}Action.class.php"; $predictActionsPath = "{$module_dir}/actions/{$predictActions}"; if (file_exists($predictActionsPath)) { $actionPath = $predictActionsPath; } $module['children'][$k] = array('app' => $app, 'module' => $module_name, 'widgetUri' => "{$module_name}/{$widgetName}", 'type' => 'xml', 'text' => $widgetName, 'securityPath' => $securityPath, 'xmlPath' => $xmlPaths[$xk], 'actionPath' => $actionPath, 'actionName' => pathinfo($actionPath, PATHINFO_BASENAME), 'name' => $widgetName, 'leaf' => true); $k++; } } else { $module['leaf'] = true; $module['iconCls'] = 'icon-folder'; } return $module; }
/** * 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; }