diff --git a/neopolimatrix/api/elements/elements.php b/neopolimatrix/api/elements/elements.php index 7a546c0..362611b 100644 --- a/neopolimatrix/api/elements/elements.php +++ b/neopolimatrix/api/elements/elements.php @@ -3,6 +3,10 @@ class elements { public static function getAllElementsOfTag($tag){ return \DBD\NEOPOLIMATRIX_GENERATE_ELEMENTLIST::QA(array($tag));} + + public static function getAllElementsOfSearch($search){ + return \DBD\NEOPOLIMATRIX_GENERATE_ELEMENTLIST_FULLTEXT_SEARCH::QA(array($search));} + public static function getText($tag){ return \DBD\NEOPOLIMATRIX_GET_TEXT::Q1(array($tag));} } \ No newline at end of file diff --git a/neopolimatrix/page/autoload.inc b/neopolimatrix/page/autoload.inc index b017c11..4d696b5 100644 --- a/neopolimatrix/page/autoload.inc +++ b/neopolimatrix/page/autoload.inc @@ -4,4 +4,5 @@ SYSTEM\autoload::registerFolder(dirname(__FILE__).'/default_page',''); SYSTEM\autoload::registerFolder(dirname(__FILE__).'/default_list',''); SYSTEM\autoload::registerFolder(dirname(__FILE__).'/default_article',''); SYSTEM\autoload::registerFolder(dirname(__FILE__).'/default_impressum',''); +SYSTEM\autoload::registerFolder(dirname(__FILE__).'/default_search',''); diff --git a/neopolimatrix/page/default_page/js/default_page.js b/neopolimatrix/page/default_page/js/default_page.js index 43544b3..293ce0f 100644 --- a/neopolimatrix/page/default_page/js/default_page.js +++ b/neopolimatrix/page/default_page/js/default_page.js @@ -2,6 +2,7 @@ $(document).ready(function() { new SYSTEM('./api.php',1,'start;filter.1'); tabs(); impressum(); + search(); FB.XFBML.parse(document.body); }); @@ -11,6 +12,13 @@ function impressum(){ system.load('impressum');}); } +function search(){ + $("#nav_search_btn").click(function(){ + alert($('#nav_search').val()); + $('#contentframe').load('./?page=search¶m=' + $('#nav_search').val()); + }); +} + function tabs(){ $("#tabs_user_list a").click(function(){ $('#tabs_user_list li').each(function(){ diff --git a/neopolimatrix/page/default_search/default_search.php b/neopolimatrix/page/default_search/default_search.php new file mode 100644 index 0000000..c372204 --- /dev/null +++ b/neopolimatrix/page/default_search/default_search.php @@ -0,0 +1,49 @@ +param = $param; + } + + private static function time_elapsed_string($ptime){ + $etime = time() - $ptime; + if ($etime < 1){ + return '0 seconds';} + + $a = array( 12 * 30 * 24 * 60 * 60 => 'year', + 30 * 24 * 60 * 60 => 'month', + 24 * 60 * 60 => 'day', + 60 * 60 => 'hour', + 60 => 'minute', + 1 => 'second'); + + foreach ($a as $secs => $str){ + $d = $etime / $secs; + if ($d >= 1){ + $r = round($d); + return $r . ' ' . $str . ($r > 1 ? 's' : '') . ' ago';} + } + } + public function generate_list(){ + $result = ''; + $tag = $this->param; + $elements = elements::getAllElementsOfSearch('%' + $tag + '%'); + foreach($elements as $element){ + $element['title'] = $element['id']; + $element['published'] = date_format(new DateTime($element['timestamp']), 'H:i d-m-Y'); + $element['ago'] = $this->time_elapsed_string(strtotime($element['timestamp'])); + $result .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_search/tpl/element.tpl'), $element); + } + return $result; + } + public function html(){ + $vars = array(); + $vars['search'] = $this->generate_list(); + $vars = array_merge($vars, \SYSTEM\locale::getStrings(101)); + return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_search/tpl/search.tpl'), $vars); + } +} \ No newline at end of file diff --git a/neopolimatrix/page/default_search/tpl/element.tpl b/neopolimatrix/page/default_search/tpl/element.tpl new file mode 100644 index 0000000..b95fb14 --- /dev/null +++ b/neopolimatrix/page/default_search/tpl/element.tpl @@ -0,0 +1,10 @@ +
Author: ${author}
+Veröffentlicht: ${timestamp}
+ + +