Esempio n. 1
0
 /**
  * Cms constructor.
  * @param array $values
  */
 public function __construct(array $values = array())
 {
     parent::__construct($values);
     $this['type'] = $this->_getCMSType();
     $this['ns'] = __NAMESPACE__ . '\\' . $this['type'] . '\\';
     $this['db'] = function ($cms) {
         SqlBuilder::set($cms['type']);
         // init SQLBuilder Driver
         $className = $cms['ns'] . 'Database';
         $database = new $className($cms);
         return $database;
     };
     $this['path'] = function ($cms) {
         $className = $cms['ns'] . 'Path';
         /** @var AbstractPath $helper */
         $helper = new $className($cms);
         $path = Path::getInstance('crosscms');
         $path->setRoot($helper->getRoot());
         $preDefinedPaths = ['upload' => $helper->getUpload(), 'cache' => $helper->getCache(), 'tmpl' => $helper->getTmpl(), 'logs' => $helper->getLogs(), 'tmp' => $helper->getTmp(), 'crosscms' => __DIR__ . '/../src'];
         foreach ($preDefinedPaths as $alias => $pathValue) {
             if (!is_dir($pathValue)) {
                 mkdir($pathValue, 0755, true);
             }
             $path->set($alias, $pathValue);
         }
         return $path;
     };
     $this['events'] = function ($cms) {
         $eventManager = new EventManager();
         $className = $cms['ns'] . 'Events';
         $helper = new $className($cms, $eventManager);
         return $helper;
     };
     $this['lang'] = function ($cms) {
         $className = $cms['ns'] . 'Lang';
         /** @var AbstractLang $helper */
         $helper = new $className($cms);
         $lang = new Lang($helper->getCode());
         $helper->setCustomLang($lang);
         return $helper;
     };
 }
Esempio n. 2
0
define('CAKE_CORE_INCLUDE_PATH', ROOT . '/vendor/cakephp/cakephp');
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
define('CAKE', CORE_PATH . 'src' . DS);
//  Create test app folders.
$folder = new Folder();
$folder->create(LOGS, 0777);
$folder->create(SESSIONS, 0777);
$folder->create(CACHE, 0777);
$folder->create(CACHE . 'view', 0777);
$folder->create(CACHE . 'models', 0777);
date_default_timezone_set('UTC');
mb_internal_encoding('UTF-8');
//  Include CakePHP framework.
/** @noinspection PhpIncludeInspection */
require_once CAKE_CORE_INCLUDE_PATH . '/config/bootstrap.php';
$path = Path::getInstance();
//  Load union core plugin.
Plugin::load('Union/Core', ['routes' => true, 'bootstrap' => true]);
$path->setRoot(APP_ROOT);
$path->set('cache', ASSETS_CACHE);
$path->set('Union/Core', ROOT);
//  Write union test application config.
Configure::write('debug', true);
Configure::write('App', ['namespace' => 'TestApp', 'encoding' => 'UTF-8', 'base' => false, 'baseUrl' => env('SCRIPT_NAME'), 'dir' => APP_DIR, 'fullBaseUrl' => 'http://localhost', 'locale' => 'ru_RU', 'paths' => ['plugins' => [APP_ROOT . 'Plugins' . DS], 'templates' => [APP . 'Template' . DS, ROOT . '/vendor/union-cms/core/src/Template/'], 'locales' => [APP . 'Locale' . DS]]]);
Configure::write('Theme', ['site' => 'Site', 'admin' => 'Admin']);
Configure::write('Session', ['defaults' => 'php']);
//  Write configure for cache model.
Cache::config(['_cake_core_' => ['engine' => 'File', 'prefix' => 'cms_core_', 'serialize' => true], '_cake_model_' => ['engine' => 'File', 'prefix' => 'cms_model_', 'serialize' => true]]);
//  Ensure default test connection is defined.
if (!getenv('db_dsn')) {
    putenv('db_dsn=sqlite:///:memory:');
Esempio n. 3
0
 public function testDeprecated_add()
 {
     $path = Path::getInstance(__METHOD__);
     $paths = array($this->_root, $this->_root . '/..');
     $path->add($paths, 'default', Path::MOD_PREPEND);
     $paths2 = array($this->_root . '/..', $this->_root);
     $path->add($paths2, 'test', Path::MOD_APPEND);
     $expected = array(realpath($this->_root . '/..'), $this->_root);
     $this->_is($expected, $path->getPaths('default:'));
     $this->_is($expected, $path->getPaths('test:'));
 }
Esempio n. 4
0
 /**
  * Loads a plugin.
  *
  * @param string $plugin
  * @param array $config
  * @return void
  */
 public static function load($plugin, array $config = [])
 {
     $config += ['events' => false];
     parent::load($plugin, $config);
     if (self::loaded($plugin)) {
         $path = self::path($plugin);
         Union::mergeConfig('App.paths.locales', $path . 'src' . DS . 'Locale' . DS);
         Path::getInstance()->set($plugin, $path);
     }
     self::events($plugin);
 }
Esempio n. 5
0
File: Lang.php Progetto: jbzoo/lang
 /**
  * @param $code
  */
 public function __construct($code)
 {
     $this->_code = self::_cleanCode($code);
     $this->_path = Path::getInstance(uniqid('lang_' . $code, true));
     $this->_storage = new Data();
 }
Esempio n. 6
0
 *
 * This file is part of the of the simple cms based on CakePHP 3.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @package   Core
 * @license   MIT
 * @copyright MIT License http://www.opensource.org/licenses/mit-license.php
 * @link      https://github.com/UnionCMS/Core
 * @author    Sergey Kalistratov <*****@*****.**>
 */
use JBZoo\Path\Path;
use Cake\Core\Configure;
use Union\Core\Utility\Hook;
//  Set virtual file system.
$path = Path::getInstance('default');
$path->setRoot(ROOT);
/**
 * Union CMS configuration.
 *
 * - docDir     - html document dir
 * - iconPrefix - icon class prefix (Default is "Awesome Font")
 * - btnPrefix  - button prefix (Default is "Bootstrap Framework)
 */
Configure::write('Union', ['docDir' => 'ltr', 'iconPref' => 'fa', 'btnPref' => 'btn', 'lineTab' => '    ']);
Configure::write('Cache.defaultConfig', ['className' => 'File', 'duration' => '+1 hour', 'path' => CACHE . 'queries' . DS, 'prefix' => 'un_']);
/** @noinspection PhpIncludeInspection */
require_once dirname(__DIR__) . DS . 'src' . DS . 'functions.php';
/** @noinspection PhpIncludeInspection */
require_once __DIR__ . DS . 'defines.php';
//  Load union core events configure.
Esempio n. 7
0
File: Html.php Progetto: JBZoo/Html
 /**
  * Html constructor.
  */
 public function __construct()
 {
     parent::__construct(array());
     $path = Path::getInstance(Html::PATH_KEY);
     $path->add(__DIR__ . '/' . Html::RENDER_DIR, 'core');
 }