当前位置: 首页>>代码示例>>PHP>>正文


PHP XoopsLocale::formatTimestamp方法代码示例

本文整理汇总了PHP中XoopsLocale::formatTimestamp方法的典型用法代码示例。如果您正苦于以下问题:PHP XoopsLocale::formatTimestamp方法的具体用法?PHP XoopsLocale::formatTimestamp怎么用?PHP XoopsLocale::formatTimestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XoopsLocale的用法示例。


在下文中一共展示了XoopsLocale::formatTimestamp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getExtensionList

 /**
  * Return all extensions
  *
  * @return array
  */
 public function getExtensionList()
 {
     // Get main instance
     $xoops = Xoops::getInstance();
     $module_handler = $xoops->getHandlerModule();
     $moduleperm_handler = $xoops->getHandlerGroupperm();
     $ret = array();
     $i = 0;
     foreach ($this->modulesList as $file) {
         $file = trim($file);
         if (XoopsLoad::fileExists(\XoopsBaseConfig::get('root-path') . '/modules/' . $file . '/xoops_version.php')) {
             clearstatcache();
             /* @var $module XoopsModule */
             $module = $module_handler->create();
             $module->loadInfoAsVar($file);
             if ($module->getInfo('extension')) {
                 if (in_array($file, $this->modulesDirnames)) {
                     $module->setInfo('install', true);
                     $extension = $module_handler->getByDirname($module->getInfo('dirname'));
                     $module->setInfo('mid', $extension->getVar('mid'));
                     $module->setInfo('update', XoopsLocale::formatTimestamp($extension->getVar('last_update'), 's'));
                     $module->setInfo('hasconfig', $module->getVar('hasconfig'));
                     if (round($module->getInfo('version'), 2) != $extension->getVar('version')) {
                         $module->setInfo('warning_update', true);
                     }
                     $groups = array();
                     if (is_object($xoops->user)) {
                         $groups = $xoops->user->getGroups();
                     }
                     $sadmin = $moduleperm_handler->checkRight('module_admin', $module->getInfo('mid'), $groups);
                     if ($sadmin && ($module->getVar('hasnotification') || is_array($module->getInfo('config')) || is_array($module->getInfo('comments')))) {
                         $module->setInfo('link_pref', \XoopsBaseConfig::get('url') . '/modules/system/admin.php?fct=preferences&op=showmod&mod=' . $module->getInfo('mid'));
                     }
                 } else {
                     $module->setInfo('install', false);
                 }
                 $module->setInfo('version', round($module->getInfo('version'), 2));
                 if (XoopsLoad::fileExists(\XoopsBaseConfig::get('root-path') . '/modules/' . $module->getInfo('dirname') . '/icons/logo_small.png')) {
                     $module->setInfo('logo_small', \XoopsBaseConfig::get('url') . '/modules/' . $module->getInfo('dirname') . '/icons/logo_small.png');
                 } else {
                     $module->setInfo('logo_small', \XoopsBaseConfig::get('url') . '/media/xoops/images/icons/16/default.png');
                 }
                 if (XoopsLoad::fileExists(\XoopsBaseConfig::get('root-path') . '/modules/' . $module->getInfo('dirname') . '/icons/logo_large.png')) {
                     $module->setInfo('logo_large', \XoopsBaseConfig::get('url') . '/modules/' . $module->getInfo('dirname') . '/icons/logo_large.png');
                 } else {
                     $module->setInfo('logo_large', \XoopsBaseConfig::get('url') . '/media/xoops/images/icons/32/default.png');
                 }
                 $module->setInfo('link_admin', \XoopsBaseConfig::get('url') . '/modules/' . $module->getInfo('dirname') . '/' . $module->getInfo('adminindex'));
                 $module->setInfo('options', $module->getAdminMenu());
                 $ret[] = $module;
                 unset($module);
                 ++$i;
             }
         }
     }
     return $ret;
 }
开发者ID:RanLee,项目名称:XoopsCore,代码行数:62,代码来源:extension.php

