namespace Friendica\Content;
use Friendica\App;
+use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Core\System;
* @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)
{
*
* @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',
'red#',
'red#matrix'
- );
+ ];
- $icons = array(
+ $icons = [
'<img class="smiley" src="' . System::baseUrl() . '/images/smiley-heart.gif" alt="<3" title="<3" />',
'<img class="smiley" src="' . System::baseUrl() . '/images/smiley-brokenheart.gif" alt="</3" title="</3" />',
'<img class="smiley" src="' . System::baseUrl() . '/images/smiley-brokenheart.gif" alt="<\\3" title="<\\3" />',
'<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;
}
* 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
$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 ')) {
$s .= '<dl><dt>' . $params['texts'][$x] . '</dt><dd>' . $params['icons'][$x] . '</dd></dl>';
}
} else {
- $params['string'] = preg_replace_callback('/<(3+)/', 'self::preg_heart', $params['string']);
+ $params['string'] = preg_replace_callback('/<(3+)/', 'self::pregHeart', $params['string']);
$s = str_replace($params['texts'], $params['icons'], $params['string']);
}
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]));
/**
* @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];