コード例 #1
0
 function createCacheConnectionByName($name)
 {
     $conf = $this->toolkit->getConf('cache');
     if (!$conf->get('cache_enabled')) {
         return $this->createCacheFakeConnection();
     } else {
         try {
             $dsn = lmbToolkit::instance()->getConf('cache')->get($name . '_cache_dsn');
             if (!is_object($dsn)) {
                 $dsn = new lmbUri($dsn);
             }
             if (!($wrapper = $dsn->getQueryItem('wrapper'))) {
                 $wrapper = array();
             }
             if ($conf->get('taggable_cache_enabled', false)) {
                 $wrapper[] = 'taggable';
             }
             if ($conf->get('mint_cache_enabled', false)) {
                 $wrapper[] = 'mint';
             }
             if ($conf->get('cache_log_enabled', false)) {
                 $wrapper[] = 'logged';
             }
             $dsn->addQueryItem('wrapper', $wrapper);
             return $this->createCacheConnectionByDSN($dsn);
         } catch (Exception $e) {
             return $this->createCacheFakeConnection();
         }
     }
 }
コード例 #2
0
 function testNotifyExternalUrl()
 {
     $observer = new lmbInnerUriNormalizerObserver(new lmbUri('http://test.com'));
     $this->reader->expectOnce('getUri');
     $this->reader->setReturnReference('getUri', $uri = new lmbUri('http://test2.com/page.html'));
     $observer->notify($this->reader);
     $this->assertEqual($uri->toString(), 'http://test2.com/page.html');
 }
コード例 #3
0
 function testCreateCacheConnectionByDSN_WithWrapper()
 {
     $dsn = new lmbUri('memory:');
     $dsn->addQueryItem('wrapper', array('mint', 'logged'));
     $connection = lmbToolkit::instance()->createCacheConnectionByDSN($dsn);
     $this->assertEqual($connection->getType(), 'memory');
     $this->assertIsA($connection, 'lmbLoggedCacheWrapper');
     $this->assertIsA($connection->getWrappedConnection(), 'lmbMintCacheWrapper');
     $this->assertIsA($connection->getWrappedConnection()->getWrappedConnection(), 'lmbCacheMemoryConnection');
 }
コード例 #4
0
 /**
  * @param lmbUri $dsn
  * @return array
  */
 protected static function getWrappers($dsn)
 {
     if (!($wrappers = $dsn->getQueryItem('wrapper'))) {
         return array();
     }
     if (!is_array($wrappers)) {
         $wrappers = array($wrappers);
     }
     return $wrappers;
 }
コード例 #5
0
 function parse($dsn = "php://input")
 {
     $put = fopen($dsn, "r");
     $query_string = '';
     while ($put_string = fread($put, 1024)) {
         $query_string .= $put_string;
     }
     $uri = new lmbUri();
     $uri->setQueryString($query_string);
     return $uri->getQueryItems();
 }
コード例 #6
0
 protected function _getHttpBasePathOffsetLevel($uri)
 {
     if (!$this->path_offset) {
         return 0;
     }
     $base_path_uri = new lmbUri(rtrim($this->base_path, '/'));
     $base_path_uri->normalizePath();
     $level = 1;
     while ($uri->getPathElement($level) == $base_path_uri->getPathElement($level) && $level < $base_path_uri->countPath()) {
         $level++;
     }
     return $level;
 }
コード例 #7
0
ファイル: lmbLogTools.class.php プロジェクト: knevcher/limb
 protected function _createLogWriter($dsn)
 {
     if (!is_object($dsn)) {
         $dsn = new lmbUri($dsn);
     }
     $writer_name = 'lmbLog' . ucfirst($dsn->getProtocol()) . 'Writer';
     $writer_file = 'limb/log/src/' . $writer_name . '.class.php';
     try {
         lmb_require($writer_file);
         $writer = new $writer_name($dsn);
         return $writer;
     } catch (lmbFileNotFoundException $e) {
         throw new lmbFileNotFoundException($writer_file, 'Log writer not found');
     }
 }
コード例 #8
0
 function __construct($dsn)
 {
     if (!is_object($dsn)) {
         $dsn = new lmbUri($dsn);
     }
     $this->dsn = $dsn;
     foreach ($dsn as $option_name => $option_value) {
         if (!is_null($option_value)) {
             $this->{$option_name} = $option_value;
         }
     }
     foreach ($dsn->getQueryItems() as $option_name => $option_value) {
         if (!is_null($option_value)) {
             $this->{$option_name} = $option_value;
         }
     }
 }
コード例 #9
0
ファイル: lmbDbDSN.class.php プロジェクト: knevcher/limb
 function buildUri()
 {
     $uri = new lmbUri();
     $uri->setProtocol($this->driver);
     $uri->setHost($this->host);
     $uri->setUser($this->get('user', ''));
     $uri->setPassword($this->get('password', ''));
     $uri->setPath('/' . $this->get('database', ''));
     if (isset($this->port)) {
         $uri->setPort($this->port);
     }
     if (count($this->extra)) {
         $uri->setQueryItems($this->extra);
     }
     return $uri;
 }