示例2: getValues

 public function getValues($keys = null, $format = null, $maxDepth = null)
 {
     $page = Page::getInstance();
     $ret = parent::getValues($keys, $format, $maxDepth);
     $ret['rating'] = number_format($this->getVar('content_rating'), 1);
     // these next two lines are rather silly
     $ret['content_authorid'] = $this->getVar('content_author');
     $ret['content_author'] = XoopsUser::getUnameFromId($this->getVar('content_author'), true);
     $ret['content_date'] = XoopsLocale::formatTimestamp($this->getVar('content_create'), $page->getConfig('page_dateformat'));
     $ret['content_time'] = XoopsLocale::formatTimestamp($this->getVar('content_create'), $page->getConfig('page_timeformat'));
     $ret['content_rating'] = number_format($this->getVar('content_rating'), 2);
     return $ret;
 }
开发者ID:RanLee,项目名称:XoopsCore,代码行数:13,代码来源:page_content.php

示例3: b_system_newmembers_show

/**
 * @return array|bool|string
 */
function b_system_newmembers_show($options)
{
    $xoops = Xoops::getInstance();
    $block = array();
    $criteria = new CriteriaCompo(new Criteria('level', 0, '>'));
    $limit = !empty($options[0]) ? $options[0] : 10;
    $criteria->setOrder('DESC');
    $criteria->setSort('user_regdate');
    $criteria->setLimit($limit);
    $member_handler = $xoops->getHandlerMember();
    $newmembers = $member_handler->getUsers($criteria);
    $count = count($newmembers);
    for ($i = 0; $i < $count; ++$i) {
        if ($options[1] == 1) {
            $block['users'][$i]['avatar'] = $newmembers[$i]->getVar('user_avatar') !== 'blank.gif' ? \XoopsBaseConfig::get('uploads-url') . '/' . $newmembers[$i]->getVar('user_avatar') : '';
        } else {
            $block['users'][$i]['avatar'] = '';
        }
        $block['users'][$i]['id'] = $newmembers[$i]->getVar('uid');
        $block['users'][$i]['name'] = $newmembers[$i]->getVar('uname');
        $block['users'][$i]['joindate'] = XoopsLocale::formatTimestamp($newmembers[$i]->getVar('user_regdate'), 's');
    }
    return $block;
}
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:27,代码来源:newmembers.php

示例4: htmlspecialchars

    $tpl->assign('channel_lastbuild', XoopsLocale::formatTimestamp(time(), 'rss'));
    $tpl->assign('channel_webmaster', $xoops->getConfig('adminmail'));
    $tpl->assign('channel_editor', $xoops->getConfig('adminmail'));
    if ($categoryid != -1) {
        $channel_category .= " > " . $categoryObj->getVar('name');
    }
    $tpl->assign('channel_category', htmlspecialchars($channel_category));
    $tpl->assign('channel_generator', $publisher->getModule()->getVar('name'));
    $tpl->assign('channel_language', XoopsLocale::getLangCode());
    $tpl->assign('image_url', \XoopsBaseConfig::get('url') . '/images/logo.gif');
    $dimention = getimagesize(\XoopsBaseConfig::get('root-path') . '/images/logo.gif');
    if (empty($dimention[0])) {
        $width = 140;
        $height = 140;
    } else {
        $width = $dimention[0] > 140 ? 140 : $dimention[0];
        $dimention[1] = $dimention[1] * $width / $dimention[0];
        $height = $dimention[1] > 140 ? $dimention[1] * $dimention[0] / 140 : $dimention[1];
    }
    $tpl->assign('image_width', $width);
    $tpl->assign('image_height', $height);
    $sarray = $publisher->getItemHandler()->getAllPublished(10, 0, $categoryid);
    if (is_array($sarray)) {
        $count = $sarray;
        /* @var $item PublisherItem */
        foreach ($sarray as $item) {
            $tpl->append('items', array('title' => htmlspecialchars($item->title(), ENT_QUOTES), 'link' => $item->getItemUrl(), 'guid' => $item->getItemUrl(), 'pubdate' => XoopsLocale::formatTimestamp($item->getVar('datesub'), 'rss'), 'description' => htmlspecialchars($item->getBlockSummary(300, true), ENT_QUOTES)));
        }
    }
}
$tpl->display('module:publisher/publisher_rss.tpl');
开发者ID:mambax7,项目名称:publisher-26,代码行数:31,代码来源:backend.php

