本文整理汇总了PHP中mosHTML::cleanText方法的典型用法代码示例。如果您正苦于以下问题:PHP mosHTML::cleanText方法的具体用法?PHP mosHTML::cleanText怎么用?PHP mosHTML::cleanText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mosHTML
的用法示例。
在下文中一共展示了mosHTML::cleanText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
$database->setQuery($query);
$rows = $database->loadObjectList();
foreach ($rows as $row) {
// title for particular item
$item_title = htmlspecialchars($row->title);
// url link to article
global $mosConfig_sef;
// & used instead of & as this is converted by feedcreator
if ($mosConfig_sef == '1') {
$item_link = sefRelToAbs('index.php?option=com_content&task=view&id=' . $row->id);
} else {
$item_link = $mosConfig_live_site . '/index.php?option=com_content&task=view&id=' . $row->id;
}
// removes all formating from the intro text for the description text
$item_description = $row->introtext;
$item_description = mosHTML::cleanText($item_description);
if ($info['limit_text']) {
if ($info['text_length']) {
// limits description text to x words
$item_description_array = split(' ', $item_description);
$count = count($item_description_array);
if ($count > $info['text_length']) {
$item_description = '';
for ($a = 0; $a < $info['text_length']; $a++) {
$item_description .= $item_description_array[$a] . ' ';
}
$item_description = trim($item_description);
$item_description .= '...';
}
} else {
// do not include description when text_length = 0
示例2: feed
function feed($id, $showFeed)
{
global $database, $mainframe;
global $mosConfig_live_site, $mosConfig_offset, $mosConfig_absolute_path;
$params = rdRss::getParameters($id);
//print_r($params);
// set filename for live bookmarks feed
if (!$showFeed & $params->live_bookmark) {
// standard bookmark filename
$params->file = $mosConfig_absolute_path . '/cache/' . $params->live_bookmark . "_" . $id;
} else {
// set filename for rss feeds
$params->file = strtolower(str_replace('.', '', $params->feed));
$params->file = $mosConfig_absolute_path . '/cache/' . $params->file . "_" . $id . '.xml';
}
// load feed creator class
$rss = new UniversalFeedCreator();
// load image creator class
$image = new FeedImage();
// loads cache file
if ($showFeed && $params->cache) {
$rss->useCached($params->feed, $params->file, $params->cache_time);
}
$rss->title = $params->title;
$rss->description = $params->description;
$rss->link = $params->link;
$rss->syndicationURL = $params->link;
$rss->cssStyleSheet = NULL;
$rss->encoding = $params->encoding;
if ($params->image) {
$image->url = $params->image;
$image->link = $params->link;
$image->title = $params->image_alt;
$image->description = $params->description;
// loads image info into rss array
$rss->image = $image;
}
if ($id == '1') {
$fp = 1;
} else {
$fp = 0;
}
$rows = rdRss::getData($params, $fp);
if (count($rows) && $params->published) {
foreach ($rows as $row) {
// title for particular item
$item_title = htmlspecialchars($row->title);
$item_title = html_entity_decode($item_title);
// url link to article
// & used instead of & as this is converted by feed creator
$item_link = $mosConfig_live_site . '/index.php?option=com_content&task=view&id=' . $row->id . '&Itemid=' . $mainframe->getItemid($row->id);
$item_link = sefRelToAbs($item_link);
// removes all formating from the intro text for the description text
$item_description = $row->introtext;
$item_description = mosHTML::cleanText($item_description);
$item_description = html_entity_decode($item_description);
if ($params->limit_text) {
if ($params->text_length) {
// limits description text to x words
$item_description_array = split(' ', $item_description);
$count = count($item_description_array);
if ($count > $params->text_length) {
$item_description = '';
for ($a = 0; $a < $params->text_length; $a++) {
$item_description .= $item_description_array[$a] . ' ';
}
$item_description = trim($item_description);
$item_description .= '...';
}
} else {
// do not include description when text_length = 0
$item_description = NULL;
}
}
// load individual item creator class
$item = new FeedItem();
// item info
$item->title = $item_title;
$item->link = $item_link;
$item->description = $item_description;
$item->source = $params->link;
$item->date = date('r', $row->created_ts);
// loads item info into rss array
$rss->addItem($item);
}
}
//save feed file
$rss->saveFeed($params->feed, $params->file, $showFeed);
}
示例3: _format
function _format(&$objDBDoc)
{
global $_DOCMAN;
require_once $_DOCMAN->getPath('classes', 'file');
require_once $_DOCMAN->getPath('classes', 'params');
require_once $_DOCMAN->getPath('classes', 'mambots');
$file = new DOCMAN_file($objDBDoc->dmfilename, $_DOCMAN->getCfg('dmpath'));
$params = new dmParameters($objDBDoc->attribs, '', 'params');
// format document data
$this->objFormatData = DOCMAN_Utils::get_object_vars($objDBDoc);
$this->objFormatData->owner = $this->_formatUserName($objDBDoc->dmowner);
$this->objFormatData->submited_by = $this->_formatUserName($objDBDoc->dmsubmitedby);
$this->objFormatData->maintainedby = $this->_formatUserName($objDBDoc->dmmantainedby);
$this->objFormatData->lastupdatedby = $this->_formatUserName($objDBDoc->dmlastupdateby);
$this->objFormatData->checkedoutby = $this->_formatUserName($objDBDoc->checked_out);
$this->objFormatData->filename = $this->_formatFilename($objDBDoc);
$this->objFormatData->filesize = $file->getSize();
$this->objFormatData->filetype = $file->ext;
$this->objFormatData->mime = $file->mime;
$this->objFormatData->hot = $this->_formatHot($objDBDoc);
$this->objFormatData->new = $this->_formatNew($objDBDoc);
$this->objFormatData->state = $this->objFormatData->new . ' ' . $this->objFormatData->hot;
//for backwards compat with 1.3
$this->objFormatData->params = $params;
$this->objFormatData->dmdescription = mosHTML::cleanText($objDBDoc->dmdescription);
// onFetchButtons event
// plugins should always return an array of Button objects
$bot = new DOCMAN_mambot('onFetchButtons');
$bot->setParm('doc', $this);
$bot->setParm('file', $file);
$bot->trigger();
if ($bot->getError()) {
_returnTo('cat_view', $bot->getErrorMsg());
}
$buttons = array();
foreach ($bot->getReturn() as $return) {
if (!is_array($return)) {
$return = array($return);
}
$buttons = array_merge($buttons, $return);
}
$this->objFormatLink =& $buttons;
// format document paths
$this->objFormatPath->icon = DOCMAN_Utils::pathIcon($file->ext . ".png", 1);
$this->objFormatPath->thumb = DOCMAN_Utils::pathThumb($objDBDoc->dmthumbnail, 1);
}
示例4: feedFrontpage
//.........这里部分代码省略.........
$image = new FeedImage();
// loads cache file
if ($showFeed && $info['cache']) {
$rss->useCached($info['feed'], $info['file'], $info['cache_time']);
}
$rss->title = $info['title'];
$rss->description = $info['description'];
$rss->link = $info['link'];
$rss->syndicationURL = $info['link'];
$rss->cssStyleSheet = NULL;
$rss->encoding = $info['encoding'];
if ($info['image']) {
$image->url = $info['image'];
$image->link = $info['link'];
$image->title = $info['image_alt'];
$image->description = $info['description'];
// loads image info into rss array
$rss->image = $image;
}
// Determine ordering for sql
switch (strtolower($info['orderby'])) {
case 'date':
$orderby = 'a.created';
break;
case 'rdate':
$orderby = 'a.created DESC';
break;
case 'alpha':
$orderby = 'a.title';
break;
case 'ralpha':
$orderby = 'a.title DESC';
break;
case 'hits':
$orderby = 'a.hits DESC';
break;
case 'rhits':
$orderby = 'a.hits ASC';
break;
case 'front':
$orderby = 'f.ordering';
break;
default:
$orderby = 'f.ordering';
break;
}
// query of frontpage content items
$query = "SELECT a.*, u.name AS author, u.usertype, UNIX_TIMESTAMP( a.created ) AS created_ts, cat.title AS cat_title, sec.title AS section_title" . "\n FROM #__content AS a" . "\n INNER JOIN #__content_frontpage AS f ON f.content_id = a.id" . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" . "\n LEFT JOIN #__categories AS cat ON cat.id = a.catid" . "\n LEFT JOIN #__sections AS sec ON sec.id = a.sectionid" . "\n WHERE a.state = 1" . "\n AND cat.published = 1" . "\n AND sec.published = 1" . "\n AND a.access = 0" . "\n AND cat.access = 0" . "\n AND sec.access = 0" . "\n AND ( a.publish_up = " . $database->Quote($nullDate) . " OR a.publish_up <= " . $database->Quote($now) . " )" . "\n AND ( a.publish_down = " . $database->Quote($nullDate) . " OR a.publish_down >= " . $database->Quote($now) . " )" . "\n ORDER BY {$orderby}";
$database->setQuery($query, 0, $info['count']);
$rows = $database->loadObjectList();
foreach ($rows as $row) {
// title for particular item
$item_title = htmlspecialchars($row->title);
$item_title = html_entity_decode($item_title);
// url link to article
// & used instead of & as this is converted by feed creator
$_Itemid = '';
$itemid = $mainframe->getItemid($row->id);
if ($itemid) {
$_Itemid = '&Itemid=' . $itemid;
}
$item_link = 'index.php?option=com_content&task=view&id=' . $row->id . $_Itemid;
$item_link = sefRelToAbs($item_link);
// removes all formating from the intro text for the description text
$item_description = $row->introtext;
$item_description = mosHTML::cleanText($item_description);
$item_description = html_entity_decode($item_description);
if ($info['limit_text']) {
if ($info['text_length']) {
// limits description text to x words
$item_description_array = split(' ', $item_description);
$count = count($item_description_array);
if ($count > $info['text_length']) {
$item_description = '';
for ($a = 0; $a < $info['text_length']; $a++) {
$item_description .= $item_description_array[$a] . ' ';
}
$item_description = trim($item_description);
$item_description .= '...';
}
} else {
// do not include description when text_length = 0
$item_description = NULL;
}
}
// load individual item creator class
$item = new FeedItem();
// item info
$item->title = $item_title;
$item->link = $item_link;
$item->description = $item_description;
$item->source = $info['link'];
$item->date = date('r', $row->created_ts);
$item->category = $row->section_title . ' - ' . $row->cat_title;
// loads item info into rss array
$rss->addItem($item);
}
// save feed file
$rss->saveFeed($info['feed'], $info['file'], $showFeed);
}
示例5: feedFrontpage
//.........这里部分代码省略.........
$rss->cssStyleSheet = NULL;
$rss->encoding = $info['encoding'];
if ($info['image']) {
$image->url = $info['image'];
$image->link = $info['link'];
$image->title = $info['image_alt'];
$image->description = $info['description'];
// loads image info into rss array
$rss->image = $image;
}
// Determine ordering for sql
switch (strtolower($info['orderby'])) {
case 'date':
$orderby = 'a.created';
break;
case 'rdate':
$orderby = 'a.created DESC';
break;
case 'alpha':
$orderby = 'a.title';
break;
case 'ralpha':
$orderby = 'a.title DESC';
break;
case 'hits':
$orderby = 'a.hits DESC';
break;
case 'rhits':
$orderby = 'a.hits ASC';
break;
case 'front':
$orderby = 'f.ordering';
break;
default:
$orderby = 'f.ordering';
break;
}
$join = "\n INNER JOIN #__content_frontpage AS f ON f.content_id = a.id";
$_and = '';
// query of frontpage content items
$query = "SELECT a.*, u.name AS author, u.usertype" . "\n FROM #__content AS a" . $join . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" . "\n WHERE a.state = '1'" . $_and . "\n AND a.access = 0" . "\n AND ( publish_up = '0000-00-00 00:00:00' OR publish_up <= '" . $now . "' )" . "\n AND ( publish_down = '0000-00-00 00:00:00' OR publish_down >= '" . $now . "' )" . "\n ORDER BY " . $orderby . ($info['count'] ? "\n LIMIT " . $info['count'] : '');
$database->setQuery($query);
$rows = $database->loadObjectList();
foreach ($rows as $row) {
// title for particular item
$item_title = htmlspecialchars($row->title);
$item_title = html_entity_decode($item_title);
// article author
$item_author = $row->author;
$ItemID = $mainframe->getItemid($row->id);
if ($ItemID == 0) {
//If the content item is not tied to a menu and the ItemID is 0 then the URL fails with SEF on
//Reset to frontpage if this is the case
$ItemID = 1;
}
// url link to article (& used instead of & as this is converted by feed creator)
/* Build the $item_link a bit differently for SEF since sefRelToAbs doesn't convert the URL properly when
passed $mosConfig_live_site. No SEF needs $mosConfig_live_site, else & becomes an issue. */
if ($mosConfig_sef == 1) {
$item_link = 'index.php?option=com_content&task=view&id=' . $row->id . '&Itemid=' . $ItemID;
} else {
$item_link = $mosConfig_live_site . '/index.php?option=com_content&task=view&id=' . $row->id . '&Itemid=' . $ItemID;
}
$item_link = sefRelToAbs($item_link);
// removes all formating from the intro text for the description text
$item_description = $row->introtext;
$item_description = mosHTML::cleanText($item_description);
$item_description = html_entity_decode($item_description);
if ($info['limit_text']) {
if ($info['text_length']) {
// limits description text to x words
$item_description_array = split(' ', $item_description);
$count = count($item_description_array);
if ($count > $info['text_length']) {
$item_description = '';
for ($a = 0; $a < $info['text_length']; $a++) {
$item_description .= $item_description_array[$a] . ' ';
}
$item_description = trim($item_description);
$item_description .= '...';
}
} else {
// do not include description when text_length = 0
$item_description = NULL;
}
}
// load individual item creator class
$item = new FeedItem();
// item info
$item->title = $item_title;
$item->link = $item_link;
$item->description = $item_description;
$item->source = $info['link'];
$item->author = $item_author;
// loads item info into rss array
$rss->addItem($item);
}
// save feed file
$rss->saveFeed($info['feed'], $info['file'], $showFeed);
}