public function __construct($name, $desc = null, $format = null) { $this->settings = new nc_multifield_settings($this); $this->template = new nc_multifield_template($this); $this->name = $name; $this->desc = $desc; $this->format = $format; require_once nc_Core::get_object()->INCLUDE_FOLDER . '../admin/class.inc.php'; $this->format_parsed = nc_field_parse_resize_options($this->format); if ($this->format_parsed['use_resize']) { $this->settings->resize($this->format_parsed['resize_width'], $this->format_parsed['resize_height']); } if ($this->format_parsed['use_preview']) { $this->settings->preview($this->format_parsed['preview_width'], $this->format_parsed['preview_height']); } if ($this->format_parsed['use_crop']) { $this->settings->crop($this->format_parsed['crop_x0'], $this->format_parsed['crop_x1'], $this->format_parsed['crop_y0'], $this->format_parsed['crop_y1']); } if ($this->format_parsed['crop_ignore']) { $this->settings->crop_ignore($this->format_parsed['crop_ignore_width'], $this->format_parsed['crop_ignore_height']); } }
// может содержать вложения, "aa/bb/cc" // массив со всеми директориями, которые надо создать $folders = explode('/', $folder); $full_path = $FILES_FOLDER; // полный путь до создаваемой папки foreach ($folders as $v) { $folder_path = $full_path . $v; $full_path .= $v . '/'; @mkdir($folder_path, $DIRCHMOD); @chmod($folder_path, $DIRCHMOD); } } $save_path = $FILES_FOLDER . $File_Path[$j] . ($fldFS[$i] == NC_FS_SIMPLE ? $tmpFile[$j] : $put_file_name); $save_path_preview = $FILES_FOLDER . $File_Path[$j] . 'preview_' . ($fldFS[$i] == NC_FS_SIMPLE ? $tmpFile[$j] : $put_file_name); @move_uploaded_file($srcFile, $save_path); $resize_format = nc_field_parse_resize_options($fldFmt[$i]); require_once $nc_core->INCLUDE_FOLDER . "classes/nc_imagetransform.class.php"; if ($resize_format['use_preview']) { @nc_ImageTransform::imgResize($save_path, $save_path_preview, $resize_format['preview_width'], $resize_format['preview_height']); } if ($resize_format['use_resize']) { @nc_ImageTransform::imgResize($save_path, $save_path, $resize_format['resize_width'], $resize_format['resize_height']); $filesize = filesize($save_path); } if ($resize_format['use_crop']) { @nc_ImageTransform::imgCrop($save_path, $save_path, $resize_format['crop_x0'], $resize_format['crop_y0'], $resize_format['crop_x1'], $resize_format['crop_y1'], NULL, 90, 0, 0, $resize_format['crop_ignore'] ? $resize_format['crop_ignore_width'] : 0, $resize_format['crop_ignore'] ? $resize_format['crop_ignore_height'] : 0); $filesize = filesize($save_path); } // в этом случаe надо записать в базу if ($fldFS[$i] == NC_FS_PROTECTED) { $query = $db->query("INSERT INTO `Filetable`\n (`Real_Name`, `File_Path`, `Virt_Name`, `File_Type`, `File_Size`, `Field_ID`, `Content_Disposition`)\n VALUES ('" . $db->escape($filename) . "', '/" . $db->escape($File_Path[$j]) . "', '" . $db->escape($put_file_name) . "', '" . $db->escape($filetype) . "',\n '" . intval($filesize) . "', '" . intval($fldID[$i]) . "', '" . intval($fldDisposition[$i]) . "')");
/** * * @param string|int $class_id - ID компонента или название системной таблицы(User|Catalogue|Subdivision|Template) * @param string|int $field - название или ID поля в которое сохранять * @param int $message_id - ID объекта|пользователя|сайта|раздела|макета * @param array $file - массив с данными о файле из $_FILES либо * path — путь к файлу(/netcat/tmp/foto.jpg) или ссылка(http://example.com/foto.jpg) * type — mime-тип, попытается определить автоматически если не задан, по умолчанию image/jpeg * name — имя файла, возьмется из ссылки если не задано * folder — нестандартная папка в которую сохранить файл, только для стандартной ФС * @param bool $no еdit - игнорировать настройки поля изменяющие файл * @param bool $message_put - режим работы внутри системы * @return array * download_path — ссылка для скачивания под оригинальным именем (ссылка с "h_") * url — путь к файлу от корня сайта * preview_url — путь к превью файла от корня сайта * name — изначальное имя файла * size — размер * type — mime-тип */ public function field_save_file($class_id, $field, $message_id, $file, $noеdit = false, $message_put = false) { $DOCUMENT_ROOT = nc_core('DOCUMENT_ROOT'); $FILES_FOLDER = nc_core('FILES_FOLDER'); $files_http_path = nc_core('SUB_FOLDER') . nc_core('HTTP_FILES_PATH'); $db = nc_core('db'); $message_id = intval($message_id); $component = new nc_Component($class_id); $systemTableID = $component->get_system_table_id(); $systemTableName = $systemTableID ? $class_id : ''; $fields = $component->get_fields(NC_FIELDTYPE_FILE); if (!empty($fields)) { foreach ($fields as $v) { if ($v['id'] == $field || $v['name'] == $field) { $rawformat = $v['format']; $field_id = $v['id']; $field_name = $v['name']; } } } else { return null; //wrong class or field } if (!$systemTableID) { $msg = $db->get_row("SELECT `Sub_Class_ID`, `Subdivision_ID` FROM `Message{$class_id}` WHERE `Message_ID` = '{$message_id}'", ARRAY_A); } else { $msg = $db->get_row("SELECT COUNT(*) FROM `{$systemTableName}` WHERE `{$systemTableName}_ID` = {$message_id}", ARRAY_A); } if (empty($msg)) { return null; //wrong message } $result = array(); #delete old file require_once $this->core->INCLUDE_FOLDER . "s_files.inc.php"; DeleteFile($field_id, $field_name, $class_id, $systemTableName, $message_id); $format = nc_field_parse_format($rawformat, NC_FIELDTYPE_FILE); $fileurl = $file['path']; $filesrc = $file['tmp_name']; if (!$fileurl && !$filesrc) { return null; //no file to save } if (!$filesrc && $fileurl && !(preg_match("~^[^=]+://~", $fileurl) && ($buf = @file_get_contents($fileurl))) && !file_exists($DOCUMENT_ROOT . $fileurl)) { //и по внутренней нет return null; } $filename = $file['name'] ? $file['name'] : substr($fileurl, strrpos($fileurl, '/') + 1); $filename = str_replace(array('<', '>'), '_', $filename); $filetype = $file['type']; $filesize = $file['size']; $folder = trim($file['folder'], '/'); // расширение файла $ext = substr($filename, strrpos($filename, ".")); if (!$systemTableID) { $File_Path = $msg['Subdivision_ID'] . "/" . $msg['Sub_Class_ID'] . "/"; } elseif ($systemTableID == 1) { $File_Path = "c/"; } elseif ($systemTableID == 3) { $File_Path = "u/"; } elseif ($systemTableID == 4) { $File_Path = "t/"; } else { $File_Path = $message_id ? $message_id . "/" : ""; //sic! why eval? $File_PathNew = "\$message/"; } // будущее имя файла на диске + путь switch ($format['fs']) { case NC_FS_PROTECTED: // hash // имя файла $put_file_name = md5($filename . date("H:i:s d.m.Y") . uniqid("netcat")); break; case NC_FS_ORIGINAL: // пользователь сам указал папку if ($folder && preg_match("/^[a-z][a-z0-9\\/]+\$/is", $folder)) { $File_Path = $folder . "/"; } // сгенерировать имя файла $put_file_name = nc_get_filename_for_original_fs($filename, $FILES_FOLDER . $File_Path); $db_string_path = ":" . ($File_PathNew ? $File_PathNew : $File_Path) . $put_file_name; break; case NC_FS_SIMPLE: // FieldID_MessageID.ext $File_Path = ''; // в папку netcat_files //sic! why eval? $put_file_name = $field_id . ($message_put ? '_$message' : "_" . $message_id) . $ext; break; } $this->create_dir($FILES_FOLDER . $File_Path); //для простой ФС нужно скопировать временный файл //он будет обрабатываться и после добавления объекта переименован в FieldID_MessageID.ext //при добавлении объекта или раздела пока неизвестен путь, поэтому файл попадет в папку netcat_files и потом перенесен $save_mame = $format['fs'] == NC_FS_SIMPLE && $message_put ? $filesrc : $put_file_name; $save_path = $FILES_FOLDER . $File_Path . $save_mame; $save_path_preview = $FILES_FOLDER . $File_Path . 'preview_' . $save_mame; if ($filesrc) { @move_uploaded_file($filesrc, $save_path); } else { if ($buf) { @file_put_contents($save_path, $buf); } else { @copy($DOCUMENT_ROOT . $fileurl, $save_path); } } $resize_format = nc_field_parse_resize_options($rawformat); require_once $this->core->INCLUDE_FOLDER . "classes/nc_imagetransform.class.php"; if (!$noеdit) { if ($resize_format['use_preview']) { @nc_ImageTransform::imgResize($save_path, $save_path_preview, $resize_format['preview_width'], $resize_format['preview_height']); } if ($resize_format['use_resize']) { @nc_ImageTransform::imgResize($save_path, $save_path, $resize_format['resize_width'], $resize_format['resize_height']); $filesize = filesize($save_path); } if ($resize_format['use_crop']) { @nc_ImageTransform::imgCrop($save_path, $save_path, $resize_format['crop_x0'], $resize_format['crop_y0'], $resize_format['crop_x1'], $resize_format['crop_y1'], NULL, 90, 0, 0, $resize_format['crop_ignore'] ? $resize_format['crop_ignore_width'] : 0, $resize_format['crop_ignore'] ? $resize_format['crop_ignore_height'] : 0); $filesize = filesize($save_path); } } $filesize = $filesize ? $filesize : filesize($save_path); $filetype = $filetype ? $filetype : ($filetype = $this->_guess_content_type($save_path) ? $filetype : "image/jpeg"); // для защищенной надо записать файл в базу if ($format['fs'] == NC_FS_PROTECTED) { $query = $db->query("INSERT INTO `Filetable`\n (`Real_Name`, `File_Path`, `Virt_Name`, `File_Type`, `File_Size`, `Field_ID`, `Content_Disposition`, `Message_ID`)\n VALUES ('" . $db->escape($filename) . "', '/" . $db->escape($File_Path) . "', '" . $db->escape($put_file_name) . "', '" . $db->escape($filetype) . "',\n '" . intval($filesize) . "', '" . intval($field_id) . "', '" . intval($format['disposition']) . "', '" . $message_id . "')"); if ($query) { $filetable_lastid = $db->insert_id; $result['download_path'] = $files_http_path . $File_Path . 'h_' . $put_file_name; } } $db_string = $filename . ":" . $filetype . ":" . $filesize . $db_string_path; $result['url'] = $files_http_path . $File_Path . $put_file_name; $result['preview_url'] = $resize_format['use_preview'] ? $files_http_path . $File_Path . 'preview_' . $put_file_name : ""; $result['name'] = $filename; $result['size'] = $filesize; $result['type'] = $filetype; if (!$message_put) { //запишем в объект сущности $query = $db->query("UPDATE `" . ($systemTableID ? $systemTableName : "Message" . $class_id) . "`\n SET `{$field_name}` = '" . $db->escape($db_string) . "'\n WHERE `" . ($systemTableID ? $systemTableName : "Message") . "_ID` = {$message_id}"); } else { //данные для использования в скриптах добавления/изменения после message_put.php $result['FileFS'] = $format['fs']; $result['tmpNewFile'] = $put_file_name; $result['File_Path'] = $File_Path; $result['File_PathNew'] = $File_PathNew; $result['filetable_lastid'] = $filetable_lastid; $result['fldValue'] = $db_string; } return $result; }
/** * Show form to edit field or create new * * @param int Field id, 0 - if new * @param int ClassId or SystemTableId, if 0 - edit field * @param bool is field in system table * @param string action * @param string form name * @param string form id * @param string Advanced elements * @return bool true */ function FieldForm($FieldID, $Id, $isSys = 0, $action = "index.php", $FormName = '', $FormID = '', $Additional = '', $isWidget = 0) { global $db, $nc_core; global $UI_CONFIG; global $field_type_name, $type_of_edit_name; $FieldID = intval($FieldID); $Id = intval($Id); $no_multifile = false; if ($isSys) { if (!$Id && $FieldID) { $sql = "SELECT `System_Table_ID` FROM `Field` WHERE `Field_ID` = {$FieldID}"; $systemTableId = $db->get_var($sql); $no_multifile = $systemTableId != 3; } else { if ($Id != 3) { $no_multifile = true; } } } if ($FieldID) { $Array = $db->get_row("SELECT `Field_Name`, `Description`, `TypeOfData_ID`, `Format`, `Extension`, `NotNull`, `Priority`, `DoSearch`,\n `Inheritance`, `DefaultState`, `TypeOfEdit_ID`, `Widget_Class_ID`, `InTableView`\n FROM `Field`\n WHERE `Field_ID`='" . $FieldID . "' AND `Checked` = 1", ARRAY_A); if ($Array["Widget_Class_ID"]) { $isWidget = 1; } } else { $Array = $_POST; $where = $isSys ? "`System_Table_ID`" : ($isWidget ? "`Widget_Class_ID`" : "`Class_ID`"); $where .= "='" . $Id . "'"; if (!$Array["Priority"]) { $res = $db->get_var("SELECT (Priority+1) FROM `Field` WHERE " . $where . " ORDER BY `Priority` DESC LIMIT 1"); if (!is_null($res)) { $Array["Priority"] = $res; } } } // js для визульного заполнения "Формата" $js = "<script type='text/javascript' language='JavaScript'>\n " . ($Array["TypeOfData_ID"] || 1 ? "nc_field_additional_format(" . intval($Array["TypeOfData_ID"] ? $Array["TypeOfData_ID"] : 1) . ");" : "") . "\n\n function nc_field_additional_format(selected_field) {\n\n //settings for text\n document.getElementById('div_upload_limits').style.display = ((selected_field == 6 || selected_field == 11 ) ? 'block' : 'none');\n\n // select FS for file field\n document.getElementById('div_field_file').style.display = ((selected_field == 6) ? 'block' : 'none');\n\n //don't show Format field\n document.getElementById('div_format').style.display = ((selected_field == 3 || selected_field == 1) ? 'none' : 'block');\n\n //settings for text\n document.getElementById('div_field_text').style.display = ((selected_field == 3 ) ? 'block' : 'none');\n\n //settings for string\n document.getElementById('div_field_string').style.display = ((selected_field == 1 ) ? 'block' : 'none');\n\n //settings for date\n document.getElementById('div_field_date').style.display = ((selected_field == 8 ) ? 'block' : 'none');\n\n document.getElementById('div_file_resize').style.display = ((selected_field == 11 || selected_field == 6) ? 'block' : 'none');"; if (!$isSys) { $js .= "//settings for search\n\t\tdocument.getElementById('dosr').disabled = ((selected_field == 9 || selected_field == 11) ? true : false);\n\t\tdocument.getElementById('dosr').style.background = ( (selected_field == 9 || selected_field == 11) ? '#eee' : '' );"; } $js .= "// default value field\n var defaultField = document.getElementById('DefaultState');\n\n if (defaultField) {\n // default value field disabled\n defaultField.disabled = ( (selected_field == 11 || selected_field==3 || selected_field==6 || selected_field==8 || selected_field==10) ? true : false );\n defaultField.style.background = ( (selected_field == 11 || selected_field==3 || selected_field==6 || selected_field==8) ? '#eee' : '' );\n\n // default value field data\n defaultField.value = (selected_field==" . intval($Array["TypeOfData_ID"]) . " ? '" . $db->escape($Array["DefaultState"]) . "' : '');\n }\n return false;\n }\n\n function nc_select_field() {\n var selected_field = document.getElementById('TypeOfData_ID').selectedIndex + 1 ;\n nc_field_additional_format (selected_field);\n nc_field_select_fs();\n return false;\n }\n\n function nc_field_select_fs() {\n var selected_fs = document.getElementById('Format_FS').selectedIndex + 1;\n document.getElementById('attachment').disabled = ( selected_fs != 3 );\n document.getElementById('download').disabled = ( selected_fs != 3 );\n return false;\n }\n\n function nc_field_select_string_format() {\n document.getElementById('div_field_string_protect_email').style.display = document.getElementById('Format_String').value == 'email' ? 'block' : 'none';\n }\n\n function nc_field_select_fck(element) {\n var \$this = \$nc(element);\n var \$panel_block = \$nc('#format-panel-block');\n if (\$this.val() == 2) {\n \$panel_block.hide();\n } else {\n \$panel_block.show();\n }\n }\n function nc_field_select_transliteration(element) {\n \$nc('#transliteration_field').change(function() {\n if (\$nc('#transliteration_field').val() == 'Keyword') {\n \$nc('#use_url_rules').prop('checked', true);\n }\n });\n var \$this = \$nc(element);\n var \$panel_block = \$nc('#transliteration-fields-panel-block');\n if (\$this.is(':checked')) {\n \$panel_block.show();\n if (\$nc('#transliteration_field').val() == 'Keyword') {\n \$nc('#use_url_rules').prop('checked', true);\n }\n } else {\n \$panel_block.hide();\n }\n }\n nc_field_select_fs();\n nc_field_select_string_format();\n </script>\n"; print "<fieldset>"; if ($FieldID) { print "<legend>" . ($Array["Description"] ? $Array["Description"] : $Array["Field_Name"]) . "</legend>"; } print "<br/><form method='post' action='" . $action . "' name='" . $FormName . "' id='" . $FormID . "'>"; $Format_FS = NC_FS_PROTECTED; // тип по ФС по умолчанию $format_text = nc_field_parse_format("", NC_FIELDTYPE_TEXT); // для textarea значения по умолчанию if ($FieldID) { if (!$isWidget) { print CONTROL_FIELD_LIST_NAMELAT . ":<br>" . nc_admin_input_simple('FieldName', $Array["Field_Name"], 50, '', "maxlength='64'") . "<br><br>"; } else { print CONTROL_FIELD_LIST_NAME . ": " . $Array["Field_Name"] . "<br><br>"; } switch ($Array['TypeOfData_ID']) { case NC_FIELDTYPE_FILE: // определим тип ФС $format_file_resize = nc_field_parse_resize_options($Array['Format']); $Array['Format'] = array_shift(explode(';', $Array['Format'])); $format_file = nc_field_parse_format($Array['Format'], $Array['TypeOfData_ID']); $Format_FS = $format_file['fs']; $file_attach = $format_file['disposition']; // закачиваемый или нет? $file_download = $format_file['download']; $Array['Format'] = nc_preg_replace('/(:?)(fs)(\\d+)/', '', $Array['Format']); // уберем из Format тип ФС $Array['Format'] = nc_preg_replace('/(:?)(download)/', '', $Array['Format']); // уберем download $Array['Format'] = nc_preg_replace('/(:?)((attachment)|(inline))/', '', $Array['Format']); // уберем attachment break; case NC_FIELDTYPE_TEXT: $format_text = nc_field_parse_format($Array['Format'], $Array['TypeOfData_ID']); break; case NC_FIELDTYPE_DATETIME: $format_date = nc_field_parse_format($Array['Format'], $Array['TypeOfData_ID']); $Array['Format'] = $format_date['type']; break; case NC_FIELDTYPE_STRING: $format_string = nc_field_parse_format($Array['Format'], $Array['TypeOfData_ID']); $Array['Format'] = $format_string['format']; $Array['UseTransliteration'] = $format_string['use_transliteration']; $Array['TransliterationField'] = $format_string['transliteration_field']; $Array['UseUrlRules'] = $format_string['use_url_rules']; break; case NC_FIELDTYPE_MULTIFILE: $format_file_resize = nc_field_parse_resize_options($Array['Format']); $Array['Format'] = array_shift(explode(';', $Array['Format'])); break; } } else { print CONTROL_FIELD_LIST_NAMELAT . ":<br>" . nc_admin_input_simple('FieldName', $Array["Field_Name"], 50, '', "maxlength='64'") . "<br><br>"; } print CONTROL_FIELD_LIST_DESCRIPTION . ":<br>" . nc_admin_input_simple('Description', htmlspecialchars_decode($Array["Description"]), 50, '', "maxlength='64'") . "<br><br>"; $openid_possibility = $nc_core->modules->get_by_keyword('auth') && nc_auth_openid_possibility(); if ($FieldID && $Array['TypeOfData_ID'] == 11 && $openid_possibility) { print "<input name='TypeOfData_ID' value='11' type='hidden'>"; } print CONTROL_FIELD_ONE_FTYPE . ":<br><select name='TypeOfData_ID' id='TypeOfData_ID' onchange='nc_select_field(); return false;'" . ($FieldID && $Array['TypeOfData_ID'] == 11 && $openid_possibility ? " disabled='disabled'" : NULL) . ">"; //print CONTROL_FIELD_ONE_FTYPE.":<br><select name='TypeOfData_ID' id='TypeOfData_ID' onchange='nc_select_field(); return false;'>"; for ($i = 1; $i <= count($field_type_name); $i++) { // Полe тиа "Связь с другими.." для системных полей не нужно if (($isSys || $isWidget) && $i === 9) { continue; } if ($i == 11 && $no_multifile) { continue; } print "<option " . ($Array["TypeOfData_ID"] == $i ? "selected" : "") . " value='" . $i . "'>" . $i . ": " . $field_type_name[$i] . "</option>\n"; } print "</select><br><br>"; $html = "<div id='div_format'>" . CONTROL_FIELD_ONE_FORMAT . ":<br>" . nc_admin_input_simple('Format', $Array["TypeOfData_ID"] != 3 ? $Array["Format"] : "", 50, '', "maxlength='255'") . "<br><br></div>"; $html .= "<div id='div_field_string'>" . nc_admin_select_simple(CONTROL_FIELD_ONE_FORMAT . ":<br/>", 'Format_String', array('' => CONTROL_FIELD_ONE_FORMAT_NONE, 'email' => CONTROL_FIELD_ONE_FORMAT_EMAIL, 'url' => CONTROL_FIELD_ONE_FORMAT_URL, 'password' => CONTROL_FIELD_ONE_FORMAT_PASSWORD, 'phone' => CONTROL_FIELD_ONE_FORMAT_PHONE, 'tags' => CONTROL_FIELD_ONE_FORMAT_TAGS), $Array["Format"], "id='Format_String' onchange='nc_field_select_string_format();'") . "<br>"; $html .= "<div id='div_field_string_protect_email'>"; $html .= nc_admin_checkbox_simple('protect_email', '', CONTROL_FIELD_ONE_PROTECT_EMAIL, $format_string['protect_email']); $html .= "</div>"; $options = GetTransliterateOptions($isSys ? "system" : ($isWidget ? "widget" : "class"), $FieldID, $Id, $systemTableId); if (count($options) > 0) { $html .= "<div id='div_field_string_use_transliteration'>"; $html .= nc_admin_checkbox_simple('use_transliteration', '1', CONTROL_FIELD_USE_TRANSLITERATION, $Array['UseTransliteration'], '', "onchange='nc_field_select_transliteration(this); return true;'"); $html .= "</div>"; $html .= "<div id='transliteration-fields-panel-block' style='" . ($Array['UseTransliteration'] == 1 ? '' : 'display: none;') . "'>"; $html .= nc_admin_select_simple(CONTROL_FIELD_TRANSLITERATION_FIELD . ":<br/>", 'transliteration_field', $options, $Array["TransliterationField"], "id='transliteration_field'", "onchange='alert('here'); return true;'") . "<br>"; $html .= nc_admin_checkbox_simple('use_url_rules', '1', CONTROL_FIELD_USE_URL_RULES, $Array['UseUrlRules'], ''); $html .= "</div>"; } $html .= "</div>"; // Вывод ограничений на загрузку файлов для тип поля Файл и множественный выбор файлов $html .= "<div id='div_upload_limits' style='display: none;'>" . CONTROL_FIELD_FILE_UPLOADS_LIMITS . "<br />\n post_max_size (" . CONTROL_FIELD_FILE_POSTMAXSIZE . "): " . ini_get('post_max_size') . " <br />\n upload_max_filesize (" . CONTROL_FIELD_FILE_UPLOADMAXFILESIZE . "): " . ini_get('upload_max_filesize') . "<br />\n max_file_uploads (" . CONTROL_FIELD_FILE_MAXFILEUPLOADS . "): " . ini_get('max_file_uploads') . "<br />\n <br /></div>"; // расширение формата для Файлов $html .= "<div id='div_field_file' style='display: none;'>\r\n" . CLASSIFICATOR_TYPEOFFILESYSTEM . ":\n <select name='Format_FS' id='Format_FS' onchange='nc_field_select_fs(); return false;' >\r\n\n <option value='" . NC_FS_SIMPLE . "' " . (NC_FS_SIMPLE == $Format_FS ? 'selected' : '') . ">" . CONTROL_FS_NAME_SIMPLE . "</option>\r\n\n <option value='" . NC_FS_ORIGINAL . "' " . (NC_FS_ORIGINAL == $Format_FS ? 'selected' : '') . ">" . CONTROL_FS_NAME_ORIGINAL . "</option>\r\n\n <option value='" . NC_FS_PROTECTED . "' " . (NC_FS_PROTECTED == $Format_FS ? 'selected' : '') . ">" . CONTROL_FS_NAME_PROTECTED . "</option>\r\n\n </select>\n <br />" . nc_admin_checkbox_simple('attachment', '', CONTROL_FIELD_ATTACHMENT, $file_attach, '', "disabled") . "\n <br/>" . nc_admin_checkbox_simple('download', '', CONTROL_FIELD_DOWNLOAD_COUNT, $file_download, '', "disabled") . "\n </div>"; // расширение формата для текста $html .= "<div id='div_field_text' style='display: none;'>\n <table class='admin_table' width='40%' >\n <col width='25%'/><col width='25%'/><col width='25%'/><col width='25%'/>\n <tr align='center'>\n <th></th>\n <th>" . CONTROL_CONTENT_SUBDIVISION_FUNCS_ACCESS_INHERIT . "</th>\n <th>" . CONTROL_CONTENT_SUBDIVISION_FUNCS_OBJ_YES . "</th>\n <th>" . CONTROL_CONTENT_SUBDIVISION_FUNCS_OBJ_NO . "</th>\n </tr>\n <tr align='center'>\n <td>" . CONTROL_CLASS_CLASS_OBJECTSLIST_SHOWOBJ_HTML . "</td>"; // разрешать HTML-теги for ($i = 0; $i <= 2; $i++) { $html .= "<td bgcolor='" . ($format_text['html'] == $i ? "#E7E7E7" : "#FFFFFF") . "'>" . nc_admin_radio_simple('format_html', $i, '', isset($Array['format_html']) && $Array['format_html'] == $i || $format_text['html'] == $i, '', "class='w'") . "\n </td>"; } $html .= "</tr><tr align='center'>\n <td>" . CONTROL_CLASS_CLASS_OBJECTSLIST_SHOWOBJ_BR . "</td>"; // перенос строки for ($i = 0; $i <= 2; $i++) { $html .= "<td bgcolor='" . ($format_text['br'] == $i ? "#E7E7E7" : "#FFFFFF") . "'>" . nc_admin_radio_simple('format_br', $i, '', isset($Array['format_br']) && $Array['format_br'] == $i || $format_text['br'] == $i, '', "class='w'") . "\n </td>"; } $html .= "\n </tr><tr align='center'>\n <td>" . CONTROL_FIELD__EDITOR_EMBED_TO_FIELD . "</td>"; // встроить редактор for ($i = 0; $i <= 2; $i++) { $html .= "<td bgcolor='" . ($format_text['fck'] == $i ? "#E7E7E7" : "#FFFFFF") . "'>" . nc_admin_radio_simple('format_fck', $i, '', isset($Array['format_fck']) && $Array['format_fck'] == $i || $format_text['fck'] == $i, '', "class='w' onchange='nc_field_select_fck(this); return true;'") . "\n </td>"; } $html .= "</tr></table><br/>"; $html .= CONTROL_FIELD__TEXTAREA_SIZE . ":<br/>\n <table class='admin_table' width='40%' >\n <col width='50%'/><col width='50%'/>\n <tr align='center'>\n <td>" . CONTROL_FIELD_HEIGHT . "</td>\n <td>" . nc_admin_input_simple('format_height', isset($Array['format_height']) ? $Array['format_height'] : $format_text['rows'], 0, 'width:100%') . "</td></tr>\n <tr align='center'>\n <td>" . CONTROL_FIELD_WIDTH . "</td>\n <td>" . nc_admin_input_simple('format_width', isset($Array['format_height']) ? $Array['format_width'] : $format_text['cols'], 0, 'width:100%') . "</td>\n </tr>\n </table>\n <br />"; $panels = array(0 => CONTROL_FIELD_PANELS_DEFAULT); $sql = "SELECT `Wysiwyg_Panel_ID`, `Name` FROM `Wysiwyg_Panel` " . "WHERE `Editor` = 'ckeditor' " . "ORDER BY `Wysiwyg_Panel_ID` ASC"; foreach ((array) $db->get_results($sql, ARRAY_A) as $panel) { $panels[$panel['Wysiwyg_Panel_ID']] = $panel['Name']; } $html .= "<div id='format-panel-block' style='" . ($format_text['fck'] == 2 ? 'display: none;' : '') . "'>" . CONTROL_FIELD_PANELS . ":<br><div class='nc-select'>" . nc_admin_select_simple('', 'format_panel', $panels, isset($Array['format_panel']) ? $Array['format_panel'] : $format_text['panel']) . "<i class='nc-caret'></i></div><br><br /></div>"; $html .= nc_admin_checkbox_simple('format_typo', 1, CONTROL_FIELD_TYPO, isset($Array['format_typo']) ? $Array['format_typo'] : $format_text['typo']) . "\n <br />" . nc_admin_checkbox_simple('format_bbcode', 1, CONTROL_FIELD_BBCODE_ENABLED, isset($Array['format_bbcode']) ? $Array['format_bbcode'] : $format_text['bbcode']) . "\n <br/><br/>\n </div>"; $html .= "<div id='div_field_date' style='display: none'>" . nc_admin_checkbox_simple('use_calendar', 1, CONTROL_FIELD_USE_CALENDAR, false, 'format_use_calendar', $format_date['calendar'] ? "checked='checked'" : "") . "\n </div><br/>"; $html .= "<div id='div_file_resize' style='display: none'>"; $html .= nc_admin_checkbox_simple('format_use_resize', 1, CONTROL_FIELD_MULTIFIELD_USE_IMAGE_RESIZE, $format_file_resize['use_resize']); $html .= "<div>"; $html .= CONTROL_FIELD_MULTIFIELD_IMAGE_WIDTH . ": " . nc_admin_input_simple('format_resize_width', $format_file_resize['resize_width'], 10) . " "; $html .= CONTROL_FIELD_MULTIFIELD_IMAGE_HEIGHT . ": " . nc_admin_input_simple('format_resize_height', $format_file_resize['resize_height'], 10); $html .= "</div><br>"; $html .= nc_admin_checkbox_simple('format_use_crop', 1, CONTROL_FIELD_MULTIFIELD_USE_IMAGE_CROP, $format_file_resize['use_crop']); $html .= "<div>"; $html .= "X0: " . nc_admin_input_simple('format_crop_x0', $format_file_resize['crop_x0'], 10) . " "; $html .= "Y0: " . nc_admin_input_simple('format_crop_y0', $format_file_resize['crop_y0'], 10) . "<br>"; $html .= "X1: " . nc_admin_input_simple('format_crop_x1', $format_file_resize['crop_x1'], 10) . " "; $html .= "Y1: " . nc_admin_input_simple('format_crop_y1', $format_file_resize['crop_y1'], 10); $html .= "</div><br>"; $html .= nc_admin_checkbox_simple('format_crop_ignore', 1, CONTROL_FIELD_MULTIFIELD_CROP_IGNORE, $format_file_resize['crop_ignore']); $html .= "<div>"; $html .= CONTROL_FIELD_MULTIFIELD_IMAGE_WIDTH . ": " . nc_admin_input_simple('format_crop_ignore_width', $format_file_resize['crop_ignore_width'], 10) . " "; $html .= CONTROL_FIELD_MULTIFIELD_IMAGE_HEIGHT . ": " . nc_admin_input_simple('format_crop_ignore_height', $format_file_resize['crop_ignore_height'], 10); $html .= "</div><br/>"; $html .= nc_admin_checkbox_simple('format_use_preview', 1, CONTROL_FIELD_MULTIFIELD_USE_IMAGE_PREVIEW, $format_file_resize['use_preview']); $html .= "<div>"; $html .= CONTROL_FIELD_MULTIFIELD_IMAGE_WIDTH . ": " . nc_admin_input_simple('format_preview_width', $format_file_resize['preview_width'], 10) . " "; $html .= CONTROL_FIELD_MULTIFIELD_IMAGE_HEIGHT . ": " . nc_admin_input_simple('format_preview_height', $format_file_resize['preview_height'], 10); $html .= "</div>"; $html .= "</div><br/>"; echo $html; echo nc_admin_textarea_simple('Extension', $Array['Extension'], CONTROL_FIELD_ONE_EXTENSION . ":<br>", 7, 0, '', 'soft'); echo "<br><br>"; print nc_admin_checkbox_simple('NotNull', 1, CONTROL_FIELD_ONE_MUSTBE, $Array["NotNull"], 'notn') . "<br>"; if ($isSys) { print nc_admin_checkbox_simple('Inheritance', 1, CONTROL_FIELD_ONE_INHERITANCE, $Array["Inheritance"], 'inhr') . "<br>"; } else { print nc_admin_checkbox_simple('DoSearch', 1, CONTROL_FIELD_ONE_INDEX, $Array["DoSearch"] && $Array['TypeOfData_ID'] != 9, 'dosr', $Array['TypeOfData_ID'] != 9 ? " disabled='disabled'" : "") . "<br>"; print nc_admin_checkbox_simple('InTableView', 1, CONTROL_FIELD_ONE_IN_TABLE_VIEW, $Array["InTableView"]) . "<br>"; } print '<br>'; print CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_PRIORITY . ": " . nc_admin_input_simple('Priority', $Array["Priority"] + 0, 3, '', "maxlength='5'") . "<br><br>"; print CONTROL_FIELD_ONE_DEFAULT . "*:<br>"; print nc_admin_input_simple('DefaultState', $Array["DefaultState"], 50, '', "id='DefaultState' maxlength='255'") . "\n"; print "<br>* " . CONTROL_FIELD_ONE_DEFAULT_NOTE . ".<br><br>\n"; print "<table class='admin_table' width='60%' >" . "<col width='25%'/><col width='25%'/><col width='25%'/><col width='25%'/>" . "<tr><td></td>"; if (!$Array["TypeOfEdit_ID"]) { $Array["TypeOfEdit_ID"] = 1; } for ($i = 1; $i <= count($type_of_edit_name); $i++) { print "<td text-align:center'><label for='mod" . $i . "'>" . $type_of_edit_name[$i] . "</label></td>"; } print "</tr><tr><td text-align:center'>" . CONTROL_FIELD_ONE_ACCESS . "</td>"; for ($i = 1; $i <= count($type_of_edit_name); $i++) { print "<td text-align:center'>" . nc_admin_radio_simple('TypeOfEdit_ID', $i, '', $Array["TypeOfEdit_ID"] == $i, "mod" . $i, "class='w'") . "</td>"; } print "</tr>" . "</table>"; // js для визуальной настройки формата print $js; if (!$FieldID) { $UI_CONFIG->actionButtons[] = array("id" => "submit", "caption" => CONTROL_FIELD_LIST_ADD, "action" => "mainView.submitIframeForm('" . $FormID . "')"); } else { $UI_CONFIG->actionButtons[] = array("id" => "submit", "caption" => CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_SAVE, "action" => "mainView.submitIframeForm('" . $FormID . "')"); } $name = $isSys ? "SystemTableID" : ($isWidget ? "widgetclass_id" : "ClassID"); if ($Id) { print "<input type='hidden' name='" . $name . "' value='" . $Id . "'>\n"; print "<input type='hidden' name='phase' value='3'>\n"; } else { if ($isSys) { print "<input type='hidden' name='SystemTableID' value='" . $Id . "'>\n"; } print "<input type='hidden' name='FieldID' value='" . $FieldID . "'>\n"; print "<input type='hidden' name='phase' value='5'>\n"; } print $Additional; print $nc_core->token->get_input(); print "<input type='hidden' name='isSys' value='" . $isSys . "'>\n"; print "<input type='hidden' name='fs' value='" . +$_REQUEST['fs'] . "'>"; print "<input type='submit' class='hidden'>\n"; print "<input type='hidden' name='isWidget' value='{$isWidget}' />"; print "</form>\n"; print "</fieldset>"; return true; }