示例5: array

$content_arr = $content_Handler->getPagePublished($start, $nb_limit);
// Assign Template variables
$xoops->tpl()->assign('content_count', $content_count);
$keywords = array();
if ($content_count > 0) {
    //Cleaning the content of $content, they are assign by blocks and mess the output
    $xoops->tpl()->assign('content', array());
    foreach (array_keys($content_arr) as $i) {
        $content_id = $content_arr[$i]->getVar('content_id');
        $content['id'] = $content_id;
        $content['title'] = $content_arr[$i]->getVar('content_title');
        $content['shorttext'] = $content_arr[$i]->getVar('content_shorttext');
        $content['authorid'] = $content_arr[$i]->getVar('content_author');
        $content['author'] = XoopsUser::getUnameFromId($content_arr[$i]->getVar('content_author'));
        $content['date'] = XoopsLocale::formatTimestamp($content_arr[$i]->getVar('content_create'), $helper->getConfig('page_dateformat'));
        $content['time'] = XoopsLocale::formatTimestamp($content_arr[$i]->getVar('content_create'), $helper->getConfig('page_timeformat'));
        $xoops->tpl()->appendByRef('content', $content);
        $keywords[] = $content_arr[$i]->getVar('content_title');
        unset($content);
    }
    // Display Page Navigation
    if ($content_count > $nb_limit) {
        $nav = new XoopsPageNav($content_count, $nb_limit, $start, 'start');
        $xoops->tpl()->assign('nav_menu', $nav->renderNav(4));
    }
} else {
    $xoops->tpl()->assign('error_message', PageLocale::E_NO_CONTENT);
}
// Metas
//description
$xoTheme->addMeta('meta', 'description', strip_tags($helper->getModule()->name()) . ', ' . implode(',', $keywords));
开发者ID:RanLee,项目名称:XoopsCore,代码行数:31,代码来源:index.php

示例6: datesub

 /**
  * @param string $dateFormat
  * @param string $format
  *
  * @return string
  */
 public function datesub($dateFormat = '', $format = 'S')
 {
     if (empty($dateformat)) {
         $dateFormat = $this->publisher->getConfig('format_date');
     }
     return XoopsLocale::formatTimestamp($this->getVar('datesub', $format), $dateFormat);
 }
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:13,代码来源:item.php

示例7: getimagesize

    $dimension = getimagesize($xoops->path($imgPath));
    $tpl->assign('image_width', $dimension[0]);
    $tpl->assign('image_height', $dimension[1]);
    $items = array();
    if ($xoops->isModule()) {
        /* @var $plugin SystemPluginInterface */
        $plugin = Xoops_Module_Plugin::getPlugin($dirname, 'system');
        $res = $plugin->backend(10);
        if (is_array($res) && count($res) > 0) {
            foreach ($res as $item) {
                $date[] = array('date' => $item['date']);
                $items[] = array('date' => XoopsLocale::formatTimestamp($item['date'], 'rss'), 'title' => XoopsLocale::convert_encoding(htmlspecialchars($item['title'])), 'content' => XoopsLocale::convert_encoding(htmlspecialchars($item['content'])), 'link' => $item['link'], 'guid' => $item['link']);
            }
        }
    } else {
        $plugins = Xoops_Module_Plugin::getPlugins('system');
        /* @var $plugin SystemPluginInterface */
        foreach ($plugins as $plugin) {
            $res = $plugin->backend(10);
            if (is_array($res) && count($res) > 0) {
                foreach ($res as $item) {
                    $date[] = array('date' => $item['date']);
                    $items[] = array('date' => XoopsLocale::formatTimestamp($item['date'], 'rss'), 'title' => XoopsLocale::convert_encoding(htmlspecialchars($item['title'])), 'content' => XoopsLocale::convert_encoding(htmlspecialchars($item['content'])), 'link' => $item['link'], 'guid' => $item['link']);
                }
            }
        }
    }
    array_multisort($date, SORT_DESC, $items);
    $tpl->assign('items', $items);
}
$tpl->display('module:' . $dirname . '/system_rss.tpl');
开发者ID:redmexico,项目名称:XoopsCore,代码行数:31,代码来源:backend.php

