本文整理匯總了PHP中IPSText::getEmoticonDirectory方法的典型用法代碼示例。如果您正苦於以下問題:PHP IPSText::getEmoticonDirectory方法的具體用法?PHP IPSText::getEmoticonDirectory怎麽用?PHP IPSText::getEmoticonDirectory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IPSText
的用法示例。
在下文中一共展示了IPSText::getEmoticonDirectory方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: fetchEmoticons
/**
* Fetch emoticons as JSON for editors, etc
*
* @param mixed Number of emoticons to fetch (false to fetch all, or an int limit)
* @return string JSON
*/
public function fetchEmoticons($fetchFirstX = false)
{
$emoDir = IPSText::getEmoticonDirectory();
$emoString = '';
$smilie_id = 0;
$total = 0;
foreach (ipsRegistry::cache()->getCache('emoticons') as $elmo) {
if ($elmo['emo_set'] != $emoDir) {
continue;
}
$total++;
if ($fetchFirstX !== false && $smilie_id + 1 > $fetchFirstX) {
continue;
}
// -----------------------------------------
// Make single quotes as URL's with html entites in them
// are parsed by the browser, so ' causes JS error :o
// -----------------------------------------
if (strstr($elmo['typed'], "'")) {
$in_delim = '"';
} else {
$in_delim = "'";
}
$emoArray[$smilie_id] = array('src' => $elmo['image'], 'text' => addslashes($elmo['typed']));
$smilie_id++;
}
return array('total' => $total, 'count' => $smilie_id, 'emoticons' => $emoArray);
}
示例2: emoticonImgtoCode
/**
* Convert IMG codes into text smilies
*
* @param text $txt
* @return text $txt
*/
public function emoticonImgtoCode($txt)
{
if (count($this->cache->getCache('emoticons')) > 0) {
$emoDir = IPSText::getEmoticonDirectory();
$txt = str_replace('<#EMO_DIR#>', $this->registry->output->skin['set_emo_dir'], $txt);
foreach ($this->cache->getCache('emoticons') as $row) {
if ($row['emo_set'] != $emoDir) {
continue;
}
/* This can shave a lot of loading time off of a site if there is a lot of large text being parsed,
especially if there are a lot of emoticons too */
if (strpos($txt, $row['image']) === false) {
continue;
}
/* BBCode */
$txt = preg_replace('#(\\s)?\\[img\\]' . preg_quote($this->settings['public_cdn_url'] . 'style_emoticons/' . $this->registry->output->skin['set_emo_dir'] . '/' . $row['image'], '#') . '\\[/img\\]#', ' ' . $row['typed'], $txt);
/* HTML */
$txt = preg_replace('#(\\s)?<img([^>]+?)src=(?:[\'"])' . preg_quote($this->settings['public_cdn_url'] . 'style_emoticons/' . $this->registry->output->skin['set_emo_dir'] . '/' . $row['image'], '#') . '(?:[\'"])(?:[^>]+?)?>#', ' ' . $row['typed'], $txt);
}
}
return $txt;
}