function porto_product_get_postdata() { global $porto_settings, $product_meta_boxes, $product_view_meta_boxes, $product_skin_meta_boxes, $product_cat_meta_boxes; $product_columns = porto_ct_product_columns(); $addlinks_pos = porto_ct_category_addlinks_pos(); // Product View Meta Boxes $product_view_meta_boxes = porto_ct_default_meta_view_boxes(); // Sidebar $product_view_meta_boxes['sidebar']['default'] = 'woo-product-sidebar'; // Product Skin Meta Boxes $product_skin_meta_boxes = porto_ct_default_meta_skin_boxes(); // Product Meta Boxes $product_meta_boxes = array("custom_tab_title1" => array("name" => "custom_tab_title1", "title" => __("Custom Tab Title 1", 'porto'), "desc" => __("Input the custom tab title.", 'porto'), "type" => "text"), "custom_tab_content1" => array("name" => "custom_tab_content1", "title" => __("Custom Tab Content 1", 'porto'), "desc" => __("Input the custom tab content.", 'porto'), "type" => "editor"), "custom_tab_title2" => array("name" => "custom_tab_title2", "title" => __("Custom Tab Title 2", 'porto'), "desc" => __("Input the custom tab title.", 'porto'), "type" => "text"), "custom_tab_content2" => array("name" => "custom_tab_content2", "title" => __("Custom Tab Content 2", 'porto'), "desc" => __("Input the custom tab content.", 'porto'), "type" => "editor")); // Category Meta Boxes $product_cat_meta_boxes = porto_ct_default_meta_view_boxes(); // Sidebar $product_cat_meta_boxes['sidebar']['default'] = 'woo-category-sidebar'; // Columns $product_cat_meta_boxes = array_insert_after('sidebar', $product_cat_meta_boxes, "product_cols", array("name" => "product_cols", "title" => __("Product Columns", 'porto'), "type" => "select", "options" => $product_columns)); $product_cat_meta_boxes = array_insert_after('product_cols', $product_cat_meta_boxes, "addlinks_pos", array("name" => "addlinks_pos", "title" => __("Add Links Position", 'porto'), "desc" => __('Select position of add to cart, add to wishlist, quickview.', 'porto'), "type" => "select", "options" => $addlinks_pos)); // Category Image $product_cat_meta_boxes = array_insert_after('content_inner_bottom', $product_cat_meta_boxes, "category_image", array("name" => "category_image", "title" => __("Category Image", 'porto'), "type" => "upload")); if (isset($porto_settings['show-category-skin']) && $porto_settings['show-category-skin']) { $product_cat_meta_boxes = array_merge($product_cat_meta_boxes, porto_ct_default_meta_skin_boxes()); } }
function execute() { // establish a new table object $this->obj_table = new table(); $this->obj_table->language = $_SESSION["user"]["lang"]; $this->obj_table->tablename = "service_groups"; // define all the columns and structure $this->obj_table->add_column("standard", "group_name", ""); $this->obj_table->add_column("standard", "group_description", ""); // defaults $this->obj_table->columns = array("group_name", "group_description"); $this->obj_table->columns_order = array("id_parent", "group_name"); // define SQL structure $this->obj_table->sql_obj->prepare_sql_settable("service_groups"); $this->obj_table->sql_obj->prepare_sql_addfield("id", ""); $this->obj_table->sql_obj->prepare_sql_addfield("id_parent", ""); // fetch all the service group information $this->obj_table->generate_sql(); $this->obj_table->load_data_sql(); // sort the data by parent ID and index by id, add a prefix to make it associative $sorted_data = array(); foreach ($this->obj_table->data as $data_row) { $data_row['level'] = 0; $sorted_data['pid_' . $data_row['id_parent']]['id_' . $data_row['id']] = $data_row; } $regenerated_list = array(); // add the items with no parent and unset the parent group $regenerated_list = $sorted_data['pid_0']; unset($sorted_data['pid_0']); // loop while there is still sorted data remaining while (count($sorted_data) > 0) { // loop through the sorted data foreach ($sorted_data as $sorted_key => $sorted_rows) { // obtain the parent ID from the key $parent_id = (int) str_replace("pid_", '', $sorted_key); if (isset($regenerated_list['id_' . $parent_id])) { // generate the target parent key, increment the level and modify the name of the items $parent_key = "id_{$parent_id}"; $parent_level = $regenerated_list['id_' . $parent_id]['level']; $set_level = $parent_level + 1; foreach ($sorted_rows as $row_key => $row) { $sorted_rows[$row_key]['level'] = $set_level; $sorted_rows[$row_key]['group_name'] = str_repeat("-", $set_level) . " " . $row['group_name']; } $regenerated_list = array_insert_after($regenerated_list, $parent_key, $sorted_rows); // unset the sorted data after adding it to the new list. unset($sorted_data[$sorted_key]); } } } $this->obj_table->data = array_values($regenerated_list); //echo "<pre>".print_r( $sorted_data, true ).//"</pre>"; //echo "<pre>".print_r( $regenerated_list, true )."</pre>"; }
function porto_product_get_postdata() { global $porto_settings, $product_meta_boxes, $product_view_meta_boxes, $product_skin_meta_boxes, $product_cat_meta_boxes; $view_mode = porto_ct_category_view_mode(); $product_columns = porto_ct_product_columns(); $addlinks_pos = porto_ct_category_addlinks_pos(); // Product View Meta Boxes $product_view_meta_boxes = porto_ct_default_meta_view_boxes(); // Sidebar $product_view_meta_boxes['sidebar']['default'] = 'woo-product-sidebar'; // Product Skin Meta Boxes $product_skin_meta_boxes = porto_ct_default_meta_skin_boxes(); $custom_tabs_count = isset($porto_settings['product-custom-tabs-count']) ? $porto_settings['product-custom-tabs-count'] : '2'; $custom_tabs = array(); if ($custom_tabs_count) { for ($i = 0; $i < $custom_tabs_count; $i++) { $index = $i + 1; // Custom Tab Title $custom_tabs['custom_tab_title' . $index] = array("name" => "custom_tab_title" . $index, "title" => sprintf(__('Custom Tab Title %d', 'porto'), $index), "desc" => __("Input the custom tab title.", 'porto'), "type" => "text"); // Content Tab Content $custom_tabs['custom_tab_content' . $index] = array("name" => "custom_tab_content" . $index, "title" => sprintf(__('Custom Tab Content %d', 'porto'), $index), "desc" => __("Input the custom tab content.", 'porto'), "type" => "editor"); } } // Product Meta Boxes $product_meta_boxes = array_merge($custom_tabs, array("product_share" => array("name" => "product_share", "title" => __("Share", 'porto'), "type" => "radio", "default" => "", "options" => array_merge(porto_ct_share_options())), "product_more_link" => array("name" => "product_more_link", "title" => __("Read More Link in Catalog Mode", 'porto'), "type" => "text"))); // Category Meta Boxes $product_cat_meta_boxes = porto_ct_default_meta_view_boxes(); // Sidebar $product_cat_meta_boxes['sidebar']['default'] = 'woo-category-sidebar'; // View Mode $product_cat_meta_boxes = array_insert_after('sidebar', $product_cat_meta_boxes, "view_mode", array("name" => "view_mode", "title" => __("View Mode", 'porto'), "type" => "radio", "options" => $view_mode)); // Columns $product_cat_meta_boxes = array_insert_after('view_mode', $product_cat_meta_boxes, "product_cols", array("name" => "product_cols", "title" => __("Product Columns", 'porto'), "type" => "select", "options" => $product_columns)); $product_cat_meta_boxes = array_insert_after('product_cols', $product_cat_meta_boxes, "addlinks_pos", array("name" => "addlinks_pos", "title" => __("Add Links Position", 'porto'), "desc" => __('Select position of add to cart, add to wishlist, quickview.', 'porto'), "type" => "select", "options" => $addlinks_pos)); // Category Image $product_cat_meta_boxes = array_insert_after('addlinks_pos', $product_cat_meta_boxes, "category_image", array("name" => "category_image", "title" => __("Category Image", 'porto'), "type" => "upload")); if (isset($porto_settings['show-category-skin']) && $porto_settings['show-category-skin']) { $product_cat_meta_boxes = array_merge($product_cat_meta_boxes, porto_ct_default_meta_skin_boxes()); } }
function sql_get_grouped_structure($sql_query) { log_write("debug", "inc_sql", "Executing function sql_get_grouped({$sql_query})"); // so many bugs are caused by forgetting to request fields from the DB as "value", so // this function has been added. if (!strstr($sql_query, 'value_id') || !strstr($sql_query, 'value_key') || !strstr($sql_query, 'value_parent')) { die("Error: SQL queries to sql_get_singlevalue must request the field with the name of \"value_id\", \"value_key\" and \"value_parent\". Eg: \"SELECT id as value_id, name as value_key, parent as value_parent FROM mytable WHERE id=foo\""); } // query the database $obj_sql = new sql_query(); $obj_sql->string = $sql_query; $obj_sql->execute(); if ($obj_sql->num_rows()) { $obj_sql->fetch_array(); // sort the data by parent ID and index by id, add a prefix to make it associative $sorted_data = array(); foreach ($obj_sql->data as $data_row) { $data_clean = array(); $data_clean['id'] = $data_row["value_id"]; $data_clean['id_parent'] = $data_row["value_parent"]; $data_clean['level'] = 0; $data_clean['key_orig'] = $data_row["value_key"]; $data_clean['key_formatted'] = $data_row["value_key"]; $sorted_data['pid_' . $data_row['value_parent']]['id_' . $data_row['value_id']] = $data_clean; } $regenerated_list = array(); // add the items with no parent and unset the parent group $regenerated_list = $sorted_data['pid_0']; unset($sorted_data['pid_0']); // loop while there is still sorted data remaining while (count($sorted_data) > 0) { // loop through the sorted data foreach ($sorted_data as $sorted_key => $sorted_rows) { // obtain the parent ID from the key $parent_id = (int) str_replace("pid_", '', $sorted_key); if (isset($regenerated_list['id_' . $parent_id])) { // generate the target parent key, increment the level and modify the name of the items $parent_key = "id_{$parent_id}"; $parent_level = $regenerated_list['id_' . $parent_id]['level']; $set_level = $parent_level + 1; foreach ($sorted_rows as $row_key => $row) { $sorted_rows[$row_key]['level'] = $set_level; $sorted_rows[$row_key]['key_formatted'] = str_repeat("-", $set_level) . " " . $row['key_orig']; } $regenerated_list = array_insert_after($regenerated_list, $parent_key, $sorted_rows); // unset the sorted data after adding it to the new list. unset($sorted_data[$sorted_key]); } } } return $regenerated_list; } // end if rows return 0; }
public function add_custom_post_columns($columns) { $place = 'title'; foreach ($this->columns['add'] as $key => $col) { if (!isset($columns[$key])) { $columns = array_insert_after($place, $columns, $key, $col); $place = $key; } } return $columns; }