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


PHP KunenaAttachmentHelper::getExtensions方法代码示例

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


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

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

示例2: before

 /**
  * Prepare topic edit form.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $this->catid = $this->input->getInt('catid');
     $mesid = $this->input->getInt('mesid');
     $saved = $this->app->getUserState('com_kunena.postfields');
     $this->me = KunenaUserHelper::getMyself();
     $this->template = KunenaFactory::getTemplate();
     $this->message = KunenaForumMessageHelper::get($mesid);
     $this->message->tryAuthorise('edit');
     $this->topic = $this->message->getTopic();
     $this->category = $this->topic->getCategory();
     $this->template->setCategoryIconset($this->topic->getCategory()->iconset);
     if ($this->config->topicicons && $this->topic->isAuthorised('edit')) {
         $this->topicIcons = $this->template->getTopicIcons(false, $saved ? $saved['icon_id'] : $this->topic->icon_id);
     }
     // Run onKunenaPrepare event.
     $params = new JRegistry();
     $params->set('ksource', 'kunena');
     $params->set('kunena_view', 'topic');
     $params->set('kunena_layout', 'reply');
     $dispatcher = JEventDispatcher::getInstance();
     JPluginHelper::importPlugin('kunena');
     $dispatcher->trigger('onKunenaPrepare', array('kunena.topic', &$this->topic, &$params, 0));
     $this->action = 'edit';
     // Get attachments.
     $this->attachments = $this->message->getAttachments();
     // Get poll.
     if ($this->message->parent == 0 && $this->topic->isAuthorised(!$this->topic->poll_id ? 'poll.create' : 'poll.edit')) {
         $this->poll = $this->topic->getPoll();
     }
     $this->allowedExtensions = KunenaAttachmentHelper::getExtensions($this->category);
     if ($saved) {
         // Update message contents.
         $this->message->edit($saved);
     }
     $this->post_anonymous = isset($saved['anonymous']) ? $saved['anonymous'] : !empty($this->category->post_anonymous);
     $this->subscriptionschecked = isset($saved['subscribe']) ? $saved['subscribe'] : $this->config->subscriptionschecked == 1;
     $this->modified_reason = isset($saved['modified_reason']) ? $saved['modified_reason'] : '';
     $this->app->setUserState('com_kunena.postfields', null);
     $this->canSubscribe = $this->canSubscribe();
     $this->headerText = JText::_('COM_KUNENA_POST_EDIT') . ' ' . $this->topic->subject;
 }
开发者ID:Ruud68,项目名称:Kunena-Forum,代码行数:50,代码来源:display.php

示例3: upload

 /**
  * @param string $key
  * @param null|int   $catid
  *
  * @return bool
  *
  * @since  K4.0
  */
 function upload($key = 'kattachment', $catid = null)
 {
     jimport('joomla.filesystem.folder');
     $config = KunenaFactory::getConfig();
     $input = JFactory::getApplication()->input;
     $fileInput = $input->files->get($key, null, 'raw');
     $upload = KunenaUpload::getInstance(KunenaAttachmentHelper::getExtensions($catid, $this->userid));
     $uploadBasePath = JPATH_ROOT . '/media/kunena/attachments/' . $this->userid . '/';
     if (!JFolder::exists($uploadBasePath)) {
         mkdir(JPATH_ROOT . '/media/kunena/attachments/' . $this->userid . '/');
     }
     $upload->splitFilename($fileInput['name']);
     $fileInput['name'] = preg_replace('/[[:space:]]/', '', $fileInput['name']);
     $fileNameWithoutExt = JFile::stripExt($fileInput['name']);
     $fileExt = JFile::getExt($fileInput['name']);
     $fileNameWithExt = $fileInput['name'];
     if (file_exists($uploadBasePath . $fileInput['name'])) {
         for ($i = 2; file_exists($uploadBasePath . $fileNameWithoutExt . '.' . $fileExt); $i++) {
             $fileNameWithoutExt = $fileNameWithoutExt . "-{$i}";
             $fileNameWithExt = $fileNameWithoutExt . '.' . $fileExt;
         }
     }
     $fileInput['name'] = $fileNameWithExt;
     $file = $upload->upload($fileInput, $uploadBasePath . $fileNameWithoutExt);
     if ($file->success) {
         if (extension_loaded('fileinfo')) {
             $finfo = new finfo(FILEINFO_MIME);
             $type = $finfo->file($uploadBasePath . $fileNameWithExt);
         } else {
             $info = getimagesize($uploadBasePath . $fileNameWithExt);
             $type = $info['mime'];
         }
         if (stripos($type, 'image/') !== false) {
             $imageInfo = KunenaImage::getImageFileProperties($uploadBasePath . $fileNameWithExt);
             if (number_format($file->size / 1024, 2) > $config->imagesize || $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);
                 }
                 $options = array('quality' => $quality);
                 try {
                     $image = new KunenaImage($uploadBasePath . $fileNameWithExt);
                     $image = $image->resize($config->imagewidth, $config->imagewidth, false);
                     $image->toFile($uploadBasePath . $fileNameWithExt, $imageInfo->type, $options);
                     unset($image);
                 } catch (Exception $e) {
                     // TODO: better error message.
                     echo $e->getMessage();
                     return false;
                 }
             }
             $this->filetype = $imageInfo->mime;
         }
         $this->protected = (bool) $config->attachment_protection;
         $this->hash = md5_file($uploadBasePath . $fileNameWithExt);
         $this->size = $file->size;
         $this->folder = 'media/kunena/attachments/' . $this->userid;
         $this->filename = $fileInput['name'];
         $this->filename_real = $uploadBasePath . $fileNameWithExt;
         $this->caption = '';
         return true;
     }
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:75,代码来源:attachment.php

