本文整理汇总了PHP中K2HelperUtilities::cleanAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP K2HelperUtilities::cleanAttributes方法的具体用法?PHP K2HelperUtilities::cleanAttributes怎么用?PHP K2HelperUtilities::cleanAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类K2HelperUtilities
的用法示例。
在下文中一共展示了K2HelperUtilities::cleanAttributes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareItem
//.........这里部分代码省略.........
}
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_S.jpg')) {
$item->imageSmall = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $item->id) . '_S.jpg';
if ($params->get('imageTimestamp')) {
$item->imageSmall .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_M.jpg')) {
$item->imageMedium = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $item->id) . '_M.jpg';
if ($params->get('imageTimestamp')) {
$item->imageMedium .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_L.jpg')) {
$item->imageLarge = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $item->id) . '_L.jpg';
if ($params->get('imageTimestamp')) {
$item->imageLarge .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_XL.jpg')) {
$item->imageXLarge = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $item->id) . '_XL.jpg';
if ($params->get('imageTimestamp')) {
$item->imageXLarge .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_Generic.jpg')) {
$item->imageGeneric = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $item->id) . '_Generic.jpg';
if ($params->get('imageTimestamp')) {
$item->imageGeneric .= $timestamp;
}
}
//Extra fields
if ($view == 'item' && $item->params->get('itemExtraFields') || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemExtraFields') || $view == 'itemlist' && $task == 'tag' && $item->params->get('tagItemExtraFields') || $view == 'itemlist' && ($task == 'search' || $task == 'date') && $item->params->get('genericItemExtraFields')) {
$item->extra_fields = $this->getItemExtraFields($item->extra_fields, $item);
}
//Attachments
if ($view == 'item' && $item->params->get('itemAttachments') || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemAttachments')) {
$item->attachments = $this->getItemAttachments($item->id);
}
//Rating
if ($view == 'item' && $item->params->get('itemRating') || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemRating')) {
$item->votingPercentage = $this->getVotesPercentage($item->id);
$item->numOfvotes = $this->getVotesNum($item->id);
}
//Filtering
if ($params->get('introTextCleanup')) {
$filterTags = preg_split('#[,\\s]+#', trim($params->get('introTextCleanupExcludeTags')));
$filterAttrs = preg_split('#[,\\s]+#', trim($params->get('introTextCleanupTagAttr')));
$filterAttrs = array_filter($filterAttrs);
$item->introtext = K2HelperUtilities::cleanTags($item->introtext, $filterTags);
if (count($filterAttrs)) {
$item->introtext = K2HelperUtilities::cleanAttributes($item->introtext, $filterTags, $filterAttrs);
}
}
if ($params->get('fullTextCleanup')) {
$filterTags = preg_split('#[,\\s]+#', trim($params->get('fullTextCleanupExcludeTags')));
$filterAttrs = preg_split('#[,\\s]+#', trim($params->get('fullTextCleanupTagAttr')));
$filterAttrs = array_filter($filterAttrs);
$item->fulltext = K2HelperUtilities::cleanTags($item->fulltext, $filterTags);
if (count($filterAttrs)) {
$item->fulltext = K2HelperUtilities::cleanAttributes($item->fulltext, $filterTags, $filterAttrs);
}
}
if ($item->params->get('catItemIntroTextWordLimit') && $task == 'category') {
$item->introtext = K2HelperUtilities::wordLimit($item->introtext, $item->params->get('catItemIntroTextWordLimit'));
}
$item->cleanTitle = $item->title;
$item->title = htmlspecialchars($item->title, ENT_QUOTES);
$item->image_caption = htmlspecialchars($item->image_caption, ENT_QUOTES);
//Author
if ($view == 'item' && ($item->params->get('itemAuthorBlock') || $item->params->get('itemAuthor')) || $view == 'itemlist' && ($task == '' || $task == 'category') && ($item->params->get('catItemAuthorBlock') || $item->params->get('catItemAuthor')) || $view == 'itemlist' && $task == 'user' || $view == 'relatedByTag') {
if (!empty($item->created_by_alias)) {
$item->author = new stdClass();
$item->author->name = $item->created_by_alias;
$item->author->avatar = K2HelperUtilities::getAvatar('alias');
$item->author->link = JURI::root();
} else {
$author = JFactory::getUser($item->created_by);
$item->author = $author;
$item->author->link = JRoute::_(K2HelperRoute::getUserRoute($item->created_by));
$item->author->profile = $this->getUserProfile($item->created_by);
$item->author->avatar = K2HelperUtilities::getAvatar($author->id, $author->email, $params->get('userImageWidth'));
}
if (!isset($item->author->profile) || is_null($item->author->profile)) {
$item->author->profile = new JObject();
$item->author->profile->gender = NULL;
}
}
//Num of comments
if ($params->get('comments', 0) > 0) {
$user = JFactory::getUser();
if (!$user->guest && $user->id == $item->created_by && $params->get('inlineCommentsModeration')) {
$item->numOfComments = $this->countItemComments($item->id, false);
} else {
$item->numOfComments = $this->countItemComments($item->id);
}
}
return $item;
}