コード例 #1
0
ファイル: DotcakeShell.php プロジェクト: dotcake/dotcake
 /**
  * generate
  *
  */
 public function generate()
 {
     $this->out('Generate .cake ...');
     $d = new Dotcake(APP, App::paths(), CAKE_CORE_INCLUDE_PATH);
     $contents = json_encode($d->generate());
     if (array_key_exists('format', $this->params)) {
         $format = $this->params['format'];
         switch ($format) {
             case 'tab':
                 $formatter = new Formatter();
                 $contents = $formatter->reformat($contents);
                 break;
             case 'ws':
                 // no break
             // no break
             case 'whitespace':
                 // can use JSON_PRETTY_PRINT option since PHP5.4
                 $formatter = new Formatter('    ');
                 // 4 spaces
                 $contents = $formatter->reformat($contents);
                 break;
             default:
                 $this->out(__d('cake_console', "'{$format}' is invalid format option. You can use 'tab', 'ws' or 'whitespace' as option value."));
                 exit(0);
         }
     }
     $this->createFile(APP . '.cake', $contents);
 }
コード例 #2
0
ファイル: CroogoTestCase.php プロジェクト: saydulk/croogo
 /**
  * setUp
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $appDir = CakePlugin::path('Croogo') . 'Test' . DS . 'test_app' . DS;
     App::build(array('Plugin' => array($appDir . 'Plugin' . DS), 'View' => array($appDir . 'View' . DS)), App::PREPEND);
     $this->_paths = App::paths();
     CakePlugin::unload('Install');
     CakePlugin::load('Example');
     Configure::write('Acl.database', 'test');
     $this->setupSettings($appDir);
 }
コード例 #3
0
 public function test()
 {
     pr(App::themePath('purple'));
     pr(App::path('Model'));
     debug(App::paths());
     pr(App::path('Component', 'DebugKit'));
     debug(env('document_root'));
     debug(h('fengjie ; fengjie '));
     LogError('fengjie');
     pr(array('fengjie', 'fengjie'));
     debug(h('fengjie ; fengjie '));
     pr(YEAR);
     pr(HOUR);
 }
コード例 #4
0
ファイル: CroogoTestCase.php プロジェクト: Demired/CakeWX
 /**
  * setUp
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $appDir = CakePlugin::path('Croogo') . 'Test' . DS . 'test_app' . DS;
     App::build(array('Plugin' => array($appDir . 'Plugin' . DS), 'View' => array($appDir . 'View' . DS)), App::PREPEND);
     $this->_paths = App::paths();
     CakePlugin::unload('Install');
     CakePlugin::load('Example');
     Configure::write('Acl.database', 'test');
     $Setting = ClassRegistry::init('Settings.Setting');
     $Setting->settingsPath = $appDir . 'Config' . DS . 'settings.json';
     Configure::drop('settings');
     Configure::config('settings', new CroogoJsonReader(dirname($Setting->settingsPath) . DS));
     $Setting->writeConfiguration();
 }
コード例 #5
0
ファイル: Dotcake.php プロジェクト: dotcake/dotcake
 /**
  * __construct
  *
  * @param string $base
  * @param array $paths
  * @param string $cake
  * @return
  */
 public function __construct($base = null, array $paths = array(), $cake = null)
 {
     if ($base === null) {
         $base = APP;
     }
     $this->__base = $base;
     if ($paths === array()) {
         $paths = App::paths();
     }
     $this->__paths = $paths;
     if ($cake === null) {
         $cake = CAKE_CORE_INCLUDE_PATH;
     }
     $this->__cake = $this->relativePath($cake);
 }
コード例 #6
0
ファイル: Configure.php プロジェクト: sowerphp/sowerphp
 /**
  * Realizar configuración al inicio de la aplicación
  * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]delaf.cl)
  * @version 2015-04-09
  */
 public static function bootstrap()
 {
     // Incluir configuraciones para el sitio web
     $paths = array_reverse(App::paths());
     foreach ($paths as &$path) {
         App::import($path . '/Config/core');
     }
     // Incluir rutas (se debe hacer por separado, primero la
     // configuración y luego rutas)
     foreach ($paths as &$path) {
         App::import($path . '/Config/routes');
     }
     // Setear parámetros de errores
     ini_set('display_errors', self::$_values['debug']);
     error_reporting(self::$_values['error']['level']);
     set_exception_handler('sowerphp\\core\\Exception::handler');
     // Definir la zona horaria
     date_default_timezone_set(self::$_values['time']['zone']);
     // definir directorio temporal
     if (is_writable(DIR_PROJECT . '/tmp')) {
         define('TMP', DIR_PROJECT . '/tmp');
     } else {
         define('TMP', sys_get_temp_dir());
     }
     // cargar reglas de Inflector para el idioma de la aplicación
     App::import('Config/Inflector/' . self::$_values['language']);
     // procesar cada capa (excepto SowerPHP/core) buscando funciones y bootstrap
     $paths = array_reverse(App::paths());
     array_shift($paths);
     foreach ($paths as &$path) {
         // Cargar funciones
         if (file_exists($path . '/basics.php')) {
             include $path . '/basics.php';
         }
         // Cargar bootstrap
         if (file_exists($path . '/bootstrap.php')) {
             include $path . '/bootstrap.php';
         }
     }
     unset($paths, $path);
 }
