Example #1
0
 /**
  * Generates the sibling categories, it also compiles the $custom_category_color_css and adds it to the footer css buffer
  * @param string $params_array
  *
  *  array(
  *       'current_category_css' => '
  *           <style>
  *              // the css style to compile
  *           </style>
  *       ',
  *           'show_background_color' => true - if true, the theme will output inline css to color the background color
  *       )
  *
  * @return string
  * @throws ErrorException
  */
 protected function get_sibling_categories($params_array = '')
 {
     $buffy = '';
     //the subcategories
     if (!empty($this->current_category_obj->cat_ID)) {
         if ($this->current_category_obj->parent === 0) {
             // get child categories
             $categories_objects = get_categories(array('parent' => $this->current_category_obj->cat_ID, 'hide_empty' => 0, 'number' => self::SIBLING_CATEGORY_LIMIT));
         }
         // if no child categories get siblings
         if (empty($categories_objects)) {
             $categories_objects = get_categories(array('parent' => $this->current_category_obj->parent, 'hide_empty' => 0, 'number' => self::SIBLING_CATEGORY_LIMIT));
         }
     }
     /**
      * if we have categories to show... show them
      */
     if (!empty($categories_objects)) {
         $buffy = '<div class="td-category-siblings">';
         $buffy .= '<ul class="td-category">';
         foreach ($categories_objects as $category_object) {
             // ignore featured cat and uncategorized
             if ($category_object->name == TD_FEATURED_CAT or strtolower($category_object->cat_name) == 'uncategorized') {
                 continue;
             }
             if (!empty($category_object->name) and td_util::get_category_option($category_object->cat_ID, 'tdc_hide_on_post') != 'hide') {
                 $class = '';
                 if ($category_object->cat_ID == $this->current_category_id) {
                     $class = 'td-current-sub-category';
                 }
                 $td_css_inline = new td_css_inline();
                 // @todo we can add more properties as needed, ex: show_border_color
                 if (!empty($params_array['show_background_color'])) {
                     $tdc_color_current_cat = td_util::get_category_option($category_object->cat_ID, 'tdc_color');
                     $td_css_inline->add_css(array('background-color' => $tdc_color_current_cat));
                 }
                 $buffy .= '<li class="entry-category"><a ' . $td_css_inline->get_inline_css() . ' class="' . $class . '"  href="' . get_category_link($category_object->cat_ID) . '">' . $category_object->name . '</a></li>';
             }
         }
         $buffy .= '</ul>';
         // subcategory dropdown list
         $buffy .= '<div class="td-subcat-dropdown td-pulldown-filter-display-option">';
         $buffy .= '<div class="td-subcat-more"><i class="td-icon-menu-down"></i></div>';
         // the dropdown list
         $buffy .= '<ul class="td-pulldown-filter-list">';
         $buffy .= '</ul>';
         $buffy .= '</div>';
         $buffy .= '<div class="clearfix"></div>';
         $buffy .= '</div>';
     }
     // compile the custom css
     if (!empty($params_array['current_category_css'])) {
         $tdc_color = td_util::get_category_option($this->current_category_obj->cat_ID, 'tdc_color');
         $td_css_compiler = new td_css_compiler($params_array['current_category_css']);
         $td_css_compiler->load_setting_raw('current_category_color', $tdc_color);
         td_css_buffer::add_to_footer($td_css_compiler->compile_css());
     }
     return $buffy;
 }
 /**
  * we emulate the WordPress background function using our own setting
  * @return string - the new css
  */
 private function add_css_custom_background()
 {
     $css_array = array();
     //color handling
     if (!empty($this->background_parameters['theme_bg_color'])) {
         $css_array['background-color'] = $this->background_parameters['theme_bg_color'];
     }
     // image handling; if there is no image stretching
     if (!empty($this->background_parameters['theme_bg_image']) and $this->background_parameters['is_stretched_bg'] == false) {
         //add the image
         $css_array['background-image'] = 'url("' . $this->background_parameters['theme_bg_image'] . '")';
         //repeat image option
         switch ($this->background_parameters['theme_bg_repeat']) {
             case '':
                 $css_array['background-repeat'] = 'no-repeat';
                 break;
             case 'repeat':
                 //$css.= "\n" . 'background-repeat:repeat;';//default value `background-repeat`
                 break;
             case 'repeat-x':
                 $css_array['background-repeat'] = 'repeat-x';
                 break;
             case 'repeat-y':
                 $css_array['background-repeat'] = 'repeat-y';
                 break;
         }
         //end switch
         //position image option
         switch ($this->background_parameters['theme_bg_position']) {
             case '':
                 //$css.= "\n" . 'background-position:left top;';//default value `background-position`
                 break;
             case 'center':
                 $css_array['background-position'] = 'center top';
                 break;
             case 'right':
                 $css_array['background-position'] = 'right top';
                 break;
         }
         //end switch
         //background attachment options
         switch ($this->background_parameters['theme_bg_attachment']) {
             case '':
                 //$css.= "\n" . 'background-attachment:scroll;';//default value `background-attachment`
                 break;
             case 'fixed':
                 $css_array['background-attachment'] = 'fixed';
                 break;
         }
         //end switch
     }
     $td_css_inline = new td_css_inline();
     $td_css_inline->add_css($css_array);
     return $td_css_inline->get_css_for_selector('body');
 }
Example #3
0
    static function html_editor($params_array)
    {
        $buffy = '';
        if (!empty($params_array['value'])) {
            $control_value = $params_array['value'];
        } else {
            //get control option from database
            $control_value = stripcslashes(td_panel_data_source::read($params_array));
        }
        $td_css_inline = new td_css_inline();
        if (!empty($params_array['css'])) {
            $td_css_inline->add_css($params_array['css']);
        }
        $editor_uid = td_global::td_generate_unique_id();
        $editor_text_uid = $editor_uid . '_text';
        ob_start();
        ?>
        <div class="td-code-editor-wrap td-html-editor-wrap">
            <textarea class="td-code-editor-textarea <?php 
        echo $editor_text_uid;
        ?>
" name="<?php 
        echo self::generate_name($params_array);
        ?>
"><?php 
        echo $control_value;
        ?>
</textarea>
            <div id="<?php 
        echo $editor_uid;
        ?>
" class="td-code-editor" <?php 
        echo $td_css_inline->get_inline_css();
        ?>
></div>
            <div class="td-clear-fix"></div>
        </div>
        <script>
            (function (){
                var editor_textarea = jQuery('.<?php 
        echo $editor_text_uid;
        ?>
');
                ace.require("ace/ext/language_tools");
                var editor = ace.edit("<?php 
        echo $editor_uid;
        ?>
");
                editor.getSession().setValue(editor_textarea.val());
                editor.getSession().on('change', function(){
                    editor_textarea.val(editor.getSession().getValue());
                });

                editor.setTheme("ace/theme/textmate");
                //editor.setShowPrintMargin(false);
                editor.getSession().setMode("ace/mode/html");
                editor.setOptions({
                    enableBasicAutocompletion: true,
                    enableSnippets: true,
                    enableLiveAutocompletion: false
                });
            })();
        </script>
        <?php 
        $buffy .= ob_get_clean();
        return $buffy;
    }