示例#1
0
 public function init($sName, $sLayout = 'index')
 {
     $this->sName = $sName;
     $this->sPath = Core::app()->config()->getThemesPath() . '/' . $sName;
     $this->sUrl = Core::app()->config()->getThemesUrl() . '/' . $sName;
     $classLayout = $this->layoutClass;
     $this->oLayout = new $classLayout($sLayout);
     $aTheme = Loader::loadConfigFile(Core::app()->config()->getThemesPath() . '/' . $sName, 'theme');
     if ($aTheme && isset($aTheme['Client']['Packages']) && count($aTheme['Client']['Packages'])) {
         foreach ($aTheme['Client']['Packages'] as $itm) {
             Core::app()->client()->registerPackage($itm);
         }
     }
     if ($aTheme && isset($aTheme['Client']['ScriptFiles']) && count($aTheme['Client']['ScriptFiles'])) {
         foreach ($aTheme['Client']['ScriptFiles'] as $itm) {
             Core::app()->client()->registerScriptFile($itm);
         }
     }
     if ($aTheme && isset($aTheme['Client']['CssFiles']) && count($aTheme['Client']['CssFiles'])) {
         foreach ($aTheme['Client']['CssFiles'] as $itm) {
             Core::app()->client()->registerCssFile($itm);
         }
     }
     return true;
 }
示例#2
0
 public function attach($owner)
 {
     if (Core::app()->checkInstalledModule($this->module_alias)) {
         parent::attach($owner);
         return true;
     }
 }
示例#3
0
 public function import($aData)
 {
     $this->sPath = $aData['Project']['Path'];
     $this->sUrl = $aData['Project']['Url'];
     $this->sLang = $aData['Project']['Language'];
     $this->sDefaultLang = $aData['Project']['DefaultLanguage'];
     $this->bDebugMode = $aData['Project']['DebugMode'];
     $aFilters = array_merge_recursive($aData['Core']['Filters'], $aData['Core']['Applications'][Core::app()->getName()]['Filters']);
     foreach ($aFilters as $key => $value) {
         if (is_numeric($key)) {
             $this->aFilters[$value] = array();
         } else {
             $this->aFilters[$key] = $value;
         }
     }
     $this->aEvents = array_merge($aData['Core']['Events'], $aData['Core']['Applications'][Core::app()->getName()]['Events']);
     $this->aExtensions = array_merge($aData['Core']['Extensions'], $aData['Core']['Applications'][Core::app()->getName()]['Extensions']);
     $this->aDb = $aData['Db'];
     $this->aCache = $aData['Cache'];
     $this->sThemesPath = $this->sPath . '/themes';
     $this->sThemesUrl = $this->sUrl . '/themes';
     $this->aDefault = isset($aData['Core']['Applications'][Core::app()->getName()]['Default']) ? $aData['Core']['Applications'][Core::app()->getName()]['Default'] : array();
     $this->aRoutes = isset($aData['Core']['Applications'][Core::app()->getName()]['Routes']) ? $aData['Core']['Applications'][Core::app()->getName()]['Routes'] : array();
     //$this->aModules = $aData['Modules'];
     return true;
 }
 public function check($sValue)
 {
     if (!preg_match("%^[A-Za-z0-9](([_\\.\\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\\.\\-]?[a-zA-Z0-9]+)*)\\.([A-Za-z])+\$%", $sValue)) {
         return Core::app()->t('Ruxon', $this->getErrorText(), ['Field' => $this->getTitle()], null, 'ruxon/framework/messages');
     }
     return true;
 }
 public function check($sValue)
 {
     if (is_numeric($sValue) && $sValue > 0 || is_array($sValue) && count($sValue) > 0 || is_string($sValue) && strlen($sValue) > 0) {
         return true;
     }
     return Core::app()->t('Ruxon', $this->sErrorText, ['Field' => $this->getTitle()], null, 'ruxon/framework/messages');
 }
 public function sendResponse($params)
 {
     if ($params['status'] == 'ok') {
         echo "OK" . $params['order_id'];
         Core::app()->hardEnd();
         return true;
     }
 }
示例#7
0
 public function run(FilterChain $oFilterChain)
 {
     if (Core::app()->request()->isAjaxRequest()) {
         $oFilterChain->next();
     } else {
         throw new RxException('Your request is not valid.', 400);
     }
 }
