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


PHP Kwf_Setup::hasDb方法代码示例

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


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

示例1: _clearCache

 protected function _clearCache($options)
 {
     if (!Kwf_Setup::hasDb()) {
         $this->_output("skipped: (no db configured)\n");
         return;
     }
     Kwf_Component_Cache_Url_Abstract::getInstance()->clear();
 }
开发者ID:koala-framework,项目名称:koala-framework,代码行数:8,代码来源:ComponentUrl.php

示例2: _clearCache

 protected function _clearCache($options)
 {
     if (!Kwf_Config::getValue('debug.componentCache.clearOnClearCache')) {
         $this->_output("skipped: (won't delete, use clear-view-cache to clear)\n");
         return;
     }
     if (!Kwf_Setup::hasDb()) {
         $this->_output("skipped: (no db configured)\n");
         return;
     }
     Kwf_Component_Cache::getInstance()->deleteViewCache(array());
 }
开发者ID:koala-framework,项目名称:koala-framework,代码行数:12,代码来源:ComponentView.php

示例3: render

 public function render($ignoreCli = false)
 {
     try {
         if (isset($_SERVER['REQUEST_URI']) && Kwf_Setup::hasDb() && Kwf_Registry::get('dao')->getDbConfig()) {
             $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
             $target = Kwf_Model_Abstract::getInstance('Kwf_Util_Model_Redirects')->findRedirectUrl('path', $_SERVER['REQUEST_URI'], $host);
             if ($target) {
                 header('Location: ' . $target, true, 301);
                 exit;
             }
         }
     } catch (Exception $e) {
         Kwf_Debug::handleException($e);
     }
     parent::render($ignoreCli);
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:16,代码来源:NotFound.php

示例4: validateSettings

 public static function validateSettings($settings, $componentClass)
 {
     if (isset($settings['ownModel']) && $settings['ownModel']) {
         if (Kwf_Setup::hasDb()) {
             //only check if db is set up correclty (might not during installation)
             try {
                 $m = Kwf_Model_Abstract::getInstance($settings['ownModel']);
                 $pk = $m->getPrimaryKey();
             } catch (Exception $e) {
             }
             if (isset($pk) && $pk != 'component_id') {
                 throw new Kwf_Exception("ownModel for '{$componentClass}' must have 'component_id' as primary key");
             }
         }
     }
     if (isset($settings['tablename'])) {
         throw new Kwf_Exception("tablename for '{$componentClass}' is set - please convert to model");
     }
     if (isset($settings['modelname'])) {
         throw new Kwf_Exception("modelname for '{$componentClass}' is set - please rename into ownModel or childModel");
     }
     if (isset($settings['model'])) {
         throw new Kwf_Exception("model for '{$componentClass}' is set - please rename into ownModel or childModel");
     }
     if (isset($settings['formModel'])) {
         throw new Kwf_Exception("formModel is no longer supported. Set the model in the FrontendForm.php. Component: '{$componentClass}'");
     }
     if (isset($settings['assets'])) {
         $f = strpos($componentClass, '.') ? substr($componentClass, 0, strpos($componentClass, '.')) : $componentClass;
         $f = str_replace('_', '/', $f);
         foreach ($settings['assets']['files'] as $i) {
             if (substr($i, -strlen($f) - 3) == $f . '.js') {
                 throw new Kwf_Exception("Remove Component.js from assets setting, it's found automatically.");
             }
             if (substr($i, -strlen($f) - 4) == $f . '.css') {
                 throw new Kwf_Exception("Remove Component.css from assets setting, it's found automatically.");
             }
             if (substr($i, -strlen($f) - 5) == $f . '.scss') {
                 throw new Kwf_Exception("Remove Component.scss from assets setting, it's found automatically.");
             }
         }
     }
 }
开发者ID:koala-framework,项目名称:koala-framework,代码行数:43,代码来源:Abstract.php

示例5: getInstance

 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
         // automatisches einloggen
         $autologin = Zend_Registry::get('config')->autologin;
         if ($autologin && Kwf_Setup::hasDb()) {
             $storage = self::$_instance->getStorage();
             $loginData = $storage->read();
             if (!isset($loginData['userId']) || !$loginData['userId']) {
                 $userModel = Zend_Registry::get('userModel');
                 $r = $userModel->getRow($userModel->select()->whereEquals('email', $autologin));
                 if (!$r) {
                     $msg = "Autologin email '{$autologin}' does not exists";
                     throw new Kwf_Exception("autologin failed: {$msg}");
                 }
                 $loginData['userId'] = $r->id;
                 $storage->write($loginData);
             }
         }
     }
     return self::$_instance;
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:23,代码来源:Auth.php

