14 private $_socnet_group_id;
21 private static $_counter = 0;
23 function __construct($list_id, $section_id, $element_id, $field_id, $file_id)
25 $this->_list_id = intval($list_id);
26 $this->_section_id = intval($section_id);
27 $this->_element_id = intval($element_id);
28 $this->_field_id = $field_id;
29 $this->_file_id = intval($file_id);
30 $this->_socnet_group_id =
"";
32 $this->_file = CFile::GetFileArray($this->_file_id);
33 if(is_array($this->_file))
35 $this->_width = intval($this->_file[
'WIDTH']);
36 $this->_height = intval($this->_file[
'HEIGHT']);
42 if($socnet_group_id > 0)
43 $this->_socnet_group_id = intval($socnet_group_id);
50 if(is_array($this->_file))
52 $intWidth = $this->_width;
53 $intHeight = $this->_height;
56 if (isset(
$params[
'url_template']))
62 $divId =
'lists-image-info-'.self::$_counter;
66 $attributes = ItemAttributes::buildByFileData($this->_file, $img_src);
67 $attributes->setTitle($this->_file[
'FILE_NAME']);
71 $html .=
'<div id="'.$divId.
'">';
80 $info = $this->_file[
"ORIGINAL_NAME"].
' (';
81 if($intWidth > 0 && $intHeight > 0)
83 $info .= $intWidth.
'x'.$intHeight.
', ';
85 $info .= CFile::FormatSize($this->_file[
'FILE_SIZE']).
')';
86 $html .=
GetMessage(
'FILE_TEXT').
': <span class="lists-file-preview-data" '.$attributes.
'>'.htmlspecialcharsex(
$info).
'</span>';
90 $html .=
GetMessage(
'FILE_TEXT').
': <span class="lists-file-preview-data" '.$attributes.
'>'.htmlspecialcharsex($this->_file[
"ORIGINAL_NAME"]).
'</span>';
92 if($intWidth > 0 && $intHeight > 0)
94 $html .=
'<br>'.GetMessage(
'FILE_WIDTH').
': '.$intWidth;
95 $html .=
'<br>'.GetMessage(
'FILE_HEIGHT').
': '.$intHeight;
97 $html .=
'<br>'.GetMessage(
'FILE_SIZE').
': '.CFile::FormatSize($this->_file[
'FILE_SIZE']);
108 $input_name = $this->_field_id;
114 if(isset(
$params[
'input_name']))
115 $input_name =
$params[
'input_name'];
117 $size = intval(
$params[
'size']);
118 if(isset(
$params[
'show_info']))
119 $show_info = (bool)
$params[
'show_info'];
122 $strReturn =
' <input name="'.htmlspecialcharsbx($input_name).
'" size="'.$size.
'" type="file" />';
124 if(is_array($this->_file))
129 'url_template' =>
$params[
'url_template'],
134 $p = mb_strpos($input_name,
"[");
136 $del_name = mb_substr($input_name, 0,
$p).
"_del".mb_substr($input_name,
$p);
138 $del_name = $input_name.
"_del";
140 $strReturn .=
'<input type="checkbox" name="'.htmlspecialcharsbx($del_name).
'" value="Y" id="'.
htmlspecialcharsbx($del_name).
'" />';
141 $strReturn .=
' <label for="'.htmlspecialcharsbx($del_name).
'">'.
GetMessage(
'FILE_DELETE').
'</label><br>';
152 array(
'#list_id#',
'#section_id#',
'#element_id#',
'#field_id#',
'#file_id#',
'#group_id#'),
153 array($this->_list_id, $this->_section_id, $this->_element_id, $this->_field_id, $this->_file_id, $this->_socnet_group_id),
158 elseif(is_array($this->_file))
160 return $this->_file[
'SRC'];
175 if(isset(
$params[
'max_width']))
176 $max_width = intval(
$params[
'max_width']);
177 if(isset(
$params[
'max_height']))
178 $max_height = intval(
$params[
'max_height']);
181 if(is_array($this->_file))
183 $intWidth = $this->_width;
184 $intHeight = $this->_height;
185 if($intWidth > 0 && $intHeight > 0 && $max_width > 0 && $max_height > 0)
187 if($intWidth > $max_width || $intHeight > $max_height)
189 $coeff = ($intWidth/$max_width > $intHeight/$max_height? $intWidth/$max_width : $intHeight/$max_height);
190 $intWidth = intval(
roundEx($intWidth/$coeff));
191 $intHeight= intval(
roundEx($intHeight/$coeff));
196 $attributes = ItemAttributes::buildByFileData($this->_file, $src);
197 $html =
'<img class="lists-file-preview-data" src="'.htmlspecialcharsbx($src).
'" '.$attributes.
' width="'.$intWidth.
'" height="'.$intHeight.
'"';
201 if(preg_match(
'/^[a-zA-Z-]+$/',
$name))
215 if(is_array($this->_file))
218 return ' [ <a href="'.htmlspecialcharsbx($src).
'" target="_self">'.
$params[
'download_text'].
'</a> ] ';
228 return $this->_width;
233 return $this->_height;
238 if(is_array($this->_file))
239 return $this->_file[
"FILE_SIZE"];
246 return is_array($this->_file) && ($this->_width > 0) && ($this->_height > 0);
static urlAddParams($url, $add_params, $options=[])
SetSocnetGroup($socnet_group_id)
GetInputHTML($params=array())
GetLinkHtml($params=array())
GetImgHtml($params=array())
GetImgSrc($params=array())
GetInfoHTML($params=array())
__construct($list_id, $section_id, $element_id, $field_id, $file_id)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if($NS['step']==6) if( $NS[ 'step']==7) if(COption::GetOptionInt('main', 'disk_space', 0) > 0) $info
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
GetMessage($name, $aReplace=null)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']