<?php

/**
 * @todo remove this hack - this view has to be rebuilt
 */
$td_panel_custom_typography_ajax = new td_panel_custom_typography_ajax();
echo $td_panel_custom_typography_ajax->td_custom_typology_generate_font_controls();
class td_panel_custom_typography_ajax
{
    //class variable
    var $td_typology_fonts_array;
    var $td_font_size_list;
    var $td_line_height_list;
    var $td_font_style_list;
    var $td_font_weight;
    var $td_text_transform;
    function __construct($post = '')
    {
        //create typology_fonts_array
        $this->td_typology_fonts_array = $this->td_create_custom_typology_fonts_array();
        //create font_size_list
        $this->td_font_size_list = $this->get_font_size_list();
        //create line_height_list
        $this->td_line_height_list = $this->get_line_height_list();
        //create font_style_list
        $this->td_font_style_list = $this->get_td_font_style_list();
        //create font_style_list
        $this->td_font_weight = $this->get_td_font_weight();
        //create text_transform
        $this->td_text_transform = $this->get_td_text_transform();
    }
 static function ajax_view_controller()
 {
     //if user is logged in and can switch themes
     if (current_user_can('switch_themes')) {
         // what view to load?
         $td_ajax_view = td_util::get_http_post_val('td_ajax_view');
         $buffy = '';
         switch ($td_ajax_view) {
             //@todo trebuie refacuta
             case 'td_thumbs':
                 require_once 'ajax_views/td_block_settings_ajax.php';
                 $buffy = td_block_settings_ajax::thumbs_panel();
                 break;
             case 'td_category':
                 require_once 'ajax_views/td_category.php';
                 $buffy = td_category_form_ajax(td_util::get_http_post_val('category_id'));
                 break;
             case 'td_translations':
                 require_once 'ajax_views/td_translations.php';
                 $buffy = td_translations_form_ajax();
                 break;
             case 'td_theme_fonts':
                 //start section
                 $td_start_section = intval(json_decode($_POST['start_section']));
                 //end section
                 $td_end_section = intval(json_decode($_POST['end_section']));
                 require_once 'ajax_views/td_theme_fonts.php';
                 $object_custom_typography_ajax = new td_panel_custom_typography_ajax();
                 $buffy = $object_custom_typography_ajax->td_custom_typology_generate_font_controls(array($td_start_section, $td_end_section));
                 break;
         }
         // each panel has to have a td-clear at the end
         $buffy .= '<div class="td-clear"></div>';
         //return the view counts
         die(json_encode($buffy));
     } else {
         die;
     }
     //end if user can switch themes
 }
 static function ajax_view_panel_loading()
 {
     //if user is logged in and can switch themes
     if (current_user_can('switch_themes')) {
         //DECODE PANEL PARAMS
         //json decode ajax_view
         if (!empty($_POST['td_ajax_view'])) {
             $td_ajax_view = $_POST['td_ajax_view'];
             //json_decode(stripslashes($_POST['td_view']), true);//didn't work with json_decode
         }
         //json decode category_id (used by category panel)
         if (!empty($_POST['category_id'])) {
             $td_category_id = json_decode(stripslashes($_POST['category_id']), true);
         }
         //json decode category_id (used by typography panel)
         if (!empty($_POST['section_id'])) {
             $td_section_id = $_POST['section_id'];
             //$td_section_id = json_decode(stripslashes($_POST['section_id']), true);//didn't work with json_decode
         }
         //FORMAT PANEL AND SEND DATA BACK
         $buffy = '';
         switch ($td_ajax_view) {
             case 'td_category':
                 include_once 'ajax_views/td_category.php';
                 $buffy = td_category_form_ajax($td_category_id) . '<div class="td-clear"></div>';
                 break;
             case 'td_translations':
                 include_once 'ajax_views/td_translations.php';
                 $buffy = td_translations_form_ajax() . '<div class="td-clear"></div>';
                 break;
             case 'td_theme_fonts':
                 if (!empty($td_section_id)) {
                     include_once 'ajax_views/td_theme_fonts.php';
                     //call the generate function to create the fonts control pannel
                     $object_custom_typography_ajax = new td_panel_custom_typography_ajax();
                     $buffy = $object_custom_typography_ajax->td_custom_typology_generate_font_controls($td_section_id) . '<div class="td-clear"></div>';
                 }
                 break;
         }
         //return the view counts
         die(json_encode($buffy));
     } else {
         die;
     }
     //end if user can switch themes
 }