示例8: Criteria

$criteria->add(new Criteria('status', 2), 'AND');
$criteria->add(new Criteria('datesub', time(), '<='), 'AND');
$criteria->setSort('datesub');
$criteria->setOrder('DESC');
//Get all articles dates as an array to save memory
$items = $publisher->getItemHandler()->getAll($criteria, array('datesub'), false);
$itemsCount = count($items);
if (!($itemsCount > 0)) {
    $xoops->redirect(\XoopsBaseConfig::get('url'), 2, _MD_PUBLISHER_NO_TOP_PERMISSIONS);
} else {
    $this_year = 0;
    $years = array();
    $months = array();
    $i = 0;
    foreach ($items as $item) {
        $time = XoopsLocale::formatTimestamp($item['datesub'], 'mysql', $useroffset);
        if (preg_match("/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})/", $time, $datetime)) {
            $this_year = (int) $datetime[1];
            $this_month = (int) $datetime[2];
            if (empty($lastyear)) {
                $lastyear = $this_year;
            }
            if ($lastmonth == 0) {
                $lastmonth = $this_month;
                $months[$lastmonth]['string'] = $months_arr[$lastmonth];
                $months[$lastmonth]['number'] = $lastmonth;
            }
            if ($lastyear != $this_year) {
                $years[$i]['number'] = $lastyear;
                $years[$i]['months'] = $months;
                $months = array();
开发者ID:redmexico,项目名称:XoopsCore,代码行数:31,代码来源:archive.php

示例9: datesub

 /**
  * @param string $dateFormat
  * @param string $format
  *
  * @return string
  */
 public function datesub($dateFormat = 's', $format = "S")
 {
     return XoopsLocale::formatTimestamp($this->getVar('datesub', $format), $dateFormat);
 }
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:10,代码来源:file.php

示例10: init

 /**
  * init - called by parent::_construct
  *
  * @return void
  */
 protected function init()
 {
     $this->setTemplate('module:xmf/xmf_feed.tpl');
     //$this->disableLogger();
     global $xoopsConfig;
     $this->_title = $xoopsConfig['sitename'];
     $this->_url = \XoopsBaseConfig::get('url');
     $this->_description = $xoopsConfig['slogan'];
     $this->_language = \XoopsLocale::getLangCode();
     $this->_charset = \XoopsLocale::getCharset();
     $this->_pubdate = \XoopsLocale::formatTimestamp(time(), 'short');
     $this->_lastbuild = \XoopsLocale::formatTimestamp(time(), 'D, d M Y H:i:s');
     $this->_webmaster = $xoopsConfig['adminmail'];
     $this->_editor = $xoopsConfig['adminmail'];
     $this->_generator = \Xoops::VERSION;
     $this->_copyright = 'Copyright ' . \XoopsLocale::formatTimestamp(time(), 'Y') . ' ' . $xoopsConfig['sitename'];
     $this->_image_title = $this->_title;
     $this->_image_url = \XoopsBaseConfig::get('url') . '/images/logo.gif';
     $this->_image_link = $this->_url;
 }
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:25,代码来源:Feed.php

示例11: unset

            }
            unset($pm);
        }
        $xoops->redirect("viewpmsg.php", 1, XoopsLocale::S_YOUR_MESSAGES_DELETED);
    }
    $xoops->header('module:system/system_viewpmsg.tpl');
    $criteria = new Criteria('to_userid', $xoops->user->getVar('uid'));
    $criteria->setSort('msg_time');
    $criteria->setOrder('DESC');
    $pm_arr = $pm_handler->getObjects($criteria);
    $total_messages = count($pm_arr);
    $xoops->tpl()->assign('display', true);
    $xoops->tpl()->assign('anonymous', $xoops->getConfig('anonymous'));
    $xoops->tpl()->assign('uid', $xoops->user->getVar("uid"));
    $xoops->tpl()->assign('total_messages', $total_messages);
    $msg_no = 0;
    foreach (array_keys($pm_arr) as $i) {
        $messages['msg_id'] = $pm_arr[$i]->getVar("msg_id");
        $messages['read_msg'] = $pm_arr[$i]->getVar("read_msg");
        $messages['msg_image'] = $pm_arr[$i]->getVar("msg_image");
        $messages['posteruid'] = $pm_arr[$i]->getVar('from_userid');
        $messages['postername'] = XoopsUser::getUnameFromId($pm_arr[$i]->getVar('from_userid'));
        $messages['subject'] = $pm_arr[$i]->getVar("subject");
        $messages['msg_time'] = XoopsLocale::formatTimestamp($pm_arr[$i]->getVar('msg_time'));
        $messages['msg_no'] = $msg_no;
        $xoops->tpl()->append('messages', $messages);
        ++$msg_no;
    }
    $xoops->tpl()->assign('token', $xoops->security()->getTokenHTML());
    $xoops->footer();
}
开发者ID:redmexico,项目名称:XoopsCore,代码行数:31,代码来源:viewpmsg.php