コード例 #7
0
ファイル: AppTest.php プロジェクト: Chromedian/inventory
 /**
  * Test that paths() works.
  *
  * @return void
  */
 public function testPaths()
 {
     $result = App::paths();
     $this->assertArrayHasKey('Plugin', $result);
     $this->assertArrayHasKey('Controller', $result);
     $this->assertArrayHasKey('Controller/Component', $result);
 }
コード例 #8
0
ファイル: CakeTestCase.php プロジェクト: Demired/CakeWX
 /**
  * Setup the test case, backup the static object values so they can be restored.
  * Specifically backs up the contents of Configure and paths in App if they have
  * not already been backed up.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     if (empty($this->_configure)) {
         $this->_configure = Configure::read();
     }
     if (empty($this->_pathRestore)) {
         $this->_pathRestore = App::paths();
     }
     if (class_exists('Router', false)) {
         Router::reload();
     }
 }
コード例 #9
0
ファイル: MenusComponentTest.php プロジェクト: dlpc/CakeWX
 public function tearDown()
 {
     App::paths($this->_paths);
     unset($this->controller);
 }
コード例 #10
0
ファイル: View.php プロジェクト: sowerphp/sowerphp
 /**
  * Método que busca la vista en las posibles rutas y para todas las posibles extensiones
  * @param view Nombre de la vista buscada (ejemplo: /inicio)
  * @param module Nombre del módulo en caso de pertenecer a uno
  * @return Ubicación de la vista que se busca
  * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]delaf.cl)
  * @version 2014-04-22
  */
 public static function location($view, $module = null)
 {
     // si la página está en caché se retorna
     if (isset(self::$_viewsLocation[$view])) {
         return self::$_viewsLocation[$view];
     }
     // extensiones
     if (!self::$extensions) {
         self::$extensions = Configure::read('page.extensions');
         if (!in_array('php', self::$extensions)) {
             self::$extensions[] = 'php';
         }
         // php siempre debe estar
     }
     // si la vista parte con / entonces se está pasando la ruta y solo falta su extension
     if ($view[0] == '/') {
         foreach (self::$extensions as $extension) {
             if (is_readable($view . '.' . $extension)) {
                 self::$_viewsLocation[$view] = $view . '.' . $extension;
                 return $view . '.' . $extension;
             }
         }
         return null;
     }
     // Determinar de donde sacar la vista
     $location = $module ? '/Module/' . str_replace('.', '/Module/', $module) : '';
     // obtener paths
     $paths = App::paths();
     // buscar archivo en cada ruta
     foreach ($paths as $path) {
         foreach (self::$extensions as $extension) {
             $file = $path . $location . '/View/' . $view . '.' . $extension;
             if (is_readable($file)) {
                 self::$_viewsLocation[$view] = $file;
                 return $file;
             }
         }
     }
     // Si se busca la vista Module/index y no fue encontrada se carga la por defecto
     if ($view == 'Module/index') {
         // Buscar el archivo de la vista en las posibles rutas
         foreach ($paths as $path) {
             $file = $path . '/View/Module/index.php';
             if (is_readable($file)) {
                 return $file;
             }
         }
     }
     // si no se encontró el archivo de la vista se retorna falso
     return false;
 }
コード例 #11
0
ファイル: CommonTestCase.php プロジェクト: gourmet/common
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->_paths = App::paths();
     // Test case static reference.
     self::$_this = $this;
     if ($plugin = Reveal::plugin(Reveal::path(true))) {
         self::$plugin = $plugin;
     }
     self::buildTestAppPaths();
     self::loadTestAppPlugins();
 }
