]> git.mxchange.org Git - friendica.git/blobdiff - view/theme/frio/theme.php
Remove "f" parameter / network page parameter cleanup
[friendica.git] / view / theme / frio / theme.php
index d177e81d327e5689337b6cac557703b14d2ce249..513bb4e61d7d9490d262d461c7d1ec1be2f3b698 100644 (file)
@@ -14,10 +14,10 @@ use Friendica\Core\Config;
 use Friendica\Core\Hook;
 use Friendica\Core\L10n;
 use Friendica\Core\Logger;
-use Friendica\Core\PConfig;
 use Friendica\Core\Renderer;
-use Friendica\Core\System;
+use Friendica\Core\Session;
 use Friendica\Database\DBA;
+use Friendica\DI;
 use Friendica\Model;
 use Friendica\Module;
 use Friendica\Util\Strings;
@@ -35,13 +35,21 @@ function frio_init(App $a)
 
        // if the device is a mobile device set js is_mobile
        // variable so the js scripts can use this information
-       if ($a->is_mobile || $a->is_tablet) {
-               $a->page['htmlhead'] .= <<< EOT
+       if (DI::mode()->isMobile() || DI::mode()->isMobile()) {
+               DI::page()['htmlhead'] .= <<< EOT
                        <script type="text/javascript">
                                var is_mobile = 1;
                        </script>
 EOT;
        }
+
+       $enable_compose = \Friendica\Core\PConfig::get(local_user(), 'frio', 'enable_compose');
+       $compose = $enable_compose === '1' || $enable_compose === null && Config::get('frio', 'enable_compose') ? 1 : 0;
+       DI::page()['htmlhead'] .= <<< HTML
+               <script type="text/javascript">
+                       var compose = $compose;
+               </script>
+HTML;
 }
 
 function frio_install()
@@ -119,7 +127,7 @@ function frio_item_photo_links(App $a, &$body_info)
 function frio_item_photo_menu(App $a, &$arr)
 {
        foreach ($arr['menu'] as $k => $v) {
-               if (strpos($v, 'poke/?f=&c=') === 0 || strpos($v, 'message/new/') === 0) {
+               if (strpos($v, 'poke?c=') === 0 || strpos($v, 'message/new/') === 0) {
                        $v = 'javascript:addToModal(\'' . $v . '\'); return false;';
                        $arr['menu'][$k] = $v;
                }
@@ -173,7 +181,7 @@ function frio_contact_photo_menu(App $a, &$args)
        // Add to pm and poke links a new key with the value 'modal'.
        // Later we can make conditions in the corresponing templates (e.g.
        // contact_template.tpl)
-       if (strpos($pokelink, 'poke/?f=&c=' . $cid) !== false) {
+       if (strpos($pokelink, 'poke?c=' . $cid) !== false) {
                $args['menu']['poke'][3] = 'modal';
        }
 
@@ -201,7 +209,7 @@ function frio_remote_nav($a, &$nav)
        // get the homelink from $_XSESSION
        $homelink = Model\Profile::getMyURL();
        if (!$homelink) {
-               $homelink = defaults($_SESSION, 'visitor_home', '');
+               $homelink = Session::get('visitor_home', '');
        }
 
        // split up the url in it's parts (protocol,domain/directory, /profile/, nickname
@@ -232,7 +240,7 @@ function frio_remote_nav($a, &$nav)
                // user info
                $r = q("SELECT `micro` FROM `contact` WHERE `uid` = %d AND `self`", intval($a->user['uid']));
 
-               $r[0]['photo'] = (DBA::isResult($r) ? $a->removeBaseURL($r[0]['micro']) : 'images/person-48.jpg');
+               $r[0]['photo'] = (DBA::isResult($r) ? DI::baseUrl()->remove($r[0]['micro']) : 'images/person-48.jpg');
                $r[0]['name'] = $a->user['username'];
        } elseif (!local_user() && remote_user()) {
                $r = q("SELECT `name`, `nick`, `micro` AS `photo` FROM `contact` WHERE `id` = %d", intval(remote_user()));
@@ -246,21 +254,21 @@ function frio_remote_nav($a, &$nav)
                $r = false;
        }
 
+       $remoteUser = null;
        if (DBA::isResult($r)) {
                $nav['userinfo'] = [
                        'icon' => (DBA::isResult($r) ? $r[0]['photo'] : 'images/person-48.jpg'),
                        'name' => $r[0]['name'],
                ];
+               $remoteUser = $r[0];
        }
 
-       if (!local_user() && !empty($server_url)) {
-               $nav['logout'] = [$server_url . '/logout', L10n::t('Logout'), '', L10n::t('End this session')];
-
+       if (!local_user() && !empty($server_url) && !is_null($remoteUser)) {
                // user menu
-               $nav['usermenu'][] = [$server_url . '/profile/' . $a->user['nickname'], L10n::t('Status'), '', L10n::t('Your posts and conversations')];
-               $nav['usermenu'][] = [$server_url . '/profile/' . $a->user['nickname'] . '?tab=profile', L10n::t('Profile'), '', L10n::t('Your profile page')];
-               $nav['usermenu'][] = [$server_url . '/photos/' . $a->user['nickname'], L10n::t('Photos'), '', L10n::t('Your photos')];
-               $nav['usermenu'][] = [$server_url . '/videos/' . $a->user['nickname'], L10n::t('Videos'), '', L10n::t('Your videos')];
+               $nav['usermenu'][] = [$server_url . '/profile/' . $remoteUser['nick'], L10n::t('Status'), '', L10n::t('Your posts and conversations')];
+               $nav['usermenu'][] = [$server_url . '/profile/' . $remoteUser['nick'] . '?tab=profile', L10n::t('Profile'), '', L10n::t('Your profile page')];
+               $nav['usermenu'][] = [$server_url . '/photos/' . $remoteUser['nick'], L10n::t('Photos'), '', L10n::t('Your photos')];
+               $nav['usermenu'][] = [$server_url . '/videos/' . $remoteUser['nick'], L10n::t('Videos'), '', L10n::t('Your videos')];
                $nav['usermenu'][] = [$server_url . '/events/', L10n::t('Events'), '', L10n::t('Your events')];
 
                // navbar links