aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfabrixxm <fabrix.xm@gmail.com>2011-09-08 20:15:27 +0200
committerfabrixxm <fabrix.xm@gmail.com>2011-09-08 20:15:27 +0200
commitd284f8017cefb79571fe51c4ae3f85b9b4e517c9 (patch)
treefbf1902147b237649048e2ab6ac8a84ffe0bf838 /include
parent2fabf8d2188516a36589487bfa2ca01dea0c5ca2 (diff)
parent68c23f6c86e2f2e24548b179f00b5bcd5ab8ba87 (diff)
downloadvolse-hubzilla-d284f8017cefb79571fe51c4ae3f85b9b4e517c9.tar.gz
volse-hubzilla-d284f8017cefb79571fe51c4ae3f85b9b4e517c9.tar.bz2
volse-hubzilla-d284f8017cefb79571fe51c4ae3f85b9b4e517c9.zip
Merge remote-tracking branch 'friendika/master' into newui
Diffstat (limited to 'include')
-rw-r--r--include/Scrape.php2
-rw-r--r--include/bb2diaspora.php5
-rw-r--r--include/network.php19
-rw-r--r--include/template_processor.php21
4 files changed, 39 insertions, 8 deletions
diff --git a/include/Scrape.php b/include/Scrape.php
index bf64c2243..b80f24c22 100644
--- a/include/Scrape.php
+++ b/include/Scrape.php
@@ -471,7 +471,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
}
if(strlen($dfrn)) {
- $ret = scrape_dfrn($dfrn);
+ $ret = scrape_dfrn(($hcard) ? $hcard : $dfrn);
if(is_array($ret) && x($ret,'dfrn-request')) {
$network = NETWORK_DFRN;
$request = $ret['dfrn-request'];
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index ca0c961b3..591aaf7fa 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -8,6 +8,10 @@ require_once('include/event.php');
function diaspora2bb($s) {
+ // bug #127
+ $s = preg_replace('/\[(.+?)\]\((.+?)[^\\\]_(.+?)\)/','[$1]($2\\_$3)',$s);
+
+
$s = str_replace(array('\\**','\\__','\\*','\\_'), array('-^doublestar^-','-^doublescore-^','-^star^-','-^score^-'),$s);
$s = preg_replace("/\*\*\*(.+?)\*\*\*/", '[b][i]$1[/i][/b]', $s);
$s = preg_replace("/\_\_\_(.+?)\_\_\_/", '[b][i]$1[/i][/b]', $s);
@@ -15,6 +19,7 @@ function diaspora2bb($s) {
$s = preg_replace("/\_\_(.+?)\_\_/", '[b]$1[/b]', $s);
$s = preg_replace("/\*(.+?)\*/", '[i]$1[/i]', $s);
$s = preg_replace("/\_(.+?)\_/", '[i]$1[/i]', $s);
+
$s = str_replace(array('-^doublestar^-','-^doublescore-^','-^star^-','-^score^-'), array('**','__','*','_'), $s);
$s = preg_replace('/\!\[(.+?)\]\((.+?)\)/','[img]$2[/img]',$s);
$s = preg_replace('/\[(.+?)\]\((.+?)\)/','[url=$2]$1[/url]',$s);
diff --git a/include/network.php b/include/network.php
index 2832ae2d3..deb257ff3 100644
--- a/include/network.php
+++ b/include/network.php
@@ -259,22 +259,29 @@ function convert_xml_element_to_array($xml_element, &$recursion_depth=0) {
// or if the resultant personal XRD doesn't contain a supported
// subscription/friend-request attribute.
+// amended 7/9/2011 to return an hcard which could save potentially loading
+// a lengthy content page to scrape dfrn attributes
+
if(! function_exists('webfinger_dfrn')) {
-function webfinger_dfrn($s) {
+function webfinger_dfrn($s,&$hcard) {
if(! strstr($s,'@')) {
return $s;
}
+ $profile_link = '';
+
$links = webfinger($s);
logger('webfinger_dfrn: ' . $s . ':' . print_r($links,true), LOGGER_DATA);
if(count($links)) {
- foreach($links as $link)
+ foreach($links as $link) {
if($link['@attributes']['rel'] === NAMESPACE_DFRN)
- return $link['@attributes']['href'];
- foreach($links as $link)
+ $profile_link = $link['@attributes']['href'];
if($link['@attributes']['rel'] === NAMESPACE_OSTATUSSUB)
- return 'stat:' . $link['@attributes']['template'];
+ $profile_link = 'stat:' . $link['@attributes']['template'];
+ if($link['@attributes']['rel'] === 'http://microformats.org/profile/hcard')
+ $hcard = $link['@attributes']['href'];
+ }
}
- return '';
+ return $profile_link;
}}
// Given an email style address, perform webfinger lookup and
diff --git a/include/template_processor.php b/include/template_processor.php
index 11769bbd0..056d25488 100644
--- a/include/template_processor.php
+++ b/include/template_processor.php
@@ -1,5 +1,6 @@
<?php
+
class Template {
var $r;
var $search;
@@ -8,6 +9,8 @@
var $nodes = array();
var $done = false;
var $d = false;
+ var $lang = null;
+
private function _preg_error(){
switch(preg_last_error()){
@@ -156,8 +159,24 @@
krsort($this->nodes);
return $s;
}
+
+ private function _get_lang(){
+ if ($this->lang!=null) return $this->lang;
+
+ $a = get_app();
+ $this->lang=array();
+ foreach ($a->strings as $k=>$v){
+ $k = preg_replace("/[^a-z0-9-]/", "", str_replace(" ","-", strtolower($k)));
+ $this->lang[$k] = $v;
+ }
+ return $this->lang;
+ }
+
public function replace($s, $r) {
+ if (!x($r,'$lang')){
+ $r['$lang'] = &$this->_get_lang();
+ }
$this->r = $r;
$this->search = array();
$this->replace = array();
@@ -171,7 +190,7 @@
// remove comments block
$s = preg_replace('/{#[^#]*#}/', "" , $s);
-
+
// replace strings recursively (limit to 10 loops)
$os = ""; $count=0;
while($os!=$s && $count<10){