示例#8
0
 public function run(FilterChain $oFilterChain)
 {
     $aDb = Core::app()->config()->getCache();
     foreach ($aDb as $k => $val) {
         Manager::getInstance()->getCache()->add(Cache::factory($val['Driver'], $val['Params']), $k);
     }
     $oFilterChain->next();
 }
 public function run(FilterChain $oFilterChain)
 {
     if (Toolkit::getInstance()->auth->checkAdminAccess()) {
         $oFilterChain->next();
     } else {
         header("Location: " . Toolkit::getInstance()->auth->loginUrl);
         Core::app()->hardEnd();
     }
 }
 public function check($sValue)
 {
     if (is_numeric($sValue) && $sValue > 0 || !is_numeric($sValue)) {
         if (mb_strlen($sValue, "utf8") <= $this->nMaxLength) {
             return true;
         }
     }
     return Core::app()->t('Ruxon', $this->getErrorText(), ['Field' => $this->getTitle(), 'EndLength' => $this->nMaxLength], null, 'ruxon/framework/messages');
 }
 public function check($sValue, $nElementId)
 {
     $oMatchValidator = new ValidationMatchRule(array($this->getAlias(), $this->getTitle(), "/^([A-Za-z]{1})([A-Za-z0-9_-]+)\$/i"));
     $oUniqValidator = new ValidationUniqRule(array($this->getAlias(), $this->getTitle(), $this->getModule(), $this->getModel(), $this->getCriteria()));
     if (strlen($sValue) >= 3 && $oMatchValidator->check($sValue) === true && $oUniqValidator->check($sValue, $nElementId) === true) {
         return true;
     }
     return Core::app()->t('Ruxon', $this->getErrorText(), ['Field' => $this->getTitle()], null, 'ruxon/framework/messages');
 }
 public function check($sValue)
 {
     if (isset($_SESSION['rx_captcha']) && $_SESSION['rx_captcha'] == $sValue) {
         unset($_SESSION['rx_captcha']);
         return true;
     }
     unset($_SESSION['rx_captcha']);
     return Core::app()->t('Ruxon', $this->getErrorText(), [], null, 'ruxon/framework/messages');
 }
 public function run(FilterChain $oFilterChain)
 {
     $aDb = Core::app()->config()->getDb();
     foreach ($aDb as $k => $val) {
         $oDb = new Db($val['ConnectionString'], $val['Username'], $val['Password'], $val['Params']);
         $oDb->open();
         Manager::getInstance()->getDb()->add($oDb, $k);
     }
     $oFilterChain->next();
 }
 public function result403()
 {
     Core::import('Modules.Main');
     $oController = new SiteController();
     $oResult = $oController->run('403', array());
     Core::app()->response()->setStatus(403);
     Core::app()->theme()->getLayout()->setContent($oResult->getHtml());
     Core::app()->response()->setResponseText(Core::app()->theme()->fetch());
     Core::app()->end();
     Core::app()->hardEnd();
 }
 /**
  * Uninstall: module uninstall action
  *
  * @return boolean
  */
 public function uninstall()
 {
     // 1. remove tables
     $migrator = new MysqlDbMigrator($this->sModuleAlias);
     $migrator->migrateTo(-1);
     // 2. remove row from the modules table
     Core::app()->deleteModuleById($this->sModuleAlias);
     // 3. Delete config
     $file = RX_PATH . '/ruxon/config/modules/' . $this->sModuleAlias . '.inc.php';
     if (file_exists($file)) {
         unlink($file);
     }
     return true;
 }
 public function check($sValue, $nElementId)
 {
     $aCriteria = array();
     $aCriteria[$this->sAlias] = $sValue;
     $aCriteria['Id'] = array('Type' => '<>', 'Value' => $nElementId);
     if (count($this->getCriteria())) {
         foreach ($this->getCriteria() as $k => $itm) {
             $aCriteria[$k] = $itm;
         }
     }
     $nRes = $this->mapper()->count(array('Criteria' => $aCriteria));
     if ($nRes > 0) {
         return Core::app()->t('Ruxon', $this->getErrorText(), ['Field' => $this->getTitle()], null, 'ruxon/framework/messages');
     }
     return true;
 }
