本文整理汇总了PHP中KunenaAttachmentHelper::getByMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP KunenaAttachmentHelper::getByMessage方法的具体用法?PHP KunenaAttachmentHelper::getByMessage怎么用?PHP KunenaAttachmentHelper::getByMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KunenaAttachmentHelper
的用法示例。
在下文中一共展示了KunenaAttachmentHelper::getByMessage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: before
/**
* Prepare reply history display.
*
* @return void
*/
protected function before()
{
parent::before();
$id = $this->input->getInt('id');
$this->topic = KunenaForumTopicHelper::get($id);
$this->history = KunenaForumMessageHelper::getMessagesByTopic($this->topic, 0, (int) $this->config->historylimit, 'DESC');
$this->replycount = $this->topic->getReplies();
$this->historycount = count($this->history);
KunenaAttachmentHelper::getByMessage($this->history);
$userlist = array();
foreach ($this->history as $message) {
$userlist[(int) $message->userid] = (int) $message->userid;
}
KunenaUserHelper::loadUsers($userlist);
// Run events
$params = new JRegistry();
$params->set('ksource', 'kunena');
$params->set('kunena_view', 'topic');
$params->set('kunena_layout', 'history');
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('kunena');
$dispatcher->trigger('onKunenaPrepare', array('kunena.messages', &$this->history, &$params, 0));
// FIXME: need to improve BBCode class on this...
$this->attachments = KunenaAttachmentHelper::getByMessage($this->history);
$this->inline_attachments = array();
$this->headerText = JText::_('COM_KUNENA_POST_EDIT') . ' ' . $this->topic->subject;
}
示例2: loadattachments
/**
* Get attachments attached to a message with AJAX.
*
* @throws RuntimeException
*
* @return string
*/
public function loadattachments()
{
// Only support JSON requests.
if ($this->input->getWord('format', 'html') != 'json') {
throw new RuntimeException(JText::_('Bad Request'), 400);
}
if (!JSession::checkToken('request')) {
throw new RuntimeException(JText::_('Forbidden'), 403);
}
$mes_id = $this->input->getInt('mes_id', 0);
$attachments = KunenaAttachmentHelper::getByMessage($mes_id);
$list = array();
foreach ($attachments as $attach) {
$object = new stdClass();
$object->id = $attach->id;
$object->size = round($attach->size / '1024', 0);
$object->name = $attach->filename;
$object->folder = $attach->folder;
$object->caption = $attach->caption;
$object->type = $attach->filetype;
$object->path = $attach->getUrl();
$object->image = $attach->isImage();
$list['files'][] = $object;
}
header('Content-type: application/json');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
while (@ob_end_clean()) {
}
echo json_encode($list);
jexit();
}
示例3: displayThreadHistory
function displayThreadHistory()
{
if (!$this->hasThreadHistory()) {
return;
}
$this->history = KunenaForumMessageHelper::getMessagesByTopic($this->topic, 0, (int) $this->config->historylimit, $ordering = 'DESC');
$this->historycount = count($this->history);
$this->replycount = $this->topic->getReplies();
KunenaAttachmentHelper::getByMessage($this->history);
$userlist = array();
foreach ($this->history as $message) {
$userlist[(int) $message->userid] = (int) $message->userid;
}
KunenaUserHelper::loadUsers($userlist);
// Run events
$params = new JRegistry();
$params->set('ksource', 'kunena');
$params->set('kunena_view', 'topic');
$params->set('kunena_layout', 'history');
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('kunena');
$dispatcher->trigger('onKunenaPrepare', array('kunena.messages', &$this->history, &$params, 0));
echo $this->loadTemplateFile('history');
}
示例4: getAttachments
/**
* @param bool|array $ids
* @param string $action
*
* @return KunenaAttachment[]
*/
public function getAttachments($ids = false, $action = 'read')
{
if ($ids === false) {
$attachments = KunenaAttachmentHelper::getByMessage($this->id, $action);
} else {
$attachments = KunenaAttachmentHelper::getById($ids, $action);
foreach ($attachments as $id => $attachment) {
if ($attachment->mesid && $attachment->mesid != $this->id) {
unset($attachments[$id]);
}
}
}
return $attachments;
}
示例5: prepareMessages
/**
* Prepare messages for display.
*
* @param int $mesid Selected message Id.
*
* @return void
*/
protected function prepareMessages($mesid)
{
// Get thank yous for all messages in the page
$thankyous = KunenaForumMessageThankyouHelper::getByMessage($this->messages);
// First collect ids and users.
$threaded = $this->layout == 'indented' || $this->layout == 'threaded';
$userlist = array();
$this->threaded = array();
$location = $this->pagination->limitstart;
foreach ($this->messages as $message) {
$message->replynum = ++$location;
if ($threaded) {
// Threaded ordering
if (isset($this->messages[$message->parent])) {
$this->threaded[$message->parent][] = $message->id;
} else {
$this->threaded[0][] = $message->id;
}
}
$userlist[(int) $message->userid] = (int) $message->userid;
$userlist[(int) $message->modified_by] = (int) $message->modified_by;
$thankyou_list = $thankyous[$message->id]->getList();
$message->thankyou = array();
if (!empty($thankyou_list)) {
$message->thankyou = $thankyou_list;
}
}
if (!isset($this->messages[$mesid]) && !empty($this->messages)) {
$this->message = reset($this->messages);
}
if ($threaded) {
if (!isset($this->messages[$this->topic->first_post_id])) {
$this->messages = $this->getThreadedOrdering(0, array('edge'));
} else {
$this->messages = $this->getThreadedOrdering();
}
}
// Prefetch all users/avatars to avoid user by user queries during template iterations
KunenaUserHelper::loadUsers($userlist);
// Prefetch attachments.
KunenaAttachmentHelper::getByMessage($this->messages);
}
示例6: getMessages
public function getMessages()
{
if ($this->messages === false) {
$layout = $this->getState('layout');
$threaded = $layout == 'indented' || $layout == 'threaded';
$this->messages = KunenaForumMessageHelper::getMessagesByTopic($this->getState('item.id'), $this->getState('list.start'), $this->getState('list.limit'), $this->getState('list.direction'), $this->getState('hold'), $threaded);
// Get thankyous for all messages in the page
$thankyous = KunenaForumMessageThankyouHelper::getByMessage($this->messages);
// First collect ids and users
$userlist = array();
$this->threaded = array();
$location = $this->getState('list.start');
foreach ($this->messages as $message) {
$message->replynum = ++$location;
if ($threaded) {
// Threaded ordering
if (isset($this->messages[$message->parent])) {
$this->threaded[$message->parent][] = $message->id;
} else {
$this->threaded[0][] = $message->id;
}
}
$userlist[intval($message->userid)] = intval($message->userid);
$userlist[intval($message->modified_by)] = intval($message->modified_by);
$thankyou_list = $thankyous[$message->id]->getList();
$message->thankyou = array();
if (!empty($thankyou_list)) {
$message->thankyou = $thankyou_list;
}
}
if (!isset($this->messages[$this->getState('item.mesid')]) && !empty($this->messages)) {
$this->setState('item.mesid', reset($this->messages)->id);
}
if ($threaded) {
if (!isset($this->messages[$this->topic->first_post_id])) {
$this->messages = $this->getThreadedOrdering(0, array('edge'));
} else {
$this->messages = $this->getThreadedOrdering();
}
}
// Prefetch all users/avatars to avoid user by user queries during template iterations
KunenaUserHelper::loadUsers($userlist);
// Get attachments
KunenaAttachmentHelper::getByMessage($this->messages);
}
return $this->messages;
}