]> git.mxchange.org Git - friendica.git/blobdiff - view/theme/frio/theme.php
Fixed indentation
[friendica.git] / view / theme / frio / theme.php
index 2913a1553317d98798ebb6ff41c1237b93de0261..58eb8268c3e5b1a6d35eacd2551108ea551f49cf 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2024, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  *
  * Name: frio
- * Description: Bootstrap V3 theme. The theme is currently under construction, so it is far from finished. For further information have a look at the <a href="https://github.com/friendica/friendica/tree/develop/view/theme/frio/README.md">ReadMe</a>.
- * Version: V.0.8.5
+ * Description: Responsive theme based on a modern HTML/CSS/JavaScript framework.
+ * Version: V.1.0
  * Author: Rabuzarus <https://friendica.kommune4.de/profile/rabuzarus>
+ * Maintainer: Hypolite Petovan <https://friendica.mrpetovan.com/profile/hypolite>
  */
 
 use Friendica\App;
 use Friendica\Content\Text\Plaintext;
-use Friendica\Content\Widget;
 use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\Core\Renderer;
-use Friendica\Core\Session;
 use Friendica\Database\DBA;
 use Friendica\DI;
-use Friendica\Model;
-use Friendica\Model\Item;
 use Friendica\Model\Contact;
+use Friendica\Model\Item;
 use Friendica\Model\Profile;
-use Friendica\Module;
-use Friendica\Util\Strings;
 
 const FRIO_SCHEME_ACCENT_BLUE   = '#1e87c2';
 const FRIO_SCHEME_ACCENT_RED    = '#b50404';
@@ -54,8 +50,6 @@ function frio_init(App $a)
        global $frio;
        $frio = 'view/theme/frio';
 
-       // disable the events module link in the profile tab
-       $a->setThemeInfoValue('events_in_profile', false);
        $a->setThemeInfoValue('videowidth', 622);
 
        Renderer::setActiveTemplateEngine('smarty3');
@@ -88,13 +82,12 @@ function frio_install()
  *  This function does replace the links to photos
  *  of other friendica users. Original the photos are
  *  linked to the photo page. Now they will linked directly
- *  to the photo file. This function is nessesary to use colorbox
+ *  to the photo file. This function is necessary to use colorbox
  *  in the network stream
  *
- * @param App $a Unused but required by hook definition
  * @param array $body_info The item and its html output
  */