示例#17
0
 public function sendResponse($params)
 {
     $script = 'result';
     $status = $params['status'];
     unset($params['status']);
     unset($params['pg_sig']);
     $params['pg_status'] = $status;
     $params['pg_sig'] = $this->getSig($params, $script);
     header("Content-Type: text/xml");
     $result = '<?xml version="1.0" encoding="utf-8"?><response>';
     foreach ($params as $key => $val) {
         $result .= '<' . $key . '>' . $val . '</' . $key . '>' . "\n";
     }
     $result .= '</response>';
     echo $result;
     Core::app()->hardEnd();
     return true;
 }
示例#18
0
 public function actionConfig($aParams = array())
 {
     $aConfig = $this->config('Config');
     $mResult = false;
     if ($aConfig) {
         if (!isset($aConfig['View']) || isset($aConfig['View']) && $aConfig['View'] != false) {
             $mResult = $this->view(array(), $aConfig['View']);
         } else {
             if (isset($aConfig['Component'])) {
                 $sComponentModule = $aConfig['Component']['Component'][0];
                 $sComponentAlias = $aConfig['Component']['Component'][1];
                 $aComponentParams = isset($aConfig['Component']['Params']) ? $aConfig['Component']['Params'] : array();
                 // Проверка доступа
                 $this->checkActionAccess('Config');
                 // load config
                 $aComponentParams['Data'] = Manager::getInstance()->getModule($this->sModuleAlias)->config();
                 if (!empty($_POST)) {
                     //echo print_r($_POST, true);die();
                     $aResult = array();
                     if (Manager::getInstance()->getModule($this->sModuleAlias)->saveConfig($_POST)) {
                         $aResult['success'] = true;
                     } else {
                         $aResult['success'] = false;
                     }
                     header("Content-type: application/json");
                     echo json_encode($aResult);
                     Core::app()->hardEnd();
                 } else {
                     $mResult = $this->component($sComponentModule, $sComponentAlias, $aComponentParams);
                 }
             } else {
                 $mResult = false;
             }
         }
     }
     return $mResult;
 }