示例6: generateCode


//.........这里部分代码省略.........
                     $ret .= "'" . $d . "'=>true, ";
                 }
                 $ret .= ");\n";
                 $ret .= "\$supportsHttps = isset(\$_SERVER['HTTP_HOST']) && isset(\$domains[\$_SERVER['HTTP_HOST']]);\n";
                 $ret .= "if (\$supportsHttps != isset(\$_SERVER['HTTPS'])) {\n";
                 $ret .= "    if (\$supportsHttps) {\n";
                 $ret .= "        {$redirectHttpsCode}";
                 $ret .= "    } else {\n";
                 $ret .= "        {$redirectHttpCode}";
                 $ret .= "    }\n";
                 $ret .= "}\n";
             } else {
                 $ret .= "if (!isset(\$_SERVER['HTTPS'])) {\n";
                 $ret .= "{$redirectHttpsCode}";
                 $ret .= "}\n";
             }
         }
         $ret .= "}\n";
     }
     $ret .= "session_set_cookie_params(\n";
     $ret .= " 0,";
     //lifetime
     $ret .= " '" . Kwf_Setup::getBaseUrl() . "/',";
     //path
     $ret .= " null,";
     //domain
     $ret .= " isset(\$_SERVER['HTTPS']),";
     //secure
     $ret .= " true";
     //httponly
     $ret .= ");\n";
     $ret .= "\n";
     //store session data in memcache if avaliable
     if ((Kwf_COnfig::getValue('server.memcache.host') || Kwf_Config::getValue('aws.simpleCacheCluster')) && Kwf_Setup::hasDb()) {
         $ret .= "\nif (PHP_SAPI != 'cli') Kwf_Util_SessionHandler::init();\n";
     }
     //up here to have less dependencies or broken redirect
     $ret .= "\n";
     $ret .= "if (substr(\$requestUri, 0, 14) == '/kwf/util/apc/'\n";
     $ret .= ") {\n";
     $ret .= "    Kwf_Util_Apc::dispatchUtils();\n";
     $ret .= "}\n";
     // Falls redirectToDomain eingeschalten ist, umleiten
     if (Kwf_Config::getValue('server.redirectToDomain')) {
         $ret .= "if (\$host && substr(\$requestUri, 0, 17) != '/kwf/maintenance/' && substr(\$requestUri, 0, 8) != '/assets/') {\n";
         $ret .= "    \$redirect = false;\n";
         if ($domains = Kwf_Config::getValueArray('kwc.domains')) {
             $ret .= "    \$domainMatches = false;\n";
             foreach ($domains as $domain) {
                 $ret .= "    if ('{$domain['domain']}' == \$host) \$domainMatches = true;\n";
             }
             $ret .= "    if (!\$domainMatches) {\n";
             foreach ($domains as $domain) {
                 if (isset($domain['pattern'])) {
                     $ret .= "\n";
                     $ret .= "        //pattern\n";
                     $ret .= "        if (!\$domainMatches && preg_match('/{$domain['pattern']}/', \$host)) {\n";
                     $ret .= "            \$domainMatches = true;\n";
                     if (isset($domain['noRedirectPattern'])) {
                         $ret .= "\n";
                         $ret .= "            //noRedirectPattern\n";
                         $ret .= "            if (!preg_match('/{$domain['noRedirectPattern']}/', \$host)) {\n";
                         $ret .= "                \$redirect = '{$domain['domain']}';\n";
                         $ret .= "            }\n";
                     } else {
                         $ret .= "            \$redirect = '{$domain['domain']}';\n";
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:67,代码来源:Setup.php

示例7: setUp

 public static function setUp($configClass = 'Kwf_Config_Web')
 {
     error_reporting(E_ALL & ~E_STRICT);
     define('APP_PATH', getcwd());
     Kwf_Setup::$configClass = $configClass;
     if (PHP_SAPI == 'cli') {
         //don't use cached setup on cli so clear-cache will always work even if eg. paths change
         require_once dirname(__FILE__) . '/../Kwf/Util/Setup.php';
         Kwf_Util_Setup::minimalBootstrap();
         eval(substr(Kwf_Util_Setup::generateCode(), 5));
     } else {
         if (!@(include APP_PATH . '/cache/setup' . self::CACHE_SETUP_VERSION . '.php')) {
             if (!file_exists(APP_PATH . '/cache/setup' . self::CACHE_SETUP_VERSION . '.php')) {
                 require_once dirname(__FILE__) . '/../Kwf/Util/Setup.php';
                 Kwf_Util_Setup::minimalBootstrapAndGenerateFile();
             }
             include APP_PATH . '/cache/setup' . self::CACHE_SETUP_VERSION . '.php';
         }
     }
     if (!defined('VKWF_PATH') && PHP_SAPI != 'cli' && self::getBaseUrl() === null) {
         //if server.baseUrl is not set try to auto detect it and generate config.local.ini accordingly
         //this code is not used if server.baseUrl is set to "" in vkwf
         if (!isset($_SERVER['PHP_SELF'])) {
             echo "Can't detect baseUrl, PHP_SELF is not set\n";
             exit(1);
         }
         $baseUrl = substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'));
         if (substr($baseUrl, -16) == '/kwf/maintenance') {
             $baseUrl = substr($baseUrl, 0, -16);
         }
         $cfg = "[production]\n";
         $cfg .= "server.domain = \"{$_SERVER['HTTP_HOST']}\"\n";
         $cfg .= "server.baseUrl = \"{$baseUrl}\"\n";
         $cfg .= "setupFinished = false\n";
         if (file_exists('config.local.ini') && filesize('config.local.ini') > 0) {
             echo "config.local.ini already exists but server.baseUrl is not set\n";
             exit(1);
         }
         if (!is_writable('.')) {
             echo "'" . getcwd() . "' is not writable, can't create config.local.ini\n";
             exit(1);
         }
         file_put_contents('config.local.ini', $cfg);
         Kwf_Config_Web::reload();
         Kwf_Config::deleteValueCache('server.domain');
         Kwf_Config::deleteValueCache('server.baseUrl');
         unlink('cache/setup' . self::CACHE_SETUP_VERSION . '.php');
         echo "<h1>" . Kwf_Config::getValue('application.name') . "</h1>\n";
         echo "<a href=\"{$baseUrl}/kwf/maintenance/setup\">[start setup]</a>\n";
         exit;
     }
     if (isset($_SERVER['REQUEST_URI']) && substr($_SERVER['REQUEST_URI'], 0, 5) == '/kwf/') {
         if (substr($_SERVER['REQUEST_URI'], 0, 9) == '/kwf/pma/' || $_SERVER['REQUEST_URI'] == '/kwf/pma') {
             Kwf_Util_Pma::dispatch();
         } else {
             if ($_SERVER['REQUEST_URI'] == '/kwf/check') {
                 $ok = true;
                 $msg = '';
                 if (Kwf_Setup::hasDb()) {
                     $date = Kwf_Registry::get('db')->query("SELECT NOW()")->fetchColumn();
                     if (!$date) {
                         $ok = false;
                         $msg .= 'mysql connection failed';
                     }
                 }
                 if (file_exists('instance_startup')) {
                     //can be used while starting up autoscaling instances
                     $ok = false;
                     $msg .= 'instance startup in progress';
                 }
                 if (!$ok) {
                     header("HTTP/1.0 500 Error");
                     echo "<h1>Check failed</h1>";
                     echo $msg;
                 } else {
                     echo "ok";
                 }
                 exit;
             }
         }
     }
     Kwf_Benchmark::checkpoint('setUp');
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:83,代码来源:Setup.php

示例8: getAuthedUserRole

 public function getAuthedUserRole()
 {
     if (php_sapi_name() == 'cli') {
         return 'cli';
     }
     if (!Kwf_Setup::hasDb()) {
         return 'guest';
     }
     $loginData = Kwf_Auth::getInstance()->getStorage()->read();
     if (isset($loginData['userRole'])) {
         return $loginData['userRole'];
     }
     $u = $this->getAuthedUser();
     return $u ? $u->role : 'guest';
 }
开发者ID:nsams,项目名称:koala-framework,代码行数:15,代码来源:Model.php


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