-function frio_item_photo_links(App $a, &$body_info)
+function frio_item_photo_links(&$body_info)
 {
        $occurence = 0;
        $p = Plaintext::getBoundariesPosition($body_info['html'], '<a', '>');
@@ -108,7 +101,7 @@ function frio_item_photo_links(App $a, &$body_info)
                        $newlink = str_replace($matches[0], "/photo/{$matches[1]}", $link);
 
                        // Add a "quiet" parameter to any redir links to prevent the "XX welcomes YY" info boxes
-                       $newlink = preg_replace('/href="([^"]+)\/redir\/([^"]+)&url=([^"]+)"/', 'href="$1/redir/$2&quiet=1&url=$3"', $newlink);
+                       $newlink = preg_replace('#href="([^"]+)/contact/redir/(\d+)&url=([^"]+)"#', 'href="$1/contact/redir/$2&quiet=1&url=$3"', $newlink);
 
                        // Having any arguments to the link for Colorbox causes it to fetch base64 code instead of the image
                        $newlink = preg_replace('/\/[?&]zrl=([^&"]+)/', '', $newlink);
@@ -127,10 +120,9 @@ function frio_item_photo_links(App $a, &$body_info)
  *  to call the addToModal javascript function so this pages can
  *  be loaded in a bootstrap modal
  *
- * @param App $a Unused but required by the hook definition
  * @param array $arr Contains item data and the original photo_menu
  */
-function frio_item_photo_menu(App $a, &$arr)
+function frio_item_photo_menu(&$arr)
 {
        foreach ($arr['menu'] as $k => $v) {
                if (strpos($v, 'message/new/') === 0) {
@@ -149,10 +141,9 @@ function frio_item_photo_menu(App $a, &$arr)
  *  Additionally the profile, status and photo page links  will be changed
  *  to don't open in a new tab if the contact is a friendica contact.
  *
- * @param App $a The app data
  * @param array $args Contains contact data and the original photo_menu
  */
-function frio_contact_photo_menu(App $a, &$args)
+function frio_contact_photo_menu(&$args)
 {
        $cid = $args['contact']['id'];
 
@@ -162,10 +153,10 @@ function frio_contact_photo_menu(App $a, &$args)
                $pmlink = '';
        }
 
-       // Set the the indicator for opening the status, profile and photo pages
+       // Set the indicator for opening the status, profile and photo pages
        // in a new tab to false if the contact a dfrn (friendica) contact
-       // We do this because we can go back on foreign friendica pages throuhg
-       // friendicas "magic-link" which indicates a friendica user on froreign
+       // We do this because we can go back on foreign friendica pages through
+       // friendicas "magic-link" which indicates a friendica user on foreign
        // friendica servers as remote user or visitor
        //
        // The value for opening in a new tab is e.g. when
@@ -180,7 +171,7 @@ function frio_contact_photo_menu(App $a, &$args)
 
        // Add to pm link a new key with the value 'modal'.
        // Later we can make conditions in the corresponding templates (e.g.
-       // contact_template.tpl)
+       // contact/entry.tpl)
        if (strpos($pmlink, 'message/new/' . $cid) !== false) {
                $args['menu']['pm'][3] = 'modal';
        }
@@ -201,7 +192,7 @@ function frio_contact_photo_menu(App $a, &$args)
  * @param array $nav_info The original nav info array: nav, banner, userinfo, sitelocation
  * @throws Exception
  */
-function frio_remote_nav(App $a, array &$nav_info)
+function frio_remote_nav(array &$nav_info)
 {
        if (DI::mode()->has(App\Mode::MAINTENANCEDISABLED)) {
                // get the homelink from $_SESSION
@@ -213,10 +204,10 @@ function frio_remote_nav(App $a, array &$nav_info)
                // since $userinfo isn't available for the hook we write it to the nav array
                // this isn't optimal because the contact query will be done now twice
                $fields = ['id', 'url', 'avatar', 'micro', 'name', 'nick', 'baseurl', 'updated'];
-               if ($a->isLoggedIn()) {
-                       $remoteUser = Contact::selectFirst($fields, ['uid' => $a->getLoggedInUserId(), 'self' => true]);
-               } elseif (!local_user() && remote_user()) {
-                       $remoteUser                = Contact::getById(remote_user(), $fields);
+               if (DI::userSession()->isAuthenticated()) {
+                       $remoteUser = Contact::selectFirst($fields, ['uid' => DI::userSession()->getLocalUserId(), 'self' => true]);
+               } elseif (!DI::userSession()->getLocalUserId() && DI::userSession()->getRemoteUserId()) {
+                       $remoteUser                = Contact::getById(DI::userSession()->getRemoteUserId(), $fields);
                        $nav_info['nav']['remote'] = DI::l10n()->t('Guest');
                } elseif (Profile::getMyURL()) {
                        $remoteUser                = Contact::getByURL($homelink, null, $fields);
@@ -233,17 +224,20 @@ function frio_remote_nav(App $a, array &$nav_info)
                        $server_url           = $remoteUser['baseurl'];
                }
 
-               if (!local_user() && !empty($server_url) && !is_null($remoteUser)) {
+               if (!DI::userSession()->getLocalUserId() && !empty($server_url) && !is_null($remoteUser)) {
                        // user menu
                        $nav_info['nav']['usermenu'][] = [$server_url . '/profile/' . $remoteUser['nick'], DI::l10n()->t('Status'), '', DI::l10n()->t('Your posts and conversations')];
                        $nav_info['nav']['usermenu'][] = [$server_url . '/profile/' . $remoteUser['nick'] . '/profile', DI::l10n()->t('Profile'), '', DI::l10n()->t('Your profile page')];
+                       // Kept for backwards-compatibility reasons, the remote server may not have updated to version 2022.12 yet
+                       // @TODO Switch with the new routes by version 2023.12
+                       //$nav_info['nav']['usermenu'][] = [$server_url . '/profile/' . $remoteUser['nick'] . '/photos', DI::l10n()->t('Photos'), '', DI::l10n()->t('Your photos')];
                        $nav_info['nav']['usermenu'][] = [$server_url . '/photos/' . $remoteUser['nick'], DI::l10n()->t('Photos'), '', DI::l10n()->t('Your photos')];
                        $nav_info['nav']['usermenu'][] = [$server_url . '/profile/' . $remoteUser['nick'] . '/media', DI::l10n()->t('Media'), '', DI::l10n()->t('Your postings with media')];
-                       $nav_info['nav']['usermenu'][] = [$server_url . '/events/', DI::l10n()->t('Events'), '', DI::l10n()->t('Your events')];
+                       $nav_info['nav']['usermenu'][] = [$server_url . '/calendar/', DI::l10n()->t('Calendar'), '', DI::l10n()->t('Your calendar')];
 
                        // navbar links
                        $nav_info['nav']['network']  = [$server_url . '/network', DI::l10n()->t('Network'), '', DI::l10n()->t('Conversations from your friends')];
-                       $nav_info['nav']['events']   = [$server_url . '/events', DI::l10n()->t('Events'), '', DI::l10n()->t('Events and Calendar')];
+                       $nav_info['nav']['calendar'] = [$server_url . '/calendar', DI::l10n()->t('Calendar'), '', DI::l10n()->t('Calendar')];
                        $nav_info['nav']['messages'] = [$server_url . '/message', DI::l10n()->t('Messages'), '', DI::l10n()->t('Private mail')];
                        $nav_info['nav']['settings'] = [$server_url . '/settings', DI::l10n()->t('Settings'), '', DI::l10n()->t('Account settings')];
                        $nav_info['nav']['contacts'] = [$server_url . '/contact', DI::l10n()->t('Contacts'), '', DI::l10n()->t('Manage/edit friends and contacts')];
@@ -252,13 +246,13 @@ function frio_remote_nav(App $a, array &$nav_info)
        }
 }
 
-function frio_display_item(App $a, &$arr)
+function frio_display_item(&$arr)
 {
        // Add follow to the item menu
        $followThread = [];
        if (
-               local_user()
-               && in_array($arr['item']['uid'], [0, local_user()])
+               DI::userSession()->getLocalUserId()
+               && in_array($arr['item']['uid'], [0, DI::userSession()->getLocalUserId()])
                && $arr['item']['gravity'] == Item::GRAVITY_PARENT
                && !$arr['item']['self']
                && !$arr['item']['mention']