]> git.mxchange.org Git - friendica.git/blobdiff - mod/cal.php
Improved page info detection
[friendica.git] / mod / cal.php
index d4830842bb05159a2d015d1a655cc24668c1cc8c..75fe87e7463f3568062f5f9faeb80d875eeeadca 100644 (file)
@@ -44,7 +44,7 @@ function cal_init(App $a)
                throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
        }
 
-       if ($a->argc < 2) {
+       if (DI::args()->getArgc() < 2) {
                throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
        }
 
@@ -52,11 +52,11 @@ function cal_init(App $a)
 
        // if it's a json request abort here becaus we don't
        // need the widget data
-       if (!empty($a->argv[2]) && ($a->argv[2] === 'json')) {
+       if (!empty(DI::args()->getArgv()[2]) && (DI::args()->getArgv()[2] === 'json')) {
                return;
        }
 
-       $owner = User::getOwnerDataByNick($a->argv[1]);
+       $owner = User::getOwnerDataByNick(DI::args()->getArgv()[1]);
        if (empty($owner)) {
                throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
        }
@@ -73,7 +73,7 @@ function cal_init(App $a)
 
 function cal_content(App $a)
 {
-       $owner = User::getOwnerDataByNick($a->argv[1]);
+       $owner = User::getOwnerDataByNick(DI::args()->getArgv()[1]);
        if (empty($owner)) {
                throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
        }
@@ -101,9 +101,9 @@ function cal_content(App $a)
        $ignored = (!empty($_REQUEST['ignored']) ? intval($_REQUEST['ignored']) : 0);
 
        $format = 'ical';
-       if ($a->argc == 4 && $a->argv[2] == 'export') {
+       if (DI::args()->getArgc() == 4 && DI::args()->getArgv()[2] == 'export') {
                $mode = 'export';
-               $format = $a->argv[3];
+               $format = DI::args()->getArgv()[3];
        }
 
        // Setup permissions structures
@@ -127,7 +127,7 @@ function cal_content(App $a)
        $sql_extra = " AND `event`.`cid` = 0 " . $sql_perms;
 
        // get the tab navigation bar
-       $tabs = BaseProfile::getTabsHTML($a, 'cal', false, $owner);
+       $tabs = BaseProfile::getTabsHTML($a, 'cal', false, $owner['nickname'], $owner['hide-friends']);
 
        // The view mode part is similiar to /mod/events.php
        if ($mode == 'view') {
@@ -172,7 +172,7 @@ function cal_content(App $a)
                $finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59);
 
 
-               if (!empty($a->argv[2]) && ($a->argv[2] === 'json')) {
+               if (!empty(DI::args()->getArgv()[2]) && (DI::args()->getArgv()[2] === 'json')) {
                        if (!empty($_GET['start'])) {
                                $start = $_GET['start'];
                        }
@@ -185,16 +185,11 @@ function cal_content(App $a)
                $start = DateTimeFormat::utc($start);
                $finish = DateTimeFormat::utc($finish);
 
-               $adjust_start = DateTimeFormat::local($start);
-               $adjust_finish = DateTimeFormat::local($finish);
-
                // put the event parametes in an array so we can better transmit them
                $event_params = [
                        'event_id'      => intval($_GET['id'] ?? 0),
                        'start'         => $start,
                        'finish'        => $finish,
-                       'adjust_start'  => $adjust_start,
-                       'adjust_finish' => $adjust_finish,
                        'ignore'        => $ignored,
                ];
 
@@ -210,7 +205,7 @@ function cal_content(App $a)
                if (DBA::isResult($r)) {
                        $r = Event::sortByDate($r);
                        foreach ($r as $rr) {
-                               $j = $rr['adjust'] ? DateTimeFormat::local($rr['start'], 'j') : DateTimeFormat::utc($rr['start'], 'j');
+                               $j = DateTimeFormat::local($rr['start'], 'j');
                                if (empty($links[$j])) {
                                        $links[$j] = DI::baseUrl() . '/' . DI::args()->getCommand() . '#link-' . $j;
                                }
@@ -220,7 +215,7 @@ function cal_content(App $a)
                // transform the event in a usable array
                $events = Event::prepareListForTemplate($r);
 
-               if (!empty($a->argv[2]) && ($a->argv[2] === 'json')) {
+               if (!empty(DI::args()->getArgv()[2]) && (DI::args()->getArgv()[2] === 'json')) {
                        echo json_encode($events);
                        exit();
                }
@@ -229,11 +224,7 @@ function cal_content(App $a)
                if (!empty($_GET['id'])) {
                        $tpl = Renderer::getMarkupTemplate("event.tpl");
                } else {
-//                     if (DI::config()->get('experimentals','new_calendar')==1){
                        $tpl = Renderer::getMarkupTemplate("events_js.tpl");
-//                     } else {
-//                             $tpl = Renderer::getMarkupTemplate("events.tpl");
-//                     }
                }
 
                // Get rid of dashes in key names, Smarty3 can't handle them