示例#19
0
 public static function import($mPath)
 {
     $aPath = array();
     if (is_array($mPath)) {
         $aPath = $mPath;
     } else {
         $aPath = explode(".", $mPath);
     }
     $sPath = '';
     $sFile = '';
     if (isset($aPath[0])) {
         switch ($aPath[0]) {
             // Модули
             case 'Modules':
                 if (!isset($_ENV['RUXON_REGISTRY_MODULES'][$aPath[1]])) {
                     $sModuleAlias = $aPath[1];
                     $module = Core::app()->getModuleById($sModuleAlias);
                     $sBasePath = !empty($module['BasePath']) ? $module['BasePath'] : 'ruxon/modules/' . $sModuleAlias;
                     $aModuleInfo = self::loadConfigFile(realpath(RX_PATH . '/' . $sBasePath), 'module');
                     if (!empty($aModuleInfo)) {
                         if (!is_dir(RX_PATH . '/runtime/cache/')) {
                             mkdir(RX_PATH . '/runtime/cache/', 0777, true);
                         }
                         if (!RUXON_DEBUG && file_exists(RX_PATH . '/runtime/cache/module_' . $sModuleAlias . '.classes.php') && filemtime(RX_PATH . '/runtime/cache/module_' . $sModuleAlias . '.classes.php') >= time() - 3600) {
                             $aFiles = (include RX_PATH . '/runtime/cache/module_' . $sModuleAlias . '.classes.php');
                         } else {
                             $aFiles = rx_glob($sBasePath);
                             file_put_contents(RX_PATH . '/runtime/cache/module_' . $sModuleAlias . '.classes.php', "<?php\nreturn " . var_export($aFiles, true) . ";");
                         }
                         if (count($aFiles)) {
                             $namespace = !empty($module['BasePath']) ? 'ruxon\\modules\\' . $sModuleAlias : null;
                             $namespace_replace = !empty($module['BasePath']) ? realpath($module['BasePath']) : null;
                             foreach ($aFiles as $file) {
                                 self::require_file($file, true, true, $namespace, $namespace_replace);
                             }
                         }
                         if (isset($aModuleInfo['RequiredModules']) && is_array($aModuleInfo['RequiredModules']) && count($aModuleInfo['RequiredModules']) > 0) {
                             foreach ($aModuleInfo['RequiredModules'] as $package) {
                                 if (!isset($_ENV['RUXON_REGISTRY_MODULES'][$package])) {
                                     self::import('Modules.' . $package);
                                 }
                             }
                         }
                         $_ENV['RUXON_REGISTRY_MODULES'][$sModuleAlias] = 1;
                         $sClassName = $sModuleAlias . 'Module';
                         $classNameWithNamespaces = '\\ruxon\\modules\\' . $sModuleAlias . '\\classes\\' . $sClassName;
                         Manager::getInstance()->setModule($sModuleAlias, class_exists($classNameWithNamespaces) ? new $classNameWithNamespaces() : new $sClassName());
                     }
                 }
                 break;
                 // Дополнения
             // Дополнения
             case 'Extensions':
                 if (!isset($_ENV['RUXON_REGISTRY_EXTENSIONS'][$aPath[1]])) {
                     for ($i = 1; $i < count($aPath); $i++) {
                         $sPath .= '/' . $aPath[$i];
                     }
                     $sBasePath = 'ruxon/extensions' . $sPath;
                     $sFile = '/extension.inc.php';
                     $aResult = self::loadConfigFile($sBasePath, 'extension');
                     if ($aResult !== false) {
                         $cache_file = RX_PATH . '/runtime/cache/extension_' . $aPath[1] . '.classes.php';
                         if (!RUXON_DEBUG && file_exists($cache_file) && filemtime($cache_file) >= time() - 3600) {
                             $aFiles = (include $cache_file);
                         } else {
                             $aFiles = rx_glob($sBasePath);
                             file_put_contents($cache_file, "<?php\nreturn " . var_export($aFiles, true) . ";");
                         }
                         if (count($aFiles)) {
                             foreach ($aFiles as $file) {
                                 self::require_file($file, true, true);
                             }
                         }
                         $_ENV['RUXON_REGISTRY_EXTENSIONS'][$aPath[1]] = 1;
                     } else {
                         throw new RxException('Файл "' . $sBasePath . $sPath . $sFile . '" не может быть загружен.');
                     }
                 }
                 break;
                 // Компоненты
             // Компоненты
             case 'Components':
                 // Подключаем компонент
                 if (count($aPath) == 3) {
                     if (!isset($_ENV['RUXON_REGISTRY_COMPONENTS'][$aPath[1]][$aPath[2]])) {
                         $sModuleAlias = $aPath[1];
                         $sComponentAlias = $aPath[2];
                         $module = Core::app()->getModuleById($sModuleAlias);
                         $sBasePath = !empty($module['BasePath']) ? $module['BasePath'] . '/components/' . $sComponentAlias : 'ruxon/modules/' . $sModuleAlias . '/components/' . $sComponentAlias;
                         $aModelInfo = self::loadConfigFile(RX_PATH . '/' . $sBasePath, 'component');
                         if (!is_dir(RX_PATH . '/runtime/cache/')) {
                             mkdir(RX_PATH . '/runtime/cache/', 0777, true);
                         }
                         $cache_file = RX_PATH . '/runtime/cache/component_' . $sModuleAlias . '_' . $sComponentAlias . '.classes.php';
                         if (!RUXON_DEBUG && file_exists($cache_file) && filemtime($cache_file) >= time() - 3600) {
                             $aFiles = (include $cache_file);
                         } else {
                             $aFiles = rx_glob($sBasePath);
                             file_put_contents($cache_file, "<?php\nreturn " . var_export($aFiles, true) . ";");
                         }
                         if (count($aFiles)) {
                             $namespace = !empty($module['BasePath']) ? 'ruxon\\modules\\' . $sModuleAlias : null;
                             $namespace_replace = !empty($module['BasePath']) ? realpath($module['BasePath']) : null;
                             foreach ($aFiles as $file) {
                                 self::require_file($file, true, true, $namespace, $namespace_replace);
                             }
                         }
                     }
                 }
                 break;
         }
     }
     return true;
 }
示例#20
0
 public function saveDbRevision($value)
 {
     $this->_moduleObject->DbRevision = $value;
     Core::app()->updateModuleById($this->sModuleAlias, $this->_moduleObject);
     return true;
 }
示例#21
0
 public function t($category, $message, $params = [], $language = null)
 {
     return Core::app()->t($category, $message, $params, $language, 'ruxon/modules/' . $this->sModuleAlias . '/messages');
 }
