Capitalized XML

Acronym classes should be capitalized
This commit is contained in:
Adam Magness 2017-11-10 07:45:33 -05:00
parent b8d9509563
commit bc49fc974c
12 changed files with 235 additions and 235 deletions

View file

@ -13,7 +13,7 @@ use Friendica\Core\NotificationsManager;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Protocol\Diaspora;
use Friendica\Util\Xml;
use Friendica\Util\XML;
require_once 'include/HTTPExceptions.php';
require_once 'include/bbcode.php';
@ -901,7 +901,7 @@ function api_create_xml($data, $root_element)
$data3 = array($root_element => $data2);
$ret = Xml::from_array($data3, $xml, false, $namespaces);
$ret = XML::from_array($data3, $xml, false, $namespaces);
return $ret;
}

View file

@ -8,8 +8,7 @@
* https://github.com/annando/Syncom
*/
use Friendica\Util\Xml;
use Friendica\Util\XML;
function node2bbcode(&$doc, $oldnode, $attributes, $startbb, $endbb)
{
@ -27,11 +26,12 @@ function node2bbcodesub(&$doc, $oldnode, $attributes, $startbb, $endbb)
$list = $xpath->query("//".$oldnode);
foreach ($list as $oldNode) {
$attr = array();
if ($oldNode->attributes->length)
foreach ($oldNode->attributes as $attribute)
if ($oldNode->attributes->length) {
foreach ($oldNode->attributes as $attribute) {
$attr[$attribute->name] = $attribute->value;
}
}
$replace = true;
@ -40,23 +40,22 @@ function node2bbcodesub(&$doc, $oldnode, $attributes, $startbb, $endbb)
$i = 0;
foreach ($attributes as $attribute => $value) {
$startbb = str_replace('\x01'.++$i, '$1', $startbb);
if (strpos('*'.$startbb, '$1') > 0) {
if ($replace && (@$attr[$attribute] != '')) {
$startbb = preg_replace($value, $startbb, $attr[$attribute], -1, $count);
// If nothing could be changed
if ($count == 0)
if ($count == 0) {
$replace = false;
} else
}
} else {
$replace = false;
}
} else {
if (@$attr[$attribute] != $value)
if (@$attr[$attribute] != $value) {
$replace = false;
}
}
}
@ -125,12 +124,12 @@ function html2bbcode($message, $basepath = '')
@$doc->loadHTML($message);
Xml::deleteNode($doc, 'style');
Xml::deleteNode($doc, 'head');
Xml::deleteNode($doc, 'title');
Xml::deleteNode($doc, 'meta');
Xml::deleteNode($doc, 'xml');
Xml::deleteNode($doc, 'removeme');
XML::deleteNode($doc, 'style');
XML::deleteNode($doc, 'head');
XML::deleteNode($doc, 'title');
XML::deleteNode($doc, 'meta');
XML::deleteNode($doc, 'xml');
XML::deleteNode($doc, 'removeme');
$xpath = new DomXPath($doc);
$list = $xpath->query("//pre");

View file

@ -8,7 +8,7 @@ use Friendica\App;
use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Network\Probe;
use Friendica\Util\Xml;
use Friendica\Util\XML;
/**
* @brief Curl wrapper
@ -414,7 +414,7 @@ function xml_status($st, $message = '')
$xmldata = array("result" => $result);
echo Xml::from_array($xmldata, $xml);
echo XML::from_array($xmldata, $xml);
killme();
}
@ -570,7 +570,8 @@ function allowed_url($url)
* Checks if the provided url domain is on the domain blocklist.
* Returns true if it is or malformed URL, false if not.
*
* @param string $url The url to check the domain from
* @param string $url The url to check the domain from
*
* @return boolean
*/
function blocked_url($url)

View file

@ -10,7 +10,7 @@ use Friendica\Core\Config;
use Friendica\Database\DBM;
use Friendica\Network\Probe;
use Friendica\Util\Lock;
use Friendica\Util\Xml;
use Friendica\Util\XML;
require_once 'include/Contact.php';
require_once 'include/threads.php';
@ -1245,39 +1245,39 @@ class ostatus
$root->setAttribute("xmlns:mastodon", NAMESPACE_MASTODON);
$attributes = array("uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION);
Xml::add_element($doc, $root, "generator", FRIENDICA_PLATFORM, $attributes);
Xml::add_element($doc, $root, "id", System::baseUrl()."/profile/".$owner["nick"]);
Xml::add_element($doc, $root, "title", sprintf("%s timeline", $owner["name"]));
Xml::add_element($doc, $root, "subtitle", sprintf("Updates from %s on %s", $owner["name"], $a->config["sitename"]));
Xml::add_element($doc, $root, "logo", $owner["photo"]);
Xml::add_element($doc, $root, "updated", datetime_convert("UTC", "UTC", "now", ATOM_TIME));
XML::add_element($doc, $root, "generator", FRIENDICA_PLATFORM, $attributes);
XML::add_element($doc, $root, "id", System::baseUrl()."/profile/".$owner["nick"]);
XML::add_element($doc, $root, "title", sprintf("%s timeline", $owner["name"]));
XML::add_element($doc, $root, "subtitle", sprintf("Updates from %s on %s", $owner["name"], $a->config["sitename"]));
XML::add_element($doc, $root, "logo", $owner["photo"]);
XML::add_element($doc, $root, "updated", datetime_convert("UTC", "UTC", "now", ATOM_TIME));
$author = self::add_author($doc, $owner);
$root->appendChild($author);
$attributes = array("href" => $owner["url"], "rel" => "alternate", "type" => "text/html");
Xml::add_element($doc, $root, "link", "", $attributes);
XML::add_element($doc, $root, "link", "", $attributes);
/// @TODO We have to find out what this is
/// $attributes = array("href" => System::baseUrl()."/sup",
/// "rel" => "http://api.friendfeed.com/2008/03#sup",
/// "type" => "application/json");
/// Xml::add_element($doc, $root, "link", "", $attributes);
/// XML::add_element($doc, $root, "link", "", $attributes);
self::hublinks($doc, $root, $owner["nick"]);
$attributes = array("href" => System::baseUrl()."/salmon/".$owner["nick"], "rel" => "salmon");
Xml::add_element($doc, $root, "link", "", $attributes);
XML::add_element($doc, $root, "link", "", $attributes);
$attributes = array("href" => System::baseUrl()."/salmon/".$owner["nick"], "rel" => "http://salmon-protocol.org/ns/salmon-replies");
Xml::add_element($doc, $root, "link", "", $attributes);
XML::add_element($doc, $root, "link", "", $attributes);
$attributes = array("href" => System::baseUrl()."/salmon/".$owner["nick"], "rel" => "http://salmon-protocol.org/ns/salmon-mention");
Xml::add_element($doc, $root, "link", "", $attributes);
XML::add_element($doc, $root, "link", "", $attributes);
$attributes = array("href" => System::baseUrl()."/api/statuses/user_timeline/".$owner["nick"].".atom",
"rel" => "self", "type" => "application/atom+xml");
Xml::add_element($doc, $root, "link", "", $attributes);
XML::add_element($doc, $root, "link", "", $attributes);
return $root;
}
@ -1292,7 +1292,7 @@ class ostatus
public static function hublinks($doc, $root, $nick)
{
$h = System::baseUrl() . '/pubsubhubbub/'.$nick;
Xml::add_element($doc, $root, "link", "", array("href" => $h, "rel" => "hub"));
XML::add_element($doc, $root, "link", "", array("href" => $h, "rel" => "hub"));
}
/**
@ -1314,7 +1314,7 @@ class ostatus
"href" => $siteinfo["image"],
"type" => $imgdata["mime"],
"length" => intval($imgdata["size"]));
Xml::add_element($doc, $root, "link", "", $attributes);
XML::add_element($doc, $root, "link", "", $attributes);
break;
case 'video':
$attributes = array("rel" => "enclosure",
@ -1322,7 +1322,7 @@ class ostatus
"type" => "text/html; charset=UTF-8",
"length" => "",
"title" => $siteinfo["title"]);
Xml::add_element($doc, $root, "link", "", $attributes);
XML::add_element($doc, $root, "link", "", $attributes);
break;
default:
break;
@ -1335,7 +1335,7 @@ class ostatus
"type" => $imgdata["mime"],
"length" => intval($imgdata["size"]));
Xml::add_element($doc, $root, "link", "", $attributes);
XML::add_element($doc, $root, "link", "", $attributes);
}
$arr = explode('[/attach],', $item['attach']);
@ -1354,7 +1354,7 @@ class ostatus
if (trim($matches[4]) != "") {
$attributes["title"] = trim($matches[4]);
}
Xml::add_element($doc, $root, "link", "", $attributes);
XML::add_element($doc, $root, "link", "", $attributes);
}
}
}
@ -1375,15 +1375,15 @@ class ostatus
$profile = $r[0];
}
$author = $doc->createElement("author");
Xml::add_element($doc, $author, "id", $owner["url"]);
Xml::add_element($doc, $author, "activity:object-type", ACTIVITY_OBJ_PERSON);
Xml::add_element($doc, $author, "uri", $owner["url"]);
Xml::add_element($doc, $author, "name", $owner["nick"]);
Xml::add_element($doc, $author, "email", $owner["addr"]);
Xml::add_element($doc, $author, "summary", bbcode($owner["about"], false, false, 7));
XML::add_element($doc, $author, "id", $owner["url"]);
XML::add_element($doc, $author, "activity:object-type", ACTIVITY_OBJ_PERSON);
XML::add_element($doc, $author, "uri", $owner["url"]);
XML::add_element($doc, $author, "name", $owner["nick"]);
XML::add_element($doc, $author, "email", $owner["addr"]);
XML::add_element($doc, $author, "summary", bbcode($owner["about"], false, false, 7));
$attributes = array("rel" => "alternate", "type" => "text/html", "href" => $owner["url"]);
Xml::add_element($doc, $author, "link", "", $attributes);
XML::add_element($doc, $author, "link", "", $attributes);
$attributes = array(
"rel" => "avatar",
@ -1391,7 +1391,7 @@ class ostatus
"media:width" => 175,
"media:height" => 175,
"href" => $owner["photo"]);
Xml::add_element($doc, $author, "link", "", $attributes);
XML::add_element($doc, $author, "link", "", $attributes);
if (isset($owner["thumb"])) {
$attributes = array(
@ -1400,34 +1400,34 @@ class ostatus
"media:width" => 80,
"media:height" => 80,
"href" => $owner["thumb"]);
Xml::add_element($doc, $author, "link", "", $attributes);
XML::add_element($doc, $author, "link", "", $attributes);
}
Xml::add_element($doc, $author, "poco:preferredUsername", $owner["nick"]);
Xml::add_element($doc, $author, "poco:displayName", $owner["name"]);
Xml::add_element($doc, $author, "poco:note", bbcode($owner["about"], false, false, 7));
XML::add_element($doc, $author, "poco:preferredUsername", $owner["nick"]);
XML::add_element($doc, $author, "poco:displayName", $owner["name"]);
XML::add_element($doc, $author, "poco:note", bbcode($owner["about"], false, false, 7));
if (trim($owner["location"]) != "") {
$element = $doc->createElement("poco:address");
Xml::add_element($doc, $element, "poco:formatted", $owner["location"]);
XML::add_element($doc, $element, "poco:formatted", $owner["location"]);
$author->appendChild($element);
}
if (trim($profile["homepage"]) != "") {
$urls = $doc->createElement("poco:urls");
Xml::add_element($doc, $urls, "poco:type", "homepage");
Xml::add_element($doc, $urls, "poco:value", $profile["homepage"]);
Xml::add_element($doc, $urls, "poco:primary", "true");
XML::add_element($doc, $urls, "poco:type", "homepage");
XML::add_element($doc, $urls, "poco:value", $profile["homepage"]);
XML::add_element($doc, $urls, "poco:primary", "true");
$author->appendChild($urls);
}
if (count($profile)) {
Xml::add_element($doc, $author, "followers", "", array("url" => System::baseUrl()."/viewcontacts/".$owner["nick"]));
Xml::add_element($doc, $author, "statusnet:profile_info", "", array("local_id" => $owner["uid"]));
XML::add_element($doc, $author, "followers", "", array("url" => System::baseUrl()."/viewcontacts/".$owner["nick"]));
XML::add_element($doc, $author, "statusnet:profile_info", "", array("local_id" => $owner["uid"]));
}
if ($profile["publish"]) {
Xml::add_element($doc, $author, "mastodon:scope", "public");
XML::add_element($doc, $author, "mastodon:scope", "public");
}
return $author;
}
@ -1509,12 +1509,12 @@ class ostatus
private static function source_entry($doc, $contact)
{
$source = $doc->createElement("source");
Xml::add_element($doc, $source, "id", $contact["poll"]);
Xml::add_element($doc, $source, "title", $contact["name"]);
Xml::add_element($doc, $source, "link", "", array("rel" => "alternate", "type" => "text/html", "href" => $contact["alias"]));
Xml::add_element($doc, $source, "link", "", array("rel" => "self", "type" => "application/atom+xml", "href" => $contact["poll"]));
Xml::add_element($doc, $source, "icon", $contact["photo"]);
Xml::add_element($doc, $source, "updated", datetime_convert("UTC", "UTC", $contact["success_update"]."+00:00", ATOM_TIME));
XML::add_element($doc, $source, "id", $contact["poll"]);
XML::add_element($doc, $source, "title", $contact["name"]);
XML::add_element($doc, $source, "link", "", array("rel" => "alternate", "type" => "text/html", "href" => $contact["alias"]));
XML::add_element($doc, $source, "link", "", array("rel" => "self", "type" => "application/atom+xml", "href" => $contact["poll"]));
XML::add_element($doc, $source, "icon", $contact["photo"]);
XML::add_element($doc, $source, "updated", datetime_convert("UTC", "UTC", $contact["success_update"]."+00:00", ATOM_TIME));
return $source;
}
@ -1613,7 +1613,7 @@ class ostatus
$as_object = $doc->createElement("activity:object");
Xml::add_element($doc, $as_object, "activity:object-type", NAMESPACE_ACTIVITY_SCHEMA."activity");
XML::add_element($doc, $as_object, "activity:object-type", NAMESPACE_ACTIVITY_SCHEMA."activity");
self::entry_content($doc, $as_object, $repeated_item, $owner, "", "", false);
@ -1622,7 +1622,7 @@ class ostatus
$as_object2 = $doc->createElement("activity:object");
Xml::add_element($doc, $as_object2, "activity:object-type", self::construct_objecttype($repeated_item));
XML::add_element($doc, $as_object2, "activity:object-type", self::construct_objecttype($repeated_item));
$title = sprintf("New comment by %s", $contact["nick"]);
@ -1673,7 +1673,7 @@ class ostatus
);
$parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
Xml::add_element($doc, $as_object, "activity:object-type", self::construct_objecttype($parent[0]));
XML::add_element($doc, $as_object, "activity:object-type", self::construct_objecttype($parent[0]));
self::entry_content($doc, $as_object, $parent[0], $owner, "New entry");
@ -1696,18 +1696,18 @@ class ostatus
private static function add_person_object($doc, $owner, $contact)
{
$object = $doc->createElement("activity:object");
Xml::add_element($doc, $object, "activity:object-type", ACTIVITY_OBJ_PERSON);
XML::add_element($doc, $object, "activity:object-type", ACTIVITY_OBJ_PERSON);
if ($contact['network'] == NETWORK_PHANTOM) {
Xml::add_element($doc, $object, "id", $contact['url']);
XML::add_element($doc, $object, "id", $contact['url']);
return $object;
}
Xml::add_element($doc, $object, "id", $contact["alias"]);
Xml::add_element($doc, $object, "title", $contact["nick"]);
XML::add_element($doc, $object, "id", $contact["alias"]);
XML::add_element($doc, $object, "title", $contact["nick"]);
$attributes = array("rel" => "alternate", "type" => "text/html", "href" => $contact["url"]);
Xml::add_element($doc, $object, "link", "", $attributes);
XML::add_element($doc, $object, "link", "", $attributes);
$attributes = array(
"rel" => "avatar",
@ -1715,14 +1715,14 @@ class ostatus
"media:width" => 175,
"media:height" => 175,
"href" => $contact["photo"]);
Xml::add_element($doc, $object, "link", "", $attributes);
XML::add_element($doc, $object, "link", "", $attributes);
Xml::add_element($doc, $object, "poco:preferredUsername", $contact["nick"]);
Xml::add_element($doc, $object, "poco:displayName", $contact["name"]);
XML::add_element($doc, $object, "poco:preferredUsername", $contact["nick"]);
XML::add_element($doc, $object, "poco:displayName", $contact["name"]);
if (trim($contact["location"]) != "") {
$element = $doc->createElement("poco:address");
Xml::add_element($doc, $element, "poco:formatted", $contact["location"]);
XML::add_element($doc, $element, "poco:formatted", $contact["location"]);
$object->appendChild($element);
}
@ -1812,7 +1812,7 @@ class ostatus
$title = self::entry_header($doc, $entry, $owner, $toplevel);
Xml::add_element($doc, $entry, "activity:object-type", ACTIVITY_OBJ_NOTE);
XML::add_element($doc, $entry, "activity:object-type", ACTIVITY_OBJ_NOTE);
self::entry_content($doc, $entry, $item, $owner, $title);
@ -1874,8 +1874,8 @@ class ostatus
$verb = self::construct_verb($item);
}
Xml::add_element($doc, $entry, "id", $item["uri"]);
Xml::add_element($doc, $entry, "title", $title);
XML::add_element($doc, $entry, "id", $item["uri"]);
XML::add_element($doc, $entry, "title", $title);
$body = self::format_picture_post($item['body']);
@ -1885,20 +1885,20 @@ class ostatus
$body = bbcode($body, false, false, 7);
Xml::add_element($doc, $entry, "content", $body, array("type" => "html"));
XML::add_element($doc, $entry, "content", $body, array("type" => "html"));
Xml::add_element($doc, $entry, "link", "", array("rel" => "alternate", "type" => "text/html",
XML::add_element($doc, $entry, "link", "", array("rel" => "alternate", "type" => "text/html",
"href" => System::baseUrl()."/display/".$item["guid"])
);
if ($complete && ($item["id"] > 0)) {
Xml::add_element($doc, $entry, "status_net", "", array("notice_id" => $item["id"]));
XML::add_element($doc, $entry, "status_net", "", array("notice_id" => $item["id"]));
}
Xml::add_element($doc, $entry, "activity:verb", $verb);
XML::add_element($doc, $entry, "activity:verb", $verb);
Xml::add_element($doc, $entry, "published", datetime_convert("UTC", "UTC", $item["created"]."+00:00", ATOM_TIME));
Xml::add_element($doc, $entry, "updated", datetime_convert("UTC", "UTC", $item["edited"]."+00:00", ATOM_TIME));
XML::add_element($doc, $entry, "published", datetime_convert("UTC", "UTC", $item["created"]."+00:00", ATOM_TIME));
XML::add_element($doc, $entry, "updated", datetime_convert("UTC", "UTC", $item["edited"]."+00:00", ATOM_TIME));
}
/**
@ -1936,12 +1936,12 @@ class ostatus
$attributes = array(
"ref" => $parent_item,
"href" => $parent_plink);
Xml::add_element($doc, $entry, "thr:in-reply-to", "", $attributes);
XML::add_element($doc, $entry, "thr:in-reply-to", "", $attributes);
$attributes = array(
"rel" => "related",
"href" => $parent_plink);
Xml::add_element($doc, $entry, "link", "", $attributes);
XML::add_element($doc, $entry, "link", "", $attributes);
}
if (intval($item["parent"]) > 0) {
@ -1960,14 +1960,14 @@ class ostatus
}
}
Xml::add_element($doc, $entry, "link", "", array("rel" => "ostatus:conversation", "href" => $conversation_href));
XML::add_element($doc, $entry, "link", "", array("rel" => "ostatus:conversation", "href" => $conversation_href));
$attributes = array(
"href" => $conversation_href,
"local_id" => $item["parent"],
"ref" => $conversation_uri);
Xml::add_element($doc, $entry, "ostatus:conversation", $conversation_uri, $attributes);
XML::add_element($doc, $entry, "ostatus:conversation", $conversation_uri, $attributes);
}
$tags = item_getfeedtags($item);
@ -1995,14 +1995,14 @@ class ostatus
dbesc(normalise_link($mention))
);
if ($r[0]["forum"] || $r[0]["prv"]) {
Xml::add_element($doc, $entry, "link", "",
XML::add_element($doc, $entry, "link", "",
array(
"rel" => "mentioned",
"ostatus:object-type" => ACTIVITY_OBJ_GROUP,
"href" => $mention)
);
} else {
Xml::add_element($doc, $entry, "link", "",
XML::add_element($doc, $entry, "link", "",
array(
"rel" => "mentioned",
"ostatus:object-type" => ACTIVITY_OBJ_PERSON,
@ -2012,18 +2012,18 @@ class ostatus
}
if (!$item["private"]) {
Xml::add_element($doc, $entry, "link", "", array("rel" => "ostatus:attention",
XML::add_element($doc, $entry, "link", "", array("rel" => "ostatus:attention",
"href" => "http://activityschema.org/collection/public"));
Xml::add_element($doc, $entry, "link", "", array("rel" => "mentioned",
XML::add_element($doc, $entry, "link", "", array("rel" => "mentioned",
"ostatus:object-type" => "http://activitystrea.ms/schema/1.0/collection",
"href" => "http://activityschema.org/collection/public"));
Xml::add_element($doc, $entry, "mastodon:scope", "public");
XML::add_element($doc, $entry, "mastodon:scope", "public");
}
if (count($tags)) {
foreach ($tags as $t) {
if ($t[0] != "@") {
Xml::add_element($doc, $entry, "category", "", array("term" => $t[2]));
XML::add_element($doc, $entry, "category", "", array("term" => $t[2]));
}
}
}
@ -2043,10 +2043,10 @@ class ostatus
}
if ($item["coord"] != "") {
Xml::add_element($doc, $entry, "georss:point", $item["coord"]);
XML::add_element($doc, $entry, "georss:point", $item["coord"]);
}
Xml::add_element($doc, $entry, "statusnet:notice_info", "", $attributes);
XML::add_element($doc, $entry, "statusnet:notice_info", "", $attributes);
}
}

View file

@ -3,7 +3,7 @@
* @file include/salmon.php
*/
use Friendica\Network\Probe;
use Friendica\Util\Xml;
use Friendica\Util\XML;
require_once 'include/crypto.php';
@ -112,7 +112,7 @@ function slapper($owner, $url, $slap)
$namespaces = array("me" => "http://salmon-protocol.org/ns/magic-env");
$salmon = Xml::from_array($xmldata, $xml, false, $namespaces);
$salmon = XML::from_array($xmldata, $xml, false, $namespaces);
// slap them
post_url($url, $salmon, array(
@ -138,7 +138,7 @@ function slapper($owner, $url, $slap)
$namespaces = array("me" => "http://salmon-protocol.org/ns/magic-env");
$salmon = Xml::from_array($xmldata, $xml, false, $namespaces);
$salmon = XML::from_array($xmldata, $xml, false, $namespaces);
// slap them
post_url($url, $salmon, array(
@ -161,13 +161,13 @@ function slapper($owner, $url, $slap)
$namespaces = array("me" => "http://salmon-protocol.org/ns/magic-env");
$salmon = Xml::from_array($xmldata, $xml, false, $namespaces);
$salmon = XML::from_array($xmldata, $xml, false, $namespaces);
// slap them
post_url($url, $salmon, array(
'Content-type: application/magic-envelope+xml',
'Content-length: ' . strlen($salmon)
));
'Content-length: ' . strlen($salmon))
);
$return_code = $a->get_curl_code();
}