ajax crawling scheme prototype
This commit is contained in:
parent
dd3393ba7c
commit
5ebb40d49d
@ -29,7 +29,7 @@ class api {
|
||||
|
||||
//Commands
|
||||
$commands = self::do_commands($params, $tree);
|
||||
if(count($commands) <= 0){
|
||||
if(count($commands) <= 0){
|
||||
return self::do_default($default, $apiclassname);} //throws
|
||||
|
||||
//Parameters
|
||||
@ -85,7 +85,7 @@ class api {
|
||||
if( !method_exists($verifyclassname, $item[\SYSTEM\DBD\system_api::FIELD_VERIFY]) ||
|
||||
!call_user_func(array($verifyclassname,$item[\SYSTEM\DBD\system_api::FIELD_VERIFY]),$params[$item[\SYSTEM\DBD\system_api::FIELD_NAME]])){
|
||||
throw new \SYSTEM\LOG\ERROR('Parameter type missmacht or Missing Verifier. Param: '.$item[\SYSTEM\DBD\system_api::FIELD_NAME].' Verifier: '.$item[\SYSTEM\DBD\system_api::FIELD_VERIFY]);}
|
||||
|
||||
//throw new \SYSTEM\LOG\ERROR("yo ".$call_funcname.' '.$apiclassname);
|
||||
\call_user_func_array(array($apiclassname,$call_funcname),array($params[$item[\SYSTEM\DBD\system_api::FIELD_NAME]]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,18 @@
|
||||
namespace SYSTEM\API;
|
||||
|
||||
abstract class api_default {
|
||||
//https://developers.google.com/webmasters/ajax-crawling/docs/getting-started
|
||||
public static function static__escaped_fragment_($_escaped_fragment_){
|
||||
$state = \SYSTEM\PAGE\State::get(1, $_escaped_fragment_,false);
|
||||
$result = '';
|
||||
foreach($state as $row){
|
||||
parse_str(\parse_url($row['url'],PHP_URL_QUERY), $params);
|
||||
$result .= \SYSTEM\API\api::run('\SYSTEM\API\verify', 'page_neopolimatrix', $params, 1, true, true)->html();
|
||||
}
|
||||
echo $result;//echo (new \default_page())->html();
|
||||
die();
|
||||
}
|
||||
|
||||
public static function default_page(){
|
||||
throw new RuntimeException("Unimplemented");}
|
||||
throw new \RuntimeException("Unimplemented");}
|
||||
}
|
||||
2
dbd/sql/mysql/data/system_api_default.sql
Normal file
2
dbd/sql/mysql/data/system_api_default.sql
Normal file
@ -0,0 +1,2 @@
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (0, 1, 4, -1, NULL, '_escaped_fragment_', 'STRING');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1, 1, 0, -1, NULL, 'page', NULL);
|
||||
@ -22,7 +22,7 @@ SYSTEM.prototype.handle_call_pages = function (data,id) {
|
||||
if(data['status']){
|
||||
system.log(system.LOG_INFO,'load pages: endpoint '+system.endpoint+':group '+system.group+':state '+id+' - success');
|
||||
if(id !== system.cur_state()){
|
||||
window.history.pushState(null, "", '#'+id);}
|
||||
window.history.pushState(null, "", '#!'+id);}
|
||||
data['result'].forEach(function(entry) {
|
||||
//load pages
|
||||
$.ajax({
|
||||
@ -115,8 +115,8 @@ SYSTEM.prototype.load_css = function loadCSS(csssrc) {
|
||||
//what?
|
||||
SYSTEM.prototype.cur_state = function() {
|
||||
var pathName = window.location.href;
|
||||
if (pathName.indexOf('#') != -1) {
|
||||
return pathName.split('#').pop();}
|
||||
if (pathName.indexOf('#!') != -1) {
|
||||
return pathName.split('#!').pop();}
|
||||
return '';
|
||||
};
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace SYSTEM\PAGE;
|
||||
class State {
|
||||
public static function get($group,$state){
|
||||
public static function get($group,$state,$returnasjson=true){
|
||||
$state = \explode(';', $state);
|
||||
$vars = array();
|
||||
for($i=1;$i<count($state);$i++){
|
||||
@ -12,10 +12,10 @@ class State {
|
||||
while($row = $res->next()){
|
||||
$row['url'] = \SYSTEM\PAGE\replace::replace($row['url'], $vars);
|
||||
$row['css'] = $row['js'] = array();
|
||||
if(/*\is_callable($row['php_class']) &&*/ \class_exists($row['php_class']) && \method_exists($row['php_class'], 'css') && \is_callable($row['php_class'].'::css')){
|
||||
if(\class_exists($row['php_class']) && \method_exists($row['php_class'], 'css') && \is_callable($row['php_class'].'::css')){
|
||||
$row['css'] = array_merge($row['css'], call_user_func($row['php_class'].'::css'));}
|
||||
if(/*\is_callable($row['php_class']) &&*/ \class_exists($row['php_class']) && \method_exists($row['php_class'], 'js') && \is_callable($row['php_class'].'::js')){
|
||||
if(\class_exists($row['php_class']) && \method_exists($row['php_class'], 'js') && \is_callable($row['php_class'].'::js')){
|
||||
$row['js'] = array_merge($row['js'], call_user_func($row['php_class'].'::js'));}
|
||||
$result[] = $row;}
|
||||
return \SYSTEM\LOG\JsonResult::toString($result);}
|
||||
return $returnasjson ? \SYSTEM\LOG\JsonResult::toString($result) : $result;}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user