本文整理汇总了PHP中CFileHelper::getFileExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP CFileHelper::getFileExtension方法的具体用法?PHP CFileHelper::getFileExtension怎么用?PHP CFileHelper::getFileExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileHelper
的用法示例。
在下文中一共展示了CFileHelper::getFileExtension方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: multiUpload
public function multiUpload()
{
$mainframe = JFactory::getApplication();
$jinput = $mainframe->input;
$my = CFactory::getUser();
$config = CFactory::getConfig();
$type = $jinput->get('type', NULL, 'NONE');
$id = $jinput->get('id', '0', 'Int');
if ($my->id == 0) {
$tokenId = $jinput->request->get('token', '', 'STRING');
$userId = $jinput->request->get('uploaderid', '', 'INT');
$my = CFactory::getUserFromTokenId($tokenId, $userId);
$session = JFactory::getSession();
$session->set('user', $my);
}
$parentTable = JTable::getInstance(ucfirst($type), 'CTable');
$parentTable->load($id);
$table = JTable::getInstance('File', 'CTable');
$_file = $jinput->files->get('file');
$fileLib = new CFilesLibrary();
if (CLimitsLibrary::exceedDaily('files', $my->id)) {
$json = array('msg' => JText::_('COM_COMMUNITY_FILES_LIMIT_REACHED'));
echo json_encode($json);
exit;
}
if ($type == 'discussion' && !CLimitsHelper::exceededGroupFileUpload($parentTable->groupid)) {
$json = array('msg' => JText::_('COM_COMMUNITY_FILES_LIMIT_REACHED'));
echo json_encode($json);
exit;
}
$now = new JDate();
$ext = pathinfo($_file['name']);
$file = new stdClass();
$file->creator = $my->id;
$file->filesize = sprintf("%u", $_file['size']);
$file->name = JString::substr($_file['name'], 0, JString::strlen($_file['name']) - (JString::strlen($ext['extension']) + 1));
$file->created = $now->toSql();
$file->type = CFileHelper::getExtensionIcon(CFileHelper::getFileExtension($_file['name']));
$fileName = JApplication::getHash($_file['name'] . time()) . JString::substr($_file['name'], JString::strlen($_file['name']) - (JString::strlen($ext['extension']) + 1));
if ($_file['error'] > 0 && $_file['error'] !== 'UPLOAD_ERR_OK') {
$json = array('msg' => JText::sprintf('COM_COMMUNITY_PHOTOS_UPLOAD_ERROR', $_file['error']));
echo json_encode($json);
exit;
}
if (!$fileLib->checkType($_file['name'])) {
$json = array('msg' => JText::_('COM_COMMUNITY_IMAGE_FILE_NOT_SUPPORTED'));
echo json_encode($json);
exit;
}
switch ($type) {
case 'discussion':
$file->discussionid = $parentTable->id;
$file->groupid = $parentTable->groupid;
$file->filepath = 'images/files' . '/' . $type . '/' . $file->discussionid . '/' . $fileName;
break;
case 'bulletin':
$file->bulletinid = $parentTable->id;
$file->groupid = $parentTable->groupid;
$file->filepath = 'images/files' . '/' . $type . '/' . $file->bulletinid . '/' . $fileName;
break;
case 'message':
$file->messageid = -1;
// set as -1 just in case this is not used and cron can clear it later
if ($id) {
$file->filepath = 'images/files/' . $type . '/' . $id . '/' . $fileName;
if (!JFolder::exists(JPATH_ROOT . '/images/files/' . $type . '/' . $id)) {
JFolder::create(JPATH_ROOT . '/images/files/' . $type . '/' . $id, (int) octdec($config->get('folderpermissionsphoto')));
JFile::copy(JPATH_ROOT . '/components/com_community/index.html', JPATH_ROOT . '/images/files/' . $type . '/' . $id . '/index.html');
}
JFile::copy($_file['tmp_name'], JPATH_ROOT . '/' . $file->filepath);
} else {
//this could be from new message, and there is no id given
$file->filepath = 'images/files/' . $type . '/temp/' . $fileName;
//create the folder here as the logic for bulletin and discussion is not the same
if (!JFolder::exists(JPATH_ROOT . '/' . $type . '/temp')) {
JFolder::create(JPATH_ROOT . '/images/files' . '/' . $type . '/temp', (int) octdec($config->get('folderpermissionsphoto')));
JFile::copy(JPATH_ROOT . '/components/com_community/index.html', JPATH_ROOT . '/files' . '/' . $type . '/temp/index.html');
}
JFile::copy($_file['tmp_name'], JPATH_ROOT . '/images/files' . '/' . $type . '/temp/' . $fileName);
}
break;
}
if ($type != 'message') {
if (!JFolder::exists(JPATH_ROOT . '/' . $type . '/' . $parentTable->id)) {
JFolder::create(JPATH_ROOT . '/images/files' . '/' . $type . '/' . $parentTable->id, (int) octdec($config->get('folderpermissionsphoto')));
JFile::copy(JPATH_ROOT . '/components/com_community/index.html', JPATH_ROOT . '/files' . '/' . $type . '/' . $parentTable->id . '/index.html');
}
JFile::copy($_file['tmp_name'], JPATH_ROOT . '/images/files' . '/' . $type . '/' . $parentTable->id . '/' . $fileName);
}
$table->bind($file);
$table->store();
$params = new CParameter('');
switch ($type) {
case 'discussion':
// Get repliers for this discussion and notify the discussion creator too
$discussionModel = CFactory::getModel('Discussions');
$discussion = JTable::getInstance('Discussion', 'CTable');
$discussion->load($parentTable->id);
$users = $discussionModel->getRepliers($discussion->id, $discussion->groupid);
$users[] = $discussion->creator;
//.........这里部分代码省略.........