/** * test that makeAbsolute adds on the CAKE_CORE_INCLUDE_PATH * * @return void */ function testMakeAbosolute() { $path = 'view/helpers/xml.php'; $roots = Configure::corePaths(); $result = $this->ApiConfig->makeAbsolute($path, $roots['libs']); $this->assertEqual($result, $roots['libs'][0] . $path); }
/** * Return all possible paths to find view files in order * * ※ _paths より直接呼び出されるようにする為だけに、Viewクラスより中身をコピー * * @param string $plugin * @return array paths * @access protected */ function __paths($plugin = null, $cached = true) { if ($plugin === null && $cached === true && !empty($this->__paths)) { return $this->__paths; } $paths = array(); $viewPaths = Configure::read('viewPaths'); $corePaths = array_flip(Configure::corePaths('view')); if (!empty($plugin)) { $count = count($viewPaths); for ($i = 0; $i < $count; $i++) { if (!isset($corePaths[$viewPaths[$i]])) { $paths[] = $viewPaths[$i] . 'plugins' . DS . $plugin . DS; } } $pluginPaths = Configure::read('pluginPaths'); $count = count($pluginPaths); for ($i = 0; $i < $count; $i++) { $paths[] = $pluginPaths[$i] . $plugin . DS . 'views' . DS; } } $paths = array_merge($paths, $viewPaths); if (empty($this->__paths)) { $this->__paths = $paths; } return $paths; }
function startup() { $appPaths = array_diff(Configure::read('modelPaths'), Configure::corePaths('model')); $this->models = Configure::listObjects('model', $appPaths, false); if (empty($this->params['src'])) { $this->params['src'] = ROOT . DS . 'src'; } }
function index() { if (!empty($this->data)) { $this->log("Trying To Save Settings:" . print_r($this->data, true), 'debug'); $this->SettingsHandler->setSettings('settings', $this->data); } $settings = $this->SettingsHandler->getSettings(); $this->log("Loading Settings:" . print_r($settings, true) . "\nCheck Paths:" . print_r(Configure::corePaths('cake'), true), 'debug'); $this->data = $settings; }
/** * Initialization method installs Simpletest and loads all plugins * * @return void * @access public */ function initialize() { $corePath = Configure::corePaths('cake'); if (isset($corePath[0])) { define('TEST_CAKE_CORE_INCLUDE_PATH', rtrim($corePath[0], DS) . DS); } else { define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH); } $this->__installSimpleTest(); require_once CAKE . 'tests' . DS . 'lib' . DS . 'test_manager.php'; require_once CAKE . 'tests' . DS . 'lib' . DS . 'cli_reporter.php'; $plugins = Configure::listObjects('plugin'); foreach ($plugins as $p) { $this->plugins[] = Inflector::underscore($p); } }
/** * Shortens file paths by replacing the application base path with 'APP', and the CakePHP core * path with 'CORE'. * * @param string $path Path to shorten * @return string Normalized path * @access public * @static */ function trimPath($path) { if (!defined('CAKE_CORE_INCLUDE_PATH') || !defined('APP')) { return $path; } if (strpos($path, APP) === 0) { return str_replace(APP, 'APP' . DS, $path); } elseif (strpos($path, CAKE_CORE_INCLUDE_PATH) === 0) { return str_replace(CAKE_CORE_INCLUDE_PATH, 'CORE', $path); } elseif (strpos($path, ROOT) === 0) { return str_replace(ROOT, 'ROOT', $path); } $corePaths = Configure::corePaths('cake'); foreach ($corePaths as $corePath) { if (strpos($path, $corePath) === 0) { return str_replace($corePath, 'CORE' . DS . 'cake' . DS, $path); } } return $path; }
if (!defined('WWW_ROOT')) { define('WWW_ROOT', dirname(__FILE__) . DS); } if (!defined('CORE_PATH')) { if (function_exists('ini_set') && ini_set('include_path', CAKE_CORE_INCLUDE_PATH . PATH_SEPARATOR . ROOT . DS . APP_DIR . DS . PATH_SEPARATOR . ini_get('include_path'))) { define('APP_PATH', null); define('CORE_PATH', null); } else { define('APP_PATH', ROOT . DS . APP_DIR . DS); define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); } } if (!(include CORE_PATH . 'cake' . DS . 'bootstrap.php')) { trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR); } $corePath = Configure::corePaths('cake'); if (isset($corePath[0])) { define('TEST_CAKE_CORE_INCLUDE_PATH', rtrim($corePath[0], DS) . DS); } else { define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH); } require_once CAKE_TESTS_LIB . 'test_manager.php'; if (Configure::read('debug') < 1) { die(__('Debug setting does not allow access to this url.', true)); } if (!isset($_SERVER['SERVER_NAME'])) { $_SERVER['SERVER_NAME'] = ''; } if (empty($_GET['output'])) { $_GET['output'] = 'html'; }
/** * Object destructor. * * Writes cache file if changes have been made to the $__map or $__paths * * @return void * @access private */ function __destruct() { if ($this->__cache) { $core = Configure::corePaths('cake'); unset($this->__paths[rtrim($core[0], DS)]); Cache::write('dir_map', array_filter($this->__paths), '_cake_core_'); Cache::write('file_map', array_filter($this->__map), '_cake_core_'); } }
/** * setUp method * * @access public * @return void */ function startTest() { $this->_get = $_GET; $_GET = array(); $this->_post = $_POST; $this->_files = $_FILES; $this->_server = $_SERVER; $this->_app = Configure::read('App'); Configure::write('App.base', false); Configure::write('App.baseUrl', false); Configure::write('App.dir', 'app'); Configure::write('App.webroot', 'webroot'); $this->_cache = Configure::read('Cache'); Configure::write('Cache.disable', true); $this->_vendorPaths = Configure::read('vendorPaths'); $this->_pluginPaths = Configure::read('pluginPaths'); $this->_viewPaths = Configure::read('viewPaths'); $this->_controllerPaths = Configure::read('controllerPaths'); $this->_debug = Configure::read('debug'); Configure::write('controllerPaths', Configure::corePaths('controller')); Configure::write('viewPaths', Configure::corePaths('view')); }
/** * buildPaths method * * @return void * @access protected */ function _buildPaths() { $this->paths = array('console' => array_pop(Configure::corePaths('cake')) . 'console' . DS . 'cake'); }
/** * Load fixtures specified in var $fixtures. * * @access private */ function _loadFixtures() { if (!isset($this->fixtures) || empty($this->fixtures)) { return; } if (!is_array($this->fixtures)) { $this->fixtures = array_map('trim', explode(',', $this->fixtures)); } $this->_fixtures = array(); foreach ($this->fixtures as $index => $fixture) { $fixtureFile = null; if (strpos($fixture, 'core.') === 0) { $fixture = substr($fixture, strlen('core.')); foreach (Configure::corePaths('cake') as $key => $path) { $fixturePaths[] = $path . DS . 'tests' . DS . 'fixtures'; } } elseif (strpos($fixture, 'app.') === 0) { $fixture = substr($fixture, strlen('app.')); $fixturePaths = array(TESTS . 'fixtures', VENDORS . 'tests' . DS . 'fixtures'); } elseif (strpos($fixture, 'plugin.') === 0) { $parts = explode('.', $fixture, 3); $pluginName = $parts[1]; $fixture = $parts[2]; $fixturePaths = array(APP . 'plugins' . DS . $pluginName . DS . 'tests' . DS . 'fixtures', TESTS . 'fixtures', VENDORS . 'tests' . DS . 'fixtures'); } else { $fixturePaths = array(TESTS . 'fixtures', VENDORS . 'tests' . DS . 'fixtures', TEST_CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'tests' . DS . 'fixtures'); } foreach ($fixturePaths as $path) { if (is_readable($path . DS . $fixture . '_fixture.php')) { $fixtureFile = $path . DS . $fixture . '_fixture.php'; break; } } if (isset($fixtureFile)) { require_once $fixtureFile; $fixtureClass = Inflector::camelize($fixture) . 'Fixture'; $this->_fixtures[$this->fixtures[$index]] =& new $fixtureClass($this->db); $this->_fixtureClassMap[Inflector::camelize($fixture)] = $this->fixtures[$index]; } } if (empty($this->_fixtures)) { unset($this->_fixtures); } }
/** * Returns default paths to search * * @param string $type type of object to be searched * @return array list of paths * @access private */ function __paths($type) { if (strtolower($type) === 'core') { $path = Configure::corePaths(); foreach ($path as $key => $value) { $count = count($key); for ($i = 0; $i < $count; $i++) { $paths[] = $path[$key][$i]; } } return $paths; } $paths = Configure::read(strtolower($type) . 'Paths'); if (empty($paths)) { if (strtolower($type) === 'plugin') { $paths = array(APP . 'plugins' . DS); } elseif (strtolower($type) === 'vendor') { $paths = array(APP . 'vendors' . DS, VENDORS, APP . 'plugins' . DS); } elseif (strtolower($type) === 'controller') { $paths = array(APP . 'controllers' . DS, APP); } elseif (strtolower($type) === 'model') { $paths = array(APP . 'models' . DS, APP); } elseif (strtolower($type) === 'view') { $paths = array(APP . 'views' . DS); } } return $paths; }
/** * Returns default paths to search * * @param string $type type of object to be searched * @return array list of paths * @access private */ function __paths($type) { if ($type === 'Core') { $path = Configure::corePaths(); foreach ($path as $key => $value) { $count = count($key); for ($i = 0; $i < $count; $i++) { $paths[] = $path[$key][$i]; } } return $paths; } $paths = Configure::read(strtolower($type) . 'Paths'); return $paths; }
/** * undocumented function * * @param string $data * @return void */ function createShell($data = array()) { $template = CONFIGS . 'templates' . DS; $chaw = Configure::read('Content.base'); if (file_exists($template . 'chaw') && !file_exists($chaw . 'chaw')) { $console = array_pop(Configure::corePaths('cake')) . 'console' . DS; ob_start(); include $template . 'chaw'; $data = ob_get_clean(); $File = new File($chaw . 'chaw', true, 0775); @chmod($File->pwd(), 0775); return $File->write($data); } return true; }
function __models() { $appPaths = array_diff(Configure::read('modelPaths'), Configure::corePaths('model')); $models = Configure::listObjects('model', $appPaths, false); return $models; }
/** * Reads database and creates schema tables * * @param array $options schema object properties * @return array Array indexed by name and tables * @access public */ function read($options = array()) { extract(array_merge(array('connection' => $this->connection, 'name' => $this->name, 'models' => true), $options)); $db =& ConnectionManager::getDataSource($connection); $prefix = null; App::import('Model', 'AppModel'); $tables = array(); $currentTables = $db->sources(); if (isset($db->config['prefix'])) { $prefix = $db->config['prefix']; } if (!is_array($models) && $models !== false) { $appPaths = array_diff(Configure::read('modelPaths'), Configure::corePaths('model')); $models = Configure::listObjects('model', $appPaths, false); } if (is_array($models)) { foreach ($models as $model) { if (!class_exists($model)) { App::import('Model', $model); } if (class_exists($model)) { $Object =& new $model(); $Object->setDataSource($connection); $table = $db->fullTableName($Object, false); if (is_object($Object)) { $table = $db->fullTableName($Object, false); if (in_array($table, $currentTables)) { $key = array_search($table, $currentTables); if (empty($tables[$Object->table])) { $tables[$Object->table] = $this->__columns($Object); $tables[$Object->table]['indexes'] = $db->index($Object); unset($currentTables[$key]); } if (!empty($Object->hasAndBelongsToMany)) { foreach ($Object->hasAndBelongsToMany as $Assoc => $assocData) { if (isset($assocData['with'])) { $class = $assocData['with']; } elseif ($assocData['_with']) { $class = $assocData['_with']; } if (is_object($Object->{$class})) { $table = $db->fullTableName($Object->{$class}, false); if (in_array($table, $currentTables)) { $key = array_search($table, $currentTables); $tables[$Object->{$class}->table] = $this->__columns($Object->{$class}); $tables[$Object->{$class}->table]['indexes'] = $db->index($Object->{$class}); unset($currentTables[$key]); } } } } } } } } } if (!empty($currentTables)) { foreach ($currentTables as $table) { if ($prefix) { $table = str_replace($prefix, '', $table); } $Object = new AppModel(array('name' => Inflector::classify($table), 'table' => $table, 'ds' => $connection)); if (in_array($table, array('aros', 'acos', 'aros_acos', Configure::read('Session.table'), 'i18n'))) { $tables[$Object->table] = $this->__columns($Object); $tables[$Object->table]['indexes'] = $db->index($Object); } else { $tables['missing'][$table] = $this->__columns($Object); $tables['missing'][$table]['indexes'] = $db->index($Object); } } } ksort($tables); return compact('name', 'tables'); }