コード例 #10
0
 function testChaining()
 {
     $uri = new lmbUri();
     $uri->addQueryItem('chaining', 'supported')->setHost('everywhere.com')->setPath('/')->setProtocol('http');
     $this->assertEqual('http://everywhere.com/?chaining=supported', $uri->toString());
 }
コード例 #11
0
ファイル: lmbUriTest.class.php プロジェクト: knevcher/limb
 function testUrlDecode()
 {
     $test_value = '+text';
     $uri = new lmbUri('/index.html?var=' . urlencode($test_value));
     $q_items = $uri->getQueryItems();
     $this->assertEqual($q_items['var'], $test_value);
 }
コード例 #12
0
ファイル: lmbRoutes.class.php プロジェクト: snowjobgit/limb
 protected function _getHttpBasePathOffsetLevel($uri)
 {
     if (!lmb_env_get('LIMB_HTTP_OFFSET_PATH')) {
         return 0;
     }
     $base_path = $uri->toString(array('protocol', 'user', 'password', 'host', 'port')) . '/' . lmb_env_get('LIMB_HTTP_OFFSET_PATH');
     $base_path_uri = new lmbUri(rtrim($base_path, '/'));
     $base_path_uri->normalizePath();
     $level = 1;
     while ($uri->getPathElement($level) == $base_path_uri->getPathElement($level) && $level < $base_path_uri->countPath()) {
         $level++;
     }
     return $level;
 }
コード例 #13
0
ファイル: indexer.php プロジェクト: snowjobgit/limb
 * @version $Id: indexer.php 7686 2009-03-04 19:57:12Z korchasa $
 */
if (!isset($argv[1])) {
    die("index starting uri not specified!\n");
}
$path = $_SERVER['LIMB_PROJECT_DIR'];
require_once $path . '/setup.php';
lmb_require('limb/net/src/lmbUri.class.php');
lmb_require('limb/web_spider/src/lmbWebSpider.class.php');
lmb_require('limb/web_spider/src/lmbUriFilter.class.php');
lmb_require('limb/web_spider/src/lmbContentTypeFilter.class.php');
lmb_require('limb/web_spider/src/lmbSearchIndexingObserver.class.php');
lmb_require('limb/search/src/indexer/lmbFullTextSearchIndexer.class.php');
lmb_require('limb/search/src/indexer/lmbSearchTextNormalizer.class.php');
lmb_require('limb/web_spider/src/lmbUriNormalizer.class.php');
$uri = new lmbUri($argv[1]);
$indexer = new lmbFullTextSearchIndexer(new lmbSearchTextNormalizer());
$indexer->useNOINDEX();
$observer = new lmbSearchIndexingObserver($indexer);
$content_type_filter = new lmbContentTypeFilter();
$content_type_filter->allowContentType('text/html');
$uri_filter = new lmbUriFilter();
$uri_filter->allowHost($uri->getHost());
$uri_filter->allowProtocol('http');
$uri_filter->allowPathRegex('~.*~');
$normalizer = new lmbUriNormalizer();
$normalizer->stripQueryItem('PHPSESSID');
$spider = new lmbWebSpider();
$spider->setContentTypeFilter($content_type_filter);
$spider->setUriFilter($uri_filter);
$spider->setUriNormalizer($normalizer);
コード例 #14
0
 /**
  * @param lmbUri $dsn
  */
 function __construct(lmbUri $dsn)
 {
     $this->_dsn = $dsn;
     $this->_log_level = ($level = $this->_dsn->getQueryItem('level')) !== false ? $level : LOG_INFO;
     $this->check_client_extension = $dsn->getQueryItem('check_extension', 1);
 }
コード例 #15
0
 /**
  * @param string|lmbUri $dsn
  * @return lmbLogWriter
  */
 function createLogWriterByDSN($dsn)
 {
     if (!is_object($dsn)) {
         $dsn = new lmbUri($dsn);
     }
     if (!$dsn->getProtocol()) {
         throw new lmbException('Empty log writer type', array('dsn' => $dsn->toString()));
     }
     $writer_name = 'lmbLog' . ucfirst($dsn->getProtocol()) . 'Writer';
     $writer_file = 'limb/log/src/writers/' . $writer_name . '.class.php';
     try {
         lmb_require($writer_file);
         $writer = new $writer_name($dsn);
         return $writer;
     } catch (lmbFileNotFoundException $e) {
         throw new lmbFileNotFoundException($writer_file, 'Log writer not found');
     }
 }
コード例 #16
0
 function __construct(lmbUri $dsn)
 {
     $this->log_file = $dsn->getPath();
     parent::__construct($dsn);
 }
コード例 #17
0
 function __construct(lmbUri $dsn)
 {
     $this->check_client_extension = $dsn->getQueryItem('check_extension', 1);
 }