1,747 9 0
xuanviet15
Private
Là mình muốn bài post trong diễn đàn nếu có code thì nó sẽ hiện ra như thế này nè bạn:
dev.xf
Sergeant
PHP:
<?php
class Brivium_HideAttachment_ControllerPublic_Attachment extends XFCP_Brivium_HideAttachment_ControllerPublic_Attachment
{
public function actionIndex()
{
$attachmentId = $this->_input->filterSingle('attachment_id', XenForo_Input::UINT);
$attachment = $this->_getAttachmentOrError($attachmentId);
if(isset($attachment)){
if($attachment['content_type'] == 'post'){
$ftpHelper = $this->getHelper('ForumThreadPost');
list($post, $thread, $forum) = $ftpHelper->assertPostValidAndViewable($attachment['content_id']);
$hideAttachment = $this->_getHideAttachmentModel();
$visitorId = XenForo_Visitor::getUserId();
if($hideAttachment->requirePermission($forum['node_id'],$post) && $hideAttachment->requirePermissionPost($post,$visitorId)){
$options = XenForo_Application::get('options');
$extensionMap = preg_split('/\s+/', trim($options->BRHA_excludedFileExtensions));
$extension = XenForo_Helper_File::getFileExtension($attachment['filename']);
if (!in_array($extension, $extensionMap))
{
$mustReply = false;
$mustLike = false;
if($options->BRHA_likeRequired && !$this->getModelFromCache('XenForo_Model_Like')->getContentLikeByLikeUser('post',$post['post_id'],$visitorId)){
$mustLike = true;
}
if($options->BRHA_replyRequired && !$hideAttachment->checkReplied($thread['thread_id'],$visitorId)){
$mustReply = true;
}
if($mustReply && $mustLike){
return $this->responseError(new XenForo_Phrase('BRHA_mustLikeAndReply'));
}else if($mustLike){
return $this->responseError(new XenForo_Phrase('BRHA_mustLike'));
}else if($mustReply){
return $this->responseError(new XenForo_Phrase('BRHA_mustReply'));
}
}
}
}
}
return parent::actionIndex();
}
/**
* @return Brivium_HideAttachment_Model_HideAttachment
*/
protected function _getHideAttachmentModel()
{
return $this->getModelFromCache('Brivium_HideAttachment_Model_HideAttachment');
}
}
xuanviet15
Private
PHP:<?php class Brivium_HideAttachment_ControllerPublic_Attachment extends XFCP_Brivium_HideAttachment_ControllerPublic_Attachment { public function actionIndex() { $attachmentId = $this->_input->filterSingle('attachment_id', XenForo_Input::UINT); $attachment = $this->_getAttachmentOrError($attachmentId); if(isset($attachment)){ if($attachment['content_type'] == 'post'){ $ftpHelper = $this->getHelper('ForumThreadPost'); list($post, $thread, $forum) = $ftpHelper->assertPostValidAndViewable($attachment['content_id']); $hideAttachment = $this->_getHideAttachmentModel(); $visitorId = XenForo_Visitor::getUserId(); if($hideAttachment->requirePermission($forum['node_id'],$post) && $hideAttachment->requirePermissionPost($post,$visitorId)){ $options = XenForo_Application::get('options'); $extensionMap = preg_split('/\s+/', trim($options->BRHA_excludedFileExtensions)); $extension = XenForo_Helper_File::getFileExtension($attachment['filename']); if (!in_array($extension, $extensionMap)) { $mustReply = false; $mustLike = false; if($options->BRHA_likeRequired && !$this->getModelFromCache('XenForo_Model_Like')->getContentLikeByLikeUser('post',$post['post_id'],$visitorId)){ $mustLike = true; } if($options->BRHA_replyRequired && !$hideAttachment->checkReplied($thread['thread_id'],$visitorId)){ $mustReply = true; } if($mustReply && $mustLike){ return $this->responseError(new XenForo_Phrase('BRHA_mustLikeAndReply')); }else if($mustLike){ return $this->responseError(new XenForo_Phrase('BRHA_mustLike')); }else if($mustReply){ return $this->responseError(new XenForo_Phrase('BRHA_mustReply')); } } } } } return parent::actionIndex(); } /** * @return Brivium_HideAttachment_Model_HideAttachment */ protected function _getHideAttachmentModel() { return $this->getModelFromCache('Brivium_HideAttachment_Model_HideAttachment'); } }
Anh Dev.xf làm thế nào vậy ạ?
xuanviet15
Private
Code nào cũng dùng thể này hay chỉ PHP thui anh ?thẻPHP:[ /php] đó em
dev.xf
Sergeant
anh vẫn dùng cho cả html và csssCode nào cũng dùng thể này hay chỉ PHP thui anh ?
xuanviet15
Private
Ohm, cảm ơn anh! để em làm thử!


