function get() { if (\App::$argv[1] === "json") { $tmp = list_smilies(); $results = array(); for ($i = 0; $i < count($tmp['texts']); $i++) { $results[] = array('text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]); } json_return_and_die($results); } else { return smilies('', true); } }
/** * @brief Replaces text emoticons with graphical images. * * It is expected that this function will be called using HTML text. * We will escape text between HTML pre and code blocks, and HTML attributes * (such as urls) from being processed. * * At a higher level, the bbcode [nosmile] tag can be used to prevent this * function from being executed by the prepare_text() routine when preparing * bbcode source for HTML display. * * @param string $s * @param boolean $sample (optional) default false * @return string */ function smilies($s, $sample = false) { if (intval(get_config('system', 'no_smilies')) || local_channel() && intval(get_pconfig(local_channel(), 'system', 'no_smilies'))) { return $s; } $s = preg_replace_callback('{<(pre|code)>.*?</\\1>}ism', 'smile_shield', $s); $s = preg_replace_callback('/<[a-z]+ .*?>/ism', 'smile_shield', $s); $params = list_smilies(); $params['string'] = $s; if ($sample) { $s = '<div class="smiley-sample">'; for ($x = 0; $x < count($params['texts']); $x++) { $s .= '<dl><dt>' . $params['texts'][$x] . '</dt><dd>' . $params['icons'][$x] . '</dd></dl>'; } } else { $params['string'] = preg_replace_callback('/<(3+)/', 'preg_heart', $params['string']); $s = str_replace($params['texts'], $params['icons'], $params['string']); } $s = preg_replace_callback('/<!--base64:(.*?)-->/ism', 'smile_unshield', $s); return $s; }