]> git.mxchange.org Git - friendica-addons.git/commitdiff
New addon "convpath": It converts all local links according to the current scheme...
authorMichael Vogel <icarus@dabo.de>
Mon, 9 Apr 2012 19:28:11 +0000 (21:28 +0200)
committerMichael Vogel <icarus@dabo.de>
Mon, 9 Apr 2012 19:28:11 +0000 (21:28 +0200)
convpath/README [new file with mode: 0755]
convpath/convpath.php [new file with mode: 0644]
facebook/facebook.php

diff --git a/convpath/README b/convpath/README
new file mode 100755 (executable)
index 0000000..9d1c307
--- /dev/null
@@ -0,0 +1,7 @@
+convpath
+
+This addon converts all internal paths according to the current scheme. 
+
+That means that if a page is called via https then all internal links are also converted into https.
+
+Same happens when you call your page with http.
diff --git a/convpath/convpath.php b/convpath/convpath.php
new file mode 100644 (file)
index 0000000..5ad7fbc
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/**
+ * Name: Convert Paths
+ * Description: Converts all internal paths according to the current scheme (http or https)
+ * Version: 1.0
+ * Author: Michael Vogel <https://pirati.ca/profile/heluecht>
+ * 
+ */
+
+function convpath_install() {
+       register_hook('page_end', 'addon/convpath/convpath.php', 'convpath_page_end');
+       register_hook('page_header', 'addon/convpath/convpath.php', 'convpath_page_header');
+}
+
+
+function convpath_uninstall() {
+       unregister_hook('page_end', 'addon/convpath/convpath.php', 'convpath_page_end');
+       unregister_hook('page_header', 'addon/convpath/convpath.php', 'convpath_page_header');
+}
+
+function convpath_page_header(&$a, &$o){
+       $o = convpath_convert($o);
+}
+
+function convpath_page_end(&$a, &$o){
+       $o = convpath_convert($o);
+       $a->page['aside'] = convpath_convert($a->page['aside']);
+}
+
+/*
+Converts a given path according to the current scheme
+*/
+function convpath_convert($path) {
+       global $a;
+
+       if ($path == "")
+               return("");
+
+       $ssl = (substr($a->get_baseurl(), 0, 8) == "https://");
+
+       if ($ssl) {
+               $search = "http://".$a->get_hostname();
+               $replace = "https://".$a->get_hostname();
+       } else {
+               $search = "https://".$a->get_hostname();
+               $replace = "http://".$a->get_hostname();
+       }
+       $path = str_replace($search, $replace, $path);
+       return($path);
+}
index 70a353dd2ee5f4cfe42876c1c1fb8f9ac768de06..5990a99e834ab0308d55481be175cf7751730d99 100755 (executable)
@@ -1447,11 +1447,13 @@ function fb_consume_stream($uid,$j,$wall = false) {
                        //if(($datarray['body'] != '') and ($uid == 1))
                        //      $datarray['body'] .= "[noparse]".print_r($entry, true)."[/noparse]";
 
-                       if ($entry->place->name)
-                               $datarray['coord'] = $entry->place->name;
-                       else if ($entry->place->location->street or $entry->place->location->city or $entry->place->location->Denmark) {
+                       if ($entry->place->name or $entry->place->location->street or 
+                               $entry->place->location->city or $entry->place->location->Denmark) {
+                               $datarray['coord'] = '';
+                               if ($entry->place->name)
+                                       $datarray['coord'] .= $entry->place->name;
                                if ($entry->place->location->street)
-                                       $datarray['coord'] = $entry->place->location->street;
+                                       $datarray['coord'] .= $entry->place->location->street;
                                if ($entry->place->location->city)
                                        $datarray['coord'] .= " ".$entry->place->location->city;
                                if ($entry->place->location->country)