/** * Get list of available controllers */ public function controllersAction() { $appPath = $this->_configMain['application_path']; $folders = File::scanFiles($this->_configMain->get('frontend_controllers'), false, true, File::Dirs_Only); $data = array(); if (!empty($folders)) { foreach ($folders as $item) { $name = basename($item); if (file_exists($item . '/Controller.php')) { $name = str_replace($appPath, '', $item . '/Controller.php'); $name = Utils::classFromPath($name); $data[] = array('id' => $name, 'title' => $name); } } } if ($this->_configMain->get('allow_externals')) { $config = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php'); $eExpert = new Externals_Expert($this->_configMain, $config); $classes = $eExpert->getClasses(); $extControllers = $eExpert->getFrontendControllers(); if (!empty($extControllers)) { $data = array_merge($data, array_values($extControllers)); } } Response::jsonSuccess($data); }
/** * Files list */ public function fslistAction() { $path = Request::post('node', 'string', ''); $path = str_replace('.', '', $path); $dirPath = $this->_config->get('controllers'); if (!is_dir($dirPath)) { Response::jsonArray(array()); } if (!strlen($path)) { $files = array($dirPath . 'Backend', $dirPath . 'Frontend'); } else { $files = File::scanFiles($dirPath . $path, array('.php'), false, File::Files_Dirs); } if (empty($files)) { Response::jsonArray(array()); } sort($files); $list = array(); foreach ($files as $k => $fpath) { $text = basename($fpath); if ($text === '.svn') { continue; } $obj = new stdClass(); $obj->id = str_replace($dirPath, '', $fpath); $obj->text = $text; if ($obj->text === 'Controller.php') { $controllerName = str_replace(array($dirPath, DIRECTORY_SEPARATOR), array('', '_'), substr($fpath, 0, -4)); $obj->url = Backend_Designer_Code::getControllerUrl($controllerName); } else { $obj->url = ''; } if (is_dir($fpath)) { $obj->expanded = false; $obj->leaf = false; } else { if ($text !== 'Controller.php') { continue; } $obj->leaf = true; } $list[] = $obj; } if ($this->_configMain->get('allow_externals') && $path == '') { $config = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php'); $eExpert = new Externals_Expert($this->_configMain, $config); $list[] = $eExpert->getControllersTree(); } Response::jsonArray($list); }
/** * Get list of registered objects (names only) * @return array */ public function getRegisteredObjects() { if (is_null(self::$_objects)) { $paths = File::scanFiles(Db_Object_Config::getConfigPath(), array('.php'), false, File::Files_Only); self::$_objects = array(); if (!empty($paths)) { foreach ($paths as $path) { self::$_objects[] = substr(basename($path), 0, -4); } } /* * Scan for External objects */ if (self::$_externalsExpert) { $objects = self::$_externalsExpert->getObjects(); if (!empty($objects)) { self::$_objects = array_merge(self::$_objects, array_keys($objects)); } } } return self::$_objects; }
/** * List defined Blocks */ public function classlistAction() { $blocksPath = $this->_configMain['blocks']; $classesPath = $this->_configMain['application_path']; $files = File::scanFiles($blocksPath, array('.php'), true, File::Files_Only); foreach ($files as $k => $file) { $class = Utils::classFromPath(str_replace($classesPath, '', $file)); if ($class != 'Block_Abstract') { $data[] = array('id' => $class, 'title' => $class); } } if ($this->_configMain->get('allow_externals')) { $config = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php'); $eExpert = new Externals_Expert($this->_configMain, $config); $extBlocks = $eExpert->getBlocks(); if (!empty($extBlocks)) { foreach ($extBlocks as $class => $path) { $data[] = array('id' => $class, 'title' => $class); } } } Response::jsonSuccess($data); }
/** * Get template path * The template is to searched for in the theme folder. * Otherwise, the system will attempt to load it from the template root folder * @param string $template - filename * @return string */ public function getTemplatePath($template) { /* * Check for external templates */ if ($this->_externalsExpert) { $templates = $this->_externalsExpert->getTemplates(); if (isset($templates[$template])) { return $templates[$template]; } } if (file_exists($this->getThemePath() . $template)) { return $this->getThemePath() . $template; } return $this->_templatesPath . $template; }
/** * Inerface projects list */ public function fslistAction() { $path = Request::post('node', 'string', ''); $config = $config = Config::factory(Config::File_Array, $this->_configMain['configs'] . 'designer.php'); $dirPath = $config->get('configs'); $list = array(); if (!is_dir($dirPath)) { Response::jsonArray(array()); } if ($path === '') { if ($this->_configMain->get('allow_externals')) { $config = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php'); $eExpert = new Externals_Expert($this->_configMain, $config); $extProjects = $eExpert->getProjects(); if (!empty($extProjects)) { foreach ($extProjects as $item) { $list[] = $item; } } } $path = $dirPath . $path; } $files = File::scanFiles($path, array('.dat'), false, File::Files_Dirs); /** * This is hard fix for windows */ if (DIRECTORY_SEPARATOR == '\\') { foreach ($files as &$v) { $v = str_replace('\\', '/', $v); $v = str_replace('//', '/', $v); } unset($v); } if (empty($files)) { Response::jsonArray(array()); } foreach ($files as $k => $fpath) { $text = basename($fpath); if ($text === '.svn') { continue; } $obj = new stdClass(); $obj->id = str_replace($this->_configMain->get('docroot'), './', $fpath); $obj->text = $text; if (is_dir($fpath)) { $obj->expanded = false; $obj->leaf = false; } else { $obj->leaf = true; } $list[] = $obj; } Response::jsonArray($list); }
/** * Get themes list */ public function themeslistAction() { $themes = File::scanFiles($this->_configMain->get('themes'), false, false, File::Dirs_Only); $result = array(); if (!empty($themes)) { foreach ($themes as $name) { $code = basename($name); if ($code[0] != '.') { $result[] = array('id' => $code, 'title' => $code); } } } if ($this->_configMain->get('allow_externals')) { $config = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php'); $eExpert = new Externals_Expert($this->_configMain, $config); $themes = $eExpert->getThemes(); if (!empty($themes)) { foreach ($themes as $k => $path) { $result[] = array('id' => $k, 'title' => $k); } } } Response::jsonSuccess($result); }
/** * Files list */ public function fslistAction() { $path = Request::post('node', 'string', ''); //$path = str_replace('.','', $path); $dirPath = $this->_config->get('configs'); if ($path === '') { $path = $dirPath . $path; } if (!is_dir($dirPath)) { Response::jsonArray(array()); } $files = File::scanFiles($path, array('.dat'), false, File::Files_Dirs); $list = array(); if (!empty($files)) { $dirs = array(); $pfiles = array(); foreach ($files as $k => $fpath) { $text = basename($fpath); if ($text === '.svn') { continue; } if (is_dir($fpath)) { $dirs[] = $fpath; } else { $pfiles[] = $fpath; } } if (!empty($dirs)) { sort($dirs); foreach ($dirs as $k => $fpath) { $text = basename($fpath); $obj = new stdClass(); $obj->id = str_replace($this->_configMain->get('docroot'), './', $fpath); $obj->text = $text; $obj->expanded = false; $obj->leaf = false; $list[] = $obj; } } if (!empty($pfiles)) { sort($pfiles); foreach ($pfiles as $k => $fpath) { $text = basename($fpath); $obj = new stdClass(); $obj->id = str_replace($this->_configMain->get('docroot'), './', $fpath); $obj->text = $text; $obj->leaf = true; $list[] = $obj; } } } if ($path == '') { if ($this->_configMain->get('allow_externals')) { $config = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php'); $eExpert = new Externals_Expert($this->_configMain, $config); $extProjects = $eExpert->getProjects(); if (!empty($extProjects)) { foreach ($extProjects as $item) { $list[] = $item; } } } } Response::jsonArray($list); }
protected function _getExternalsExpert() { if ($this->_externalsExpert) { return $this->_externalsExpert; } $config = Config::factory(Config::File_Array, $this->_config->get('configs') . 'externals.php'); if ($this->_cache) { Externals_Expert::setDefaultCache($this->_cache); } $this->_externalsExpert = new Externals_Expert($this->_config, $config); return $this->_externalsExpert; }