diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/functions.php | 11 | ||||
| -rw-r--r-- | src/init.php | 6 | ||||
| -rw-r--r-- | src/phinde/Autoloader.php | 21 | ||||
| -rw-r--r-- | src/phinde/Elasticsearch.php (renamed from src/Elasticsearch.php) | 12 | ||||
| -rw-r--r-- | src/phinde/Elasticsearch/Request.php (renamed from src/Elasticsearch/Request.php) | 0 | ||||
| -rw-r--r-- | src/phinde/Helper.php | 15 | ||||
| -rw-r--r-- | src/phinde/Html/Pager.php (renamed from src/Html/Pager.php) | 0 |
7 files changed, 52 insertions, 13 deletions
diff --git a/src/functions.php b/src/functions.php deleted file mode 100644 index fd91360..0000000 --- a/src/functions.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php -function isUrlAllowed($url) -{ - $urlDomain = parse_url($url, PHP_URL_HOST); - if (!in_array($urlDomain, $GLOBALS['phinde']['domains'])) { - return false; - } - return true; -} - -?> diff --git a/src/init.php b/src/init.php new file mode 100644 index 0000000..d6aa35f --- /dev/null +++ b/src/init.php @@ -0,0 +1,6 @@ +<?php +namespace phinde; +require_once __DIR__ . '/../src/phinde/Autoloader.php'; +Autoloader::register(); +require_once __DIR__ . '/../data/config.php'; +?> diff --git a/src/phinde/Autoloader.php b/src/phinde/Autoloader.php new file mode 100644 index 0000000..4717e1c --- /dev/null +++ b/src/phinde/Autoloader.php @@ -0,0 +1,21 @@ +<?php +namespace phinde; + +class Autoloader +{ + public static function autoload($class) + { + $file = str_replace(array('\\', '_'), '/', $class) + . '.php'; + if (stream_resolve_include_path($file)) { + require_once $file; + } + } + + public static function register() + { + set_include_path(__DIR__ . '/../' . PATH_SEPARATOR . get_include_path()); + spl_autoload_register('phinde\\Autoloader::autoload'); + } +} +?> diff --git a/src/Elasticsearch.php b/src/phinde/Elasticsearch.php index b3f3067..4bc4637 100644 --- a/src/Elasticsearch.php +++ b/src/phinde/Elasticsearch.php @@ -68,7 +68,7 @@ class Elasticsearch $r->send(); } - public function search($query, $page, $perPage) + public function search($query, $filters, $page, $perPage) { $r = new Elasticsearch_Request( $this->baseUrl . 'document/_search', @@ -94,7 +94,7 @@ class Elasticsearch 'term' => array( 'status' => 'indexed' ) - ) + ), ) ) ), @@ -126,6 +126,14 @@ class Elasticsearch //array('modate' => array('order' => 'desc')) ) ); + foreach ($filters as $type => $value) { + $doc['query']['bool']['must'][] = array( + 'term' => array( + $type => $value + ) + ); + } + //unset($doc['_source']); //ini_set('xdebug.var_display_max_depth', 10); diff --git a/src/Elasticsearch/Request.php b/src/phinde/Elasticsearch/Request.php index 7bb6add..7bb6add 100644 --- a/src/Elasticsearch/Request.php +++ b/src/phinde/Elasticsearch/Request.php diff --git a/src/phinde/Helper.php b/src/phinde/Helper.php new file mode 100644 index 0000000..4863961 --- /dev/null +++ b/src/phinde/Helper.php @@ -0,0 +1,15 @@ +<?php +namespace phinde; + +class Helper +{ + public static function isUrlAllowed($url) + { + $urlDomain = parse_url($url, PHP_URL_HOST); + if (!in_array($urlDomain, $GLOBALS['phinde']['domains'])) { + return false; + } + return true; + } +} +?> diff --git a/src/Html/Pager.php b/src/phinde/Html/Pager.php index a14a53d..a14a53d 100644 --- a/src/Html/Pager.php +++ b/src/phinde/Html/Pager.php |
