public function autoInstallExtensions() { $path = $this->app_plugins_dir . DS . $this->plugin_name . DS . 'extensions'; $extensionFiles = AkFileSystem::dir($path, array('recurse' => true, 'skip_path_restriction' => true)); foreach ($extensionFiles as $extensionFile) { $this->installExtensions('extensions' . DS . $extensionFile); } }
public function test_should_get_all_controllers_with_their_actions() { $available_controllers = (array) AkFileSystem::dir(AkConfig::getDir('controllers'), array('dirs' => false)); $got = $this->menu_helper->_get_default_full_menu(); foreach ($available_controllers as $controller_filename) { $controller_name = str_replace('_controller.php', '', $controller_filename); $this->assertTrue(isset($got[$controller_name])); } $this->assertTrue(in_array('authenticate', $got['authentication'])); }
public function __construct($options) { $default_options = array('source' => $this->getAbsolutePath(dirname(__FILE__) . DIRECTORY_SEPARATOR . str_repeat(DIRECTORY_SEPARATOR . '..', 4) . DIRECTORY_SEPARATOR . 'app_layout'), 'force' => false, 'skip' => false, 'quiet' => false, 'public_html' => false); $this->options = array_merge($default_options, $options); $this->options['directory'] = $this->getAbsolutePath(@$this->options['directory']); if (empty($this->options['directory'])) { trigger_error('You must supply a valid destination path', E_USER_ERROR); } $this->source_tree = AkFileSystem::dir($this->options['source'], array('dirs' => true, 'recurse' => true)); $this->destination_tree = AkFileSystem::dir($this->options['directory'], array('dirs' => true, 'recurse' => true)); }
public function _getMenuOptionsForControllersInModule($type = 'admin') { $controllers = AkFileSystem::dir(AK_CONTROLLERS_DIR . DS . $this->_controller->getModuleName(), array('dirs' => false)); sort($controllers); $menu_options = array(); foreach ($controllers as $controller) { $controller_name = substr($controller, 0, -15); $menu_options[AkInflector::titleize($controller_name)] = array('id' => $controller_name, 'url' => array('controller' => $controller_name)); } $options_file = $this->_getMenuOptionsFile($type); if (!file_exists($options_file)) { AkFileSystem::file_put_contents(AK_CONFIG_DIR . DS . $options_file, Ak::convert('array', 'yaml', array('default' => $menu_options))); } return $menu_options; }
public function _get_default_full_menu() { $controllers_dir = AkConfig::getDir('controllers'); $controller_file_names = array_map('array_pop', (array) AkFileSystem::dir($controllers_dir, array('files' => false))); sort($controller_file_names); $menu_options = array(); foreach ($controller_file_names as $controller_file_name) { $controller_name = str_replace('.php', '', $controller_file_name); if (strstr($controller_file_name, '_controller.php') && file_exists($controllers_dir . DS . $controller_file_name)) { include_once $controllers_dir . DS . $controller_file_name; $controller_class_name = AkInflector::classify($controller_name); $menu_options[str_replace('_controller', '', $controller_name)] = $this->_get_this_class_methods($controller_class_name); } } return $menu_options; }
public function absolutizeStaticAssetFilePaths($files_dir, $relative_url = '/') { if ($relative_url == '/') { return; } $relative_url = str_replace('//', '/', '/' . trim($relative_url, '/') . '/'); $replacements = array('url(/images' => 'url(' . $relative_url . 'images', 'url(\'/images' => 'url(\'' . $relative_url . 'images', 'url("/images' => 'url("' . $relative_url . 'images', 'src="/images/' => 'src="' . $relative_url . 'images/', 'src=\'/images/' => 'src=\'' . $relative_url . 'images/', 'src="/javascrips/' => 'src="' . $relative_url . 'javascrips/', 'src=\'/javascrips/' => 'src=\'' . $relative_url . 'javascrips/', 'type="text/css" href="/stylesheets' => 'type="text/css" href="' . $relative_url . 'stylesheets', 'type=\'text/css\' href=\'/stylesheets' => 'type=\'text/css\' href=\'' . $relative_url . 'stylesheets'); $keys = array_keys($replacements); $values = array_values($replacements); $this->files = AkFileSystem::dir($files_dir, array('recurse' => true)); empty($this->options['force']) ? $this->_checkForModified($this->files, $files_dir, $files_dir) : null; $installed_files = $this->_getInstalledFiles($this->files, $files_dir, $files_dir); foreach ($installed_files as $installed_file) { if (preg_match('/\\.(js|css|html)$/', $installed_file)) { $contents = str_replace($keys, $values, file_get_contents($installed_file)); file_put_contents($installed_file, $contents); } } }
protected function _getAvailableTemplates() { $path = $this->ActionMailer->getTemplatePath(); if (!isset($templates[$path])) { $templates[$path] = array_map('basename', AkFileSystem::dir($path, array('dirs' => false))); } return $templates[$path]; }
/** * Loads a list of existing plugins to $this->_available_plugins by inspecting the plugins directory. * * @return void * @access private */ public function _findPlugins() { $plugin_dirs = AkFileSystem::dir(AK_PLUGINS_DIR, array('dirs' => true, 'files' => false)); $this->_available_plugins = array(); foreach ($plugin_dirs as $plugin_dir) { $plugin_dir = array_pop($plugin_dir); if ($plugin_dir[0] != '.') { $this->_available_plugins[] = $plugin_dir; } } }
public function test_dir_should_not_recurse_when_set_to_false() { $files_and_dirs = AkFileSystem::dir(AK_FRAMEWORK_DIR, array('dirs' => true, 'recurse' => false)); foreach ($files_and_dirs as $k => $file_or_dir) { if (is_array($file_or_dir)) { $this->assertEqual(count($files_and_dirs[$k]), 1); } } }
private function _getGeneratorsInsidePath($path) { $generators = array(); if (is_dir($path)) { foreach (AkFileSystem::dir($path, array('files' => false, 'dirs' => true)) as $folder) { $generator = Ak::first(array_keys($folder)); if (strstr($generator, '.php') || is_file($path . DS . $generator)) { continue; } $generators[$path . DS . $generator . DS . $generator . '_generator.php'] = $generator; } } return $generators; }
$file = AkConfig::getDir('app') . DS . 'installers' . DS . rtrim(join('/', array_map(array('AkInflector', 'underscore'), explode('/', $installer . '/'))), '/') . '_installer.php'; function ak_print_available_installers($files, $preffix = '') { foreach ($files as $k => $file) { if (is_string($file)) { if (preg_match('/(.*)_installer\\.php$/', $file, $match)) { echo ' * ' . $preffix . $match[1] . "\n"; } } else { ak_print_available_installers($file, $k . '::'); } } echo "\n"; } if ($installer_class_name == 'Installer') { $files = AkFileSystem::dir(AkConfig::getDir('app') . DS . 'installers', array('recurse' => true)); if (empty($files)) { echo Ak::t("\n Could not find installers at %dir \n", array('%dir' => AkConfig::getDir('app') . DS . 'installers')); } else { echo Ak::t("\n You must supply a valid installer name like : \n"); echo Ak::t("\n > ./script/migrate my_installer_name install\n\n"); echo Ak::t(" Available installers are: \n\n"); ak_print_available_installers($files); } } elseif (!file_exists($file)) { echo Ak::t("\n\n Could not locate the installer file %file\n\n", array('%file' => $file)); } else { require_once $file; if (!class_exists($installer_class_name)) { echo Ak::t("\n\n Could not find load the installer. Class doesn't exists\n\n"); } else {
/** * @deprecated * @uses AkFileSystem::dir */ static function dir($path, $options = array()) { Ak::deprecateMethod(__METHOD__, 'AkFileSystem::dir()'); return AkFileSystem::dir($path, $options); }
public function getApplicationHelperNames() { $handler = $this->_Handler; $handler->app_helpers = !isset($handler->app_helpers) ? 'all' : $handler->app_helpers; $helpers_dir = AkConfig::getDir('helpers'); $helper_names = array(); if ($handler->app_helpers == 'all') { $available_helpers = AkFileSystem::dir($helpers_dir, array('dirs' => false)); $helper_names = array(); foreach ($available_helpers as $available_helper) { $helper_names[$helpers_dir . DS . $available_helper] = AkInflector::classify(substr($available_helper, 0, -10)); } } elseif (!empty($handler->app_helpers)) { foreach (Ak::toArray($handler->app_helpers) as $helper_name) { $helper_names[$helpers_dir . DS . AkInflector::underscore($helper_name) . '_helper.php'] = AkInflector::camelize($helper_name); } } return $helper_names; }