mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 23:35:12 +00:00
cleanup
This commit is contained in:
parent
32826204c1
commit
6d36d10f29
4 changed files with 27 additions and 80 deletions
|
@ -20,7 +20,8 @@ use Code\Render\Theme;
|
|||
function localize_item(&$item)
|
||||
{
|
||||
|
||||
if (activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE) || $item['verb'] === 'Announce') {
|
||||
if (activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)
|
||||
|| $item['verb'] === 'Announce') {
|
||||
if (! $item['obj']) {
|
||||
return;
|
||||
}
|
||||
|
@ -37,7 +38,8 @@ function localize_item(&$item)
|
|||
|
||||
if (isset($obj['actor']) && is_string($obj['actor']) && $obj['actor']) {
|
||||
$author_link = $obj['actor'];
|
||||
} elseif (isset($obj['attributedTo']) && is_string($obj['attributedTo']) && $obj['attributedTo']) {
|
||||
}
|
||||
elseif (isset($obj['attributedTo']) && is_string($obj['attributedTo']) && $obj['attributedTo']) {
|
||||
$author_link = $obj['attributedTo'];
|
||||
}
|
||||
else {
|
||||
|
@ -222,7 +224,7 @@ function localize_item(&$item)
|
|||
/**
|
||||
* @brief Count the total of comments on this item and its desendants.
|
||||
*
|
||||
* @param array $item an assoziative item-array which provides:
|
||||
* @param array $item an associative item-array which provides:
|
||||
* * \e array \b children
|
||||
* @return number
|
||||
*/
|
||||
|
@ -517,23 +519,14 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
|
|||
|
||||
$locktype = intval($item['item_private']);
|
||||
|
||||
$likebuttons = false;
|
||||
$shareable = false;
|
||||
|
||||
$verified = (intval($item['item_verified']) ? t('Message signature validated') : '');
|
||||
$forged = ((($item['sig']) && (! intval($item['item_verified']))) ? t('Message signature incorrect') : '');
|
||||
|
||||
$unverified = '';
|
||||
|
||||
// $tags=[];
|
||||
// $terms = get_terms_oftype($item['term'],array(TERM_HASHTAG,TERM_MENTION,TERM_UNKNOWN,TERM_COMMUNITYTAG));
|
||||
// if(count($terms))
|
||||
// foreach($terms as $tag)
|
||||
// $tags[] = format_term_for_display($tag);
|
||||
|
||||
$body = prepare_body($item, true);
|
||||
|
||||
$has_tags = (($body['tags'] || $body['categories'] || $body['mentions'] || $body['attachments'] || $body['folders']) ? true : false);
|
||||
$has_tags = $body['tags'] || $body['categories'] || $body['mentions'] || $body['attachments'] || $body['folders'];
|
||||
|
||||
if (strcmp(datetime_convert('UTC', 'UTC', $item['created']), datetime_convert('UTC', 'UTC', 'now - 12 hours')) > 0) {
|
||||
$is_new = true;
|
||||
|
@ -543,9 +536,9 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
|
|||
|
||||
$conv_link = ((in_array($item['item_type'], [ ITEM_TYPE_CARD, ITEM_TYPE_ARTICLE])) ? $item['plink'] : z_root() . '/display/?mid=' . gen_link_id($conv_link_mid));
|
||||
|
||||
$allowed_type = (in_array($item['item_type'], get_config('system', 'pin_types', [ ITEM_TYPE_POST ])) ? true : false);
|
||||
$allowed_type = in_array($item['item_type'], get_config('system', 'pin_types', [ ITEM_TYPE_POST ]));
|
||||
$pinned_items = ($allowed_type ? get_pconfig($item['uid'], 'pinned', $item['item_type'], []) : []);
|
||||
$pinned = ((! empty($pinned_items) && in_array($item['mid'], $pinned_items)) ? true : false);
|
||||
$pinned = ! empty($pinned_items) && in_array($item['mid'], $pinned_items);
|
||||
|
||||
$tmp_item = [
|
||||
'template' => $tpl,
|
||||
|
@ -601,7 +594,7 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
|
|||
'edpost' => false,
|
||||
'star' => ((Features::enabled(local_channel(), 'star_posts')) ? $star : ''),
|
||||
'drop' => $drop,
|
||||
'vote' => $likebuttons,
|
||||
'vote' => false,
|
||||
'like' => '',
|
||||
'dislike' => '',
|
||||
'comment' => '',
|
||||
|
@ -709,33 +702,6 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
|
|||
return $o;
|
||||
}
|
||||
|
||||
|
||||
function best_link_url($item)
|
||||
{
|
||||
|
||||
$best_url = '';
|
||||
$sparkle = false;
|
||||
|
||||
$clean_url = normalise_link($item['author-link']);
|
||||
|
||||
if ((local_channel()) && (local_channel() == $item['uid'])) {
|
||||
if (isset(App::$contacts) && x(App::$contacts, $clean_url)) {
|
||||
$best_url = App::$contacts[$clean_url]['url'];
|
||||
}
|
||||
}
|
||||
if (! $best_url) {
|
||||
if (strlen($item['author-link'])) {
|
||||
$best_url = $item['author-link'];
|
||||
} else {
|
||||
$best_url = $item['url'];
|
||||
}
|
||||
}
|
||||
|
||||
return $best_url;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function thread_action_menu($item, $mode = '')
|
||||
{
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ function sync_atoken($channel, $atokens)
|
|||
continue;
|
||||
}
|
||||
|
||||
$r = q(
|
||||
q(
|
||||
"UPDATE atoken SET " . TQUOT . "%s" . TQUOT . " = '%s' WHERE atoken_guid = '%s' AND atoken_uid = %d",
|
||||
dbesc($k),
|
||||
dbesc($v),
|
||||
|
@ -847,10 +847,8 @@ function sync_sysapps($channel, $apps)
|
|||
$sysapps = Apps::get_system_apps(false);
|
||||
|
||||
if ($channel && $apps) {
|
||||
$columns = db_columns('app');
|
||||
|
||||
foreach ($apps as $app) {
|
||||
$exists = false;
|
||||
$term = ((array_key_exists('term', $app)) ? $app['term'] : null);
|
||||
|
||||
if (array_key_exists('app_system', $app) && (! intval($app['app_system']))) {
|
||||
|
@ -1590,7 +1588,6 @@ function sync_files($channel, $files)
|
|||
if ($att['filetype'] === 'multipart/mixed' && $att['is_dir']) {
|
||||
Stdio::mkdir($newfname, STORAGE_DEFAULT_PERMISSIONS, true);
|
||||
$attachment_stored = true;
|
||||
continue;
|
||||
} else {
|
||||
// it's a file
|
||||
// for the sync version of this algorithm (as opposed to 'offline import')
|
||||
|
@ -1635,7 +1632,6 @@ function sync_files($channel, $files)
|
|||
if ($x['success']) {
|
||||
$attachment_stored = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1843,11 +1839,10 @@ function scan_webpage_elements($path, $type, $cloud = false)
|
|||
$metadata = json_decode(file_get_contents($jsonfilepath), true);
|
||||
if ($cloud) {
|
||||
$contentfilename = get_filename_by_cloudname($metadata['contentfile'], $channel, $folder);
|
||||
$metadata['path'] = $folder . '/' . $contentfilename;
|
||||
} else {
|
||||
$contentfilename = $metadata['contentfile'];
|
||||
$metadata['path'] = $folder . '/' . $contentfilename;
|
||||
}
|
||||
$metadata['path'] = $folder . '/' . $contentfilename;
|
||||
if ($metadata['contentfile'] === '') {
|
||||
logger('Invalid ' . $type . ' content file');
|
||||
return false;
|
||||
|
@ -1885,7 +1880,6 @@ function import_webpage_element($element, $channel, $type)
|
|||
$namespace = 'WEBPAGE';
|
||||
$name = $element['pagelink'];
|
||||
if ($name) {
|
||||
require_once('library/urlify/URLify.php');
|
||||
$name = strtolower(URLify::transliterate($name));
|
||||
}
|
||||
$arr['title'] = $element['title'];
|
||||
|
@ -1958,7 +1952,7 @@ function import_webpage_element($element, $channel, $type)
|
|||
// The element owner is the channel importing the elements
|
||||
$arr['owner_xchan'] = get_observer_hash();
|
||||
// The author is either the owner or whomever was specified
|
||||
$arr['author_xchan'] = (($element['author_xchan']) ? $element['author_xchan'] : get_observer_hash());
|
||||
$arr['author_xchan'] = (($element['author_xchan']) ?: get_observer_hash());
|
||||
// Import mimetype if it is a valid mimetype for the element
|
||||
$mimetypes = [
|
||||
'text/bbcode',
|
||||
|
@ -1986,7 +1980,7 @@ function import_webpage_element($element, $channel, $type)
|
|||
intval(local_channel())
|
||||
);
|
||||
|
||||
IConfig::Set($arr, 'system', $namespace, (($name) ? $name : substr($arr['mid'], 0, 16)), true);
|
||||
IConfig::Set($arr, 'system', $namespace, (($name) ?: substr($arr['mid'], 0, 16)), true);
|
||||
|
||||
if ($i) {
|
||||
$arr['id'] = $i[0]['id'];
|
||||
|
@ -1994,17 +1988,9 @@ function import_webpage_element($element, $channel, $type)
|
|||
if ($arr['edited'] > $i[0]['edited']) {
|
||||
$x = item_store_update($arr, $execflag);
|
||||
}
|
||||
} else {
|
||||
if (($i) && (intval($i[0]['item_deleted']))) {
|
||||
// was partially deleted already, finish it off
|
||||
q(
|
||||
"delete from item where mid = '%s' and uid = %d",
|
||||
dbesc($arr['mid']),
|
||||
intval(local_channel())
|
||||
);
|
||||
} else {
|
||||
$x = item_store($arr, $execflag);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$x = item_store($arr, $execflag);
|
||||
}
|
||||
|
||||
if ($x && $x['success']) {
|
||||
|
|
|
@ -69,7 +69,7 @@ function get_browser_language()
|
|||
*
|
||||
* If there is no match fall back to config['system']['language']
|
||||
*
|
||||
* @return Language code in 2-letter ISO 639-1 (en).
|
||||
* @return string // code in 2-letter ISO 639-1 (en).
|
||||
*/
|
||||
function get_best_language()
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ function get_best_language()
|
|||
$preferred = 'unset';
|
||||
}
|
||||
|
||||
$arr = array('langs' => $langs, 'preferred' => $preferred);
|
||||
$arr = ['langs' => $langs, 'preferred' => $preferred];
|
||||
|
||||
Hook::call('get_best_language', $arr);
|
||||
|
||||
|
@ -168,6 +168,7 @@ function pop_lang()
|
|||
*
|
||||
* @param string $lang language code in 2-letter ISO 639-1 (en, de, fr) format
|
||||
* @param bool $install (optional) default false
|
||||
* @noinspection PhpIncludeInspection
|
||||
*/
|
||||
function load_translation_table($lang, $install = false)
|
||||
{
|
||||
|
@ -224,7 +225,7 @@ function t($s, $ctx = '')
|
|||
|
||||
function translate_projectname($s)
|
||||
{
|
||||
if (strpos($s, 'rojectname') !== false) {
|
||||
if (str_contains($s, 'rojectname')) {
|
||||
return str_replace([ '$projectname','$Projectname' ], [ System::get_project_name(), ucfirst(System::get_project_name()) ], $s);
|
||||
}
|
||||
return $s;
|
||||
|
@ -291,10 +292,10 @@ function string_plural_select_default($n)
|
|||
function get_language_name($s, $l = null)
|
||||
{
|
||||
// get() expects the second part to be in upper case
|
||||
if (strpos($s, '-') !== false) {
|
||||
if (str_contains($s, '-')) {
|
||||
$s = substr($s, 0, 2) . strtoupper(substr($s, 2));
|
||||
}
|
||||
if ($l !== null && strpos($l, '-') !== false) {
|
||||
if ($l !== null && str_contains($l, '-')) {
|
||||
$l = substr($l, 0, 2) . strtoupper(substr($l, 2));
|
||||
}
|
||||
|
||||
|
@ -372,11 +373,9 @@ function lang_selector()
|
|||
|
||||
$tpl = Theme::get_template('lang_selector.tpl');
|
||||
|
||||
$o = replace_macros($tpl, array(
|
||||
return replace_macros($tpl, [
|
||||
'$title' => t('Select an alternate language'),
|
||||
'$langs' => array($lang_options, $selected),
|
||||
'$langs' => [$lang_options, $selected],
|
||||
|
||||
));
|
||||
|
||||
return $o;
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ function photo_upload($channel, $observer, $args)
|
|||
// allow an import from a binary string representing the image.
|
||||
// This bypasses the upload step and max size limit checking
|
||||
|
||||
$imagedata = (($args['content']) ? $args['content'] : $args['data']);
|
||||
$imagedata = (($args['content']) ?: $args['data']);
|
||||
$filename = $args['filename'];
|
||||
$filesize = strlen($imagedata);
|
||||
// this is going to be deleted if it exists
|
||||
|
@ -223,7 +223,6 @@ function photo_upload($channel, $observer, $args)
|
|||
if (! $height) {
|
||||
$height = $ph->getHeight();
|
||||
}
|
||||
$smallest = 0;
|
||||
|
||||
$photo_hash = (($args['resource_id']) ?: photo_new_resource());
|
||||
|
||||
|
@ -509,7 +508,7 @@ function photo_upload($channel, $observer, $args)
|
|||
} else {
|
||||
$item['aid'] = $channel['channel_account_id'];
|
||||
$item['uid'] = $channel['channel_id'];
|
||||
$item_result = item_store($item, false, $deliver);
|
||||
item_store($item, false, $deliver);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -596,8 +595,6 @@ function photo_calculate_scale($arr)
|
|||
$width = $arr[0];
|
||||
$height = $arr[1];
|
||||
|
||||
$dest_width = $dest_height = 0;
|
||||
|
||||
if (! ($width && $height)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -698,7 +695,6 @@ function photos_albums_list($channel, $observer, $sort_key = 'display_path', $di
|
|||
if ($xv['total'] != 0 && attach_can_view_folder($channel_id, $observer_xchan, $xv['folder'])) {
|
||||
$albums[] = [ 'album' => $rv['display_path'], 'folder' => $xv['folder'], 'total' => $xv['total'] ];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue