<?php

class dataInstallTaxMetas{

    public $tax_numbers;
    public $tax_strings;

    function addToWP(){
        global $wpdb;
        $prefix = $wpdb->prefix;

        @mysql_query( "DELETE FROM `".$prefix."gen_options` WHERE `namespace` LIKE 'cm-cat-opt-%'" );
        @mysql_query( "DELETE FROM `".$prefix."gen_options` WHERE `namespace` LIKE 'cm-sin-opt-%'" );

        $values = array();

        // taxonomies meta numbers
        foreach ($this->tax_numbers as $key=>$data) {
            $tax = ffGetByTitle::term( $data['ns_2'] );
            $values[] = " ('".$data['name']."', '".$data['value']."', '".$data['ns_1'].$tax."') ";
        }

        foreach ($this->tax_strings as $key=>$data) {
            $values[] = " ('".$data['name']."', '".$data['value']."', '".$data['namespace']."')" ;
        }

        mysql_query( "INSERT INTO `".$prefix."gen_options` (`name`, `value`, `namespace`)
                            VALUES " . implode(" , ", $values) );
    }

    function __construct( ){

        $this->tax_numbers = array(
            array('ns_1' => 'cm-cat-opt-','ns_2' => 'Uncategorized','name' => 'category_template','value' => 'blog/blog-sidebar.php'),
            array('ns_1' => 'cm-cat-opt-','ns_2' => 'Blog','name' => 'category_template','value' => 'blog/blog-sidebar.php'),
            array('ns_1' => 'cm-cat-opt-','ns_2' => 'Blog','name' => 'single_template','value' => 'single-blog/single-sidebar.php'),
            array('ns_1' => 'cm-cat-opt-','ns_2' => 'Portfolio','name' => 'category_template','value' => 'portfolio/portfolio-sidebar.php'),
            array('ns_1' => 'cm-cat-opt-','ns_2' => 'Portfolio','name' => 'clickable_title','value' => '1'),
            array('ns_1' => 'cm-cat-opt-','ns_2' => 'Portfolio','name' => 'custom_sidebar','value' => 'default'),
            array('ns_1' => 'cm-cat-opt-','ns_2' => 'Portfolio','name' => 'order','value' => 'default'),
            array('ns_1' => 'cm-cat-opt-','ns_2' => 'Portfolio','name' => 'order_by','value' => 'default'),
            array('ns_1' => 'cm-cat-opt-','ns_2' => 'Portfolio','name' => 'postmeta_category','value' => '1'),
            array('ns_1' => 'cm-cat-opt-','ns_2' => 'Portfolio','name' => 'posts_per_page','value' => '3'),
            array('ns_1' => 'cm-cat-opt-','ns_2' => 'Portfolio','name' => 'show_readmore_button','value' => '1'),
            array('ns_1' => 'cm-cat-opt-','ns_2' => 'Portfolio','name' => 'single_template','value' => 'single-blog/single-sidebar.php'),
            array('ns_1' => 'cm-cat-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'category_template','value' => 'portfolio/portfolio-fullwidth.php'),
            array('ns_1' => 'cm-cat-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'clickable_title','value' => '1'),
            array('ns_1' => 'cm-cat-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'custom_sidebar','value' => 'default'),
            array('ns_1' => 'cm-cat-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'order','value' => 'default'),
            array('ns_1' => 'cm-cat-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'order_by','value' => 'default'),
            array('ns_1' => 'cm-cat-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'postmeta_category','value' => '1'),
            array('ns_1' => 'cm-cat-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'posts_per_page','value' => '3'),
            array('ns_1' => 'cm-cat-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'show_readmore_button','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio','name' => 'fw_sin_action_button','value' => ''),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio','name' => 'fw_sin_action_button_link','value' => ''),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio','name' => 'fw_sin_action_left','value' => ''),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio','name' => 'fw_sin_action_right','value' => ''),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio','name' => 'fw_sin_action_show','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio','name' => 'fw_sin_clickable_image','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio','name' => 'fw_sin_clickable_title','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio','name' => 'fw_sin_custom_sidebar','value' => 'default'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio','name' => 'fw_sin_description_show','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio','name' => 'fw_sin_description_text','value' => ''),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio','name' => 'fw_sin_enable_comments','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio','name' => 'fw_sin_enable_date','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio','name' => 'fw_sin_main_image_height','value' => '0'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio','name' => 'fw_sin_open_image_in_lightbox','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio','name' => 'fw_sin_postmeta_author','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio','name' => 'fw_sin_postmeta_category','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio','name' => 'fw_sin_postmeta_tags','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio','name' => 'fw_sin_sidebar_position','value' => 'right'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio','name' => 'single_template','value' => ''),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'fw_sin_action_button','value' => ''),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'fw_sin_action_button_link','value' => ''),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'fw_sin_action_left','value' => ''),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'fw_sin_action_right','value' => ''),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'fw_sin_action_show','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'fw_sin_clickable_image','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'fw_sin_clickable_title','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'fw_sin_custom_sidebar','value' => 'default'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'fw_sin_description_show','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'fw_sin_description_text','value' => ''),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'fw_sin_enable_comments','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'fw_sin_enable_date','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'fw_sin_main_image_height','value' => '0'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'fw_sin_open_image_in_lightbox','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'fw_sin_postmeta_author','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'fw_sin_postmeta_category','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'fw_sin_postmeta_tags','value' => '1'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'fw_sin_sidebar_position','value' => 'right'),
            array('ns_1' => 'cm-sin-opt-','ns_2' => 'Portfolio Fullwidth','name' => 'single_template','value' => '')
        );


        $this->tax_strings = array(
            array('namespace' => 'cm-cat-opt-index','name' => 'category_template','value' => 'blog/blog-sidebar.php'),
            array('namespace' => 'cm-cat-opt-archive','name' => 'category_template','value' => 'blog/blog-sidebar.php'),
            array('namespace' => 'cm-cat-opt-search','name' => 'category_template','value' => 'blog/blog-sidebar.php')
        );


    }
}