示例4: displayEdit

 protected function displayEdit($tpl = null)
 {
     $this->catid = $this->state->get('item.catid');
     $mesid = $this->state->get('item.mesid');
     $saved = $this->app->getUserState('com_kunena.postfields');
     $this->message = KunenaForumMessageHelper::get($mesid);
     if (!$this->message->authorise('edit')) {
         $this->app->enqueueMessage($this->message->getError(), 'notice');
         return false;
     }
     $this->topic = $this->message->getTopic();
     $this->category = $this->topic->getCategory();
     if ($this->config->topicicons && $this->topic->authorise('edit', null, false)) {
         $this->topicIcons = $this->ktemplate->getTopicIcons(false, $saved ? $saved['icon_id'] : $this->topic->icon_id);
     }
     // Run events
     $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));
     $this->_prepareDocument('edit');
     $this->action = 'edit';
     // Get attachments
     $this->attachments = $this->message->getAttachments();
     // Get poll
     if ($this->message->parent == 0 && (!$this->topic->poll_id && $this->topic->authorise('poll.create', null, false) || $this->topic->poll_id && $this->topic->authorise('poll.edit', null, false))) {
         $this->poll = $this->topic->getPoll();
     }
     $this->allowedExtensions = KunenaAttachmentHelper::getExtensions($this->category);
     if ($saved) {
         // Update message contents
         $this->message->edit($saved);
     }
     $this->post_anonymous = isset($saved['anonymous']) ? $saved['anonymous'] : !empty($this->category->post_anonymous);
     $this->subscriptionschecked = isset($saved['subscribe']) ? $saved['subscribe'] : $this->config->subscriptionschecked == 1;
     $this->modified_reason = isset($saved['modified_reason']) ? $saved['modified_reason'] : '';
     $this->app->setUserState('com_kunena.postfields', null);
     $this->render('Topic/Edit', $tpl);
 }
开发者ID:Jougito,项目名称:DynWeb,代码行数:42,代码来源:view.html.php

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

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


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