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


PHP KunenaAttachmentHelper::get方法代码示例

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


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

示例1: 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

示例2: getInstance

 /**
  * @param mixed $identifier
  * @param bool $reload
  *
  * @return KunenaAttachment
  *
  * @since  K4.0
  */
 public static function getInstance($identifier = null, $reload = false)
 {
     return KunenaAttachmentHelper::get($identifier, $reload);
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:12,代码来源:attachment.php

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: removeattachments

 /**
  * Remove files with AJAX.
  *
  * @throws RuntimeException
  *
  * @return string
  */
 public function removeattachments()
 {
     // 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);
     }
     $attach_id = $this->input->getInt('file_id', 0);
     $success = array();
     $instance = KunenaAttachmentHelper::get($attach_id);
     $success['result'] = $instance->delete();
     unset($instance);
     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($success);
     jexit();
 }
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:32,代码来源:topic.php


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