Merge pull request #5037 from Quix0r/rewrites/curly-braces-is-result-usage-001

Rewrites/curly braces is result usage 001
pull/5052/merge
Hypolite Petovan 2018-05-13 10:05:38 -04:00 zatwierdzone przez GitHub
commit 3228bb614c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
4 zmienionych plików z 39 dodań i 23 usunięć

Wyświetl plik

@ -2162,6 +2162,7 @@ function admin_page_themes(App $a)
}
$readme = null;
if (is_file("view/theme/$theme/README.md")) {
$readme = Markdown::convert(file_get_contents("view/theme/$theme/README.md"), false);
} elseif (is_file("view/theme/$theme/README")) {

Wyświetl plik

@ -43,6 +43,7 @@ function poco_init(App $a) {
echo json_encode($ret);
killme();
}
if ($a->argc > 1 && $a->argv[1] === '@global') {
// List of all profiles that this server recently had data from
$global = true;

Wyświetl plik

@ -5,6 +5,7 @@ use Friendica\Database\DBM;
function share_init(App $a) {
$post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
if (!$post_id || !local_user()) {
killme();
}
@ -14,37 +15,44 @@ function share_init(App $a) {
WHERE `item`.`id` = %d LIMIT 1",
intval($post_id)
);
if (!DBM::is_result($r) || ($r[0]['private'] == 1)) {
killme();
}
if (strpos($r[0]['body'], "[/share]") !== false) {
$pos = strpos($r[0]['body'], "[share");
$o = substr($r[0]['body'], $pos);
} else {
$o = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
if ($r[0]['title'])
if ($r[0]['title']) {
$o .= '[b]'.$r[0]['title'].'[/b]'."\n";
}
$o .= $r[0]['body'];
$o.= "[/share]";
$o .= "[/share]";
}
echo $o;
killme();
}
/// @TODO Rewrite to handle over whole record array
function share_header($author, $profile, $avatar, $guid, $posted, $link) {
$header = "[share author='".str_replace(["'", "[", "]"], ["'", "[", "]"], $author).
"' profile='".str_replace(["'", "[", "]"], ["'", "[", "]"], $profile).
"' avatar='".str_replace(["'", "[", "]"], ["'", "[", "]"], $avatar);
$header = "[share author='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $author).
"' profile='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $profile).
"' avatar='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $avatar);
if ($guid) {
$header .= "' guid='".str_replace(["'", "[", "]"], ["'", "[", "]"], $guid);
$header .= "' guid='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $guid);
}
if ($posted) {
$header .= "' posted='".str_replace(["'", "[", "]"], ["'", "[", "]"], $posted);
$header .= "' posted='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $posted);
}
$header .= "' link='".str_replace(["'", "[", "]"], ["'", "[", "]"], $link)."']";
$header .= "' link='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $link)."']";
return $header;
}

Wyświetl plik

@ -63,7 +63,7 @@ class DFRN
* @param array $owner Owner record
*
* @return string DFRN entries
* @todo Add type-hints
* @todo Find proper type-hints
*/
public static function entries($items, $owner)
{
@ -96,6 +96,7 @@ class DFRN
* @param boolean $onlyheader Output only the header without content? (Default is "no")
*
* @return string DFRN feed entries
* @todo Find proper type-hints
*/
public static function feed($dfrn_id, $owner_nick, $last_update, $direction = 0, $onlyheader = false)
{
@ -120,8 +121,6 @@ class DFRN
}
}
// default permissions - anonymous user
$sql_extra = " AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' ";
@ -134,6 +133,7 @@ class DFRN
);
if (! DBM::is_result($r)) {
logger(sprintf('No contact found for nickname=%d', $owner_nick), LOGGER_WARNING);
killme();
}
@ -169,6 +169,7 @@ class DFRN
);
if (! DBM::is_result($r)) {
logger(sprintf('No contact found for uid=%d', $owner_id), LOGGER_WARNING);
killme();
}
@ -177,8 +178,10 @@ class DFRN
$groups = Group::getIdsByContactId($contact['id']);
if (count($groups)) {
for ($x = 0; $x < count($groups); $x ++)
for ($x = 0; $x < count($groups); $x ++) {
$groups[$x] = '<' . intval($groups[$x]) . '>' ;
}
$gs = implode('|', $groups);
} else {
$gs = '<<>>' ; // Impossible to match
@ -397,7 +400,7 @@ class DFRN
* @param array $owner Owner record
*
* @return string DFRN mail
* @todo Add type-hints
* @todo Find proper type-hints
*/
public static function mail($item, $owner)
{
@ -433,7 +436,7 @@ class DFRN
* @param array $owner Owner record
*
* @return string DFRN suggestions
* @todo Add type-hints
* @todo Find proper type-hints
*/
public static function fsuggest($item, $owner)
{
@ -462,7 +465,7 @@ class DFRN
* @param int $uid User ID
*
* @return string DFRN relocations
* @todo Add type-hints
* @todo Find proper type-hints
*/
public static function relocate($owner, $uid)
{
@ -524,7 +527,7 @@ class DFRN
* @param bool $public Is it a header for public posts?
*
* @return object XML root object
* @todo Add type-hints
* @todo Find proper type-hints
*/
private static function addHeader($doc, $owner, $authorelement, $alternatelink = "", $public = false)
{
@ -600,7 +603,7 @@ class DFRN
* @param boolean $public boolean
*
* @return object XML author object
* @todo Add type-hints
* @todo Find proper type-hints
*/
private static function addAuthor($doc, $owner, $authorelement, $public)
{
@ -744,7 +747,7 @@ class DFRN
* @param array $item Item elements
*
* @return object XML author object
* @todo Add type-hints
* @todo Find proper type-hints
*/
private static function addEntryAuthor($doc, $element, $contact_url, $item)
{
@ -785,7 +788,7 @@ class DFRN
* @param string $activity activity value
*
* @return object XML activity object
* @todo Add type-hints
* @todo Find proper type-hints
*/
private static function createActivity($doc, $element, $activity)
{
@ -796,12 +799,15 @@ class DFRN
if (!$r) {
return false;
}
if ($r->type) {
XML::addElement($doc, $entry, "activity:object-type", $r->type);
}
if ($r->id) {
XML::addElement($doc, $entry, "id", $r->id);
}
if ($r->title) {
XML::addElement($doc, $entry, "title", $r->title);
}
@ -848,7 +854,7 @@ class DFRN
* @param array $item Item element
*
* @return object XML attachment object
* @todo Add type-hints
* @todo Find proper type-hints
*/
private static function getAttachment($doc, $root, $item)
{
@ -888,7 +894,7 @@ class DFRN
* @param bool $single If set, the entry is created as an XML document with a single "entry" element
*
* @return object XML entry object
* @todo Add type-hints
* @todo Find proper type-hints
*/
private static function entry($doc, $type, $item, $owner, $comment = false, $cid = 0, $single = false)
{
@ -1289,7 +1295,6 @@ class DFRN
$postvars['dissolve'] = '1';
}
if ((($contact['rel']) && ($contact['rel'] != CONTACT_IS_SHARING) && (! $contact['blocked'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) {
$postvars['data'] = $atom;
$postvars['perm'] = 'rw';
@ -1576,7 +1581,7 @@ class DFRN
$href = "";
$width = 0;
foreach ($avatar->attributes as $attributes) {
/// @TODO Rewrite these similar if () to one switch
/// @TODO Rewrite these similar if() to one switch
if ($attributes->name == "href") {
$href = $attributes->textContent;
}
@ -2796,6 +2801,7 @@ class DFRN
{
logger("Processing deletions");
$uri = null;
foreach ($deletion->attributes as $attributes) {
if ($attributes->name == "ref") {
$uri = $attributes->textContent;