本文整理汇总了PHP中UploadField::handle方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadField::handle方法的具体用法?PHP UploadField::handle怎么用?PHP UploadField::handle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UploadField
的用法示例。
在下文中一共展示了UploadField::handle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* {@inheritdoc}
*/
public function handle(\ElggEntity $entity)
{
$this->tmp_icon_sizes = array();
// make sure we do not duplicate icon creation
elgg_register_plugin_hook_handler('entity:icon:sizes', 'object', array($this, 'getIconSizes'), 999);
$result = parent::handle($entity);
elgg_unregister_plugin_hook_handler('entity:icon:sizes', 'object', array($this, 'getIconSizes'));
if (!$result) {
return $entity;
}
$shortname = $this->getShortname();
$upload = $this->getValues($entity);
$icon_sizes = hypeApps()->iconFactory->getSizes($upload);
$custom_icon_sizes = (array) $this->input_vars->{"icon_sizes"};
$icon_sizes = array_merge($icon_sizes, $custom_icon_sizes);
if (empty($icon_sizes)) {
return $entity;
}
$image_upload_crop_coords = (array) get_input('image_upload_crop_coords', array());
$ratio_coords = (array) elgg_extract($shortname, $image_upload_crop_coords, array());
list($master_width, $master_height) = getimagesize($_FILES[$shortname]['tmp_name']);
foreach ($icon_sizes as $icon_name => $icon_size) {
$ratio = (int) $icon_size['w'] / (int) $icon_size['h'];
$coords = (array) elgg_extract("{$ratio}", $ratio_coords, array());
$x1 = (int) elgg_extract('x1', $coords);
$x2 = (int) elgg_extract('x2', $coords);
$y1 = (int) elgg_extract('y1', $coords);
$y2 = (int) elgg_extract('y2', $coords);
if ($x2 <= $x1 || $y2 <= $y1) {
// do not crop
$this->tmp_coords = false;
} else {
$this->tmp_coords = $coords;
$this->tmp_coords['master_width'] = $master_width;
$this->tmp_coords['master_height'] = $master_height;
}
if (!isset($icon_size['name'])) {
$icon_size['name'] = $icon_name;
}
$this->tmp_icon_sizes = array($icon_size['name'] => $icon_size);
$options = array('icon_sizes' => $this->tmp_icon_sizes, 'coords' => $this->tmp_coords);
elgg_register_plugin_hook_handler('entity:icon:sizes', 'object', array($this, 'getIconSizes'), 999);
if (hypeApps()->iconFactory->create($upload, $_FILES[$shortname]['tmp_name'], $options)) {
foreach (array('x1', 'x2', 'y1', 'y2') as $c) {
$upload->{"_coord_{$ratio}_{$coord}"} = elgg_extract($c, $coords, 0);
if ($ratio === 1) {
$upload->{$c} = elgg_extract($c, $coords, 0);
}
}
}
elgg_unregister_plugin_hook_handler('entity:icon:sizes', 'object', array($this, 'getIconSizes'));
}
$upload->icontime = time();
return $entity;
}