当前位置: 首页>>代码示例>>PHP>>正文


PHP waSystem::getApp方法代码示例

本文整理汇总了PHP中waSystem::getApp方法的典型用法代码示例。如果您正苦于以下问题:PHP waSystem::getApp方法的具体用法?PHP waSystem::getApp怎么用?PHP waSystem::getApp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在waSystem的用法示例。


在下文中一共展示了waSystem::getApp方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepare

 protected function prepare()
 {
     $this->assign('wa_url', $this->system->getRootUrl());
     $this->assign('wa_backend_url', waSystem::getInstance()->getConfig()->getBackendUrl(true));
     $this->assign('wa_app', $this->system->getApp());
     $this->assign('wa_app_url', $this->system->getAppUrl(null, true));
     $this->assign('wa_app_static_url', $this->system->getAppStaticUrl());
     if (!$this->helper) {
         $this->helper = new waViewHelper($this);
     }
     $this->assign('wa', $this->helper);
 }
开发者ID:nowaym,项目名称:webasyst-framework,代码行数:12,代码来源:waView.class.php

示例2: getUrl

 public function getUrl($path, $params = array(), $absolute = false)
 {
     if (is_bool($params)) {
         $absolute = $params;
         $params = array();
     }
     $parts = explode('/', $path);
     $app = $parts[0];
     if (!$app) {
         $app = $this->system->getApp();
     }
     if (isset($parts[1])) {
         $params['module'] = $parts[1];
     }
     if (isset($parts[2])) {
         $params['action'] = $parts[2];
     }
     $routes = array();
     if (!$this->route || $this->route['app'] != $app || !isset($this->route['module']) && isset($params['module']) && $params['module'] != 'frontend' || isset($this->route['module']) && isset($params['module']) && $this->route['module'] != $params['module']) {
         // find base route
         if (isset($params['domain'])) {
             $routes[$params['domain']] = $this->getRoutes($params['domain']);
             unset($params['domain']);
         } else {
             $routes = $this->routes;
         }
         // filter by app and module
         foreach ($routes as $domain => $domain_routes) {
             foreach ($domain_routes as $r_id => $r) {
                 if (!isset($r['app']) || $r['app'] != $app || isset($params['module']) && isset($r['module']) && $r['module'] != $params['module']) {
                     unset($routes[$domain][$r_id]);
                 }
             }
             if (!$routes[$domain]) {
                 unset($routes[$domain]);
             }
         }
     } else {
         $routes[$this->getDomain()] = array($this->route);
     }
     $max = -1;
     $result = null;
     foreach ($routes as $domain => $domain_routes) {
         foreach ($domain_routes as $r) {
             $i = $this->countParams($r, $params);
             if (isset($params['module']) && isset($r['module'])) {
                 $i++;
             }
             if ($absolute || $this->getDomain() != $domain) {
                 $root_url = self::getUrlByRoute($r, $domain);
             } else {
                 $root_url = $this->system->getRootUrl(false, true) . self::clearUrl($r['url']);
             }
             if ($i > $max) {
                 $max = $i;
                 $result = $root_url;
             }
             $app_routes = $this->getAppRoutes($r['app'], $r);
             foreach ($app_routes as $app_r) {
                 $j = $i + $this->countParams($app_r, $params);
                 if (!isset($params['action']) && !isset($app_r['action'])) {
                     $j++;
                 }
                 $u = $app_r['url'];
                 if (preg_match_all('/<([a-z_]+):?([^>]*)?>/ui', $u, $match, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
                     $offset = 0;
                     foreach ($match as $m) {
                         $v = $m[1][0];
                         if (isset($params[$v])) {
                             $u = substr($u, 0, $m[0][1] + $offset) . $params[$v] . substr($u, $m[0][1] + $offset + strlen($m[0][0]));
                             $offset += strlen($params[$v]) - strlen($m[0][0]);
                             $j++;
                         } else {
                             if (substr($u, $m[0][1] - 1, 1) === '(' && substr($u, $m[0][1] + strlen($m[0][0]), 3) === '/)?') {
                                 $u = substr($u, 0, $m[0][1] - 1) . substr($u, $m[0][1] + strlen($m[0][0]) + 3);
                             } else {
                                 continue 2;
                             }
                         }
                     }
                 }
                 if ($j >= $max || $result === null) {
                     if ($j == $max && $this->getDomain() && $domain != $this->getDomain() && $result) {
                     } else {
                         $max = $j;
                         $result = $root_url . self::clearUrl($u);
                     }
                 }
             }
         }
     }
     return $result;
 }
开发者ID:nowaym,项目名称:webasyst-framework,代码行数:93,代码来源:waRouting.class.php

示例3: execute

 /** Execute appropriate controller and return it's result.
  * Throw 404 exception if no controller found. */
 public function execute($plugin = null, $module = null, $action = null, $default = false)
 {
     if (!$this->system->getConfig()->checkRights($module, $action)) {
         throw new waRightsException(_ws("Access denied."));
     }
     // current app prefix
     $prefix = $this->system->getConfig()->getPrefix();
     // Load plugin locale and set plugin as active
     if ($plugin) {
         $plugin_path = $this->system->getAppPath('plugins/' . $plugin, $this->system->getApp());
         if (!file_exists($plugin_path . '/lib/config/plugin.php')) {
             $plugin = null;
         } else {
             $plugin_info = (include $plugin_path . '/lib/config/plugin.php');
             // check rights
             if (isset($plugin_info['rights']) && $plugin_info['rights']) {
                 if (!$this->system->getUser()->getRights($this->system->getConfig()->getApplication(), 'plugin.' . $plugin)) {
                     throw new waRightsException(_ws("Access denied"), 403);
                 }
             }
             waSystem::pushActivePlugin($plugin, $prefix);
             if (is_dir($plugin_path . '/locale')) {
                 waLocale::load($this->system->getLocale(), $plugin_path . '/locale', waSystem::getActiveLocaleDomain(), false);
             }
         }
     }
     // custom login and signup
     if (wa()->getEnv() == 'frontend') {
         if (!$plugin && !$action && $module == 'login') {
             $login_action = $this->system->getConfig()->getFactory('login_action');
             if ($login_action) {
                 $controller = $this->system->getDefaultController();
                 $controller->setAction($login_action);
                 $r = $controller->run();
                 return $r;
             }
         } elseif (!$plugin && !$action && $module == 'signup') {
             $signup_action = $this->system->getConfig()->getFactory('signup_action');
             if ($signup_action) {
                 $controller = $this->system->getDefaultController();
                 $controller->setAction($signup_action);
                 $r = $controller->run();
                 return $r;
             }
         }
     }
     //
     // Check possible ways to handle the request one by one
     //
     // list of failed class names (for debugging)
     $class_names = array();
     // Single Controller (recomended)
     $class_name = $prefix . ($plugin ? ucfirst($plugin) . 'Plugin' : '') . ucfirst($module) . ($action ? ucfirst($action) : '') . 'Controller';
     if (class_exists($class_name, true)) {
         /**
          * @var $controller waController
          */
         $controller = new $class_name();
         $r = $controller->run();
         if ($plugin) {
             waSystem::popActivePlugin();
         }
         return $r;
     }
     $class_names[] = $class_name;
     // Single Action
     $class_name = $prefix . ($plugin ? ucfirst($plugin) . 'Plugin' : '') . ucfirst($module) . ($action ? ucfirst($action) : '') . 'Action';
     if (class_exists($class_name)) {
         // get default view controller
         /**
          * @var $controller waDefaultViewController
          */
         $controller = $this->system->getDefaultController();
         $controller->setAction($class_name);
         $r = $controller->run();
         if ($plugin) {
             waSystem::popActivePlugin();
         }
         return $r;
     }
     $class_names[] = $class_name;
     // Controller Multi Actions, Zend/Symfony style
     $class_name = $prefix . ($plugin ? ucfirst($plugin) . 'Plugin' : '') . ucfirst($module) . 'Actions';
     if (class_exists($class_name, true)) {
         $controller = new $class_name();
         $r = $controller->run($action);
         if ($plugin) {
             waSystem::popActivePlugin();
         }
         return $r;
     }
     $class_names[] = $class_name;
     // Plugin is no longer active
     if ($plugin) {
         waSystem::popActivePlugin();
     }
     // Last chance: default action for this module
     if ($action && $default) {
//.........这里部分代码省略.........
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:101,代码来源:waFrontController.class.php

示例4: __toString

    public function __toString()
    {
        try {
            $wa = wa();
            $additional_info = '';
        } catch (Exception $e) {
            $wa = null;
            $additional_info = $e->getMessage();
        }
        $message = nl2br($this->getMessage());
        if ($wa && waSystem::getApp()) {
            $app = $wa->getAppInfo();
            $backend_url = $wa->getConfig()->getBackendUrl(true);
        } else {
            $app = array();
        }
        if (!waSystemConfig::isDebug() && $wa) {
            $env = $wa->getEnv();
            $file = $code = $this->getCode();
            if (!$code || !file_exists(dirname(__FILE__) . '/data/' . $code . '.php')) {
                $file = 'error';
            }
            include dirname(__FILE__) . '/data/' . $file . '.php';
            exit;
        }
        if ($wa && $wa->getEnv() == 'cli' || !$wa && php_sapi_name() == 'cli') {
            return date("Y-m-d H:i:s") . " php " . implode(" ", waRequest::server('argv')) . "\n" . "Error: {$this->getMessage()}\nwith code {$this->getCode()} in '{$this->getFile()}' around line {$this->getLine()}:{$this->getFileContext()}\n" . $this->getTraceAsString() . "\n" . ($additional_info ? "Error while initializing waSystem during error generation: " . $additional_info . "\n" : '');
        } elseif ($this->code == 404) {
            $response = new waResponse();
            $response->setStatus(404);
            $response->sendHeaders();
        }
        $request = htmlentities(var_export($_REQUEST, true), ENT_NOQUOTES, 'utf-8');
        $params = htmlentities(var_export(waRequest::param(), true), ENT_NOQUOTES, 'utf-8');
        $context = htmlentities($this->getFileContext(), ENT_NOQUOTES, 'utf-8');
        $trace = htmlentities($this->getTraceAsString(), ENT_NOQUOTES, 'utf-8');
        $result = <<<HTML
<div style="width:99%; position:relative; text-align: left;">
\t<h2 id='Title'>{$message}</h2>
\t<div id="Context" style="display: block;">
\t\t<h3>Error with code {$this->getCode()} in '{$this->getFile()}' around line {$this->getLine()}:</h3>
\t\t<pre>{$context}</pre>
\t</div>
\t<div id="Trace">
\t\t<h2>Call stack</h2>
\t\t<pre>{$trace}</pre>
\t</div>
\t<div id="Request">
\t\t<h2>Request</h2>
\t\t<pre>{$request}</pre>
    </div>
</div>
<div style="text-align: left;">
    <h2>Params</h2>
    <pre>{$params}</pre>
</div>
HTML;
        if ($additional_info) {
            $additional_info = htmlentities($additional_info, ENT_NOQUOTES, 'utf-8');
            $result .= <<<HTML

<div style="text-align: left;">
    <h2>Error while initializing waSystem during error generation</h2>
    <pre>{$additional_info}</pre>
</div>
HTML;
        }
        return $result;
    }
开发者ID:Lazary,项目名称:webasyst,代码行数:69,代码来源:waException.class.php

示例5: userRights

 public function userRights($name)
 {
     return $this->wa->getUser()->getRights($this->wa->getApp(), $name);
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:4,代码来源:waViewHelper.class.php

示例6: prepare

 protected function prepare()
 {
     $this->smarty->compile_id = isset($this->options['compile_id']) ? $this->system->getApp() . "_" . $this->options['compile_id'] : $this->system->getApp() . "_" . $this->system->getLocale();
     parent::prepare();
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:5,代码来源:waSmarty3View.class.php

示例7: app

 public function app()
 {
     return $this->wa->getApp();
 }
开发者ID:nowaym,项目名称:webasyst-framework,代码行数:4,代码来源:waViewHelper.class.php

示例8: getPageModel

 /**
  * @return waPageModel
  */
 protected function getPageModel()
 {
     $class = $this->wa->getApp() . 'PageModel';
     return new $class();
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:8,代码来源:waAppViewHelper.class.php


注:本文中的waSystem::getApp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。