]> git.mxchange.org Git - friendica.git/blobdiff - src/App.php
Merge pull request #6127 from annando/notice
[friendica.git] / src / App.php
index 781faf1a506ad90326a309c0942e58ac04729129..445101309384a2f651b46fd69f78b507835538a4 100644 (file)
@@ -136,40 +136,8 @@ class App
                $this->footerScripts[] = trim($url, '/');
        }
 
-       /**
-        * @brief An array for all theme-controllable parameters
-        *
-        * Mostly unimplemented yet. Only options 'template_engine' and
-        * beyond are used.
-        */
-       public $theme = [
-               'sourcename' => '',
-               'videowidth' => 425,
-               'videoheight' => 350,
-               'force_max_items' => 0,
-               'stylesheet' => '',
-               'template_engine' => 'smarty3',
-       ];
-
-       /**
-        * @brief An array of registered template engines ('name'=>'class name')
-        */
-       public $template_engines = [];
-
-       /**
-        * @brief An array of instanced template engines ('name'=>'instance')
-        */
-       public $template_engine_instance = [];
        public $process_id;
        public $queue;
-       private $ldelim = [
-               'internal' => '',
-               'smarty3' => '{{'
-       ];
-       private $rdelim = [
-               'internal' => '',
-               'smarty3' => '}}'
-       ];
        private $scheme;
        private $hostname;
 
@@ -309,7 +277,7 @@ class App
                $this->isAjax = strtolower(defaults($_SERVER, 'HTTP_X_REQUESTED_WITH', '')) == 'xmlhttprequest';
 
                // Register template engines
-               $this->registerTemplateEngine('Friendica\Render\FriendicaSmartyEngine');
+               Core\Renderer::registerTemplateEngine('Friendica\Render\FriendicaSmartyEngine');
        }
 
        /**
@@ -752,8 +720,8 @@ class App
                        $this->page['title'] = $this->config['sitename'];
                }
 
-               if (!empty($this->theme['stylesheet'])) {
-                       $stylesheet = $this->theme['stylesheet'];
+               if (!empty(Core\Renderer::$theme['stylesheet'])) {
+                       $stylesheet = Core\Renderer::$theme['stylesheet'];
                } else {
                        $stylesheet = $this->getCurrentThemeStylesheetPath();
                }
@@ -772,12 +740,12 @@ class App
 
                Core\Addon::callHooks('head', $this->page['htmlhead']);
 
-               $tpl = get_markup_template('head.tpl');
+               $tpl = Core\Renderer::getMarkupTemplate('head.tpl');
                /* put the head template at the beginning of page['htmlhead']
                 * since the code added by the modules frequently depends on it
                 * being first
                 */