示例12: getPosterArray

 /**
  * Get an array with info about the poster
  *
  * @param int $poster_id
  *
  * @return array
  * @access private
  */
 private function getPosterArray($poster_id)
 {
     $xoops = Xoops::getInstance();
     $poster['id'] = (int) $poster_id;
     if ($poster['id'] > 0) {
         $member_handler = $xoops->getHandlerMember();
         $user = $member_handler->getUser($poster['id']);
         if (is_object($user)) {
             $poster['uname'] = XoopsUserUtility::getUnameFromId($poster['id'], false, true);
             $poster_rank = $user->rank();
             $poster['rank_image'] = $poster_rank['image'];
             $poster['rank_title'] = $poster_rank['title'];
             $response = $xoops->service("Avatar")->getAvatarUrl($user);
             $avatar = $response->getValue();
             $avatar = empty($avatar) ? $xoops->url('uploads/blank.gif') : $avatar;
             $poster['avatar'] = $avatar;
             $poster['regdate'] = XoopsLocale::formatTimestamp($user->getVar('user_regdate'), 's');
             $poster['from'] = $user->getVar('user_from');
             $poster['postnum'] = $user->getVar('posts');
             $poster['status'] = $user->isOnline() ? _MD_COMMENTS_ONLINE : '';
             return $poster;
         } else {
             $poster['id'] = 0;
         }
     }
     $poster['uname'] = XoopsUserUtility::getUnameFromId($poster['id'], false, true);
     $poster['rank_title'] = '';
     $poster['avatar'] = $xoops->url('uploads/blank.gif');
     $poster['regdate'] = '';
     $poster['from'] = '';
     $poster['postnum'] = 0;
     $poster['status'] = '';
     return $poster;
 }
开发者ID:dazzlesoftware,项目名称:XoopsCore,代码行数:42,代码来源:commentrenderer.php

