本文整理汇总了PHP中TextCleaner::truncate方法的典型用法代码示例。如果您正苦于以下问题:PHP TextCleaner::truncate方法的具体用法?PHP TextCleaner::truncate怎么用?PHP TextCleaner::truncate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextCleaner
的用法示例。
在下文中一共展示了TextCleaner::truncate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rd_block_resources
/**
* Este archivo permite controlar el bloque o los bloques
* Bloques Existentes:
*
* 1. Publicaciones Recientes
* 2. Publicaciones Populares (Mas Leídas)
* 3. Publicaciones Mejor Votadas
*/
function rd_block_resources($options)
{
global $xoopsModule;
include_once XOOPS_ROOT_PATH . '/modules/docs/class/rdresource.class.php';
$db = XoopsDatabaseFactory::getDatabaseConnection();
$mc = RMUtilities::module_config('docs');
$sql = "SELECT * FROM " . $db->prefix("rd_resources") . ' WHERE public=1 AND approved=1';
switch ($options[0]) {
case 'recents':
$sql .= " ORDER BY created DESC";
break;
case 'popular':
$sql .= " ORDER BY `reads` DESC";
break;
}
$sql .= " LIMIT 0, " . ($options[1] > 0 ? $options[1] : 5);
$result = $db->query($sql);
$block = array();
while ($row = $db->fetchArray($result)) {
$res = new RDResource();
$res->assignVars($row);
$ret = array();
$ret['id'] = $res->id();
$ret['title'] = $res->getVar('title');
if ($options[2]) {
$ret['desc'] = $options[3] == 0 ? $res->getVar('description') : TextCleaner::truncate($res->getVar('description'), $options[3]);
}
$ret['link'] = $res->permalink();
$ret['author'] = sprintf(__('Created by %s', 'docs'), '<strong>' . $res->getVar('owname') . '</strong>');
$ret['reads'] = sprintf(__('Viewed %s times', 'docs'), '<strong>' . $res->getVar('reads') . '</strong>');
$block['resources'][] = $ret;
}
RMTemplate::get()->add_style('blocks.css', 'docs');
return $block;
}
示例2: search_resources
function search_resources()
{
global $xoopsConfig, $xoopsUser, $page, $xoopsTpl;
$keyword = rmc_server_var($_GET, 'keyword', '');
$db = XoopsDatabaseFactory::getDatabaseConnection();
$sql = "SELECT COUNT(*) FROM " . $db->prefix("rd_resources") . " WHERE (title LIKE '%{$keyword}%' OR description LIKE '%{$keyword}%') AND public=1 AND approved=1";
list($num) = $db->fetchRow($db->query($sql));
$page = rmc_server_var($_GET, 'page', 1);
$limit = 15;
$tpages = ceil($num / $limit);
$page = $page > $tpages ? $tpages : $page;
$start = $num <= 0 ? 0 : ($page - 1) * $limit;
$nav = new RMPageNav($num, $limit, $page, 5);
$nav->target_url(RDFunctions::make_link('search') . '?keyword=' . $keyword . '&page={PAGE_NUM}');
$sql = "SELECT * FROM " . $db->prefix("rd_resources") . " WHERE (title LIKE '%{$keyword}%' OR description LIKE '%{$keyword}%') AND public=1 AND approved=1 LIMIT {$start}, {$limit}";
$result = $db->query($sql);
$resources = array();
while ($row = $db->fetchArray($result)) {
$res = new RDResource();
$res->assignVars($row);
$resources[] = array('id' => $res->id(), 'title' => $res->getVar('title'), 'desc' => TextCleaner::truncate($res->getVar('description'), 100), 'link' => $res->permalink(), 'created' => $res->getVar('created'), 'owner' => $res->getVar('owner'), 'uname' => $res->getVar('owname'), 'reads' => $res->getVar('reads'));
}
RDFunctions::breadcrumb();
RMBreadCrumb::get()->add_crumb(__('Browsing recent Documents', 'docs'));
RMTemplate::get()->add_style('docs.css', 'docs');
include 'header.php';
$xoopsTpl->assign('xoops_pagetitle', sprintf(__('Search results for "%s"', 'docs'), $keyword));
include RMEvents::get()->run_event('docs.template.search', RMTemplate::get()->get_template('rd_search.php', 'module', 'docs'));
include 'footer.php';
}
示例3: eventMywordsViewPost
/**
* This method is designed specially for MyWords
*/
public function eventMywordsViewPost($post_data, MWPost $post)
{
$config = RMFunctions::get()->plugin_settings('metaseo', true);
if (!$config['meta']) {
$metas = '<meta name="description" content="' . TextCleaner::truncate($post->content(true), $config['len']) . '" />';
$tags = array();
foreach ($post->tags() as $tag) {
$tags[] = $tag['tag'];
}
$tags = implode(',', $tags);
$metas .= '<meta name="keywords" content="' . $tags . '" />';
} else {
$metas = '<meta name="description" content="' . $post->get_meta($config['meta_name'], false) . '" />';
$metas = '<meta name="description" content="' . $post->get_meta($config['meta_keys'], false) . '" />';
}
RMTemplate::get()->add_head($metas);
return $post_data;
}
示例4: rmc_bkcomments_show
function rmc_bkcomments_show($options)
{
$db = XoopsDatabaseFactory::getDatabaseConnection();
$sql = "SELECT * FROM " . $db->prefix("rmc_comments") . " ORDER BY id_com DESC";
$limit = $options[0] > 0 ? $options[0] : 10;
$sql .= " LIMIT 0,{$limit}";
$result = $db->query($sql);
$comments = array();
$ucache = array();
$ecache = array();
$mods = array();
while ($row = $db->fetchArray($result)) {
$com = new RMComment();
$com->assignVars($row);
if ($options[3]) {
// Editor data
if (!isset($ecache[$com->getVar('user')])) {
$ecache[$com->getVar('user')] = new RMCommentUser($com->getVar('user'));
}
$editor = $ecache[$com->getVar('user')];
if ($editor->getVar('xuid') > 0) {
if (!isset($ucache[$editor->getVar('xuid')])) {
$ucache[$editor->getVar('xuid')] = new XoopsUser($editor->getVar('xuid'));
}
$user = $ucache[$editor->getVar('xuid')];
$poster = array('id' => $user->getVar('uid'), 'name' => $user->getVar('uname'), 'email' => $user->getVar('email'), 'posts' => $user->getVar('posts'), 'avatar' => $user->getVar('user_avatar') != '' && $user->getVar('user_avatar') != 'blank.gif' ? XOOPS_UPLOAD_URL . '/' . $user->getVar('user_avatar') : RMCURL . '/images/avatar.gif', 'rank' => $user->rank());
} else {
$poster = array('id' => 0, 'name' => $editor->getVar('name'), 'email' => $editor->getVar('email'), 'posts' => 0, 'avatar' => RMCURL . '/images/avatar.gif', 'rank' => '');
}
}
// Get item
$cpath = XOOPS_ROOT_PATH . '/modules/' . $row['id_obj'] . '/class/' . $row['id_obj'] . 'controller.php';
if (is_file($cpath)) {
if (!class_exists(ucfirst($row['id_obj']) . 'Controller')) {
include_once $cpath;
}
$class = ucfirst($row['id_obj']) . 'Controller';
$controller = new $class();
$item = $controller->get_item($row['params'], $com);
$item_url = $controller->get_item_url($row['params'], $com);
} else {
$item = __('Unknow', 'rmcommon');
$item_url = '';
}
if (isset($mods[$row['id_obj']])) {
$mod = $mods[$row['id_obj']];
} else {
$m = RMFunctions::load_module($row['id_obj']);
$mod = $m->getVar('name');
$mods[$row['id_obj']] = $mod;
}
$comments[] = array('id' => $row['id_com'], 'text' => TextCleaner::truncate(TextCleaner::getInstance()->clean_disabled_tags(TextCleaner::getInstance()->popuplinks(TextCleaner::getInstance()->nofollow($com->getVar('content')))), 50), 'poster' => isset($poster) ? $poster : null, 'posted' => formatTimestamp($com->getVar('posted'), 'l'), 'item' => $item, 'item_url' => $item_url, 'module' => $row['id_obj'], 'status' => $com->getVar('status'), 'module' => $mod);
}
$comments = RMEvents::get()->run_event('rmcommon.loading.block.comments', $comments);
$block['comments'] = $comments;
$block['show_module'] = $options[1];
$block['show_name'] = $options[2];
$block['show_user'] = $options[3];
$block['show_date'] = $options[4];
$num = $options[2] + $options[3] + $options[4];
$block['data_width'] = floor(100 / $num);
RMTemplate::get()->add_xoops_style('bk_comments.css', 'rmcommon');
return $block;
}
示例5: RMPageNav
$tags_list .= ($tags_list == '' ? '' : ', ') . '<a href="' . $tag->permalink() . '">' . $tag->getVar('tag') . '</a>';
}
// Post pages
$total_pages = $post->total_pages();
$nav = new RMPageNav($total_pages, 1, $page, 5);
$nav->target_url($post->permalink() . ($mc['permalinks'] > 1 ? 'page/{PAGE_NUM}/' : '&page={PAGE_NUM}'));
$xoopsTpl->assign('post_navbar', $nav->render(true));
// Post data
$post_arr = array('id' => $post->id(), 'title' => $post->getVar('title'), 'published' => sprintf(__('%s by %s', 'mywords'), MWFunctions::format_time($post->getVar('pubdate')), date('H:i', $post->getVar('pubdate')), '<a href="' . $editor->permalink() . '">' . (isset($editor) ? $editor->getVar('name') : __('Anonymous', 'mywords')) . "</a>"), 'text' => $post->content(false, $page), 'cats' => $post->get_categories_names(), 'tags' => $tags_list, 'trackback' => $post->getVar('pingstatus') ? MWFunctions::get_url(true) . $post->id() : '', 'meta' => $post->get_meta('', false), 'time' => $post->getVar('pubdate'), 'image' => $post->getImage($xoopsModuleConfig['post_imgs_size']), 'author' => $editor->getVar('name'), 'alink' => $editor->permalink());
// Plugins?
$post_arr = RMEvents::get()->run_event('mywords.view.post', $post_arr, $post);
$xoopsTpl->assign('post', $post_arr);
// Social sites
if ($xoopsModuleConfig['showbookmarks']) {
foreach ($socials as $site) {
$xoopsTpl->append('socials', array('title' => $site->getVar('title'), 'icon' => $site->getVar('icon'), 'url' => $site->link($post->getVar('title'), $post->permalink(), TextCleaner::truncate($post->content(true), 60)), 'alt' => $site->getVar('alt')));
}
}
unset($tags_list);
// Comments
// When use the common utilities comments system you can choose between
// use of Common Utilities templates or use your own templates
// We will use MyWords included templates
if ($post->getVar('comstatus')) {
$comms = RMFunctions::get_comments('mywords', 'post=' . $post->id(), 'module', 0, null, false);
if (count($comms) != $post->getVar('comments')) {
$post->setVar('comments', count($comms));
$xoopsDB->queryF("UPDATE " . $xoopsDB->prefix("mw_posts") . " SET `comments`=" . count($comms) . " WHERE id_post=" . $post->id());
}
$xoopsTpl->assign('comments', $comms);
// Comments form
示例6: elseif
}
}
include RMTemplate::get()->get_template('rd_resall.php', 'module', 'docs');
} elseif ($res->getVar('quick')) {
// Show Quick Index to User
$content = false;
//Obtiene índice
$db = XoopsDatabaseFactory::getDatabaseConnection();
$sql = "SELECT * FROM " . $db->prefix('rd_sections') . " WHERE id_res='" . $res->id() . "' AND parent=0 ORDER BY `order`";
$result = $db->queryF($sql);
// Quick index array
$qindex_sections = array();
while ($rows = $db->fetchArray($result)) {
$sec = new RDSection();
$sec->assignVars($rows);
$qindex_sections[] = array('id' => $id, 'title' => $sec->getVar('title'), 'desc' => TextCleaner::getInstance()->clean_disabled_tags(TextCleaner::truncate($sec->getVar('content'), 255)), 'link' => $sec->permalink());
}
include RMTemplate::get()->get_template('rd_quickindex.php', 'module', 'docs');
} else {
if (!$allowed) {
RDFunctions::error_404();
}
$toc = array();
RDFunctions::sections_tree_index(0, 0, $res, '', '', false, $toc);
include RMTemplate::get()->get_template('rd_resindextoc.php', 'module', 'docs');
}
RMTemplate::get()->add_style('docs.css', 'docs');
RMTemplate::get()->add_jquery();
RMTemplate::get()->add_script(RDURL . '/include/js/docs.js');
if ($standalone) {
RDFunctions::standalone();