]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/Smilies.php
Rename social.disable_cw pconfig to system.disable_cw
[friendica.git] / src / Content / Smilies.php
index 464b5ee83ee28bad158025565c9bed59c610e832..89a833d71098762dd1f8f583bd1b447a76ccb7e4 100644 (file)
@@ -15,6 +15,7 @@
 namespace Friendica\Content;
 
 use Friendica\App;
+use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\PConfig;
 use Friendica\Core\System;
@@ -33,6 +34,8 @@ class Smilies
         * @param array  $b              Array of emoticons
         * @param string $smiley         The text smilie
         * @param string $representation The replacement
+        *
+        * @return void
         */
        public static function add(&$b, $smiley, $representation)
        {
@@ -57,9 +60,9 @@ class Smilies
         *
         * @hook smilie ('texts' => smilies texts array, 'icons' => smilies html array)
         */
-       public static function get_list()
+       public static function getList()
        {
-               $texts =  array(
+               $texts =  [
                        '<3',
                        '</3',
                        '<\\3',
@@ -96,9 +99,9 @@ class Smilies
                        'red#',
                        'red#matrix'
 
-               );
+               ];
 
-               $icons = array(
+               $icons = [
                '<img class="smiley" src="' . System::baseUrl() . '/images/smiley-heart.gif" alt="&lt;3" title="&lt;3" />',
                '<img class="smiley" src="' . System::baseUrl() . '/images/smiley-brokenheart.gif" alt="&lt;/3" title="&lt;/3" />',
                '<img class="smiley" src="' . System::baseUrl() . '/images/smiley-brokenheart.gif" alt="&lt;\\3" title="&lt;\\3" />',
@@ -134,10 +137,10 @@ class Smilies
                '<a href="https://friendi.ca">~friendica <img class="smiley" src="' . System::baseUrl() . '/images/friendica-16.png" alt="~friendica" title="~friendica" /></a>',
                '<a href="http://redmatrix.me/">red<img class="smiley" src="' . System::baseUrl() . '/images/rm-16.png" alt="red#" title="red#" />matrix</a>',
                '<a href="http://redmatrix.me/">red<img class="smiley" src="' . System::baseUrl() . '/images/rm-16.png" alt="red#matrix" title="red#matrix" />matrix</a>'
-               );
+               ];
 
-               $params = array('texts' => $texts, 'icons' => $icons);
-               call_hooks('smilie', $params);
+               $params = ['texts' => $texts, 'icons' => $icons];
+               Addon::callHooks('smilie', $params);
 
                return $params;
        }
@@ -154,7 +157,7 @@ class Smilies
         * bbcode source for HTML display
         *
         * @param string  $s         Text that should be replaced
-        * @param boolean $sample
+        * @param boolean $sample    optional, default false
         * @param boolean $no_images Only replace emoticons without images
         *
         * @return string HML Output of the Smilie
@@ -170,10 +173,10 @@ class Smilies
                $s = preg_replace_callback('/<pre>(.*?)<\/pre>/ism', 'self::encode', $s);
                $s = preg_replace_callback('/<code>(.*?)<\/code>/ism', 'self::encode', $s);
 
-               $params = self::get_list();
+               $params = self::getList();
 
                if ($no_images) {
-                       $cleaned = array('texts' => array(), 'icons' => array());
+                       $cleaned = ['texts' => [], 'icons' => []];
                        $icons = $params['icons'];
                        foreach ($icons as $key => $icon) {
                                if (!strstr($icon, '<img ')) {
@@ -192,7 +195,7 @@ class Smilies
                                $s .= '<dl><dt>' . $params['texts'][$x] . '</dt><dd>' . $params['icons'][$x] . '</dd></dl>';
                        }
                } else {
-                       $params['string'] = preg_replace_callback('/&lt;(3+)/', 'self::preg_heart', $params['string']);
+                       $params['string'] = preg_replace_callback('/&lt;(3+)/', 'self::pregHeart', $params['string']);
                        $s = str_replace($params['texts'], $params['icons'], $params['string']);
                }
 
@@ -202,11 +205,21 @@ class Smilies
                return $s;
        }
 
+       /**
+        * @param string $m string
+        *
+        * @return string base64 encoded string
+        */
        private static function encode($m)
        {
                return(str_replace($m[1], base64url_encode($m[1]), $m[0]));
        }
 
+       /**
+        * @param string $m string
+        *
+        * @return string base64 decoded string
+        */
        private static function decode($m)
        {
                return(str_replace($m[1], base64url_decode($m[1]), $m[0]));
@@ -216,13 +229,13 @@ class Smilies
        /**
         * @brief expand <3333 to the correct number of hearts
         *
-        * @param string $x
+        * @param string $x string
         *
         * @return string HTML Output
         *
         * @todo: Rework because it doesn't work correctly
         */
-       private static function preg_heart($x)
+       private static function pregHeart($x)
        {
                if (strlen($x[1]) == 1) {
                        return $x[0];