示例13: htmlspecialchars

                    $poster = $member_handler->getUser($comments_arr[$i]->getVar('uid'));
                    if (is_object($poster)) {
                        $comments_poster_uname = '<a href="' . \XoopsBaseConfig::get('url') . '/userinfo.php?uid=' . $comments_arr[$i]->getVar('uid') . '">' . $poster->getVar('uname') . '</a>';
                    }
                }
                $comments_icon = $comments_arr[$i]->getVar('icon') == '' ? '/images/icons/no_posticon.gif' : '/images/subject/' . htmlspecialchars($comments_arr[$i]->getVar('icon'), ENT_QUOTES);
                $comments_icon = '<img src="' . \XoopsBaseConfig::get('url') . $comments_icon . '" alt="" />';
                $comments['comments_id'] = $id;
                $comments['comments_poster'] = $comments_poster_uname;
                $comments['comments_icon'] = $comments_icon;
                $comments['comments_title'] = '<a href="main.php?op=comments_jump&amp;item_id=' . $comments_arr[$i]->getVar("id") . '">' . $comments_arr[$i]->getVar("title") . '</a>';
                $comments['comments_ip'] = $comments_arr[$i]->getVar('ip');
                $comments['comments_date'] = XoopsLocale::formatTimeStamp($comments_arr[$i]->getVar('created'));
                $comments['comments_text'] = $myts->undoHtmlSpecialChars($comments_arr[$i]->getVar('text'));
                $comments['comments_status'] = @$status_array2[$comments_arr[$i]->getVar('status')];
                $comments['comments_date_created'] = XoopsLocale::formatTimestamp($comments_arr[$i]->getVar('created'), 'm');
                $comments['comments_modid'] = @$module_array[$comments_arr[$i]->getVar('modid')];
                //$comments['comments_view_edit_delete'] = '<img class="cursorpointer" onclick="display_dialog('.$id.', true, true, \'slide\', \'slide\', 300, 500);" src="images/icons/view.png" alt="'._AM_COMMENTS_VIEW.'" title="'._AM_COMMENTS_VIEW.'" /><a href="admin/comments/comment_edit.php?id='.$id.'"><img src="./images/icons/edit.png" border="0" alt="'._EDIT.'" title="'._EDIT.'"></a><a href="admin/comments/comment_delete.php?id='.$id.'"><img src="./images/icons/delete.png" border="0" alt="'._DELETE.'" title="'._DELETE.'"></a>';
                $xoops->tpl()->appendByRef('comments', $comments);
                $xoops->tpl()->appendByRef('comments_popup', $comments);
                unset($comments);
            }
            if ($comments_count > $comments_limit) {
                $nav = new XoopsPageNav($comments_count, $comments_limit, $comments_start, 'comments_start', 'comments_module=' . $comments_module . '&amp;comments_status=' . $comments_status);
                $xoops->tpl()->assign('nav', $nav->renderNav());
            }
        }
        break;
}
// Call Footer
$xoops->footer();
开发者ID:redmexico,项目名称:XoopsCore,代码行数:31,代码来源:main.php