-               $this->page['htmlhead'] = replace_macros($tpl, [
+               $this->page['htmlhead'] = Core\Renderer::replaceMacros($tpl, [
                        '$baseurl'         => $this->getBaseURL(),
                        '$local_user'      => local_user(),
                        '$generator'       => 'Friendica' . ' ' . FRIENDICA_VERSION,
@@ -819,11 +787,11 @@ class App
                 */
                if ($this->is_mobile || $this->is_tablet) {
                        if (isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
-                               $link = 'toggle_mobile?address=' . curPageURL();
+                               $link = 'toggle_mobile?address=' . urlencode(curPageURL());
                        } else {
-                               $link = 'toggle_mobile?off=1&address=' . curPageURL();
+                               $link = 'toggle_mobile?off=1&address=' . urlencode(curPageURL());
                        }
-                       $this->page['footer'] .= replace_macros(get_markup_template("toggle_mobile_footer.tpl"), [
+                       $this->page['footer'] .= Core\Renderer::replaceMacros(Core\Renderer::getMarkupTemplate("toggle_mobile_footer.tpl"), [
                                '$toggle_link' => $link,
                                '$toggle_text' => Core\L10n::t('toggle mobile')
                        ]);
@@ -831,8 +799,8 @@ class App
 
                Core\Addon::callHooks('footer', $this->page['footer']);
 
-               $tpl = get_markup_template('footer.tpl');
-               $this->page['footer'] = replace_macros($tpl, [
+               $tpl = Core\Renderer::getMarkupTemplate('footer.tpl');
+               $this->page['footer'] = Core\Renderer::replaceMacros($tpl, [
                        '$baseurl' => $this->getBaseURL(),
                        '$footerScripts' => $this->footerScripts,
                ]) . $this->page['footer'];
@@ -848,114 +816,18 @@ class App
        public function removeBaseURL($origURL)
        {
                // Remove the hostname from the url if it is an internal link
-               $nurl = normalise_link($origURL);
-               $base = normalise_link($this->getBaseURL());
+               $nurl = Util\Strings::normaliseLink($origURL);
+               $base = Util\Strings::normaliseLink($this->getBaseURL());
                $url = str_replace($base . '/', '', $nurl);
 
                // if it is an external link return the orignal value
-               if ($url == normalise_link($origURL)) {
+               if ($url == Util\Strings::normaliseLink($origURL)) {
                        return $origURL;
                } else {
                        return $url;
                }
        }
 
-       /**
-        * @brief Register template engine class
-        *
-        * @param string $class
-        */
-       private function registerTemplateEngine($class)
-       {
-               $v = get_class_vars($class);
-               if (!empty($v['name'])) {
-                       $name = $v['name'];
-                       $this->template_engines[$name] = $class;
-               } else {
-                       echo "template engine <tt>$class</tt> cannot be registered without a name.\n";
-                       die();
-               }
-       }
-
-       /**
-        * @brief Return template engine instance.
-        *
-        * If $name is not defined, return engine defined by theme,
-        * or default
-        *
-        * @return object Template Engine instance
-        */
-       public function getTemplateEngine()
-       {
-               $template_engine = defaults($this->theme, 'template_engine', 'smarty3');
-
-               if (isset($this->template_engines[$template_engine])) {
-                       if (isset($this->template_engine_instance[$template_engine])) {
-                               return $this->template_engine_instance[$template_engine];
-                       } else {
-                               $class = $this->template_engines[$template_engine];
-                               $obj = new $class;
-                               $this->template_engine_instance[$template_engine] = $obj;
-                               return $obj;
-                       }
-               }
-
-               echo "template engine <tt>$template_engine</tt> is not registered!\n";
-               exit();
-       }
-
-       /**
-        * @brief Returns the active template engine.
-        *
-        * @return string the active template engine
-        */
-       public function getActiveTemplateEngine()
-       {
-               return $this->theme['template_engine'];
-       }
-
-       /**
-        * sets the active template engine
-        *
-        * @param string $engine the template engine (default is Smarty3)
-        */
-       public function setActiveTemplateEngine($engine = 'smarty3')
-       {
-               $this->theme['template_engine'] = $engine;
-       }
-
-       /**
-        * Gets the right delimiter for a template engine
-        *
-        * Currently:
-        * Internal = ''
-        * Smarty3 = '{{'
-        *
-        * @param string $engine The template engine (default is Smarty3)
-        *
-        * @return string the right delimiter
-        */
-       public function getTemplateLeftDelimiter($engine = 'smarty3')
-       {
-               return $this->ldelim[$engine];
-       }
-
-       /**
-        * Gets the left delimiter for a template engine
-        *
-        * Currently:
-        * Internal = ''
-        * Smarty3 = '}}'
-        *
-        * @param string $engine The template engine (default is Smarty3)
-        *
-        * @return string the left delimiter
-        */
-       public function getTemplateRightDelimiter($engine = 'smarty3')
-       {
-               return $this->rdelim[$engine];
-       }
-
        /**
         * Saves a timestamp for a value - f.e. a call
         * Necessary for profiling Friendica
@@ -1571,7 +1443,7 @@ class App
                // and www.example.com vs example.com.
                // We will only change the url to an ip address if there is no existing setting
 
-               if (empty($url) || (!link_compare($url, $this->getBaseURL())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $this->getHostName()))) {
+               if (empty($url) || (!Util\Strings::compareLink($url, $this->getBaseURL())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $this->getHostName()))) {
                        Core\Config::set('system', 'url', $this->getBaseURL());
                }
        }
@@ -1682,7 +1554,7 @@ class App
                        $this->module = 'maintenance';
                } else {
                        $this->checkURL();
-                       check_db(false);
+                       Core\Update::check(false);
                        Core\Addon::loadAddons();
                        Core\Hook::loadHooks();
                }
@@ -1792,8 +1664,8 @@ class App
                                Core\Logger::log('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], Core\Logger::DEBUG);
 
                                header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . Core\L10n::t('Not Found'));
-                               $tpl = get_markup_template("404.tpl");
-                               $this->page['content'] = replace_macros($tpl, [
+                               $tpl = Core\Renderer::getMarkupTemplate("404.tpl");
+                               $this->page['content'] = Core\Renderer::replaceMacros($tpl, [
                                        '$message' =>  Core\L10n::t('Page not found.')
                                ]);
                        }
@@ -1881,7 +1753,7 @@ class App
 
                // Add the navigation (menu) template
                if ($this->module != 'install' && $this->module != 'maintenance') {
-                       $this->page['htmlhead'] .= replace_macros(get_markup_template('nav_head.tpl'), []);
+                       $this->page['htmlhead'] .= Core\Renderer::replaceMacros(Core\Renderer::getMarkupTemplate('nav_head.tpl'), []);
                        $this->page['nav']       = Content\Nav::build($this);
                }