protected function _buildBranch($parent_id, $level = 0) { $result = $level === 0 && $this->parent_group_apply_to_root === true || $level > 0 ? $this->parent_group_start_string : null; if (isset($this->_data[$parent_id])) { foreach ($this->_data[$parent_id] as $category_id => $category) { $result .= '<div class="panel panel-default">'; $result .= ' <div class="panel-heading">'; $result .= ' <h2 class="panel-title">'; $result .= ' <a data-toggle="collapse" data-parent="#accordion" href="#collapse_' . $category_id . '">'; $result .= $category['selectors_name']; $result .= ' </a>'; $result .= tep_draw_form('delete_css', FILENAME_BTS_CSS, 'selID=' . $category_id . '&action=deleteconfirm', 'post', 'class="pull-right"') . tep_draw_button(IMAGE_DELETE, 'trash', null, 'primary') . '</form>'; $result .= ' </h2>'; $result .= ' </div>'; $result .= ' <div id="collapse_' . $category_id . '" class="panel-collapse collapse">'; $result .= ' <div class="panel-body">'; $result .= tep_draw_form('css', FILENAME_BTS_CSS, 'selID=' . $category_id . '&action=save', 'post', 'id="' . $category_id . '"'); $result .= TEXT_CSS_SELECTOR_NAME . ' ' . tep_draw_input_field('selectors_name', $category['selectors_name'], 'class="form-control"') . '<br />'; $result .= '<table class="table table-hover table-striped table-bordered input_new_edit_fields_wrap">'; $result .= '<tr><th>' . TEXT_PROPERTY_ELEMENT . '</td><th>' . TEXT_PROPERTY_VALUE . '</th><th><button id="' . $category_id . '" class="add_new_edit_field_button"> + </button></th></tr>'; $properties = tep_get_properties($category_id); for ($i = 0, $n = sizeof($properties); $i < $n; $i++) { $result .= '<tr id="' . $properties[$i]['properties_id'] . '">'; $result .= ' <td>' . tep_draw_input_field('property_element[' . $properties[$i]['properties_id'] . ']', tep_get_property_element($category_id, $properties[$i]['properties_id']), 'class="form-control"') . '</td>'; $result .= ' <td>' . tep_draw_input_field('property_value[' . $properties[$i]['properties_id'] . ']', tep_get_property_value($category_id, $properties[$i]['properties_id']), 'class="form-control"') . '</td>'; $result .= ' <td><a href="#" class="remove_new_edit_field">Remove</a></td>'; $result .= '</tr>'; } $result .= ' </table>'; $result .= '<br />' . tep_draw_button(IMAGE_SAVE, 'disk', null, 'primary') . tep_draw_button(IMAGE_CANCEL, 'close', tep_href_link(FILENAME_BTS_CSS)); $result .= ' </form>'; $result .= ' </div>'; $result .= ' </div>'; $result .= '</div>'; if (isset($this->_data[$category_id]) && ($this->max_level == '0' || $this->max_level > $level + 1)) { $result .= $this->_buildBranch($category_id, $level + 1); } } } $result .= $level === 0 && $this->parent_group_apply_to_root === true || $level > 0 ? $this->parent_group_end_string : null; return $result; }
for ($i = 0, $n = sizeof($property_element); $i < $n; $i++) { tep_db_query('insert into ' . TABLE_BTS_CSS_PROPERTIES . ' (selectors_id, property_element, property_value ) values ("' . $selectors_id . '", "' . $property_element[$i] . '", "' . $property_value[$i] . '")'); } //END inserting multiple PROPERTY fields tep_redirect(tep_href_link(FILENAME_BTS_CSS)); break; case 'save': if (isset($HTTP_GET_VARS['selID'])) { $selectors_id = tep_db_prepare_input($HTTP_GET_VARS['selID']); } $selectors_name = tep_db_prepare_input($HTTP_POST_VARS['selectors_name']); $sql_data_array = array('selectors_name' => $selectors_name); $update_sql_data = array('last_modified' => 'now()'); $sql_data_array = array_merge($sql_data_array, $update_sql_data); tep_db_perform(TABLE_BTS_CSS_SELECTORS, $sql_data_array, 'update', "selectors_id = '" . (int) $selectors_id . "'"); $properties = tep_get_properties($selectors_id); for ($i = 0, $n = sizeof($properties); $i < $n; $i++) { $property_element_array = tep_db_prepare_input($HTTP_POST_VARS['property_element']); $property_value_array = tep_db_prepare_input($HTTP_POST_VARS['property_value']); $property_id = tep_db_prepare_input($properties[$i]['properties_id']); $sql_data_array = array('property_element' => $property_element_array[$property_id], 'property_value' => $property_value_array[$property_id]); tep_db_perform(TABLE_BTS_CSS_PROPERTIES, $sql_data_array, 'update', "properties_id = '" . (int) $property_id . "' and selectors_id = '" . (int) $selectors_id . "'"); } tep_redirect(tep_href_link(FILENAME_BTS_CSS)); break; case 'deleteconfirm': if (isset($HTTP_GET_VARS['selID'])) { $selectors_id = tep_db_prepare_input($HTTP_GET_VARS['selID']); } tep_db_query("delete from " . TABLE_BTS_CSS_SELECTORS . " where selectors_id = '" . (int) $selectors_id . "'"); tep_db_query("delete from " . TABLE_BTS_CSS_PROPERTIES . " where selectors_id = '" . (int) $selectors_id . "'");
$contents[] = array('text' => '<br />' . TEXT_CSS_SELECTOR_NAME . '<br />' . tep_draw_input_field('selectors_name')); $css_inputs_string = '<table class="input_fields_wrap">'; $css_inputs_string .= '<tr><th>' . TEXT_PROPERTY_ELEMENT . '</td><th> : </th><th>' . TEXT_PROPERTY_VALUE . '</th><th><button class="add_field_button"> + </button></th></tr>'; $css_inputs_string .= '<tr><td>' . tep_draw_input_field('property_element[]') . '</td><td>:</td><td>' . tep_draw_input_field('property_value[]') . '</td></tr>'; $css_inputs_string .= '</table>'; $contents[] = array('text' => '<br />' . $css_inputs_string); $contents[] = array('align' => 'center', 'text' => '<br />' . tep_draw_button(IMAGE_SAVE, 'disk', null, 'primary') . tep_draw_button(IMAGE_CANCEL, 'close', tep_href_link(FILENAME_BTS_CSS, 'page=' . $HTTP_GET_VARS['page'] . '&selID=' . $HTTP_GET_VARS['selID']))); break; case 'edit': $heading[] = array('text' => '<strong>' . TEXT_HEADING_EDIT_CSS . '</strong>'); $contents = array('form' => tep_draw_form('css', FILENAME_BTS_CSS, 'page=' . $HTTP_GET_VARS['page'] . '&selID=' . $cssInfo->selectors_id . '&action=save', 'post')); $contents[] = array('text' => TEXT_EDIT_INTRO); $contents[] = array('text' => '<br />' . TEXT_CSS_SELECTOR_NAME . '<br />' . tep_draw_input_field('selectors_name', $cssInfo->selectors_name)); $css_inputs_string = '<table class="input_new_edit_fields_wrap">'; $css_inputs_string .= '<tr><th>' . TEXT_PROPERTY_ELEMENT . '</td><th> : </th><th>' . TEXT_PROPERTY_VALUE . '</th><th><button id="' . $cssInfo->selectors_id . '" class="add_new_edit_field_button"> + </button></th></tr>'; $properties = tep_get_properties($cssInfo->selectors_id); for ($i = 0, $n = sizeof($properties); $i < $n; $i++) { $css_inputs_string .= '<tr id="' . $properties[$i]['properties_id'] . '"><td>' . tep_draw_input_field('property_element[' . $properties[$i]['properties_id'] . ']', tep_get_property_element($cssInfo->selectors_id, $properties[$i]['properties_id'])) . '</td><td>:</td><td> ' . tep_draw_input_field('property_value[' . $properties[$i]['properties_id'] . ']', tep_get_property_value($cssInfo->selectors_id, $properties[$i]['properties_id'])) . '</td><td><a href="#" class="remove_new_edit_field">Remove</a></td></tr>'; } $css_inputs_string .= '</table>'; $contents[] = array('text' => '<br />' . $css_inputs_string); $contents[] = array('align' => 'center', 'text' => '<br />' . tep_draw_button(IMAGE_SAVE, 'disk', null, 'primary') . tep_draw_button(IMAGE_CANCEL, 'close', tep_href_link(FILENAME_BTS_CSS, 'page=' . $HTTP_GET_VARS['page'] . '&selID=' . $cssInfo->selectors_id))); break; case 'delete': $heading[] = array('text' => '<strong>' . TEXT_HEADING_DELETE_CSS . '</strong>'); $contents = array('form' => tep_draw_form('css', FILENAME_BTS_CSS, 'page=' . $HTTP_GET_VARS['page'] . '&selID=' . $cssInfo->selectors_id . '&action=deleteconfirm')); $contents[] = array('text' => TEXT_DELETE_INTRO); $contents[] = array('text' => '<br /><strong>' . $cssInfo->selectors_name . '</strong>'); $contents[] = array('align' => 'center', 'text' => '<br />' . tep_draw_button(IMAGE_DELETE, 'trash', null, 'primary') . tep_draw_button(IMAGE_CANCEL, 'close', tep_href_link(FILENAME_BTS_CSS, 'page=' . $HTTP_GET_VARS['page'] . '&selID=' . $cssInfo->selectors_id))); break; default: