當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DiscussHelper::uploadCategoryAvatar方法代碼示例

本文整理匯總了PHP中DiscussHelper::uploadCategoryAvatar方法的典型用法代碼示例。如果您正苦於以下問題:PHP DiscussHelper::uploadCategoryAvatar方法的具體用法?PHP DiscussHelper::uploadCategoryAvatar怎麽用?PHP DiscussHelper::uploadCategoryAvatar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DiscussHelper的用法示例。


在下文中一共展示了DiscussHelper::uploadCategoryAvatar方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: save

 public function save()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     $mainframe = JFactory::getApplication();
     $task = $this->getTask();
     $message = '';
     $type = 'success';
     if (JRequest::getMethod() == 'POST') {
         $post = JRequest::get('post');
         if (empty($post['title'])) {
             DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_CATEGORIES_INVALID_CATEGORY'), DISCUSS_QUEUE_ERROR);
             $url = 'index.php?option=com_easydiscuss&view=categories';
             $mainframe->redirect(JRoute::_($url, false));
             return;
         }
         $category = JTable::getInstance('Category', 'Discuss');
         $user = JFactory::getUser();
         $post['created_by'] = $user->id;
         $catId = JRequest::getVar('catid', '');
         $isNew = empty($catId) ? true : false;
         $alterOrdering = true;
         if (!empty($catId)) {
             $category->load($catId);
             $newParentId = $post['parent_id'];
             if ($category->parent_id != $newParentId) {
                 $alterOrdering = true;
             } else {
                 $alterOrdering = false;
             }
             $post['id'] = $catId;
         }
         $category->bind($post);
         // Description might contain html codes
         $description = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW);
         $category->description = $description;
         // Bind params
         $params = DiscussHelper::getRegistry('');
         $params->set('show_description', $post['show_description']);
         $params->set('maxlength', $post['maxlength']);
         $params->set('maxlength_size', $post['maxlength_size']);
         $params->set('cat_notify_custom', $post['cat_notify_custom']);
         $params->set('cat_email_parser', $post['cat_email_parser']);
         $params->set('cat_email_parser_password', $post['cat_email_parser_password']);
         $params->set('cat_email_parser_switch', $post['cat_email_parser_switch']);
         $category->params = $params->toString();
         if (!$category->store($alterOrdering)) {
             JError::raiseError(500, $category->getError());
             exit;
         }
         //save the category acl
         $category->deleteACL();
         $category->saveACL($post);
         $file = JRequest::getVar('Filedata', '', 'files', 'array');
         if (!empty($file['name'])) {
             $newAvatar = DiscussHelper::uploadCategoryAvatar($category, true);
             $category->avatar = $newAvatar;
             $category->store();
             //now update the avatar.
         }
         // now we need to rerun the category ordering incase admin assign the correct category tree as a child of another category.
         $category->rebuildOrdering();
         $message = JText::_('COM_EASYDISCUSS_CATEGORIES_SAVED_SUCCESS');
     } else {
         $message = JText::_('COM_EASYDISCUSS_INVALID_REQUEST');
         $type = 'error';
     }
     DiscussHelper::setMessageQueue($message, $type);
     if ($task == 'savePublishNew') {
         $mainframe->redirect('index.php?option=com_easydiscuss&view=category');
         $mainframe->close();
     }
     if ($task == 'apply') {
         $mainframe->redirect('index.php?option=com_easydiscuss&view=category&catid=' . $category->id);
         $mainframe->close();
     }
     $mainframe->redirect('index.php?option=com_easydiscuss&view=categories');
     $mainframe->close();
 }
開發者ID:BetterBetterBetter,項目名稱:B3App,代碼行數:79,代碼來源:category.php


注:本文中的DiscussHelper::uploadCategoryAvatar方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。