From cb5cd120d9222bd85330eb8861a4309f617322c4 Mon Sep 17 00:00:00 2001 From: Harvie Date: Fri, 24 Dec 2010 03:32:43 +0100 Subject: [PATCH] Transport cleanup --- .../function.get_threaded_children.php | 5 +++-- wwwroot/inc/transports.inc | 15 +++++++++++++++ wwwroot/inc/transports/kyberia.sk.inc | 4 ++++ wwwroot/nodes.php | 11 ++++++----- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/wwwroot/inc/smarty/node_methodz/function.get_threaded_children.php b/wwwroot/inc/smarty/node_methodz/function.get_threaded_children.php index c39e537..7a7cc33 100644 --- a/wwwroot/inc/smarty/node_methodz/function.get_threaded_children.php +++ b/wwwroot/inc/smarty/node_methodz/function.get_threaded_children.php @@ -65,12 +65,13 @@ else $security = ""; $child = $result->getRecord(); if($child['external_link']=='transport') { $child['node_status']='linked'; - $transport = preg_split('/[:@]/',trim($child['node_content'])); + /*$transport = preg_split('/[:@]/',trim($child['node_content'])); require_once(INCLUDE_DIR.'transports.inc'); transport_load($transport[0]); global $transports; $child['node_name']=$transport[0].':'.$transport[1].'@defaulthost'; - $child['node_content']=$transport[0].':'.$transport[1].'@defaulthost:
'.$transports[$transport[0]]['get_node_content']($transport[1]); + $child['node_content']=$transport[0].':'.$transport[1].'@defaulthost:
'.$transports[$transport[0]]['get_node_content']($transport[1]);*/ + $child = array_merge($child, transport_translate($child['node_content'])); } if($child['synapse_creator']!='') { diff --git a/wwwroot/inc/transports.inc b/wwwroot/inc/transports.inc index 6c595c3..318096d 100644 --- a/wwwroot/inc/transports.inc +++ b/wwwroot/inc/transports.inc @@ -4,3 +4,18 @@ function transport_load($transport) { require_once(TRANSPORT_DIR.$transport.'.inc'); } +function transport_translate($transport_handle) { + $transport = preg_split('/[:@]/',trim($transport_handle)); + transport_load($transport[0]); + global $transports; + + $id=$transport[1]; + $domain='defaulthost'; if(isset($transport[2])) $domain=$transport[2]; + $transport=$transport[0]; + + $node['node_name']="$transport:$id@$domain"; + $node['url']=$transports[$transport]['get_node_url']($id); + $node['node_content']=$node['url'].'
'.$transports[$transport]['get_node_content']($id); + + return $node; +} diff --git a/wwwroot/inc/transports/kyberia.sk.inc b/wwwroot/inc/transports/kyberia.sk.inc index 23e40d2..1620572 100644 --- a/wwwroot/inc/transports/kyberia.sk.inc +++ b/wwwroot/inc/transports/kyberia.sk.inc @@ -3,6 +3,10 @@ $transport_name='kyberia.sk'; global $transports; +$transports[$transport_name]['get_node_url']=function($id, $protocol='http', $domain='kyberia.sk') { + return "$protocol://$domain/id/$id"; +}; + $transports[$transport_name]['get_node_content']=function($id, $protocol='http', $domain='kyberia.sk', $content_template='2019721') { return file_get_contents("$protocol://$domain/id/$id/$content_template"); }; diff --git a/wwwroot/nodes.php b/wwwroot/nodes.php index 54cfa79..c6e8f57 100644 --- a/wwwroot/nodes.php +++ b/wwwroot/nodes.php @@ -88,11 +88,12 @@ if (isset($_SERVER['HTTP_REFERER'])) { } //connecting to database and creating universal $db object -require(INCLUDE_DIR.'log.inc'); -require(INCLUDE_DIR.'ubik.inc'); -require(INCLUDE_DIR.'nodes.inc'); -require(INCLUDE_DIR.'error_messages.inc'); -require(INCLUDE_DIR.'database.inc'); +require_once(INCLUDE_DIR.'log.inc'); +require_once(INCLUDE_DIR.'ubik.inc'); +require_once(INCLUDE_DIR.'nodes.inc'); +require_once(INCLUDE_DIR.'error_messages.inc'); +require_once(INCLUDE_DIR.'database.inc'); +require_once(INCLUDE_DIR.'transports.inc'); $db = new CLASS_DATABASE(); -- 2.30.2