]> git.mxchange.org Git - friendica.git/blobdiff - include/text.php
Merge pull request #5862 from nupplaphil/rename_App_Methods
[friendica.git] / include / text.php
index a9a11f76f2a8aae0d51a1b484ad31d83990d3589..5a18529d93ab68837560d1cb927fcbc131ff2bb7 100644 (file)
@@ -42,7 +42,7 @@ function replace_macros($s, $r) {
        // pass $baseurl to all templates
        $r['$baseurl'] = System::baseUrl();
 
-       $t = $a->template_engine();
+       $t = $a->getTemplateEngine();
        try {
                $output = $t->replaceMacros($s, $r);
        } catch (Exception $e) {
@@ -50,7 +50,7 @@ function replace_macros($s, $r) {
                killme();
        }
 
-       $a->save_timestamp($stamp1, "rendering");
+       $a->saveTimestamp($stamp1, "rendering");
 
        return $output;
 }
@@ -473,7 +473,7 @@ function get_markup_template($s, $root = '') {
        $stamp1 = microtime(true);
 
        $a = get_app();
-       $t = $a->template_engine();
+       $t = $a->getTemplateEngine();
        try {
                $template = $t->getTemplateFile($s, $root);
        } catch (Exception $e) {
@@ -481,7 +481,7 @@ function get_markup_template($s, $root = '') {
                killme();
        }
 
-       $a->save_timestamp($stamp1, "file");
+       $a->saveTimestamp($stamp1, "file");
 
        return $template;
 }
@@ -574,7 +574,7 @@ function logger($msg, $level = LOGGER_INFO) {
 
        $stamp1 = microtime(true);
        @file_put_contents($logfile, $logline, FILE_APPEND);
-       $a->save_timestamp($stamp1, "file");
+       $a->saveTimestamp($stamp1, "file");
 }
 
 /**
@@ -634,7 +634,7 @@ function dlogger($msg, $level = LOGGER_INFO) {
 
        $stamp1 = microtime(true);
        @file_put_contents($logfile, $logline, FILE_APPEND);
-       $a->save_timestamp($stamp1, "file");
+       $a->saveTimestamp($stamp1, "file");
 }
 
 
@@ -1191,9 +1191,6 @@ function prepare_body(array &$item, $attach = false, $is_preview = false)
                                $a->page['htmlhead'] .= replace_macros(get_markup_template('videos_head.tpl'), [
                                        '$baseurl' => System::baseUrl(),
                                ]);
-                               $a->page['end'] .= replace_macros(get_markup_template('videos_end.tpl'), [
-                                       '$baseurl' => System::baseUrl(),
-                               ]);
                        }
 
                        $url_parts = explode('/', $the_url);
@@ -1417,7 +1414,7 @@ function get_plink($item) {
                        ];
 
                if (x($item, 'plink')) {
-                       $ret["href"] = $a->remove_baseurl($item['plink']);
+                       $ret["href"] = $a->removeBaseURL($item['plink']);
                        $ret["title"] = L10n::t('link to source');
                }
 
@@ -1459,26 +1456,6 @@ function return_bytes($size_str) {
        }
 }
 
-
-/**
- * @return string
- */
-function generate_user_guid() {
-       $found = true;
-       do {
-               $guid = System::createGUID(32);
-               $x = q("SELECT `uid` FROM `user` WHERE `guid` = '%s' LIMIT 1",
-                       DBA::escape($guid)
-               );
-               if (!DBA::isResult($x)) {
-                       $found = false;
-               }
-       } while ($found == true);
-
-       return $guid;
-}
-
-
 /**
  * @param string $s
  * @param boolean $strip_padding
@@ -1931,58 +1908,3 @@ function format_network_name($network, $url = 0) {
                return $network_name;
        }
 }
-
-/**
- * @brief Syntax based code highlighting for popular languages.
- * @param string $s Code block
- * @param string $lang Programming language
- * @return string Formated html
- */
-function text_highlight($s, $lang) {
-       if ($lang === 'js') {
-               $lang = 'javascript';
-       }
-
-       if ($lang === 'bash') {
-               $lang = 'sh';
-       }
-
-       // @TODO: Replace Text_Highlighter_Renderer_Html by scrivo/highlight.php
-
-       // Autoload the library to make constants available
-       class_exists('Text_Highlighter_Renderer_Html');
-
-       $options = [
-               'numbers' => HL_NUMBERS_LI,
-               'tabsize' => 4,
-       ];
-
-       $tag_added = false;
-       $s = trim(html_entity_decode($s, ENT_COMPAT));
-       $s = str_replace('    ', "\t", $s);
-
-       /*
-        * The highlighter library insists on an opening php tag for php code blocks. If
-        * it isn't present, nothing is highlighted. So we're going to see if it's present.
-        * If not, we'll add it, and then quietly remove it after we get the processed output back.
-        */
-       if ($lang === 'php' && strpos($s, '<?php') !== 0) {
-               $s = '<?php' . "\n" . $s;
-               $tag_added = true;
-       }
-
-       $renderer = new Text_Highlighter_Renderer_Html($options);
-       $factory = new Text_Highlighter();
-       $hl = $factory->factory($lang);
-       $hl->setRenderer($renderer);
-       $o = $hl->highlight($s);
-       $o = str_replace("\n", '', $o);
-
-       if ($tag_added) {
-               $b = substr($o, 0, strpos($o, '<li>'));
-               $e = substr($o, strpos($o, '</li>'));
-               $o = $b . $e;
-       }
-
-       return '<code>' . $o . '</code>';
-}