Merge pull request #5037 from Quix0r/rewrites/curly-braces-is-result-usage-001
Rewrites/curly braces is result usage 001
This commit is contained in:
commit
3228bb614c
|
@ -2162,6 +2162,7 @@ function admin_page_themes(App $a)
|
||||||
}
|
}
|
||||||
|
|
||||||
$readme = null;
|
$readme = null;
|
||||||
|
|
||||||
if (is_file("view/theme/$theme/README.md")) {
|
if (is_file("view/theme/$theme/README.md")) {
|
||||||
$readme = Markdown::convert(file_get_contents("view/theme/$theme/README.md"), false);
|
$readme = Markdown::convert(file_get_contents("view/theme/$theme/README.md"), false);
|
||||||
} elseif (is_file("view/theme/$theme/README")) {
|
} elseif (is_file("view/theme/$theme/README")) {
|
||||||
|
|
|
@ -43,6 +43,7 @@ function poco_init(App $a) {
|
||||||
echo json_encode($ret);
|
echo json_encode($ret);
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($a->argc > 1 && $a->argv[1] === '@global') {
|
if ($a->argc > 1 && $a->argv[1] === '@global') {
|
||||||
// List of all profiles that this server recently had data from
|
// List of all profiles that this server recently had data from
|
||||||
$global = true;
|
$global = true;
|
||||||
|
|
|
@ -5,6 +5,7 @@ use Friendica\Database\DBM;
|
||||||
|
|
||||||
function share_init(App $a) {
|
function share_init(App $a) {
|
||||||
$post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
|
$post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
|
||||||
|
|
||||||
if (!$post_id || !local_user()) {
|
if (!$post_id || !local_user()) {
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
@ -14,37 +15,44 @@ function share_init(App $a) {
|
||||||
WHERE `item`.`id` = %d LIMIT 1",
|
WHERE `item`.`id` = %d LIMIT 1",
|
||||||
intval($post_id)
|
intval($post_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!DBM::is_result($r) || ($r[0]['private'] == 1)) {
|
if (!DBM::is_result($r) || ($r[0]['private'] == 1)) {
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($r[0]['body'], "[/share]") !== false) {
|
if (strpos($r[0]['body'], "[/share]") !== false) {
|
||||||
$pos = strpos($r[0]['body'], "[share");
|
$pos = strpos($r[0]['body'], "[share");
|
||||||
$o = substr($r[0]['body'], $pos);
|
$o = substr($r[0]['body'], $pos);
|
||||||
} else {
|
} 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']);
|
$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 .= '[b]'.$r[0]['title'].'[/b]'."\n";
|
||||||
|
}
|
||||||
|
|
||||||
$o .= $r[0]['body'];
|
$o .= $r[0]['body'];
|
||||||
$o.= "[/share]";
|
$o .= "[/share]";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $o;
|
echo $o;
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @TODO Rewrite to handle over whole record array
|
||||||
function share_header($author, $profile, $avatar, $guid, $posted, $link) {
|
function share_header($author, $profile, $avatar, $guid, $posted, $link) {
|
||||||
$header = "[share author='".str_replace(["'", "[", "]"], ["'", "[", "]"], $author).
|
$header = "[share author='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $author).
|
||||||
"' profile='".str_replace(["'", "[", "]"], ["'", "[", "]"], $profile).
|
"' profile='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $profile).
|
||||||
"' avatar='".str_replace(["'", "[", "]"], ["'", "[", "]"], $avatar);
|
"' avatar='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $avatar);
|
||||||
|
|
||||||
if ($guid) {
|
if ($guid) {
|
||||||
$header .= "' guid='".str_replace(["'", "[", "]"], ["'", "[", "]"], $guid);
|
$header .= "' guid='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($posted) {
|
if ($posted) {
|
||||||
$header .= "' posted='".str_replace(["'", "[", "]"], ["'", "[", "]"], $posted);
|
$header .= "' posted='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $posted);
|
||||||
}
|
}
|
||||||
$header .= "' link='".str_replace(["'", "[", "]"], ["'", "[", "]"], $link)."']";
|
|
||||||
|
$header .= "' link='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $link)."']";
|
||||||
|
|
||||||
return $header;
|
return $header;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ class DFRN
|
||||||
* @param array $owner Owner record
|
* @param array $owner Owner record
|
||||||
*
|
*
|
||||||
* @return string DFRN entries
|
* @return string DFRN entries
|
||||||
* @todo Add type-hints
|
* @todo Find proper type-hints
|
||||||
*/
|
*/
|
||||||
public static function entries($items, $owner)
|
public static function entries($items, $owner)
|
||||||
{
|
{
|
||||||
|
@ -96,6 +96,7 @@ class DFRN
|
||||||
* @param boolean $onlyheader Output only the header without content? (Default is "no")
|
* @param boolean $onlyheader Output only the header without content? (Default is "no")
|
||||||
*
|
*
|
||||||
* @return string DFRN feed entries
|
* @return string DFRN feed entries
|
||||||
|
* @todo Find proper type-hints
|
||||||
*/
|
*/
|
||||||
public static function feed($dfrn_id, $owner_nick, $last_update, $direction = 0, $onlyheader = false)
|
public static function feed($dfrn_id, $owner_nick, $last_update, $direction = 0, $onlyheader = false)
|
||||||
{
|
{
|
||||||
|
@ -120,8 +121,6 @@ class DFRN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// default permissions - anonymous user
|
// default permissions - anonymous user
|
||||||
|
|
||||||
$sql_extra = " AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' ";
|
$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)) {
|
if (! DBM::is_result($r)) {
|
||||||
|
logger(sprintf('No contact found for nickname=%d', $owner_nick), LOGGER_WARNING);
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,6 +169,7 @@ class DFRN
|
||||||
);
|
);
|
||||||
|
|
||||||
if (! DBM::is_result($r)) {
|
if (! DBM::is_result($r)) {
|
||||||
|
logger(sprintf('No contact found for uid=%d', $owner_id), LOGGER_WARNING);
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,8 +178,10 @@ class DFRN
|
||||||
$groups = Group::getIdsByContactId($contact['id']);
|
$groups = Group::getIdsByContactId($contact['id']);
|
||||||
|
|
||||||
if (count($groups)) {
|
if (count($groups)) {
|
||||||
for ($x = 0; $x < count($groups); $x ++)
|
for ($x = 0; $x < count($groups); $x ++) {
|
||||||
$groups[$x] = '<' . intval($groups[$x]) . '>' ;
|
$groups[$x] = '<' . intval($groups[$x]) . '>' ;
|
||||||
|
}
|
||||||
|
|
||||||
$gs = implode('|', $groups);
|
$gs = implode('|', $groups);
|
||||||
} else {
|
} else {
|
||||||
$gs = '<<>>' ; // Impossible to match
|
$gs = '<<>>' ; // Impossible to match
|
||||||
|
@ -397,7 +400,7 @@ class DFRN
|
||||||
* @param array $owner Owner record
|
* @param array $owner Owner record
|
||||||
*
|
*
|
||||||
* @return string DFRN mail
|
* @return string DFRN mail
|
||||||
* @todo Add type-hints
|
* @todo Find proper type-hints
|
||||||
*/
|
*/
|
||||||
public static function mail($item, $owner)
|
public static function mail($item, $owner)
|
||||||
{
|
{
|
||||||
|
@ -433,7 +436,7 @@ class DFRN
|
||||||
* @param array $owner Owner record
|
* @param array $owner Owner record
|
||||||
*
|
*
|
||||||
* @return string DFRN suggestions
|
* @return string DFRN suggestions
|
||||||
* @todo Add type-hints
|
* @todo Find proper type-hints
|
||||||
*/
|
*/
|
||||||
public static function fsuggest($item, $owner)
|
public static function fsuggest($item, $owner)
|
||||||
{
|
{
|
||||||
|
@ -462,7 +465,7 @@ class DFRN
|
||||||
* @param int $uid User ID
|
* @param int $uid User ID
|
||||||
*
|
*
|
||||||
* @return string DFRN relocations
|
* @return string DFRN relocations
|
||||||
* @todo Add type-hints
|
* @todo Find proper type-hints
|
||||||
*/
|
*/
|
||||||
public static function relocate($owner, $uid)
|
public static function relocate($owner, $uid)
|
||||||
{
|
{
|
||||||
|
@ -524,7 +527,7 @@ class DFRN
|
||||||
* @param bool $public Is it a header for public posts?
|
* @param bool $public Is it a header for public posts?
|
||||||
*
|
*
|
||||||
* @return object XML root object
|
* @return object XML root object
|
||||||
* @todo Add type-hints
|
* @todo Find proper type-hints
|
||||||
*/
|
*/
|
||||||
private static function addHeader($doc, $owner, $authorelement, $alternatelink = "", $public = false)
|
private static function addHeader($doc, $owner, $authorelement, $alternatelink = "", $public = false)
|
||||||
{
|
{
|
||||||
|
@ -600,7 +603,7 @@ class DFRN
|
||||||
* @param boolean $public boolean
|
* @param boolean $public boolean
|
||||||
*
|
*
|
||||||
* @return object XML author object
|
* @return object XML author object
|
||||||
* @todo Add type-hints
|
* @todo Find proper type-hints
|
||||||
*/
|
*/
|
||||||
private static function addAuthor($doc, $owner, $authorelement, $public)
|
private static function addAuthor($doc, $owner, $authorelement, $public)
|
||||||
{
|
{
|
||||||
|
@ -744,7 +747,7 @@ class DFRN
|
||||||
* @param array $item Item elements
|
* @param array $item Item elements
|
||||||
*
|
*
|
||||||
* @return object XML author object
|
* @return object XML author object
|
||||||
* @todo Add type-hints
|
* @todo Find proper type-hints
|
||||||
*/
|
*/
|
||||||
private static function addEntryAuthor($doc, $element, $contact_url, $item)
|
private static function addEntryAuthor($doc, $element, $contact_url, $item)
|
||||||
{
|
{
|
||||||
|
@ -785,7 +788,7 @@ class DFRN
|
||||||
* @param string $activity activity value
|
* @param string $activity activity value
|
||||||
*
|
*
|
||||||
* @return object XML activity object
|
* @return object XML activity object
|
||||||
* @todo Add type-hints
|
* @todo Find proper type-hints
|
||||||
*/
|
*/
|
||||||
private static function createActivity($doc, $element, $activity)
|
private static function createActivity($doc, $element, $activity)
|
||||||
{
|
{
|
||||||
|
@ -796,12 +799,15 @@ class DFRN
|
||||||
if (!$r) {
|
if (!$r) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($r->type) {
|
if ($r->type) {
|
||||||
XML::addElement($doc, $entry, "activity:object-type", $r->type);
|
XML::addElement($doc, $entry, "activity:object-type", $r->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($r->id) {
|
if ($r->id) {
|
||||||
XML::addElement($doc, $entry, "id", $r->id);
|
XML::addElement($doc, $entry, "id", $r->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($r->title) {
|
if ($r->title) {
|
||||||
XML::addElement($doc, $entry, "title", $r->title);
|
XML::addElement($doc, $entry, "title", $r->title);
|
||||||
}
|
}
|
||||||
|
@ -848,7 +854,7 @@ class DFRN
|
||||||
* @param array $item Item element
|
* @param array $item Item element
|
||||||
*
|
*
|
||||||
* @return object XML attachment object
|
* @return object XML attachment object
|
||||||
* @todo Add type-hints
|
* @todo Find proper type-hints
|
||||||
*/
|
*/
|
||||||
private static function getAttachment($doc, $root, $item)
|
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
|
* @param bool $single If set, the entry is created as an XML document with a single "entry" element
|
||||||
*
|
*
|
||||||
* @return object XML entry object
|
* @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)
|
private static function entry($doc, $type, $item, $owner, $comment = false, $cid = 0, $single = false)
|
||||||
{
|
{
|
||||||
|
@ -1289,7 +1295,6 @@ class DFRN
|
||||||
$postvars['dissolve'] = '1';
|
$postvars['dissolve'] = '1';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((($contact['rel']) && ($contact['rel'] != CONTACT_IS_SHARING) && (! $contact['blocked'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) {
|
if ((($contact['rel']) && ($contact['rel'] != CONTACT_IS_SHARING) && (! $contact['blocked'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) {
|
||||||
$postvars['data'] = $atom;
|
$postvars['data'] = $atom;
|
||||||
$postvars['perm'] = 'rw';
|
$postvars['perm'] = 'rw';
|
||||||
|
@ -1576,7 +1581,7 @@ class DFRN
|
||||||
$href = "";
|
$href = "";
|
||||||
$width = 0;
|
$width = 0;
|
||||||
foreach ($avatar->attributes as $attributes) {
|
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") {
|
if ($attributes->name == "href") {
|
||||||
$href = $attributes->textContent;
|
$href = $attributes->textContent;
|
||||||
}
|
}
|
||||||
|
@ -2796,6 +2801,7 @@ class DFRN
|
||||||
{
|
{
|
||||||
logger("Processing deletions");
|
logger("Processing deletions");
|
||||||
$uri = null;
|
$uri = null;
|
||||||
|
|
||||||
foreach ($deletion->attributes as $attributes) {
|
foreach ($deletion->attributes as $attributes) {
|
||||||
if ($attributes->name == "ref") {
|
if ($attributes->name == "ref") {
|
||||||
$uri = $attributes->textContent;
|
$uri = $attributes->textContent;
|
||||||
|
|
Loading…
Reference in a new issue