本文整理汇总了PHP中KunenaAttachmentHelper类的典型用法代码示例。如果您正苦于以下问题:PHP KunenaAttachmentHelper类的具体用法?PHP KunenaAttachmentHelper怎么用?PHP KunenaAttachmentHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KunenaAttachmentHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: before
/**
* Prepare user attachments list.
*
* @return void
*/
protected function before()
{
parent::before();
$userid = $this->input->getInt('userid');
$params = array('file' => '1', 'image' => '1', 'orderby' => 'desc', 'limit' => '30');
$this->template = KunenaFactory::getTemplate();
$this->me = KunenaUserHelper::getMyself();
$this->profile = KunenaUserHelper::get($userid);
$this->attachments = KunenaAttachmentHelper::getByUserid($this->profile, $params);
// Pre-load messages.
$messageIds = array();
foreach ($this->attachments as $attachment)
{
$messageIds[] = (int) $attachment->mesid;
}
$messages = KunenaForumMessageHelper::getMessages($messageIds, 'none');
// Pre-load topics.
$topicIds = array();
foreach ($messages as $message)
{
$topicIds[] = $message->thread;
}
KunenaForumTopicHelper::getTopics($topicIds, 'none');
$this->headerText = JText::_('COM_KUNENA_MANAGE_ATTACHMENTS');
}
开发者ID:BillVGN,项目名称:PortalPRP,代码行数:39,代码来源:display.php
示例2: 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;
}
开发者ID:Ruud68,项目名称:Kunena-Forum,代码行数:32,代码来源:display.php
示例3: delete
/**
* @throws Exception
*/
public function delete()
{
if (!JSession::checkToken('post')) {
$this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
$this->setRedirect(KunenaRoute::_($this->baseurl, false));
return;
}
$cid = JFactory::getApplication()->input->get('cid', array(), 'post', 'array');
// Array of integers
Joomla\Utilities\ArrayHelper::toInteger($cid);
if (!$cid) {
$this->app->enqueueMessage(JText::_('COM_KUNENA_NO_ATTACHMENTS_SELECTED'), 'error');
$this->setRedirect(KunenaRoute::_($this->baseurl, false));
return;
}
foreach ($cid as $id) {
$attachment = KunenaAttachmentHelper::get($id);
$message = $attachment->getMessage();
$attachments = array($attachment->id, 1);
$attach = array();
$removeList = array_keys(array_diff_key($attachments, $attach));
Joomla\Utilities\ArrayHelper::toInteger($removeList);
$message->removeAttachments($removeList);
$message->save();
$topic = $message->getTopic();
$attachment->delete();
if ($topic->attachments > 0) {
$topic->attachments = $topic->attachments - 1;
$topic->save(false);
}
}
$this->app->enqueueMessage(JText::_('COM_KUNENA_ATTACHMENTS_DELETED_SUCCESSFULLY'));
$this->setRedirect(KunenaRoute::_($this->baseurl, false));
}
开发者ID:Ruud68,项目名称:Kunena-Forum,代码行数:37,代码来源:attachments.php
示例4: before
/**
* Prepare topic reply form.
*
* @return void
*
* @throws RuntimeException
* @throws KunenaExceptionAuthorise
*/
protected function before()
{
parent::before();
$catid = $this->input->getInt('catid');
$id = $this->input->getInt('id');
$mesid = $this->input->getInt('mesid');
$quote = $this->input->getBool('quote', false);
$saved = $this->app->getUserState('com_kunena.postfields');
$this->me = KunenaUserHelper::getMyself();
$this->template = KunenaFactory::getTemplate();
if (!$mesid) {
$this->topic = KunenaForumTopicHelper::get($id);
$parent = KunenaForumMessageHelper::get($this->topic->first_post_id);
} else {
$parent = KunenaForumMessageHelper::get($mesid);
$this->topic = $parent->getTopic();
}
$this->category = $this->topic->getCategory();
if ($parent->isAuthorised('reply') && $this->me->canDoCaptcha()) {
if (JPluginHelper::isEnabled('captcha')) {
$plugin = JPluginHelper::getPlugin('captcha');
$params = new JRegistry($plugin[0]->params);
$captcha_pubkey = $params->get('public_key');
$catcha_privkey = $params->get('private_key');
if (!empty($captcha_pubkey) && !empty($catcha_privkey)) {
JPluginHelper::importPlugin('captcha');
$dispatcher = JDispatcher::getInstance();
$result = $dispatcher->trigger('onInit', 'dynamic_recaptcha_1');
$this->captchaEnabled = $result[0];
}
} else {
$this->captchaEnabled = false;
}
}
$parent->tryAuthorise('reply');
// Run event.
$params = new JRegistry();
$params->set('ksource', 'kunena');
$params->set('kunena_view', 'topic');
$params->set('kunena_layout', 'reply');
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('kunena');
$dispatcher->trigger('onKunenaPrepare', array('kunena.topic', &$this->topic, &$params, 0));
// Can user edit topic icons?
if ($this->config->topicicons && $this->topic->isAuthorised('edit')) {
$this->topicIcons = $this->template->getTopicIcons(false, $saved ? $saved['icon_id'] : $this->topic->icon_id);
}
list($this->topic, $this->message) = $parent->newReply($saved ? $saved : $quote);
$this->action = 'post';
$this->allowedExtensions = KunenaAttachmentHelper::getExtensions($this->category);
$this->post_anonymous = $saved ? $saved['anonymous'] : !empty($this->category->post_anonymous);
$this->subscriptionschecked = $saved ? $saved['subscribe'] : $this->config->subscriptionschecked == 1;
$this->app->setUserState('com_kunena.postfields', null);
$this->canSubscribe = $this->canSubscribe();
$this->headerText = JText::_('COM_KUNENA_BUTTON_MESSAGE_REPLY') . ' ' . $this->topic->subject;
}
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:64,代码来源:display.php
示例5: _getList
protected function _getList($query, $limitstart = 0, $limit = 0)
{
$this->_db->setQuery($query, $limitstart, $limit);
$ids = $this->_db->loadColumn();
$results = KunenaAttachmentHelper::getById($ids);
$userids = array();
$mesids = array();
foreach ($results as $result) {
$userids[$result->userid] = $result->userid;
$mesids[$result->mesid] = $result->mesid;
}
KunenaUserHelper::loadUsers($userids);
KunenaForumMessageHelper::getMessages($mesids);
return $results;
}
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:15,代码来源:attachments.php
示例6: delete
/**
* Method to delete the KunenaForumTopic object from the database.
*
* @param bool $recount
*
* @return bool True on success.
*/
public function delete($recount = true)
{
if (!$this->exists()) {
return true;
}
if (!parent::delete()) {
return false;
}
// Clear authentication cache
$this->_authfcache = $this->_authccache = $this->_authcache = array();
// NOTE: shadow topic doesn't exist, DO NOT DELETE OR CHANGE ANY EXTERNAL INFORMATION
if ($this->moved_id == 0) {
$db = JFactory::getDBO();
// Delete user topics
$queries[] = "DELETE FROM #__kunena_user_topics WHERE topic_id={$db->quote($this->id)}";
// Delete user read
$queries[] = "DELETE FROM #__kunena_user_read WHERE topic_id={$db->quote($this->id)}";
// Delete poll (users)
$queries[] = "DELETE FROM #__kunena_polls_users WHERE pollid={$db->quote($this->poll_id)}";
// Delete poll (options)
$queries[] = "DELETE FROM #__kunena_polls_options WHERE pollid={$db->quote($this->poll_id)}";
// Delete poll
$queries[] = "DELETE FROM #__kunena_polls WHERE id={$db->quote($this->poll_id)}";
// Delete thank yous
$queries[] = "DELETE t FROM #__kunena_thankyou AS t INNER JOIN #__kunena_messages AS m ON m.id=t.postid WHERE m.thread={$db->quote($this->id)}";
// Delete all messages
$queries[] = "DELETE m, t FROM #__kunena_messages AS m INNER JOIN #__kunena_messages_text AS t ON m.id=t.mesid WHERE m.thread={$db->quote($this->id)}";
foreach ($queries as $query) {
$db->setQuery($query);
$db->query();
KunenaError::checkDatabaseError();
}
// FIXME: add recount statistics
if ($recount) {
KunenaUserHelper::recount();
KunenaForumCategoryHelper::recount();
KunenaAttachmentHelper::cleanup();
KunenaForumMessageThankyouHelper::recount();
}
}
return true;
}
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:49,代码来源:topic.php
示例7: upload
/**
* Upload files with AJAX.
*
* @throws RuntimeException
*/
public function upload()
{
// Only support JSON requests.
if ($this->input->getWord('format', 'html') != 'json') {
throw new RuntimeException(JText::_('Bad Request'), 400);
}
$upload = KunenaUpload::getInstance();
// We are converting all exceptions into JSON.
try {
if (!JSession::checkToken('request')) {
throw new RuntimeException(JText::_('Forbidden'), 403);
}
$me = KunenaUserHelper::getMyself();
$catid = $this->input->getInt('catid', 0);
$mesid = $this->input->getInt('mesid', 0);
if ($mesid) {
$message = KunenaForumMessageHelper::get($mesid);
$message->tryAuthorise('attachment.create');
$category = $message->getCategory();
} else {
$category = KunenaForumCategoryHelper::get($catid);
// TODO: Some room for improvements in here... (maybe ask user to pick up category first)
if ($category->id) {
if (stripos($this->input->getString('mime'), 'image/') !== false) {
$category->tryAuthorise('topic.post.attachment.createimage');
} else {
$category->tryAuthorise('topic.post.attachment.createfile');
}
}
}
$caption = $this->input->getString('caption');
$options = array('filename' => $this->input->getString('filename'), 'size' => $this->input->getInt('size'), 'mime' => $this->input->getString('mime'), 'hash' => $this->input->getString('hash'), 'chunkStart' => $this->input->getInt('chunkStart', 0), 'chunkEnd' => $this->input->getInt('chunkEnd', 0));
// Upload!
$upload->addExtensions(KunenaAttachmentHelper::getExtensions($category->id, $me->userid));
$response = (object) $upload->ajaxUpload($options);
if (!empty($response->completed)) {
// We have it all, lets create the attachment.
$uploadFile = $upload->getProtectedFile();
list($basename, $extension) = $upload->splitFilename();
$attachment = new KunenaAttachment();
$attachment->bind(array('mesid' => 0, 'userid' => (int) $me->userid, 'protected' => null, 'hash' => $response->hash, 'size' => $response->size, 'folder' => null, 'filetype' => $response->mime, 'filename' => null, 'filename_real' => $response->filename, 'caption' => $caption));
// Resize image if needed.
if ($attachment->isImage()) {
$imageInfo = KunenaImage::getImageFileProperties($uploadFile);
$config = KunenaConfig::getInstance();
if ($imageInfo->width > $config->imagewidth || $imageInfo->height > $config->imageheight) {
// Calculate quality for both JPG and PNG.
$quality = $config->imagequality;
if ($quality < 1 || $quality > 100) {
$quality = 70;
}
if ($imageInfo->type == IMAGETYPE_PNG) {
$quality = intval(($quality - 1) / 10);
}
$image = new KunenaImage($uploadFile);
$image = $image->resize($config->imagewidth, $config->imageheight, false);
$options = array('quality' => $quality);
$image->toFile($uploadFile, $imageInfo->type, $options);
unset($image);
$attachment->hash = md5_file($uploadFile);
$attachment->size = filesize($uploadFile);
}
}
$attachment->saveFile($uploadFile, $basename, $extension, true);
// Set id and override response variables just in case if attachment was modified.
$response->id = $attachment->id;
$response->hash = $attachment->hash;
$response->size = $attachment->size;
$response->mime = $attachment->filetype;
$response->filename = $attachment->filename_real;
}
} catch (Exception $response) {
$upload->cleanup();
// Use the exception as the response.
}
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 $upload->ajaxResponse($response);
jexit();
}
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:91,代码来源:topic.php
示例8: 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;
}
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:20,代码来源:message.php
示例9: authoriseUpload
/**
* @param KunenaUser $user
*
* @return KunenaExceptionAuthorise|null
*/
protected function authoriseUpload(KunenaUser $user)
{
// Check if attachments are allowed
if (KunenaAttachmentHelper::getExtensions($this, $user) === false) {
return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_LIB_CATEGORY_AUTHORISE_FAILED_UPLOAD_NOT_ALLOWED'), 403);
}
return null;
}
开发者ID:densem-2013,项目名称:exikom,代码行数:13,代码来源:category.php
示例10: DoAttachment
function DoAttachment($bbcode, $action, $name, $default, $params, $content)
{
if ($action == BBCODE_CHECK) {
return true;
}
$attachments = null;
if ($bbcode->parent instanceof KunenaForumMessage) {
$attachments = $bbcode->parent->getAttachments();
} elseif (is_object($bbcode->parent) && isset($bbcode->parent->attachments)) {
$attachments =& $bbcode->parent->attachments;
}
/** @var KunenaAttachment $att */
/** @var KunenaAttachment $attachment */
$attachment = null;
if (!empty($default)) {
$attachment = KunenaAttachmentHelper::get($default);
unset($attachments[$attachment->id]);
} elseif (empty($content)) {
$attachment = array_shift($attachments);
} elseif (!empty($attachments)) {
foreach ($attachments as $att) {
if ($att->getFilename() == $content) {
$attachment = $att;
unset($attachments[$att->id]);
break;
}
}
}
// Display tag in activity streams etc..
if (!isset($attachments) || !empty($bbcode->parent->forceMinimal)) {
if ($attachment->isImage()) {
$hide = KunenaFactory::getConfig()->showimgforguest == 0 && JFactory::getUser()->id == 0;
if (!$hide) {
return "<div class=\"kmsgimage\">{$attachment->getImageLink()}</div>";
}
} else {
$hide = KunenaFactory::getConfig()->showfileforguest == 0 && JFactory::getUser()->id == 0;
if (!$hide) {
return "<div class=\"kmsgattach\"><h4>" . JText::_('COM_KUNENA_FILEATTACH') . "</h4>" . JText::_('COM_KUNENA_FILENAME') . " <a href=\"" . $attachment->getUrl() . "\" target=\"_blank\" rel=\"nofollow\">" . $attachment->filename . "</a><br />" . JText::_('COM_KUNENA_FILESIZE') . ' ' . number_format(intval($attachment->size) / 1024, 0, '', ',') . ' KB' . "</div>";
}
}
}
if (!$attachment && !empty($bbcode->parent->inline_attachments)) {
foreach ($bbcode->parent->inline_attachments as $att) {
if ($att->getFilename() == trim(strip_tags($content))) {
$attachment = $att;
break;
}
}
}
if (!$attachment) {
return $bbcode->HTMLEncode($content);
}
return $this->renderAttachment($attachment, $bbcode);
}
开发者ID:Weley,项目名称:Saviors-web,代码行数:55,代码来源:bbcode.php
示例11: DoAttachment
function DoAttachment($bbcode, $action, $name, $default, $params, $content)
{
if ($action == BBCODE_CHECK) {
return true;
}
$attachments = null;
if ($bbcode->parent instanceof KunenaForumMessage) {
$attachments = $bbcode->parent->getAttachments();
} elseif (is_object($bbcode->parent) && isset($bbcode->parent->attachments)) {
$attachments =& $bbcode->parent->attachments;
}
// Display tag in activity streams etc..
if (!isset($attachments) || !empty($bbcode->parent->forceMinimal)) {
$filename = basename(trim(strip_tags($content)));
return '[' . JText::_('COM_KUNENA_FILEATTACH') . ' ' . basename(!empty($params["name"]) ? $params["name"] : $filename) . ']';
}
/** @var KunenaAttachment $att */
/** @var KunenaAttachment $attachment */
$attachment = null;
if (!empty($default)) {
$attachment = KunenaAttachmentHelper::get($default);
unset($attachments[$attachment->id]);
} elseif (empty($content)) {
$attachment = array_shift($attachments);
} elseif (!empty($attachments)) {
foreach ($attachments as $att) {
if ($att->getFilename() == $content) {
$attachment = $att;
unset($attachments[$att->id]);
break;
}
}
}
// Display tag in activity streams etc..
if (!empty($bbcode->parent->forceMinimal) || !is_object($bbcode->parent) && !isset($bbcode->parent->attachments)) {
$filename = basename(trim(strip_tags($content)));
return $attachment->getThumbnailLink();
}
if (!$attachment && !empty($bbcode->parent->inline_attachments)) {
foreach ($bbcode->parent->inline_attachments as $att) {
if ($att->getFilename() == trim(strip_tags($content))) {
$attachment = $att;
break;
}
}
}
if (!$attachment) {
return $bbcode->HTMLEncode($content);
}
return $this->renderAttachment($attachment, $bbcode);
}
开发者ID:Jougito,项目名称:DynWeb,代码行数:51,代码来源:bbcode.php
示例12: 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;
}
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:47,代码来源:topic.php
示例13: canManageAttachments
/**
* @return bool
*/
function canManageAttachments()
{
if ($this->config->show_imgfiles_manage_profile) {
$params = array('file' => '1', 'image' => '1', 'orderby' => 'desc', 'limit' => '30');
$this->userattachs = KunenaAttachmentHelper::getByUserid($this->profile, $params);
if ($this->userattachs) {
if ($this->me->isModerator() || $this->profile->userid == $this->me->userid) {
return true;
} else {
return false;
}
} else {
return false;
}
}
return false;
}
开发者ID:Ruud68,项目名称:Kunena-Forum,代码行数:20,代码来源:view.html.php
示例14: defined
<?php
/**
* Kunena Component
*
* @package Kunena.Template.Crypsis
* @subpackage BBCode
*
* @copyright (C) 2008 - 2016 Kunena Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link https://www.kunena.org
**/
defined('_JEXEC') or die ();
/** @var KunenaAttachment $attachment */
$attachment = $this->attachment;
$config = KunenaConfig::getInstance();
$attributesLink = $attachment->isImage() && $config->lightbox ? ' class="fancybox-button" rel="fancybox-button"' : '';
?>
<a class="btn btn-small" rel="popover" data-placement="bottom" data-trigger="hover" target="_blank" data-content="Filesize: <?php echo number_format($attachment->size / 1024, 0, '', ',') . JText::_('COM_KUNENA_USER_ATTACHMENT_FILE_WEIGHT'); ?>
" data-original-title="<?php echo $attachment->getShortName(); ?>" href="<?php echo $attachment->getUrl(); ?>" title="<?php echo KunenaAttachmentHelper::shortenFileName($attachment->getFilename(), 0, 26); ?>">
<i class="icon icon-info"></i>
</a>
开发者ID:BillVGN,项目名称:PortalPRP,代码行数:25,代码来源:textlink.php
示例15: defined
<?php
/**
* Kunena Component
* @package Kunena.Template.Crypsis
* @subpackage BBCode
*
* @copyright (C) 2008 - 2016 Kunena Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link https://www.kunena.org
**/
defined ( '_JEXEC' ) or die ();
/** @var KunenaAttachment $attachment */
$attachment = $this->attachment;
if (!$attachment->isImage()) return;
$config = KunenaConfig::getInstance();
$attributesLink = $config->lightbox ? ' rel="lightbox[imagelink' . $attachment->mesid . ']"' : '';
$attributesImg = ' style="max-height:' . (int) $config->imageheight . 'px;"';
?>
<a href="<?php echo $attachment->getUrl(); ?>" title="<?php echo KunenaAttachmentHelper::shortenFileName($attachment->getFilename(), 0,7); ?>"<?php echo $attributesLink; ?>>
<img src="<?php echo $attachment->getUrl(); ?>"<?php echo $attributesImg; ?> alt="" />
</a>
开发者ID:BillVGN,项目名称:PortalPRP,代码行数:26,代码来源:image.php
示例16:
<?php
if ($url) {
?>
<?php
echo JText::_('COM_KUNENA_FILENAME');
?>
<a href="<?php
echo $url;
?>
" title="<?php
echo $this->escape($filename);
?>
">
<?php
echo $this->escape(KunenaAttachmentHelper::shortenFilename($filename));
?>
</a>
<br />
<?php
echo JText::_('COM_KUNENA_FILESIZE') . number_format($size / 1024, 0, '', ',') . ' ' . JText::_('COM_KUNENA_USER_ATTACHMENT_FILE_WEIGHT');
?>
<?php
}
?>
</div>
开发者ID:Ruud68,项目名称:Kunena-Forum,代码行数:29,代码来源:default.php
示例17: 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');
}
开发者ID:Jougito,项目名称:DynWeb,代码行数:24,代码来源:view.html.php
示例18: display
/**
* Display attachment.
*
* @return void
*
* @throws RuntimeException
* @throws KunenaExceptionAuthorise
*/
public function display()
{
KunenaFactory::loadLanguage('com_kunena');
$format = $this->input->getWord('format', 'html');
$id = $this->input->getInt('id', 0);
$thumb = $this->input->getBool('thumb', false);
$download = $this->input->getBool('download', false);
// Run before executing action.
$this->before();
if ($format != 'raw' || !$id) {
throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 404);
} elseif ($this->config->board_offline && !$this->me->isAdmin()) {
// Forum is offline.
throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_FORUM_IS_OFFLINE'), 503);
} elseif ($this->config->regonly && !$this->me->exists()) {
// Forum is for registered users only.
throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_LOGIN_NOTIFICATION'), 403);
}
$attachment = KunenaAttachmentHelper::get($id);
$attachment->tryAuthorise();
$path = $attachment->getPath($thumb);
if ($thumb && !$path) {
$path = $attachment->getPath(false);
}
if (!$path) {
// File doesn't exist.
throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 404);
}
if (headers_sent()) {
throw new KunenaExceptionAuthorise('HTTP headers were already sent. Sending attachment failed.', 500);
}
// Close all output buffers, just in case.
while (@ob_end_clean()) {
}
// Handle 304 Not Modified
if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
$etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']);
if ($etag == $attachment->hash) {
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($path)) . ' GMT', true, 304);
// Give fast response.
flush();
$this->app->close();
}
}
// Set file headers.
header('ETag: ' . $attachment->hash);
header('Pragma: public');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($path)) . ' GMT');
if (!$download && $attachment->isImage()) {
// By default display images inline.
$guest = new KunenaUser();
// If guests can access the image, we allow it to be cached for an hour.
if ($attachment->isAuthorised('read', $guest)) {
$maxage = 60 * 60;
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $maxage) . ' GMT');
header('Cache-Control: maxage=' . $maxage);
} else {
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
}
header('Content-type: ' . $attachment->filetype);
header('Content-Disposition: inline; filename="' . $attachment->getFilename(false) . '"');
} else {
// Otherwise force file download.
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header('Content-Type: application/octet-stream');
header('Content-Type: application/download');
header('Content-Disposition: attachment; filename="' . $attachment->getFilename(false) . '"');
}
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($path));
flush();
// Output the file contents.
@readfile($path);
flush();
$this->app->close();
}
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:88,代码来源:display.php
示例19: defined
*
* @package Kunena.Template.Crypsis
* @subpackage BBCode
*
* @copyright (C) 2008 - 2015 Kunena Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link http://www.kunena.org
**/
defined('_JEXEC') or die;
/** @var KunenaAttachment $attachment */
$attachment = $this->attachment;
$config = KunenaConfig::getInstance();
$attributesLink = $attachment->isImage() && $config->lightbox ? ' class="fancybox-button" rel="fancybox-button"' : '';
?>
<a class="btn btn-small" rel="popover" data-placement="bottom" data-trigger="hover" data-content="Filesize: <?php
echo number_format($attachment->size / 1024, 0, '', ',') . JText::_('COM_KUNENA_USER_ATTACHMENT_FILE_WEIGHT');
?>
" data-original-title="<?php
echo $attachment->getShortName();
?>
" href="<?php
echo $attachment->getUrl();
?>
" title="<?php
echo KunenaAttachmentHelper::shortenFileName($attachment->getFilename(), 0, 26);
?>
">
<i class="icon icon-info"></i>
</a>
开发者ID:r-ahmadi,项目名称:Kunena-Forum,代码行数:30,代码来源:textlink.php
示例20: delfile
public function delfile()
{
if (!JSession::checkToken('post')) {
$this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
$this->setRedirectBack();
return;
}
$cid = JRequest::getVar('cid', array(), 'post', 'array');
// Array of integers
JArrayHelper::toInteger($cid);
if (!empty($cid)) {
$number = 0;
foreach ($cid as $id) {
$attachment = KunenaAttachmentHelper::get($id);
$message = $attachment->getMessage();
$attachments = array($attachment->id, 1);
$attach = array();
$removeList = array_keys(array_diff_key($attachments, $attach));
JArrayHelper::toInteger($removeList);
$message->removeAttachments($removeList);
$topic = $message->getTopic();
if ($attachment->isAuthorised('delete') && $attachment->delete()) {
$message->save();
if ($topic->attachments > 0) {
$topic->attachments = $topic->attachments - 1;
$topic->save(false);
}
$number++;
}
}
if ($number > 0) {
$this->app->enqueueMessage(JText::sprintf('COM_KUNENA_ATTACHMENTS_DELETE_SUCCESSFULLY', $number));
$this->setRedirectBack();
return;
} else {
$this->app->enqueueMessage(JText::_('COM_KUNENA_ATTACHMENTS_DELETE_FAILED'));
$this->setRedirectBack();
return;
}
}
$this->app->enqueueMessage(JText::_('COM_KUNENA_ATTACHMENTS_NO_ATTACHMENTS_SELECTED'));
$this->setRedirectBack();
}
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:43,代码来源:user.php
注:本文中的KunenaAttachmentHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论