コード例 #12
0
ファイル: Module.php プロジェクト: sowerphp/sowerphp
 /**
  * Entrega la ruta completa para un archivo
  * @param module Nombre del modulo
  * @param file Ruta hacia el archivo, sin .php
  * @return Ruta completa para el archivo solicitado o null si no existe
  * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]delaf.cl)
  * @version 2014-03-17
  */
 public static function fileLocation($module, $file)
 {
     $paths = App::paths();
     foreach ($paths as &$path) {
         $fileLocation = $path . '/Module/' . str_replace('.', '/Module/', $module) . '/' . $file . '.php';
         if (file_exists($fileLocation)) {
             return $fileLocation;
         }
     }
     return null;
 }
コード例 #13
0
ファイル: Dispatcher.php プロジェクト: sowerphp/sowerphp
 /**
  * Busca si lo solicitado existe físicamente en el servidor y lo entrega
  * @param url Ruta de los que se está solicitando
  * @param response Objeto Response
  * @return Verdadero si lo solicitado existe dentro de /webroot
  * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]delaf.cl)
  * @version 2014-03-21
  */
 private static function _asset($url, Network_Response $response)
 {
     // Si la URL es vacía se retorna falso
     if ($url == '') {
         return false;
     }
     // Inicializar el archivo como null
     $assetFile = null;
     // Buscar el archivo en los posibles directorios webroot, incluyendo
     // los paths de los modulos
     $paths = null;
     // si hay más de dos slash en la url podría ser un módulo así que se
     // busca path para el modulo
     $slashPos = strpos($url, '/', 1);
     if ($slashPos) {
         // paths de plugins
         $module = Module::find($url);
         if (isset($module[0])) {
             Module::load($module);
             $paths = Module::paths($module);
         }
         // si existe el módulo en los paths entonces si es un módulo lo que
         // se está pidiendo, y es un módulo ya cargado. Si este no fuera el
         // caso podría no ser plugin, o no estar cargado
         if ($paths) {
             $removeCount = count(explode('.', $module)) + 1;
             $aux = explode('/', $url);
             while ($removeCount-- > 0) {
                 array_shift($aux);
             }
             $url = '/' . implode('/', $aux);
         }
     }
     // si no está definido el path entonces no era de módulo y se deberá
     // buscar en los paths de la aplicación
     if (!$paths) {
         $paths = App::paths();
     }
     // en cada paths encontrado buscar el archivo solicitado
     foreach ($paths as &$path) {
         $file = $path . '/webroot' . $url;
         if (file_exists($file) && !is_dir($file)) {
             $assetFile = $file;
             break;
         }
     }
     // Si se encontró el archivo se envía al cliente
     if ($assetFile !== null) {
         // Solo se entrega mediante PHP si el archivo no está en
         // DIR_WEBSITE/webroot
         if (!strpos($assetFile, DIR_WEBSITE) !== false) {
             $response->sendFile($assetFile);
         }
         return true;
     }
     // Si no se encontró se retorna falso
     return false;
 }
コード例 #14
0
ファイル: bootstrap.php プロジェクト: JacopKane/Cake-Nod
    }
    public function __construct()
    {
        $this->_defaultConfig['Type'] = $this->_setEnviromentType();
        $config = array_replace_recursive($this->_defaultConfig, $this->_getUserConfig());
        $config = $this->_setPaths($config);
        $config = $this->_setRoutes($config);
        $config = $this->_setNames($config);
        return Configure::write('Environment', $config) ? true : false;
    }
    public static function init()
    {
        return new static();
    }
}
if (!NodStrap::init()) {
    return false;
}
$nodPaths = array('Vendor' => array(Configure::read('Environment.Paths.libraries') . DS), 'Plugin' => array(Configure::read('Environment.Paths.cake_plugins') . DS, Configure::read('Environment.Paths.nod_plugins') . DS, Configure::read('Environment.Paths.nod_plugins') . DS . 'Nod' . DS), 'View' => array(App::pluginPath('Nod') . 'View' . DS), 'Controller' => array(Configure::read('Environment.Paths.cake_nod') . DS . 'Controller' . DS));
$nodPaths = array_merge_recursive(App::paths(), $nodPaths);
App::build($nodPaths);
//debug(App::paths());
$locale = 'tur';
setlocale(LC_ALL, $locale);
putenv("LC_ALL={$locale}");
Configure::write('Config.language', $locale);
CakePlugin::load(array('CakeStrap' => array('bootstrap' => true), 'ClientRedirect', 'ControllersList', 'DebugKit', 'Uploader'));
$autoloadPath = APP . DS . 'Vendor' . DS . 'autoload.php';
if (file_exists($autoloadPath)) {
    require_once $autoloadPath;
}