示例#22
0
 protected function executeRequest($nStatusCode, $aParams)
 {
     $sModule = $aParams['Module'];
     $sController = 'ruxon\\modules\\' . $sModule . '\\controllers\\' . $aParams['Controller'] . 'Controller';
     $sAction = $aParams['Action'];
     Core::import('Modules.' . $sModule);
     if (!class_exists($sController)) {
         $sController = $aParams['Controller'] . 'Controller';
     }
     Core::app()->theme()->getLayout()->setMetaTitle($aParams['Action'] . ' - ' . $aParams['Controller'] . ' - ' . $aParams['Module']);
     $oController = new $sController($sModule, $aParams['Controller']);
     unset($aParams['Action']);
     unset($aParams['Controller']);
     unset($aParams['Module']);
     $oResult = $oController->run($sAction, $aParams);
     Core::app()->response()->setStatus($nStatusCode);
     if (is_object($oResult)) {
         if ($oResult->getLayout()) {
             Core::app()->theme()->getLayout()->setContent($oResult->getHtml());
             $fullcontent = Core::app()->theme()->fetch();
             Core::app()->response()->setResponseText($fullcontent);
         } else {
             $res = Toolkit::getInstance()->client->renderAjaxScriptFiles();
             $res .= Toolkit::getInstance()->client->renderAjaxCssFiles();
             Core::app()->response()->setResponseText($res . $oResult->getHtml());
         }
     }
     return true;
 }
示例#23
0
文件: Index.tpl.php 项目: ruxon/app
echo $this->getMetaKeywords();
?>
" />
    <meta name="description" content="<?php 
echo $this->getMetaDescription();
?>
" />
    <title><?php 
echo $this->getMetaTitle();
?>
</title>

    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <?php 
echo Core::app()->client()->renderAll();
?>

    <script src="<?php 
echo $this->getUrl();
?>
/js/bootstrap.min.js"></script>

    <!-- Bootstrap core CSS -->
    <link href="<?php 
echo $this->getUrl();
?>
/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="<?php 
示例#24
0
 public function getTheme()
 {
     return Core::app()->theme();
 }
示例#25
0
 public function actionLogout($params = array())
 {
     \Toolkit::i()->auth->logout();
     header("Location: /");
     Core::app()->hardEnd();
 }
示例#26
0
文件: index.php 项目: ruxon/app
<?php

if (file_exists(dirname(__FILE__) . '/vendor/autoload.php')) {
    require_once dirname(__FILE__) . '/vendor/autoload.php';
}
require_once dirname(__FILE__) . '/ruxon/kernel/kernel.php';
Core::init(WebApplication::getInstance());
Core::app()->run();
示例#27
0
 public function t($category, $message, $params = [], $language = null)
 {
     $infoPath = empty($module['BasePath']) ? 'ruxon/modules/' . $this->sModuleAlias . '/component/' . $this->sComponentAlias . '/messages' : $module['BasePath'] . '/component/' . $this->sComponentAlias . '/messages';
     return Core::app()->t($category, $message, $params, $language, $infoPath);
 }
示例#28
0
 public function getPageId()
 {
     return method_exists(Core::app(), 'getPage') ? $this->getPage()->getId() : false;
 }
示例#29
0
 public function t($category, $message, $params = [], $language = null)
 {
     return Core::app()->t($category, $message, $params, $language, 'themes/' . $this->getTheme()->getName() . '/messages');
 }
示例#30
0
文件: nfw.php 项目: nvlad/framework
define('kTplExt', '.tpl');
include kFWConfigPath . 'Bootstrap' . kPhpExt;
Core::init();
//Display::init();
//echo '<br>'.Request::host(2).'<br>';
foreach ($Apps as $App) {
    $matchedHost = true;
    if (isset($App[kAppsHost]) && $App[kAppsHost] !== null) {
        $matchedHost = false;
        $host = Request::host(isset($App[kAppsHostLevel]) ? $App[kAppsHostLevel] : 0);
        $matched = preg_match($App[kAppsHost], $host);
        if ($matched) {
            $matchedHost = true;
        }
    }
    $matchedPath = true;
    if ($matchedHost && isset($App[kAppsPath]) && $App[kAppsPath] !== null) {
        $matchedPath = false;
        $matched = preg_match($App[kAppsPath], $_SERVER['REQUEST_URI']);
        if ($matched) {
            $matchedPath = true;
        }
    }
    if ($matchedHost && $matchedPath) {
        Core::app($App);
        break;
    }
}
//$Display = Display::instance();
//$Display->layout('test');
//$Display->render('html');