18 require_once SQ_CORE_PACKAGE_PATH.
'/designs/design_area/design_area_edit_fns.inc';
19 require_once SQ_FUDGE_PATH.
'/general/text.inc';
42 parent::__construct();
59 if (!$asset->
writeAccess(
'attributes'))
return FALSE;
61 $o->
note(translate(
'core_only_upload_files_of_type', make_readable_list($asset->allowed_extensions)));
62 $o->
note(translate(
'core_image_size_restricted', $asset->
attr(
'max_width'), $asset->
attr(
'max_height')));
81 $info = get_file_upload_info($prefix);
84 if ($info === FALSE || empty($info)) {
89 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
90 if (!in_array(get_file_type($info[
'name']) , $asset->allowed_extensions)) {
91 trigger_localised_error(
'CORE0190', E_USER_WARNING, make_readable_list($asset->allowed_extensions));
96 $size = getimagesize($info[
'tmp_name']);
97 if ($size === FALSE)
return FALSE;
98 $max_width = (int) $asset->
attr(
'max_width');
99 $max_height = (int) $asset->
attr(
'max_height');
100 if (($max_width && $size[0] > $max_width) || ($max_height && $size[1] > $max_height)) {
101 trigger_localised_error(
'CORE0191', E_USER_WARNING, $asset->
attr(
'max_width'), $asset->
attr(
'max_height'));
105 create_directory($asset->data_path_public);
107 $old_image = $asset->
attr(
'image');
108 $new_image = $info[
'name'];
111 if ($old_image && $old_image != $new_image && file_exists($asset->data_path_public.
'/'.$old_image)) {
112 if (!unlink($asset->data_path_public.
'/'.$old_image)) {
113 trigger_localised_error(
'CORE0163', E_USER_WARNING);
119 if (!move_uploaded_file($info[
'tmp_name'], $asset->data_path_public.
'/'.$info[
'name'])) {
120 trigger_localised_error(
'CORE0166', E_USER_WARNING);
145 $image = $asset->
attr(
'image');
146 if (empty($image) || !file_exists($asset->data_path_public.
'/'.$image)) {
147 echo translate(
'core_design_area_custom_image_no_upload');
150 <a href=
"<?php echo sq_web_path('data').'/assets/'.$asset->type().'/'.get_asset_hash($asset->id).'/'.$asset->id.'/'.$image; ?>" target=
"_blank"><?php echo $image; ?></a>