public function save_fields($params = null, $only_isset_post = false) { foreach ($this->template->fields->standart as $field => $tmp) { if (!$only_isset_post || isset($_POST[$field])) { nc_save_file($this->template->fields->get_path($field), stripslashes($params ? $params[$field] : $_POST[$field])); } } }
public function save_fields($fields, $template = null) { $template = $template ? $template : $this->template; foreach ($fields as $name => $value) { nc_save_file($template->fields->get_path($name), $value); } nc_tpl_parser::parts2main($template); }
public function create($type, $settings) { $path = $this->template->path_to_root_folder . '/' . $this->id . '/' . $type; nc_create_folder(nc_standardize_path_to_folder($path)); foreach ($settings as $field_name => $tmp) { nc_save_file(nc_standardize_path_to_file($path . '/' . $field_name . $this->template->extension), $settings[$field_name]); } }
public function convert($ClassID, $action = 'convert') { $nc_core = nc_Core::get_object(); $db = $nc_core->db; $fs = $action == 'convert' ? 1 : 0; if ($action == 'convert') { $this->db->query("UPDATE `Class` SET `File_Mode` = 1, `File_Path` = IF(`ClassTemplate` > 0, CONCAT('/', `ClassTemplate`, '/', `Class_ID`,'/'), CONCAT('/', `Class_ID`,'/')) WHERE `Class_ID` = " . $ClassID . " OR `ClassTemplate` = " . $ClassID); } if ($this->db->errno) { return nc_print_status(CONTROL_CLASS_CONVERT_DB_ERROR, 'error', null, 1); } $classes_data = $this->db->get_results("SELECT * FROM `Class` WHERE `Class_ID` = " . $ClassID . " OR `ClassTemplate` = " . $ClassID . " ORDER BY `ClassTemplate` ASC", ARRAY_A); foreach ($classes_data as $class_data) { $templates = $this->get_class_templates_list(); //save tpls $class_editor = new nc_class_editor($nc_core->CLASS_TEMPLATE_FOLDER, $db); $class_editor->load($class_data['ClassTemplate']); $path = $class_editor->get_absolute_path() . $class_data['Class_ID'] . "/class_v40_backup.html"; if ($action == 'convert') { $new_temlates = $this->convert_class_templates($class_data); $class_editor->save_new_class($class_data['Class_ID'], $new_temlates); foreach ($templates as $field_name => $tmp) { $fields[$field_name] = "<!-- {$field_name} -->" . $class_data[$field_name] . "<!-- /{$field_name} -->"; } $backup_content = join("\n\n", $fields); nc_save_file($path, $backup_content); } else { $restore_content = nc_check_file($path) ? nc_get_file($path) : false; if (!$restore_content) { return nc_print_status(CONTROL_CLASS_CONVERT_UNDO_FILE_ERROR, 'error', null, 1); } foreach ($templates as $field_name => $tmp) { if (preg_match("#<!-- ?{$field_name} ?-->(.*)<!-- ?/ ?{$field_name} ?-->#is", $restore_content, $matches)) { $restored_templates[$field_name] = $matches[1]; } } if ($restored_templates && is_array($restored_templates)) { $query = array(); foreach ($restored_templates as $field_name => $tmp) { $query[] = "`" . $field_name . "` = '" . $db->prepare($tmp) . "'"; } // сообственно, добавление $SQL = "\nUPDATE `Class`"; $SQL .= "\n SET `File_Mode` = 0 , " . join(",\n ", $query); $SQL .= "\n WHERE `Class_ID` = " . $class_data['Class_ID']; $this->db->query($SQL); if ($this->db->errno) { return nc_print_status(CONTROL_CLASS_CONVERT_DB_ERROR, 'error', null, 1); } } } $message = nc_print_status(CONTROL_CLASS_CONVERT_OK, 'OK', null, 1); $message .= "<a href='index.php?phase=4&ClassID=" . $ClassID . "&fs=" . $fs . "'>" . CONTROL_CLASS_CONVERT_OK_GOEDIT . "</a>"; } return $message; //no errors }
public function save_fields($post_fields) { $magic_quotes = get_magic_quotes_gpc(); foreach ($this->template->fields->standart as $field_name => $tmp) { $field_key = $this->template->type . '_' . $field_name; if (isset($post_fields[$field_key])) { $data = $magic_quotes ? stripslashes($post_fields[$field_key]) : $post_fields[$field_key]; nc_save_file($this->template->fields->get_path($field_name), $data); } } }
public function save_fields($only_isset_post = false, $template = null, $fld_content = null) { if (null == $template) { $template = $this->template; } if ($fld_content === null) { $fld_content = nc_core('input')->fetch_post(); } foreach ($template->fields->standart as $field => $tmp) { if (!$only_isset_post || isset($fld_content[$field])) { if ($field == 'RecordTemplate') { $fld_content['RecordTemplate'] = nc_get_string_service_prefix_for_RecordTemplate() . $fld_content['RecordTemplate'] . nc_get_string_service_suffix_for_RecordTemplate(); } nc_save_file($template->fields->get_path($field), $fld_content[$field]); } } nc_tpl_parser::parts2main($template); }
/** * @return $this */ public function save() { if ($this->main) { nc_save_file($this->template->fields->get_path($this->template->type), $this->main); } foreach ($this->fields as $field_name => $content) { if ($content === null) { continue; } nc_save_file($this->template->fields->get_path($field_name), $content); } return $this; }