started search api, param not handled...
This commit is contained in:
parent
5777b7b583
commit
9bf661accb
@ -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));}
|
||||
}
|
||||
@ -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','');
|
||||
|
||||
|
||||
@ -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(){
|
||||
|
||||
49
neopolimatrix/page/default_search/default_search.php
Normal file
49
neopolimatrix/page/default_search/default_search.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
class default_search extends \SYSTEM\PAGE\Page {
|
||||
|
||||
public static function js(){
|
||||
return array( \SYSTEM\WEBPATH(new PPAGE(),'default_search/js/default_search.js'));}
|
||||
|
||||
var $param = null;
|
||||
public function __construct($param) {
|
||||
$this->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);
|
||||
}
|
||||
}
|
||||
10
neopolimatrix/page/default_search/tpl/element.tpl
Normal file
10
neopolimatrix/page/default_search/tpl/element.tpl
Normal file
@ -0,0 +1,10 @@
|
||||
<div style="width: 750px; margin: auto; margin-bottom: 50px;">
|
||||
<p style="float: left; font-size: 10pt; margin-top: 7px;">Author: <i>${author}</i></p>
|
||||
<p style="float: right; font-size: 10pt; margin-top: 7px;">Veröffentlicht: ${timestamp}</p>
|
||||
<div style="clear: both;"></div>
|
||||
<div style="border-top: solid 1px black; width: 100%;"></div>
|
||||
<h2>${title}</h2>
|
||||
<br>
|
||||
${deDE}
|
||||
<br>
|
||||
</div>
|
||||
1
neopolimatrix/page/default_search/tpl/search.tpl
Normal file
1
neopolimatrix/page/default_search/tpl/search.tpl
Normal file
@ -0,0 +1 @@
|
||||
${search}
|
||||
@ -9,6 +9,9 @@ class page_neopolimatrix extends \SYSTEM\API\api_default {
|
||||
public static function page_article($id){
|
||||
return new default_article($id);}
|
||||
|
||||
public static function page_search($param){
|
||||
return new default_search($param);}
|
||||
|
||||
public static function page_impressum(){
|
||||
return new default_impressum();}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user