示例14: foreach

 $numrows = $listingHandler->getCount();
 $listing_arr = $listingHandler->getall($criteria);
 foreach (array_keys($listing_arr) as $i) {
     $lid = $listing_arr[$i]->getVar('lid');
     $cid = $listing_arr[$i]->getVar('cid');
     $name = $listing_arr[$i]->getVar('name');
     $mname = $listing_arr[$i]->getVar('mname');
     $lname = $listing_arr[$i]->getVar('lname');
     $school = $listing_arr[$i]->getVar('school');
     $year = $listing_arr[$i]->getVar('year');
     $studies = $listing_arr[$i]->getVar('studies');
     $activities = $listing_arr[$i]->getVar('activities');
     $extrainfo = $listing_arr[$i]->getVar('extrainfo');
     $occ = $listing_arr[$i]->getVar('occ');
     $date = $listing_arr[$i]->getVar('date');
     $date = XoopsLocale::formatTimestamp($date, 's');
     $email = $listing_arr[$i]->getVar('email');
     $submitter = $listing_arr[$i]->getVar('submitter');
     $usid = $listing_arr[$i]->getVar('usid');
     $town = $listing_arr[$i]->getVar('town');
     $valid = $listing_arr[$i]->getVar('valid');
     $photo = $listing_arr[$i]->getVar('photo');
     $photo2 = $listing_arr[$i]->getVar('photo2');
     $view = $listing_arr[$i]->getVar('view');
     $recordexist = false;
     if ($lid != 0) {
         $recordexist = true;
         $listingHandler->updateCounter($lid);
     }
     $xoops->tpl()->assign('add_from', AlumniLocale::ALUMNI_LISTINGS . ' ' . $xoopsConfig['sitename']);
     $xoops->tpl()->assign('add_from_title', AlumniLocale::ALUMNI_LISTINGS);
开发者ID:jlm69,项目名称:alumni-26x,代码行数:31,代码来源:listing.php

示例15: b_comments_show

/**
 * @copyright       XOOPS Project (http://xoops.org)
 * @license         GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @package         Comments
 * @author          trabis <lusopoemas@gmail.com>
 * @author          Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/
 * @version         $Id$
 */
function b_comments_show($options)
{
    $xoops = Xoops::getInstance();
    $helper = $xoops->getModuleHelper('comments');
    $block = array();
    $available_modules = \Xoops\Module\Plugin::getPlugins('comments');
    if (empty($available_modules)) {
        return $block;
    }
    $comment_handler = $helper->getHandlerComment();
    $criteria = new CriteriaCompo(new Criteria('status', Comments::STATUS_ACTIVE));
    $criteria->setLimit((int) $options[0]);
    $criteria->setSort('created');
    $criteria->setOrder('DESC');
    // Check modules permissions
    $moduleperm_handler = $xoops->getHandlerGroupPermission();
    $gperm_groupid = $xoops->getUserGroups();
    $criteria1 = new CriteriaCompo(new Criteria('gperm_name', 'module_read', '='));
    $criteria1->add(new Criteria('gperm_groupid', '(' . implode(',', $gperm_groupid) . ')', 'IN'));
    $perms = $moduleperm_handler->getObjects($criteria1, true);
    $modIds = array();
    foreach ($perms as $item) {
        $modIds[] = $item->getVar('gperm_itemid');
    }
    if (count($modIds) > 0) {
        $modIds = array_unique($modIds);
        $criteria->add(new Criteria('modid', '(' . implode(',', $modIds) . ')', 'IN'));
    } else {
        return $block;
    }
    $comments = $comment_handler->getObjects($criteria, true);
    $member_handler = $xoops->getHandlerMember();
    $module_handler = $xoops->getHandlerModule();
    $modules = $module_handler->getObjectsArray(new Criteria('dirname', "('" . implode("','", array_keys($available_modules)) . "')", 'IN'), true);
    $comment_config = array();
    foreach (array_keys($comments) as $i) {
        $mid = $comments[$i]->getVar('modid');
        $com['module'] = '<a href="' . \XoopsBaseConfig::get('url') . '/modules/' . $modules[$mid]->getVar('dirname') . '/">' . $modules[$mid]->getVar('name') . '</a>';
        if (!isset($comment_config[$mid])) {
            $comment_config[$mid] = \Xoops\Module\Plugin::getPlugin($modules[$mid]->getVar('dirname'), 'comments');
        }
        $com['id'] = $i;
        $com['title'] = '<a href="' . \XoopsBaseConfig::get('url') . '/modules/' . $modules[$mid]->getVar('dirname') . '/' . $comment_config[$mid]->pageName() . '?' . $comment_config[$mid]->itemName() . '=' . $comments[$i]->getVar('itemid') . '&amp;com_id=' . $i . '&amp;com_rootid=' . $comments[$i]->getVar('rootid') . '&amp;' . htmlspecialchars($comments[$i]->getVar('exparams')) . '#comment' . $i . '">' . $comments[$i]->getVar('title') . '</a>';
        $com['icon'] = htmlspecialchars($comments[$i]->getVar('icon'), ENT_QUOTES);
        $com['icon'] = $com['icon'] != '' ? $com['icon'] : 'icon1.gif';
        $com['time'] = XoopsLocale::formatTimestamp($comments[$i]->getVar('created'), 'm');
        if ($comments[$i]->getVar('uid') > 0) {
            $poster = $member_handler->getUser($comments[$i]->getVar('uid'));
            if (is_object($poster)) {
                $com['poster'] = '<a href="' . \XoopsBaseConfig::get('url') . '/userinfo.php?uid=' . $comments[$i]->getVar('uid') . '">' . $poster->getVar('uname') . '</a>';
            } else {
                $com['poster'] = $xoops->getConfig('anonymous');
            }
        } else {
            $com['poster'] = $xoops->getConfig('anonymous');
        }
        $block['comments'][] = $com;
        unset($com);
    }
    return $block;
}
开发者ID:dazzlesoftware,项目名称:XoopsCore,代码行数:69,代码来源:comments_blocks.php


注:本文中的XoopsLocale::formatTimestamp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。