]> git.mxchange.org Git - friendica.git/blobdiff - src/App.php
Merge pull request #6031 from MrPetovan/bug/add-missing-lang-default-template
[friendica.git] / src / App.php
index 8cd3b74f99483a11f5a009cbfb402280016257b2..ff118ac72550792328c7305f2d393d659c868bff 100644 (file)
@@ -34,8 +34,6 @@ class App
        public $query_string = '';
        public $config = [];
        public $page = [];
-       public $pager = [];
-       public $page_offset;
        public $profile;
        public $profile_uid;
        public $user;
@@ -303,16 +301,6 @@ class App
                        $this->module = 'home';
                }
 
-               // See if there is any page number information, and initialise pagination
-               $this->pager['page'] = !empty($_GET['page']) && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1;
-               $this->pager['itemspage'] = 50;
-               $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
-
-               if ($this->pager['start'] < 0) {
-                       $this->pager['start'] = 0;
-               }
-               $this->pager['total'] = 0;
-
                // Detect mobile devices
                $mobile_detect = new MobileDetect();
                $this->is_mobile = $mobile_detect->isMobile();
@@ -732,23 +720,6 @@ class App
                return $this->urlPath;
        }
 
-       public function setPagerTotal($n)
-       {
-               $this->pager['total'] = intval($n);
-       }
-
-       public function setPagerItemsPage($n)
-       {
-               $this->pager['itemspage'] = ((intval($n) > 0) ? intval($n) : 0);
-               $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
-       }
-
-       public function setPagerPage($n)
-       {
-               $this->pager['page'] = $n;
-               $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
-       }
-
        /**
         * Initializes App->page['htmlhead'].
         *
@@ -798,9 +769,6 @@ class App
                        $touch_icon = 'images/friendica-128.png';
                }
 
-               // get data wich is needed for infinite scroll on the network page
-               $infinite_scroll = infinite_scroll_data($this->module);
-
                Core\Addon::callHooks('head', $this->page['htmlhead']);
 
                $tpl = get_markup_template('head.tpl');
@@ -818,7 +786,6 @@ class App
                        '$update_interval' => $interval,
                        '$shortcut_icon'   => $shortcut_icon,
                        '$touch_icon'      => $touch_icon,
-                       '$infinite_scroll' => $infinite_scroll,
                        '$block_public'    => intval(Core\Config::get('system', 'block_public')),
                        '$stylesheets'     => $this->stylesheets,
                ]) . $this->page['htmlhead'];
@@ -1774,7 +1741,7 @@ class App
                        $privateapps = Core\Config::get('config', 'private_addons', false);
                        if (Core\Addon::isEnabled($this->module) && file_exists("addon/{$this->module}/{$this->module}.php")) {
                                //Check if module is an app and if public access to apps is allowed or not
-                               if ((!local_user()) && Core\Addon::isApp($this->module) && $privateapps) {
+                               if ((!local_user()) && Core\Hook::isAddonApp($this->module) && $privateapps) {
                                        info(Core\L10n::t("You must be logged in to use addons. "));
                                } else {
                                        include_once "addon/{$this->module}/{$this->module}.php";
@@ -1984,6 +1951,9 @@ class App
                // Theme templates expect $a as an App instance
                $a = $this;
 
+               // Used as is in view/php/default.php
+               $lang = Core\L10n::getCurrentLang();
+
                /// @TODO Looks unsafe (remote-inclusion), is maybe not but Core\Theme::getPathForFile() uses file_exists() but does not escape anything
                require_once $template;
        }
@@ -2000,10 +1970,26 @@ class App
        public function internalRedirect($toUrl = '', $ssl = false)
        {
                if (filter_var($toUrl, FILTER_VALIDATE_URL)) {
-                       throw new InternalServerErrorException('URL is not a relative path, please use System::externalRedirectTo');
+                       throw new InternalServerErrorException("'$toUrl is not a relative path, please use System::externalRedirectTo");
                }
 
                $redirectTo = $this->getBaseURL($ssl) . '/' . ltrim($toUrl, '/');
                Core\System::externalRedirect($redirectTo);
        }
+
+       /**
+        * Automatically redirects to relative or absolute URL
+        * Should only be used if it isn't clear if the URL is either internal or external
+        *
+        * @param string $toUrl The target URL
+        *
+        */
+       public function redirect($toUrl)
+       {
+               if (filter_var($toUrl, FILTER_VALIDATE_URL)) {
+                       Core\System::externalRedirect($toUrl);
+               } else {
+                       $this->internalRedirect($toUrl);
+               }
+       }
 }