本文整理汇总了PHP中ElggFile::getSubtype方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggFile::getSubtype方法的具体用法?PHP ElggFile::getSubtype怎么用?PHP ElggFile::getSubtype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElggFile
的用法示例。
在下文中一共展示了ElggFile::getSubtype方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: file_tools_get_file_extension
/**
* Get the extension of an ElggFile
*
* @param ElggFile $file the file to check
*
* @return string
*/
function file_tools_get_file_extension($file)
{
$result = '';
if ($file->getSubtype() == 'file') {
if ($filename = $file->getFilename()) {
$exploded_filename = explode('.', $filename);
$result = end($exploded_filename);
}
}
return strtolower($result);
}
示例2: forward
if (isset($params->container_guid)) {
$container = get_entity($params->container_guid);
} else {
$container = elgg_get_logged_in_user_entity();
}
}
if (!$container instanceof ElggEntity) {
register_error(elgg_echo('images:error:not_found'));
forward(REFERRER);
}
if (!$entity) {
$entity = new ElggFile();
$entity->subtype = 'file';
$entity->container_guid = $container ? $container->guid : elgg_get_logged_in_user_guid();
}
if (!$entity->canEdit() || !$container->canWriteToContainer(0, $entity->getType(), $entity->getSubtype())) {
register_error(elgg_echo('images:error:permission_denied'));
forward(REFERRER);
}
$entity = images()->createFromUpload('upload', $entity);
if (!$entity) {
register_error(elgg_echo('images:upload:error:invalid_file'));
forward(REFERRER);
}
$entity->title = $params->title;
$entity->description = $params->description;
$entity->tags = string_to_tag_array((string) $params->tags);
$entity->access_id = isset($params->access_id) ? $params->access_id : get_default_access();
if ($entity->save()) {
if (elgg_is_xhr()) {
echo json_encode($entity->toObject());