Commit 1c16d433 authored by John Punzalan's avatar John Punzalan

Update ESI, change ability to tags

parent 299c6d2c
......@@ -226,8 +226,8 @@ class Esi_Management_Admin {
$plugin_admin_region = new Esi_Management_Region( $this->plugin_name, $this->version );
add_submenu_page( $this->plugin_name, __( 'Region', 'esi' ), __( 'Region', 'esi' ), 'manage_options', 'esi-management-region', array( $plugin_admin_region, 'plugin_page' ) );
$plugin_admin_ability = new Esi_Management_Ability( $this->plugin_name, $this->version );
add_submenu_page( $this->plugin_name, __( 'Ability', 'esi' ), __( 'Ability', 'esi' ), 'manage_options', 'esi-management-ability', array( $plugin_admin_ability, 'plugin_page' ) );
$plugin_admin_tag = new Esi_Management_Tag( $this->plugin_name, $this->version );
add_submenu_page( $this->plugin_name, __( 'Tag', 'esi' ), __( 'Tag', 'esi' ), 'manage_options', 'esi-management-tag', array( $plugin_admin_tag, 'plugin_page' ) );
$plugin_admin_patent = new Esi_Management_Patent( $this->plugin_name, $this->version );
add_submenu_page( $this->plugin_name, __( 'Patent', 'esi' ), __( 'Patent', 'esi' ), 'manage_options', 'esi-management-patent', array( $plugin_admin_patent, 'plugin_page' ) );
......
......@@ -55,7 +55,7 @@ class Esi_Management_Entity_Form {
$total_raised = isset( $_POST['total-raised'] ) ? (int)sanitize_text_field( $_POST['total-raised'] ) : '';
$latest_round_type = isset( $_POST['latest-round-type'] ) ? (int)sanitize_text_field( $_POST['latest-round-type'] ) : '';
$technology_ids = isset( $_POST['technology_id'] ) ? ( $_POST['technology_id'] ) : '';
$ability_ids = isset( $_POST['ability_id'] ) ? ( $_POST['ability_id'] ) : '';
$tag_ids = isset( $_POST['tag_id'] ) ? ( $_POST['tag_id'] ) : '';
$industry_ids = isset( $_POST['industry_id'] ) ? ( $_POST['industry_id'] ) : '';
$industry_sub_ids = isset( $_POST['industry_sub_id'] ) ? ( $_POST['industry_sub_id'] ) : '';
$facebook = isset( $_POST['facebook'] ) ? ( $_POST['facebook'] ) : '';
......@@ -124,7 +124,7 @@ class Esi_Management_Entity_Form {
$industry_ids = array_merge($industry_ids, $industry_sub_ids);
esi_save_list_entity_technology($fields['id'], $technology_ids);
esi_save_list_entity_ability($fields['id'], $ability_ids);
esi_save_list_entity_tag($fields['id'], $tag_ids);
esi_save_list_entity_industry($fields['id'], $industry_ids);
if($is_ajax){
......
......@@ -297,22 +297,22 @@ function esi_save_list_entity_technology( $entityid = 0, $technologyids = array(
* Fetch technologies array
*
* @param int $entity_id
* @param array $ability_ids
* @param array $tag_ids
*
* @return array
*/
function esi_save_list_entity_ability( $entity_id = 0, $ability_ids = array() ) {
function esi_save_list_entity_tag( $entity_id = 0, $tag_ids = array() ) {
global $wpdb;
// Delete all current join from liaison table
$wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'esi_ability_entity WHERE entity_id = %d', $entityid));
$wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'esi_tag_entity WHERE entity_id = %d', $entityid));
// Insert new news_id ability_id relation
foreach ($ability_ids as $ability_id) {
// Insert new news_id tag_id relation
foreach ($tag_ids as $tag_id) {
$wpdb->insert(
$wpdb->prefix . "esi_ability_entity",
$wpdb->prefix . "esi_tag_entity",
array(
'ability_id' => $ability_id,
'tag_id' => $tag_id,
'entity_id' => intval($entity_id)
));
}
......@@ -325,17 +325,17 @@ function esi_save_list_entity_ability( $entity_id = 0, $ability_ids = array() )
*
* @return array
*/
function esi_get_list_selected_entity_ability( $id = 0, $output = 'object' ) {
function esi_get_list_selected_entity_tag( $id = 0, $output = 'object' ) {
global $wpdb;
// Get Selected technology mapping
$arrSelectedTechnology = $wpdb->get_results("SELECT * FROM " .$wpdb->prefix . "esi_ability_entity WHERE entity_id = " . $id, OBJECT_K);
$arrSelectedTechnology = $wpdb->get_results("SELECT * FROM " .$wpdb->prefix . "esi_tag_entity WHERE entity_id = " . $id, OBJECT_K);
if ($output == 'array') {
$array = array();
foreach ($arrSelectedTechnology as $selected) {
$array [] = $selected->ability_id;
$array [] = $selected->tag_id;
}
$arrSelectedTechnology = $array;
......@@ -385,7 +385,7 @@ function esi_save_list_entity_industry( $entity_id = 0, $industry_ids = array())
// Delete all current join from liaison table
$wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'esi_entity_industry WHERE entity_id = %d', $entity_id));
// Insert new news_id ability_id relation
// Insert new news_id tag_id relation
foreach ($industry_ids as $industry_id) {
$wpdb->insert(
$wpdb->prefix . "esi_entity_industry",
......
......@@ -22,8 +22,8 @@ $technologies = esi_get_all_list_technology();
$technologies_selected = esi_get_list_selected_entity_technology($id, 'array');
$investment_type = esi_get_all_investment_type(array('number' => 10000));
$entities = esi_get_all_entity(array('number' => 10000));
$abilities = esi_get_all_ability(array('number' => 10000));
$abilities_selected = esi_get_list_selected_entity_ability($id, 'array');
$tags = esi_get_all_tag(array('number' => 10000));
$tags_selected = esi_get_list_selected_entity_tag($id, 'array');
$industries_selected = esi_get_list_selected_entity_industry($id, 'array');
......@@ -209,14 +209,14 @@ add_thickbox();
</select><br />
</td>
</tr>
<tr class="row-ability-id">
<tr class="row-tag-id">
<th scope="row">
<label for="ability_id"><?php _e( 'Ability', 'esi' ); ?></label>
<label for="tag_id"><?php _e( 'Tag', 'esi' ); ?></label>
</th>
<td>
<select id="ability_id" class="chosen-select" name="ability_id[]" multiple="multiple">
<?php foreach ($abilities as $ability) : ?>
<option value="<?= $ability->id ?>" <?= (in_array($ability->id, $abilities_selected)) ? "selected='selected'" : ""?>><?= $ability->name ?></option>
<select id="tag_id" class="chosen-select" name="tag_id[]" multiple="multiple">
<?php foreach ($tags as $tag) : ?>
<option value="<?= $tag->id ?>" <?= (in_array($tag->id, $tags_selected)) ? "selected='selected'" : ""?>><?= $tag->name ?></option>
<?php endforeach; ?>
</select><br />
</td>
......
......@@ -47,12 +47,11 @@ class Esi_Management_News_Form {
$media_id = isset( $_POST['media_id'] ) ? intval( $_POST['media_id'] ) : '';
$type_id = isset( $_POST['type_id'] ) ? intval( $_POST['type_id'] ) : '';
$region_id = isset( $_POST['region_id'] ) ? intval( $_POST['region_id'] ) : '';
$investment_id = isset( $_POST['investment_id'] ) ? intval( $_POST['investment_id'] ) : '';
$industry_id = isset( $_POST['radar_industry'] ) ? $_POST['radar_industry'] : array();
$function_id = isset( $_POST['radar_function'] ) ? $_POST['radar_function'] : array();
$technology_ids = isset( $_POST['technology_sub_id'] ) ? $_POST['technology_sub_id'] : array();
$ability_ids = isset( $_POST['ability_id'] ) ? $_POST['ability_id'] : array();
$tag_ids = isset( $_POST['tag_id'] ) ? $_POST['tag_id'] : array();
$post_id = isset( $_POST['post_id'] ) ? intval( $_POST['post_id'] ) : '';
......@@ -82,10 +81,6 @@ class Esi_Management_News_Form {
$errors[] = __( 'Error: Type is required', 'esi' );
}
// if ( ! $investment_id ) {
// $errors[] = __( 'Error: Investment is required', 'esi' );
// }
if ( ! $region_id ) {
$errors[] = __( 'Error: Region is required', 'esi' );
}
......@@ -117,12 +112,11 @@ class Esi_Management_News_Form {
'entity_id' => $entity_id,
'media_id' => $media_id,
'type_id' => $type_id,
'investment_id' => $investment_id,
'region_id' => $region_id,
'industry_id' => $industry_id,
'function_id' => $function_id,
'technology_ids' => $technology_ids,
'ability_ids' => $ability_ids,
'tag_ids' => $tag_ids,
'post_id' => $post_id
);
......
......@@ -105,8 +105,8 @@ function esi_insert_new( $args = array() ) {
unset( $args['function_id'] );
$technology_ids = $args['technology_ids'];
unset( $args['technology_ids'] );
$ability_ids = $args['ability_ids'];
unset( $args['ability_ids'] );
$tag_ids = $args['tag_ids'];
unset( $args['tag_ids'] );
$radar_industry_id = esi_get_radar_by_industry($industry_id);
$radar_function_id = esi_get_radar_by_function($function_id);
......@@ -127,7 +127,7 @@ function esi_insert_new( $args = array() ) {
esi_save_news_industry($row_id, $industry_id);
esi_save_news_function($row_id, $function_id);
esi_save_list_technology_news($row_id, $technology_ids);
esi_save_list_news_ability($row_id, $ability_ids);
esi_save_list_news_tag($row_id, $tag_ids);
return $row_id;
}
......@@ -137,7 +137,7 @@ function esi_insert_new( $args = array() ) {
esi_save_news_industry($row_id, $industry_id);
esi_save_news_function($row_id, $function_id);
esi_save_list_technology_news($row_id, $technology_ids);
esi_save_list_news_ability($row_id, $ability_ids);
esi_save_list_news_tag($row_id, $tag_ids);
// do update method here
if ( $wpdb->update( $table_name, $args, array( 'id' => $row_id ) ) ) {
......@@ -382,22 +382,22 @@ function esi_get_list_selected_news_technology( $id = 0, $output = 'object' ) {
* Fetch technologies array
*
* @param int $news_id
* @param array $ability_ids
* @param array $tag_ids
*
* @return array
*/
function esi_save_list_news_ability( $news_id = 0, $ability_ids = array() ) {
function esi_save_list_news_tag( $news_id = 0, $tag_ids = array() ) {
global $wpdb;
// Delete all current join from liaison table
$wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'esi_ability_news WHERE news_id = %d', $news_id));
$wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'esi_tag_news WHERE news_id = %d', $news_id));
// Insert new news_id ability_id relation
foreach ($ability_ids as $ability_id) {
// Insert new news_id tag_id relation
foreach ($tag_ids as $tag_id) {
$wpdb->insert(
$wpdb->prefix . "esi_ability_news",
$wpdb->prefix . "esi_tag_news",
array(
'ability_id' => $ability_id,
'tag_id' => $tag_id,
'news_id' => intval($news_id)
));
}
......@@ -410,17 +410,17 @@ function esi_save_list_news_ability( $news_id = 0, $ability_ids = array() ) {
*
* @return array
*/
function esi_get_list_selected_news_ability( $id = 0, $output = 'object' ) {
function esi_get_list_selected_news_tag( $id = 0, $output = 'object' ) {
global $wpdb;
// Get Selected technology mapping
$arrSelectedTechnology = $wpdb->get_results("SELECT * FROM " .$wpdb->prefix . "esi_ability_news WHERE news_id = " . $id, OBJECT_K);
$arrSelectedTechnology = $wpdb->get_results("SELECT * FROM " .$wpdb->prefix . "esi_tag_news WHERE news_id = " . $id, OBJECT_K);
if ($output == 'array') {
$array = array();
foreach ($arrSelectedTechnology as $selected) {
$array [] = $selected->ability_id;
$array [] = $selected->tag_id;
}
$arrSelectedTechnology = $array;
......
......@@ -6,7 +6,7 @@
* @package Package
* @subpackage Sub Package
*/
class Esi_Management_Ability_Form {
class Esi_Management_Tag_Form {
/**
* Hook 'em all
......@@ -18,13 +18,13 @@ class Esi_Management_Ability_Form {
/**
* Handle the new ability and edit form
* Handle the new tag and edit form
*
* @return void
*/
public function handle_form($is_ajax = false) {
if ( !isset( $_POST['submit_ability'] ) && !$is_ajax ) {
if ( !isset( $_POST['submit_tag'] ) && !$is_ajax ) {
return;
}
......@@ -37,7 +37,7 @@ class Esi_Management_Ability_Form {
}
$errors = array();
$page_url = admin_url( 'admin.php?page=esi-management-ability' );
$page_url = admin_url( 'admin.php?page=esi-management-tag' );
$field_id = isset( $_POST['field_id'] ) ? intval( $_POST['field_id'] ) : 0;
$name = isset( $_POST['name'] ) ? sanitize_text_field( $_POST['name'] ) : '';
......@@ -70,7 +70,7 @@ class Esi_Management_Ability_Form {
// New or edit?
if ( ! $field_id ) {
$insert_id = esi_insert_ability( $fields );
$insert_id = esi_insert_tag( $fields );
$fields['id'] = $insert_id;
......@@ -78,7 +78,7 @@ class Esi_Management_Ability_Form {
$fields['id'] = $field_id;
$insert_id = esi_insert_ability( $fields );
$insert_id = esi_insert_tag( $fields );
}
if($is_ajax){
......@@ -96,4 +96,4 @@ class Esi_Management_Ability_Form {
}
}
new Esi_Management_Ability_Form();
new Esi_Management_Tag_Form();
......@@ -28,12 +28,12 @@ if ( ! class_exists ( 'WP_List_Table' ) ) {
/**
* List table class
*/
class Esi_Management_Ability_List extends \WP_List_Table {
class Esi_Management_Tag_List extends \WP_List_Table {
function __construct() {
parent::__construct( array(
'singular' => 'ability',
'plural' => 'ability',
'singular' => 'tag',
'plural' => 'tag',
'ajax' => false
) );
}
......@@ -48,7 +48,7 @@ class Esi_Management_Ability_List extends \WP_List_Table {
* @return void
*/
function no_items() {
_e( 'No ability found', 'esi' );
_e( 'No tag found', 'esi' );
}
/**
......@@ -98,10 +98,10 @@ class Esi_Management_Ability_List extends \WP_List_Table {
function column_name( $item ) {
$actions = array();
$actions['edit'] = sprintf( '<a href="%s" data-id="%d" name="%s">%s</a>', admin_url( 'admin.php?page=esi-management-ability&action=edit&id=' . $item->id ), $item->id, __( 'Edit this item', 'esi' ), __( 'Edit', 'esi' ) );
$actions['delete'] = sprintf( '<a href="%s" class="submitdelete" data-id="%d" name="%s">%s</a>', admin_url( 'admin.php?page=esi-management-ability&action=delete&id=' . $item->id ), $item->id, __( 'Delete this item', 'esi' ), __( 'Delete', 'esi' ) );
$actions['edit'] = sprintf( '<a href="%s" data-id="%d" name="%s">%s</a>', admin_url( 'admin.php?page=esi-management-tag&action=edit&id=' . $item->id ), $item->id, __( 'Edit this item', 'esi' ), __( 'Edit', 'esi' ) );
$actions['delete'] = sprintf( '<a href="%s" class="submitdelete" data-id="%d" name="%s">%s</a>', admin_url( 'admin.php?page=esi-management-tag&action=delete&id=' . $item->id ), $item->id, __( 'Delete this item', 'esi' ), __( 'Delete', 'esi' ) );
return sprintf( '<a href="%1$s"><strong>%2$s</strong></a> %3$s', admin_url( 'admin.php?page=esi-management-ability&action=view&id=' . $item->id ), $item->name, $this->row_actions( $actions ) );
return sprintf( '<a href="%1$s"><strong>%2$s</strong></a> %3$s', admin_url( 'admin.php?page=esi-management-tag&action=view&id=' . $item->id ), $item->name, $this->row_actions( $actions ) );
}
/**
......@@ -138,7 +138,7 @@ class Esi_Management_Ability_List extends \WP_List_Table {
*/
function column_cb( $item ) {
return sprintf(
'<input type="checkbox" name="ability_id[]" value="%d" />', $item->id
'<input type="checkbox" name="tag_id[]" value="%d" />', $item->id
);
}
......@@ -187,10 +187,10 @@ class Esi_Management_Ability_List extends \WP_List_Table {
$args['order'] = $_REQUEST['order'] ;
}
$this->items = esi_get_all_ability( $args );
$this->items = esi_get_all_tag( $args );
$this->set_pagination_args( array(
'total_items' => esi_get_ability_count(),
'total_items' => esi_get_tag_count(),
'per_page' => $per_page
) );
}
......
......@@ -3,7 +3,7 @@
/**
* Admin Menu
*/
class Esi_Management_Ability {
class Esi_Management_Tag {
/**
* The ID of this plugin.
......@@ -34,7 +34,7 @@ class Esi_Management_Ability {
$this->plugin_name = $plugin_name;
$this->version = $version;
// add_action( 'admin_menu_ability', array( $this, 'admin_menu' ) );
// add_action( 'admin_menu_tag', array( $this, 'admin_menu' ) );
}
......@@ -46,7 +46,7 @@ class Esi_Management_Ability {
// public function admin_menu() {
//
// /** Top Menu **/
// add_submenu_page( 'esi-management', __( 'ability', 'esi' ), __( 'ability', 'esi' ), 'manage_ability', 'esi-management-ability', array( $this, 'plugin_page' ) );
// add_submenu_page( 'esi-management', __( 'tag', 'esi' ), __( 'tag', 'esi' ), 'manage_tag', 'esi-management-tag', array( $this, 'plugin_page' ) );
// }
/**
......@@ -62,16 +62,16 @@ class Esi_Management_Ability {
case 'view':
case 'edit':
case 'new':
$template = dirname( __FILE__ ) . '/partials/esi-management-ability-form.php';
$template = dirname( __FILE__ ) . '/partials/esi-management-tag-form.php';
break;
case 'delete':
esi_delete_ability($id);
$template = dirname( __FILE__ ) . '/partials/esi-management-ability-list.php';
esi_delete_tag($id);
$template = dirname( __FILE__ ) . '/partials/esi-management-tag-list.php';
break;
default:
$template = dirname( __FILE__ ) . '/partials/esi-management-ability-list.php';
$template = dirname( __FILE__ ) . '/partials/esi-management-tag-list.php';
break;
}
......
<?php
/**
* Get all ability
* Get all tag
*
* @param $args array
*
* @return array
*/
function esi_get_all_ability( $args = array() ) {
function esi_get_all_tag( $args = array() ) {
global $wpdb;
$defaults = array(
......@@ -18,11 +18,11 @@ function esi_get_all_ability( $args = array() ) {
);
$args = wp_parse_args( $args, $defaults );
$cache_key = 'ability-all';
$cache_key = 'tag-all';
$items = wp_cache_get( $cache_key, 'esi' );
if ( false === $items ) {
$items = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . 'esi_ability ORDER BY ' . $args['orderby'] .' ' . $args['order'] .' LIMIT ' . $args['offset'] . ', ' . $args['number'] );
$items = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . 'esi_tag ORDER BY ' . $args['orderby'] .' ' . $args['order'] .' LIMIT ' . $args['offset'] . ', ' . $args['number'] );
wp_cache_set( $cache_key, $items, 'esi' );
}
......@@ -31,35 +31,35 @@ function esi_get_all_ability( $args = array() ) {
}
/**
* Fetch all ability from database
* Fetch all tag from database
*
* @return array
*/
function esi_get_ability_count() {
function esi_get_tag_count() {
global $wpdb;
return (int) $wpdb->get_var( 'SELECT COUNT(*) FROM ' . $wpdb->prefix . 'esi_ability' );
return (int) $wpdb->get_var( 'SELECT COUNT(*) FROM ' . $wpdb->prefix . 'esi_tag' );
}
/**
* Fetch a single ability from database
* Fetch a single tag from database
*
* @param int $id
*
* @return array
*/
function esi_get_ability( $id = 0 ) {
function esi_get_tag( $id = 0 ) {
global $wpdb;
return $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'esi_ability WHERE id = %d', $id ) );
return $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'esi_tag WHERE id = %d', $id ) );
}
/**
* Insert a ability ability
* Insert a tag tag
*
* @param array $args
*/
function esi_insert_ability( $args = array() ) {
function esi_insert_tag( $args = array() ) {
global $wpdb;
$defaults = array(
......@@ -70,7 +70,7 @@ function esi_insert_ability( $args = array() ) {
);
$args = wp_parse_args( $args, $defaults );
$table_name = $wpdb->prefix . 'esi_ability';
$table_name = $wpdb->prefix . 'esi_tag';
// some basic validation
if ( empty( $args['name'] ) ) {
......@@ -80,12 +80,12 @@ function esi_insert_ability( $args = array() ) {
return new WP_Error( 'no-description', __( 'No Description provided.', 'esi' ) );
}
// remove row id to determine if ability or update
// remove row id to determine if tag or update
$row_id = (int) $args['id'];
unset( $args['id'] );
if ( ! $row_id ) {
// insert a ability
// insert a tag
if ( $wpdb->insert( $table_name, $args ) ) {
return $wpdb->insert_id;
}
......@@ -107,7 +107,7 @@ function esi_insert_ability( $args = array() ) {
* @param int $id
*
*/
function esi_delete_ability( $id = 0 ) {
function esi_delete_tag( $id = 0 ) {
global $wpdb;
$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'esi_ability WHERE id = %d', $id ) );
$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'esi_tag WHERE id = %d', $id ) );
}
......@@ -13,17 +13,17 @@
*/
global $wpdb;
$item = esi_get_ability( $id );
$ability_list = esi_get_all_ability(array('number' => 1000));
$item = esi_get_tag( $id );
$tag_list = esi_get_all_tag(array('number' => 1000));
add_thickbox();
?>
<div class="wrap">
<?php if ($_GET['action'] == 'view'): ?>
<h1><?php _e( 'Update Ability', 'esi' ); ?> : <?= $item->name ?></h1>
<h1><?php _e( 'Update Tag', 'esi' ); ?> : <?= $item->name ?></h1>
<?php else: ?>
<h1><?php _e( 'Add Ability', 'esi' ); ?></h1>
<h1><?php _e( 'Add Tag', 'esi' ); ?></h1>
<?php endif; ?>
<form action="" method="post">
......@@ -35,7 +35,7 @@ add_thickbox();
<label for="name"><?php _e( 'Name', 'esi' ); ?></label>
</th>
<td>
<input type="text" name="name" id="name" class="regular-text" placeholder="<?php echo esc_attr( 'Add ability', 'esi' ); ?>" value="<?php echo ($item)?esc_attr( $item->name ):''; ?>" required="required" />
<input type="text" name="name" id="name" class="regular-text" placeholder="<?php echo esc_attr( 'Add tag', 'esi' ); ?>" value="<?php echo ($item)?esc_attr( $item->name ):''; ?>" required="required" />
</td>
</tr>
<tr class="row-description">
......@@ -52,8 +52,8 @@ add_thickbox();
</th>
<td>
<select id="parent" class="chosen-select" name="parent">
<?php foreach ($ability_list as $ability) : ?>
<option value="<?= $ability->id ?>" <?= ($ability->id == $item->parent) ? "selected='selected'" : ""?>><?= $ability->name ?></option>
<?php foreach ($tag_list as $tag) : ?>
<option value="<?= $tag->id ?>" <?= ($tag->id == $item->parent) ? "selected='selected'" : ""?>><?= $tag->name ?></option>
<?php endforeach; ?>
</select><br />
</td>
......@@ -65,9 +65,9 @@ add_thickbox();
<?php wp_nonce_field( '' ); ?>
<?php if ($_GET['action'] == 'view'): ?>
<?php submit_button( __( 'Update ability', 'esi' ), 'primary', 'submit ability' ); ?>
<?php submit_button( __( 'Update tag', 'esi' ), 'primary', 'submit tag' ); ?>
<?php else: ?>
<?php submit_button( __( 'Add ability', 'esi' ), 'primary', 'submit ability' ); ?>
<?php submit_button( __( 'Add tag', 'esi' ), 'primary', 'submit tag' ); ?>
<?php endif; ?>
</form>
</div>
......@@ -16,13 +16,13 @@
<!-- This file should primarily consist of HTML with a little bit of PHP. -->
<div class="wrap">
<h2><?php _e( 'Ability List', 'esi' ); ?> <a href="<?php echo admin_url( 'admin.php?page=esi-management-ability&action=new' ); ?>" class="add-new-h2"><?php _e( 'Add New', 'esi' ); ?></a></h2>
<h2><?php _e( 'Tag List', 'esi' ); ?> <a href="<?php echo admin_url( 'admin.php?page=esi-management-tag&action=new' ); ?>" class="add-new-h2"><?php _e( 'Add New', 'esi' ); ?></a></h2>
<form method="post">
<input type="hidden" name="page" value="ttest_list_table">
<?php
$list_table = new Esi_Management_Ability_List();
$list_table = new Esi_Management_Tag_List();
$list_table->prepare_items();
$list_table->search_box( 'search', 'search_id' );
$list_table->display();
......
......@@ -53,6 +53,15 @@ class Esi_Management_Activator {
)";
dbDelta( $sql );
// Create Radar Industry liaison table
$table_name = $wpdb->prefix . 'esi_radar_entity';
$sql = "CREATE TABLE $table_name (
radar_id INT NOT NULL,
entity_id INT NOT NULL,
PRIMARY KEY (radar_id, entity_id)
)";
dbDelta( $sql );
// Create Industry table
$table_name = $wpdb->prefix . 'esi_industry';
......@@ -92,7 +101,6 @@ class Esi_Management_Activator {
url varchar(2083) NOT NULL,
media_id INT(11) NOT NULL,
company_id INT(11) NOT NULL,
investment_id INT(11) NOT NULL,
type_id INT(11) NOT NULL,
region_id INT(11) NOT NULL,
post_id BIGINT(20) NOT NULL,
......@@ -120,12 +128,32 @@ class Esi_Management_Activator {
)";
dbDelta( $sql );
// Create News Function liaison table
$table_name = $wpdb->prefix . 'esi_news_function';
// Create News Entity liaison table
$table_name = $wpdb->prefix . 'esi_news_entity';
$sql = "CREATE TABLE $table_name (
news_id INT NOT NULL,
function_id INT NOT NULL,
PRIMARY KEY (news_id, function_id)
entity_id INT NOT NULL,
PRIMARY KEY (news_id, entity_id)
)";
dbDelta( $sql );
// Create News Radar liaison table
$table_name = $wpdb->prefix . 'esi_news_radar';
$sql = "CREATE TABLE $table_name (
news_id INT NOT NULL,
radar_id INT NOT NULL,
PRIMARY KEY (news_id, radar_id)
)";
dbDelta( $sql );
// Create Technology table
$table_name = $wpdb->prefix . 'esi_technology';
$sql = "CREATE TABLE $table_name (
id INT NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL,
description text NOT NULL,
parent INT(11) NOT NULL,
PRIMARY KEY (id)
)";
dbDelta( $sql );
......@@ -216,7 +244,7 @@ class Esi_Management_Activator {
dbDelta( $sql );
// Create Ability table
$table_name = $wpdb->prefix . 'esi_ability';
$table_name = $wpdb->prefix . 'esi_tag';
$sql = "CREATE TABLE $table_name (
id INT NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL,
......@@ -227,21 +255,21 @@ class Esi_Management_Activator {
dbDelta( $sql );
// Create Ability Entity liaison table
$table_name = $wpdb->prefix . 'esi_ability_entity';
$table_name = $wpdb->prefix . 'esi_tag_entity';
$sql = "CREATE TABLE $table_name (
ability_id INT NOT NULL,
tag_id INT NOT NULL,
entity_id INT NOT NULL,
PRIMARY KEY (ability_id, entity_id)
PRIMARY KEY (tag_id, entity_id)
)";
dbDelta( $sql );
// Create Ability News liaison table
$table_name = $wpdb->prefix . 'esi_ability_news';
$table_name = $wpdb->prefix . 'esi_tag_news';
$sql = "CREATE TABLE $table_name (
ability_id INT NOT NULL,
tag_id INT NOT NULL,
news_id INT NOT NULL,
PRIMARY KEY (ability_id, news_id)
PRIMARY KEY (tag_id, news_id)
)";
dbDelta( $sql );
......
......@@ -120,7 +120,7 @@ class Esi_Management {
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/modules/investment/functions-investment.php';
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/modules/investment-type/functions-investment-type.php';
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/modules/region/functions-region.php';
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/modules/ability/functions-ability.php';
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/modules/ability/functions-tag.php';
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/modules/patent/functions-patent.php';
// Default
......@@ -167,9 +167,9 @@ class Esi_Management {
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/modules/region/class-esi-management-region-form.php';
// Ability
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/modules/ability/class-esi-management-ability.php';
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/modules/ability/class-esi-management-ability-list.php';
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/modules/ability/class-esi-management-ability-form.php';
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/modules/ability/class-esi-management-tag.php';
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/modules/ability/class-esi-management-tag-list.php';
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/modules/ability/class-esi-management-tag-form.php';
// Patent
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/modules/patent/class-esi-management-patent.php';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment